Skip to content

iit-DLSLab/unitree_ros2_dls

 
 

Repository files navigation

Introduction

This repo uses unitree_ros2 from unitree. It's just adding some new messages and a complete robot_hal script to talk with the robot, compatible with some dls controllers.

Install Unitree ROS2 package

1. Dependencies

The main dependencies other ros-humble are

ros-humble-rmw-cyclonedds-cpp
ros-humble-rosidl-generator-dds-idl

A conda environment can be found in the folder installation

2. Compile unitree_go and unitree_api packages

After compiling cyclone-dds, ROS2 dependencies is required for compilation of the unitree_go and unitree_api packages:

cd cyclonedds_ws
colcon build # Compile all packages in the workspace
source install/setup.bash

Connect to Unitree robot

1. Network configuration

Connect Unitree robot and the computer using Ethernet cable. Then, use ifconfig to view the network interface that the robot connected.

Next, open the network settings, find the network interface that the robot connected.In IPv4 setting, change the IPv4 mode to manual, set the address to 192.168.123.99, and set the mask to 255.255.255.0. After completion, click apply and wait for the network to reconnect.

Open setup.sh file.

sudo gedit ~/unitree_ros2/setup.sh
#!/bin/bash
echo "Setup unitree ros2 environment"
source /opt/ros/foxy/setup.bash
source $HOME/unitree_ros2/cyclonedds_ws/install/setup.bash
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
export CYCLONEDDS_URI='<CycloneDDS><Domain><General><Interfaces>
                            <NetworkInterface name="enp3s0" priority="default" multicast="default" />
                        </Interfaces></General></Domain></CycloneDDS>'

where "enp3s0" is the network interface name of unitree robot connected. Modify it to the corresponding network interface according to the actual situation.

Source the environment to setup the ROS2 support of Unitree robot:

source ~/unitree_ros2/setup.sh

If you don't want to source the bash script every time when a new terminal opens, you can write the content of bash script into ~/.bashrc, but attention should be paid when there are multiple ROS environments coexisting in the system.

If your computer is not connected to the robot but you still want to use Unitree ROS2 for simulation and other functions, you can use the local loopback "lo" as the network interface.

source ~/unitree_ros2/setup_local.sh # use "lo" as the network interface

or

source ~/unitree_ros2/setup_default.sh # No network network interface specified 

2. Connect and test

After completing the above configuration, it is recommended to restart the computer before conducting the test.

Ensure that the network of robot is connected correctly, open a terminal and input:

source ~/unitree_ros2/setup.sh
ros2 topic list

If you have any problem in seeing, listening the topic, maybe it's the firewall.

The firewall gives us problem!!

sudo ufw disable

or

sudo ufw allow from 192.168.123.18 to any port 7400:65535 proto udp
sudo ufw allow from 192.168.123.161 to any port 7400:65535 proto udp

3. Running the hal

The source code of examples locates at /example/src/src.

Open a terminal and input:

source ~/unitree_ros2/setup.sh
cd ~/unitree_ros2/example
colcon build

After compilation, run in the terminal:

./install/unitree_ros2_example/bin/robot_hal 

You can even use

python3 launch_hal.py

About

A fork from unitree_ros2 repository, that adds a new script for comunicating with DLS controllers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 98.6%
  • CMake 1.2%
  • Other 0.2%