Skip to content

Commit eb4c19d

Browse files
authored
[Controller Interface] Make assign and release interfaces virtual (#1743)
1 parent 4472287 commit eb4c19d

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

controller_interface/include/controller_interface/controller_interface_base.hpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,26 @@ class ControllerInterfaceBase : public rclcpp_lifecycle::node_interfaces::Lifecy
104104
CONTROLLER_INTERFACE_PUBLIC
105105
virtual InterfaceConfiguration state_interface_configuration() const = 0;
106106

107+
/// Method that assigns the Loaned interfaces to the controller.
108+
/**
109+
* Method used by the controller_manager to assign the interfaces to the controller.
110+
* \note When this method is overridden, the user has to also implement the `release_interfaces`
111+
* method by overriding it to release the interfaces.
112+
*
113+
* \param[in] command_interfaces vector of command interfaces to be assigned to the controller.
114+
* \param[in] state_interfaces vector of state interfaces to be assigned to the controller.
115+
*/
107116
CONTROLLER_INTERFACE_PUBLIC
108-
void assign_interfaces(
117+
virtual void assign_interfaces(
109118
std::vector<hardware_interface::LoanedCommandInterface> && command_interfaces,
110119
std::vector<hardware_interface::LoanedStateInterface> && state_interfaces);
111120

121+
/// Method that releases the Loaned interfaces from the controller.
122+
/**
123+
* Method used by the controller_manager to release the interfaces from the controller.
124+
*/
112125
CONTROLLER_INTERFACE_PUBLIC
113-
void release_interfaces();
126+
virtual void release_interfaces();
114127

115128
CONTROLLER_INTERFACE_PUBLIC
116129
return_type init(

doc/release_notes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ For details see the controller_manager section.
2424
* All chainable controllers must implement the method ``export_state_interfaces`` to export the state interfaces, similar to ``export_reference_interfaces`` method that is exporting the reference interfaces.
2525
* The controllers will now set ``use_global_arguments`` from `NodeOptions <https://docs.ros.org/en/rolling/p/rclcpp/generated/classrclcpp_1_1NodeOptions.html#_CPPv4N6rclcpp11NodeOptions20use_global_argumentsEb>`__ to false, to avoid getting influenced by global arguments (Issue : `#1684 <https://github.com/ros-controls/ros2_control/issues/1684>`_) (`#1694 <https://github.com/ros-controls/ros2_control/pull/1694>`_). From now on, in order to set the parameters to the controller, the ``--param-file`` option from spawner should be used.
2626
* With (`#1683 <https://github.com/ros-controls/ros2_control/pull/1683>`_) the ``rclcpp_lifecycle::State & get_state()`` and ``void set_state(const rclcpp_lifecycle::State & new_state)`` are replaced by ``rclcpp_lifecycle::State & get_lifecycle_state()`` and ``void set_lifecycle_state(const rclcpp_lifecycle::State & new_state)``. This change affects controllers and hardware. This is related to (`#1240 <https://github.com/ros-controls/ros2_control/pull/1240>`_) as variant support introduces ``get_state`` and ``set_state`` methods for setting/getting state of handles.
27+
* The ``assign_interfaces`` and ``release_interfaces`` methods are now virtual, so that the user can override them to store the interfaces into custom variable types, so that the user can have the flexibility to take the ownership of the loaned interfaces to the controller (`#1743 <https://github.com/ros-controls/ros2_control/pull/1743>`_)
2728

2829
controller_manager
2930
******************

0 commit comments

Comments
 (0)