Go1 development with ROS2 (C++ and Python)

Go1 development with ROS2.

Links to where this discussion started:


I am using deep reinforcement learning to create new walking gaits for the go1. My go1 Edu just arrived but I was unable to get ROS2 working. Have any of you gotten it to work? I installed all the dependancies but it can’t seem to find a configuration file. Any ideas?

CMake Error at CMakeLists.txt:9 (find_package):
By not providing “Findros2_unitree_legged_msgs.cmake” in CMAKE_MODULE_PATH
this project has asked CMake to find a package configuration file provided
by “ros2_unitree_legged_msgs”, but CMake did not find one.

Could not find a package configuration file provided by
“ros2_unitree_legged_msgs” with any of the following names:


Add the installation prefix of “ros2_unitree_legged_msgs” to
CMAKE_PREFIX_PATH or set “ros2_unitree_legged_msgs_DIR” to a directory
containing one of the above files. If “ros2_unitree_legged_msgs” provides
a separate development package or SDK, be sure it has been installed.

Hi @evaughan

Yes so there are a few errors that needs to be fixed when you use Unitree’s packages for the Go1.

I am using Ubuntu 22.04 and ROS2 Humble and this worked for me.

The packages you need are:
ROS2 to Real package:

Unitree legged SDK release 3.5.1 - This is the required SDK for the ROS2 package:

Rename the unzipped folder from unitree_legged_sdk-3.5.1 to unitree_legged_sdk-master.
Move the unitree_legged_sdk-master folder to ws/src/unitree_ros2_to_real.

In both of these repositories follow the README’s for their respective dependencies.

You also need this:

You need to change the version of Java:

  1. sudo apt install openjdk-8-jdk
  2. sudo update-alternatives --config javac
    Then choose java-8-openjdk option

Lastly when you have all of this you need to fix errors in their code.

  1. Fix ws/src/unitree_ros2_to_real/unitree_legged_sdk-master/include/unitree_legged_sdk/comm.h
    Find the HighCmd struct and fix the typo for the “position” member (it is spelled “postion”), line 189
  2. Add this to the CMakelist.txt of the unitree_ros2_to_real package:
    DIRECTORY ${CMAKE_SOURCE_DIR}/unitree_legged_sdk-master/lib/

Lastly Go to the ws folder and colcon build.

@Marnonel6 thanks so much for sharing this info. I’m definitely going to be giving it a try soon. Cheers!

1 Like

Thanks the the detailed description. I figured there were things missing from the Unitree instructions. Unfortunately even with these fixes I get the same error.

It happens in CMakeLists at this line:

find_package(ros2_unitree_legged_msgs REQUIRED)

and ideas what it is looking for?


Does your workspace structure look like this? (Photo above)
The package ros2_unitree_legged_msgs should be outside of unitree_ros2_to_real.

CMakelist.txt for unitree_ros2_to_real package

cmake_minimum_required(VERSION 3.5)

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)

find_package(ros2_unitree_legged_msgs REQUIRED)

  set(ARCH amd64)
  set(ARCH arm64)
set(EXTRA_LIBS -pthread libunitree_legged_sdk_${ARCH}.so lcm)



 DIRECTORY ${CMAKE_SOURCE_DIR}/unitree_legged_sdk-master/lib/


add_executable(ros2_udp src/ros2_udp.cpp)
target_link_libraries(ros2_udp ${EXTRA_LIBS})
ament_target_dependencies(ros2_udp rclcpp ros2_unitree_legged_msgs)

add_executable(ros2_walk_example src/ros2_walk_example.cpp)
target_link_libraries(ros2_walk_example ${EXTRA_LIBS})
ament_target_dependencies(ros2_walk_example rclcpp ros2_unitree_legged_msgs)

add_executable(ros2_position_example src/ros2_position_example.cpp)
target_link_libraries(ros2_position_example ${EXTRA_LIBS})
ament_target_dependencies(ros2_position_example rclcpp ros2_unitree_legged_msgs)



Interesting. When I grabbed unitree_ros2_to_real from GitHub ros2_unitree_legged_msgs was inside Unitree_ros2_real. I moved it outside and indeed it does work… Thanks!

Yes they never say to do that we just figured it out. Good luck with the project.

I am trying to get my head around the ROS installation on the GO1 as I am still just learning ROS.
If I want to run the legged sdk examples directly on the GO1 (not remotely) do I copy the ros_to_real and the leggedSDK (ROS1 versions) to the raspberry pi onboard and then build them? Then use SSH to execute them? or are they already there somewhere?

You should be able to locate the Unitree legged SDK in the following directory on Raspberry Pi:

Also, if you have any other problems would you mind opening a new thread please? This was specific to ROS 2 and we’d like to keep things organized. Thanks.

Great thanks, just what I was looking for.

I will be sure to open a new thread next time.