switch_controller.cpp
Go to the documentation of this file.
00001 #include "switch_controller.h"
00002 #include <ros/ros.h>
00003 #include <pr2_mechanism_msgs/SwitchController.h>
00004 #include <pr2_mechanism_msgs/LoadController.h>
00005 
00006 bool load_controller(std::string name)
00007 {
00008   return true;
00009   ros::NodeHandle n;
00010   ros::ServiceClient client = n.serviceClient<pr2_mechanism_msgs::LoadController>("/pr2_controller_manager/load_controller");
00011 
00012   pr2_mechanism_msgs::LoadController service_data;
00013   service_data.request.name = name;
00014   if (client.call(service_data)) { 
00015     ROS_INFO_STREAM("Loaded " << name); 
00016     return service_data.response.ok;
00017   } else { 
00018     ROS_INFO_STREAM("Failed to load " << name); 
00019     return false;
00020   } 
00021 }
00022 bool switch_controller(std::string start, std::string stop)
00023 {
00024   ros::NodeHandle n;
00025   ros::ServiceClient client = n.serviceClient<pr2_mechanism_msgs::SwitchController>("/pr2_controller_manager/switch_controller");
00026 
00027   pr2_mechanism_msgs::SwitchController to_imped;
00028   to_imped.request.start_controllers.push_back(start);
00029   to_imped.request.stop_controllers.push_back(stop);
00030   to_imped.request.strictness = pr2_mechanism_msgs::SwitchController::Request::BEST_EFFORT;
00031   if (client.call(to_imped)) { 
00032     ROS_INFO_STREAM("Switched from " << stop << " to "<<start); 
00033     return to_imped.response.ok;
00034   } else { 
00035     ROS_INFO_STREAM("Failed to switch from " << stop << " to "<<start); 
00036     return false;
00037   } 
00038 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends


door_manipulation_tools
Author(s): Felix Endres
autogenerated on Wed Dec 26 2012 16:02:19