Public Member Functions | Private Member Functions | Private Attributes | List of all members
controller_manager::ControllerManager Class Reference

ROS Controller Manager and Runner. More...

#include <controller_manager.h>

Public Member Functions

 ControllerManager (hardware_interface::RobotHW *robot_hw, const ros::NodeHandle &nh=ros::NodeHandle())
 Constructor. More...
virtual ~ControllerManager ()
Real-Time Safe Functions
void update (const ros::Time &time, const ros::Duration &period, bool reset_controllers=false)
 Update all active controllers. More...
Non Real-Time Safe Functions
bool loadController (const std::string &name)
 Load a new controller by name. More...
bool unloadController (const std::string &name)
 Unload a controller by name. More...
bool switchController (const std::vector< std::string > &start_controllers, const std::vector< std::string > &stop_controllers, const int strictness)
 Switch multiple controllers simultaneously. More...
virtual controller_interface::ControllerBasegetControllerByName (const std::string &name)
 Get a controller by name. More...
void registerControllerLoader (ControllerLoaderInterfaceSharedPtr controller_loader)
 Register a controller loader. More...

Private Member Functions

void getControllerNames (std::vector< std::string > &v)

Private Attributes

ros::NodeHandle cm_node_
std::list< ControllerLoaderInterfaceSharedPtrcontroller_loaders_
ros::NodeHandle root_nh_
Controller Switching
std::vector< controller_interface::ControllerBase * > start_request_
std::vector< controller_interface::ControllerBase * > stop_request_
std::list< hardware_interface::ControllerInfoswitch_start_list_
std::list< hardware_interface::ControllerInfoswitch_stop_list_
bool please_switch_
int switch_strictness_
Controllers List

The controllers list is double-buffered to avoid needing to lock the real-time thread when switching controllers in the non-real-time thread.

boost::recursive_mutex controllers_lock_
 Mutex protecting the current controllers list. More...
std::vector< ControllerSpeccontrollers_lists_ [2]
 Double-buffered controllers list. More...
int current_controllers_list_
 The index of the current controllers list. More...
int used_by_realtime_
 The index of the controllers list being used in the real-time thread. More...

ROS Service API

boost::mutex services_lock_
ros::ServiceServer srv_list_controllers_
ros::ServiceServer srv_list_controller_types_
ros::ServiceServer srv_load_controller_
ros::ServiceServer srv_unload_controller_
ros::ServiceServer srv_switch_controller_
ros::ServiceServer srv_reload_libraries_
bool listControllerTypesSrv (controller_manager_msgs::ListControllerTypes::Request &req, controller_manager_msgs::ListControllerTypes::Response &resp)
bool listControllersSrv (controller_manager_msgs::ListControllers::Request &req, controller_manager_msgs::ListControllers::Response &resp)
bool switchControllerSrv (controller_manager_msgs::SwitchController::Request &req, controller_manager_msgs::SwitchController::Response &resp)
bool loadControllerSrv (controller_manager_msgs::LoadController::Request &req, controller_manager_msgs::LoadController::Response &resp)
bool unloadControllerSrv (controller_manager_msgs::UnloadController::Request &req, controller_manager_msgs::UnloadController::Response &resp)
bool reloadControllerLibrariesSrv (controller_manager_msgs::ReloadControllerLibraries::Request &req, controller_manager_msgs::ReloadControllerLibraries::Response &resp)

Detailed Description

ROS Controller Manager and Runner.

This class advertises a ROS interface for loading, unloading, starting, and stopping ros_control-based controllers. It also serializes execution of all running controllers in update.

Definition at line 67 of file controller_manager.h.

Constructor & Destructor Documentation

controller_manager::ControllerManager::ControllerManager ( hardware_interface::RobotHW robot_hw,
const ros::NodeHandle nh = ros::NodeHandle() 


robot_hwA pointer to a robot hardware interface
nhThe ros::NodeHandle in whose namespace all ROS interfaces should operate.

Definition at line 43 of file controller_manager.cpp.

controller_manager::ControllerManager::~ControllerManager ( )

Definition at line 68 of file controller_manager.cpp.

Member Function Documentation

controller_interface::ControllerBase * controller_manager::ControllerManager::getControllerByName ( const std::string &  name)

Get a controller by name.

nameThe name of a controller
An up-casted pointer to the controller identified by name

Definition at line 115 of file controller_manager.cpp.

void controller_manager::ControllerManager::getControllerNames ( std::vector< std::string > &  v)

Definition at line 129 of file controller_manager.cpp.

bool controller_manager::ControllerManager::listControllersSrv ( controller_manager_msgs::ListControllers::Request &  req,
controller_manager_msgs::ListControllers::Response &  resp 

Definition at line 602 of file controller_manager.cpp.

bool controller_manager::ControllerManager::listControllerTypesSrv ( controller_manager_msgs::ListControllerTypes::Request &  req,
controller_manager_msgs::ListControllerTypes::Response &  resp 

Definition at line 575 of file controller_manager.cpp.

bool controller_manager::ControllerManager::loadController ( const std::string &  name)

Load a new controller by name.

This dynamically loads a controller called name and initializes the newly loaded controller.

It determines the controller type by accessing the ROS parameter "type" in the namespace given by name relative to the namespace of root_nh_. It then initializes the controller with the hardware_interface::RobotHW pointer robot_hw_, the ros::NodeHandle describing this namespace, and a reference to a std::set to retrieve the resources needed by this controller.

A controller cannot be loaded while already loaded. To re-load a controller, first unloadController and then loadController.

nameThe name of the controller as well as the ROS namespace under which the controller should be loaded
True on success
False on failure

Definition at line 141 of file controller_manager.cpp.

bool controller_manager::ControllerManager::loadControllerSrv ( controller_manager_msgs::LoadController::Request &  req,
controller_manager_msgs::LoadController::Response &  resp 

Definition at line 648 of file controller_manager.cpp.

void controller_manager::ControllerManager::registerControllerLoader ( ControllerLoaderInterfaceSharedPtr  controller_loader)

Register a controller loader.

By default, the pluginlib-based ControllerLoader is registered on construction of this class. To load controllers through alternate means, register alternate controller loaders here. Note, however, that when controllers are loaded by loadController the controller loaders are queried in the order that they were registered. This means that if a controller CAN be loaded by the pluginlib-based ControllerLoader, then it WILL, regardless of which other loaders are registered.

controller_loaderA pointer to the loader to be registered

Definition at line 695 of file controller_manager.cpp.

bool controller_manager::ControllerManager::reloadControllerLibrariesSrv ( controller_manager_msgs::ReloadControllerLibraries::Request &  req,
controller_manager_msgs::ReloadControllerLibraries::Response &  resp 

Definition at line 522 of file controller_manager.cpp.

bool controller_manager::ControllerManager::switchController ( const std::vector< std::string > &  start_controllers,
const std::vector< std::string > &  stop_controllers,
const int  strictness 

Switch multiple controllers simultaneously.

start_controllersA vector of controller names to be started
stop_controllersA vector of controller names to be stopped
strictnessHow important it is that the requested controllers are started and stopped. The levels are defined in the controller_manager_msgs/SwitchControllers service as either BEST_EFFORT or STRICT. BEST_EFFORT means that switchController can still succeed if a non-existent controller is requested to be stopped or started.

Definition at line 340 of file controller_manager.cpp.

bool controller_manager::ControllerManager::switchControllerSrv ( controller_manager_msgs::SwitchController::Request &  req,
controller_manager_msgs::SwitchController::Response &  resp 

Definition at line 680 of file controller_manager.cpp.

bool controller_manager::ControllerManager::unloadController ( const std::string &  name)

Unload a controller by name.

nameThe name of the controller to unload. (The same as the one used in loadController )

Definition at line 276 of file controller_manager.cpp.

bool controller_manager::ControllerManager::unloadControllerSrv ( controller_manager_msgs::UnloadController::Request &  req,
controller_manager_msgs::UnloadController::Response &  resp 

Definition at line 664 of file controller_manager.cpp.

void controller_manager::ControllerManager::update ( const ros::Time time,
const ros::Duration period,
bool  reset_controllers = false 

Update all active controllers.

When controllers are started or stopped (or switched), those calls are made in this function.

timeThe current time
periodThe change in time since the last call to update
reset_controllersIf true, stop and start all running controllers before updating

Definition at line 75 of file controller_manager.cpp.

Member Data Documentation

ros::NodeHandle controller_manager::ControllerManager::cm_node_

Definition at line 172 of file controller_manager.h.

std::list<ControllerLoaderInterfaceSharedPtr> controller_manager::ControllerManager::controller_loaders_

Definition at line 174 of file controller_manager.h.

std::vector<ControllerSpec> controller_manager::ControllerManager::controllers_lists_[2]

Double-buffered controllers list.

Definition at line 191 of file controller_manager.h.

boost::recursive_mutex controller_manager::ControllerManager::controllers_lock_

Mutex protecting the current controllers list.

Definition at line 189 of file controller_manager.h.

int controller_manager::ControllerManager::current_controllers_list_

The index of the current controllers list.

Definition at line 193 of file controller_manager.h.

bool controller_manager::ControllerManager::please_switch_

Definition at line 180 of file controller_manager.h.

hardware_interface::RobotHW* controller_manager::ControllerManager::robot_hw_

Definition at line 170 of file controller_manager.h.

ros::NodeHandle controller_manager::ControllerManager::root_nh_

Definition at line 172 of file controller_manager.h.

boost::mutex controller_manager::ControllerManager::services_lock_

Definition at line 213 of file controller_manager.h.

ros::ServiceServer controller_manager::ControllerManager::srv_list_controller_types_

Definition at line 214 of file controller_manager.h.

ros::ServiceServer controller_manager::ControllerManager::srv_list_controllers_

Definition at line 214 of file controller_manager.h.

ros::ServiceServer controller_manager::ControllerManager::srv_load_controller_

Definition at line 214 of file controller_manager.h.

ros::ServiceServer controller_manager::ControllerManager::srv_reload_libraries_

Definition at line 215 of file controller_manager.h.

ros::ServiceServer controller_manager::ControllerManager::srv_switch_controller_

Definition at line 215 of file controller_manager.h.

ros::ServiceServer controller_manager::ControllerManager::srv_unload_controller_

Definition at line 215 of file controller_manager.h.

std::vector<controller_interface::ControllerBase*> controller_manager::ControllerManager::start_request_

Definition at line 178 of file controller_manager.h.

std::vector<controller_interface::ControllerBase*> controller_manager::ControllerManager::stop_request_

Definition at line 178 of file controller_manager.h.

std::list<hardware_interface::ControllerInfo> controller_manager::ControllerManager::switch_start_list_

Definition at line 179 of file controller_manager.h.

std::list<hardware_interface::ControllerInfo> controller_manager::ControllerManager::switch_stop_list_

Definition at line 179 of file controller_manager.h.

int controller_manager::ControllerManager::switch_strictness_

Definition at line 181 of file controller_manager.h.

int controller_manager::ControllerManager::used_by_realtime_

The index of the controllers list being used in the real-time thread.

Definition at line 195 of file controller_manager.h.

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

Author(s): Wim Meeussen, Mathias L├╝dtke
autogenerated on Mon Apr 20 2020 03:52:09