ROS2 Concepts in Practice #3 – DDS/RTPS

Learn ROS2 DDS/RTTPS Middlewares

Written by Ruben Alves

06/05/2022

What we are going to learn

  1. How to set up the DDS middleware for your ROS2 programs
  2. What are DDS and RTPS used by ROS2
  3. How to avoid errors when working with multiple DDS providers

List of resources used in this post

  1. Use the rosject: https://app.theconstructsim.com/#/l/4a5ab758/
  2. ROS Development Studio (ROSDS) —▸ http://rosds.online
  3. ROS2 Courses –▸
    1. ROS2 Basics in 5 Days (Python): https://app.theconstructsim.com/#/Course/73
    2. ROS2 Basics in 5 Days (C++): https://app.theconstructsim.com/#/Course/61

Opening the rosject

In order to better understand DDS/RTTPS used in ROS2, we need to have ROS2 installed in our system, and it is also useful to have some simulations. To make your life easier, we already prepared a rosject with a simulation for that: https://app.theconstructsim.com/#/l/4a5ab758/ .

You can download the rosject on your own computer if you want to work locally, but just by copying the rosject (clicking the link), you will have a setup already prepared for you.

After the rosject has been successfully copied to your own area, you should see a Run button. Just click that button to launch the rosject (below you have a rosject example).

Learn ROS2 Parameters - Run rosject

Learn ROS2 – Run rosject (example of the RUN button)

 

After pressing the Run button, you should have the rosject loaded. Let’s now head to the next section to really get some real practice.

DDS Overview

DDS stands for Data Distribution Service, it is an industry standard for distributed object management groups. More info on https://www.dds-foundation.org/what-is-dds-3/

ROS2 is built on top of DDS/RTPS Middleware implementations to handle DDS/RTPS communication. Right now, we have 4 DDS implementations available for ROS2. The different implementations implement the ROS Middleware Interface (RMW).

In this POST we will be using the ROS2 Galactic version. For ROS2 Galactic, the default DDS Implementation is Cyclone DDS.

RTTPS Overview

RTPS (Real-Time Transport Protocol) is the protocol used by DDS. https://www.omg.org/spec/DDSI-RTPS/2.3/Beta1/PDF

The DDS War

Up until ROS2 Foxy, the default DDS Implementation used by ROS was eProsima’s Fast DDS (previous default RMW)
Eclipse Cyclone DDS (default one since Galactic)

For ROS2 Galactic, as we already mentioned earlier,  the default DDS Implementation is Cyclone DDS. The Galactic version was released on May 23rd, 2021, and is supported until November 2022.

For ROS2 Humble, an LTS (Long Term Support) version with support until May 2027,  eProsima’s Fast DDS is again the default middleware.

Running publishers and subscribers with default DDS

Assuming you have opened the rosject by clicking the Run button mentioned in earlier sections, let’s now Open a Terminal in order to launch ROS nodes.

Open a new Terminal

Open a new Terminal

 

In the first terminal that is open, let’s start a publisher by running the command below:

ros2 run demo_nodes_cpp talker

 

Please open a second terminal and run a subscriber there:

ros2 run demo_nodes_cpp listener

 

If everything went well, the publisher and subscriber should be working with no problems:

ROS2 Concepts in Practice #3 - DDS_RTPS - publisher and subscriber

ROS2 Concepts in Practice #3 – DDS_RTPS – publisher and subscriber

Since we did not inform the DDS Implementation that we are using, they are using the default one, which for ROS Galactic is Cyclone DDS.

You may be asking: How do I know which implementation I’m really using?

That is quite easy. After running ros2 topic list, a ROS2 Daemon will be launched and in the command line, you will see the DDS Implementation used. If you then list the process and search for rmw using grep, you will find the implementation being used.

Let’s search the DDS with the command “ps faux | grep rmw“:

ps faux | grep rmw

# The output
/usr/bin/python3 /opt/ros/galactic/bin/_ros2_daemon --rmw-implementation rmw_cyclonedds_cpp --ros-domain-id 0

As we can see in the output “–rmw-implementation rmw_cyclonedds_cpp“, the implementation used for ROS Galactic is Cyclone DDS.

RMW_IMPLEMENTATION

If you want to use different DDS Implementations, you can make usage of the environment variable called RMW_IMPLEMENTATION that ROS uses.

Let’s put it into practice in the next sections.

Using eProsima’s Fast DDS

In order to use FastDDS, you have to export the following variable:

export RMW_IMPLEMENTATION=rmw_fastrtps_cpp

 

On The Construct we already have ros-galactic-rmw-fastrtps-cpp installed, but if running the nodes in your own computer, you may need to install it with:

sudo apt-get update

sudo apt-get install -y ros-galactic-rmw-fastrtps-cpp

 

You can also set the variable when starting each node, for example. Please go to the first terminal, kill the current publisher by pressing CTRL-C, and then let’s launch the publisher with FastDDS with the command below:

RMW_IMPLEMENTATION=rmw_fastrtps_cpp ros2 run demo_nodes_cpp talker

And to run the subscriber using FastDDS, you can just set RMW_IMPLEMENTATION:

RMW_IMPLEMENTATION=rmw_fastrtps_cpp ros2 run demo_nodes_cpp listener

 

You can go even further and use different DDS Implementations for different ROS Nodes. To test this, please open a third terminal and do not kill the current publisher running with FastDDS. You can then run the listener in a third terminal using CyCloneDDS with:

RMW_IMPLEMENTATION=rmw_cyclonedds_cpp ros2 run demo_nodes_cpp listener

The listener should be working with no problems.

Using CycloneDDS

In order to use CycloneDDS, you just have to define RMW_IMPLEMENTATION=rmw_cyclonedds_cpp, and you will also need to have the ros-galactic-rmw-cyclonedds-cpp package installed.

On The Construct, this package is already installed, but if you are running the ROS2 nodes on your  computer, you may need to install the package ros-galactic-rmw-cyclonedds-cpp with:

sudo apt-get update

sudo apt-get install -y ros-galactic-rmw-cyclonedds-cpp

 

You can then run the talker/publisher and listener/subscriber using CycloneDDS with:

RMW_IMPLEMENTATION=rmw_cyclonedds_cpp ros2 run demo_nodes_cpp talker

RMW_IMPLEMENTATION=rmw_cyclonedds_cpp ros2 run demo_nodes_cpp listener

 

Using GurumNetworks GurumDDS

In order to use GurumDDS, you have to export RMW_IMPLEMENTATION=rmw_gurumdds_cpp.

Let’s try to run the publisher:

RMW_IMPLEMENTATION=rmw_gurumdds_cpp ros2 run demo_nodes_cpp talker

Since we do not have that DDS implementation installed, you should have an error similar to the following:

 

[ERROR] [1651517328.801031797] [rcl]: Error getting RMW implementation identifier / 
RMW implementation not installed (expected identifier of 'rmw_gurumdds_cpp'), 
with error message 'failed to load shared library 'librmw_gurumdds_cpp.so' due to dlopen error: 
librmw_gurumdds_cpp.so: cannot open shared object file: No such file or directory, 
at /tmp/binarydeb/ros-galactic-rcutils-4.0.2/src/shared_library.c:99, 
at /tmp/binarydeb/ros-galactic-rmw-implementation-2.4.1/src/functions.cpp:75', exiting with 1., 
at /tmp/binarydeb/ros-galactic-rcl-3.1.2/src/rcl/rmw_implementation_identifier_check.c:139

 

The problem happens because we do not have the GurumDDS installed by default on The Construct. You have to install the ros-galactic-rmw-gurumdds-cpp package with:

sudo apt-get update

sudo apt-get install -y ros-galactic-rmw-gurumdds-cpp

 

After that, running the publisher and subscriber should work with no problems:

RMW_IMPLEMENTATION=rmw_gurumdds_cpp ros2 run demo_nodes_cpp talker

 

Hm, now you probably have a new error similar to the following:

user:~$ RMW_IMPLEMENTATION=rmw_gurumdds_cpp ros2 run demo_nodes_cpp talker
22-05-02 18:52:44.719 2804 2804 E [License] Invalid license
22-05-02 18:52:44.719 2804 2804 E [License] Reason: No license for feature(gurumdds-x86_64-linux)
22-05-02 18:52:44.719 2804 2804 E [License] Please contact us via email below for license extension and inquiries.
22-05-02 18:52:44.719 2804 2804 E [License] email: contact@gurum.cc

 

Well, I think it is clear to you that this DDS implementation needs a special license. If you want to use this implementation, it would be nice to reach the creators through the email contact@gurum.cc.

Using Connext DDS

In order to use Connext DDS to run a ROS2 node, for example, you can just:

RMW_IMPLEMENTATION=rmw_connext_cpp ros2 run demo_nodes_cpp talker

But we will have an error also because this DDS implementation is not installed. The error is the following:

[ERROR] [1651517890.844612937] [rcl]: Error getting RMW implementation identifier / 
RMW implementation not installed (expected ide ntifier of 'rmw_connext_cpp'), 
with error message 'failed to load shared library 'librmw_connext_cpp.so' due to dlopen error: 
librmw_connext_cpp.so: cannot open shared object file: 
No such file or directory, at /tmp/binarydeb/ros-galactic-rcutils-4.0.2/src/sha
red_library.c:99, 
at /tmp/binarydeb/ros-galactic-rmw-implementation-2.4.1/src/functions.cpp:75', 
exiting with 1., 
at /tmp/binarydeb/ros-galactic-rcl-3.1.2/src/rcl/rmw_implementation_identifier_check.c:139

 

If you want to install this DDS implementation, I would ask you to follow the instructions in the link below:

https://docs.ros.org/en/foxy/Installation/DDS-Implementations/Install-Connext-Security-Plugins.html

Limitations when mixing DDS Implementations

We saw in the Using FastDDS section that we can use different DDSs for the publisher and subscriber.

We cannot use, however, any combinations of DDS implementations because there are some limitations. The know limitations are:

Fast DDS and Connext limitations

  • WString published by Fast DDS can’t be received correctly by Connext on macOS

Connext and Cyclone DDS

  • Does not support pub/sub communication for WString

Connext Dynamic and Connext Dynamic

  • Does not support C services

Youtube video

So this is the post for today. Remember that we have the live version of this post on YouTube. If you liked the content, please consider subscribing to our youtube channel. We are publishing new content ~every day.

Keep pushing your ROS Learning.

Related Courses & Training

If you want to learn more about ROS and ROS2, we recommend the following courses:

Masterclass 2023 batch2 blog banner

Check Out These Related Posts

129. ros2ai

129. ros2ai

I would like to dedicate this episode to all the ROS Developers who believe that ChatGPT or...

read more

0 Comments

Submit a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Pin It on Pinterest

Share This