1. Echo Example

The following YAML configuration file configures a DDS Router to create a Simple Participant in Domain Id 0 and an Echo Participant that will print in stdout every message received in Domain 0, as well as information regarding discovery events.

version: v5.0

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

allowlist:
  - name: hello_world_topic                                           # 1
  - name: rt/chatter                                                  # 2

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

##################################
# SIMPLE PARTICIPANT
# This participant will subscribe to topics in allowlist in specific domain and listen every message published there

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

##################################
# ECHO PARTICIPANT
# This Participant will print in stdout every message received by the other Participants, as well as discovery information

  - name: EchoParticipant                                             # 6
    kind: echo                                                        # 7
    discovery: true                                                   # 8
    data: true                                                        # 9
    verbose: true                                                     # 10

1.1. Configuration

1.1.1. Allowed Topics

This section lists the Topics that the DDS Router will route from one Participant to the other. Topic hello_world_topic (from the Fast DDS hello_world example) and ROS 2 topic rt/chatter will be forwarded from SimpleParticipant to EchoParticipant, that will print the message in stdout.

allowlist:
  - name: hello_world_topic                                           # 1
  - name: rt/chatter                                                  # 2

1.1.2. Simple Participant

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

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

1.1.3. Echo Participant

This Participant is configured to display information regarding messages received, as well as discovery events. See Echo Participant Configuration for more details.

  - name: EchoParticipant                                             # 6
    kind: echo                                                        # 7
    discovery: true                                                   # 8
    data: true                                                        # 9
    verbose: true                                                     # 10

1.2. Execute example

For a detailed explanation on how to execute the DDS Router, refer to this section.

Note

Internal entities for a specific topic are only created once a data receiver (Reader/Subscriber) is discovered. Hence, for this example to work, either substitute allowlist for builtin-topics in the configuration file, or launch a subscriber/listener in the same domain (0).

1.2.1. Execute with Fast DDS HelloWorld Example

Execute a Fast DDS HelloWorld example:

./<path/to/fastdds_installation>/share/fastdds/examples/cpp/hello_world/bin/hello_world publisher

Execute DDS Router with this configuration file (available in <path/to/ddsrouter_tool>/share/resources/configurations/examples/echo.yaml). The expected output from the DDS Router, printed by the Echo Participant is:

New endpoint discovered: Endpoint{01.0f.92.94.d9.98.7e.6b.00.00.00.00|0.0.1.3;writer;Topic{hello_world_topic;HelloWorld;TopicQoS{durability(Fuzzy{Level(SET) TRANSIENT_LOCAL});reliability(Fuzzy{Level(SET) RELIABLE});ownership(Fuzzy{Level(SET) SHARED});depth(Fuzzy{Level(DEFAULT) 5000});max_tx_rate(Fuzzy{Level(DEFAULT) 0});max_rx_rate(Fuzzy{Level(DEFAULT) 0});downsampling(Fuzzy{Level(DEFAULT) 1})}(payload::rtps::v0)};SpecificEndpointQoS{Partitions{};OwnershipStrength{0}};Active;SimpleParticipant}.
In Endpoint: 01.0f.92.94.d9.98.7e.6b.00.00.00.00|0.0.1.3 from Participant: SimpleParticipant in topic: hello_world_topic payload received: Payload{00 01 00 00 01 00 00 00 0c 00 00 00 48 65 6c 6c 6f 20 77 6f 72 6c 64 00} with specific qos: SpecificEndpointQoS{Partitions{};OwnershipStrength{0}}.
In Endpoint: 01.0f.92.94.d9.98.7e.6b.00.00.00.00|0.0.1.3 from Participant: SimpleParticipant in topic: hello_world_topic payload received: Payload{00 01 00 00 02 00 00 00 0c 00 00 00 48 65 6c 6c 6f 20 77 6f 72 6c 64 00} with specific qos: SpecificEndpointQoS{Partitions{};OwnershipStrength{0}}.
...

1.2.2. Execute with ROS 2 demo nodes

Execute a ROS 2 demo_nodes_cpp talker in default domain 0:

ros2 run demo_nodes_cpp talker

Execute DDS Router with this configuration file (available in <path/to/ddsrouter_tool>/share/resources/configurations/examples/echo.yaml). The Echo Participant prints the discovery and data traces of topic rt/chatter (and the other ROS 2 internal topics discovered), with the same format as in the previous example.