LeRobot 文件

HopeJR

Hugging Face's logo
加入 Hugging Face 社群

並獲得增強的文件體驗

開始使用

HopeJR

先修條件

安裝 LeRobot

請遵循安裝說明來安裝 LeRobot。

安裝含有 HopeJR 依賴項的 LeRobot

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:指尖關節

食指、中指、無名指與小指:

  • 橈側屈肌 (Radial flexor):將手指根部向拇指方向移動
  • 尺側屈肌 (Ulnar flexor):將手指根部向小指方向移動
  • PIP/DIP:彎曲手指的遠端與近端指骨

每一個關節都需要透過 GUI 單獨進行校準。請注意,為了獲得對稱的運動,尺側屈肌和橈側屈肌應具有相同大小的活動範圍(但具有不同的偏移量)。

Setting boundaries in the hand calibration GUI

使用校準介面來設定如上所示的每個關節的範圍邊界。

Saving calibration values

一旦您為所有關節設定了適當的邊界,請點擊「儲存」(Save) 將校準值寫入馬達。

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,您可以在其中設定每個馬達的範圍限制。機械手臂的運動組織如下:

  • 肩部 (Shoulder):俯仰 (pitch)、偏航 (yaw) 與翻滾 (roll)
  • 肘部 (Elbow):彎曲 (flex)
  • 腕部 (Wrist):俯仰 (pitch)、偏航 (yaw) 與翻滾 (roll)

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 會話中執行。

手 (Hand)

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

手臂 (Arm)

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=<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 \
    # --dataset.vcodec=auto \
    --display_data=true

重播

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 \
  # --dataset.vcodec=auto \
  --policy.path=outputs/train/hopejr_hand/checkpoints/last/pretrained_model
在 GitHub 上更新

© . This site is unofficial and not affiliated with Hugging Face, Inc.