eProsima ROS 2 Router, a.k.a DDS Router, is an end-user software application that enables the connection of distributed ROS 2 networks (see the documentation here <vulcanexus_router>
). That is, ROS 2 nodes such as publishers and subscriptions, or clients and services, deployed in one geographic location and using a dedicated local network will be able to communicate with other ROS 2 nodes deployed in different geographic locations on their own dedicated local networks as if they were all on the same network through the .
This tutorial explains how to configure a with forwarding routes. In particular, we will configure two participants in different domains and communicate them with a . The will have two forwarding routes, one generic and one specific to a topic. These routes will allow us to define what participants can subscribe to the data that another participant is publishing. This configuration can be useful when a participant wants to send sensible data over a to a subset of participants.
Note
This tutorial is similar to the tutorials_router_change_domain
tutorial, since we will launch a talker and a listener on different domains and connect them with a . The difference between both tutorials is that, in this one, we will set up forwarding routes to limit which participants can receive data.
The DDS protocol defines Domain Id as a parameter for every DomainParticipant. Different entities in different Domain Ids will never discover each other, and thus they will not communicate with each other. The can be used as a bridge between ROS 2 Domains, so that every node in a domain can communicate with every other node on another domain, as illustrated in the following figure:
This tutorial will use the demo_nodes_cpp
package, available in the Vulcanexus Desktop distribution. Two ROS 2 nodes, a talker and a listener, will be launched on different ROS 2 Domains, so that they cannot communicate between each other. Then, the will be used as a bridge between the two Domains, allowing the listener to receive the messages from the talker.
To proceed, please install Vulcanexus with one of the following installation methods:
linux_binary_installation
linux_source_installation
docker_installation
To deploy the , we need to create its configuration file.
The following YAML configuration file configures a with two Simple Participants in domains 0
and 1
, and establishes forwarding routes between them.
Note
This configuration enables listeners in domain 1
to subscribe to messages published in domain 0
for any topic. It also enables listeners in domain 0
to subscribe to messages published in domain 1
only for the topic secret
.
/resources/tutorials/cloud/router_conf_with_forwarding_routes/router_conf_with_forwarding_routes.yaml
The Simple Participants are configured with a name, a kind (local
), and a domain id (0
and 1
).
/resources/tutorials/cloud/router_conf_with_forwarding_routes/router_conf_with_forwarding_routes.yaml
We define the generic forwarding routes under the tag routes
. This route is configured so that ROS_2_Domain_1
can subscribe to the data published by ROS_2_Domain_0
.
/resources/tutorials/cloud/router_conf_with_forwarding_routes/router_conf_with_forwarding_routes.yaml
This route is configured so that ROS_2_Domain_1
does not publish the data it receives. Thus, a subscriber in domain 0
would not receive the data published in domain 1
.
/resources/tutorials/cloud/router_conf_with_forwarding_routes/router_conf_with_forwarding_routes.yaml
We define the topic forwarding routes under the tag topic-routes
by declaring the topic's name
, type
, and routes
.
/resources/tutorials/cloud/router_conf_with_forwarding_routes/router_conf_with_forwarding_routes.yaml
Note
The type
tag is required. The topic forwarding route will not be set for a topic with the same name
but a different type
.
Then, we declare the route for each participant.
Warning
When a topic forwarding route is defined for a specific topic, the generic forwarding route gets completely ignored and the topic forwarding route is used instead.
This route is configured so that ROS_2_Domain_0
will subscribe to the data published by ROS_2_Domain_1
on topic secret
.
/resources/tutorials/cloud/router_conf_with_forwarding_routes/router_conf_with_forwarding_routes.yaml
This route is configured so that ROS_2_Domain_0
does not forward the data it receives on topic secret
.
/resources/tutorials/cloud/router_conf_with_forwarding_routes/router_conf_with_forwarding_routes.yaml
Run the with the configuration file available at <path/to/file>/ros_2_router_with_forwarding_routes.yaml
.
ddsrouter --config-path <path/to/file>/ros_2_router_with_forwarding_routes.yaml
The output from the should be something like:
Starting DDS Router Tool execution.
DDS Router running.
If so, the has started correctly and it is currently running. In order to close the execution, press ^C or send a signal (SIGINT 2
or SIGTERM 15
) to close it.
Let us start by running the ROS 2 talker and listener nodes.
To run the nodes, we need to set up the Vulcanexus environment so that the demo_nodes_cpp
package is available. There are two ways to achieve this:
Running the Vulcanexus Docker image.
Run the Vulcanexus Docker image by executing:
docker run -it ubuntu-vulcanexus:humble-desktop
And then, source the Vulcanexus installation by executing (inside the container):
source /opt/vulcanexus/humble/setup.bash
Setting up a development environment on the local host.
To do this, the
vucanexus-humble-desktop
package is needed, since it includes all the simulation tools, demos, and tutorials.Set up the Vulcanexus environment by executing:
source /opt/vulcanexus/humble/setup.bash
Run a ROS 2 demo_nodes_cpp
talker on domain 0
:
ROS_DOMAIN_ID=0 ros2 run demo_nodes_cpp talker
Run a ROS 2 demo_nodes_cpp
listener on domain 1
:
ROS_DOMAIN_ID=1 ros2 run demo_nodes_cpp listener
Since the has a generic forwarding route from domain 0
and 1
, it will forward messages from the publisher in domain 0
to the subscriber in domain 1
, that will print them in stdout
.
Run a ROS 2 demo_nodes_cpp
talker on domain 1
:
ROS_DOMAIN_ID=1 ros2 run demo_nodes_cpp talker
Run a ROS 2 demo_nodes_cpp
listener on domain 0
:
ROS_DOMAIN_ID=0 ros2 run demo_nodes_cpp listener
Since the does not have a generic forwarding route from domain 1
and 0
, it will not forward messages from the publisher in domain 1
to the subscriber in domain 0
.
Run a ROS 2 demo_nodes_cpp
talker on domain 0
:
ROS_DOMAIN_ID=0 ros2 run demo_nodes_cpp talker --ros-args -r chatter:=secret
Run a ROS 2 demo_nodes_cpp
listener on domain 1
:
ROS_DOMAIN_ID=1 ros2 run demo_nodes_cpp listener --ros-args -r chatter:=secret
Since the does not have a topic forwarding route on topic secret
from domain 0
and 1
, it will not forward messages from the publisher in domain 0
to the subscriber in domain 1
.
Run a ROS 2 demo_nodes_cpp
talker on domain 1
:
ROS_DOMAIN_ID=1 ros2 run demo_nodes_cpp talker --ros-args -r chatter:=secret
Run a ROS 2 demo_nodes_cpp
listener on domain 0
:
ROS_DOMAIN_ID=0 ros2 run demo_nodes_cpp listener --ros-args -r chatter:=secret
Since the has a topic forwarding route on topic secret
from domain 1
and 0
, it will forward messages from the publisher in domain 1
to the subscriber in domain 0
, that will print them in stdout
.