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
.
##################################
# 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_"
##################################
# SIMPLE PARTICIPANT DOMAIN 0
# This participant will subscribe to topics in allowlist in domain 0 and listen every message published there
SimpleParticipant_domain0: # 3
type: local # 4
domain: 0 # 5
##################################
# SIMPLE PARTICIPANT DOMAIN 1
# This Participant will print in stdout every message received by the other Participants
SimpleParticipant_domain1: # 6
type: 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 type and the Domain Id, which is 0
in this case.
SimpleParticipant_domain0: # 3
type: local # 4
domain: 0 # 5
2.1.3. Simple Participant Domain 1¶
This Participant is configured with a name, a type and the Domain Id, which is 1
in this case.
SimpleParticipant_domain1: # 6
type: 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>/share/resources/configurations/examples/change_domain.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
.