controller_manager.h
Go to the documentation of this file.
1 // Copyright (C) 2008-2009, Willow Garage, Inc.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright notice,
7 // this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name of Stanford University nor the names of its
12 // contributors may be used to endorse or promote products derived from
13 // this software without specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 // POSSIBILITY OF SUCH DAMAGE.
27 
28 /*
29  * Author: Stuart Glaser, Wim Meeussen
30  */
31 #ifndef MECHANISM_CONTROL_H
32 #define MECHANISM_CONTROL_H
33 
34 #include <pthread.h>
35 #include <map>
36 #include <string>
37 #include <vector>
38 #include "ros/ros.h"
40 #include <tinyxml.h>
44 #include <ros/node_handle.h>
47 #include <pr2_mechanism_msgs/ListControllerTypes.h>
48 #include <pr2_mechanism_msgs/ListControllers.h>
49 #include <pr2_mechanism_msgs/ReloadControllerLibraries.h>
50 #include <pr2_mechanism_msgs/LoadController.h>
51 #include <pr2_mechanism_msgs/UnloadController.h>
52 #include <pr2_mechanism_msgs/SwitchController.h>
53 #include <pr2_mechanism_msgs/MechanismStatistics.h>
54 #include <sensor_msgs/JointState.h>
55 #include <boost/thread/condition.hpp>
56 
57 
59 
61 
62 public:
64  const ros::NodeHandle& nh=ros::NodeHandle());
65  virtual ~ControllerManager();
66 
67  // Real-time functions
68  void update();
69 
70  // Non real-time functions
71  bool initXml(TiXmlElement* config);
72  bool loadController(const std::string& name);
73  bool unloadController(const std::string &name);
74  bool switchController(const std::vector<std::string>& start_controllers,
75  const std::vector<std::string>& stop_controllers,
76  const int strictness);
77 
78  // controllers_lock_ must be locked before calling
79  virtual pr2_controller_interface::Controller* getControllerByName(const std::string& name);
80 
83 
84 private:
85  void getControllerNames(std::vector<std::string> &v);
86  void getControllerSchedule(std::vector<size_t> &schedule);
87 
90 
91  // for controller switching
92  std::vector<pr2_controller_interface::Controller*> start_request_, stop_request_;
95 
96  // controller lists
97  boost::mutex controllers_lock_;
98  std::vector<ControllerSpec> controllers_lists_[2];
99  std::vector<size_t> controllers_scheduling_[2];
101 
102  // for controller statistics
106 
107  // for publishing constroller state
108  void publishJointState();
114 
115  // services to work with controllers
116  bool listControllerTypesSrv(pr2_mechanism_msgs::ListControllerTypes::Request &req,
117  pr2_mechanism_msgs::ListControllerTypes::Response &resp);
118  bool listControllersSrv(pr2_mechanism_msgs::ListControllers::Request &req,
119  pr2_mechanism_msgs::ListControllers::Response &resp);
120  bool switchControllerSrv(pr2_mechanism_msgs::SwitchController::Request &req,
121  pr2_mechanism_msgs::SwitchController::Response &resp);
122  bool loadControllerSrv(pr2_mechanism_msgs::LoadController::Request &req,
123  pr2_mechanism_msgs::LoadController::Response &resp);
124  bool unloadControllerSrv(pr2_mechanism_msgs::UnloadController::Request &req,
125  pr2_mechanism_msgs::UnloadController::Response &resp);
126  bool reloadControllerLibrariesSrv(pr2_mechanism_msgs::ReloadControllerLibraries::Request &req,
127  pr2_mechanism_msgs::ReloadControllerLibraries::Response &resp);
128  boost::mutex services_lock_;
132 };
133 
134 }
135 #endif /* MECHANISM_CONTROL_H */
pr2_controller_manager::ControllerManager::~ControllerManager
virtual ~ControllerManager()
Definition: controller_manager.cpp:63
pr2_controller_manager
Definition: controller_manager.h:58
realtime_publisher.h
node_handle.h
pr2_controller_manager::ControllerManager::pre_update_stats_
Statistics pre_update_stats_
Definition: controller_manager.h:103
pr2_controller_manager::ControllerManager::controller_loader_
boost::shared_ptr< pluginlib::ClassLoader< pr2_controller_interface::Controller > > controller_loader_
Definition: controller_manager.h:89
pr2_controller_manager::ControllerManager::last_published_joint_state_
ros::Time last_published_joint_state_
Definition: controller_manager.h:113
controller_provider.h
pr2_controller_manager::ControllerManager
Definition: controller_manager.h:60
boost::shared_ptr
ros.h
pr2_controller_manager::ControllerManager::srv_reload_libraries_
ros::ServiceServer srv_reload_libraries_
Definition: controller_manager.h:130
pr2_controller_manager::ControllerManager::unloadControllerSrv
bool unloadControllerSrv(pr2_mechanism_msgs::UnloadController::Request &req, pr2_mechanism_msgs::UnloadController::Response &resp)
Definition: controller_manager.cpp:804
pr2_controller_manager::ControllerManager::model_
pr2_mechanism_model::Robot model_
Definition: controller_manager.h:81
pr2_controller_manager::ControllerManager::controller_node_
ros::NodeHandle controller_node_
Definition: controller_manager.h:88
pr2_controller_manager::ControllerManager::used_by_realtime_
int used_by_realtime_
Definition: controller_manager.h:100
pr2_controller_manager::ControllerManager::last_published_mechanism_stats_
ros::Time last_published_mechanism_stats_
Definition: controller_manager.h:113
pr2_controller_manager::ControllerManager::motors_previously_halted_
bool motors_previously_halted_
Definition: controller_manager.h:131
pr2_controller_manager::ControllerManager::srv_unload_controller_
ros::ServiceServer srv_unload_controller_
Definition: controller_manager.h:130
pr2_controller_manager::ControllerManager::loadController
bool loadController(const std::string &name)
Definition: controller_manager.cpp:219
pr2_controller_manager::ControllerManager::current_controllers_list_
int current_controllers_list_
Definition: controller_manager.h:100
Statistics
Definition: controller_spec.h:54
pr2_controller_manager::ControllerManager::initXml
bool initXml(TiXmlElement *config)
Definition: controller_manager.cpp:70
pr2_controller_manager::ControllerManager::listControllersSrv
bool listControllersSrv(pr2_mechanism_msgs::ListControllers::Request &req, pr2_mechanism_msgs::ListControllers::Response &resp)
Definition: controller_manager.cpp:751
pr2_controller_manager::ControllerManager::getControllerSchedule
void getControllerSchedule(std::vector< size_t > &schedule)
Definition: controller_manager.cpp:212
pr2_hardware_interface::HardwareInterface
controller_spec.h
pr2_controller_manager::ControllerManager::publish_period_joint_state_
ros::Duration publish_period_joint_state_
Definition: controller_manager.h:112
hardware_interface.h
pr2_controller_manager::ControllerManager::ControllerManager
ControllerManager(pr2_hardware_interface::HardwareInterface *hw, const ros::NodeHandle &nh=ros::NodeHandle())
Definition: controller_manager.cpp:47
pr2_controller_manager::ControllerManager::getControllerByName
virtual pr2_controller_interface::Controller * getControllerByName(const std::string &name)
Definition: controller_manager.cpp:191
ros::ServiceServer
pr2_controller_manager::ControllerManager::services_lock_
boost::mutex services_lock_
Definition: controller_manager.h:128
realtime_tools::RealtimePublisher< sensor_msgs::JointState >
pr2_controller_manager::ControllerManager::reloadControllerLibrariesSrv
bool reloadControllerLibrariesSrv(pr2_mechanism_msgs::ReloadControllerLibraries::Request &req, pr2_mechanism_msgs::ReloadControllerLibraries::Response &resp)
Definition: controller_manager.cpp:682
pr2_controller_manager::ControllerManager::loadControllerSrv
bool loadControllerSrv(pr2_mechanism_msgs::LoadController::Request &req, pr2_mechanism_msgs::LoadController::Response &resp)
Definition: controller_manager.cpp:788
pr2_controller_manager::ControllerManager::getControllerNames
void getControllerNames(std::vector< std::string > &v)
Definition: controller_manager.cpp:202
pr2_controller_manager::ControllerManager::unloadController
bool unloadController(const std::string &name)
Definition: controller_manager.cpp:368
pr2_mechanism_model::RobotState
pr2_controller_manager::ControllerManager::update
void update()
Definition: controller_manager.cpp:126
pr2_controller_manager::ControllerManager::pub_mech_stats_
realtime_tools::RealtimePublisher< pr2_mechanism_msgs::MechanismStatistics > pub_mech_stats_
Definition: controller_manager.h:111
pr2_controller_manager::ControllerManager::switchControllerSrv
bool switchControllerSrv(pr2_mechanism_msgs::SwitchController::Request &req, pr2_mechanism_msgs::SwitchController::Response &resp)
Definition: controller_manager.cpp:820
pr2_controller_manager::ControllerManager::publishMechanismStatistics
void publishMechanismStatistics()
Definition: controller_manager.cpp:589
pr2_controller_manager::ControllerManager::srv_list_controller_types_
ros::ServiceServer srv_list_controller_types_
Definition: controller_manager.h:129
pr2_mechanism_model::Robot
class_loader.hpp
pr2_controller_manager::ControllerManager::switch_strictness_
int switch_strictness_
Definition: controller_manager.h:94
pr2_controller_manager.pr2_controller_manager_interface.start_controllers
def start_controllers(names)
Definition: pr2_controller_manager_interface.py:87
pr2_controller_manager::ControllerManager::post_update_stats_
Statistics post_update_stats_
Definition: controller_manager.h:105
pr2_controller_interface::Controller
pr2_controller_manager::ControllerManager::listControllerTypesSrv
bool listControllerTypesSrv(pr2_mechanism_msgs::ListControllerTypes::Request &req, pr2_mechanism_msgs::ListControllerTypes::Response &resp)
Definition: controller_manager.cpp:732
pr2_controller_manager::ControllerManager::controllers_lists_
std::vector< ControllerSpec > controllers_lists_[2]
Definition: controller_manager.h:98
pr2_controller_manager::ControllerManager::publishJointState
void publishJointState()
Definition: controller_manager.cpp:553
pr2_controller_manager::ControllerManager::srv_list_controllers_
ros::ServiceServer srv_list_controllers_
Definition: controller_manager.h:129
ros::Time
pr2_controller_manager::ControllerManager::switchController
bool switchController(const std::vector< std::string > &start_controllers, const std::vector< std::string > &stop_controllers, const int strictness)
Definition: controller_manager.cpp:466
pr2_controller_manager::ControllerManager::controllers_scheduling_
std::vector< size_t > controllers_scheduling_[2]
Definition: controller_manager.h:99
pr2_controller_manager::ControllerManager::srv_load_controller_
ros::ServiceServer srv_load_controller_
Definition: controller_manager.h:129
pr2_controller_interface::ControllerProvider
pr2_controller_manager::ControllerManager::cm_node_
ros::NodeHandle cm_node_
Definition: controller_manager.h:88
pr2_controller_manager::ControllerManager::update_stats_
Statistics update_stats_
Definition: controller_manager.h:104
pr2_controller_manager.pr2_controller_manager_interface.stop_controllers
def stop_controllers(names)
Definition: pr2_controller_manager_interface.py:93
ros::Duration
pr2_controller_manager::ControllerManager::stop_request_
std::vector< pr2_controller_interface::Controller * > stop_request_
Definition: controller_manager.h:92
pr2_controller_manager::ControllerManager::please_switch_
bool please_switch_
Definition: controller_manager.h:93
pr2_controller_manager::ControllerManager::state_
pr2_mechanism_model::RobotState * state_
Definition: controller_manager.h:82
pr2_controller_manager::ControllerManager::publish_period_mechanism_stats_
ros::Duration publish_period_mechanism_stats_
Definition: controller_manager.h:112
pr2_controller_manager::ControllerManager::pub_joint_state_
realtime_tools::RealtimePublisher< sensor_msgs::JointState > pub_joint_state_
Definition: controller_manager.h:110
pr2_controller_manager::ControllerManager::srv_switch_controller_
ros::ServiceServer srv_switch_controller_
Definition: controller_manager.h:130
ros::NodeHandle
robot.h
pr2_controller_manager::ControllerManager::start_request_
std::vector< pr2_controller_interface::Controller * > start_request_
Definition: controller_manager.h:92
pr2_controller_manager::ControllerManager::controllers_lock_
boost::mutex controllers_lock_
Definition: controller_manager.h:97


pr2_controller_manager
Author(s): Eric Berger berger@willowgarage.com, Stuart Glaser, Wim Meeussen
autogenerated on Mon Mar 6 2023 03:49:21