00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef _ROS_GRASPIT_INTERFACE_H_
00036 #define _ROS_GRASPIT_INTERFACE_H_
00037
00038 #include <map>
00039
00040
00041 #include <include/plugin.h>
00042 namespace db_planner
00043 {
00044 class DatabaseManager;
00045 }
00046 class GraspitDBModel;
00047 class Pr2Gripper2010;
00048 class Body;
00049 class transf;
00050 class GraspableBody;
00051
00052 #include <ros/ros.h>
00053
00054 #include <object_manipulation_msgs/Grasp.h>
00055 #include <object_manipulation_msgs/GraspPlanning.h>
00056
00057 #include "graspit_interface_msgs/LoadDatabaseModel.h"
00058 #include "graspit_interface_msgs/LoadObstacle.h"
00059 #include "graspit_interface_msgs/ClearBodies.h"
00060 #include "graspit_interface_msgs/SimulateScan.h"
00061 #include "graspit_interface_msgs/TestGrasp.h"
00062 #include "graspit_interface_msgs/GenerateGrasp.h"
00063 #include "graspit_interface_msgs/VerifyGrasp.h"
00064
00065 namespace graspit_interface
00066 {
00067
00068 class RosGraspitInterface : public Plugin
00069 {
00070 private:
00072 ros::NodeHandle *root_nh_;
00073
00075 ros::NodeHandle *priv_nh_;
00076
00078
00080 db_planner::DatabaseManager *db_mgr_;
00081
00083 ros::ServiceServer load_model_srv_;
00084
00086 ros::ServiceServer load_obstacle_srv_;
00087
00089 ros::ServiceServer clear_bodies_srv_;
00090
00092 ros::ServiceServer simulate_scan_srv_;
00093
00095 ros::ServiceServer test_grasp_srv_;
00096
00098 ros::ServiceServer grasp_planning_srv_;
00099
00101 ros::ServiceServer generate_grasp_srv_;
00102
00104 ros::ServiceServer verify_grasp_srv_;
00105
00106
00107
00109 ros::Publisher scan_publisher_;
00110
00112 std::map<int, GraspitDBModel*> models_;
00113
00115 Pr2Gripper2010 *gripper_;
00116
00118 int default_grasp_test_type_;
00119
00121 double default_energy_threshold_;
00122
00124
00126 GraspitDBModel* getModel(int model_id);
00127
00129 bool loadGripper();
00130
00131
00132
00134 void gripperCollisionCheck(const Body *object, graspit_interface_msgs::TestGrasp::Response &response);
00135
00137 void computeEnergy(Body *object, graspit_interface_msgs::TestGrasp::Response &response);
00138
00139
00140
00142 void testGraspDirect(const object_manipulation_msgs::Grasp &grasp, GraspableBody *object,
00143 graspit_interface_msgs::TestGrasp::Response &response);
00144
00146 void testGraspCompliant(const object_manipulation_msgs::Grasp &grasp, GraspableBody *object,
00147 graspit_interface_msgs::TestGrasp::Response &response);
00148
00150 void testGraspReactive(const object_manipulation_msgs::Grasp &grasp, GraspableBody *object,
00151 graspit_interface_msgs::TestGrasp::Response &response);
00152
00154 void testGraspRobustReactive(const object_manipulation_msgs::Grasp &grasp, GraspableBody *object,
00155 graspit_interface_msgs::TestGrasp::Response &response);
00156
00157
00158
00160 bool loadModelCB(graspit_interface_msgs::LoadDatabaseModel::Request &request,
00161 graspit_interface_msgs::LoadDatabaseModel::Response &response);
00162
00164 bool loadObstacleCB(graspit_interface_msgs::LoadObstacle::Request &request,
00165 graspit_interface_msgs::LoadObstacle::Response &response);
00166
00168 bool clearBodiesCB(graspit_interface_msgs::ClearBodies::Request &request,
00169 graspit_interface_msgs::ClearBodies::Response &response);
00170
00172 bool simulateScanCB(graspit_interface_msgs::SimulateScan::Request &request,
00173 graspit_interface_msgs::SimulateScan::Response &response);
00174
00176 bool testGraspCB(graspit_interface_msgs::TestGrasp::Request &request,
00177 graspit_interface_msgs::TestGrasp::Response &response);
00178
00180 bool graspPlanningCB(object_manipulation_msgs::GraspPlanning::Request &request,
00181 object_manipulation_msgs::GraspPlanning::Response &response);
00182
00184 bool generateGraspCB(graspit_interface_msgs::GenerateGrasp::Request &request,
00185 graspit_interface_msgs::GenerateGrasp::Response &response);
00186
00188 bool verifyGraspCB(graspit_interface_msgs::VerifyGrasp::Request &request,
00189 graspit_interface_msgs::VerifyGrasp::Response &response);
00190
00191
00192 public:
00194 RosGraspitInterface();
00196 ~RosGraspitInterface();
00198 virtual int init(int argc, char **argv);
00200 virtual int mainLoop();
00201 };
00202
00203 }
00204
00205 #endif