Go to the documentation of this file.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
00036
00037 #ifndef _GRASP_RETRIEVER_H_
00038 #define _GRASP_RETRIEVER_H_
00039
00040 #include <ros/ros.h>
00041
00042 #include <vector>
00043 #include <map>
00044 #include <tf/transform_broadcaster.h>
00045 #include <object_manipulation_msgs/GraspableObject.h>
00046
00047 #include <household_objects_database_msgs/DatabaseModelPose.h>
00048 #include <household_objects_database/database_grasp.h>
00049 #include <household_objects_database/database_perturbation.h>
00050 using household_objects_database::DatabasePerturbationPtr;
00051
00052 #include "probabilistic_grasp_planner/forward_decls.h"
00053
00054 #include "probabilistic_grasp_planner/probabilistic_planner_tools.h"
00055
00056 namespace probabilistic_grasp_planner {
00057
00058 class GraspRetriever
00059 {
00060 protected:
00061 std::string arm_name_;
00062 std::vector<GraspWithMetadata> grasps_;
00063 public:
00064
00065 virtual void getGrasps(std::vector<GraspWithMetadata> &grasps) = 0;
00066
00067 GraspRetriever(const std::string &arm_name) :
00068 arm_name_(arm_name)
00069 {
00070
00071 }
00072 };
00073 typedef boost::shared_ptr<GraspRetriever> GraspRetrieverPtr;
00074
00075 class DatabaseGraspRetriever : public GraspRetriever
00076 {
00077 private:
00079 std::map<int, std::vector<household_objects_database::DatabaseGraspPtr> > grasps_cache_;
00080
00081 protected:
00082 ObjectsDatabasePtr database_;
00083
00085 const household_objects_database_msgs::DatabaseModelPose &model_;
00086
00088 bool prune_compliant_copies_;
00089
00091 bool use_cluster_rep_grasps_;
00092
00098 void appendMetadataToGrasps(const std::vector<household_objects_database::DatabaseGraspPtr> &db_grasps,
00099 std::vector<GraspWithMetadata> &grasps);
00103 void pruneGraspList(std::vector<household_objects_database::DatabaseGraspPtr> &grasps, double gripper_threshold,
00104 double table_clearance_threshold);
00105
00106 public:
00110 DatabaseGraspRetriever(ObjectsDatabasePtr database,
00111 const household_objects_database_msgs::DatabaseModelPose &model,
00112 const std::string &arm_name,
00113 bool prune_compliant_copies,
00114 bool use_cluster_rep_grasps);
00115
00120 virtual void getGrasps(std::vector<GraspWithMetadata> &grasps);
00121
00122 virtual void fetchFromDB();
00123
00124 };
00125 typedef boost::shared_ptr<DatabaseGraspRetriever> DatabaseGraspRetrieverPtr;
00126
00127 class ClusterRepGraspRetriever : public DatabaseGraspRetriever
00128 {
00129 private:
00131 std::map<int, std::vector<household_objects_database::DatabaseGraspPtr> > grasps_cache_;
00132 protected:
00133
00134 public:
00135 ClusterRepGraspRetriever(ObjectsDatabasePtr database, const household_objects_database_msgs::DatabaseModelPose &model,
00136 const std::string &arm_name);
00141 virtual void getGrasps(std::vector<GraspWithMetadata> &grasps);
00142
00143 virtual void fetchFromDB();
00144 };
00145 typedef boost::shared_ptr<ClusterRepGraspRetriever> ClusterRepGraspRetrieverPtr;
00146
00147 class DebugClusterRepGraspRetriever : public ClusterRepGraspRetriever
00148 {
00149 public:
00150 DebugClusterRepGraspRetriever(ObjectsDatabasePtr database,
00151 const household_objects_database_msgs::DatabaseModelPose &model,
00152 const std::string &arm_name) :
00153 ClusterRepGraspRetriever(database, model, arm_name)
00154 {
00155
00156 }
00157
00162 virtual void getGrasps(std::vector<GraspWithMetadata> &grasps);
00163 };
00164
00168 class PerturbationGraspRetriever : public DatabaseGraspRetriever
00169 {
00170 private:
00171 const GraspWithMetadata *gstar_;
00172 protected:
00173 std::vector<DatabasePerturbationPtr> perturbations_;
00174 virtual void fetchFromDB();
00175 public:
00176 PerturbationGraspRetriever(ObjectsDatabasePtr database,
00177 const household_objects_database_msgs::DatabaseModelPose &model,
00178 const std::string &arm_name);
00179 void setGrasp(const GraspWithMetadata *gstar)
00180 {
00181 gstar_ = gstar;
00182 }
00183
00184 void getGrasps(std::vector<GraspWithMetadata> &grasps);
00185 };
00186
00187 class OnlinePerturbationGraspRetriever : GraspRetriever
00188 {
00189 private:
00190 const GraspWithMetadata *gstar_;
00191
00192 public:
00193 OnlinePerturbationGraspRetriever(const GraspWithMetadata *gstar, const std::string &arm_name) :
00194 GraspRetriever(arm_name), gstar_(gstar)
00195 {
00196
00197 }
00198
00199 void getGrasps(std::vector<GraspWithMetadata> &grasps);
00200 };
00201
00202 class ClusterPlannerGraspRetriever : public GraspRetriever
00203 {
00204 private:
00205 tf::TransformBroadcaster tf_broadcaster;
00206 ros::ServiceClient cluster_planner_srv_;
00207 std::vector<object_manipulation_msgs::Grasp> grasps_from_cluster_planner_;
00208 sensor_msgs::PointCloud cloud_;
00209 protected:
00210 void appendGraspsFromClusterPlanner(std::vector<GraspWithMetadata> &grasps);
00211 virtual void fetchFromPlanner(const object_manipulation_msgs::GraspableObject &graspable_object);
00212 public:
00213 ClusterPlannerGraspRetriever(ros::NodeHandle &nh, const std::string &cluster_planner_name,
00214 const object_manipulation_msgs::GraspableObject &graspable_object,
00215 const std::string &arm_name);
00216
00220 virtual void getGrasps(std::vector<GraspWithMetadata> &grasps);
00221 };
00222 }
00223
00224 #endif