Skip to content

Commit 4199be1

Browse files
christophfroehlichmamueluth
authored andcommitted
Fix RST syntax and some typos (#18)
* Fix rst syntax and some typos * Fix rst syntax and small typos * Fix clang issue
1 parent 1ffdb84 commit 4199be1

File tree

3 files changed

+82
-78
lines changed

3 files changed

+82
-78
lines changed

doc/Iron.rst

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,19 @@ Adaption of Command-/StateInterfaces
5353
***************************************
5454
Changes from `(PR #1240) <https://github.com/ros-controls/ros2_control/pull/1240>`__
5555

56-
* ``Command-/StateInterfaces`` are now created and exported automatically by the framework via the ``on_export_command_interfaces()`` or ``on_export_state_interfaces()`` method based on the ``InterfaceDescription`` (check the hardware_info.hpp).
56+
* ``Command-/StateInterfaces`` are now created and exported automatically by the framework via the ``on_export_command_interfaces()`` or ``on_export_state_interfaces()`` methods based on the interfaces defined in the ``ros2_control`` XML-tag, which gets parsed and the ``InterfaceDescription`` is created accordingly (check the `hardware_info.hpp <https://github.com/ros-controls/ros2_control/tree/{REPOS_FILE_BRANCH}/hardware_interface/include/hardware_interface/hardware_info.hpp>`__).
5757
* The memory for storing the value of a ``Command-/StateInterfaces`` is no longer allocated in the hardware but instead in the ``Command-/StateInterfaces`` itself.
58-
* To access the automatically created ``Command-/StateInterfaces`` we provide to ``std::unordered_map<std::string, InterfaceDescription>``. Where the string is the fully qualified name of the interface and the ``InterfaceDescription`` the configuration of the interface. The ``std::unordered_map<>`` are divided into ``type_state_interfaces_`` and ``type_command_interfaces_`` where type can be: ``joint``, ``sensor``, ``gpio`` and ``unlisted``. E.g. the ``CommandInterfaces`` for all joints can be found in the ``joint_command_interfaces_`` map. The ``unlisted`` includes all interfaces not listed in the .ros2_control.xacro but created by overriding the ``export_command_interfaces_2()`` or ``export_state_interfaces_2()`` function and creating some custom ``Command-/StateInterfaces``.
58+
* To access the automatically created ``Command-/StateInterfaces`` we provide the ``std::unordered_map<std::string, InterfaceDescription>``, where the string is the fully qualified name of the interface and the ``InterfaceDescription`` is the configuration of the interface. The ``std::unordered_map<>`` are divided into ``type_state_interfaces_`` and ``type_command_interfaces_`` where type can be: ``joint``, ``sensor``, ``gpio`` and ``unlisted``. E.g. the ``CommandInterfaces`` for all joints can be found in the ``joint_command_interfaces_`` map. The ``unlisted`` includes all interfaces not listed in the ``ros2_control`` XML-tag but were created by overriding the ``export_command_interfaces_2()`` or ``export_state_interfaces_2()`` function by creating some custom ``Command-/StateInterfaces``.
5959

6060
Migration of Command-/StateInterfaces
6161
-------------------------------------
6262
To adapt to the new way of creating and exporting ``Command-/StateInterfaces`` follow those steps:
63+
6364
1. Delete the ``std::vector<hardware_interface::CommandInterface> export_command_interfaces() override`` and ``std::vector<hardware_interface::StateInterface> export_state_interfaces() override``.
64-
2. Delete the allocated Memory for any ``Command-/StateInterfaces``:
65-
3. If you have a ``std::vector<double> hw_commands_;`` for joint ``CommandInterfaces`` delete it and any usage/appearance. Wherever you iterated over a state/command or accessed commands stated like this:
65+
2. Delete allocated memory for any ``Command-/StateInterfaces``, e.g.:
66+
67+
* If you have a ``std::vector<double> hw_commands_;`` for joints' ``CommandInterfaces`` delete the definition and any usage/appearance.
68+
* Wherever you iterated over a state/command or accessed commands like this:
6669

6770
.. code-block:: c++
6871

@@ -106,11 +109,12 @@ replace it with
106109
// means that the prefix is included for the name: E.g.: prefix/joint_1/velocity
107110
set_command(name_of_command_interface_x, get_state(name_of_state_interface_y));
108111

109-
Migration of unlisted Command-/StateInterfaces not defined in .ros2_control.xacro
110-
---------------------------------------------------------------------------------
111-
If you have some unlisted ``Command-/StateInterfaces`` not included in the .ros2_control.xacro you can follow those steps:
112+
Migration of unlisted Command-/StateInterfaces not defined in ``ros2_control`` XML-tag
113+
--------------------------------------------------------------------------------------
114+
If you want some unlisted ``Command-/StateInterfaces`` not included in the ``ros2_control`` XML-tag you can follow those steps:
115+
112116
1. Override the ``virtual std::vector<hardware_interface::InterfaceDescription> export_command_interfaces_2()`` or ``virtual std::vector<hardware_interface::InterfaceDescription> export_state_interfaces_2()``
113-
2. Create the InterfaceDescription for each of the Interfaces you want to create in the override ``export_command_interfaces_2()`` or ``export_state_interfaces_2()`` function, add it to a vector and return the vector:
117+
2. Create the InterfaceDescription for each of the interfaces you want to create in the override ``export_command_interfaces_2()`` or ``export_state_interfaces_2()`` function, add it to a vector and return the vector:
114118

115119
.. code-block:: c++
116120

@@ -119,19 +123,18 @@ If you have some unlisted ``Command-/StateInterfaces`` not included in the .ros2
119123
InterfaceInfo unlisted_interface;
120124
unlisted_interface.name = "some_unlisted_interface";
121125
unlisted_interface.min = "-5.0";
122-
unlisted_interface.data_type = "5.0";
123-
unlisted_interface.data_type = "1.0";
124126
unlisted_interface.data_type = "double";
125127
my_unlisted_interfaces.push_back(InterfaceDescription(info_.name, unlisted_interface));
126128

127129
return my_unlisted_interfaces;
128130

129-
3. The unlisted interface will then be stored in either the ``unlisted_command_interfaces_`` or ``unlisted_state_interfaces_`` map depending in which function they are created.
130-
4. You can access it like any other interface with the ``get_state(name)``, ``set_state(name, value)``, ``get_command(name)`` or ``set_command(name, value)``. E.g. ``get_state("some_unlisted_interface")``.
131+
3. The unlisted interface will then be stored in either the ``unlisted_command_interfaces_`` or ``unlisted_state_interfaces_`` map depending in which function they are created.
132+
4. You can access it like any other interface with the ``get_state(name)``, ``set_state(name, value)``, ``get_command(name)`` or ``set_command(name, value)``. E.g. ``get_state("some_unlisted_interface")``.
131133

132134
Custom exportation of Command-/StateInterfaces
133135
----------------------------------------------
134136
In case the default implementation (``on_export_command_interfaces()`` or ``on_export_state_interfaces()`` ) for exporting the ``Command-/StateInterfaces`` is not enough you can override them. You should however consider the following things:
137+
135138
* If you want to have unlisted interfaces available you need to call the ``export_command_interfaces_2()`` or ``export_state_interfaces_2()`` and add them to the ``unlisted_command_interfaces_`` or ``unlisted_state_interfaces_``.
136-
* Don't forget to store the created ``Command-/StateInterfaces`` internally as you only return shared_ptrs and the resource manager will not provide access to the created ``Command-/StateInterfaces`` for the hardware. So you must take care of storing them yourself.
139+
* Don't forget to store the created ``Command-/StateInterfaces`` internally as you only return ``shared_ptrs`` and the resource manager will not provide access to the created ``Command-/StateInterfaces`` for the hardware. So you must take care of storing them yourself.
137140
* Names must be unique!

0 commit comments

Comments
 (0)