Skip to content

Commit 971f0cf

Browse files
authored
Migration notes on init (#2412)
1 parent 6d695b3 commit 971f0cf

File tree

2 files changed

+50
-4
lines changed

2 files changed

+50
-4
lines changed

doc/migration.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,49 @@ Migration Guides: Jazzy to Kilted
44
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
55

66
This list summarizes important changes between Jazzy (previous) and Kilted (current) releases, where changes to user code might be necessary.
7+
8+
hardware_interface
9+
******************
10+
11+
* The preferred signature for the ``on_init`` method in all
12+
``hardware_interface::*Interface`` classes has changed (`#
13+
2323 <https://github.com/ros-controls/ros2_control/pull/2323>`_) from
14+
15+
.. code-block:: cpp
16+
17+
CallbackReturn on_init(const hardware_interface::HardwareInfo& info)
18+
19+
to
20+
21+
.. code-block:: cpp
22+
23+
CallbackReturn on_init(const HardwareComponentInterfaceParams& params)
24+
25+
The ``HardwareInfo`` object can be accessed from the ``HardwareComponentInterfaceParams`` object using
26+
``params.hardware_info``. Hardware implementations implementing the ``on_init`` method should
27+
update their method signature accordingly as the deprecated signature will be removed in a
28+
future release.
29+
30+
See :ref:`writing_new_hardware_component` for advanced usage of the
31+
``HardwareComponentInterfaceParams`` object.
32+
33+
* The preferred signature for the ``init()`` method in all
34+
``hardware_interface::*Interface`` classes has changed (`#
35+
2344 <https://github.com/ros-controls/ros2_control/pull/2344>`_) from
36+
37+
38+
.. code-block:: cpp
39+
40+
CallbackReturn init(const HardwareInfo & hardware_info, rclcpp::Logger logger, rclcpp::Clock::SharedPtr clock)
41+
42+
to
43+
44+
.. code-block:: cpp
45+
46+
CallbackReturn init(const hardware_interface::HardwareComponentParams & params)
47+
48+
49+
* The ``initialize`` methods of all hardware components (such as ``Actuator``, ``Sensor``, etc.)
50+
have been updated from passing a ``const HardwareInfo &`` to passing a ``const
51+
HardwareComponentParams &`` (`# 2323 <https://github.com/ros-controls/ros2_control/pull/2323>`_).
52+
The old signatures are deprecated and will be removed in a future release.

hardware_interface/doc/writing_new_hardware_component.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,17 @@ The following is a step-by-step guide to create source files, basic tests, and c
7575
});
7676
}
7777
78-
**Method 2: Using the Executor from `HardwareComponentParams`**
78+
**Method 2: Using the Executor from `HardwareComponentInterfaceParams`**
7979

80-
For more advanced use cases where you need direct control over node creation, the ``on_init`` method can be configured to receive a ``HardwareComponentParams`` struct. This struct contains a ``weak_ptr`` to the ``ControllerManager``'s executor.
80+
For more advanced use cases where you need direct control over node creation, the ``on_init`` method can be configured to receive a ``HardwareComponentInterfaceParams`` struct. This struct contains a ``weak_ptr`` to the ``ControllerManager``'s executor.
8181

82-
#. **Update ``on_init`` Signature**: First, your hardware interface must override the ``on_init`` version that takes ``HardwareComponentParams``.
82+
#. **Update ``on_init`` Signature**: First, your hardware interface must override the ``on_init`` version that takes ``HardwareComponentInterfaceParams``.
8383

8484
.. code-block:: cpp
8585
8686
// In your <robot_hardware_interface_name>.hpp
8787
hardware_interface::CallbackReturn on_init(
88-
const hardware_interface::HardwareComponentParams & params) override;
88+
const hardware_interface::HardwareComponentInterfaceParams & params) override;
8989
9090
#. **Lock and Use the Executor**: Inside ``on_init``, you must safely "lock" the ``weak_ptr`` to get a usable ``shared_ptr``. You can then create your own node and add it to the executor.
9191

0 commit comments

Comments
 (0)