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
00031 #ifndef DB_PLANNER_GRASP_H
00032 #define DB_PLANNER_GRASP_H
00033
00034 #include <string>
00035 #include <vector>
00036 #include "model.h"
00037 using std::string;
00038 using std::vector;
00039
00040 namespace db_planner {
00041
00042 class Grasp {
00043 private:
00045 const Model* source_model_;
00047 int grasp_id_;
00049 string source_;
00051 string hand_name_;
00053 double epsilon_quality_, volume_quality_;
00055 double energy_;
00057 double pregrasp_clearance_;
00059 bool cluster_rep_;
00061 double table_clearance_;
00063 vector<double> pregrasp_joints_, final_grasp_joints_, pregrasp_position_, final_grasp_position_, contacts_;
00065 bool compliant_copy_;
00067 int compliant_original_id_;
00068
00069 public:
00070 virtual ~Grasp(){}
00071 void SetSourceModel(const Model& source_model) {
00072 source_model_ = &source_model;
00073 }
00074 void SetHandName(const string& hand_name) { hand_name_ = hand_name; }
00075 void SetPregraspJoints(const vector<double>& pregraspJoints) { pregrasp_joints_ = pregraspJoints; }
00076 void SetPregraspPosition(const vector<double>& pregraspPosition) { pregrasp_position_ = pregraspPosition; }
00077 void SetFinalgraspJoints(const vector<double>& finalgraspJoints) { final_grasp_joints_ = finalgraspJoints; }
00078 void SetFinalgraspPosition(const vector<double>& finalgraspPosition) { final_grasp_position_ = finalgraspPosition; }
00079 void SetContacts(const vector<double>& contacts) { contacts_ = contacts; }
00080
00081 vector<double> GetPregraspJoints() const { return pregrasp_joints_; }
00082 vector<double> GetPregraspPosition() const { return pregrasp_position_; }
00083 vector<double> GetFinalgraspJoints() const { return final_grasp_joints_; }
00084 vector<double> GetFinalgraspPosition() const { return final_grasp_position_; }
00085 vector<double> GetContacts() const { return contacts_; }
00086
00087 void SetEpsilonQuality(const double epsilon_quality) {
00088 epsilon_quality_ = epsilon_quality;
00089 }
00090 void SetVolumeQuality(const double volume_quality) {
00091 volume_quality_ = volume_quality;
00092 }
00093 void SetEnergy(const double energy) {
00094 energy_ = energy;
00095 }
00096 void SetGraspId(const int grasp_id) { grasp_id_ = grasp_id; }
00097 void SetSource(string source){source_ = source;}
00098 string GetSource() const {return source_;}
00099 const Model& SourceModel() const { return *source_model_; }
00100 const string& HandName() const { return hand_name_; }
00101 double EpsilonQuality() const { return epsilon_quality_; }
00102 double VolumeQuality() const { return volume_quality_; }
00103 double Energy() const {return energy_;}
00104 int GraspId() const { return grasp_id_; }
00105 double Clearance() const {return pregrasp_clearance_;}
00106 void SetClearance(double clearance) {pregrasp_clearance_=clearance;}
00107 double TableClearance() const {return table_clearance_;}
00108 void SetTableClearance(double clearance) {table_clearance_ = clearance;}
00109 bool ClusterRep() const {return cluster_rep_;}
00110 void SetClusterRep(bool c) {cluster_rep_ = c;}
00111 bool CompliantCopy() const {return compliant_copy_;}
00112 void SetCompliantCopy(bool c) {compliant_copy_ = c;}
00113 int CompliantOriginalId() const {return compliant_original_id_;}
00114 void SetCompliantOriginalId(int id) {compliant_original_id_ = id;}
00115
00117
00119 virtual bool Transform(const float [16]) { return false; }
00120 virtual bool SetGraspParameters(const vector<double>& ,
00121 const vector<double>& ,
00122 const vector<double>& ,
00123 const vector<double>& ) {
00124 return false;
00125 }
00126
00127 static bool CompareEnergy(const Grasp* g1, const Grasp *g2) {
00128 return g1->energy_ < g2->energy_;
00129 }
00130 static bool CompareEpsilon(const Grasp* g1, const Grasp *g2) {
00131 return g1->epsilon_quality_ < g2->epsilon_quality_;
00132 }
00133 static bool CompareVolume(const Grasp* g1, const Grasp *g2) {
00134 return g1->volume_quality_ < g2->volume_quality_;
00135 }
00136 };
00137
00139 class GraspAllocator {
00140 public:
00141 virtual Grasp* Get() const = 0;
00142 };
00143
00144 }
00145
00146
00147 #endif // DB_PLANNER_GRASP_H