Skip to content

Commit 24d4ab2

Browse files
maryaB-osrBlast545jacobperron
authored
Rearranging ros2#863 YAML parameters content (ros2#887)
* Add tutorial YAML files parameters Signed-off-by: Jorge Perez <[email protected]> * Update source/Contributing/Migration-Guide.rst Co-authored-by: Marya Belanger <[email protected]> * Update source/Tutorials/Parameters-YAML-files-migration-guide.rst Co-authored-by: Marya Belanger <[email protected]> * Update source/Tutorials/Parameters-YAML-files-migration-guide.rst Co-authored-by: Marya Belanger <[email protected]> * Update source/Tutorials/Parameters-YAML-files-migration-guide.rst Co-authored-by: Marya Belanger <[email protected]> * Update source/Tutorials/Parameters-YAML-files-migration-guide.rst Co-authored-by: Marya Belanger <[email protected]> * Update source/Tutorials/Parameters-YAML-files-migration-guide.rst Co-authored-by: Marya Belanger <[email protected]> * Update source/Tutorials/Parameters-YAML-files-migration-guide.rst Co-authored-by: Marya Belanger <[email protected]> * Update source/Tutorials/Parameters-YAML-files-migration-guide.rst Co-authored-by: Marya Belanger <[email protected]> * Update source/Contributing/Migration-Guide.rst Co-authored-by: Jacob Perron <[email protected]> * Update source/Tutorials/Parameters-YAML-files-migration-guide.rst Co-authored-by: Jacob Perron <[email protected]> * Update source/Contributing/Migration-Guide.rst Co-authored-by: Jacob Perron <[email protected]> * Use cross reference to YAML extra document Signed-off-by: Jorge Perez <[email protected]> * rearranging Blast545's YAML parameters content Signed-off-by: maryaB-osr <[email protected]> * fix link Signed-off-by: maryaB-osr <[email protected]> * Refactor 'concept' page Refactored the concept page to keep it high-level without details and referenced other pages containing details. Signed-off-by: Jacob Perron <[email protected]> * minor typo Signed-off-by: Jacob Perron <[email protected]> * Refactor migration guide Signed-off-by: Jacob Perron <[email protected]> Co-authored-by: Jorge Perez <[email protected]> Co-authored-by: Jacob Perron <[email protected]>
1 parent 5b7244a commit 24d4ab2

File tree

7 files changed

+114
-0
lines changed

7 files changed

+114
-0
lines changed

source/Concepts.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Concept overviews will help you understand the "big picture" idea of ROS 2 syste
1515
Concepts/About-Topic-Statistics
1616
Concepts/ROS-2-Client-Libraries
1717
Concepts/Logging
18+
Concepts/About-ROS-2-Parameters
1819

1920
See https://docs.ros2.org/ for more high-level ROS 2 documentation.
2021

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
.. _AboutParameters:
2+
3+
.. redirect-from::
4+
5+
About-ROS-2-Parameters
6+
7+
About parameters in ROS 2
8+
=========================
9+
10+
.. contents:: Table of Contents
11+
:local:
12+
13+
Overview
14+
--------
15+
16+
ROS parameters are associated with ROS nodes.
17+
Parameters are used to externally configure nodes at runtime (and during runtime).
18+
The lifetime of a parameter is tied to the lifetime of the node (though the node could implement some sort of persistence to reload values after restart).
19+
20+
Parameters are addressed by node name, node namespace, parameter name, and parameter namespace.
21+
Providing a parameter namespace is optional.
22+
23+
Each parameter consists of a key and a value, where the key is a string and the value could be one of the following types: bool, int64, float64, string, byte[], bool[], int64[], float64[] or string[]
24+
25+
For an hands-on tutorial with ROS parameters see :ref:`ROS2Params`.
26+
27+
Setting parameters
28+
------------------
29+
30+
Parameters can be set in many different ways.
31+
They can be set from the command-line, from launch files, or programmatically.
32+
They can be set individually or together in a parameters file.
33+
34+
In order to set a parameter on a node, the node must first *declare* that it has that parameter.
35+
See :ref:`CppParamNode` or :ref:`PythonParamNode` for tutorials on declaring and using parameters from a node.
36+
These tutorials also demonstrate how to dynamically set a parameter with the ``ros2 param`` tool and from a launch file.
37+
38+
For examples on setting parameters from the command-line or from a parameters file, see :ref:`NodeArgsParameters`.
39+
40+
Migrating from ROS 1
41+
--------------------
42+
43+
The :ref:`Launch file migration guide <MigratingLaunch>` explains how to migrate ``param`` and ``rosparam`` launch tags from ROS 1 to ROS 2.
44+
45+
The :ref:`YAML parameter file migration guide <yaml-ros1-ros2>` explains how to migrate parameter files from ROS 1 to ROS 2.

source/Contributing/Migration-Guide.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,18 @@ Replace:
395395
* ``#include <boost/function.hpp>`` with ``#include <functional>``
396396
* ``boost::function`` with ``std::function``
397397

398+
Parameters
399+
----------
400+
401+
In ROS 1, parameters are associated with a central server that allowed retrieving parameters at runtime through the use of the network APIs.
402+
In ROS 2, parameters are associated per node and are configurable at runtime with ROS services.
403+
404+
* See `ROS 2 Parameter design document <https://design.ros2.org/articles/ros_parameters.html>`_ for more details about the system model.
405+
406+
* See `ROS 2 CLI usage <https://index.ros.org/doc/ros2/Tutorials/Parameters/Understanding-ROS2-Parameters/>`_ for a better understanding of how the CLI tools work and its differences with ROS 1 tooling.
407+
408+
* See :ref:`yaml-ros1-ros2` to see how YAML parameter files are parsed in ROS 2 and their differences with ROS implementation.
409+
398410
Launch files
399411
------------
400412

source/Tutorials.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ Miscellaneous
117117
Tutorials/Eclipse-Oxygen-with-ROS-2-and-rviz2
118118
Tutorials/Building-ROS-2-on-Linux-with-Eclipse-Oxygen
119119
Tutorials/Building-Realtime-rt_preempt-kernel-for-ROS-2
120+
Tutorials/Parameters-YAML-files-migration-guide
120121

121122
Demos
122123
-----

source/Tutorials/Launch-files-migration-guide.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _MigratingLaunch:
2+
13
Migrating launch files from ROS 1 to ROS 2
24
==========================================
35

source/Tutorials/Node-arguments.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ See ``--log-level`` argument usage in `the logging page <Logging-and-logger-conf
115115
Parameters
116116
----------
117117

118+
.. _NodeArgsParameters:
119+
118120
Setting parameters directly in the command line
119121
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
120122

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
.. _yaml-ros1-ros2:
2+
3+
Migrating YAML parameter files from ROS 1 to ROS 2
4+
==================================================
5+
6+
This tutorial describes how to adapt ROS 1 parameters files for ROS 2.
7+
8+
YAML file example
9+
-----------------
10+
11+
YAML is used to write parameters files in both ROS 1 and ROS 2.
12+
The main difference in ROS 2 is that node names must be used to address parameters.
13+
In addition to the fully qualified node name, we use the key "ros__parameters" to signal the start of parameters for the node.
14+
15+
16+
For example, here is a parameters file in ROS 1:
17+
18+
.. code-block:: yaml
19+
20+
lidar_name: foo
21+
lidar_id: 10
22+
ports: [11312, 11311, 21311]
23+
debug: true
24+
25+
Let's assume that the first two parameters are for a node named ``/lidar_ns/lidar_node_name``, the second parameter is for a node named ``/imu``, and the last parameter we want to set on both nodes.
26+
27+
We would construct our ROS 2 parameters file as follows:
28+
29+
.. code-block:: yaml
30+
31+
/lidar_ns:
32+
lidar_node_name:
33+
ros__parameters:
34+
lidar_name: foo
35+
id: 10
36+
imu:
37+
ros__parameters:
38+
ports: [2438, 2439, 2440]
39+
/**:
40+
ros__parameters:
41+
debug: true
42+
43+
Note the use of wildcards (``/**``) to indicate that the parameter ``debug`` should be set on any node in any namespace.
44+
45+
Feature parity
46+
--------------
47+
48+
Some features of ROS 1 parameters files does not exist in ROS 2:
49+
50+
- Mixed types in a list is not supported yet (`related issue <https://github.com/ros2/rcl/issues/463>`_)
51+
- ``deg`` and ``rad`` substitutions are not supported

0 commit comments

Comments
 (0)