Public Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
controller_interface::MultiInterfaceController< T1, T2, T3, T4 > Class Template Reference

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

#include <multi_interface_controller.h>

Inheritance diagram for controller_interface::MultiInterfaceController< T1, T2, T3, T4 >:
Inheritance graph
[legend]

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)
 
MultiInterfaceControlleroperator= (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::InterfaceResourcesClaimedResources
 
- Public Attributes inherited from controller_interface::ControllerBase
enum controller_interface::ControllerBase:: { ... }  state_
 The current execution state of the controller. More...
 

Detailed Description

template<class T1, class T2 = void, class T3 = void, class T4 = void>
class controller_interface::MultiInterfaceController< T1, T2, T3, T4 >

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
T1Hardware interface type. This parameter is required.
T2Hardware interface type. This parameter is optional. Leave unspecified if controller only claims resources from a single hardware interface.
T3Hardware interface type. This parameter is optional. Leave unspecified if controller only claims resources from two hardware interfaces.
T4Hardware interface type. This parameter is optional. Leave unspecified if controller only claims resources from three hardware interfaces.
Precondition
When specified, template parameters T1 to T4 must be different types.

Definition at line 194 of file multi_interface_controller.h.

Constructor & Destructor Documentation

template<class T1 , class T2 = void, class T3 = void, class T4 = void>
controller_interface::MultiInterfaceController< T1, T2, T3, T4 >::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 202 of file multi_interface_controller.h.

template<class T1 , class T2 = void, class T3 = void, class T4 = void>
virtual controller_interface::MultiInterfaceController< T1, T2, T3, T4 >::~MultiInterfaceController ( )
inlinevirtual

Definition at line 206 of file multi_interface_controller.h.

template<class T1 , class T2 = void, class T3 = void, class T4 = void>
controller_interface::MultiInterfaceController< T1, T2, T3, T4 >::MultiInterfaceController ( const MultiInterfaceController< T1, T2, T3, T4 > &  c)
private

Member Function Documentation

template<class T1 , class T2 = void, class T3 = void, class T4 = void>
static void controller_interface::MultiInterfaceController< T1, T2, T3, T4 >::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 354 of file multi_interface_controller.h.

template<class T1 , class T2 = void, class T3 = void, class T4 = void>
static void controller_interface::MultiInterfaceController< T1, T2, T3, T4 >::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 371 of file multi_interface_controller.h.

template<class T1 , class T2 = void, class T3 = void, class T4 = void>
static bool controller_interface::MultiInterfaceController< T1, T2, T3, T4 >::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 340 of file multi_interface_controller.h.

template<class T1 , class T2 = void, class T3 = void, class T4 = void>
virtual bool controller_interface::MultiInterfaceController< T1, T2, T3, T4 >::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 235 of file multi_interface_controller.h.

template<class T1 , class T2 = void, class T3 = void, class T4 = void>
virtual bool controller_interface::MultiInterfaceController< T1, T2, T3, T4 >::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 265 of file multi_interface_controller.h.

template<class T1 , class T2 = void, class T3 = void, class T4 = void>
virtual bool controller_interface::MultiInterfaceController< T1, T2, T3, T4 >::initRequest ( hardware_interface::RobotHW robot_hw,
ros::NodeHandle root_nh,
ros::NodeHandle controller_nh,
ClaimedResources claimed_resources 
)
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).

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 293 of file multi_interface_controller.h.

template<class T1 , class T2 = void, class T3 = void, class T4 = void>
MultiInterfaceController& controller_interface::MultiInterfaceController< T1, T2, T3, T4 >::operator= ( const MultiInterfaceController< T1, T2, T3, T4 > &  c)
private
template<class T1 , class T2 = void, class T3 = void, class T4 = void>
static void controller_interface::MultiInterfaceController< T1, T2, T3, T4 >::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 389 of file multi_interface_controller.h.

Member Data Documentation

template<class T1 , class T2 = void, class T3 = void, class T4 = void>
bool controller_interface::MultiInterfaceController< T1, T2, T3, T4 >::allow_optional_interfaces_
protected

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

Definition at line 403 of file multi_interface_controller.h.

template<class T1 , class T2 = void, class T3 = void, class T4 = void>
hardware_interface::RobotHW controller_interface::MultiInterfaceController< T1, T2, T3, T4 >::robot_hw_ctrl_
protected

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

Definition at line 400 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 Fri Jun 7 2019 22:00:06