Skip to content

Commit 37f43df

Browse files
nepyopemichel-aractingiCopilot
authored
Feat/add unitree g1 robot (#2530)
* add unitree_g1_robot_class * finish locomotion loading code * precommit * separate groot locomotion logic * remove leftover locomotion variable, unify kp kd * format config * properly comment config, example locomotion and unitree_g1 class * ready to review * download policy from the hub in `examples/unitree_g1/gr00t_locomotion` * fix linter * make precommit happy, add ignore flags * linter pt3 * linter pt4 * [done] make precommit happy * fix linter 5 * add docs * push utils * feat(robots): add Unitree G1 humanoid support with ZMQ bridge (#2539) * feat(robots): add Unitree G1 humanoid support with ZMQ bridge - Use JSON + base64 serialization for secure communication instead of pickle - Add documentation section - Rename robot_server to run_g1_server - Add dependecies to pyproject.toml * nit in docs * remove globals use * cast robot data to int/float * ensure robot is connected before changing mode * temperature can be list, average in such case --------- Co-authored-by: Martino Russi <[email protected]> * style nit * remove transform_imu_data * remove scipy dependency * modify toml, add external unitree_sdk2py dep * return actions from send_action * cleaning * add instructions for local deployment * Update src/lerobot/robots/unitree_g1/unitree_g1.py Co-authored-by: Copilot <[email protected]> Signed-off-by: Martino Russi <[email protected]> * update config and readme * update docs * update docs * remove torch import * fix docs * remove ip from docs * add licence header --------- Signed-off-by: Martino Russi <[email protected]> Co-authored-by: Michel Aractingi <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 5f7b5f2 commit 37f43df

File tree

10 files changed

+1365
-0
lines changed

10 files changed

+1365
-0
lines changed

docs/source/_toctree.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979
title: Hope Jr
8080
- local: reachy2
8181
title: Reachy 2
82+
- local: unitree_g1
83+
title: Unitree G1
8284
title: "Robots"
8385
- sections:
8486
- local: phone_teleop

docs/source/unitree_g1.mdx

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
# Unitree G1 Robot Setup and Control
2+
3+
This guide covers the complete setup process for the Unitree G1 humanoid, from initial connection to running gr00t_wbc locomotion.
4+
5+
## About the Unitree G1
6+
7+
We offer support for both 29 and 23 DOF G1. In this first PR we introduce:
8+
9+
- **`unitree g1` robot class, handling low level communication with the humanoid**
10+
- **ZMQ socket bridge** for remote communication over WiFi, allowing one to deploy policies remotely instead of over ethernet or directly on the Orin
11+
- **GR00T locomotion policy** for bipedal walking and balance
12+
13+
---
14+
15+
## Part 1: Connect to Robot over Ethernet
16+
17+
### Step 1: Configure Your Computer's Ethernet Interface
18+
19+
Set a static IP on the same subnet as the robot:
20+
21+
```bash
22+
# Replace 'enp131s0' with your ethernet interface name (check with `ip a`)
23+
sudo ip addr flush dev enp131s0
24+
sudo ip addr add 192.168.123.200/24 dev enp131s0
25+
sudo ip link set enp131s0 up
26+
```
27+
28+
**Note**: The robot's Ethernet IP is fixed at `192.168.123.164`. Your computer must use `192.168.123.x` where x ≠ 164.
29+
30+
### Step 2: SSH into the Robot
31+
32+
```bash
33+
34+
# Password: 123
35+
```
36+
37+
You should now be connected to the robot's onboard computer.
38+
39+
---
40+
41+
## Part 2: Enable WiFi on the Robot
42+
43+
Once connected via Ethernet, follow these steps to enable WiFi:
44+
45+
### Step 1: Enable WiFi Hardware
46+
47+
```bash
48+
# Unblock WiFi radio
49+
sudo rfkill unblock wifi
50+
sudo rfkill unblock all
51+
52+
# Bring up WiFi interface
53+
sudo ip link set wlan0 up
54+
55+
# Enable NetworkManager control
56+
sudo nmcli radio wifi on
57+
sudo nmcli device set wlan0 managed yes
58+
sudo systemctl restart NetworkManager
59+
```
60+
61+
### Step 2: Enable Internet Forwarding
62+
63+
**On your laptop:**
64+
65+
```bash
66+
# Enable IP forwarding
67+
sudo sysctl -w net.ipv4.ip_forward=1
68+
69+
# Set up NAT (replace wlp132s0f0 with your WiFi interface)
70+
sudo iptables -t nat -A POSTROUTING -o wlp132s0f0 -s 192.168.123.0/24 -j MASQUERADE
71+
sudo iptables -A FORWARD -i wlp132s0f0 -o enp131s0 -m state --state RELATED,ESTABLISHED -j ACCEPT
72+
sudo iptables -A FORWARD -i enp131s0 -o wlp132s0f0 -j ACCEPT
73+
```
74+
75+
**On the robot:**
76+
77+
```bash
78+
# Add laptop as default gateway
79+
sudo ip route del default 2>/dev/null || true
80+
sudo ip route add default via 192.168.123.200 dev eth0
81+
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
82+
83+
# Test connection
84+
ping -c 3 8.8.8.8
85+
```
86+
87+
### Step 3: Connect to WiFi Network
88+
89+
```bash
90+
# List available networks
91+
nmcli device wifi list
92+
93+
# Connect to your WiFi (example)
94+
sudo nmcli connection add type wifi ifname wlan0 con-name "YourNetwork" ssid "YourNetwork"
95+
sudo nmcli connection modify "YourNetwork" wifi-sec.key-mgmt wpa-psk
96+
sudo nmcli connection modify "YourNetwork" wifi-sec.psk "YourPassword"
97+
sudo nmcli connection modify "YourNetwork" connection.autoconnect yes
98+
sudo nmcli connection up "YourNetwork"
99+
100+
# Check WiFi IP address
101+
ip a show wlan0
102+
```
103+
104+
### Step 4: SSH Over WiFi
105+
106+
Once connected to WiFi, note the robot's IP address and disconnect the Ethernet cable. You can now SSH over WiFi:
107+
108+
```bash
109+
ssh unitree@<YOUR_ROBOT_IP>
110+
# Password: 123
111+
```
112+
113+
Replace `<YOUR_ROBOT_IP>` with your robot's actual WiFi IP address (e.g., `172.18.129.215`).
114+
115+
---
116+
117+
## Part 3: Robot Server Setup
118+
119+
### Step 1: Install LeRobot on the Orin
120+
121+
SSH into the robot and install LeRobot:
122+
123+
```bash
124+
ssh unitree@<YOUR_ROBOT_IP>
125+
126+
conda create -y -n lerobot python=3.10
127+
conda activate lerobot
128+
git clone https://github.com/huggingface/lerobot.git
129+
cd lerobot
130+
pip install -e '.[unitree_g1]'
131+
git clone https://github.com/unitreerobotics/unitree_sdk2_python.git
132+
cd unitree_sdk2_python && pip install -e .
133+
```
134+
135+
**Note**: The Unitree SDK requires CycloneDDS v0.10.2 to be installed. See the [Unitree SDK documentation](https://github.com/unitreerobotics/unitree_sdk2_python) for details.
136+
137+
### Step 2: Run the Robot Server
138+
139+
On the robot:
140+
141+
```bash
142+
python src/lerobot/robots/unitree_g1/run_g1_server.py
143+
```
144+
145+
**Important**: Keep this terminal running. The server must be active for remote control.
146+
147+
---
148+
149+
## Part 4: Running GR00T Locomotion
150+
151+
With the robot server running, you can now control the robot from your laptop.
152+
153+
### Step 1: Install LeRobot on your machine
154+
155+
```bash
156+
conda create -y -n lerobot python=3.10
157+
conda activate lerobot
158+
git clone https://github.com/huggingface/lerobot.git
159+
cd lerobot
160+
pip install -e '.[unitree_g1]'
161+
git clone https://github.com/unitreerobotics/unitree_sdk2_python.git
162+
cd unitree_sdk2_python && pip install -e .
163+
```
164+
165+
### Step 2: Update Robot IP in Config
166+
167+
Edit the config file to match your robot's WiFi IP:
168+
169+
```python
170+
# In src/lerobot/robots/unitree_g1/config_unitree_g1.py
171+
robot_ip: str = "<YOUR_ROBOT_IP>" # Replace with your robot's WiFi IP.
172+
```
173+
174+
**Note**: When running directly on the G1 (not remotely), set `robot_ip: str = "127.0.0.1"` instead.
175+
176+
### Step 3: Run the Locomotion Policy
177+
178+
```bash
179+
# Run GR00T locomotion controller
180+
python examples/unitree_g1/gr00t_locomotion.py --repo-id "nepyope/GR00T-WholeBodyControl_g1"
181+
```
182+
183+
### Step 4: Control with Remote
184+
185+
- **Left stick**: Forward/backward and left/right movement
186+
- **Right stick**: Rotation
187+
- **R1 button**: Raise waist height
188+
- **R2 button**: Lower waist height
189+
190+
Press `Ctrl+C` to stop the policy.
191+
192+
---
193+
194+
## Additional Resources
195+
196+
- [Unitree SDK Documentation](https://github.com/unitreerobotics/unitree_sdk2_python)
197+
- [GR00T Policy Repository](https://huggingface.co/nepyope/GR00T-WholeBodyControl_g1)
198+
- [LeRobot Documentation](https://github.com/huggingface/lerobot)
199+
- [Unitree_IL_Lerobot](https://github.com/unitreerobotics/unitree_IL_lerobot)
200+
201+
---
202+
203+
_Last updated: December 2025_

0 commit comments

Comments
 (0)