6. XML Participant Configuration

The following YAML configuration file configures a DDS Router to create a Simple Participant in domain 0, and another participant configured by XML to communicate in domain 1. The result of executing this configuration is similar to the one in Change Domain Example. It generates a bridge between two different domains (0 & 1).

##################################
# CONFIGURATION VERSION
version: v4.0                                                     # 0

##################################
# CONFIGURATION VERSION
xml:                                                              # 1
  files:
    - "./xml_configuration.xml"                                   # 2
  raw: |                                                          # 3
    <?xml version="1.0" encoding="UTF-8" ?>
    <profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles" >
        <participant profile_name="custom_participant_configuration">
            <domainId>1</domainId>
            <rtps></rtps>
        </participant>
    </profiles>

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

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

  - name: SimpleParticipant                                       # 6
    kind: local                                                   # 7
    domain: 0                                                     # 8

##################################
# WAN SERVER
# This participant will subscribe to topics in allowlist and connect to clients through Initial Peers.

  - name: XMLParticipant                                          # 9
    kind: xml                                                     # 10
    profile: custom_participant_configuration                     # 11

6.1. Configuration

6.1.1. Fast DDS XML Configuration

Fast DDS supports loading XML configuration files to load profiles. These profiles are used to configure different DomainParticipants using profile name. Loading an XML file or setting the raw xml file in the DDS Router YAML configuration file allows to load such profiles. Here there are the 2 ways to load them. For more information check following section.

xml:                                                              # 1
  files:
    - "./xml_configuration.xml"                                   # 2
  raw: |                                                          # 3
    <?xml version="1.0" encoding="UTF-8" ?>
    <profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles" >
        <participant profile_name="custom_participant_configuration">
            <domainId>1</domainId>
            <rtps></rtps>
        </participant>
    </profiles>

6.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                                       # 6
    kind: local                                                   # 7
    domain: 0                                                     # 8

6.1.3. XML Participant Domain 1

This Participant is configured with a name, a kind and the XML profile tag that will be used to configure it. As the XML loaded in this same YAML file configures profile custom_participant_configuration as default Participant in domain 1, this Participant will work as a local participant in such domain.

  - name: XMLParticipant                                          # 9
    kind: xml                                                     # 10
    profile: custom_participant_configuration                     # 11

6.2. Execute example

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

6.2.1. Execute with Fast DDS Basic Configuration Example

Execute a Fast DDS BasicConfigurationExample publisher in domain 0:

./BasicConfigurationExample publisher --domain 0

Execute a Fast DDS BasicConfigurationExample subscriber in domain 1:

./BasicConfigurationExample subscriber --domain 1

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

6.2.2. 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/xml.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.