LeRobot 文件
Unitree G1
並獲得增強的文件體驗
開始使用
Unitree G1
Unitree G1 人形機器人現已支援 LeRobot!您可以進行遠端操作、訓練移動操作 (locomanipulation) 策略、在模擬環境中測試等。同時支援 29 和 23 自由度 (DoF) 的版本。
第 1 部分:入門指南
安裝 Unitree SDK
請遵循 unitree_sdk2_python 安裝指南。已在 unitree_sdk2py==1.0.1 和 cyclonedds==0.10.2 版本下測試通過。
conda create -y -n lerobot python=3.12
conda activate lerobot
git clone https://github.com/unitreerobotics/unitree_sdk2_python.git
cd unitree_sdk2_python
pip install -e .
cd ..安裝 LeRobot
conda install ffmpeg -c conda-forge
conda install -c conda-forge "pinocchio>=3.0.0,<4.0.0"
git clone https://github.com/huggingface/lerobot.git
cd lerobot
pip install -e '.[unitree_g1]'目前,必須從 conda-forge(而非 pip)安裝 pinocchio,以包含機械手臂逆運動學 (IK) 所需的 CasADi 綁定。
測試安裝(模擬環境)
模擬環境有其專屬的相依套件。請查看模擬環境相依套件:Unitree G1 Mujoco EnvHub。
pip install mujoco loguru msgpack msgpack-numpy
lerobot-teleoperate \
--robot.type=unitree_g1 \
--robot.is_simulation=true \
--teleop.type=unitree_g1 \
--teleop.id=wbc_unitree \
--robot.cameras='{"global_view": {"type": "zmq", "server_address": "localhost", "port": 5555, "camera_name": "head_camera", "width": 640, "height": 480, "fps": 30, "warmup_s": 5}}' \
--display_data=true \
--robot.controller=GrootLocomotionController這將為 G1 啟動一個 MuJoCo 模擬實例。您可以在啟動前將遊戲手把連接到您的機器,以便在模擬中控制機器人的移動。我們透過 --robot.controller 支援 HolosomaLocomotionController 和 GrootLocomotionController。
- 按下
9以釋放機器人 - 按下
7/8以增加 / 減少腰部高度
連接到實體機器人
G1 的乙太網路 IP 固定為 192.168.123.164。您的電腦必須在同一個子網路上擁有一個靜態 IP:192.168.123.x,其中 x ≠ 164。
# Replace 'enp131s0' with your ethernet interface name (check with `ip a`)
sudo ip addr flush dev enp131s0
sudo ip addr add 192.168.123.200/24 dev enp131s0
sudo ip link set enp131s0 up透過 SSH 連接至機器人
ssh unitree@192.168.123.164
# Password: 123透過乙太網路共用網際網路
G1 需要網際網路存取權限來複製儲存庫並安裝套件。請透過乙太網路分享您筆記型電腦的網路連線。
在您的筆記型電腦上
sudo sysctl -w net.ipv4.ip_forward=1
# Replace wlp132s0f0 with your WiFi interface name
sudo iptables -t nat -A POSTROUTING -o wlp132s0f0 -s 192.168.123.0/24 -j MASQUERADE
sudo iptables -A FORWARD -i wlp132s0f0 -o enp131s0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i enp131s0 -o wlp132s0f0 -j ACCEPT在 G1 上
sudo ip route del default 2>/dev/null || true
sudo ip route add default via 192.168.123.200 dev eth0
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
# Verify
ping -c 3 8.8.8.8在 G1 上安裝 Unitree SDK
conda create -y -n lerobot python=3.12
conda activate lerobot
git clone https://github.com/unitreerobotics/unitree_sdk2_python.git
cd unitree_sdk2_python
python -m pip install -e .
cd ..在 G1 上安裝 LeRobot
git clone https://github.com/huggingface/lerobot.git
cd lerobot
conda install -c conda-forge "pinocchio>=3.0.0,<4.0.0"
python -m pip install -e '.[unitree_g1]'目前,必須從 conda-forge(而非 pip)安裝 pinocchio,以包含機械手臂逆運動學 (IK) 所需的 CasADi 綁定。
(選用)在機器人上啟用 WiFi
若要進行無線 SSH 存取,您可以在 G1 上啟用 WiFi(預設為停用)
sudo rfkill unblock all
sudo ip link set wlan0 up
sudo nmcli radio wifi on
sudo nmcli device set wlan0 managed yes
sudo systemctl restart NetworkManager連接到 WiFi 網路
nmcli device wifi list
sudo nmcli connection add type wifi ifname wlan0 con-name "YourNetwork" ssid "YourNetwork"
sudo nmcli connection modify "YourNetwork" wifi-sec.key-mgmt wpa-psk
sudo nmcli connection modify "YourNetwork" wifi-sec.psk "YourPassword"
sudo nmcli connection modify "YourNetwork" connection.autoconnect yes
sudo nmcli connection up "YourNetwork"
ip a show wlan0之後您就可以透過 WiFi 而非乙太網路進行 SSH 連接
ssh unitree@<ROBOT_WIFI_IP>
# Password: 123第 2 部分:遠端操作與移動控制
執行機器人伺服器
在機器人上(從 ~/lerobot 目錄)
cd ~/lerobot
python src/lerobot/robots/unitree_g1/run_g1_server.py --camera執行移動控制策略
您可以從筆記型電腦透過乙太網路、WiFi(實驗性功能)或直接在機器人上執行遠端操作客戶端。請注意您的網路可能造成的潛在延遲。
從您的筆記型電腦
lerobot-teleoperate \
--robot.type=unitree_g1 \
--robot.is_simulation=false \
--robot.robot_ip=<ROBOT_IP> \
--teleop.type=unitree_g1 \
--teleop.id=wbc_unitree \
--robot.cameras='{"global_view": {"type": "zmq", "server_address": "<ROBOT_IP>", "port": 5555, "camera_name": "head_camera", "width": 640, "height": 480, "fps": 30}}' \
--display_data=true \
--robot.controller=HolosomaLocomotionController我們透過 --robot.controller 支援 GrootLocomotionController 和 HolosomaLocomotionController。
第 3 部分:使用 Homunculus 外骨骼進行移動操作
我們透過 Homunculus 外骨骼提供移動操作解決方案 — 這是一個開源的 7 自由度全身控制外骨骼。點擊此處查看。
校正
lerobot-calibrate \ --teleop.type=unitree_g1 \ --teleop.left_arm_config.port=/dev/ttyACM1 \ --teleop.right_arm_config.port=/dev/ttyACM0 \ --teleop.id=exo
在校準期間,請將每個關節移動至其完整活動範圍。校準完成後,將關節移動至中性位置,然後按下 n 繼續。
記錄資料集
lerobot-record \
--robot.type=unitree_g1 \
--robot.is_simulation=true \
--robot.cameras='{"global_view": {"type": "zmq", "server_address": "localhost", "port": 5555, "camera_name": "head_camera", "width": 640, "height": 480, "fps": 30}}' \
--teleop.type=unitree_g1 \
--teleop.left_arm_config.port=/dev/ttyACM1 \
--teleop.right_arm_config.port=/dev/ttyACM0 \
--teleop.id=exo \
--dataset.repo_id=your-username/dataset-name \
--dataset.single_task="Test" \
--dataset.num_episodes=2 \
--dataset.episode_time_s=5 \
--dataset.reset_time_s=5 \
--dataset.push_to_hub=true \
--dataset.streaming_encoding=true \
--dataset.encoder_threads=2注意:如果您僅使用遊戲手把,請省略
--teleop.left_arm_config.port和--teleop.right_arm_config.port參數。
資料集範例:nepyope/unitree_box_move_blue_full
第 4 部分:訓練與推論
訓練
python src/lerobot/scripts/lerobot_train.py \
--dataset.repo_id=your-username/dataset-name \
--policy.type=pi05 \
--output_dir=./outputs/pi05_training \
--job_name=pi05_training \
--policy.repo_id=your-username/your-repo-id \
--policy.pretrained_path=lerobot/pi05_base \
--policy.compile_model=true \
--policy.gradient_checkpointing=true \
--wandb.enable=true \
--policy.dtype=bfloat16 \
--policy.freeze_vision_encoder=false \
--policy.train_expert_only=false \
--steps=3000 \
--policy.device=cuda \
--batch_size=32使用 RTC 進行推論
訓練完成後,我們建議使用即時控制 (RTC) 來部署推論策略。
python examples/rtc/eval_with_real_robot.py \
--policy.path=your-username/your-repo-id \
--policy.device=cuda \
--robot.type=unitree_g1 \
--robot.is_simulation=false \
--robot.controller=HolosomaLocomotionController \
--robot.cameras='{"global_view": {"type": "zmq", "server_address": "<ROBOT_IP>", "port": 5555, "camera_name": "head_camera", "width": 640, "height": 480, "fps": 30}}' \
--task="task_description" \
--duration=1000 \
--fps=30 \
--rtc.enabled=true額外資源
最後更新:2026 年 3 月
在 GitHub 上更新