mirror of
https://github.com/huggingface/lerobot.git
synced 2026-07-24 02:06:15 +00:00
reverse
This commit is contained in:
@@ -296,27 +296,22 @@ class OpenArmsMini(Teleoperator):
|
|||||||
right_motors_to_flip = ["joint_1", "joint_2", "joint_3", "joint_4", "joint_5"]
|
right_motors_to_flip = ["joint_1", "joint_2", "joint_3", "joint_4", "joint_5"]
|
||||||
left_motors_to_flip = ["joint_1", "joint_3", "joint_4", "joint_5", "joint_6", "joint_7"]
|
left_motors_to_flip = ["joint_1", "joint_3", "joint_4", "joint_5", "joint_6", "joint_7"]
|
||||||
|
|
||||||
# Joint mapping: teleop joint -> robot joint (swap 6 and 7)
|
|
||||||
joint_map = {"joint_6": "joint_7", "joint_7": "joint_6"}
|
|
||||||
|
|
||||||
# Read positions from both arms
|
# Read positions from both arms
|
||||||
right_positions = self.bus_right.sync_read("Present_Position")
|
right_positions = self.bus_right.sync_read("Present_Position")
|
||||||
left_positions = self.bus_left.sync_read("Present_Position")
|
left_positions = self.bus_left.sync_read("Present_Position")
|
||||||
|
|
||||||
# Combine into single action dict with arm prefixes, flip and map joints
|
# Combine into single action dict with arm prefixes and flip specified motors
|
||||||
action = {}
|
action = {}
|
||||||
for motor, val in right_positions.items():
|
for motor, val in right_positions.items():
|
||||||
robot_joint = joint_map.get(motor, motor)
|
|
||||||
if motor in right_motors_to_flip:
|
if motor in right_motors_to_flip:
|
||||||
action[f"right_{robot_joint}.pos"] = -val
|
action[f"right_{motor}.pos"] = -val
|
||||||
else:
|
else:
|
||||||
action[f"right_{robot_joint}.pos"] = val
|
action[f"right_{motor}.pos"] = val
|
||||||
for motor, val in left_positions.items():
|
for motor, val in left_positions.items():
|
||||||
robot_joint = joint_map.get(motor, motor)
|
|
||||||
if motor in left_motors_to_flip:
|
if motor in left_motors_to_flip:
|
||||||
action[f"left_{robot_joint}.pos"] = -val
|
action[f"left_{motor}.pos"] = -val
|
||||||
else:
|
else:
|
||||||
action[f"left_{robot_joint}.pos"] = val
|
action[f"left_{motor}.pos"] = val
|
||||||
|
|
||||||
dt_ms = (time.perf_counter() - start) * 1e3
|
dt_ms = (time.perf_counter() - start) * 1e3
|
||||||
logger.debug(f"{self} read action: {dt_ms:.1f}ms")
|
logger.debug(f"{self} read action: {dt_ms:.1f}ms")
|
||||||
@@ -333,9 +328,6 @@ class OpenArmsMini(Teleoperator):
|
|||||||
right_motors_to_flip = ["joint_1", "joint_2", "joint_3", "joint_4", "joint_5"]
|
right_motors_to_flip = ["joint_1", "joint_2", "joint_3", "joint_4", "joint_5"]
|
||||||
left_motors_to_flip = ["joint_1", "joint_3", "joint_4", "joint_5", "joint_6", "joint_7"]
|
left_motors_to_flip = ["joint_1", "joint_3", "joint_4", "joint_5", "joint_6", "joint_7"]
|
||||||
|
|
||||||
# Joint mapping: robot joint -> teleop joint (swap 6 and 7)
|
|
||||||
joint_map = {"joint_6": "joint_7", "joint_7": "joint_6"}
|
|
||||||
|
|
||||||
# Split feedback by arm and flip motors as needed
|
# Split feedback by arm and flip motors as needed
|
||||||
right_positions = {}
|
right_positions = {}
|
||||||
left_positions = {}
|
left_positions = {}
|
||||||
@@ -345,20 +337,16 @@ class OpenArmsMini(Teleoperator):
|
|||||||
motor_name = key.removesuffix(".pos")
|
motor_name = key.removesuffix(".pos")
|
||||||
if motor_name.startswith("right_"):
|
if motor_name.startswith("right_"):
|
||||||
base_name = motor_name.removeprefix("right_")
|
base_name = motor_name.removeprefix("right_")
|
||||||
# Apply joint mapping (swap 6↔7)
|
if base_name in right_motors_to_flip:
|
||||||
teleop_joint = joint_map.get(base_name, base_name)
|
right_positions[base_name] = -val
|
||||||
if teleop_joint in right_motors_to_flip:
|
|
||||||
right_positions[teleop_joint] = -val
|
|
||||||
else:
|
else:
|
||||||
right_positions[teleop_joint] = val
|
right_positions[base_name] = val
|
||||||
elif motor_name.startswith("left_"):
|
elif motor_name.startswith("left_"):
|
||||||
base_name = motor_name.removeprefix("left_")
|
base_name = motor_name.removeprefix("left_")
|
||||||
# Apply joint mapping (swap 6↔7)
|
if base_name in left_motors_to_flip:
|
||||||
teleop_joint = joint_map.get(base_name, base_name)
|
left_positions[base_name] = -val
|
||||||
if teleop_joint in left_motors_to_flip:
|
|
||||||
left_positions[teleop_joint] = -val
|
|
||||||
else:
|
else:
|
||||||
left_positions[teleop_joint] = val
|
left_positions[base_name] = val
|
||||||
|
|
||||||
# Write positions to both arms
|
# Write positions to both arms
|
||||||
if right_positions:
|
if right_positions:
|
||||||
|
|||||||
Reference in New Issue
Block a user