Using ROS 2 with Unitree robots is simpler than many people think, because you do not need a real "bridge": the Unitree SDK communicates over DDS (CycloneDDS) and ROS 2 also uses DDS as its middleware. With the right messages and the correct network configuration, a ROS 2 node can read the robot's state and send commands directly. This guide takes you from zero to the first topic in the lab, following the official unitree_ros2 repository.
How the integration works
The unitree_ros2 README explains that, since the robot and ROS 2 share DDS as their communication mechanism, ROS 2 messages can be used to communicate with and control the robot without wrapping the SDK interface. The repository provides:
cyclonedds_ws— the workspace with the message packagesunitree_api,unitree_go(Go2, B2, H1) andunitree_hg(G1, H1-2 and other models);example— examples for reading state, high-level control for the Go2 and low-level control, including an example dedicated to the G1.
The README explicitly mentions support for Go2, B2 and H1; the examples also cover the G1 and H1-2. For other models, check the specific documentation before you start.
Which ROS 2 distribution
| Ubuntu | ROS 2 | Notes |
|---|---|---|
| 20.04 | Foxy | Tested by the repository, but Foxy is now out of support |
| 22.04 | Humble | Recommended by the repository; LTS supported until May 2027 |
| 24.04 | Jazzy | LTS until May 2029, but not listed among the combinations tested by unitree_ros2 |
For a new lab project today the most prudent choice is still Ubuntu 22.04 + ROS 2 Humble. If you have to use Jazzy, budget time to build and verify compatibility yourself.
Step-by-step installation (Humble)
- Install ROS 2 Humble following the official ROS documentation.
- Clone the repository:
git clone https://github.com/unitreerobotics/unitree_ros2 - Install the dependencies:
sudo apt install ros-humble-rmw-cyclonedds-cpp sudo apt install ros-humble-rosidl-generator-dds-idl sudo apt install libyaml-cpp-dev - CycloneDDS: the robots use version 0.10.2. With Humble the manual CycloneDDS build step can be skipped; with Foxy it must be built from the
releases/0.10.xbranch without the ROS 2 environment sourced in the terminal, otherwise the build fails. - Build the message packages:
source /opt/ros/humble/setup.bash cd ~/unitree_ros2/cyclonedds_ws colcon build
Configuring the network
- Connect the PC and the robot with an Ethernet cable and find the interface (for example
enp3s0). - Set IPv4 to manual: address
192.168.123.99, netmask255.255.255.0. - Edit
~/unitree_ros2/setup.sh, setting your distribution (the README usesfoxyas the example) and your interface name:source /opt/ros/humble/setup.bash source $HOME/unitree_ros2/cyclonedds_ws/install/setup.bash export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp export CYCLONEDDS_URI='<CycloneDDS><Domain><General><Interfaces> <NetworkInterface name="enp3s0" priority="default" multicast="default" /> </Interfaces></General></Domain></CycloneDDS>' - Load the environment with
source ~/unitree_ros2/setup.sh. The README recommends restarting the PC before the first test.
Without a robot connected you can work locally with setup_local.sh, which uses the loopback interface lo: useful together with the unitree_mujoco simulator.
The first topic
source ~/unitree_ros2/setup.sh
ros2 topic list
ros2 topic echo /sportmodestate
The main topics documented in the README:
| Topic | Content |
|---|---|
/sportmodestate, /lf/sportmodestate | Motion state: position, velocity, gait (quadrupeds) |
/lowstate, /lf/lowstate | Motor, IMU and battery state |
/wirelesscontroller | Remote controller input |
/lowcmd | Low-level motor commands |
/api/sport/request | High-level control requests |
The lf prefix marks the low-frequency version of the topic. To build and run the examples:
cd ~/unitree_ros2/example
colcon build
./install/unitree_ros2_example/bin/read_motion_state
On the G1 use the examples for the unitree_hg family, such as low-level state reading and the G1 control example. Remember that on the G1 low-level control requires debug mode and a suspended robot: see the G1 operational guide.
Common problems and fixes
ros2 topic listdoes not show the robot's topics — check thatRMW_IMPLEMENTATIONisrmw_cyclonedds_cpp, that the interface name inCYCLONEDDS_URIis correct and that the PC is in the192.168.123.xsubnet.- CycloneDDS build errors (Foxy) — the ROS 2 environment was sourced in the terminal; temporarily comment out the
sourceline in~/.bashrc. - Several ROS environments on the same machine — avoid putting
setup.shin~/.bashrcif you also work on other projects: source it only when needed. - Topics are there but commands have no effect — on the G1 check the robot's mode: in debug mode high-level commands are ignored.
- Simulation and real robot "see" each other — use different domain IDs and interfaces: loopback for simulation, Ethernet for the robot.
After the first topic
Once the robot's state reaches ROS 2, you can record it with rosbag (there is a dedicated example), visualise it, integrate additional sensors and build navigation and perception pipelines. For direct programming with the SDK see programming the G1; for GPU simulation see NVIDIA Isaac and Omniverse.
FAQ
Do I need a bridge between ROS 2 and the Unitree SDK?
No. The robot and ROS 2 both use DDS: with the unitree_ros2 message packages and CycloneDDS configured, ROS 2 nodes talk to the robot directly.
Can I use ROS 2 Jazzy?
The official repository lists Foxy and Humble as tested, with Humble recommended. Jazzy is not on the list: you can try it, but compatibility has to be verified on your project.
Which IP should I give the PC?
The README specifies 192.168.123.99 with netmask 255.255.255.0. Any free address in the 192.168.123.x subnet that is not already used by the robot will work.
Can I work without the robot?
Yes: with setup_local.sh and the unitree_mujoco simulator you can develop and test locally, then move to the robot by changing only the network configuration.
Need a hand?
CALIGO sets up ROS 2 on Unitree robots for universities and R&D departments, from networking to the first working node, and trains the team. Request support.
Commercial overview and catalogue: Abra Robotics.