mirror of
https://github.com/huggingface/lerobot.git
synced 2026-06-02 20:01:25 +00:00
* feat(robots): natively integrate Seeed Studio reBot B601-DM arm Add first-class LeRobot support for the Seeed Studio reBot arm, replacing the out-of-tree `lerobot-robot-seeed-b601` / `lerobot-teleoperator-rebot-arm-102` plugin packages. New devices: - robot `rebot_b601_follower` — single-arm B601-DM follower (6-DOF + gripper, Damiao CAN motors via `motorbridge`) - robot `bi_rebot_b601_follower` — bimanual follower composing two single arms - teleoperator `rebot_102_leader` — single-arm StarArm102 / reBot Arm 102 leader (FashionStar UART servos via `motorbridge-smart-servo`) - teleoperator `bi_rebot_102_leader` — bimanual leader composing two single arms The bimanual variants reuse the single-arm classes and namespace each arm's observation/action keys with `left_` / `right_` prefixes, so a bimanual StarArm102 leader can teleoperate a bimanual reBot B601 follower. Optional SDK imports are guarded; a `rebot` extra installs `motorbridge` and `motorbridge-smart-servo`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs: add reBot B601-DM calibration & dual-arm teleoperation guide Add docs/source/rebot_b601.mdx covering single-arm and bimanual calibration and teleoperation for the reBot B601-DM follower and reBot Arm 102 leader, with zero-position reference images from the Seeed Studio wiki. Register the page in the docs toctree. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs: fix reBot B601 MDX build (move JSON example out of <Tip>) The doc-builder parses `{...}` inside MDX component children as a Svelte expression, so the joint_directions JSON example broke the build. Move it into a top-level fenced code block. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs: apply prettier formatting to reBot B601 page Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs: remove duplicate colocated reBot B601 page docs/source/rebot_b601.mdx is the canonical, toctree-registered page; the colocated rebot_b601.md was a redundant thinner copy. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs: clarify 6-DOF leader fallback comment in reBot B601 follower Explain that holding wrist_yaw at zero is what lets a 6-DOF leader (e.g. so100_leader / so101_leader) teleoperate the 7-DOF follower. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor: address Caroline's PR review on reBot B601 integration - leader: remove _validate_config (no other lerobot device validates its config; a key mismatch now surfaces as a plain KeyError) - leader: simplify _round_to_valid_range to direct modular arithmetic instead of a bidirectional search loop - leader: inline the single-use _clamp helper - follower & leader: write MotorCalibration range_min/range_max from the configured joint_limits / joint_ranges instead of a fixed [-90, 90] - docs: add a "Find the USB ports" section (lerobot-find-port) and move the brltty/permissions tip there; link the OpenArm page for SocketCAN adapter configuration Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
144 lines
3.9 KiB
Python
144 lines
3.9 KiB
Python
# Copyright 2024 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.
|
|
|
|
"""
|
|
Replays the actions of an episode from a dataset on a robot.
|
|
|
|
Requires: pip install 'lerobot[core_scripts]' (includes dataset + hardware + viz extras)
|
|
|
|
Examples:
|
|
|
|
```shell
|
|
lerobot-replay \
|
|
--robot.type=so100_follower \
|
|
--robot.port=/dev/tty.usbmodem58760431541 \
|
|
--robot.id=black \
|
|
--dataset.repo_id=<USER>/record-test \
|
|
--dataset.episode=0
|
|
```
|
|
|
|
Example replay with bimanual so100:
|
|
```shell
|
|
lerobot-replay \
|
|
--robot.type=bi_so_follower \
|
|
--robot.left_arm_port=/dev/tty.usbmodem5A460851411 \
|
|
--robot.right_arm_port=/dev/tty.usbmodem5A460812391 \
|
|
--robot.id=bimanual_follower \
|
|
--dataset.repo_id=${HF_USER}/bimanual-so100-handover-cube \
|
|
--dataset.episode=0
|
|
```
|
|
|
|
"""
|
|
|
|
import logging
|
|
import time
|
|
from dataclasses import asdict, dataclass
|
|
from pathlib import Path
|
|
from pprint import pformat
|
|
|
|
from lerobot.configs import parser
|
|
from lerobot.datasets import LeRobotDataset
|
|
from lerobot.processor import (
|
|
make_default_robot_action_processor,
|
|
)
|
|
from lerobot.robots import ( # noqa: F401
|
|
Robot,
|
|
RobotConfig,
|
|
bi_openarm_follower,
|
|
bi_rebot_b601_follower,
|
|
bi_so_follower,
|
|
earthrover_mini_plus,
|
|
hope_jr,
|
|
koch_follower,
|
|
make_robot_from_config,
|
|
omx_follower,
|
|
openarm_follower,
|
|
reachy2,
|
|
rebot_b601_follower,
|
|
so_follower,
|
|
unitree_g1,
|
|
)
|
|
from lerobot.utils.constants import ACTION
|
|
from lerobot.utils.import_utils import register_third_party_plugins
|
|
from lerobot.utils.robot_utils import precise_sleep
|
|
from lerobot.utils.utils import (
|
|
init_logging,
|
|
log_say,
|
|
)
|
|
|
|
|
|
@dataclass
|
|
class DatasetReplayConfig:
|
|
# Dataset identifier. By convention it should match '{hf_username}/{dataset_name}' (e.g. `lerobot/test`).
|
|
repo_id: str
|
|
# Episode to replay.
|
|
episode: int
|
|
# Root directory where the dataset will be stored (e.g. 'dataset/path'). If None, defaults to $HF_LEROBOT_HOME/repo_id.
|
|
root: str | Path | None = None
|
|
# Limit the frames per second. By default, uses the policy fps.
|
|
fps: int = 30
|
|
|
|
|
|
@dataclass
|
|
class ReplayConfig:
|
|
robot: RobotConfig
|
|
dataset: DatasetReplayConfig
|
|
# Use vocal synthesis to read events.
|
|
play_sounds: bool = True
|
|
|
|
|
|
@parser.wrap()
|
|
def replay(cfg: ReplayConfig):
|
|
init_logging()
|
|
logging.info(pformat(asdict(cfg)))
|
|
|
|
robot_action_processor = make_default_robot_action_processor()
|
|
|
|
robot = make_robot_from_config(cfg.robot)
|
|
dataset = LeRobotDataset(cfg.dataset.repo_id, root=cfg.dataset.root, episodes=[cfg.dataset.episode])
|
|
|
|
actions = dataset.select_columns(ACTION)
|
|
|
|
robot.connect()
|
|
|
|
try:
|
|
log_say("Replaying episode", cfg.play_sounds, blocking=True)
|
|
for idx in range(dataset.num_frames):
|
|
start_episode_t = time.perf_counter()
|
|
|
|
action_array = actions[idx][ACTION]
|
|
action = {}
|
|
for i, name in enumerate(dataset.features[ACTION]["names"]):
|
|
action[name] = action_array[i]
|
|
|
|
robot_obs = robot.get_observation()
|
|
|
|
processed_action = robot_action_processor((action, robot_obs))
|
|
|
|
_ = robot.send_action(processed_action)
|
|
|
|
dt_s = time.perf_counter() - start_episode_t
|
|
precise_sleep(max(1 / dataset.fps - dt_s, 0.0))
|
|
finally:
|
|
robot.disconnect()
|
|
|
|
|
|
def main():
|
|
register_third_party_plugins()
|
|
replay()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|