00001 00002 /* 00003 * Copyright 2013 Southwest Research Institute 00004 00005 Licensed under the Apache License, Version 2.0 (the "License"); 00006 you may not use this file except in compliance with the License. 00007 You may obtain a copy of the License at 00008 00009 http://www.apache.org/licenses/LICENSE-2.0 00010 00011 Unless required by applicable law or agreed to in writing, software 00012 distributed under the License is distributed on an "AS IS" BASIS, 00013 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 See the License for the specific language governing permissions and 00015 limitations under the License. 00016 */ 00017 00018 #ifndef MOVEPICKPLACESERVER_H_ 00019 #define MOVEPICKPLACESERVER_H_ 00020 00021 #include "MoveArmActionClient.h" 00022 #include <object_manipulator/grasp_execution/approach_lift_grasp.h> 00023 #include <object_manipulator/place_execution/descend_retreat_place.h> 00024 #include <object_manipulation_msgs/PickupAction.h> 00025 #include <object_manipulation_msgs/PlaceAction.h> 00026 #include <object_manipulation_msgs/GraspHandPostureExecutionAction.h> 00027 #include <actionlib/server/simple_action_server.h> 00028 00029 namespace mtconnect_cnc_robot_example 00030 { 00031 // aliases 00032 typedef actionlib::ActionServer<object_manipulation_msgs::PickupAction> MoveArmPickupServer; 00033 typedef actionlib::ActionServer<object_manipulation_msgs::PlaceAction> MoveArmPlaceServer; 00034 typedef actionlib::SimpleActionClient<object_manipulation_msgs::GraspHandPostureExecutionAction> GraspActionClient; 00035 typedef object_manipulation_msgs::GraspHandPostureExecutionGoal GraspGoal; 00036 typedef boost::shared_ptr<MoveArmPickupServer> MoveArmPickupServerPtr; 00037 typedef boost::shared_ptr<MoveArmPlaceServer> MoveArmPlaceServerPtr; 00038 typedef boost::shared_ptr<GraspActionClient> GraspActionClientPtr; 00039 typedef MoveArmPickupServer::GoalHandle PickupGoalHandle; 00040 typedef MoveArmPlaceServer::GoalHandle PlaceGoalHandle; 00041 00042 // defaults 00043 static const std::string DEFAULT_PICKUP_ACTION = "pickup_action_service"; 00044 static const std::string DEFAULT_PLACE_ACTION = "place_action_service"; 00045 static const std::string DEFAULT_GRASP_ACTION = "grasp_action_service"; 00046 static const double DURATION_WAIT_GRASP_RESULT = 20.0f; 00047 00048 class MovePickPlaceServer: public MoveArmActionClient 00049 { 00050 public: 00051 MovePickPlaceServer(); 00052 virtual ~MovePickPlaceServer(); 00053 00054 virtual void run(); 00055 //virtual void start(); // waits for client requests 00056 00057 virtual bool fetchParameters(std::string nameSpace = ""); 00058 00059 virtual bool moveArmThroughPickSequence(const object_manipulation_msgs::PickupGoal &pickup_goal); 00060 virtual bool moveArmThroughPlaceSequence(const object_manipulation_msgs::PlaceGoal &place_goal); 00061 00062 protected: 00063 00064 virtual bool setup(); 00065 00066 protected: 00067 00068 virtual void pickupGoalCallback(PickupGoalHandle goal); 00069 virtual void pickupCancelCallback(PickupGoalHandle goal); 00070 virtual void placeGoalCallback(PlaceGoalHandle goal); 00071 virtual void placeCancelCallback(PlaceGoalHandle goal); 00072 00073 bool createPickupMoveSequence(const object_manipulation_msgs::PickupGoal &goal 00074 ,geometry_msgs::PoseArray &pickup_pose_sequence); 00075 bool createPlaceMoveSequence(const object_manipulation_msgs::PlaceGoal &goal 00076 ,geometry_msgs::PoseArray &place_pose_sequence); 00077 00078 protected: 00079 00080 // action servers 00081 MoveArmPickupServerPtr arm_pickup_server_ptr_; 00082 MoveArmPlaceServerPtr arm_place_server_ptr_; 00083 00084 // server goal handles 00085 MoveArmPickupServer::GoalHandle pickup_gh_; 00086 MoveArmPlaceServer::GoalHandle place_gh_; 00087 00088 // action clients 00089 GraspActionClientPtr grasp_action_client_ptr_; 00090 00091 // PickupGoalInfo pickup_goal_; 00092 // PlaceGoalInfo place_goal_; 00093 00094 }; 00095 00096 } 00097 #endif /* MOVEPICKPLACESERVER_H_ */