You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

teleoperate_real_robot.py 934 B

123456789101112131415161718192021222324252627282930
  1. """Module for teleoperating a physical robot.
  2. This module provides functionality for controlling a physical robot through
  3. teleoperation, allowing real-time control of robot movements and actions.
  4. """
  5. from dynamixel import Dynamixel
  6. from robot import Robot
  7. leader_dynamixel = Dynamixel.Config(
  8. baudrate=1_000_000, device_name="/dev/ttyDXL_master_right",
  9. ).instantiate()
  10. follower_dynamixel = Dynamixel.Config(
  11. baudrate=1_000_000, device_name="/dev/ttyDXL_puppet_right",
  12. ).instantiate()
  13. follower = Robot(follower_dynamixel, servo_ids=[1, 2, 3, 4, 5, 6, 7, 8])
  14. leader = Robot(leader_dynamixel, servo_ids=[1, 2, 3, 4, 5, 6, 7, 8])
  15. # leader.set_trigger_torque()
  16. import time
  17. times_rec = []
  18. times_send = []
  19. while True:
  20. now = time.time()
  21. pos = leader.read_position()
  22. # print(f"Time to rec pos: {(time.time() - now) * 1000}")
  23. follower.set_goal_pos(pos)
  24. print(f"Time to send pos: {(time.time() - now) * 1000}")