Skip to content

Commit 0a4f76c

Browse files
MRicoIE2CSrichiprosima
authored andcommitted
Add ROS 2 CLI module to Fast DDS Discovery Server Tutorial (#16)
* Refs #17064: Add ROS 2 CLI module to Fast DDS Discovery Server Tutorial Signed-off-by: Mikel Rico <[email protected]> * Refs #17064: ROS2 repo suggestions: A publisher is a communication interface, not a node. Signed-off-by: Mikel Rico <[email protected]> * Refs #17064: ROS2 repo suggestions: Nits Signed-off-by: Mikel Rico <[email protected]> * Refs #17064: ROS2 repo suggestions: Network graph Signed-off-by: Mikel Rico <[email protected]> * Refs #17064: Applied suggestions Signed-off-by: Mikel Rico <[email protected]> * Refs #17064: Nitpicks Signed-off-by: Mikel Rico <[email protected]> --------- Signed-off-by: Mikel Rico <[email protected]>
1 parent 6db8920 commit 0a4f76c

File tree

1 file changed

+151
-2
lines changed

1 file changed

+151
-2
lines changed

source/Tutorials/Advanced/Discovery-Server/Discovery-Server.rst

+151-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ The following figure shows the decrease in discovery messages:
5151
:align: center
5252

5353
This architecture reduces the number of messages sent between the server and clients dramatically.
54-
In the following graph, the reduction in network traffic over the discovery phase for the `RMF Clinic demonstration <https://github.com/osrf/rmf_demos>`__ is shown:
54+
In the following graph, the reduction in network traffic over the discovery phase for the `RMF Clinic demonstration <https://github.com/open-rmf/rmf_demos#Clinic-World>`__ is shown:
5555

5656
.. image:: figures/discovery_server_v2_performance.svg
5757
:align: center
@@ -285,10 +285,159 @@ We should see how ``Listener 1`` is receiving messages from both talker nodes, w
285285

286286

287287

288+
ROS 2 Introspection
289+
-------------------
290+
291+
ROS 2 Command Line Interface (CLI) implements several introspection tools to analyze the behaviour of a ROS 2 network.
292+
These tools (i.e. ``ros2 bag record``, ``ros2 topic list``, etc.) are very helpful to understand a ROS 2 working network.
293+
294+
Most of these tools use DDS simple discovery to exchange topic information with every existing participant (using simple discovery, every participant in the network is connected with each other).
295+
However, the new Discovery Server v2 implements a network traffic reduction scheme that limits the discovery data between participants that do not share a topic.
296+
This means that not every node will receive every topic's discovery data unless it has a reader for that topic.
297+
As most ROS 2 CLIs need a node in the network (some of them rely on a running ROS 2 daemon, and some create their own nodes), using the Discovery Server v2 these nodes will not have all the network information, and thus their functionalities are limited.
298+
299+
The Discovery Server v2 functionality allows every Participant running as a **SUPER_CLIENT**, a kind of **Client** that connects to a **SERVER**, from which it receives all the available discovery information (instead of just what it needs).
300+
In this sense, ROS 2 introspection tools can be configured as **Super Client**, thus being able to discover every entity that is using the Discovery Server protocol within the network.
301+
302+
.. note::
303+
304+
In this section we use the term *Participant* as a DDS entity. Each DDS *Participant* corresponds with a ROS 2 *Context*, a ROS 2 abstraction over DDS.
305+
`Nodes <ROS2Nodes>` are ROS 2 entities that rely on DDS communication interfaces: ``DataWriter`` and ``DataReader``.
306+
Each *Participant* can hold multiple ROS 2 Nodes.
307+
For further details about these concepts, please visit the `Node to Participant mapping design document <http://design.ros2.org/articles/Node_to_Participant_mapping.html>`__
308+
309+
310+
Daemon's related tools
311+
^^^^^^^^^^^^^^^^^^^^^^
312+
313+
The ROS 2 Daemon is used in several ROS 2 CLI introspection tools.
314+
It creates its own Participant to add a ROS 2 Node to the network graph, in order to receive all the data sent.
315+
In order for the ROS 2 CLI to work when using Discovery Server mechanism, the ROS 2 Daemon needs to be
316+
configured as **Super Client**.
317+
Therefore, this section is devoted to explain how to use ROS 2 CLI with ROS 2 Daemon running as a **Super Client**.
318+
This will allow the Daemon to discover the entire Node graph, and to receive every topic and endpoint information.
319+
To do so, a Fast DDS XML configuration file is used to configure the ROS 2 Daemon and CLI tools.
320+
321+
.. warning::
322+
Although it is possible to run the ROS 2 Daemon as a **Server**, this is not recommended since the daemon will stop
323+
after two hours of inactivity, taking the **Server** down with it.
324+
325+
Below you can find a XML configuration profile, which for this tutorial should be saved in the working directory as ```super_client_configuration_file.xml``` file.
326+
This file will configure every new participant using it, as a **Super Client**.
327+
328+
.. code-block:: xml
329+
330+
<?xml version="1.0" encoding="UTF-8" ?>
331+
<dds>
332+
<profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">
333+
<participant profile_name="super_client_profile" is_default_profile="true">
334+
<rtps>
335+
<builtin>
336+
<discovery_config>
337+
<discoveryProtocol>SUPER_CLIENT</discoveryProtocol>
338+
<discoveryServersList>
339+
<RemoteServer prefix="44.53.00.5f.45.50.52.4f.53.49.4d.41">
340+
<metatrafficUnicastLocatorList>
341+
<locator>
342+
<udpv4>
343+
<address>127.0.0.1</address>
344+
<port>11811</port>
345+
</udpv4>
346+
</locator>
347+
</metatrafficUnicastLocatorList>
348+
</RemoteServer>
349+
</discoveryServersList>
350+
</discovery_config>
351+
</builtin>
352+
</rtps>
353+
</participant>
354+
</profiles>
355+
</dds>
356+
357+
358+
.. note::
359+
360+
Under the *RemoteServer* tag, the *prefix* attribute value should be updated according to the server ID passed on the CLI (see `Fast DDS CLI <https://fast-dds.docs.eprosima.com/en/latest/fastddscli/cli/cli.html#discovery>`__).
361+
The value specified in the shown XML snippet corresponds to an ID of value 0.
362+
363+
First of all, instantiate a Discovery Server using `Fast DDS CLI <https://fast-dds.docs.eprosima.com/en/latest/fastddscli/cli/cli.html#discovery>`__ specifying an ID of value 0.
364+
365+
.. code-block:: console
366+
367+
fastdds discovery -i 0 -l 127.0.0.1 -p 11811
368+
369+
Run a talker and a listener that will discover each other through the Server (notice that ``ROS_DISCOVERY_SERVER`` configuration is the same as the one in ``super_client_configuration_file.xml``).
370+
371+
.. code-block:: console
372+
373+
export ROS_DISCOVERY_SERVER="127.0.0.1:11811"
374+
ros2 run demo_nodes_cpp listener --ros-args --remap __node:=listener
375+
376+
.. code-block:: console
377+
378+
export ROS_DISCOVERY_SERVER="127.0.0.1:11811"
379+
ros2 run demo_nodes_cpp talker --ros-args --remap __node:=talker
380+
381+
Then, instantiate a ROS 2 Daemon using the **Super Client** configuration (remember to source ROS 2 installation in every new terminal).
382+
383+
.. code-block:: console
384+
385+
export FASTRTPS_DEFAULT_PROFILES_FILE=super_client_configuration_file.xml
386+
ros2 daemon stop
387+
ros2 daemon start
388+
ros2 topic list
389+
ros2 node info /talker
390+
ros2 topic info /chatter
391+
ros2 topic echo /chatter
392+
393+
We can also see the Node's Graph using the ROS 2 tool ``rqt_graph`` as follows (you may need to press the refresh button):
394+
395+
.. code-block:: console
396+
397+
export FASTRTPS_DEFAULT_PROFILES_FILE=super_client_configuration_file.xml
398+
rqt_graph
399+
400+
401+
No Daemon tools
402+
^^^^^^^^^^^^^^^
403+
404+
Some ROS 2 CLI tools do not use the ROS 2 Daemon.
405+
In order for these tools to connect with a Discovery Server and receive all the topics information they need to be instantiated as a **Super Client** that connects to the **Server**.
406+
407+
Following the previous configuration, build a simple system with a talker and a listener.
408+
First, run a **Server**:
409+
410+
.. code-block:: console
411+
412+
fastdds discovery -i 0 -l 127.0.0.1 -p 11811
413+
414+
Then, run the talker and listener in separate terminals:
415+
416+
.. code-block:: console
417+
418+
export ROS_DISCOVERY_SERVER="127.0.0.1:11811"
419+
ros2 run demo_nodes_cpp listener --ros-args --remap __node:=listener
420+
421+
.. code-block:: console
422+
423+
export ROS_DISCOVERY_SERVER="127.0.0.1:11811"
424+
ros2 run demo_nodes_cpp talker --ros-args --remap __node:=talker
425+
426+
Continue using the ROS 2 CLI with ``--no-daemon`` option with the new configuration.
427+
New nodes will connect with the existing Server and will know every topic.
428+
Exporting ``ROS_DISCOVERY_SERVER`` is not needed as the ROS 2 tools will be configured through the ``FASTRTPS_DEFAULT_PROFILES_FILE``.
429+
430+
.. code-block:: console
431+
432+
export FASTRTPS_DEFAULT_PROFILES_FILE=super_client_configuration_file.xml
433+
ros2 topic list --no-daemon
434+
ros2 node info /talker --no-daemon --spin-time 2
435+
436+
288437
Compare Fast DDS Discovery Server with Simple Discovery Protocol
289438
----------------------------------------------------------------
290439

291-
In order to compare executing nodes using the Simple Discovery Protocol (the default DDS mechanism for distributed discovery) or the discovery server, two scripts that execute a talker and many listeners and analyze the network traffic during this time are provided.
440+
In order to compare executing nodes using the *Simple Discovery* Protocol (the default DDS mechanism for distributed discovery) or the *Discovery Server*, two scripts that execute a talker and many listeners and analyze the network traffic during this time are provided.
292441
For this experiment, ``tshark`` is required to be installed on your system.
293442
The configuration file is mandatory in order to avoid using intraprocess mode.
294443

0 commit comments

Comments
 (0)