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 Jazzy.
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
configure
toon_init
and change return type toCallbackReturn
If 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.hpp
andhardware_interface_status_values.hpp
Add include of header
rclcpp_lifecycle/state.hpp
although this may not be strictly necessaryreplace first three lines in
on_init
to:
if (hardware_interface::[Actuator|Sensor|System]Interface::on_init(info) != CallbackReturn::SUCCESS)
{
return CallbackReturn::ERROR;
}
Change last return of
on_init
toreturn 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_activate
andon_deactivate
toCallbackReturn
Change last return of
on_activate
andon_deactivate
toreturn CallbackReturn::SUCCESS;
If you have any
return_type::ERROR
inon_init
,on_activate
, orin_deactivate
change toCallbackReturn::ERROR
If you get link errors with undefined refernences to symbols in
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface
, then addrclcpp_lifecyle
package dependency toCMakeLists.txt
andpackage.xml