ROS2 on Multiple Machines

Utilizing the DDS (Data Distribution Service) in ROS2, it’s feasible to send and receive messages across multiple machines without explicit configuration. This functionality is employed to control a robot, referred to as DBot, and to collect data from it using an external computer.

For detailed information, refer to this guide

Note

DBot operates on Ubuntu 22.04 with ROS2 Humble installed. The external computer should also have ROS2 installed, preferably the same distribution (ROS Humble).

Prerequisites

  1. Ensure both machines are connected to the same network.

  2. Verify that multicasting is enabled on the network. To check, run the following command on DBot to obtain its IP address:

    $ hostname -I
    

    This command will return an IP address, such as 192.168.1.102(). Then, from the external computer, run:

    $ ping 192.168.1.102
    

    If the ping is successful, communication between the external computer and DBot is established.

  3. Confirm that all machines share the same domain ID.

  4. To enable joystick control from the external PC, install the ‘joy_linux’ ROS2 package:

    $ sudo apt-get install ros-humble-joy-linux
    

SSH Connection

To establish SSH connection make sure that dbot and the laptop are both connected to the same wifi. It is recommended to use wifi router mounted on top of dbot (Tp link M200). The password for the router is 52399565 and Dbot ip is set to 192.168.1.102, Therefore you can make ssh connection by:

$ ssh dbot2@192.168.1.102

Configuring Joystick Control

If your joystick ID is not ‘js0’, replace XXX with your joystick ID and run:

$ ros2 run joy_linux joy_linux_node --ros-args -p dev:=/dev/input/XXX

For instance, for ID ‘js1’, execute:

$ ros2 run joy_linux joy_linux_node --ros-args -p dev:=/dev/input/js1

This action sets the parameter and initiates the ‘joy_linux’ node, allowing DBot to be controlled from the external PC.

Note

With ROS functionalities shared between the two machines, access to all topics, nodes, etc., is available. However, be mindful of potential delays in data sharing, especially when recording messages (e.g., from a Velodyne sensor) on the external PC.

Setting the ROS_DOMAIN_ID

For ROS communication across multiple machines, a common ‘ROS_DOMAIN_ID’ parameter is essential. By default, this value is 0 and doesn’t require explicit setting. To add more machines to the same network or to restrict communication, setting a domain ID is recommended:

$ export ROS_DOMAIN_ID=XX

Replace XX with any number between 0 and 101. Ensure the same ID is used for both DBot and the external PC.