Skip to content

Set up ROS 2 communication with the robot

Using the PAL Development Docker

Make sure you robot is connected to the network and that it is accessible from your development machine. Alternatively, connect your development machine to the access point of your robot if available.

Connect to the robot

To connect to a robot use the PAL Connection CLI from inside the PAL Development Docker:

pal connection start [robot_address] [network_interface] [ros_domain_id]

This runs the PAL Connection Script that is explained in detail below.

The arguments that the CLI is expecting are:

  • robot_address (Optional): The IP address or the DNS-solvable hostname of the robot.

  • network_interface (Optional): The specific network interface to use for the connection. You can check all the interfaces with ip a.

  • ros_domain_id (Optional): The ROS_DOMAIN_ID the robot is currently using.

After a successful connection the terminal should look as shown in Figure 1.

Cyclone proper connection
Figure 1: Bash shell after proper cyclone connection with the robot.

This would mean that a Cyclone connection has been successfully established with your robot. You can now for example see the topics in your development environment with ros2 topic list.

A started connection is specific to the bash session it was run. If you want to see the topics in another bash session, the connection line has to be run again in that new session.

Attention

Please ensure ROS_LOCALHOST_ONLY environment variable is NOT set, especially that it is not in your .bashrc file. Everything is handled by the config package and this environment variable can lead to connection and simulation issues.

Disconnecting from the robot

To disconnect from the robot just run exit in the bash session where you ran the pal connection tool. This will stop the Cyclone connection and you will no longer be able to see the topics.

PAL Connection Script

The PAL Connection CLI is a wrapper around the PAL connection script. The connection script can be run directly with the ROS 2 command below.

   ros2 run cyclone_dev_cfg pal_connect.sh [network_interface] [robot_address]

Once the connection is established please ensure the ROS_DOMAIN_ID is set correctly.

Using any other Docker

To connect to a robot from a non-PAL Docker container or computer (that is, without the PAL Connection CLI), you must manually configure Cyclone DDS using a custom configuration file.

We suggest you to start from the PAL Cyclone DDS configuration template. Note that this configuration disables automatic discovery, so you must follow the configuration steps below to see any topics.

   <CycloneDDS>
     <Domain>
       <General>
         <AllowMulticast>false</AllowMulticast>
         <MaxMessageSize>1400B</MaxMessageSize>
         <Interfaces>
           <NetworkInterface name="lo" priority="0"/>
         </Interfaces>
       </General>
       <Discovery>
         <ParticipantIndex>auto</ParticipantIndex>
         <Peers>
           <Peer Address="localhost"/>
         </Peers>
         <MaxAutoParticipantIndex>500</MaxAutoParticipantIndex>
       </Discovery>
       <Internal>
         <Watermarks>
           <WhcHigh>2000kB</WhcHigh>
         </Watermarks>
       </Internal>
       <Tracing>
         <Verbosity>config</Verbosity>
         <OutputFile>${HOME}/.ros/log/cdds.log</OutputFile>
       </Tracing>
     </Domain>
   </CycloneDDS>

To apply a custom Cyclone DDS configuration on your PC or Docker container:

  1. Identify the network interface you want to use for the connection. On your development environment, use the ip a command to list available interfaces. Typically, Wi-Fi interfaces are named wlo1 and Ethernet interfaces enp3s0,but names may vary depending on your system. Note the interface name.

  2. Obtain the IP address or hostname of the robot. On the robot, run ip a to get the IP address for the relevant interface. This interface does not need to match the one selected on your development computer. Alternatively, you can use the robot's hostname if your DNS is configured appropriately.

  3. Add your network interface to the <Interfaces> section of the configuration, assigning it the highest priority. For example:

        <Interfaces>
        <NetworkInterface name="<your_interface>" priority="1"/>
        <NetworkInterface name="lo" priority="0"/>
        </Interfaces>
    
  4. Add the robot's IP address or hostname as a peer in the <Peers> section. For example:

        <Peers>
        <Peer Address="<robot_ip_or_hostname>"/>
        <Peer Address="localhost"/>
        </Peers>
    
  5. Save the modified XML file to your development computer and note its absolute path.

  6. Instruct Cyclone DDS to use this configuration by running the following command. To make this change permanent, add the export command directly to your bashrc.

     export CYCLONEDDS_URI=<absolute_path_to_xml>
    
  7. Restart the ROS 2 daemon with ros2 daemon stop and stop any running ROS 2 nodes. You should now be able to list and echo topics as usual. If you are still unable to see any topics, please go through the troubleshooting steps.

Running Docker inside a PAL Robot

If you are running Docker containers directly in a PAL robot, you can use the configuration template as-is, provided you start the container with the --net host flag. You just need to go through the last two steps This is also the case if you are running different non-PAL containers in your local computer.