Skip to content

feat(motors): switch Damiao motors to MIT mode in configure_motors#3753

Open
xixinzhang wants to merge 2 commits into
huggingface:mainfrom
xixinzhang:feat/damiao-mit-mode-check
Open

feat(motors): switch Damiao motors to MIT mode in configure_motors#3753
xixinzhang wants to merge 2 commits into
huggingface:mainfrom
xixinzhang:feat/damiao-mit-mode-check

Conversation

@xixinzhang

@xixinzhang xixinzhang commented Jun 10, 2026

Copy link
Copy Markdown

Summary

DamiaoMotorsBus assumed motors were already flashed to MIT control mode but never enforced or established it. A motor flashed to POS_VEL / VEL / TORQUE_POS by DM_Tool would silently misinterpret MIT-format frames with no diagnostic.

This PR mirrors the sibling RobstrideMotorsBus pattern: write CTRL_MODE = MIT to each motor's RAM in configure_motors() and assert the cached mode before MIT control sends. RAM-only write, no flash wear; re-issued on every connect.

Test plan

  • OpenArm with motors flashed to MIT: behaviour unchanged.
  • OpenArm with one motor flashed to POS_VEL: driver brings it back to MIT at connect; motion normal.
  • uv run ruff check src/lerobot/motors/damiao/ — passes.

DamiaoMotorsBus assumed motors were already flashed to MIT control mode
but never enforced or established it. A motor flashed to POS_VEL / VEL /
TORQUE_POS by DM_Tool would silently misinterpret MIT-format CAN frames,
producing erratic motion with no diagnostic.

Mirror the sibling RobstrideMotorsBus pattern: track per-motor operation
mode in memory, write CTRL_MODE = MIT to each motor's RAM at every
configure_motors() call, and guard MIT control sends with an in-memory
assertion. RAM-only write, no flash wear; re-issued on every connect.

Wires up the previously-unused CAN_CMD_WRITE_PARAM, ControlMode, and
MotorVariable constants from tables.py.
Copilot AI review requested due to automatic review settings June 10, 2026 00:43
@github-actions github-actions Bot added the robots Issues concerning robots HW interfaces label Jun 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR adds operation mode tracking and switching for Damiao motors, specifically ensuring motors are in MIT control mode before accepting MIT control commands.

Changes:

  • Introduces a _switch_operation_mode method that sends a CAN parameter write command to change the motor's control mode.
  • During configure_motors, each motor is now explicitly switched to MIT mode before being enabled.
  • Runtime guards are added in _mit_control and _mit_control_batch to reject commands if the motor isn't confirmed to be in MIT mode.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +299 to +300
if self._recv_motor_response(expected_recv_id=recv_id, timeout=MEDIUM_TIMEOUT_SEC) is not None:
self.operation_mode[motor_name] = mode
Comment on lines +157 to +158
# Motor Mode
self.operation_mode: dict[str, ControlMode] = {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

robots Issues concerning robots HW interfaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants