Go1 development with ROS2 (C++ and Python)

Go1 development with ROS2.

Links to where this discussion started:

Hi,

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:

ros2_unitree_legged_msgsConfig.cmake
ros2_unitree_legged_msgs-config.cmake

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:
    install(
    DIRECTORY ${CMAKE_SOURCE_DIR}/unitree_legged_sdk-master/lib/
    DESTINATION 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?

image

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)
project(unitree_legged_real)



find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)

find_package(ros2_unitree_legged_msgs REQUIRED)


message("-- CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64.*")
  set(ARCH amd64)
else()
  set(ARCH arm64)
endif()
set(EXTRA_LIBS -pthread libunitree_legged_sdk_${ARCH}.so lcm)


set(CMAKE_CXX_FLAGS "-O3")

include_directories(
    include
    ${CMAKE_SOURCE_DIR}/unitree_legged_sdk-master/include
)

install(
 DIRECTORY ${CMAKE_SOURCE_DIR}/unitree_legged_sdk-master/lib/
 DESTINATION lib
)


link_directories(${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)

install(TARGETS
    ros2_udp
    ros2_walk_example
    ros2_position_example
    testing_ros2_pkg
    DESTINATION lib/${PROJECT_NAME}
)


ament_package()





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.

Hello,

I see you have it working with Ubuntu 22.04 and ROS2
We are also using Ubuntu 22.04 and ROS2 Humble (and conda).
We have the code running but the robot won’t move, we just need high-level control. Please help.
I am working for a Lab at Berkeley and we are trying to control the Go1 Robot from a desktop with a wired connection to internet and a wireless connection to the Go1.

The desktop is using Ubuntu 22.04 and ROS2 Humble. We are also using a conda env.

We followed all the steps here https://www.youtube.com/watch?v=YSedTUxI0wc
But when we run both:
ros2 run unitree_legged_real ros2_udp highlevel
ros2 run unitree_legged_real ros2_walk_example

The robot will not move, despite the code running without errors.
We are able to ping the robot and ssh into the pi

We could really use some help, we also tried the video with turtle sim but the robot wouldn’t move either:

The only thing I can think is that either:

  1. The robot is not subscribing to the correct topics/nodes
    Or
  2. Because our desktop has a wired connection to the university internet, and a wifi 6e antenna that goes directly into the motherboard, there is some sort of firewall or ip configuration that needs to be done.

Things we have tried:

  1. Changing the udp in ros2_udp.cpp to 192.168.12.1
  2. With and without Docker
  3. ROS1 and ROS2

Any and all advice would be greatly appreciated