Controller able to claim resources from multiple hardware interfaces. More...
#include <multi_interface_controller.h>
Public Member Functions | |
MultiInterfaceController (bool allow_optional_interfaces=false) | |
virtual | ~MultiInterfaceController () |
Public Member Functions inherited from controller_interface::ControllerBase | |
ControllerBase () | |
virtual | ~ControllerBase () |
virtual void | starting (const ros::Time &) |
This is called from within the realtime thread just before the first call to update. More... | |
virtual void | update (const ros::Time &time, const ros::Duration &period)=0 |
This is called periodically by the realtime thread when the controller is running. More... | |
virtual void | stopping (const ros::Time &) |
This is called from within the realtime thread just after the last update call before the controller is stopped. More... | |
bool | isRunning () |
Check if the controller is running. More... | |
void | updateRequest (const ros::Time &time, const ros::Duration &period) |
Calls update only if this controller is running. More... | |
bool | startRequest (const ros::Time &time) |
Calls starting only if this controller is initialized or already running. More... | |
bool | stopRequest (const ros::Time &time) |
Calls stopping only if this controller is initialized or already running. More... | |
Static Protected Member Functions | |
static void | clearClaims (hardware_interface::RobotHW *robot_hw) |
Clear claims from all hardware interfaces requested by this controller. More... | |
static void | extractInterfaceResources (hardware_interface::RobotHW *robot_hw_in, hardware_interface::RobotHW *robot_hw_out) |
Extract all hardware interfaces requested by this controller from robot_hw_in , and add them also to robot_hw_out . More... | |
static bool | hasRequiredInterfaces (hardware_interface::RobotHW *robot_hw) |
Check if robot hardware abstraction contains all required interfaces. More... | |
static void | populateClaimedResources (hardware_interface::RobotHW *robot_hw, ClaimedResources &claimed_resources) |
Extract all hardware interfaces requested by this controller from robot_hw_in , and add them also to robot_hw_out . More... | |
Protected Attributes | |
bool | allow_optional_interfaces_ |
hardware_interface::RobotHW | robot_hw_ctrl_ |
Private Member Functions | |
MultiInterfaceController (const MultiInterfaceController &c) | |
MultiInterfaceController & | operator= (const MultiInterfaceController &c) |
Non Real-Time Safe Functions | |
virtual bool | init (hardware_interface::RobotHW *, ros::NodeHandle &) |
Custom controller initialization logic. More... | |
virtual bool | init (hardware_interface::RobotHW *, ros::NodeHandle &, ros::NodeHandle &) |
Custom controller initialization logic. More... | |
virtual bool | initRequest (hardware_interface::RobotHW *robot_hw, ros::NodeHandle &root_nh, ros::NodeHandle &controller_nh, ClaimedResources &claimed_resources) |
Initialize the controller from a RobotHW pointer. More... | |
Additional Inherited Members | |
Public Types inherited from controller_interface::ControllerBase | |
enum | { CONSTRUCTED, INITIALIZED, RUNNING } |
The current execution state of the controller. More... | |
typedef std::vector< hardware_interface::InterfaceResources > | ClaimedResources |
Public Attributes inherited from controller_interface::ControllerBase | |
enum controller_interface::ControllerBase:: { ... } | state_ |
The current execution state of the controller. More... | |
Controller able to claim resources from multiple hardware interfaces.
This particular controller implementation allows to claim resources from one up to four different hardware interfaces. The types of these hardware interfaces are specified as template parameters.
An example multi-interface controller could claim, for instance, resources from a position-controlled arm and velocity-controlled wheels. Another example would be a controller claiming both position and effort interfaces for the same robot resources, but this would require a robot with a custom (non-exclusive) resource handling policy.
By default, all specified hardware interfaces are required, and their existence will be enforced by initRequest. It is possible to make hardware interfaces optional by means of the allow_optional_interfaces
constructor parameter. This allows to write controllers where some interfaces are mandatory, and others, if present, improve controller performance, but whose absence does not prevent the controller from running.
The following is an example of a controller claiming resources from velocity- and effort-controlled joints.
The following fragment is a modified version of the above example, where controller interfaces are not required. It is left to the controller implementer to verify interface validity. Only the initialization code is shown.
T1 | Hardware interface type. This parameter is required. |
T2 | Hardware interface type. This parameter is optional. Leave unspecified if controller only claims resources from a single hardware interface. |
T3 | Hardware interface type. This parameter is optional. Leave unspecified if controller only claims resources from two hardware interfaces. |
T4 | Hardware interface type. This parameter is optional. Leave unspecified if controller only claims resources from three hardware interfaces. |
T1
to T4
must be different types. Definition at line 194 of file multi_interface_controller.h.
|
inline |
allow_optional_interfaces | If set to true, initRequest will not fail if one or more of the requested interfaces is not present. If set to false (the default), all requested interfaces are required. |
Definition at line 202 of file multi_interface_controller.h.
|
inlinevirtual |
Definition at line 206 of file multi_interface_controller.h.
|
private |
|
inlinestaticprotected |
Clear claims from all hardware interfaces requested by this controller.
robot_hw | Robot hardware abstraction containing the interfaces whose claims will be cleared. |
Definition at line 354 of file multi_interface_controller.h.
|
inlinestaticprotected |
Extract all hardware interfaces requested by this controller from robot_hw_in
, and add them also to robot_hw_out
.
[in] | robot_hw_in | Robot hardware abstraction containing the interfaces requested by this controller, and potentially others. |
[out] | robot_hw_out | Robot hardware abstraction containing only the interfaces requested by this controller. |
Definition at line 371 of file multi_interface_controller.h.
|
inlinestaticprotected |
Check if robot hardware abstraction contains all required interfaces.
robot_hw | Robot hardware abstraction. |
robot_hw
, false otherwise. Definition at line 340 of file multi_interface_controller.h.
|
inlinevirtual |
Custom controller initialization logic.
In this method resources from different interfaces are claimed, and other non real-time initialization is performed, such as setup of ROS interfaces and resource pre-allocation.
robot_hw | Robot hardware abstraction containing a subset of the entire robot. If MultiInterfaceController was called with allow_optional_interfaces set to false (the default), this parameter contains all the interfaces requested by the controller. If allow_optional_interfaces was set to false , this parameter may contain none, some or all interfaces requested by the controller, depending on whether the robot exposes them. Please refer to the code examples in the class description. |
controller_nh | A NodeHandle in the namespace from which the controller should read its configuration, and where it should set up its ROS interface. |
Definition at line 235 of file multi_interface_controller.h.
|
inlinevirtual |
Custom controller initialization logic.
In this method resources from different interfaces are claimed, and other non real-time initialization is performed, such as setup of ROS interfaces and resource pre-allocation.
robot_hw | Robot hardware abstraction containing a subset of the entire robot. If MultiInterfaceController was called with allow_optional_interfaces set to false (the default), this parameter contains all the interfaces requested by the controller. If allow_optional_interfaces was set to false , this parameter may contain none, some or all interfaces requested by the controller, depending on whether the robot exposes them. Please refer to the code examples in the class description. |
root_nh | A NodeHandle in the root of the controller manager namespace. This is where the ROS interfaces are setup (publishers, subscribers, services). |
controller_nh | A NodeHandle in the namespace of the controller. This is where the controller-specific configuration resides. |
Definition at line 265 of file multi_interface_controller.h.
|
inlineprotectedvirtual |
Initialize the controller from a RobotHW pointer.
This calls init with a RobotHW that is a subset of the input robot_hw
parameter, containing only the requested hardware interfaces (all or some, depending on the value of allow_optional_interfaces
passed to the constructor).
robot_hw | The robot hardware abstraction. | |
root_nh | A NodeHandle in the root of the controller manager namespace. This is where the ROS interfaces are setup (publishers, subscribers, services). | |
controller_nh | A NodeHandle in the namespace of the controller. This is where the controller-specific configuration resides. | |
[out] | claimed_resources | The resources claimed by this controller. They can belong to multiple hardware interfaces. |
Implements controller_interface::ControllerBase.
Definition at line 293 of file multi_interface_controller.h.
|
private |
|
inlinestaticprotected |
Extract all hardware interfaces requested by this controller from robot_hw_in
, and add them also to robot_hw_out
.
[in] | robot_hw_in | Robot hardware abstraction containing the interfaces requested by this controller, and potentially others. |
[out] | claimed_resources | The resources claimed by this controller. They can belong to multiple hardware interfaces. |
Definition at line 389 of file multi_interface_controller.h.
|
protected |
Flag to indicate if hardware interfaces are considered optional (i.e. non-required).
Definition at line 403 of file multi_interface_controller.h.
|
protected |
Robot hardware abstraction containing only the subset of interfaces requested by the controller.
Definition at line 400 of file multi_interface_controller.h.