Unitree A1 robot on ROS Noetic

ZIN MIN
9 min readJun 11, 2022

Unitree A1 robot is China made four legs quadruped robot. Unitree A1 robot supports ROS Melodic. In this experiment, I will do Unitree A1 on ROS Noetic on Windows WSL 2.0 Ubuntu 20.04. It is just for simulation testing. But I am tested with Ubuntu 18.04 Melodic as well. It is working.

However I am not recommend to do this testing on the actual robot. You have to take your own risk.

Prerequisite items are ROS Noetic on Ubuntu 20.04. I am using WSL2.0 environment, if you want to create test environment on WSL2.0, please reference this article ROS on WSL 2. ROS

Verify your Noetic Environment

Before start do testing, verify ROS Noetic Environment.

printenv | grep ROS

Create ROS Catkin Workspace Environment

We should start create Catkin Workspace. If you want to know what is ROS Catkin Workspace, please go to ROS tutorials pages for more detail. ROS/Tutorials/InstallingandConfiguringROSEnvironment — ROS Wiki

Now create catkin_ws folder under login user folder by using below command. This command will create catkin_ws folder under user directory and will create src folder under catkin_ws folder together.

mkdir -p ~/catkin_ws/src

Now test catkin_make command. catkin_make is ROS compiler command. catkin_make command can run under catkin_ws folder. Therefore go to catkin_ws folder and run it.

cd ~/catkin_ws
catkin_make

After successfully run the catkin_make, you can see build, devel, and src folder inside catkin_ws folder. You can check list those folder by using ls command.

ls ~/catkin_ws

Define the source path pointing to devel/setup.bash

source devel/setup.bash

Now we can start prepare for Unitree A1 robots packages.

Unitree A1 ROS prerequisite items

Unitree A1 robot is using ROS Melodic and you can learn detail requirements packages in here, GitHub — unitreerobotics/unitree_ros

Unitree A1 ROS prerequisite items

  1. boost
  2. CMake
  3. g++
  4. gedit (optional)
  5. LCM (Lightweight Communications and Marshalling server to pass the massage and data marshalling under low latency for real-time system.)
  6. Unitree Leg SDK V3.2 (low level SDK for robot movement)
  7. Unitree ROS to Real V3.2.1 (it is optional, not necessary for simulation testing)

Check and install boost

Typically boost is already in the Ubuntu system.

dpkg -s libboost-dev | grep Version

If it is not install in your system, please follow How to Install Boost on Ubuntu 16.04/18.04 Linux — OSETC TECH

Check and install CMake

Typically cmake is already in ROS Noetic.

cmake --version

If it is not install in your system, please install with bellow command.

sudo apt install cmake -y

Check and install g++

Typically g++ is already install in ROS Noetic.

g++ --version

If it is not install in your system, please install with bellow command.

sudo apt install g++ -y

Install gedit (Optional)

gedit is a text editor which is optional for Unitree A1 ROS test. To install gedit, please run below command.

sudo apt gedit -y

Install LCM

LCM is a Lightweight Communications and Marshalling server. LCM needs to install from the source code. You can read detail information from LCM: Build Instructions (lcm-proj.github.io)

In here, I will post my test experiment only based on LCM GitHub guidance.

Install build essential

Build essential packages is necessary for LCM. But most of build essential packages are already in ROS. However you can check how to install Build Essential in here. What is build-essential Ubuntu, how to install and use it? (linuxhint.com) Before install build essential, please update the local package source list first.

sudo apt update
sudo apt install build-essential -y

Install libglib2.0

libglib2.0 is one of prerequisite item for LCM.

sudo apt install libglib2.0-dev-bin -y

Clone LCM Source Code

Now it is time to clone LCM source code to local by using git command. Make sure your in the login user directory by typing cd ~. After that get LCM source code from GitHub.

git clone https://github.com/lcm-proj/lcm.git

After clone successfully, you can see the folder list in user directory. There could be LCM folder together with catkin_ws folder.

ls

Build and Install LCM

Now we can build from LCM source code and install. First, create the build folder inside the LCM folder. And go in to build folder and use cmake .. command and build. After build successfully using sudo make install comand and install LCM.

mkdir ~/lcm/build
cd ~/lcm/build
cmake ..
make
sudo make install

Install unitree_legged_sdk_v3.2

Now it is time to install unitree_legged_sdk_v3.2. Unitree Legged SDK can be download from Unitree GitHub as .tar.gz archive file. Therefore, we can use wget and download .tar.gz file.

Go to user profile folder and download unitree_legged_sdk.

cd ~
wget https://github.com/unitreerobotics/unitree_legged_sdk/archive/refs/tags/v3.2.tar.gz

After download .tar.gz file successfully, you can see the folder list in user directory. There could be LCM folder together with catkin_ws folder.

ls

Un-tar the package.

sudo tar -xvf v3.2.tar.gz

Check with ls command. There could be unitree_legged_sdk-3.2 folder under user profile folder.

ls

Rename Unitree_Legged_SDK by using mv move command. After that, giving access permission by using chmod 777.

sudo mv unitree_legged_sdk-3.2 unitree_legged_sdk
sudo chmod 777 unitree_legged_sdk

Build unitree_legged_sdk

Now time to build unitree_legged_sdk. Make build directory inside unitree_legged_sdk. And go in to build folder and using cmake .. command to generate build system.

mkdir unitree_legged_sdk/build
cd unitree_legged_sdk/build
cmake ..

Next step is build by using make command

Setup unitree_ros_to_real_3.2.1

Unitree_ros_to_real_3.2.1 is a package that can communicate unitree_ros to real robot. This package shall be inside the catkin_ws/src folder. Therefore go to ~/catkin_ws/src folder and get the package .tar.gz archive file.

cd ~/catkin_ws/src
wget https://github.com/unitreerobotics/unitree_ros_to_real/archive/refs/tags/v3.2.1.tar.gz

Check download .tar.gz by using ls command. There should be a v3.2.1.tar.gz file.

ls ~/catkin_ws/src

Un-tar the package

sudo tar -xvf v3.2.1.tar.gz

Rename unitree_ros_to_real by using mv move command. After that, giving access permission by using chmod 777.

sudo mv unitree_ros_to_real-3.2.1 unitree_ros_to_real
sudo chmod 777 unitree_ros_to_real

We have to prepare Unitree A1 ROS environment. First we have to know what is our Ubuntu OS architecture. Check arm or amd architecture by using dpkg command. My PC is amd64.

dpkg --print-architecture

Declare environment variables at Ubuntu .bashrc system file.

sudo gedit ~/.bashrc

.bashrc file will be opened with gedit text editor windows. Please update below variables to end of the file.

source ~/catkin_ws/devel/setup.bash
source /usr/share/gazebo-11/setup.sh
export ROS_PACKAGE_PATH=~/catkin_ws:${ROS_PACKAGE_PATH}
export GAZEBO_PLUGIN_PATH=~/catkin_ws/devel/lib:${GAZEBO_PLUGIN_PATH}
export LD_LIBRARY_PATH=~/catkin_ws/devel/lib:${LD_LIBRARY_PATH}
export UNITREE_LEGGED_SDK_PATH=~/unitree_legged_sdk
export UNITREE_PLATFORM="amd64"
export UNITREE_SDK_VERSION="3_2"

Logout WSL2.0 Ubuntu with exit command and re-login again to the check variables.

Test environment variables:

echo $UNITREE_SDK_VERSION
echo $GAZEBO_PLUGIN_PATH
echo $ROS_PACKAGE_PATH

Now building time for Unitree_ROS_To_Real. Unitree_ros_to_real is ROS pacakage. Therefore, we cand directly build by using catkin_make. But to use catkin_make, you must be in catkin_ws folder.

cd ~/catkin_ws
catkin_make

Yayyyyy! Now all prerequisite items are ready. Time to setup Unitree A1 ROS.

Set up Unitree A1 ROS

First, install relative packages.

sudo apt-get install ros-noetic-controller-interface  ros-noetic-gazebo-ros-control ros-noetic-joint-state-controller ros-noetic-effort-controllers ros-noetic-joint-trajectory-controller -y

Download unitree_ros and Build

Unitree_ros is a ROS package. Therfore git clone from Unitree GitHub to catkin_ws/src folder.

cd ~/catkin_ws/src
git clone https://github.com/unitreerobotics/unitree_ros.git

After download, next step is build unitree_ros by using catkin_make command.

cd ~/catkin_ws
catkin_make

Yayyyy! Now we successfully setup Unitree A1 ROS on Ubuntu 20.04 ROS Noetic distro.

Test unitree_gazebo & unitree_controller

To do Unitree A1 robot via gazebo simulator, we need to open multiple command windows.

Run unitree A1 robot in gazebo.

roslaunch unitree_gazebo normal.launch rname:=a1

Gazebo simulator will be opened as below. Depend on your windows OS specification, Gazebo windows will take a few second to open.

Now open a new command tab and run unitree_servo to stand robot.

rosrun unitree_controller unitree_servo

Now open a new command tab again and run unitree_servo to stand robot.

rosrun unitree_controller unitree_move_kinetic

Cool! Now Unitree A1 robot can be simulated in Gazebo 11. But depend on OS specification, graphic could be very slow.

Browse ROS Topic List when running Unitree_Gazebo

You can check ROS topic list when running Unitree A1 in Gazebo. Take note, rostopic list can be run inside catkin_ws workspace.

cd ~/catkin_ws
/a1_gazebo/FL_calf_controller/command
/a1_gazebo/FL_calf_controller/joint_wrench
/a1_gazebo/FL_calf_controller/state
/a1_gazebo/FL_hip_controller/command
/a1_gazebo/FL_hip_controller/joint_wrench
/a1_gazebo/FL_hip_controller/state
/a1_gazebo/FL_thigh_controller/command
/a1_gazebo/FL_thigh_controller/joint_wrench
/a1_gazebo/FL_thigh_controller/state
/a1_gazebo/FR_calf_controller/command
/a1_gazebo/FR_calf_controller/joint_wrench
/a1_gazebo/FR_calf_controller/state
/a1_gazebo/FR_hip_controller/command
/a1_gazebo/FR_hip_controller/joint_wrench
/a1_gazebo/FR_hip_controller/state
/a1_gazebo/FR_thigh_controller/command
/a1_gazebo/FR_thigh_controller/joint_wrench
/a1_gazebo/FR_thigh_controller/state
/a1_gazebo/RL_calf_controller/command
/a1_gazebo/RL_calf_controller/joint_wrench
/a1_gazebo/RL_calf_controller/state
/a1_gazebo/RL_hip_controller/command
/a1_gazebo/RL_hip_controller/joint_wrench
/a1_gazebo/RL_hip_controller/state
/a1_gazebo/RL_thigh_controller/command
/a1_gazebo/RL_thigh_controller/joint_wrench
/a1_gazebo/RL_thigh_controller/state
/a1_gazebo/RR_calf_controller/command
/a1_gazebo/RR_calf_controller/joint_wrench
/a1_gazebo/RR_calf_controller/state
/a1_gazebo/RR_hip_controller/command
/a1_gazebo/RR_hip_controller/joint_wrench
/a1_gazebo/RR_hip_controller/state
/a1_gazebo/RR_thigh_controller/command
/a1_gazebo/RR_thigh_controller/joint_wrench
/a1_gazebo/RR_thigh_controller/state
/a1_gazebo/joint_states
/apply_force/trunk
/clock
/gazebo/link_states
/gazebo/model_states
/gazebo/parameter_descriptions
/gazebo/parameter_updates
/gazebo/performance_metrics
/gazebo/set_link_state
/gazebo/set_model_state
/rosout
/rosout_agg
/tf
/tf_static
/trunk_imu
/visual/FL_foot_contact/the_force
/visual/FR_foot_contact/the_force
/visual/RL_foot_contact/the_force
/visual/RR_foot_contact/the_force

Install ROS RQT

To visualize ROS Nodes and Topics, we can use ROS RQT. Install ROS RQT and RQT Plugin as below:

sudo apt install ros-noetic-rqt -y
sudo apt install ros-noetic-rqt-common-plugins -y

Unitree A1 Nodes and Topics in ROS RQT

rosrun rqt_graph rqt_graph

Done!

--

--