Skip to content

Commit 3a53368

Browse files
committed
rename export_state/command_interface_2 to export_state/commad_interface_descriptions
1 parent 2d6e7ea commit 3a53368

File tree

5 files changed

+29
-19
lines changed

5 files changed

+29
-19
lines changed

hardware_interface/doc/writing_new_hardware_component.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ The following is a step-by-step guide to create source files, basic tests, and c
5555
#. Implement ``on_cleanup`` method, which does the opposite of ``on_configure``.
5656
#. ``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

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``.
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_interface_descriptions()`` or ``export_state_interface_descriptions()`` function by creating some custom ``Command-/StateInterfaces``.
5959
* For the ``Sensor``-type hardware interface there is no ``export_command_interfaces`` method.
6060
* As a reminder, the full interface names have structure ``<joint_name>/<interface_type>``.
6161

6262
#. (optional) If you want some unlisted ``Command-/StateInterfaces`` not included in the ``ros2_control`` XML-tag you can follow those steps:
6363

64-
#. Override the ``virtual std::vector<hardware_interface::InterfaceDescription> export_command_interfaces_2()`` or ``virtual std::vector<hardware_interface::InterfaceDescription> export_state_interfaces_2()``
65-
#. 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:
64+
#. Override the ``virtual std::vector<hardware_interface::InterfaceDescription> export_command_interface_descriptions()`` or ``virtual std::vector<hardware_interface::InterfaceDescription> export_state_interface_descriptions()``
65+
#. Create the InterfaceDescription for each of the interfaces you want to create in the override ``export_command_interface_descriptions()`` or ``export_state_interface_descriptions()`` function, add it to a vector and return the vector:
6666

6767
.. code-block:: c++
6868

@@ -81,7 +81,7 @@ The following is a step-by-step guide to create source files, basic tests, and c
8181

8282
#. (optional) 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:
8383

84-
* 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_``.
84+
* If you want to have unlisted interfaces available you need to call the ``export_command_interface_descriptions()`` or ``export_state_interface_descriptions()`` and add them to the ``unlisted_command_interfaces_`` or ``unlisted_state_interfaces_``.
8585
* 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.
8686
* Names must be unique!
8787

hardware_interface/include/hardware_interface/actuator_interface.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ class ActuatorInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNod
189189
*
190190
* \return vector of descriptions to the unlisted StateInterfaces
191191
*/
192-
virtual std::vector<hardware_interface::InterfaceDescription> export_state_interfaces_2()
192+
virtual std::vector<hardware_interface::InterfaceDescription>
193+
export_state_interface_descriptions()
193194
{
194195
// return empty vector by default.
195196
return {};
@@ -206,7 +207,7 @@ class ActuatorInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNod
206207
{
207208
// import the unlisted interfaces
208209
std::vector<hardware_interface::InterfaceDescription> unlisted_interface_descriptions =
209-
export_state_interfaces_2();
210+
export_state_interface_descriptions();
210211

211212
std::vector<std::shared_ptr<StateInterface>> state_interfaces;
212213
state_interfaces.reserve(
@@ -265,7 +266,8 @@ class ActuatorInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNod
265266
*
266267
* \return vector of descriptions to the unlisted CommandInterfaces
267268
*/
268-
virtual std::vector<hardware_interface::InterfaceDescription> export_command_interfaces_2()
269+
virtual std::vector<hardware_interface::InterfaceDescription>
270+
export_command_interface_descriptions()
269271
{
270272
// return empty vector by default.
271273
return {};
@@ -282,7 +284,7 @@ class ActuatorInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNod
282284
{
283285
// import the unlisted interfaces
284286
std::vector<hardware_interface::InterfaceDescription> unlisted_interface_descriptions =
285-
export_command_interfaces_2();
287+
export_command_interface_descriptions();
286288

287289
std::vector<std::shared_ptr<CommandInterface>> command_interfaces;
288290
command_interfaces.reserve(

hardware_interface/include/hardware_interface/sensor_interface.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ class SensorInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNodeI
173173
*
174174
* \return vector of descriptions to the unlisted StateInterfaces
175175
*/
176-
virtual std::vector<hardware_interface::InterfaceDescription> export_state_interfaces_2()
176+
virtual std::vector<hardware_interface::InterfaceDescription>
177+
export_state_interface_descriptions()
177178
{
178179
// return empty vector by default.
179180
return {};
@@ -190,7 +191,7 @@ class SensorInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNodeI
190191
{
191192
// import the unlisted interfaces
192193
std::vector<hardware_interface::InterfaceDescription> unlisted_interface_descriptions =
193-
export_state_interfaces_2();
194+
export_state_interface_descriptions();
194195

195196
std::vector<std::shared_ptr<StateInterface>> state_interfaces;
196197
state_interfaces.reserve(

hardware_interface/include/hardware_interface/system_interface.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ class SystemInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNodeI
208208
*
209209
* \return vector of descriptions to the unlisted StateInterfaces
210210
*/
211-
virtual std::vector<hardware_interface::InterfaceDescription> export_state_interfaces_2()
211+
virtual std::vector<hardware_interface::InterfaceDescription>
212+
export_state_interface_descriptions()
212213
{
213214
// return empty vector by default.
214215
return {};
@@ -225,7 +226,7 @@ class SystemInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNodeI
225226
{
226227
// import the unlisted interfaces
227228
std::vector<hardware_interface::InterfaceDescription> unlisted_interface_descriptions =
228-
export_state_interfaces_2();
229+
export_state_interface_descriptions();
229230

230231
std::vector<std::shared_ptr<StateInterface>> state_interfaces;
231232
state_interfaces.reserve(
@@ -297,7 +298,8 @@ class SystemInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNodeI
297298
*
298299
* \return vector of descriptions to the unlisted CommandInterfaces
299300
*/
300-
virtual std::vector<hardware_interface::InterfaceDescription> export_command_interfaces_2()
301+
virtual std::vector<hardware_interface::InterfaceDescription>
302+
export_command_interface_descriptions()
301303
{
302304
// return empty vector by default.
303305
return {};
@@ -314,7 +316,7 @@ class SystemInterface : public rclcpp_lifecycle::node_interfaces::LifecycleNodeI
314316
{
315317
// import the unlisted interfaces
316318
std::vector<hardware_interface::InterfaceDescription> unlisted_interface_descriptions =
317-
export_command_interfaces_2();
319+
export_command_interface_descriptions();
318320

319321
std::vector<std::shared_ptr<CommandInterface>> command_interfaces;
320322
command_interfaces.reserve(

hardware_interface/test/test_component_interfaces_custom_export.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ class DummyActuatorDefault : public hardware_interface::ActuatorInterface
5757
{
5858
std::string get_name() const override { return "DummyActuatorDefault"; }
5959

60-
std::vector<hardware_interface::InterfaceDescription> export_state_interfaces_2() override
60+
std::vector<hardware_interface::InterfaceDescription> export_state_interface_descriptions()
61+
override
6162
{
6263
std::vector<hardware_interface::InterfaceDescription> interfaces;
6364
hardware_interface::InterfaceInfo info;
@@ -68,7 +69,8 @@ class DummyActuatorDefault : public hardware_interface::ActuatorInterface
6869
return interfaces;
6970
}
7071

71-
std::vector<hardware_interface::InterfaceDescription> export_command_interfaces_2() override
72+
std::vector<hardware_interface::InterfaceDescription> export_command_interface_descriptions()
73+
override
7274
{
7375
std::vector<hardware_interface::InterfaceDescription> interfaces;
7476
hardware_interface::InterfaceInfo info;
@@ -96,7 +98,8 @@ class DummySensorDefault : public hardware_interface::SensorInterface
9698
{
9799
std::string get_name() const override { return "DummySensorDefault"; }
98100

99-
std::vector<hardware_interface::InterfaceDescription> export_state_interfaces_2() override
101+
std::vector<hardware_interface::InterfaceDescription> export_state_interface_descriptions()
102+
override
100103
{
101104
std::vector<hardware_interface::InterfaceDescription> interfaces;
102105
hardware_interface::InterfaceInfo info;
@@ -118,7 +121,8 @@ class DummySystemDefault : public hardware_interface::SystemInterface
118121
{
119122
std::string get_name() const override { return "DummySystemDefault"; }
120123

121-
std::vector<hardware_interface::InterfaceDescription> export_state_interfaces_2() override
124+
std::vector<hardware_interface::InterfaceDescription> export_state_interface_descriptions()
125+
override
122126
{
123127
std::vector<hardware_interface::InterfaceDescription> interfaces;
124128
hardware_interface::InterfaceInfo info;
@@ -129,7 +133,8 @@ class DummySystemDefault : public hardware_interface::SystemInterface
129133
return interfaces;
130134
}
131135

132-
std::vector<hardware_interface::InterfaceDescription> export_command_interfaces_2() override
136+
std::vector<hardware_interface::InterfaceDescription> export_command_interface_descriptions()
137+
override
133138
{
134139
std::vector<hardware_interface::InterfaceDescription> interfaces;
135140
hardware_interface::InterfaceInfo info;

0 commit comments

Comments
 (0)