Skip to content

ROS 2 Network Configuration

The ROS 21 DDS middleware allows advanced network configurations. This page contains some examples that may be useful when interacting with the iRobot® Create® 3.

Important

Depending on the ROS 2 RMW used, the syntax for configuring the network will be different. We recommend to visit the RMW vendor documentation for more details.

You can choose a RMW implementation on your machine using

export RMW_IMPLEMENTATION=name-of-the-rmw

On the robot the same can be controlled through the Create® 3 webserver.

Important

Always make sure that all the ROS 2 processes you are using have selected the same RMW implementation.

Fast-DDS

Fast-DDS allows to specify DDS configuration through an XML file. In order to apply a configuration, the path to the XML file must be provided through the following environment variable:

export FASTRTPS_DEFAULT_PROFILES_FILE=/path/to/the/xml/profile

Detailed network configurations are described in the Fast-DDS documentation.

Multiple Network Interfaces

Fast-DDS supports multiple network interfaces out of the box. A ROS 2 process will automatically use all the interfaces that were available when it started (it will not use network interfaces activated while the process was already running).

Disable Multicast

Some networks (e.g., academic or corporate Wi-Fi) may block the multicast packets used by ROS 2 by default. The following XML profile can be used on your laptop (or compute board) to force using unicast and directly connect to the IP address of your robot.

The file must be edited replacing ROBOT_IP with the actual IP value.

<?xml version="1.0" encoding="UTF-8" ?>
<profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">
   <participant profile_name="unicast_connection" is_default_profile="true">
       <rtps>
           <builtin>
               <metatrafficUnicastLocatorList>
                   <locator/>
               </metatrafficUnicastLocatorList>
               <initialPeersList>
                   <locator>
                       <udpv4>
                           <address>ROBOT_IP</address>
                       </udpv4>
                   </locator>
               </initialPeersList>
           </builtin>
       </rtps>
   </participant>
</profiles>

CycloneDDS

CycloneDDS allows to specify DDS configuration through an XML file. In order to apply a configuration, the path to the XML file must be provided through the following environment variable:

export CYCLONEDDS_URI=/path/to/the/xml/profile

Detailed network configurations are described in the CycloneDDS documentation.

Multiple Network Interfaces

This feature requires CycloneDDS version 0.8.0 or higher. Use the following XML profile specifying the name of all the network interfaces you want to use. For example usb0 and wlan0 in this example.

<CycloneDDS>
   <Domain>
     <General>
        <NetworkInterfaceAddress>usb0,wlan0</NetworkInterfaceAddress>
    </General>
   </Domain>
</CycloneDDS>

Note that the specified network interfaces must be already active when the ROS 2 process is started.

Attention

If the robot is running with a Compute Board like a Raspberry Pi® or an NVIDIA® Jetson™ connected via USB, then the robot is using a multiple interface CycloneDDS config file to communicate both over usb0 and wlan0. We have found that with CycloneDDS version 0.8.1, for an Ubuntu laptop to see the robot topics with CycloneDDS when running multiple interfaces, the laptop must use the configuration option:

<CycloneDDS>
   <Domain>
     <General>
        <DontRoute>true</DontRoute>
    </General>
   </Domain>
</CycloneDDS>

Disable Multicast

Some networks (e.g. corporate WiFi) may block the multicast packets used by ROS 2 by default. The following XML profile can be used on your laptop (or compute board) to force using unicast and directly connect to the IP address of your robot.

The file must be edited replacing ${ROBOT_IP} with the actual IP value, or exporting the value as an environment variable.

<CycloneDDS>
  <Domain>
    <Id>any</Id>
    <General>
      <NetworkInterfaceAddress>auto</NetworkInterfaceAddress>
      <AllowMulticast>false</AllowMulticast>
      <EnableMulticastLoopback>true</EnableMulticastLoopback>
    </General>
    <Discovery>
      <ParticipantIndex>0</ParticipantIndex>
      <Peers>
        <Peer Address="${ROBOT_IP}:7410"/>
      </Peers>
    </Discovery>
  </Domain>
</CycloneDDS>

  1. ROS 2 is governed by Open Robotics