2. Change Domain Example

The following YAML configuration file configures a DDS Router to create two Simple Participants, one in domain 0 and another in domain 1.

##################################
# CONFIGURATION VERSION
version: v3.0                                                               # 0

##################################
# ALLOWED TOPICS
# Allowing FastDDS and ROS2 HelloWorld demo examples topics

allowlist:
  - name: HelloWorldTopic                                                   # 1
    type: HelloWorld                                                        # 1
  - name: rt/chatter                                                        # 2
    type: std_msgs::msg::dds_::String_

##################################
# PARTICIPANTS
participants:

##################################
# SIMPLE PARTICIPANT DOMAIN 0
# This participant subscribes to allowlist topics in DDS Domain 0 and listen every message published in such DDS Domain

  - name: SimpleParticipant_domain0                                         # 3
    kind: local                                                             # 4
    domain: 0                                                               # 5

##################################
# SIMPLE PARTICIPANT DOMAIN 1
# This participant subscribes to allowlist topics in DDS Domain 1 and listen every message published in such DDS Domain

  - name: SimpleParticipant_domain1                                         # 6
    kind: local                                                             # 7
    domain: 1                                                               # 8

2.1. Configuration

2.1.1. Allowed Topics

This section lists the Topics that the DDS Router will route from one Participant to the other. Topic HelloWorldTopic with datatype HelloWorld, and ROS 2 topic rt/chatter with datatype std_msgs::msg::dds_::String_ will be forwarded from one domain to the other, allowing different DDS domains to interact with each other.

allowlist:
  - name: HelloWorldTopic                                                   # 1
    type: HelloWorld                                                        # 1
  - name: rt/chatter                                                        # 2
    type: std_msgs::msg::dds_::String_

2.1.2. Simple Participant Domain 0

This Participant is configured with a name, a kind and the Domain Id, which is 0 in this case.

  - name: SimpleParticipant_domain0                                         # 3
    kind: local                                                             # 4
    domain: 0                                                               # 5

2.1.3. Simple Participant Domain 1

This Participant is configured with a name, a kind and the Domain Id, which is 1 in this case.

  - name: SimpleParticipant_domain1                                         # 6
    kind: local                                                             # 7
    domain: 1                                                               # 8

2.2. Execute example

Please refer to this section for a detailed explanation on how to execute the DDS Router.

2.2.1. Execute with ROS 2 demo nodes

Execute a ROS 2 demo_nodes_cpp talker in domain 0:

ROS_DOMAIN_ID=0 ros2 run demo_nodes_cpp talker

Execute a ROS 2 demo_nodes_cpp listener in domain 1:

ROS_DOMAIN_ID=1 ros2 run demo_nodes_cpp listener

Execute DDS Router with this configuration file (available in <path/to/ddsrouter_tool>/share/resources/configurations/examples/change_domain_allowlist.yaml). Once the DDS Router is running, messages from talker in domain 0 will be forwarded by the Router to the listener in domain 1, that will print them in stdout.

There is also available an example without allowlist (available in <path/to/ddsrouter_tool>/share/resources/configurations/examples/change_domain.yaml). In this case, the topics of the DDS network are dynamically discovered by the DDS Router. Since there is no allowlist, the data from all the topics found are forwarded.