From b71ca0ad826c046f4457f0e24cf98b571f7aa7c7 Mon Sep 17 00:00:00 2001 From: Remi Cadene Date: Thu, 24 Oct 2024 17:44:19 +0200 Subject: [PATCH] Address review with Simon --- examples/10_use_so100.md | 7 +++++++ examples/11_use_moss.md | 7 +++++++ lerobot/common/robot_devices/cameras/intelrealsense.py | 3 +-- lerobot/common/robot_devices/cameras/opencv.py | 5 ++--- lerobot/common/robot_devices/motors/feetech.py | 10 ---------- lerobot/common/robot_devices/robots/manipulator.py | 7 ++++--- tests/test_control_robot.py | 2 +- 7 files changed, 22 insertions(+), 19 deletions(-) diff --git a/examples/10_use_so100.md b/examples/10_use_so100.md index c338ff2a3..f9631dada 100644 --- a/examples/10_use_so100.md +++ b/examples/10_use_so100.md @@ -146,6 +146,13 @@ Follow step 6 of the [assembly video](https://youtu.be/ZqtPjuVFFpg) which illust |---|---|---| | SO-100 leader arm zero position | SO-100 leader arm rotated position | SO-100 leader arm rest position | +Run this script to launch manual calibration: +```bash +python lerobot/scripts/control_robot.py calibrate \ + --robot-path lerobot/configs/robot/so100.yaml \ + --robot-overrides '~cameras' --arms main_leader +``` + ## Teleoperate **Simple teleop** diff --git a/examples/11_use_moss.md b/examples/11_use_moss.md index be1ae7675..0b3acf812 100644 --- a/examples/11_use_moss.md +++ b/examples/11_use_moss.md @@ -146,6 +146,13 @@ Follow step 6 of the [assembly video](https://youtu.be/ZqtPjuVFFpg) which illust |---|---|---| | Moss v1 leader arm zero position | Moss v1 leader arm rotated position | Moss v1 leader arm rest position | +Run this script to launch manual calibration: +```bash +python lerobot/scripts/control_robot.py calibrate \ + --robot-path lerobot/configs/robot/moss.yaml \ + --robot-overrides '~cameras' --arms main_leader +``` + ## Teleoperate **Simple teleop** diff --git a/lerobot/common/robot_devices/cameras/intelrealsense.py b/lerobot/common/robot_devices/cameras/intelrealsense.py index e331dee3f..479694277 100644 --- a/lerobot/common/robot_devices/cameras/intelrealsense.py +++ b/lerobot/common/robot_devices/cameras/intelrealsense.py @@ -200,8 +200,7 @@ class IntelRealSenseCamera: To find the camera indices of your cameras, you can run our utility script that will save a few frames for each camera: ```bash - python lerobot/common/robot_devices/cameras/intelrealsense.py \ - --images-dir outputs/images_from_intelrealsense_cameras + python lerobot/common/robot_devices/cameras/intelrealsense.py --images-dir outputs/images_from_intelrealsense_cameras ``` When an IntelRealSenseCamera is instantiated, if no specific config is provided, the default fps, width, height and color_mode diff --git a/lerobot/common/robot_devices/cameras/opencv.py b/lerobot/common/robot_devices/cameras/opencv.py index 58dd93bd6..2d8b12c91 100644 --- a/lerobot/common/robot_devices/cameras/opencv.py +++ b/lerobot/common/robot_devices/cameras/opencv.py @@ -216,8 +216,7 @@ class OpenCVCamera: To find the camera indices of your cameras, you can run our utility script that will be save a few frames for each camera: ```bash - python lerobot/common/robot_devices/cameras/opencv.py \ - --images-dir outputs/images_from_opencv_cameras + python lerobot/common/robot_devices/cameras/opencv.py --images-dir outputs/images_from_opencv_cameras ``` When an OpenCVCamera is instantiated, if no specific config is provided, the default fps, width, height and color_mode @@ -324,7 +323,7 @@ def connect(self): if self.camera_index not in available_cam_ids: raise ValueError( f"`camera_index` is expected to be one of these available cameras {available_cam_ids}, but {self.camera_index} is provided instead. " - "To find the camera index you should use, run `python lerobot/lerobot/common/robot_devices/cameras/opencv.py`." + "To find the camera index you should use, run `python lerobot/common/robot_devices/cameras/opencv.py`." ) raise OSError(f"Can't access OpenCVCamera({camera_idx}).") diff --git a/lerobot/common/robot_devices/motors/feetech.py b/lerobot/common/robot_devices/motors/feetech.py index 3d7bb790c..0d5480f7a 100644 --- a/lerobot/common/robot_devices/motors/feetech.py +++ b/lerobot/common/robot_devices/motors/feetech.py @@ -298,16 +298,6 @@ def __init__( self.logs = {} self.track_positions = {} - self.present_pos = { - "prev": [None] * len(self.motor_names), - "below_zero": [None] * len(self.motor_names), - "above_max": [None] * len(self.motor_names), - } - self.goal_pos = { - "prev": [None] * len(self.motor_names), - "below_zero": [None] * len(self.motor_names), - "above_max": [None] * len(self.motor_names), - } def connect(self): if self.is_connected: diff --git a/lerobot/common/robot_devices/robots/manipulator.py b/lerobot/common/robot_devices/robots/manipulator.py index cc82168ed..4a344c35c 100644 --- a/lerobot/common/robot_devices/robots/manipulator.py +++ b/lerobot/common/robot_devices/robots/manipulator.py @@ -51,7 +51,7 @@ class ManipulatorRobotConfig: """ # Define all components of the robot - robot_type: str = "koch" + robot_type: str | None = None leader_arms: dict[str, MotorsBus] = field(default_factory=lambda: {}) follower_arms: dict[str, MotorsBus] = field(default_factory=lambda: {}) cameras: dict[str, Camera] = field(default_factory=lambda: {}) @@ -81,7 +81,7 @@ def __setattr__(self, prop: str, val): super().__setattr__(prop, val) def __post_init__(self): - if self.robot_type not in ["koch", "koch_bimanual", "aloha", "so100", "moss"]: + if self.robot_type is None or self.robot_type not in ["koch", "aloha", "so100", "moss"]: raise ValueError(f"Provided robot type ({self.robot_type}) is not supported.") @@ -292,7 +292,7 @@ def connect(self): self.follower_arms[name].write("Torque_Enable", 1) if self.config.gripper_open_degree is not None: - if self.robot_type in ["aloha", "so100", "moss"]: + if self.robot_type != "koch": raise NotImplementedError( f"{self.robot_type} does not support position AND current control in the handle, which is require to set the gripper open." ) @@ -328,6 +328,7 @@ def load_or_run_calibration_(name, arm, arm_type): with open(arm_calib_path) as f: calibration = json.load(f) else: + # TODO(rcadene): display a warning in __init__ if calibration file not available print(f"Missing calibration file '{arm_calib_path}'") if self.robot_type in ["koch", "aloha"]: diff --git a/tests/test_control_robot.py b/tests/test_control_robot.py index 767adef62..d6297a90a 100644 --- a/tests/test_control_robot.py +++ b/tests/test_control_robot.py @@ -162,7 +162,7 @@ def test_record_and_replay_and_policy(tmpdir, request, robot_type, mock): if robot_type == "aloha": env_name = "aloha_real" policy_name = "act_aloha_real" - elif robot_type in ["koch", "koch_bimanual", "so100", "moss"]: + elif robot_type in ["koch", "so100", "moss"]: env_name = "koch_real" policy_name = "act_koch_real" else: