HopeJR

前置条件

安装 LeRobot

按照安装说明安装 LeRobot。

安装带 HopeJR 依赖的 LeRobot:

pip install -e ".[hopejr]"

设备配置

在开始 calibration 和操作之前,你需要确定每个 HopeJR 组件的 USB 端口。运行此脚本以查找机械臂、手部、手套和外骨骼的 USB 端口:

lerobot-find-port

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

步骤 1:calibration

在执行 teleoperation 之前,需要 calibrate Hope JR 的肢体。calibration 文件将保存在 ~/.cache/huggingface/lerobot/calibration

1.1 calibrate 机器人手部

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

运行 calibration 脚本时,会弹出 calibration GUI。手指关节命名如下:

拇指

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

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

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

这些都需要通过 GUI 逐一 calibration。 注意,尺侧和桡侧屈肌应具有相同大小的范围(但偏移不同),以获得对称的运动。

Setting boundaries in the hand calibration GUI

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

Saving calibration values

为所有关节设置好合适的边界后,点击 “Save” 将 calibration 值保存到电机。

1.2 calibration teleoperation 手套

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

calibration 完成后,系统会将 calibration 保存到 /Users/your_username/.cache/huggingface/lerobot/calibration/teleoperators/homunculus_glove/red.json

1.3 calibrate 机器人手臂

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

这将打开 calibration GUI,你可以在其中为每个电机设置范围限制。手臂 action 组织如下:

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

Setting boundaries in the arm calibration GUI

使用 calibration 界面为每个关节设置范围边界。让每个关节完成其全部运动范围,并相应地调整最小值和最大值。为所有关节设置好合适的边界后,保存 calibration。

1.4 calibration teleoperation 外骨骼

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

外骨骼可用于控制机器人手臂。calibration 时,系统会提示你让所有关节完成其全部运动范围:

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:teleoperation

由于 Feetech 中间件中的全局变量冲突,手臂和手部的 teleoperation 必须在不同的 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 进行录制、回放和训练仍处于实验阶段。

录制

此步骤录制 dataset,可参见此处的示例。

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=<USER>/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 \
    --dataset.streaming_encoding=true \
    --dataset.encoder_threads=2 \
    --display_data=true
# Optional: --dataset.rgb_encoder.vcodec=auto

回放

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

训练

lerobot-train \
  --dataset.repo_id=<USER>/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=<USER>/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=<USER>/eval_hopejr \
  --dataset.single_task="Evaluate hopejr hand policy" \
  --dataset.num_episodes=10 \
  --dataset.streaming_encoding=true \
  --dataset.encoder_threads=2 \
  --policy.path=outputs/train/hopejr_hand/checkpoints/last/pretrained_model
# Optional: --dataset.rgb_encoder.vcodec=auto
在 GitHub 上更新