You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

7.1 KiB

id title status source_sections related_topics key_equations key_terms images examples open_questions
sdk-programming SDK & Programming Interface established reference/sources/github-unitree-sdk2.md, reference/sources/github-unitree-sdk2-python.md, reference/sources/official-get-sdk.md, reference/sources/official-dds-services.md [ros2-integration networking-comms joint-configuration sensors-perception] [] [unitree_sdk2 dds cyclone_dds pybind11 lowcmd lowstate motor_cmd force_position_hybrid domain_id] [] [] [Python vs C++ API coverage parity (are all C++ features wrapped?) High-level sport mode API details for G1 specifically Camera API — how to access D435i frames via SDK]

SDK & Programming Interface

Software development kits, APIs, and programming interfaces for controlling the G1.

1. Unitree SDK2 (C++)

The primary SDK for robot control. DDS-based, works without ROS2 but remains ROS2-compatible. [T0 — GitHub]

Property Value
Repository https://github.com/unitreerobotics/unitree_sdk2
Version v2.0.2 (as of July 2025)
Language C++ (99.2% of codebase)
License BSD-3-Clause
Middleware CycloneDDS v0.10.2
Supported OS Ubuntu 20.04 LTS
Architectures aarch64 (Jetson), x86_64 (development PC)
Compiler GCC 9.4.0+
Build system CMake 3.10+
GitHub stars ~888

Dependencies

sudo apt install cmake libyaml-cpp-dev libeigen3-dev libboost-all-dev libspdlog-dev libfmt-dev

Build & Install

git clone https://github.com/unitreerobotics/unitree_sdk2.git
cd unitree_sdk2
mkdir build && cd build
cmake .. && make

# System-wide install (optional)
sudo make install

# Custom install location
cmake .. -DCMAKE_INSTALL_PREFIX=/custom/path
sudo make install

Key Features

  • Request-response and topic subscription/publishing patterns
  • Low-level motor control (LowCmd/LowState)
  • High-level sport mode commands
  • IMU data access
  • Wireless controller input
  • Native DDS — no ROS2 dependency required

2. Python SDK (unitree_sdk2_python)

Python wrapper maintaining API consistency with C++ SDK. [T0 — GitHub]

Property Value
Repository https://github.com/unitreerobotics/unitree_sdk2_python
Binding pybind11
Python version ≥ 3.8
CycloneDDS version 0.10.2 (critical — must match)
License BSD-3-Clause
GitHub stars ~579

Installation

git clone https://github.com/unitreerobotics/unitree_sdk2_python.git
cd unitree_sdk2_python
pip3 install -e .

Note: May require separate CycloneDDS compilation from source and setting the CYCLONEDDS_HOME environment variable. [T1]

G1 Examples

Located in /example/g1/ directory:

  • High-level control: stand/lie down, velocity commands, attitude adjustment, trajectory tracking
  • Low-level control: direct motor position/torque commands
  • Peripherals: wireless controller, front camera (OpenCV), obstacle avoidance, LED/volume control

All examples require a network interface parameter (e.g., enp2s0) for robot connectivity.

3. Control Modes

The SDK supports multiple control modes via the MotorCmd_ structure: [T0 — Developer Guide]

Mode Field Description
Position control q Target joint angle in radians
Velocity control dq Target joint velocity in rad/s
Torque control tau Feed-forward torque in Nm
Force-position hybrid q + tau Position target with torque feed-forward
Enable/disable mode 0 = Disable motor, 1 = Enable motor

Control loop rate: 500 Hz (commands should be published at this rate for smooth control)

4. Data Streams (DDS Topics)

Body Control

Topic Type Direction Description
rt/lowstate unitree_hg::msg::dds_::LowState_ Subscribe Full robot state
rt/lowcmd unitree_hg::msg::dds_::LowCmd_ Publish Motor commands for all joints

Dexterous Hand (Dex3-1)

Topic Type Direction Description
rt/dex3/left/cmd unitree_hg protocol Publish Left hand commands
rt/dex3/right/cmd unitree_hg protocol Publish Right hand commands
rt/dex3/left/state unitree_hg protocol Subscribe Left hand state
rt/dex3/right/state unitree_hg protocol Subscribe Right hand state

LowState_ Contents

  • mode_pr: Parallel mechanism control mode
  • mode_machine: G1 type identifier
  • tick: Timer (increments every 1ms)
  • imu_state: IMU sensor data (orientation, angular velocity, acceleration)
  • motor_state: State for all body motors (position, velocity, torque)
  • wireless_remote: Remote control data
  • crc: Checksum for data integrity

5. Development Workflow

  1. Simulation first: Test with unitree_mujoco (same DDS interface, switch domain ID)
  2. Network setup: Connect to robot's WiFi or Ethernet (192.168.123.0/24)
  3. Verify connection: Subscribe to rt/lowstate to confirm data flow
  4. Start simple: Begin with high-level sport mode commands before low-level control
  5. Deploy to Jetson: Cross-compile or develop directly on the onboard Jetson Orin NX

6. Code Examples

See examples/ for worked examples. Key patterns:

  • Subscriber pattern: Create DDS subscriber for rt/lowstate, read joint states in callback
  • Publisher pattern: Create DDS publisher for rt/lowcmd, send motor commands at 500 Hz
  • High-level pattern: Use sport mode request/response API for walking, standing, etc.

Key Relationships