Skip to content

feat(motors): allow per-motor setup and calibration for SO leader/follower#3499

Open
eliasab16 wants to merge 8 commits intohuggingface:mainfrom
eliasab16:feat/per-motor-setup-calibration
Open

feat(motors): allow per-motor setup and calibration for SO leader/follower#3499
eliasab16 wants to merge 8 commits intohuggingface:mainfrom
eliasab16:feat/per-motor-setup-calibration

Conversation

@eliasab16
Copy link
Copy Markdown

@eliasab16 eliasab16 commented May 3, 2026

Summary / Motivation

Adds a --motors flag that acceps a comma separated list of motor names to lerobot-setup-motors and lerobot-calibrate modules so users can recalibrate or re-register a single motor (or a subset) without redoing the full sequence. Useful when replacing a single servo or correcting drift on one joint without disturbing the rest of the calibration.

Examples:

lerobot-calibrate \
    --teleop.type=so101_leader \
    --teleop.port=/dev/tty.usbmodem58760431551 \
    --teleop.id=test \
    --motors=shoulder_pan,elbow_flex      <-- new
lerobot-setup-motors \
    --teleop.type=so101_leader \
    --teleop.port=/dev/tty.usbmodem58760431551 \
    --motors=shoulder_pan,elbow_flex      <-- new

What changed

  1. New calibrate_partial helper in src/lerobot/motors/feetech/calibration.py that takes a list of motor names and merges new homing offsets / ranges into the existing calibration dict.
  2. so_leader.calibrate(motors=...) and so_follower.calibrate(motors=...) dispatch to the helper for partial calibration mode; full path unchanged.
  3. so_leader.setup_motors(motors=...) and so_followre.setup_motors(motors=...) accept a subset of motors to setup.
  4. CLI: --motors=shoulder_pan,elbow_flex (comma-separated string for shell-friendliness; rejects invalid characters via regex).
  5. Full-turn motors (e.g. wrist_roll) still receive a homing offset but skip ROM recording.
  6. On failure mid-flight, motor registers are restored to the previous calibration; in-memory and on-disk state untouched.
  7. No breaking changes: motors kwarg defaults to None.

How was this tested (or how to run locally)

  • ran pytest tests/motors/test_calibration.py -v
  • ran pre-commit run --all-files
  • tested both scripts locally on my own robots:
    • lerobot-setup-motors: replaced one of the servos with another one and was able to register it individually.
    • lerobot-calibrate: ran the script on different subset of servos and recorded their new calibrations; verified that the only the selected motors' calibration values changed; verified that the full_turn_motor ("wrist_roll") was skipped during calibration as expected in the original flow.
  • verified that the old flow still works: ran the scripts without passing the new flag

Checklist (required before merge)

Reviewer notes

  • Regarding point (1) in the "what changed" section: at first I followed the existing structure by adding the same partial calibration function to both the follower and leader files separately. But then decided to just create a new file 'calibration.py' under motors/feetech and created the partial calibration as a shared method. The obvious reasons are to reduce redundancy in both the main files and the tests and improve maintainability. However if there are good reasons why we should keep separate methods in both the so_leader.py and so_follower.py, I can change that. But if this approach is accepted, then maybe we should consider moving more of the calibration logic to the new 'calibration.py' file.

  • While the partial calibration function is generic and can be used for any feetech-based robot, I only integrated it into the so101 follower and leader files. If this diff is accepted and merged, I will extend it to the other robot files.

@github-actions github-actions Bot added tests Problems with test coverage, failures, or improvements to testing robots Issues concerning robots HW interfaces labels May 3, 2026
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 tests Problems with test coverage, failures, or improvements to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant