LeRobot 文档

HopeJR

Hugging Face's logo
加入 Hugging Face 社区

并获得增强的文档体验

开始使用

HopeJR

先决条件

安装 LeRobot

请遵循 安装说明 来安装 LeRobot。

安装 LeRobot 及 HopeJR 依赖项

pip install -e ".[hopejr]"

设备配置

在开始校准和操作之前,您需要识别每个 HopeJR 组件的 USB 端口。运行此脚本以查找机械臂、手、手套和外骨骼的 USB 端口。

lerobot-find-port

这将显示可用的 USB 端口及其关联设备。请记下端口路径(例如,/dev/tty.usbmodem58760433331/dev/tty.usbmodem11301),因为在录制数据、回放片段或运行遥操作脚本时,您需要在 --robot.port--teleop.port 参数中指定它们。

第 1 步:校准

在执行遥操作之前,需要校准 HopeJR 的肢体。校准文件将保存在 ~/.cache/huggingface/lerobot/calibration 中。

1.1 校准机器人手

lerobot-calibrate \
    --robot.type=hope_jr_hand \
    --robot.port=/dev/tty.usbmodem58760432281 \
    --robot.id=blue \
    --robot.side=right

运行校准脚本时,将弹出一个校准图形用户界面(GUI)。手指关节的名称如下:

拇指:

  • CMC:连接拇指和手掌的基关节
  • MCP:指关节
  • PIP:第一指间关节
  • DIP:指尖关节

食指、中指、无名指和小指:

  • 桡侧屈肌:将手指根部向拇指方向移动
  • 尺侧屈肌:将手指根部向小指方向移动
  • PIP/DIP:弯曲手指的远节指骨和近节指骨

这些关节中的每一个都需要通过 GUI 单独校准。请注意,尺侧屈肌和桡侧屈肌的范围大小应相同(但偏移量不同),以获得对称的运动。

Setting boundaries in the hand calibration GUI

使用校准界面为每个关节设置范围边界,如上所示。

Saving calibration values

为所有关节设置好适当的边界后,点击“保存”将校准值保存到电机中。

1.2 校准遥操作手套

lerobot-calibrate \
    --teleop.type=homunculus_glove \
    --teleop.port=/dev/tty.usbmodem11201 \
    --teleop.id=red \
    --teleop.side=right

将每根手指在其整个运动范围内移动,从拇指开始。

Move thumb through its entire range of motion.
Recording positions. Press ENTER to stop...

-------------------------------------------
NAME      |    MIN |    POS |    MAX
thumb_cmc |   1790 |   1831 |   1853
thumb_mcp |   1497 |   1514 |   1528
thumb_pip |   1466 |   1496 |   1515
thumb_dip |   1463 |   1484 |   1514

继续校准每一根手指

Move middle through its entire range of motion.
Recording positions. Press ENTER to stop...

-------------------------------------------
NAME                 |    MIN |    POS |    MAX
middle_mcp_abduction |   1598 |   1718 |   1820
middle_mcp_flexion   |   1512 |   1658 |   2136
middle_dip           |   1484 |   1500 |   1547

校准完成后,系统将把校准数据保存到 /Users/your_username/.cache/huggingface/lerobot/calibration/teleoperators/homunculus_glove/red.json

1.3 校准机器人手臂

lerobot-calibrate \
    --robot.type=hope_jr_arm \
    --robot.port=/dev/tty.usbserial-1110 \
    --robot.id=white

这将打开一个校准 GUI,您可以在其中为每个电机设置范围限制。手臂的运动组织如下:

  • 肩部:俯仰、偏航和翻滚
  • 肘部:弯曲
  • 手腕:俯仰、偏航和翻滚

Setting boundaries in the arm calibration GUI

使用校准界面为每个关节设置范围边界。将每个关节在其整个运动范围内移动,并相应地调整最小值和最大值。为所有关节设置好适当的边界后,保存校准。

1.4 校准遥操作外骨骼

lerobot-calibrate \
    --teleop.type=homunculus_arm \
    --teleop.port=/dev/tty.usbmodem11201 \
    --teleop.id=black

外骨骼可以用来控制机器人手臂。在校准过程中,系统会提示您将所有关节在其整个运动范围内移动。

Move all joints through their entire range of motion.
Recording positions. Press ENTER to stop...

-------------------------------------------
-------------------------------------------
NAME            |    MIN |    POS |    MAX
shoulder_pitch  |    586 |    736 |    895
shoulder_yaw    |   1257 |   1374 |   1390
shoulder_roll   |    449 |   1034 |   2564
elbow_flex      |   3023 |   3117 |   3134
wrist_roll      |   3073 |   3096 |   3147
wrist_yaw       |   2143 |   2171 |   2185
wrist_pitch     |   1975 |   1993 |   2074
Calibration saved to /Users/your_username/.cache/huggingface/lerobot/calibration/teleoperators/homunculus_arm/black.json

第 2 步:遥操作

由于 Feetech 中间件中的全局变量冲突,手臂和手的遥操作必须在单独的 shell 会话中运行。

lerobot-teleoperate \
    --robot.type=hope_jr_hand \
    --robot.port=/dev/tty.usbmodem58760432281 \
    --robot.id=blue \
    --robot.side=right \
    --teleop.type=homunculus_glove \
    --teleop.port=/dev/tty.usbmodem11201 \
    --teleop.id=red \
    --teleop.side=right \
    --display_data=true \
    --fps=30

手臂

lerobot-teleoperate \
    --robot.type=hope_jr_arm \
    --robot.port=/dev/tty.usbserial-1110 \
    --robot.id=white \
    --teleop.type=homunculus_arm \
    --teleop.port=/dev/tty.usbmodem11201 \
    --teleop.id=black \
    --display_data=true \
    --fps=30

第 3 步:录制、回放、训练

使用 Hope-JR 进行录制、回放和训练仍处于实验阶段。

录制

此步骤记录数据集,您可以在此处查看示例。

lerobot-record \
    --robot.type=hope_jr_hand \
    --robot.port=/dev/tty.usbmodem58760432281 \
    --robot.id=right \
    --robot.side=right \
    --robot.cameras='{"main": {"type": "opencv", "index_or_path": 0, "width": 640, "height": 480, "fps": 30}}' \
    --teleop.type=homunculus_glove \
    --teleop.port=/dev/tty.usbmodem1201 \
    --teleop.id=right \
    --teleop.side=right \
    --dataset.repo_id=nepyope/hand_record_test_with_video_data \
    --dataset.single_task="Hand recording test with video data" \
    --dataset.num_episodes=1 \
    --dataset.episode_time_s=5 \
    --dataset.push_to_hub=true \
    --dataset.private=true \
    --display_data=true

回放

lerobot-replay \
    --robot.type=hope_jr_hand \
    --robot.port=/dev/tty.usbmodem58760432281 \
    --robot.id=right \
    --robot.side=right \
    --dataset.repo_id=nepyope/hand_record_test_with_camera \
    --dataset.episode=0

训练

lerobot-train \
  --dataset.repo_id=nepyope/hand_record_test_with_video_data \
  --policy.type=act \
  --output_dir=outputs/train/hopejr_hand \
  --job_name=hopejr \
  --policy.device=mps \
  --wandb.enable=true \
  --policy.repo_id=nepyope/hand_test_policy

评估

您可以在此处查看此训练运行的示例。

lerobot-record \
  --robot.type=hope_jr_hand \
  --robot.port=/dev/tty.usbmodem58760432281 \
  --robot.id=right \
  --robot.side=right \
  --robot.cameras='{"main": {"type": "opencv", "index_or_path": 0, "width": 640, "height": 480, "fps": 30}}' \
  --display_data=false \
  --dataset.repo_id=nepyope/eval_hopejr \
  --dataset.single_task="Evaluate hopejr hand policy" \
  --dataset.num_episodes=10 \
  --policy.path=outputs/train/hopejr_hand/checkpoints/last/pretrained_model
< > 在 GitHub 上更新