Programming the Unitree G1 is not just about installing an SDK. You need to choose the level you will work at (high-level commands, direct motor control, ROS 2, reinforcement learning policies), where the code will run and how to test it without putting the robot at risk. This guide puts Unitree's official tools in order and proposes the workflow we use in CALIGO development projects.
If you have not connected the robot to your PC yet, start from the G1 operational guide: networking, IP addresses and debug mode are prerequisites for everything below.
The official tools
| Repository | What it is for |
|---|---|
| unitree_sdk2 | Official C++ SDK based on CycloneDDS, with examples for G1, H2, R1, Go2, B2, AS2 and other models. |
| unitree_sdk2_python | Python interface to the same SDK, useful for prototypes and integration with machine learning tools. |
| unitree_ros2 | Messages and examples for talking to the robot directly from ROS 2. |
| unitree_mujoco | MuJoCo simulator speaking the same protocol as the SDK: the same code runs in simulation and on the robot. |
| unitree_rl_gym | Reinforcement learning pipeline (Isaac Gym and MuJoCo) with deployment on the real robot. |
| xr_teleoperate | Teleoperation with XR headsets and data collection for imitation learning. |
Setting up the development environment
C++ SDK
The unitree_sdk2 README lists Ubuntu 20.04 LTS on x86_64 and aarch64 as the reference platform, with GCC 9.4 and CMake 3.10 or later. Dependencies and build are those of a classic CMake project:
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 ..
make
To install it system-wide use sudo make install, or a dedicated prefix with -DCMAKE_INSTALL_PREFIX. Many teams work on Ubuntu 22.04, but it is not the platform listed in the README: if you hit build errors, the first step is to check package versions.
Python SDK
unitree_sdk2_python requires Python 3.8 or later and CycloneDDS 0.10.2. It is installed from source:
git clone https://github.com/unitreerobotics/unitree_sdk2_python.git
cd unitree_sdk2_python
pip3 install -e .
Examples are launched by passing the name of the network interface connected to the robot, for example python3 ./example/...script.py enp3s0. Forgetting or mistyping this argument is by far the most frequent error.
Where to run the code
- External PC over Ethernet — the most convenient way to develop and debug, with a static IP in the
192.168.123.xsubnet. - On-board development computer (
192.168.123.164, Jetson Orin NX on EDU units) — needed when the robot must run untethered or when network latency matters. - Never on the locomotion computer (
.161), which is reserved for Unitree's motion control.
A practical strategy: develop and test on the PC, then move only stable code to the on-board computer.
High level or low level?
The G1 exposes two very different ways of control:
- High level: you ask Unitree's locomotion service to walk, stop or change posture. Balance stays with the firmware. It is the right starting point for applications, demos and integration with perception and navigation.
- Low level: you send commands directly to the motors (position, velocity, torque, gains) and read joint, IMU and battery state. It is used for custom controllers and RL policies. It requires debug mode, which switches off the locomotion service, and a suspended robot.
The G1 uses the unitree_hg message family, shared with H1-2 and AS2, while Go2, B2 and H1 use unitree_go. When adapting examples written for another robot, make sure you use the right message types.
Simulation before the robot
unitree_mujoco is the step we always recommend before touching the hardware. The simulator is built on top of the SDK: if you do not specify a network interface it uses the local interface and a domain ID reserved for simulation (1), while on the real robot you use domain ID 0 and the connected interface. In practice the same program moves from simulation to the robot by changing only the network configuration.
For learned locomotion, unitree_rl_gym follows the Train → Play → Sim2Sim → Sim2Real flow: training in Isaac Gym, verification, cross-testing in MuJoCo and finally deployment with deploy_real.py, always with the robot in debug mode. For more recent simulation environments see our guide to NVIDIA Isaac and Omniverse.
Teleoperation and data collection
For manipulation and imitation learning projects, xr_teleoperate lets you drive the G1 (23 and 29 DoF versions) with Apple Vision Pro, PICO 4 Ultra Enterprise or Meta Quest 3, with Dex3-1, Dex1-1, Inspire or BrainCo hands, and record episodes compatible with unitree_IL_lerobot. Hugging Face's LeRobot project also officially supports the G1.
A 7-step workflow
- Stable network: ping to .161 and .164, SSH into the development computer.
- SDK built and a first read-only state example (no commands sent).
- Simulation in unitree_mujoco with the same code.
- High level on the real robot, in a safe area.
- Low level only with the robot suspended, low gains and gradual transitions.
- ROS 2 if you need to integrate navigation and sensors: see ROS 2 on Unitree.
- On-board deployment and endurance tests, writing down firmware and SDK versions.
Frequent mistakes
- No data from the SDK: wrong network interface or a CycloneDDS version other than 0.10.x.
- High-level commands ignored: the robot is in debug mode.
- Conflicts with ROS 2: several CycloneDDS installations on the system, or ROS environment variables loaded when not needed.
- Wrong message types: Go2 examples (
unitree_go) used on the G1 (unitree_hg). - Low-level code tested on the ground: the fastest way to damage the robot.
FAQ
Can I program the G1 in Python?
Yes, with unitree_sdk2_python (Python 3.8 or later). For high-frequency controllers many teams still prefer the official C++ SDK.
Do I need ROS 2 to program the G1?
No. The SDK is enough to control the robot. ROS 2 is useful when you want to reuse existing navigation, perception or visualisation packages.
Can the base G1 be programmed?
Secondary development is designed for the EDU versions, which also include the on-board development computer. Before buying, check with the seller what is enabled on the exact configuration.
How long does it take to get a first working program?
With network and environment already configured, running an official example takes little time. The real time goes into networking, dependency versions and test safety: that is where expert support saves the most.
Want to speed up development?
CALIGO configures the environment, sets up simulation and develops the first G1 applications with you, training the team along the way. Let's talk about your project.
Commercial overview and catalogue: Abra Robotics.