calibration failed : ValueError: Magnitude 2114 exceeds 2047 (max for sign_bit_index=11)
System Info
I followed the instruction to create the environment with miniconda.
I numbered the motors with the corresponding script but when I wanted to start the calibration - for the follower- i had the following error:
file:///home/fabrice/Images/s101_error.png
Is there a script to read the position of each motor ?
Information
- [x] One of the scripts in the examples/ folder of LeRobot
- [ ] My own task or dataset (give details below)
Reproduction
Each time I start the calibration script
Expected behavior
Should be like in the video tutorial - an array with the motor and its position
Hello there,
we had the same issue. Can you roll back a few commits ( like 20 ) and see if that solves the problem.
Good luck,
A.
Could you paste here your full stack trace?
Hello, you mean this one:
(lerobot) fabrice@fabrice-XMG:~/lerobot$ python -m lerobot.calibrate --robot.type=so101_follower --robot.port=/dev/ttyACM0 --robot.id=follower
Move follower SO101Follower to the middle of its range of motion and press ENTER....
Traceback (most recent call last):
File "/home/fabrice/miniconda3/envs/lerobot/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/home/fabrice/miniconda3/envs/lerobot/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/fabrice/lerobot/lerobot/calibrate.py", line 84, in <module>
calibrate()
File "/home/fabrice/miniconda3/envs/lerobot/lib/python3.10/site-packages/draccus/argparsing.py", line 225, in wrapper_inner
response = fn(cfg, *args, **kwargs)
File "/home/fabrice/lerobot/lerobot/calibrate.py", line 79, in calibrate
device.calibrate()
File "/home/fabrice/lerobot/lerobot/common/robots/so101_follower/so101_follower.py", line 114, in calibrate
homing_offsets = self.bus.set_half_turn_homings()
File "/home/fabrice/lerobot/lerobot/common/motors/motors_bus.py", line 714, in set_half_turn_homings
self.write("Homing_Offset", motor, offset)
File "/home/fabrice/lerobot/lerobot/common/motors/motors_bus.py", line 1019, in write
value = self._encode_sign(data_name, {id_: value})[id_]
File "/home/fabrice/lerobot/lerobot/common/motors/feetech/feetech.py", line 317, in _encode_sign
ids_values[id_] = encode_sign_magnitude(ids_values[id_], sign_bit)
File "/home/fabrice/lerobot/lerobot/common/utils/encoding_utils.py", line 23, in encode_sign_magnitude
raise ValueError(f"Magnitude {magnitude} exceeds {max_magnitude} (max for {sign_bit_index=})")
ValueError: Magnitude 2114 exceeds 2047 (max for sign_bit_index=11)
Thanks. I'm not sure what's going on as it's difficult to reproduce. This error basically says that it's trying to write a value higher than what's allowed by that motor's register (for the homing offset). Did you try multiple times and get the same error each time?
Ah yes this time it works and I was able to calibrate the follower. BUT now confident it work smoothly for the leader I got the message (I was too confident) below. Looks like that you want the same fimrware version for all servos. I am used to Robotis dynamixel environment and updating the firmware is easy. Here with this company, it is clearly painful - I found the exe to read the servos but I cannot find where the version of the firmware are stored, do you have any hint? Thank you very much
lerobot) fabrice@fabrice-XMG:~/lerobot$ python -m lerobot.calibrate --teleop.type=so101_leader --teleop.port=/dev/ttyACM0 --teleop.id=leader
Traceback (most recent call last):
File "/home/fabrice/miniconda3/envs/lerobot/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/home/fabrice/miniconda3/envs/lerobot/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/fabrice/lerobot/lerobot/calibrate.py", line 84, in <module>
calibrate()
File "/home/fabrice/miniconda3/envs/lerobot/lib/python3.10/site-packages/draccus/argparsing.py", line 225, in wrapper_inner
response = fn(cfg, *args, **kwargs)
File "/home/fabrice/lerobot/lerobot/calibrate.py", line 78, in calibrate
device.connect(calibrate=False)
File "/home/fabrice/lerobot/lerobot/common/teleoperators/so101_leader/so101_leader.py", line 73, in connect
self.bus.connect()
File "/home/fabrice/lerobot/lerobot/common/motors/motors_bus.py", line 436, in connect
self._connect(handshake)
File "/home/fabrice/lerobot/lerobot/common/motors/motors_bus.py", line 445, in _connect
self._handshake()
File "/home/fabrice/lerobot/lerobot/common/motors/feetech/feetech.py", line 168, in _handshake
self._assert_same_firmware()
File "/home/fabrice/lerobot/lerobot/common/motors/feetech/feetech.py", line 159, in _assert_same_firmware
raise RuntimeError(
RuntimeError: Some Motors use different firmware versions:
{1: '3.9', 2: '3.10', 3: '3.9', 4: '3.9', 5: '3.10', 6: '3.9'}
Update their firmware first using Feetech's software. Visit https://www.feetechrc.com/software.
This has happened to me too; to fix I first wrapped this line in a try-catch with a log statment to know which motor the issue was coming from:
try:
ids_values[id_] = encode_sign_magnitude(ids_values[id_], sign_bit)
except ValueError as e:
logger.error(f"Error encoding sign for motor {id_}: {e}")
raise
Then I restarted the calibration, moving that motor away from the mid-point towards on the extremes, to get the first enter hit to pass. Once it did, I restarted the calibration, this time putting all motors at their mid-point, and that time it worked.
@afallou that help, i disconnected the motor and re-connecting it and it fiexed the problem.
I encountered the same issue, just unplugging the AC adapter and plugging it back fixed the problem for me.
I've faced the same issue after upgrading the STS3215's firmware, but re-connecting the AC adapter solved the problem.
Hello, you mean this one:
(lerobot) fabrice@fabrice-XMG:~/lerobot$ python -m lerobot.calibrate --robot.type=so101_follower --robot.port=/dev/ttyACM0 --robot.id=follower Move follower SO101Follower to the middle of its range of motion and press ENTER.... Traceback (most recent call last): File "/home/fabrice/miniconda3/envs/lerobot/lib/python3.10/runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "/home/fabrice/miniconda3/envs/lerobot/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/home/fabrice/lerobot/lerobot/calibrate.py", line 84, in <module> calibrate() File "/home/fabrice/miniconda3/envs/lerobot/lib/python3.10/site-packages/draccus/argparsing.py", line 225, in wrapper_inner response = fn(cfg, *args, **kwargs) File "/home/fabrice/lerobot/lerobot/calibrate.py", line 79, in calibrate device.calibrate() File "/home/fabrice/lerobot/lerobot/common/robots/so101_follower/so101_follower.py", line 114, in calibrate homing_offsets = self.bus.set_half_turn_homings() File "/home/fabrice/lerobot/lerobot/common/motors/motors_bus.py", line 714, in set_half_turn_homings self.write("Homing_Offset", motor, offset) File "/home/fabrice/lerobot/lerobot/common/motors/motors_bus.py", line 1019, in write value = self._encode_sign(data_name, {id_: value})[id_] File "/home/fabrice/lerobot/lerobot/common/motors/feetech/feetech.py", line 317, in _encode_sign ids_values[id_] = encode_sign_magnitude(ids_values[id_], sign_bit) File "/home/fabrice/lerobot/lerobot/common/utils/encoding_utils.py", line 23, in encode_sign_magnitude raise ValueError(f"Magnitude {magnitude} exceeds {max_magnitude} (max for {sign_bit_index=})") ValueError: Magnitude 2114 exceeds 2047 (max for sign_bit_index=11)
got the same issue when i do the leader arms calibration. but it works fine with follower arms.
i have git checkout to earlier commit 4e4eec92dcc4ab4476c7c399b47678926b111ed9 it still failed. but after I unplug the cable and reconnect it again. the leader calibrate script works...
And then....I got the error message below...... then i tried again.....it finally worked
(lerobot) MacBook-2:lerobot bluebird$ python -m lerobot.calibrate --teleop.type=so101_leader --teleop.port=/dev/tty.usbmodem5A680088281 --teleop.id=anan_leader_arm Move anan_leader_arm SO101Leader to the middle of its range of motion and press ENTER.... Move all joints sequentially through their entire ranges of motion. Recording positions. Press ENTER to stop...
NAME | MIN | POS | MAX
shoulder_pan | 2047 | 2295 | 2296
shoulder_lift | 2047 | 3136 | 3148
elbow_flex | 952 | 1098 | 2048
wrist_flex | 2047 | 2091 | 4368
wrist_roll | 144 | 152 | 3953
gripper | 2039 | 2046 | 2047
Traceback (most recent call last):
File "/Users/bluebird/miniconda3/envs/lerobot/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/Users/bluebird/miniconda3/envs/lerobot/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/Users/bluebird/compile_install/lerobot/lerobot/calibrate.py", line 84, in
Are there any other solutions? Unplugging AC does not work
For folks having similar issues: It might be due to the servo encoder overflow. If you are using feetech one, you can download the debug software from their website: https://www.feetechrc.com/software.html (FD 1.9.8.3). Attached are the parameters to connect to the servo. Click search, servo will pop up in the listr. Unmount your motor, and adjust the slider bar to around center position and then remount. The do the calibration error should be gone.
A solution that fixed my issue was to use the link above: https://www.feetechrc.com/software.html to download the debug software. The software worked on a Windows machine, but it did not work for my MacBook. Connect to the servos and select them one by one using the commands above. Click the Programming tab and set the torque enable option to 128. After this, rerun the calibrate script. You may have to do this for each servo if it doesn't fix it.
Hi @mertonmeng and @Coded190,
Thank you for your help and answers on this calibration issue. I believe the error was caused by an assembly error : if the servos should be assembled in the zero position, but it's hard to tell on Feetech's servos.
In cas you'd prefer to stay on MacOS/Linux to debug the motors, you can check the tools provided at the end of this doc : https://huggingface.co/docs/lerobot/feetech
Best,
Caroline.
FWIW I had this issue, and what ended up solving it for me was unplugging both USB and AC power, and then moving the affected motors to their home position. While holding them in the home position, plugging back in USB and AC power. I don't know if this is just wishful thinking but that seemed to do the trick. Simply unplugging the AC power or AC + USB many times didn't work. Here's a diff I made as well just to print out the affected motor.
diff --git a/src/lerobot/motors/feetech/feetech.py b/src/lerobot/motors/feetech/feetech.py
index 88d45ba3..133f6c81 100644
--- a/src/lerobot/motors/feetech/feetech.py
+++ b/src/lerobot/motors/feetech/feetech.py
@@ -315,7 +315,10 @@ class FeetechMotorsBus(MotorsBus):
encoding_table = self.model_encoding_table.get(model)
if encoding_table and data_name in encoding_table:
sign_bit = encoding_table[data_name]
- ids_values[id_] = encode_sign_magnitude(ids_values[id_], sign_bit)
+ try:
+ ids_values[id_] = encode_sign_magnitude(ids_values[id_], sign_bit)
+ except ValueError as error:
+ print(f"Failed to calibrate motor {id_}: {error}")
return ids_values
Hi @mklingen,
Thank you for sharing this addition to the _encode_sign method, I think this could be a nice PR ! If you are willing to open a PR, could you turn your print statement into a ValueError and replace Failed to calibrate motor {id_}: by a more generic message displaying id_ as well as data_name (e.g. Failed to encode sign for motor ... with data ...) ? Thanks !
Best,
Caroline.
Hi all, I also ran into this issue while trying to calibrate a SO-101 arm. What fixed it for me was:
- Follow instructions on https://huggingface.co/docs/lerobot/en/feetech through Step 4: Scan for Motors, stop before Step 5.
- Select the Programming tab.
- Move ALL joints to the middle of their range; for me it looks like an upside-down L with the gripper/thumb thing half "open".
- Click Offset.
This seems to set all the current servo positions as the positional midpoint in the Debug view. Before doing this, one of the servos scrolled off the top of the graph on one end of its movement. I'm new to all this though, so hopefully my guess is correct. :) I had access to a Windows machine, it's possible this could be accomplished with the Feetech Debug Tool as well?
Hi @williamito,
Nice discovery, thanks ! This is way easier than disassembling all the servos with shifted zero positions ;) I assume this button must set the current value of the encoder to 0, so you don't have the exceeding value error anymore.
It would be a nice addition to our doc about fetch motors if you feel like opening a PR !
Best,
Caroline,
Encoutered the same issue just unpluged the adapter and conneted back as @nxu96 suggested and issue has been resolved.