fix: symmetric calibration for wrist_roll motors in SO-101#3320
fix: symmetric calibration for wrist_roll motors in SO-101#3320cwzhong627-source wants to merge 2 commits intohuggingface:mainfrom
Conversation
|
Hey, I'm currently looking into this PR. |
hi@Maximellerbach, I've realized the issue and will close this PR. You are right—the 180° loss is a significant regression caused by the way I forced symmetry. Here is the "Math" behind the problem: Example: If a user calibrates the wrist at 1024 (90° off the physical center 2048): safe_delta becomes 1024. The range is restricted to [0, 2048], which is only 180°. The remaining 180° on the other side is "sacrificed" just to maintain a symmetric software zero-point. Why wrist_roll is unique: For linear joints, shrinking the range to find the center works fine. For circular joints, it creates a "topological break" where the robot suddenly lose half its motion. Next Step: Option A (Automatic Offset): Keep the full [0, 4095] range and use homing_offset to align the zero-point in software. This is the most user-friendly. Option B (Validation): Simply warn/block the user during calibration if the wrist is too far from the physical center, forcing a manual mechanical adjustment. I'm leaning toward Option A. Let me know what you think, and I'll follow up with a fresh PR! |
fix(robots): ensure symmetric wrist_roll calibration for SO-101
Type / Scope
Summary / Motivation
Current calibration for wrist_roll (full-turn motors) in SO-101 robots relies on a hardcoded range or an asymmetric logic, which causes the software "zero" point to deviate from the physical orientation set by the user during the calibration process.
This PR implements a symmetric range strategy. By calculating a safe_delta centered at the current physical position, we ensure that the software center ((min + max) / 2) perfectly aligns with the user-defined physical zero. This fixes the "offset wrist" issue and ensures consistent range of motion in both directions.
Related issues
Fixes / Closes: #3193
What changed
How was this tested (or how to run locally)
lerobot-calibrateand set the wrist to a specific orientation.calibration.json.range_minandrange_maxare symmetric around the set position (e.g.,current_pos=2028resulted inmin=0,max=4056).Bash
Checklist (required before merge)
pre-commit run -a) - Note: If you haven't run this, you can check if CI passes.pytest)Reviewer notes
The core logic uses
safe_deltato prevent the range from exceeding the physical limits (0-4095) while maintaining symmetry. This is crucial becausemotors_bus.pyuses the arithmetic mean of the range to define the normalized zero point.