00001 #ifndef GRASP_PLANNING_GRASPIT_ROS_GRASPITSERVICES_H 00002 #define GRASP_PLANNING_GRASPIT_ROS_GRASPITSERVICES_H 00003 00025 #include <ros/ros.h> 00026 #include <string> 00027 #include <vector> 00028 00029 #include <grasp_planning_graspit/SharedPtr.h> 00030 00031 #include <grasp_planning_graspit_msgs/LoadDatabaseModel.h> 00032 #include <grasp_planning_graspit_msgs/AddToDatabase.h> 00033 #include <grasp_planning_graspit_msgs/SaveWorld.h> 00034 00035 #include <moveit_msgs/GraspPlanning.h> 00036 00037 namespace GraspIt 00038 { 00039 00040 class GraspItSceneManager; 00041 class GraspItSimpleDBManager; 00042 class EigenGraspPlanner; 00043 class EigenGraspResult; 00044 00080 class GraspItServices 00081 { 00082 public: 00083 GraspItServices(); 00084 ~GraspItServices(); 00085 00089 void start(); 00090 00091 private: 00092 GraspItServices(const GraspItServices& o) {} 00093 00094 void init(); 00095 00096 // reads parameters from the parameter service 00097 void readParams(); 00098 00102 bool acceptAddToDB(grasp_planning_graspit_msgs::AddToDatabase::Request &req, 00103 grasp_planning_graspit_msgs::AddToDatabase::Response &res); 00104 00108 bool acceptLoadModel(grasp_planning_graspit_msgs::LoadDatabaseModel::Request &req, 00109 grasp_planning_graspit_msgs::LoadDatabaseModel::Response &res); 00110 00114 bool acceptSaveWorld(grasp_planning_graspit_msgs::SaveWorld::Request &req, 00115 grasp_planning_graspit_msgs::SaveWorld::Response &res); 00116 00120 bool acceptEGPlanning(moveit_msgs::GraspPlanning::Request &req, 00121 moveit_msgs::GraspPlanning::Response &res); 00122 00129 moveit_msgs::Grasp getGraspMsg(const EigenGraspResult& r, const std::string& id, 00130 const std::vector<std::string>& robotJointNames, 00131 const std::string& objectFrame) const; 00132 00133 00134 SHARED_PTR<GraspItSceneManager> graspitMgr; 00135 SHARED_PTR<GraspItSimpleDBManager> mgr; 00136 SHARED_PTR<GraspIt::EigenGraspPlanner> egPlanner; 00137 00138 // ---- service servers --- 00139 00140 ros::ServiceServer addGraspitFileSrv; 00141 ros::ServiceServer loadGraspitModelSrv; 00142 ros::ServiceServer saveWorldSrv; 00143 ros::ServiceServer egPlanningSrv; 00144 00145 // --- variables read from ROS parameter server (commented in class header) 00146 00147 std::string dbName; 00148 std::string egPlannerName; 00149 std::string addToDBTopic; 00150 std::string loadModelTopic; 00151 std::string saveWorldTopic; 00152 std::string egPlanningTopic; 00153 int defaultMaxPlanningSteps; 00154 int defaultNumRepeatPlanning; 00155 int defaultNumKeepResults; 00156 bool defaultFinishWithAutograsp; 00157 float graspMsgPositionFactor; 00158 std::string resultsOutputDirectory; 00159 bool saveResultFilesInventor; 00160 bool saveResultFilesGraspit; 00161 00162 00163 // if true, the joint DOF values will be generated. This may be necessary 00164 // because graspit generates results with opposite values 00165 bool negateJointDOFs; 00166 00167 00168 ros::NodeHandle priv; 00169 ros::NodeHandle pub; 00170 }; 00171 00172 } // namespace GraspIt 00173 00174 #endif // GRASP_PLANNING_GRASPIT_ROS_GRASPITSERVICES_H