SHOP News & Articles Contact Impressum

Control Unitree A1 with ROS (via WiFi and Ethernet)

Hello,

I am trying to control Unitree A1 using ROS. When I connect to the robot using its WiFi (Unitree), I can use the unitree_legged_sdk package. For instance, I can run

sudo ./example_walk

and the robot moves. However, I want to control the robot using ROS, and there is no detailed tutorial for this purpose.

First of all, I connected to the robot using both WiFi and Ethernet. I can ping both of the connections (I can already verify that WiFi works, because for sudo ./example_walk I use it):

ping 192.168.123.201 for ethernet
ping 192.168.123.105 for WiFi

Then, I try to use ROS for controlling the robot. I first launch this file:
roslaunch unitree_legged_real real.launch ctrl_level:=highlevel

When I do that, no error is given, and I get the following output:

started roslaunch server http://staycoolish-PC:33983/

SUMMARY
========

PARAMETERS
 * /control_level: highlevel
 * /firmwork: 3_2
 * /robot_name: a1
 * /rosdistro: noetic
 * /rosversion: 1.15.14

NODES
  /
    node_lcm_server (unitree_legged_real/lcm_server_3_2)

auto-starting new master
process[master]: started with pid [5894]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to 6d4ce3ea-0e70-11ed-ab0d-1300bbba5118
process[rosout-1]: started with pid [5904]
started core service [/rosout]
process[node_lcm_server-2]: started with pid [5907]
UDP Initialized. Port: 8080 
LCM Initialized. Subscribe channel: LCM_High_Cmd, Publish channel: LCM_High_State
[Loop Start] named: UDP_Send, period: 2(ms), run at cpu: 3 
[Loop Start] named: UDP_Recv, period: 2(ms), run at cpu: 3 
[Loop Start] named: LCM_Recv, period: 2(ms), cpu unspecified
[Loop Start] named: control_loop, period: 2(ms), cpu unspecified

However, something strange happens, no node is created. When I check with rosnode list, the only node is /rosout. Therefore, when I run the code

rosrun unitree_legged_real example_walk

nothing happens.

What is the right way for using ROS? Or, what am I missing?

Thank you,

Dear all,

thanks for your topic.

Just a few general questions:

  • Are you having a QUADRUPED A1 Basic or Explorer?
  • When you have purchased it / which Software Version is running on it?
  • Do you have access to docs.quadruped.de?

@Sohail May you can assist him as well?

Thanks for your interest:

It is the Basic version. There are two computers on it: One main computer (Ubuntu 16.04 is installed, but ROS is not installed), and a Raspberry Pi (I didn’t check the OS version and whether ROS is installed, because the robot is controlled via the other computer, as far as I know). It is purchased around 2 years ago, but this is the first time it is used except for using with the remote controller.

I don’t have access to http://docs.quadruped.de/ , but I think I have downloaded and read maybe all of your tutorials already, at least the ones that are on your website. We purchased the robot from Unitree, via a local distributor. Unfortunately, their support is quite limited (local distributor has no people working with ROS, and Unitree is not very responsive), and I couldn’t get any response for the issues I opened on their Github pages. To be honest, I noticed that your website is the most comprehensive and helpful place for this robot, and that is why I ask my question here. I do believe though, there is no good resource for ROS connection of A1. Thus, hopefully my question would be useful for your customers as well.

Thank you,

Hi @staycoolish,

On your pc that is connected to the robot. You must run it as a super user i.e.

sudo su

Next source the environment where the A1 package is usually in the catkin_ws in the same super user terminal, (replace unitree with your username)

source /home/unitree/catkin_ws/devel/setup.bash

Finally run the roslaunch file with

roslaunch unitree_legged_real real.launch ctrl_level:=highlevel

Also we have like a software stack that has this if you are interested in purchasing one of the newer versions :slight_smile:

Thanks a lot @Sohail !

I luckily solved the problem, but the reason was really strange, and I couldn’t really understand why. Nonetheless, it can happen to the others as well. When I try to run anything from the unitree_legged_real package, these are the options:

And when I look at the CMakeLists.txt inside the unitree_legged_real package, I see that there are 5 executables defined inside it (I took a screenshot but I can only upload 1, so :D):

Those 5 options in that package are:

lcm_server_3_2
position_lcm
velocity_lcm
torque_lcm
walk_lcm

Therefore, the remaining are actually unrelated to unitree_legged_real:

CMakeLists.txt
control_via_keyboard (this one is for Go1 as far as I know, and I installed the 3.2.1 version of unitree_ros_to_real -version for A1-, so I don’t know why it is even there)
velocity_mode.cpp, walk_mode.cpp, position_mode.cpp, torque_mode.cpp are the codes for the functions velocity_lcm, walk_lcm, position_lcm, torque_lcm. Those .cpp files should not be shown when rosrun is used.

and the remaining ones

That’s why nothing was happening when I write

rosrun unitree_legged_real example_walk , because example_walk is not related to that package.

I tried all the available 5 functions: lcm_server_3_2 does not work, it says Segmentation fault (core dumped) . The rest (position_lcm, velocity_lcm, torque_lcm, walk_lcm) work, walk_lcm requires high level control mode from real.launch; the other require low level control mode. I connected the ethernet cable to the robot’s main computer, didn’t try WiFi yet. Overall, thanks for your help, applying the steps you said, the robot worked successfully.

I am working in a university, and my supervisor wants me to control the robot (high level or low level) by myself. I believe it is preferable if we write our own code, but in case we buy a new Unitree A1, I will let him know about your software :smiley: What is its difference by the way, from the codes provided by Unitree?

We build upon Unitree’s existing SDK to provide specific ROS interface and drivers such walking odometry purely hardware based, joint_state_publishers, etc.

Footer With Address And Phones