../_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 the ROS_DOMAIN_ID in ROS 2#

The PAL OS Docker image and robots of PAL use the ROS_DOMAIN_ID in combination with a custom Cyclone DDS configuration in order to establish P2P connection between ROS 2 systems. This allows for a more stable way of connecting to different ROS 2 systems and is more network friendly when using multiple ROS 2 systems on the same network. Steps on how to establish a connection between a PAL OS Docker image and a robot can be found in Set up ROS 2 communication with the robot.

The ROS_DOMAIN_ID is an environment variable in ROS 2 that is used to separate multiple ROS 2 processes running on the same network. Nodes with the same ROS_DOMAIN_ID can communicate with each other, but are not able to communicate to nodes with a different ROS_DOMAIN_ID. By setting different ROS_DOMAIN_ID values, you can run multiple ROS 2 processes on the same network without interference between them. A more detailed explanation of the ROS_DOMAIN_ID can be found in the ROS 2 documentation.

Important

By using the custom Cyclone DDS configuration, topics are not accessible from outside even with the same ROS_DOMAIN_ID set, unless you explicitly connect to the robot with the connection script. Section Set up ROS 2 communication with the robot explains how to use the connection script.

To show the ROS_DOMAIN_ID of the robot, the following command can be used inside the robot:

echo $ROS_DOMAIN_ID

in the PAL OS Docker image the ROS_DOMAIN_ID is set to 0 by default. To be able to establish P2P connection with the robot, change the ROS_DOMAIN_ID in your PAL OS Docker image to the same ROS_DOMAIN_ID as the robot. This can be done with the following commands:

# Set the same ROS_DOMAIN_ID as the robot
export ROS_DOMAIN_ID=42

# Show the current ROS_DOMAIN_ID
echo $ROS_DOMAIN_ID

# Make the ROS_DOMAIN_ID persistent
echo "export ROS_DOMAIN_ID=42" >> ~/.bashrc

Note

Changes to a Docker image can also be saved by committing the changes to a new image.

See the Docker tutorials to learn more about Docker.

See also#