Skip to content

Commit 1402c40

Browse files
committed
bug fix for head control jittering in head_and_arm_control_demo; refractored code to separate generic dynamixel and ur controller and lab demo hardware specific setup into different files
1 parent c58a11f commit 1402c40

File tree

9 files changed

+614
-653
lines changed

9 files changed

+614
-653
lines changed

scripts/arm_control.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from teleop_demo_python.hardware.ur import DualArmURController
1+
from teleop_demo_python.hardware import DualArmURController
22
from teleop_demo_python.utils.pico_client import PicoClient
33

44

scripts/head_and_arm_control_demo.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import 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-
62
import 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

912
def 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()

scripts/head_control.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from teleop_demo_python.hardware.dynamixel import DynamixelHeadController
2-
from teleop_demo_python.utils.pico_client import PicoClient
3-
4-
import time
51
import threading
2+
import time
3+
4+
from teleop_demo_python.hardware import DynamixelHeadController
5+
from teleop_demo_python.utils.pico_client import PicoClient
66

77

88
def main():
@@ -20,7 +20,7 @@ def main():
2020

2121
while True:
2222
try:
23-
time.sleep(0.1)
23+
time.sleep(0.01)
2424
except KeyboardInterrupt:
2525
print("Stopping head control...")
2626
stop_signal.set()
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from teleop_demo_python.hardware.dual_arm_ur_controller import (
2+
DualArmURController,
3+
)
4+
from teleop_demo_python.hardware.dynamixel import DynamixelController
5+
from teleop_demo_python.hardware.dynamixel_head_controller import (
6+
DynamixelHeadController,
7+
)
8+
from teleop_demo_python.hardware.ur import URController

0 commit comments

Comments
 (0)