-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Feat/add bimanual so100 robot #1509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7942694
feat: init commit add bimanual so100
pkooij 8c1ac29
Feat: add cam connect and example for teleop
pkooij e4040cc
Merge branch 'main' into feat/add_bimanual_so100_robot
pkooij 6b46f6e
feat: Add replay and record cmd examples
pkooij 6c2a2ff
Merge branch 'main' into feat/add_bimanual_so100_robot
pkooij d01142f
fix: added feedback pr
pkooij c473e62
fix: pr comments
pkooij File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #!/usr/bin/env python | ||
|
|
||
| # Copyright 2025 The HuggingFace Inc. team. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| from .bi_so100_follower import BiSO100Follower | ||
michel-aractingi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| from .config_bi_so100_follower import BiSO100FollowerConfig | ||
163 changes: 163 additions & 0 deletions
163
src/lerobot/robots/bi_so100_follower/bi_so100_follower.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,163 @@ | ||
| #!/usr/bin/env python | ||
|
|
||
| # Copyright 2025 The HuggingFace Inc. team. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import logging | ||
| import time | ||
| from functools import cached_property | ||
| from typing import Any | ||
|
|
||
| from lerobot.cameras.utils import make_cameras_from_configs | ||
| from lerobot.robots.so100_follower import SO100Follower | ||
| from lerobot.robots.so100_follower.config_so100_follower import SO100FollowerConfig | ||
|
|
||
| from ..robot import Robot | ||
| from .config_bi_so100_follower import BiSO100FollowerConfig | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class BiSO100Follower(Robot): | ||
| """ | ||
| [Bimanual SO-100 Follower Arms](https://github.com/TheRobotStudio/SO-ARM100) designed by TheRobotStudio | ||
AdilZouitine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| This bimanual robot can also be easily adapted to use SO-101 follower arms, just replace the SO100Follower class with SO101Follower and SO100FollowerConfig with SO101FollowerConfig. | ||
| """ | ||
|
|
||
| config_class = BiSO100FollowerConfig | ||
| name = "bi_so100_follower" | ||
|
|
||
| def __init__(self, config: BiSO100FollowerConfig): | ||
| super().__init__(config) | ||
| self.config = config | ||
|
|
||
| left_arm_config = SO100FollowerConfig( | ||
| id=f"{config.id}_left" if config.id else None, | ||
| calibration_dir=config.calibration_dir, | ||
| port=config.left_arm_port, | ||
| disable_torque_on_disconnect=config.left_arm_disable_torque_on_disconnect, | ||
| max_relative_target=config.left_arm_max_relative_target, | ||
| use_degrees=config.left_arm_use_degrees, | ||
| cameras={}, | ||
| ) | ||
|
|
||
| right_arm_config = SO100FollowerConfig( | ||
| id=f"{config.id}_right" if config.id else None, | ||
| calibration_dir=config.calibration_dir, | ||
| port=config.right_arm_port, | ||
| disable_torque_on_disconnect=config.right_arm_disable_torque_on_disconnect, | ||
| max_relative_target=config.right_arm_max_relative_target, | ||
| use_degrees=config.right_arm_use_degrees, | ||
| cameras={}, | ||
| ) | ||
|
|
||
| self.left_arm = SO100Follower(left_arm_config) | ||
| self.right_arm = SO100Follower(right_arm_config) | ||
| self.cameras = make_cameras_from_configs(config.cameras) | ||
|
|
||
| @property | ||
| def _motors_ft(self) -> dict[str, type]: | ||
| return {f"left_{motor}.pos": float for motor in self.left_arm.bus.motors} | { | ||
| f"right_{motor}.pos": float for motor in self.right_arm.bus.motors | ||
| } | ||
|
|
||
| @property | ||
| def _cameras_ft(self) -> dict[str, tuple]: | ||
| return { | ||
| cam: (self.config.cameras[cam].height, self.config.cameras[cam].width, 3) for cam in self.cameras | ||
| } | ||
|
|
||
| @cached_property | ||
| def observation_features(self) -> dict[str, type | tuple]: | ||
| return {**self._motors_ft, **self._cameras_ft} | ||
|
|
||
| @cached_property | ||
| def action_features(self) -> dict[str, type]: | ||
| return self._motors_ft | ||
|
|
||
| @property | ||
| def is_connected(self) -> bool: | ||
| return ( | ||
| self.left_arm.bus.is_connected | ||
| and self.right_arm.bus.is_connected | ||
| and all(cam.is_connected for cam in self.cameras.values()) | ||
| ) | ||
|
|
||
| def connect(self, calibrate: bool = True) -> None: | ||
| self.left_arm.connect(calibrate) | ||
| self.right_arm.connect(calibrate) | ||
|
|
||
| for cam in self.cameras.values(): | ||
| cam.connect() | ||
|
|
||
| @property | ||
| def is_calibrated(self) -> bool: | ||
| return self.left_arm.is_calibrated and self.right_arm.is_calibrated | ||
|
|
||
| def calibrate(self) -> None: | ||
| self.left_arm.calibrate() | ||
| self.right_arm.calibrate() | ||
|
|
||
| def configure(self) -> None: | ||
| self.left_arm.configure() | ||
| self.right_arm.configure() | ||
|
|
||
| def setup_motors(self) -> None: | ||
| self.left_arm.setup_motors() | ||
| self.right_arm.setup_motors() | ||
|
|
||
| def get_observation(self) -> dict[str, Any]: | ||
| obs_dict = {} | ||
|
|
||
| # Add "left_" prefix | ||
| left_obs = self.left_arm.get_observation() | ||
| obs_dict.update({f"left_{key}": value for key, value in left_obs.items()}) | ||
|
|
||
| # Add "right_" prefix | ||
| right_obs = self.right_arm.get_observation() | ||
| obs_dict.update({f"right_{key}": value for key, value in right_obs.items()}) | ||
|
|
||
| for cam_key, cam in self.cameras.items(): | ||
| start = time.perf_counter() | ||
| obs_dict[cam_key] = cam.async_read() | ||
| dt_ms = (time.perf_counter() - start) * 1e3 | ||
| logger.debug(f"{self} read {cam_key}: {dt_ms:.1f}ms") | ||
|
|
||
| return obs_dict | ||
|
|
||
| def send_action(self, action: dict[str, Any]) -> dict[str, Any]: | ||
| # Remove "left_" prefix | ||
| left_action = { | ||
| key.removeprefix("left_"): value for key, value in action.items() if key.startswith("left_") | ||
| } | ||
| # Remove "right_" prefix | ||
| right_action = { | ||
| key.removeprefix("right_"): value for key, value in action.items() if key.startswith("right_") | ||
| } | ||
|
|
||
| send_action_left = self.left_arm.send_action(left_action) | ||
| send_action_right = self.right_arm.send_action(right_action) | ||
|
|
||
| # Add prefixes back | ||
| prefixed_send_action_left = {f"left_{key}": value for key, value in send_action_left.items()} | ||
| prefixed_send_action_right = {f"right_{key}": value for key, value in send_action_right.items()} | ||
|
|
||
| return {**prefixed_send_action_left, **prefixed_send_action_right} | ||
|
|
||
| def disconnect(self): | ||
| self.left_arm.disconnect() | ||
| self.right_arm.disconnect() | ||
|
|
||
| for cam in self.cameras.values(): | ||
| cam.disconnect() | ||
39 changes: 39 additions & 0 deletions
39
src/lerobot/robots/bi_so100_follower/config_bi_so100_follower.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| #!/usr/bin/env python | ||
|
|
||
| # Copyright 2025 The HuggingFace Inc. team. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| from dataclasses import dataclass, field | ||
|
|
||
| from lerobot.cameras import CameraConfig | ||
|
|
||
| from ..config import RobotConfig | ||
|
|
||
|
|
||
| @RobotConfig.register_subclass("bi_so100_follower") | ||
| @dataclass | ||
| class BiSO100FollowerConfig(RobotConfig): | ||
| left_arm_port: str | ||
| right_arm_port: str | ||
|
|
||
| # Optional | ||
michel-aractingi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| left_arm_disable_torque_on_disconnect: bool = True | ||
| left_arm_max_relative_target: int | None = None | ||
| left_arm_use_degrees: bool = False | ||
| right_arm_disable_torque_on_disconnect: bool = True | ||
| right_arm_max_relative_target: int | None = None | ||
| right_arm_use_degrees: bool = False | ||
|
|
||
| # cameras (shared between both arms) | ||
| cameras: dict[str, CameraConfig] = field(default_factory=dict) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #!/usr/bin/env python | ||
|
|
||
| # Copyright 2025 The HuggingFace Inc. team. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| from .bi_so100_leader import BiSO100Leader | ||
michel-aractingi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| from .config_bi_so100_leader import BiSO100LeaderConfig | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.