From cad03eb0c5fa61985c27162aa31edf4db7920826 Mon Sep 17 00:00:00 2001 From: Maxime Date: Mon, 13 Apr 2026 12:44:17 +0200 Subject: [PATCH] adding explicit error message when invalid position readings --- src/lerobot/motors/motors_bus.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lerobot/motors/motors_bus.py b/src/lerobot/motors/motors_bus.py index 509f5e95f..82c34d7f9 100644 --- a/src/lerobot/motors/motors_bus.py +++ b/src/lerobot/motors/motors_bus.py @@ -777,6 +777,16 @@ class SerialMotorsBus(MotorsBusBase): self.reset_calibration(motor_names) actual_positions = self.sync_read("Present_Position", motor_names, normalize=False) + + if any(pos < 0 or pos > 4095 for pos in actual_positions.values()): + invalid_positions = {m: p for m, p in actual_positions.items() if p < 0 or p > 4095} + + raise RuntimeError( + f"Some motors have invalid position readings {invalid_positions}, which can lead to incorrect homing offsets.\n" + "Try to disconnect the robot's AC power and USB cable, move it to the middle of its range of motion, then reconnect.\n" + "If the problem persists, check the documentation: https://huggingface.co/docs/lerobot/feetech" + ) + homing_offsets = self._get_half_turn_homings(actual_positions) for motor, offset in homing_offsets.items(): self.write("Homing_Offset", motor, offset)