00001 //###################################################################### 00002 // 00003 // GraspIt! 00004 // Copyright (C) 2002-2009 Columbia University in the City of New York. 00005 // All rights reserved. 00006 // 00007 // GraspIt! is free software: you can redistribute it and/or modify 00008 // it under the terms of the GNU General Public License as published by 00009 // the Free Software Foundation, either version 3 of the License, or 00010 // (at your option) any later version. 00011 // 00012 // GraspIt! is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with GraspIt!. If not, see <http://www.gnu.org/licenses/>. 00019 // 00020 // Author(s): Hao Dang and Matei T. Ciocarlie 00021 // 00022 // $Id: graspit_db_grasp.h,v 1.13 2010/01/13 23:03:37 cmatei Exp $ 00023 // 00024 //###################################################################### 00025 00030 #ifndef _GRASPIT_DB_GRASP_ENTRY_H_ 00031 #define _GRASPIT_DB_GRASP_ENTRY_H_ 00032 #include "DBPlanner/grasp.h" 00033 00034 #include <QString> 00035 #include <vector> 00036 #include <string> 00037 00038 #include "graspitGUI.h" 00039 #include "world.h" 00040 #include "ivmgr.h" 00041 00042 class GraspPlanningState; 00043 class Hand; 00044 class GraspitDBModel; 00045 00046 using std::string; 00049 class GraspitDBGrasp : public db_planner::Grasp{ 00051 GraspPlanningState *mPreGrasp, *mFinalGrasp; 00053 std::vector<double> mTestScores; 00055 Hand* mHand; 00056 00057 public: 00058 GraspitDBGrasp(const GraspitDBGrasp& grasp2); 00059 GraspitDBGrasp(Hand* h) : mHand(h), mPreGrasp(NULL), mFinalGrasp(NULL) {} 00060 ~GraspitDBGrasp(); 00062 GraspPlanningState* getPreGraspPlanningState() { return mPreGrasp; } 00064 GraspPlanningState* getFinalGraspPlanningState() { return mFinalGrasp; } 00066 const GraspPlanningState* getPreGraspPlanningState() const { return mPreGrasp; } 00068 const GraspPlanningState* getFinalGraspPlanningState() const { return mFinalGrasp; } 00069 00071 void addTestScore(double s) { mTestScores.push_back( s < 0 ? 0 : s); } 00073 double getTestScore(int i) { return mTestScores[i]; } 00075 int getNumTestScores() { return (int)mTestScores.size(); } 00077 double getTestAverageScore(); 00079 bool Transform(const float array[16]); 00081 void setPreGraspPlanningState(GraspPlanningState* p); 00083 00084 void setFinalGraspPlanningState(GraspPlanningState* p); 00088 virtual bool SetGraspParameters(const vector<double>& pregrasp_joints, 00089 const vector<double>& pregrasp_position, 00090 const vector<double>& grasp_joints, 00091 const vector<double>& grasp_position); 00093 const Hand *getHand() const {return mHand;} 00094 00096 static QString getHandDBName(Hand* h); 00098 static QString getHandGraspitPath(QString handDBName); 00099 }; 00100 00105 class GraspitDBGraspAllocator : public db_planner::GraspAllocator 00106 { 00107 private: 00109 Hand *mHand; 00110 public: 00111 GraspitDBGraspAllocator(Hand *h) : mHand(h) {} 00112 db_planner::Grasp* Get() const { 00113 return new GraspitDBGrasp(mHand); 00114 } 00115 }; 00116 00117 #endif