grasp_generator.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2010, Willow Garage, Inc.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of the Willow Garage nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *********************************************************************/
00034 
00035 #ifndef GRASP_GENERATOR_H
00036 #define GRASP_GENERATOR_H
00037 
00038 #include <boost/shared_ptr.hpp>
00039 
00040 #include <ros/ros.h>
00041 
00042 #include <object_manipulation_msgs/GraspableObject.h>
00043 #include <object_manipulation_msgs/Grasp.h>
00044 #include <household_objects_database_msgs/DatabaseModelPose.h>
00045 #include <household_objects_database/objects_database.h>
00046 #include "household_objects_database/database_grasp.h"
00047 #include "household_objects_database/database_perturbation.h"
00048 #include "bayesian_grasp_planner/bayesian_grasp_planner_tools.h"
00049 
00050 namespace bayesian_grasp_planner {
00051 
00052 class GraspGenerator
00053 {
00054 protected:
00055   std::vector<GraspWM> grasps_;
00056  
00057 public:
00058   virtual void generateGrasps() = 0;
00059 
00060   const std::vector<GraspWM> & getGrasps() {return grasps_;}
00061 
00062   void getGrasps(std::vector<GraspWM> &grasps)
00063   {
00064     grasps.insert( grasps.end(), grasps_.begin(), grasps_.end());
00065   }
00066 
00067 };
00068 
00069 class GraspGeneratorServiceCaller : public GraspGenerator
00070 {
00071 private:
00072   ros::ServiceClient service_;
00073   const object_manipulation_msgs::GraspableObject object_;
00074   const std::string arm_name_;
00075   const std::string service_name_;
00076 
00077   void appendMetadataToGrasps(std::vector<object_manipulation_msgs::Grasp> &grasp_msgs,
00078                               std::vector<GraspWM> &grasps);
00079 
00080 public:
00081   GraspGeneratorServiceCaller(ros::NodeHandle &nh, const std::string service_name, 
00082                               const object_manipulation_msgs::GraspableObject &graspable_object,
00083                               const std::string arm_name);
00084 
00085   void generateGrasps();
00086 };
00087 
00088 class GraspGeneratorDatabaseRetriever : public GraspGenerator
00089 {
00090 private:
00091   boost::shared_ptr<household_objects_database::ObjectsDatabase> database_;
00092   household_objects_database_msgs::DatabaseModelPose model_;
00093   const std::string arm_name_;
00094 
00095   void appendMetadataToGrasps(const std::vector<household_objects_database::DatabaseGraspPtr> &db_grasps,
00096                        std::vector<GraspWM> &grasps);
00097 
00098   bool cluster_reps_;
00099 
00100 public:
00101   GraspGeneratorDatabaseRetriever(boost::shared_ptr<household_objects_database::ObjectsDatabase> database,
00102                                   household_objects_database_msgs::DatabaseModelPose model, const std::string arm_name,
00103                                   bool cluster_reps);
00104 
00105   void generateGrasps();
00106 };
00107 
00108 
00109 }
00110 
00111 
00112 #endif


bayesian_grasp_planner
Author(s): Kaijen Hsiao and Matei Ciocarlie
autogenerated on Thu Jan 2 2014 11:40:34