Skip to content

Renkunzhao/unitree_lowlevel

Repository files navigation

Unitree Low Level

This project provides a low-level controller for Unitree Go2 and G1 robots.

Features

  • Acts as a hardware interface: reads sensor data, calls the high-level controller, and sends commands to the robot.
  • Emergency stop (E-stop) support.
  • Provides IK + PD control for robot initialization.
  • Documentation: Connection, WIFI, Visualization, APT-SOURCE

Requirements

Used to communicate with Unitree Go2/G1 robots via DDS. Since ROS 2 also uses DDS as the underlying transport, they are naturally connected and accessible as long as the ROS_DOMAIN_ID and network interface match.

Provides ROS 2 message packages so nodes can decode the Unitree messages. Otherwise, ros2 topic list can see topics, but ros2 topic echo cannot decode them. On Foxy, the default ROS 2 DDS implementation differs from unitree_sdk2, so you must build Cyclone DDS following the unitree_ros2 instructions (this is included in scripts/colcon-config.sh).

Clone

mkdir -p unitree_ws/src # scripts will clone additional repos into src/
cd unitree_ws/src
git clone https://github.com/Renkunzhao/unitree_lowlevel.git

Installation

Docker Installation

You have to install Docker and NVIDIA Container Toolkit first.

Edit docker-compose.yaml (on Jetson)

change gpus: all to runtime: nvidia

Host Machine

cd unitree_lowlevel/docker
docker compose up -d --build       # build image and start container
docker exec -it unitree_ws bash     # attach container

Dependencies (skip if you use Docker)

sudo apt install -y python-is-python3 libopenblas-dev python3-dev python3-vcstool libyaml-cpp-dev libspdlog-dev libboost-all-dev libglfw3-dev libfmt-dev

Build

cd unitree_lowlevel
./scripts/colcon-config.sh $ROS_DISTRO <Release|Debug>

Run

# Run the Unitree example and stop the default controller (run once per boot)
source src/unitree_lowlevel/scripts/setup.sh <network-interface> $ROS_DISTRO
./build/unitree_sdk2/bin/go2_stand_example $NetworkInterface

# Low level controller
ros2 run unitree_lowlevel go2_lowlevel_node $NetworkInterface $WORKSPACE/src/unitree_lowlevel/config/go2.yaml

Usage

States & Keys

Emergency stop:

  • L2 + B -> E-stop

IDLE (initial state, zero torque)

  • L2 + A -> STAND

STAND (IK + PD)

  • ly, lx, ry, rx -> Height, Roll, Pitch, Yaw
  • L2 + A -> IDLE
  • START -> High-level controller (needs user implementation; not included here)

High-level controller

  • SELECT -> STAND

For a demonstration of how to implement a high-level controller, see legged_rl_deploy.

Develop

This repo uses vcstool to manage dependencies and colcon/CMake to build.

cd $WORKSPACE
vcs export lib --exact > $WORKSPACE/src/unitree_lowlevel/scripts/lib.repos
vcs export src > $WORKSPACE/src/unitree_lowlevel/scripts/src.repos
# Manually delete any irrelevant repos from the exported .repos files.

Optional Integrations

The following repositories are not required to build or run unitree_lowlevel. They are optional tools that can improve your workflow (simulation, examples, reference controllers).

This repo provides helper scripts and configs to integrate with them quickly.

unitree_mujoco - Highly Recommended

Used for simulation validation before hardware deployment. Unitree MuJoCo provides the same API as the hardware, so you can switch between simulation and hardware by setting ROS_DOMAIN_ID and the network interface.

Note: Unitree MuJoCo uses src/unitree_mujoco/simulate/config.yaml for configuration. Set use_joystick: 1 if you need a joystick.

source src/unitree_lowlevel/scripts/setup.sh <network-interface> $ROS_DISTRO
./src/unitree_mujoco/simulate/build/unitree_mujoco -i 0 -n $NetworkInterface

Note: By design, Unitree uses ROS_DOMAIN_ID=0 on hardware and suggests ROS_DOMAIN_ID=1 for simulation. Because simulation and hardware often run on different interfaces (e.g., lo and eth0), this repo uses ROS_DOMAIN_ID=0 for both settings.

A repository for reinforcement learning implementation for Unitree robots, based on IsaacLab, with c++ deploy code provided.

source src/unitree_lowlevel/scripts/setup.sh <network-interface> $ROS_DISTRO

cd $WORKSPACE/lib
git clone https://github.com/unitreerobotics/unitree_rl_lab.git

cd unitree_rl_lab/deploy/robots/g1_29dof
mkdir build
cd build
# if you install unitree_sdk2 in /opt/unitree_robotics
source $WORKSPACE/src/unitree_lowlevel/scripts/unitree_sdk_path.sh
cmake .. && make -j$(nproc)
./g1_ctrl $NetworkInterface

A repository for reinforcement learning implementation for Unitree robots, based on Mujoco, with c++ deploy code provided.

source src/unitree_lowlevel/scripts/setup.sh <network-interface> $ROS_DISTRO

cd $WORKSPACE/lib
git clone https://github.com/unitreerobotics/unitree_rl_mjlab.git

cd unitree_rl_mjlab/deploy/robots/g1
mkdir build
cd build
# if you install unitree_sdk2 in /opt/unitree_robotics
source $WORKSPACE/src/unitree_lowlevel/scripts/unitree_sdk_path.sh
cmake .. && make -j$(nproc)
./g1_ctrl $NetworkInterface

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published