Programming the Unitree G1 takes three things: the EDU version, an Ubuntu PC connected to the robot's internal network and the official unitree_sdk2 SDK. If the robot has just arrived, start with power on, remote control and standing it up for the first time.
Which G1 can be programmed
On the official G1 page custom software development is only available on the G1 EDU; the base G1 has 23 degrees of freedom and no computing module for development. The EDU versions range from 23 to 43 DoF, with an optional computing module (Unitree cites Orin boards) and optional Dex3-1 hands. At list price the G1 Air costs €19,809 and the G1-U1 EDU (23 DoF, 100 TOPS compute dock) €38,005, excluding VAT; shipping and insurance to the UK are quoted separately. To choose between U1, U2 and the versions with hands, see the guide which G1 version to choose.
Architecture: where your code runs
The G1 EDU has a motion control computer, managed by Unitree, and a development computer (PC2) for user code. The Unitree repositories, for example xr_teleoperate, put PC2 at 192.168.123.164 with user unitree. Unitree provides the initial password; the developer FAQ and the LeRobot guide for the G1 report 123. Change it as soon as the robot joins a shared network.
You have two options:
- Code on your laptop: the PC talks to the robot over DDS on the Ethernet cable. This is the most convenient choice for development and debugging.
- Code on PC2: you run the program over SSH on the robot. Needed for cable-free autonomy and to reduce latency.
ssh unitree@192.168.123.164
Configuring the PC network
- Connect the PC to the robot with an Ethernet cable.
- Set the interface to manual IPv4: address
192.168.123.99(the one Unitree suggests), netmask255.255.255.0. Do not use addresses already present on the robot, such as.164. - With
ip aorifconfignote the interface name (enp3s0,eth0...): all the SDK examples take it as an argument. - Check with
ping 192.168.123.164. If there is no reply, the problem is the network: no point opening the IDE.
A dedicated Ethernet port (even a USB adapter) avoids conflicts with the lab network.
Installing unitree_sdk2 (C++)
The unitree_sdk2 README gives Ubuntu 20.04, gcc 9.4.0, x86_64 or aarch64 CPU and CMake 3.10 or higher as the reference environment. Windows is not among the listed environments.
sudo apt-get update
sudo apt-get install -y cmake g++ build-essential libyaml-cpp-dev \
libeigen3-dev libboost-all-dev libfmt-dev
git clone https://github.com/unitreerobotics/unitree_sdk2.git
cd unitree_sdk2 && mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/opt/unitree_robotics
make
sudo make install
make also builds the examples, which end up in build/bin/. Installing to /opt/unitree_robotics is also what the unitree_mujoco simulator recommends.
Or Python: unitree_sdk2_python
The Python wrapper requires Python 3.8 or higher and cyclonedds 0.10.2:
git clone https://github.com/unitreerobotics/unitree_sdk2_python.git
cd unitree_sdk2_python
pip3 install -e .
If the installation stops with "Could not locate cyclonedds", the README explains how to build CycloneDDS from the releases/0.10.x branch and set CYCLONEDDS_HOME. The G1 examples are in example/g1/. A useful note from the examples README: the G1 and H1-2 use the unitree_hg messages, while the Go2, B2 and H1 use unitree_go.
Debug mode: before every low-level test
At power-on the G1 starts its own motion control, which keeps sending commands to the motors. If you publish on rt/lowcmd at the same time, the two command streams conflict. The procedure documented in the unitree_rl_gym deployment guide is:
- switch on the robot hanging in the harness and wait for zero-torque mode;
- press L2+R2 on the remote: the robot enters debug mode with the joints damped;
- only now run the low-level program.
In debug mode the robot does not balance on its own: leave it suspended until your controller holds it up.
First test: moving the ankles
The g1_ankle_swing_example example (source in example/g1/low_level/) reads rt/lowstate, writes rt/lowcmd and swings the ankles. From the build folder:
./bin/g1_ankle_swing_example enp3s0
Replace enp3s0 with your interface. If the terminal prints "CRC Error", the received message is corrupt or does not match the expected type: check the cable, the interface and the SDK version.
For high-level commands (standing, walking at set velocities) there is g1_loco_client, which uses the built-in motion control and therefore runs outside debug mode:
./bin/g1_loco_client --network_interface=enp3s0 --get_fsm_id
Main topics
| DDS topic | Contents | Source |
|---|---|---|
rt/lowstate | Motor state, IMU, battery | ankle swing example |
rt/lowcmd | Position, velocity and torque commands, kp/kd gains | ankle swing example |
rt/secondary_imu | Torso IMU | ankle swing example, unitree_mujoco |
rt/dex3/left/cmd, rt/dex3/right/cmd | Dex3-1 hand commands | g1_dex3_example |
rt/lf/dex3/left/state, rt/lf/dex3/right/state | Dex3-1 hand state | g1_dex3_example |
The Dex3-1 hands have topics separate from those of the body joints.
Simulate first: unitree_mujoco
unitree_mujoco is a MuJoCo-based simulator that exposes the same messages (LowCmd, LowState, SportModeState, torso IMU for the G1). A program written with unitree_sdk2, unitree_sdk2_python or unitree_ros2 runs first in simulation and then on the robot. The simulator supports low-level development only. To move to the robot you change the network interface and the DDS domain id: the README recommends 1 in simulation, while the default on the robot is 0. For reinforcement learning, unitree_rl_gym covers the train, play, sim2sim (MuJoCo) and sim2real cycle for the G1, H1, H1-2 and Go2.
When to add ROS 2
The direct SDK is the shortest route for motors and isolated tests. ROS 2 is needed when you have to integrate Nav2, MoveIt, standard vision pipelines, rosbag recording or several robots in the same lab. The unitree_ros2 package contains the unitree_hg messages and a low-level example for the G1 (g1/lowlevel/g1_low_level_example); Unitree has tested it on Ubuntu 22.04 with Humble (recommended) and on Ubuntu 20.04 with Foxy. Installation, network and the first topic are in the guide ROS 2 on Unitree robots.
Lab safety checklist
- First tests always with the robot suspended and a clear area around it.
- Low kp/kd gains and conservative torque limits in the first control loop.
- One person on the remote, ready to put the robot into damping.
- Same SDK version on the PC and on the robot; after an OTA update re-check the examples.
Abra Robotics offers training and software development on top of the SDK as services separate from the hardware: details on Software and Universities and Research.
Frequently asked questions
Can you program the base G1 (non-EDU)?
No. The Unitree page provides for custom software development only on the G1 EDU: the base G1 has neither the development computer nor SDK access.
Which operating system is needed on the development PC?
Ubuntu. For the SDK the reference environment is Ubuntu 20.04; for ROS 2 Unitree recommends Ubuntu 22.04 with Humble.
What is the address of the G1 development computer?
The G1 EDU PC2 answers on 192.168.123.164, user unitree. Your PC takes a free address on the same subnet.
Why do I need debug mode before a low-level test?
Because the built-in motion control keeps sending commands to the motors. With L2+R2, with the robot suspended, you stop it, and only then do you publish on rt/lowcmd.
Better to start from simulation or hardware?
From simulation. With unitree_mujoco the same program moves to the G1 by changing the network interface and the DDS domain id (1 in simulation, 0 on the robot).
Sources
- Unitree, G1 product page (versions, DoF, SDK development): unitree.com/g1
- Unitree, unitree_sdk2, README and G1 examples: github.com/unitreerobotics/unitree_sdk2 · example/g1
- Unitree, unitree_sdk2_python: github.com/unitreerobotics/unitree_sdk2_python
- Unitree, unitree_ros2: github.com/unitreerobotics/unitree_ros2
- Unitree, unitree_mujoco: github.com/unitreerobotics/unitree_mujoco
- Unitree, unitree_rl_gym, deployment guide on the real robot (L2+R2 debug mode): deploy_real/README.md
- Unitree, xr_teleoperate (PC2 on 192.168.123.164): github.com/unitreerobotics/xr_teleoperate
- Unitree Document Center, G1 developer section: support.unitree.com/home/en/G1_developer
- Hugging Face, LeRobot documentation for the Unitree G1: huggingface.co/docs/lerobot/en/unitree_g1
