diff --git a/lerobot/common/robot_devices/motors/feetech.py b/lerobot/common/robot_devices/motors/feetech.py index 3c134d64d..1ed13d858 100644 --- a/lerobot/common/robot_devices/motors/feetech.py +++ b/lerobot/common/robot_devices/motors/feetech.py @@ -352,14 +352,14 @@ class FeetechMotorsBus: print(e) return False - def find_motor_indices(self, possible_ids=None): + def find_motor_indices(self, possible_ids=None, num_retry=2): if possible_ids is None: possible_ids = range(MAX_ID_RANGE) indices = [] for idx in tqdm.tqdm(possible_ids): try: - present_idx = self.read_with_motor_ids(self.motor_models, [idx], "ID")[0] + present_idx = self.read_with_motor_ids(self.motor_models, [idx], "ID", num_retry=num_retry)[0] except ConnectionError: continue diff --git a/lerobot/common/robot_devices/robots/manipulator.py b/lerobot/common/robot_devices/robots/manipulator.py index 54c60bac9..46eba1f62 100644 --- a/lerobot/common/robot_devices/robots/manipulator.py +++ b/lerobot/common/robot_devices/robots/manipulator.py @@ -335,7 +335,7 @@ class ManipulatorRobot: calibration = run_arm_calibration(arm, self.robot_type, name, arm_type) - elif self.robot_type in ["so100", "moss"]: + elif self.robot_type in ["so100"]: from lerobot.common.robot_devices.robots.feetech_calibration import ( run_arm_auto_calibration, run_arm_manual_calibration, @@ -343,12 +343,21 @@ class ManipulatorRobot: if arm_type == "leader": calibration = run_arm_manual_calibration(arm, self.robot_type, name, arm_type) - elif arm_type == "follower": calibration = run_arm_auto_calibration(arm, self.robot_type, name, arm_type) else: raise ValueError(arm_type) + elif self.robot_type in ["moss"]: + from lerobot.common.robot_devices.robots.feetech_calibration import ( + run_arm_manual_calibration, + ) + + if arm_type == "leader" or arm_type == "follower": + calibration = run_arm_manual_calibration(arm, self.robot_type, name, arm_type) + else: + raise ValueError(arm_type) + print(f"Calibration is done! Saving calibration file '{arm_calib_path}'") arm_calib_path.parent.mkdir(parents=True, exist_ok=True) with open(arm_calib_path, "w") as f: diff --git a/lerobot/configs/robot/moss.yaml b/lerobot/configs/robot/moss.yaml index c3535d765..8a9019851 100644 --- a/lerobot/configs/robot/moss.yaml +++ b/lerobot/configs/robot/moss.yaml @@ -18,7 +18,7 @@ max_relative_target: null leader_arms: main: _target_: lerobot.common.robot_devices.motors.feetech.FeetechMotorsBus - port: /dev/tty.usbmodem585A0077581 + port: /dev/tty.usbmodem58760431091 motors: # name: (index, model) shoulder_pan: [1, "sts3215"] @@ -31,7 +31,7 @@ leader_arms: follower_arms: main: _target_: lerobot.common.robot_devices.motors.feetech.FeetechMotorsBus - port: /dev/tty.usbmodem585A0080971 + port: /dev/tty.usbmodem58760431191 motors: # name: (index, model) shoulder_pan: [1, "sts3215"] diff --git a/lerobot/scripts/configure_motor.py b/lerobot/scripts/configure_motor.py index 4459a75f8..4d833c088 100644 --- a/lerobot/scripts/configure_motor.py +++ b/lerobot/scripts/configure_motor.py @@ -91,9 +91,7 @@ def configure_motor(port, brand, model, motor_idx_des, baudrate_des): baudrate_idx = list(SERIES_BAUDRATE_TABLE.values()).index(baudrate_des) # The write can fail, so we allow retries - motor_bus.write_with_motor_ids( - motor_bus.motor_models, motor_index, "Baud_Rate", baudrate_idx, num_retry=2 - ) + motor_bus.write_with_motor_ids(motor_bus.motor_models, motor_index, "Baud_Rate", baudrate_idx) time.sleep(0.5) motor_bus.set_bus_baudrate(baudrate_des) present_baudrate_idx = motor_bus.read_with_motor_ids( @@ -104,6 +102,7 @@ def configure_motor(port, brand, model, motor_idx_des, baudrate_des): raise OSError("Failed to write baudrate.") print(f"Setting its index to desired index {motor_idx_des}") + motor_bus.write_with_motor_ids(motor_bus.motor_models, motor_index, "Lock", 0) motor_bus.write_with_motor_ids(motor_bus.motor_models, motor_index, "ID", motor_idx_des) present_idx = motor_bus.read_with_motor_ids(motor_bus.motor_models, motor_idx_des, "ID", num_retry=2) diff --git a/lerobot/scripts/control_robot.py b/lerobot/scripts/control_robot.py index 425247e65..031e608e7 100644 --- a/lerobot/scripts/control_robot.py +++ b/lerobot/scripts/control_robot.py @@ -144,6 +144,9 @@ def calibrate(robot: Robot, arms: list[str] | None): robot.home() return + if arms is None: + arms = robot.available_arms + unknown_arms = [arm_id for arm_id in arms if arm_id not in robot.available_arms] available_arms_str = " ".join(robot.available_arms) unknown_arms_str = " ".join(unknown_arms)