You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/Tutorials/Advanced/Discovery-Server/Discovery-Server.rst
+151-2
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,7 @@ The following figure shows the decrease in discovery messages:
51
51
:align:center
52
52
53
53
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:
@@ -285,10 +285,159 @@ We should see how ``Listener 1`` is receiving messages from both talker nodes, w
285
285
286
286
287
287
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**.
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).
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``.
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.
292
441
For this experiment, ``tshark`` is required to be installed on your system.
293
442
The configuration file is mandatory in order to avoid using intraprocess mode.
0 commit comments