Skip to content

Commit 86c5ad7

Browse files
authored
ROS: Swap left and right EE in EE topic (#385)
1 parent af72817 commit 86c5ad7

2 files changed

Lines changed: 26 additions & 26 deletions

File tree

examples/teleop_ros2/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ NV_CXR_ENABLE_PUSH_DEVICES=0
2828
- `xr_teleop/hand` (`geometry_msgs/PoseArray`)
2929
- `poses`: Finger joint poses (all joints except palm/wrist, right then left)
3030
- `xr_teleop/ee_poses` (`geometry_msgs/PoseArray`)
31-
- `poses[0]`: Right hand/controller EE pose (if active)
32-
- `poses[1]`: Left hand/controller EE pose (if active)
31+
- `poses[0]`: Left hand/controller EE pose (if active)
32+
- `poses[1]`: Right hand/controller EE pose (if active)
3333
- `xr_teleop/root_twist` (`geometry_msgs/TwistStamped`)
3434
- `xr_teleop/root_pose` (`geometry_msgs/PoseStamped`)
3535
- `xr_teleop/controller_data` (`std_msgs/ByteMultiArray`, msgpack-encoded dictionary)

examples/teleop_ros2/python/teleop_ros2_node.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
2121
Topic names (remappable via ROS 2 remapping):
2222
- xr_teleop/hand (PoseArray): [finger_joint_poses...]
23-
- xr_teleop/ee_poses (PoseArray): [right_ee, left_ee]
23+
- xr_teleop/ee_poses (PoseArray): [left_ee, right_ee]
2424
- xr_teleop/root_twist (TwistStamped): root velocity command
2525
- xr_teleop/root_pose (PoseStamped): root pose command (height only)
2626
- xr_teleop/controller_data (ByteMultiArray): msgpack-encoded controller data
@@ -241,23 +241,23 @@ def _build_ee_msg_from_controllers(
241241
transform_rot: Rotation | None = None,
242242
transform_trans: Sequence[float] | None = None,
243243
) -> PoseArray:
244-
"""Build a PoseArray with right then left controller aim poses (wrist proxy)."""
244+
"""Build a PoseArray with left then right controller aim poses (wrist proxy)."""
245245
msg = PoseArray()
246246
msg.header.stamp = now
247247
msg.header.frame_id = frame_id
248-
if not right_ctrl.is_none:
249-
pos = [float(x) for x in right_ctrl[ControllerInputIndex.AIM_POSITION]]
250-
ori = [float(x) for x in right_ctrl[ControllerInputIndex.AIM_ORIENTATION]]
248+
if not left_ctrl.is_none:
249+
pos = [float(x) for x in left_ctrl[ControllerInputIndex.AIM_POSITION]]
250+
ori = [float(x) for x in left_ctrl[ControllerInputIndex.AIM_ORIENTATION]]
251251
pose = _to_pose(pos, ori)
252252
if transform_rot is not None or transform_trans is not None:
253253
pose = _apply_transform_to_pose(pose, transform_rot, transform_trans)
254254
msg.poses.append(pose)
255255
else:
256256
msg.poses.append(_to_pose([0.0, 0.0, 0.0]))
257257

258-
if not left_ctrl.is_none:
259-
pos = [float(x) for x in left_ctrl[ControllerInputIndex.AIM_POSITION]]
260-
ori = [float(x) for x in left_ctrl[ControllerInputIndex.AIM_ORIENTATION]]
258+
if not right_ctrl.is_none:
259+
pos = [float(x) for x in right_ctrl[ControllerInputIndex.AIM_POSITION]]
260+
ori = [float(x) for x in right_ctrl[ControllerInputIndex.AIM_ORIENTATION]]
261261
pose = _to_pose(pos, ori)
262262
if transform_rot is not None or transform_trans is not None:
263263
pose = _apply_transform_to_pose(pose, transform_rot, transform_trans)
@@ -276,30 +276,30 @@ def _build_ee_msg_from_hands(
276276
transform_rot: Rotation | None = None,
277277
transform_trans: Sequence[float] | None = None,
278278
) -> PoseArray:
279-
"""Build a PoseArray with right then left hand wrist poses (EE proxy)."""
279+
"""Build a PoseArray with left then right hand wrist poses (EE proxy)."""
280280
msg = PoseArray()
281281
msg.header.stamp = now
282282
msg.header.frame_id = frame_id
283283

284-
if not right_hand.is_none:
285-
right_positions = np.asarray(right_hand[HandInputIndex.JOINT_POSITIONS])
286-
right_orientations = np.asarray(right_hand[HandInputIndex.JOINT_ORIENTATIONS])
284+
if not left_hand.is_none:
285+
left_positions = np.asarray(left_hand[HandInputIndex.JOINT_POSITIONS])
286+
left_orientations = np.asarray(left_hand[HandInputIndex.JOINT_ORIENTATIONS])
287287
pose = _to_pose(
288-
right_positions[HandJointIndex.WRIST],
289-
right_orientations[HandJointIndex.WRIST],
288+
left_positions[HandJointIndex.WRIST],
289+
left_orientations[HandJointIndex.WRIST],
290290
)
291291
if transform_rot is not None or transform_trans is not None:
292292
pose = _apply_transform_to_pose(pose, transform_rot, transform_trans)
293293
msg.poses.append(pose)
294294
else:
295295
msg.poses.append(_to_pose([0.0, 0.0, 0.0]))
296296

297-
if not left_hand.is_none:
298-
left_positions = np.asarray(left_hand[HandInputIndex.JOINT_POSITIONS])
299-
left_orientations = np.asarray(left_hand[HandInputIndex.JOINT_ORIENTATIONS])
297+
if not right_hand.is_none:
298+
right_positions = np.asarray(right_hand[HandInputIndex.JOINT_POSITIONS])
299+
right_orientations = np.asarray(right_hand[HandInputIndex.JOINT_ORIENTATIONS])
300300
pose = _to_pose(
301-
left_positions[HandJointIndex.WRIST],
302-
left_orientations[HandJointIndex.WRIST],
301+
right_positions[HandJointIndex.WRIST],
302+
right_orientations[HandJointIndex.WRIST],
303303
)
304304
if transform_rot is not None or transform_trans is not None:
305305
pose = _apply_transform_to_pose(pose, transform_rot, transform_trans)
@@ -705,7 +705,7 @@ def _build_wrist_tfs(
705705
left_available: bool,
706706
now,
707707
) -> List[TransformStamped]:
708-
"""Build wrist TF transforms from a pre-built ee_poses PoseArray (right pose at index 0, left at index 1)."""
708+
"""Build wrist TF transforms from a pre-built ee_poses PoseArray (left pose at index 0, right at index 1)."""
709709
tfs = []
710710

711711
def _get_orientation(pose: Pose) -> List[float]:
@@ -716,24 +716,24 @@ def _get_orientation(pose: Pose) -> List[float]:
716716
pose.orientation.w,
717717
]
718718

719-
if right_available:
719+
if left_available:
720720
pose = ee_msg.poses[0]
721721
tfs.append(
722722
_make_transform(
723723
now,
724724
self._world_frame,
725-
self._right_wrist_frame,
725+
self._left_wrist_frame,
726726
[pose.position.x, pose.position.y, pose.position.z],
727727
_get_orientation(pose),
728728
)
729729
)
730-
if left_available:
730+
if right_available:
731731
pose = ee_msg.poses[1]
732732
tfs.append(
733733
_make_transform(
734734
now,
735735
self._world_frame,
736-
self._left_wrist_frame,
736+
self._right_wrist_frame,
737737
[pose.position.x, pose.position.y, pose.position.z],
738738
_get_orientation(pose),
739739
)

0 commit comments

Comments
 (0)