../_images/tiagopro-icon.png ../_images/tiago-head-icon.png ../_images/kangaroo-icon.png ../_images/tiago-icon.png ../_images/triago-icon.png ../_images/ari-icon.png ../_images/talos-icon.png ../_images/mobile-bases-icon.png

Set up ROS 2 communication with the robot#

🏁 Goal of this guide

By the end of this guide, you will know how to set up Cyclone DDS with peer-to-peer discovery and connect your development environment to the robot.

Pre-requisites#

Establish a P2P connection with the robot#

In ROS 2 it is possible to set up ROS communication between a robot and the PAL OS Docker image (or another development environment). For this communication to be successful the robot and development machine have to be connected to the same network, either by cable or wireless. For more details on network configuration of the robot see the section Network configuration. Furthermore, both the PAL OS Docker image and robot need to have the proper Cyclone DDS configuration.

Cyclone DDS is the default RMW in ROS 2 Humble. In its default config, it will use multicast for discovery, making it unreliable for certain network configurations. To avoid this, a custom configuration has been created for both the PAL OS Docker image and robot. This configuration sets up explicit peer-to-peer discovery using unicast traffic. This page will go through the different steps to ensure the configuration is set up correctly.

Container setup#

The Cyclone DDS configuration in the PAL OS Docker image is handled by the package pal-alum-cyclone-dev-cfg. In order to establish a P2P connection with other ROS2 systems (like your robot), ensure this package is installed. By default, the PAL OS Docker image is deliverd with this package. However, in case it is not present, it can be installed with the following command:

sudo apt install pal-alum-cyclone-dev-cfg

Robot setup#

The Cyclone DDS configuration on the robot is handled by the package pal-alum-cyclone-robot-cfg. In order to establish a P2P connection with other ROS2 systems ensure this package is installed. By default, robots are delivered with this package. However, in case it is not present, it can be installed with the following command:

sudo apt install pal-alum-cyclone-robot-cfg

Reboot the robot after installation. After the reboot, no DDS traffic will exit the robot until a peer is explicitly connected. As a result, multiple robots can operate in the same network without interfering with each other in any way.

Connect to the robot#

To connect to a robot use the following command from inside the PAL OS Docker image.

ros2 run cyclone_dev_cfg pal_connect.sh <network_interface> <robot_ip/hostname>
  • <network_interface>: The network interface of the PAL OS Docker image that has connectivity with the robot. You can check all your interfaces with ip a. For example:

> ip a

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
     inet 127.0.0.1/8 scope host lo
     valid_lft forever preferred_lft forever
     inet6 ::1/128 scope host
     valid_lft forever preferred_lft forever
 4: wlo1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
     link/ether cc:15:31:e5:5f:c4 brd ff:ff:ff:ff:ff:ff
     altname wlp0s20f3
 41: enx803f5d0160c9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
     link/ether 80:3f:5d:01:60:c9 brd ff:ff:ff:ff:ff:ff
     inet 192.168.3.174/24 brd 192.168.3.255 scope global dynamic noprefixroute enx803f5d0160c9
     valid_lft 10570sec preferred_lft 10570sec
     inet6 fe80::fb77:2258:4dcd:e549/64 scope link noprefixroute
     valid_lft forever preferred_lft forever

Please note that you have to choose the network interface that has connectivity with the robot. For example, in this case, the developer machine is connected to the network through cable (enx803f5d0160c9).

The connection script will ensure that the robot is reachable by the hostname or IP you specified through the selected interface. If you receive an error message like:

[ERROR] Peer address <robot_ip> is not reachable through network interface <interface>.

Please take into account that if you have multiple interfaces up, not all of them may have connectivity with the robot. You can ensure that the network interface you are using is the one that has connectivity with the robot by pinging the robot through that interface:

ping <robot_ip> -I <interface>
  • <interface>: The network interface

  • <robot_ip/hostname>: the IP or hostname of the robot.

The hostname must be resolvable from your development environment, which depends on your network DNS configuration. If it doesn’t work with the hostname, you should use the IP directly.

After a successful connection the terminal should look like the image below.

../_images/cyclone_proper_connection.png

This means a Cyclone connection has been successfully established with your robot. You can now eg see the topics in your development environment with ros2 topic list.

Important

The script ensures a connection that is specific to this bash session. If you want to see the topics in another bash session, the connection script has to be run again in the new session.

Disconnecting from the robot#

To disconnect from the robot, you can simply run exit in the bash session where you ran the connection script. This will stop the Cyclone connection and you will no longer be able to see the topics.

Troubleshooting#

  1. Check that you can ping the robot:

    ping <your_robot_ip>

  2. If the ping is unsuccessful, please check the robot IP on the robot using ip a. You should be able to see an IP under the appropriate network interface (normally, wlan0). Note down that IP, and try to ping it again from your development environment.

  3. If the normal ping was successful but you cannot yet see the topics, you can try a DDS ping:
    • On the robot: ddsperf pong

    • On the development environment: ddsperf ping

  4. If you don’t see a connection being established, but the normal ping was successful, please ensure the env variable ROS_LOCALHOST_ONLY is not set, as it can interfere with the connection script. You can unset it with: unset ROS_LOCALHOST_ONLY. You should also ensure that it is not being set in your .bashrc file.

  5. If a connection was established (you were able to see a DDS discovery in both the robot and your PC), but you still don’t see the topics after a little while, you can try stopping the ros2 daemon: ros2 daemon stop.

Frequently Asked Questions#

See also#