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 #ifndef BAYESIAN_GRASP_PLANNER_H
00036 #define BAYESIAN_GRASP_PLANNER_H
00037 
00038 #include <boost/shared_ptr.hpp>
00039 #include <object_manipulator/tools/grasp_marker_publisher.h>
00040 #include <object_manipulation_msgs/GraspableObject.h>
00041 #include <object_manipulation_msgs/Grasp.h>
00042 #include "bayesian_grasp_planner/bayesian_grasp_planner_tools.h"
00043 #include <household_objects_database/objects_database.h>
00044 
00045 namespace bayesian_grasp_planner
00046 {
00047 
00048   
00049 class ObjectDetector;
00050 class GraspEvaluatorProb;
00051 
00052 class BayesianGraspPlanner
00053 {
00054 private:
00055 
00056   ros::NodeHandle nh_;
00057 
00058   household_objects_database::ObjectsDatabasePtr database_;
00059 
00061   object_manipulator::GraspMarkerPublisher debug_preprune_grasp_marker_publisher_;
00062 
00064   object_manipulator::GraspMarkerPublisher debug_postprune_grasp_marker_publisher_;
00065 
00067   object_manipulator::GraspMarkerPublisher grasp_marker_publisher_;
00068 
00073   void visualizeGrasps(const std::vector<GraspWM> &grasps, 
00074                         object_manipulator::GraspMarkerPublisher *grasp_marker_pub, bool color_by_rank);
00075 
00076 
00077   void createMutuallyExclusiveObjectRepresentations(const object_manipulation_msgs::GraspableObject &original_object,
00078                                                   std::vector<object_manipulation_msgs::GraspableObject> &me_objects );
00079 
00080   void createDatabaseObjectDetectors(const std::vector<object_manipulation_msgs::GraspableObject> &objects,
00081                                      std::vector< boost::shared_ptr<ObjectDetector> >&detectors);
00082 
00083   void appendMetadataToTestGrasps(std::vector<object_manipulation_msgs::Grasp> &input_list,
00084                                                                   std::vector<GraspWM> &output_list,
00085                                                                   const std::string frame_id);
00086 
00087   void clusterGrasps(std::vector<GraspWM> &input_list, 
00088                                          std::vector<GraspWM> &cluster_rep_list);
00089 
00090   void pruneGraspList(std::vector<GraspWM> &grasps, const double threshold);
00091 
00092 public:
00093   BayesianGraspPlanner(household_objects_database::ObjectsDatabasePtr database) : 
00094     nh_("~"),database_(database),
00095         debug_preprune_grasp_marker_publisher_("debug_preprune_grasp_list","",5.0),
00096         debug_postprune_grasp_marker_publisher_("debug_postprune_grasp_list","",5.0),
00097         grasp_marker_publisher_("grasp_marker_publisher","",5.0)
00098         {} 
00099 
00100   void bayesianInference(std::vector<GraspWM> &grasps,
00101                          const std::vector<object_manipulation_msgs::GraspableObject> &objects,
00102                          const std::vector< boost::shared_ptr<ObjectDetector> > &object_detectors,
00103                          const std::vector< boost::shared_ptr<GraspEvaluatorProb> > &prob_evaluators);
00104 
00105   void plan(const std::string &arm_name,
00106             const object_manipulation_msgs::GraspableObject &graspable_object,
00107             std::vector<object_manipulation_msgs::Grasp> &final_grasp_list);
00108 
00109 };
00110 typedef boost::shared_ptr<BayesianGraspPlanner> BayesianGraspPlannerPtr;
00111 
00112 } 
00113 
00114 #endif