arm_pose_service.cpp
Go to the documentation of this file.
00001 #include "move_arm.h"
00002 #include <door_manipulation_tools/RobotPosture.h>
00003 #include "switch_controller.h"
00004 
00005 bool  serviceCallback(door_manipulation_tools::RobotPosture::Request  &req,
00006                       door_manipulation_tools::RobotPosture::Response &res )
00007 {
00008   res.success = true;
00009   res.success = switch_controller("l_arm_controller", "l_arm_cart_imped_controller");
00010   if(!res.success){
00011     ROS_ERROR("Could not switch to l_arm_controller");
00012     return false;
00013   }
00014   res.success = switch_controller("r_arm_controller", "r_arm_cart_imped_controller");
00015   if(!res.success){
00016     ROS_ERROR("Could not switch to r_arm_controller");
00017     return false;
00018   }
00019 
00020   ROS_INFO("Starting Robot Arm");
00021   RobotArm robotArm;
00022   bool left_busy = false, right_busy = false;
00023   for(unsigned int i = 0; i < req.posture_names.size(); i++){
00024     ROS_INFO_STREAM("Moving to " << req.posture_names[i]);
00025     if(left_busy && req.posture_names[i][0] == 'l'){
00026         ROS_INFO_STREAM("Goal state: " << robotArm.getState(req.posture_names[i][0]).getText());
00027         left_busy = false;
00028     }
00029     if(right_busy && req.posture_names[i][0] == 'r'){
00030         ROS_INFO_STREAM("Goal state: " << robotArm.getState(req.posture_names[i][0]).getText());
00031         right_busy = false;
00032     }
00033     robotArm.startTrajectory(req.posture_names[i]);
00034     if(req.posture_names[i][0] == 'l')
00035       left_busy = true;
00036     else if(req.posture_names[i][0] == 'r')
00037       right_busy = true;
00038   }
00039   if(left_busy) ROS_INFO_STREAM("Goal state: " << robotArm.getState('l').getText());
00040   if(right_busy) ROS_INFO_STREAM("Goal state: " << robotArm.getState('r').getText());
00041   return true;
00042 }
00043 
00044 int main(int argc, char **argv)
00045 {
00046   ros::init(argc, argv, "robot_posture_service");
00047   ros::NodeHandle n;
00048   ros::ServiceServer service = n.advertiseService("robot_pose", serviceCallback);
00049   ROS_INFO("Robot pose service advertised. Waiting for clients.");
00050   ros::spin();
00051 }
00052 
 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