feat: xarm manipulator adapter improvement#2353
Conversation
- Fix _XARM6/7_INITIAL_JOINTS to use degrees instead of radians - Add motion_enable(False) before set_state(4) in stop() - Update custom arm docs with activate/deactivate lifecycle methods - Ignore .omo/ directory
Remove unnecessary getattr/callable/hasattr guards since ManipulatorAdapter Protocol guarantees these methods exist.
Greptile SummaryThis PR improves the XArm teleoperation workflow by wiring live joint states into the keyboard teleop module for accurate initialization, and introducing
Confidence Score: 4/5Safe to merge for simulation/testing; a physical-robot safety concern in the deactivation path warrants review before deploying to a real arm. The dimos/hardware/manipulators/xarm/adapter.py — specifically the Important Files Changed
Sequence DiagramsequenceDiagram
participant C as ControlCoordinator
participant A as XArmAdapter
participant K as KeyboardTeleopModule
Note over C,A: start() / _setup_hardware()
C->>A: connect()
A-->>C: True
C->>A: activate()
A->>A: _prepare_for_position_motion()
A->>A: _move_to_initial_pose() [blocking]
A->>A: set_control_mode(SERVO_POSITION)
A-->>C: True
C->>C: publish joint_state stream
Note over K: start() / _pygame_loop thread
K->>C: "joint_state.get_next(timeout=5s)"
C-->>K: JointState (initial positions)
K->>K: JogState.from_fk(initial_joints)
Note over K: SPACE pressed
K->>C: "joint_state.get_next(timeout=0.1s)"
C-->>K: JointState (current)
K->>K: sync current_pose to live FK
Note over C,A: stop()
C->>C: tick_loop.stop()
C->>A: deactivate()
A->>A: _prepare_for_position_motion()
A->>A: _move_to_initial_pose() [blocking]
A->>A: motion_enable(False), set_state(4)
A-->>C: True
C->>A: disconnect()
Reviews (2): Last reviewed commit: "fix: address lifecycle review feedback" | Re-trigger Greptile |
- Guard activate()/deactivate() calls in the coordinator so adapters without lifecycle methods (twist bases, whole-body) no longer raise AttributeError; restore the write_enable(True) fallback on setup - Implement activate()/deactivate() in MockAdapter and ShmMujocoAdapter to satisfy the extended ManipulatorAdapter protocol - Log and set the stop event when keyboard teleop fails to read the initial joint state instead of exiting the thread silently - Remove unused home_pose computation in keyboard teleop - Add coordinator test covering adapters without lifecycle methods Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Closes #1183
Solution
This PR resolves the following issues observed on teleoperating xarm:
KeyboardTeleopModule initial position sync
Wire robot joint states to the keyboard teleop module so that it initialize target to the robot startup position. A more proper fix in my mind should be to refactor keyboard teleop module to only output relative cartesian motion and wire that to some relative cartesian task so that the teleop module is decoupled from the actual robot state.
XArm graceful start/stop
Added two lifecycle methods in manipulator adapter
activate/deactivateto execute functions required before robot starts/stop movement. The semantic is different fromconnect/disconnectin that sometime you might want to only pause robot commanding while still keeping the connection. Now the xarm will move to the default position on start/stop.How to Test
# connects to a real robot for testing dimos --xarm6-ip=192.168.1.210 run keyboard-teleop-xarm6Contributor License Agreement