5. Repeater Example¶
A DDS Router could work as a TURN Repeater to forward messages by the same Participant. If you are interested in understanding the use case of a Repeater please refer to the following section Repeater DDS Router.
The version attribute is required, as the
repeater tag is only supported from v3.0 configuration version.
version: v3.0 # 0
5.1.2. Allowed Topics¶
This section lists the Topics that the DDS Router will route from
one Participant to the other.
HelloWorldTopic with datatype
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_
5.1.3. Repeater Participant¶
The Repeater Participant is the one that will be used to forward messages by the same Participant.
It must be a
WAN Participant and be configured as so with
- name: RepeaterParticipant # 3 kind: wan # 4 repeater: true # 5 listening-addresses: - domain: "server.domain.com" port: 11666 transport: tcp
5.1.4. Client Participants¶
Every Client can connect to a Repeater Participant as if it was a normal
The Repeater admits as many edge DDS Router connections as desired, so several DDS Router can use the same
or similar configuration to communicate across it.
- name: Client # 5 kind: wan # 6 connection-addresses: - domain: "server.domain.com" port: 11666 transport: tcp
5.2. Execute example¶
Please refer to this section for a detailed explanation on how to execute the DDS Router.
5.2.1. Execute with ROS 2 demo nodes¶
In order to run this example, there must be three different hosts located in different local networks:
host HA with private IP
192.168.1.2connected to network router RA with public IP
host HB with private IP
192.168.2.2connected to network router RB with public IP
host HC with private IP
192.168.2.3connected to network router RC with public IP
This example could be run in localhost or with two hosts in the same LAN, but it will not use the WAN communication features of the DDS Router.
5.2.2. Host HA¶
This host runs the DDS Router Repeater Server, which will receive data from both edges and redirect the messages
Execute DDS Router using file
Remember to change the IP and port on the configuration file to the actual public IP of RA, and be sure that
the port forwarding rules are configured in RA so HA is accessible from the outside.
5.2.3. Hosts HB and HC¶
These hosts run the DDS Router WAN Clients, which will connect to the previously launched Repeater Server.
Execute DDS Router using file
Remember to change the IPs and ports on the configuration file to the actual public IPs of RA and RB.
In this example the port forwarding is not required, as the Repeater will allow the communication through it,
and TCP protocol is being used..
Both clients can execute ROS 2 demo nodes, which will publish and subscribe in topic
talker in one of them and a
listener in the other.
It is recommended to use different
ROS_DOMAIN_ID in each node, so in case both nodes are accessible
(under same network) no loop is created.
In order to do so, change the YAML configuration files to use different domains, and use the following ROS2 commands:
# Hb ROS_DOMAIN_ID=0 ros2 run demo_nodes_cpp talker # Hc ROS_DOMAIN_ID=1 ros2 run demo_nodes_cpp listener
After executing the three DDS Router applications in hosts, and talker and listener applications, the listener in HC will start receiving and printing data from the talker in HB. You are communicating DDS via WAN.
If HB can access HC due to port forwarding or because both are under the same network,
listener will receive duplicated messages, as one of them will arrive from HB and the other