Distributed System in ROS2

When you run your ROS2 application, there are often requirements to run ROS2 nodes in different locations on different machines. Since ROS2 uses in the abstract DDS layer for communication between the nodes, we can arrange the communication very easily.
In order to understand fully the architecture of ROS2 I recommend you to be familiar with this article.

For the purpose of this article, I communicated the Nvidia Jetson Xavier and my PC. Both units run ROS2 Foxy. I connected the RGB camera to Jetso and ran a publisher (in C++ or Python). The PC runs subscribers (C++ or Python) to subscribe to the topic and displays a video stream.

The source code is available on my GitHub.

The architecture can be depicted as follows.

Below I include, the ROS2 command to run your application according to the above figure. The application can be run on the same machine or other configurations without changes.

The most important however is to run the application (publisher — subscriber on the same ROS_DOMAIN_ID. In order to align you have to export the same ID.

If you run your application in C++,

Modify your CMakeList.txt (see also my Github). Here I display CMakeList.txt to build publisher and subscriber. You have to choose your machine type.

Copy the pub_cam.cpp and sub_cam.cpp (from my repository) to /dev_opencv/src.

If you run your application in Python,

Copy Python scripts to dev_opencv_py and modify setup.py,

In package.xml change

Run following command,

Thank you for reading.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store