Unitree SDK2 Developer Tutorial: From Getting Started to Advanced Applications
Unitree SDK2 Developer Tutorial
For Unitree Go2 / B2 / H1 — real-time motion control, sensor access, and ROS2-ready development.
Overview
September 23, 2025 / Los Angeles, US. Unitree SDK2 is a CycloneDDS-based communication & control framework for Unitree robots. It works without ROS2 while remaining ROS2-compatible, and provides native C++ APIs plus a Python wrapper (pybind11) for rapid prototyping and production deployments.
Key Characteristics
- Low-latency DDS: direct data exchange with robot hardware
- No ROS2 required: optional ROS2 interoperability via DDS
- Cross-language: C++ APIs, Python wrapper via pybind11
System Requirements
- Ubuntu 20.04 or 22.04 (recommended)
- Python 3.8+
- CMake 3.16+ | g++ 9.0+
Installation
- Clone repository
git clone https://github.com/unitreerobotics/unitree_sdk2
cd unitree_sdk2
- Build the SDK core (C++)
mkdir build && cd build
cmake ..
make -j4
- Install Python wrapper & dependencies
cd ../python_wrapper
pip install .
pip install pybind11 cyclonedds
If installation fails, ensure python3-dev and DDS runtime libraries are installed.
Quick Start (Python)
from unitree_sdk2 import RobotInterface
robot = RobotInterface()
robot.start() # establish communication
# Basic motions
robot.move_forward(speed=0.2, duration=3.0)
robot.sit_down()
robot.stand_up()
Accessing Robot State
# Joint states
angles = robot.get_joint_angles()
vels = robot.get_joint_velocities()
# IMU
imu = robot.get_imu_data()
print(imu.orientation, imu.angular_velocity)
# Foot contact forces
forces = robot.get_foot_forces()
Advanced Motion Control
# Custom trajectory
traj = [
{"x":0.2, "y":0.0, "z":0.0, "duration":2.0},
{"x":0.2, "y":0.1, "z":0.0, "duration":2.0},
]
robot.execute_trajectory(traj)
# Mode switching
robot.set_motion_mode("trot")
robot.set_motion_mode("stand")
ROS2 Interoperability
- SDK2 and ROS2 nodes can share topics via DDS
- Publish IMU to
/imu/datafor RViz while keeping low-latency Python control - Use a DDS domain bridge in mixed environments
Best Practices
- Run on Ubuntu 20.04/22.04; avoid mixed OS toolchains
- Keep robot & control PC on the same subnet
- Prototype in Python; move performance-critical parts to C++
Troubleshooting
-
ImportError: add CycloneDDS path to
LD_LIBRARY_PATH - High latency: check Wi-Fi/Ethernet quality (DDS is sensitive to packet loss)
-
No response: ensure robot control lock is released
About K-robotic shop: K-Robotic brings the future of robotics to your hands. From Unitree quadrupeds to advanced humanoids, we provide innovative robots, fast U.S. delivery, and local support you can trust.
Need help or local support? K-Robotic provides U.S.-based guidance, RMA, and integration services for Unitree robots.
Contact K-Robotic