Skip to content

Commit

Permalink
Clarify Fast DDS Discovery Server Tutorial for Windows support (ros2#…
Browse files Browse the repository at this point in the history
…4063) (ros2#4082)

* Clarify Fast DDS Discovery Server Tutorial for Windows support (#22)

Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
(cherry picked from commit db8055e)

Co-authored-by: Jesús Poderoso <120394830+JesusPoderoso@users.noreply.github.com>
  • Loading branch information
mergify[bot] and JesusPoderoso authored Dec 26, 2023
1 parent 35b6398 commit d1a952c
Showing 1 changed file with 239 additions and 22 deletions.
261 changes: 239 additions & 22 deletions source/Tutorials/Advanced/Discovery-Server/Discovery-Server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,19 @@ Execute the listener demo, to listen to the ``/chatter`` topic.
In a new terminal, set the environment variable ``ROS_DISCOVERY_SERVER`` to the location of the discovery server.
(Do not forget to source ROS 2 in every new terminal)

.. code-block:: console
.. tabs::

.. group-tab:: Linux

.. code-block:: console
export ROS_DISCOVERY_SERVER=127.0.0.1:11811
export ROS_DISCOVERY_SERVER=127.0.0.1:11811
.. group-tab:: Windows

.. code-block:: console
set ROS_DISCOVERY_SERVER=127.0.0.1:11811
Launch the listener node. Use the argument ``--remap __node:=listener_discovery_server`` to change the node's name for this tutorial.

Expand All @@ -121,9 +131,22 @@ Launch talker node

Open a new terminal and set the ``ROS_DISCOVERY_SERVER`` environment variable as before so that the node starts a discovery client.

.. tabs::

.. group-tab:: Linux

.. code-block:: console
export ROS_DISCOVERY_SERVER=127.0.0.1:11811
.. group-tab:: Windows

.. code-block:: console
set ROS_DISCOVERY_SERVER=127.0.0.1:11811
.. code-block:: console
export ROS_DISCOVERY_SERVER=127.0.0.1:11811
ros2 run demo_nodes_cpp talker --ros-args --remap __node:=talker_discovery_server
You should now see the talker publishing "hello world" messages, and the listener receiving these messages.
Expand Down Expand Up @@ -186,14 +209,40 @@ In several terminals, run the following code to establish a communication with r
``--server-id N`` means server with id N. When referencing the servers with ``ROS_DISCOVERY_SERVER``, server ``0`` must be in first place and server ``1`` in second place.

.. tabs::

.. group-tab:: Linux

.. code-block:: console
export ROS_DISCOVERY_SERVER="127.0.0.1:11811;127.0.0.1:11888"
.. group-tab:: Windows

.. code-block:: console
set ROS_DISCOVERY_SERVER="127.0.0.1:11811;127.0.0.1:11888"
.. code-block:: console
export ROS_DISCOVERY_SERVER="127.0.0.1:11811;127.0.0.1:11888"
ros2 run demo_nodes_cpp talker --ros-args --remap __node:=talker
.. tabs::

.. group-tab:: Linux

.. code-block:: console
export ROS_DISCOVERY_SERVER="127.0.0.1:11811;127.0.0.1:11888"
.. group-tab:: Windows

.. code-block:: console
set ROS_DISCOVERY_SERVER="127.0.0.1:11811;127.0.0.1:11888"
.. code-block:: console
export ROS_DISCOVERY_SERVER="127.0.0.1:11811;127.0.0.1:11888"
ros2 run demo_nodes_cpp listener --ros-args --remap __node:=listener
Now, if one of these servers fails, there will still be discovery capability available and nodes will still discover each other.
Expand All @@ -214,14 +263,40 @@ In different terminals, run the following code to establish a communication with
fastdds discovery --server-id 0 --ip-address 127.0.0.1 --port 11811 --backup
.. tabs::

.. group-tab:: Linux

.. code-block:: console
export ROS_DISCOVERY_SERVER="127.0.0.1:11811"
.. group-tab:: Windows

.. code-block:: console
set ROS_DISCOVERY_SERVER="127.0.0.1:11811"
.. code-block:: console
export ROS_DISCOVERY_SERVER="127.0.0.1:11811"
ros2 run demo_nodes_cpp talker --ros-args --remap __node:=talker
.. tabs::

.. group-tab:: Linux

.. code-block:: console
export ROS_DISCOVERY_SERVER="127.0.0.1:11811"
.. group-tab:: Windows

.. code-block:: console
set ROS_DISCOVERY_SERVER="127.0.0.1:11811"
.. code-block:: console
export ROS_DISCOVERY_SERVER="127.0.0.1:11811"
ros2 run demo_nodes_cpp listener --ros-args --remap __node:=listener
Several backup files are created in the discovery server's working directory (the directory it was launched in).
Expand Down Expand Up @@ -257,24 +332,76 @@ In another terminal run the second server listening on localhost using another p
Now, run each node in a different terminal. Use ``ROS_DISCOVERY_SERVER`` environment variable to decide which server they are connected to. Be aware that the `ids must match <https://fast-dds.docs.eprosima.com/en/v2.1.0/fastdds/env_vars/env_vars.html>`__.

.. tabs::

.. group-tab:: Linux

.. code-block:: console
export ROS_DISCOVERY_SERVER="127.0.0.1:11811;127.0.0.1:11888"
.. group-tab:: Windows

.. code-block:: console
set ROS_DISCOVERY_SERVER="127.0.0.1:11811;127.0.0.1:11888"
.. code-block:: console
export ROS_DISCOVERY_SERVER="127.0.0.1:11811;127.0.0.1:11888"
ros2 run demo_nodes_cpp talker --ros-args --remap __node:=talker_1
.. tabs::

.. group-tab:: Linux

.. code-block:: console
export ROS_DISCOVERY_SERVER="127.0.0.1:11811;127.0.0.1:11888"
.. group-tab:: Windows

.. code-block:: console
set ROS_DISCOVERY_SERVER="127.0.0.1:11811;127.0.0.1:11888"
.. code-block:: console
export ROS_DISCOVERY_SERVER="127.0.0.1:11811;127.0.0.1:11888"
ros2 run demo_nodes_cpp listener --ros-args --remap __node:=listener_1
.. tabs::

.. group-tab:: Linux

.. code-block:: console
export ROS_DISCOVERY_SERVER="127.0.0.1:11811"
.. group-tab:: Windows

.. code-block:: console
set ROS_DISCOVERY_SERVER="127.0.0.1:11811"
.. code-block:: console
export ROS_DISCOVERY_SERVER="127.0.0.1:11811"
ros2 run demo_nodes_cpp talker --ros-args --remap __node:=talker_2
.. tabs::

.. group-tab:: Linux

.. code-block:: console
export ROS_DISCOVERY_SERVER=";127.0.0.1:11888"
.. group-tab:: Windows

.. code-block:: console
set ROS_DISCOVERY_SERVER=";127.0.0.1:11888"
.. code-block:: console
export ROS_DISCOVERY_SERVER=";127.0.0.1:11888"
ros2 run demo_nodes_cpp listener --ros-args --remap __node:=listener_2
We should see how ``Listener 1`` is receiving messages from both talker nodes, while ``Listener 2`` is in a different partition from ``Talker 2`` and so does not receive messages from it.
Expand Down Expand Up @@ -364,21 +491,60 @@ First of all, instantiate a Discovery Server using `Fast DDS CLI <https://fast-d
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``).

.. tabs::

.. group-tab:: Linux

.. code-block:: console
export ROS_DISCOVERY_SERVER="127.0.0.1:11811"
.. group-tab:: Windows

.. code-block:: console
set ROS_DISCOVERY_SERVER="127.0.0.1:11811"
.. code-block:: console
export ROS_DISCOVERY_SERVER="127.0.0.1:11811"
ros2 run demo_nodes_cpp listener --ros-args --remap __node:=listener
.. tabs::

.. group-tab:: Linux

.. code-block:: console
export ROS_DISCOVERY_SERVER="127.0.0.1:11811"
.. group-tab:: Windows

.. code-block:: console
set ROS_DISCOVERY_SERVER="127.0.0.1:11811"
.. code-block:: console
export ROS_DISCOVERY_SERVER="127.0.0.1:11811"
ros2 run demo_nodes_cpp talker --ros-args --remap __node:=talker
Then, instantiate a ROS 2 Daemon using the **Super Client** configuration (remember to source ROS 2 installation in every new terminal).

.. tabs::

.. group-tab:: Linux

.. code-block:: console
export FASTRTPS_DEFAULT_PROFILES_FILE=super_client_configuration_file.xml
.. group-tab:: Windows

.. code-block:: console
set FASTRTPS_DEFAULT_PROFILES_FILE=super_client_configuration_file.xml
.. code-block:: console
export FASTRTPS_DEFAULT_PROFILES_FILE=super_client_configuration_file.xml
ros2 daemon stop
ros2 daemon start
ros2 topic list
Expand All @@ -388,9 +554,22 @@ Then, instantiate a ROS 2 Daemon using the **Super Client** configuration (remem
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):

.. tabs::

.. group-tab:: Linux

.. code-block:: console
export FASTRTPS_DEFAULT_PROFILES_FILE=super_client_configuration_file.xml
.. group-tab:: Windows

.. code-block:: console
set FASTRTPS_DEFAULT_PROFILES_FILE=super_client_configuration_file.xml
.. code-block:: console
export FASTRTPS_DEFAULT_PROFILES_FILE=super_client_configuration_file.xml
rqt_graph
Expand All @@ -409,27 +588,65 @@ First, run a **Server**:
Then, run the talker and listener in separate terminals:

.. tabs::

.. group-tab:: Linux

.. code-block:: console
export ROS_DISCOVERY_SERVER="127.0.0.1:11811"
.. group-tab:: Windows

.. code-block:: console
set ROS_DISCOVERY_SERVER="127.0.0.1:11811"
.. code-block:: console
export ROS_DISCOVERY_SERVER="127.0.0.1:11811"
ros2 run demo_nodes_cpp listener --ros-args --remap __node:=listener
.. tabs::

.. group-tab:: Linux

.. code-block:: console
export ROS_DISCOVERY_SERVER="127.0.0.1:11811"
.. group-tab:: Windows

.. code-block:: console
set ROS_DISCOVERY_SERVER="127.0.0.1:11811"
.. code-block:: console
export ROS_DISCOVERY_SERVER="127.0.0.1:11811"
ros2 run demo_nodes_cpp talker --ros-args --remap __node:=talker
Continue using the ROS 2 CLI with ``--no-daemon`` option with the new configuration.
New nodes will connect with the existing Server and will know every topic.
Exporting ``ROS_DISCOVERY_SERVER`` is not needed as the ROS 2 tools will be configured through the ``FASTRTPS_DEFAULT_PROFILES_FILE``.

.. tabs::

.. group-tab:: Linux

.. code-block:: console
export FASTRTPS_DEFAULT_PROFILES_FILE=super_client_configuration_file.xml
.. group-tab:: Windows

.. code-block:: console
set FASTRTPS_DEFAULT_PROFILES_FILE=super_client_configuration_file.xml
.. code-block:: console
export FASTRTPS_DEFAULT_PROFILES_FILE=super_client_configuration_file.xml
ros2 topic list --no-daemon
ros2 node info /talker --no-daemon --spin-time 2
Compare Fast DDS Discovery Server with Simple Discovery Protocol
----------------------------------------------------------------

Expand All @@ -439,7 +656,7 @@ The configuration file is mandatory in order to avoid using intraprocess mode.

.. note::

These scripts require a discovery server closure feature that is only available from versions newer than the version provided in ROS 2 Foxy.
These scripts are only supported on Linux, and require a discovery server closure feature that is only available from versions newer than the version provided in ROS 2 Foxy.
In order to use this functionality, compile ROS 2 with Fast DDS v2.1.0 or higher.

These scripts' features are references for advanced purposes and their study is left to the user.
Expand All @@ -464,8 +681,8 @@ After both executions are done, run the Python script to generate a graph simila
.. code-block:: console
$ export FASTRTPS_DEFAULT_PROFILES_FILE="no_intraprocess_configuration.xml"
$ sudo bash generate_discovery_packages.bash ~/ros2_foxy/install/local_setup.bash
$ sudo bash generate_discovery_packages.bash ~/ros2_foxy/install/local_setup.bash SERVER
$ sudo bash generate_discovery_packages.bash ~/ros2/install/local_setup.bash
$ sudo bash generate_discovery_packages.bash ~/ros2/install/local_setup.bash SERVER
$ python3 discovery_packets.py
.. image:: figures/discovery_packets.svg
Expand Down

0 comments on commit d1a952c

Please sign in to comment.