You're reading the documentation for a version of ROS 2 that has reached its EOL (end-of-life), and is no longer officially supported. If you want up-to-date information, please have a look at Kilted.
Hardware Components
Hardware components represent abstraction of physical hardware in ros2_control framework. There are three types of hardware Actuator, Sensor and System. For details on each type check Hardware Components description.
Handling of errors that happen during read() and write() calls
If hardware_interface::return_type::ERROR is returned from read() or write() methods of a hardware interface, on_error(previous_state) method will be called to handle any error that happened.
Error handling follows the node lifecycle.
If successful CallbackReturn::SUCCESS is returned and hardware is again in UNCONFIGURED state, if any ERROR or FAILURE happens the hardware ends in FINALIZED state and can not be recovered.
The only option is to reload the complete plugin, but there is currently no service for this in the Controller Manager.
Migration from Foxy to Galactic
Between Foxy and Galactic we made substantial changes to the interface of hardware components to enable management of their lifecycle. The following list shows a set of quick changes to port existing hardware components to Galactic:
Rename
configuretoon_initand change return type toCallbackReturnIf using BaseInterface as base class then you should remove it. Specifically, change:
hardware_interface::BaseInterface<hardware_interface::[Actuator|Sensor|System]Interface> to hardware_interface::[Actuator|Sensor|System]Interface
Remove include of headers
base_interface.hppandhardware_interface_status_values.hppAdd include of header
rclcpp_lifecycle/state.hppalthough this may not be strictly necessaryreplace first three lines in
on_initto:
if (hardware_interface::[Actuator|Sensor|System]Interface::on_init(info) != CallbackReturn::SUCCESS)
{
return CallbackReturn::ERROR;
}
Change last return of
on_inittoreturn CallbackReturn::SUCCESS;Remove all lines with
status_ = ...orstatus::...Rename
start()toon_activate(const rclcpp_lifecycle::State & previous_state)andstop()toon_deactivate(const rclcpp_lifecycle::State & previous_state)Change return type of
on_activateandon_deactivatetoCallbackReturnChange last return of
on_activateandon_deactivatetoreturn CallbackReturn::SUCCESS;If you have any
return_type::ERRORinon_init,on_activate, orin_deactivatechange toCallbackReturn::ERRORIf you get link errors with undefined refernences to symbols in
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface, then addrclcpp_lifecylepackage dependency toCMakeLists.txtandpackage.xml