11import argparse
2- from teleop_demo_python .hardware .dynamixel import DynamixelHeadController
3- from teleop_demo_python .utils .pico_client import PicoClient
4- from teleop_demo_python .hardware .ur import DualArmURController
5-
62import threading
3+ import time
4+
5+ from teleop_demo_python .hardware import (
6+ DualArmURController ,
7+ DynamixelHeadController ,
8+ )
9+ from teleop_demo_python .utils .pico_client import PicoClient
710
811
912def main ():
10- parser = argparse .ArgumentParser (
11- description = "Run head and dual arm teleoperation control."
12- )
13+ parser = argparse .ArgumentParser (description = "Run head and dual arm teleoperation control." )
1314 parser .add_argument (
1415 "--reset" ,
1516 action = "store_true" ,
@@ -18,11 +19,8 @@ def main():
1819 args = parser .parse_args ()
1920
2021 pico_client = PicoClient ()
21-
22- # Initialize controllers after parsing args, in case reset needs them
23- # Or, if reset can be done without full init, adjust accordingly
2422 head_controller = DynamixelHeadController (pico_client )
25- arm_controller = DualArmURController (pico_client )
23+ arm_controller = DualArmURController (pico_client , visualize_placo = False )
2624
2725 if args .reset :
2826 print ("Reset flag detected. Running arm controller reset procedure..." )
@@ -31,7 +29,6 @@ def main():
3129 print ("Arm controller reset procedure completed." )
3230 except Exception as e :
3331 print (f"Error during arm_controller.reset(): { e } " )
34-
3532 else :
3633 print ("No reset flag detected. Proceeding with normal operation." )
3734 arm_controller .calc_target_joint_position ()
@@ -49,22 +46,28 @@ def main():
4946 target = arm_controller .run_right_controller_thread ,
5047 args = (stop_signal ,),
5148 )
49+ ik_thread = threading .Thread (
50+ target = arm_controller .run_ik_thread ,
51+ args = (stop_signal ,),
52+ )
5253
5354 # Start the threads
5455 head_thread .start ()
5556 left_arm_thread .start ()
5657 right_arm_thread .start ()
58+ ik_thread .start ()
5759
5860 while not stop_signal .is_set ():
5961 try :
60- arm_controller . calc_target_joint_position ( )
62+ time . sleep ( 0.01 )
6163 except KeyboardInterrupt :
6264 print ("KeyboardInterrupt detected. Exiting..." )
6365 stop_signal .set () # Trigger the stop signal for all threads
6466
6567 head_thread .join ()
6668 left_arm_thread .join ()
6769 right_arm_thread .join ()
70+ ik_thread .join ()
6871
6972 head_controller .close ()
7073 arm_controller .close ()
0 commit comments