Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
controller_interface::MultiInterfaceController< T > Class Template Reference

Controller able to claim resources from multiple hardware interfaces. More...

#include <multi_interface_controller.h>

Inheritance diagram for controller_interface::MultiInterfaceController< T >:
Inheritance graph
[legend]

Public Member Functions

 MultiInterfaceController (bool allow_optional_interfaces=false)
 
- Public Member Functions inherited from controller_interface::ControllerBase
 ControllerBase ()=default
 
 ControllerBase (const ControllerBase &)=delete
 
 ControllerBase (ControllerBase &&)=delete
 
ControllerBaseoperator= (const ControllerBase &)=delete
 
ControllerBaseoperator= (ControllerBase &&)=delete
 
virtual ~ControllerBase ()=default
 
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...
 
virtual void waiting (const ros::Time &)
 This is called from within the realtime thread while the controller is waiting to start. More...
 
virtual void aborting (const ros::Time &)
 This is called from within the realtime thread when the controller needs to be aborted. More...
 
bool isInitialized () const
 Check if the controller is initialized. More...
 
bool isRunning () const
 Check if the controller is running. More...
 
bool isStopped () const
 Check if the controller is stopped. More...
 
bool isWaiting () const
 Check if the controller is waiting. More...
 
bool isAborted () const
 Check if the controller is aborted. 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 unless this controller is just constructed. More...
 
bool stopRequest (const ros::Time &time)
 Calls stopping unless this controller is just constructed. More...
 
bool waitRequest (const ros::Time &time)
 Calls waiting unless this controller is just constructed. More...
 
bool abortRequest (const ros::Time &time)
 Calls abort unless this controller is just constructed. 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_
 

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...
 
bool initRequest (hardware_interface::RobotHW *robot_hw, ros::NodeHandle &root_nh, ros::NodeHandle &controller_nh, ClaimedResources &claimed_resources) override
 Initialize the controller from a RobotHW pointer. More...
 

Additional Inherited Members

- Public Types inherited from controller_interface::ControllerBase
enum  {
  CONSTRUCTED, INITIALIZED, RUNNING, STOPPED,
  WAITING, ABORTED
}
 The current execution state of the controller. More...
 
typedef std::vector< hardware_interface::InterfaceResourcesClaimedResources
 
- Public Attributes inherited from controller_interface::ControllerBase
enum controller_interface::ControllerBase:: { ... }  state_ = {CONSTRUCTED}
 The current execution state of the controller. More...
 

Detailed Description

template<typename... T>
class controller_interface::MultiInterfaceController< T >

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.

using namespace hardware_interface;
class VelEffController : public
EffortJointInterface>
{
public:
VelEffController() {}
{
// robot_hw pointer only contains the two interfaces requested by the
// controller. It is a subset of the entire robot, which may have more
// hardware interfaces
// v and e below are guarranteed to be valid
// Fetch resources from interfaces, perform rest of initialization
//...
return true;
}
void starting(const ros::Time& time);
void update(const ros::Time& time, const ros::Duration& period);
void stopping(const ros::Time& time);
};

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.

class VelEffController : public
EffortJointInterface>
{
public:
// Note true flag passed to parent class, allowing requested hardware
// interfaces to be optional
VelEffController()
EffortJointInterface> (true)
{}
{
// robot_hw pointer contains at most the two interfaces requested by the
// controller. It may have none, only one or both, depending on whether the
// robot exposes them
// v is a required interface
VelocityJointInterface* v = robot_hw->get<VelocityJointInterface>();
if (!v)
{
return false;
}
// e is an optional interface. If present, additional features are enabled.
// Controller can still function if interface or some of its resources are
// absent
EffortJointInterface* e = robot_hw->get<EffortJointInterface>();
// Fetch resources from interfaces, perform rest of initialization
//...
return true;
}
...
};
Template Parameters
T...Hardware interface types. This parameter is required.

Definition at line 149 of file multi_interface_controller.h.

Constructor & Destructor Documentation

◆ MultiInterfaceController()

template<typename... T>
controller_interface::MultiInterfaceController< T >::MultiInterfaceController ( bool  allow_optional_interfaces = false)
inline
Parameters
allow_optional_interfacesIf 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 157 of file multi_interface_controller.h.

Member Function Documentation

◆ clearClaims()

template<typename... T>
static void controller_interface::MultiInterfaceController< T >::clearClaims ( hardware_interface::RobotHW robot_hw)
inlinestaticprotected

Clear claims from all hardware interfaces requested by this controller.

Parameters
robot_hwRobot hardware abstraction containing the interfaces whose claims will be cleared.

Definition at line 302 of file multi_interface_controller.h.

◆ extractInterfaceResources()

template<typename... T>
static void controller_interface::MultiInterfaceController< T >::extractInterfaceResources ( hardware_interface::RobotHW robot_hw_in,
hardware_interface::RobotHW robot_hw_out 
)
inlinestaticprotected

Extract all hardware interfaces requested by this controller from robot_hw_in, and add them also to robot_hw_out.

Parameters
[in]robot_hw_inRobot hardware abstraction containing the interfaces requested by this controller, and potentially others.
[out]robot_hw_outRobot hardware abstraction containing only the interfaces requested by this controller.

Definition at line 315 of file multi_interface_controller.h.

◆ hasRequiredInterfaces()

template<typename... T>
static bool controller_interface::MultiInterfaceController< T >::hasRequiredInterfaces ( hardware_interface::RobotHW robot_hw)
inlinestaticprotected

Check if robot hardware abstraction contains all required interfaces.

Parameters
robot_hwRobot hardware abstraction.
Returns
true if all required hardware interfaces are exposed by robot_hw, false otherwise.

Definition at line 292 of file multi_interface_controller.h.

◆ init() [1/2]

template<typename... T>
virtual bool controller_interface::MultiInterfaceController< T >::init ( hardware_interface::RobotHW ,
ros::NodeHandle  
)
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.

Parameters
robot_hwRobot 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_nhA NodeHandle in the namespace from which the controller should read its configuration, and where it should set up its ROS interface.
Returns
True if initialization was successful and the controller is ready to be started.

Definition at line 187 of file multi_interface_controller.h.

◆ init() [2/2]

template<typename... T>
virtual bool controller_interface::MultiInterfaceController< T >::init ( hardware_interface::RobotHW ,
ros::NodeHandle ,
ros::NodeHandle  
)
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.

Parameters
robot_hwRobot 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_nhA NodeHandle in the root of the controller manager namespace. This is where the ROS interfaces are setup (publishers, subscribers, services).
controller_nhA NodeHandle in the namespace of the controller. This is where the controller-specific configuration resides.
Returns
True if initialization was successful and the controller is ready to be started.

Definition at line 217 of file multi_interface_controller.h.

◆ initRequest()

template<typename... T>
bool controller_interface::MultiInterfaceController< T >::initRequest ( hardware_interface::RobotHW robot_hw,
ros::NodeHandle root_nh,
ros::NodeHandle controller_nh,
ClaimedResources claimed_resources 
)
inlineoverrideprotectedvirtual

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).

Parameters
robot_hwThe robot hardware abstraction.
root_nhA NodeHandle in the root of the controller manager namespace. This is where the ROS interfaces are setup (publishers, subscribers, services).
controller_nhA NodeHandle in the namespace of the controller. This is where the controller-specific configuration resides.
[out]claimed_resourcesThe resources claimed by this controller. They can belong to multiple hardware interfaces.
Returns
True if initialization was successful and the controller is ready to be started.

Implements controller_interface::ControllerBase.

Definition at line 245 of file multi_interface_controller.h.

◆ populateClaimedResources()

template<typename... T>
static void controller_interface::MultiInterfaceController< T >::populateClaimedResources ( hardware_interface::RobotHW robot_hw,
ClaimedResources claimed_resources 
)
inlinestaticprotected

Extract all hardware interfaces requested by this controller from robot_hw_in, and add them also to robot_hw_out.

Parameters
[in]robot_hw_inRobot hardware abstraction containing the interfaces requested by this controller, and potentially others.
[out]claimed_resourcesThe resources claimed by this controller. They can belong to multiple hardware interfaces.

Definition at line 329 of file multi_interface_controller.h.

Member Data Documentation

◆ allow_optional_interfaces_

template<typename... T>
bool controller_interface::MultiInterfaceController< T >::allow_optional_interfaces_
protected

Flag to indicate if hardware interfaces are considered optional (i.e. non-required).

Definition at line 339 of file multi_interface_controller.h.

◆ robot_hw_ctrl_

template<typename... T>
hardware_interface::RobotHW controller_interface::MultiInterfaceController< T >::robot_hw_ctrl_
protected

Robot hardware abstraction containing only the subset of interfaces requested by the controller.

Definition at line 336 of file multi_interface_controller.h.


The documentation for this class was generated from the following file:


controller_interface
Author(s): Wim Meeussen
autogenerated on Wed Aug 19 2020 03:17:49