Skip to content

ROS2 Communication

By default, the ROS2 version of the SDK uses the global ROS2 communication mechanism. On a local network, ROS2 processes on all hosts automatically communicate with each other (that is, by default the ROS2 stack on one host can discover the topics of ROS2 processes on another host). This may cause node conflicts or unintended execution of control programs. To avoid such problems, we recommend applying the following restrictive configuration before launching ROS2 programs.

  1. Restrict ROS2 communication to the local host.
echo "export ROS_LOCALHOST_ONLY=1" >> ~/.bashrc
# To remove the restriction, edit the ~/.bashrc file and change it to: ROS_LOCALHOST_ONLY=0
  1. Configure ROS_DOMAIN_ID to isolate the communication domain. ROS_DOMAIN_ID is used to partition independent communication domains. ROS2 processes can communicate with each other only when they share the same ROS_DOMAIN_ID; otherwise, even on the same host, ROS2 processes with different ROS_DOMAIN_ID values cannot communicate. This is similar to setting a port number in networking: communication isolation is achieved by specifying a non-zero number.
# Example: set it to 72
export ROS_DOMAIN_ID=72  

For the purpose and usage of the relevant environment variables, see the Configuring Environment section of the official ROS2 documentation.