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 // Authors: Steffen Knoop 00021 // Andrew T. Miller 00022 // 00023 // $Id: grasp_tester.h,v 1.5 2009/03/25 22:10:24 cmatei Exp $ 00024 // 00025 //###################################################################### 00026 00027 /***************************************************************************/ 00028 /* FILE: grasp_tester.h */ 00029 /* AUTHOR: Steffen Knoop */ 00030 /* DATE: 03-08-2002 */ 00031 /***************************************************************************/ 00032 00037 #ifndef GRASP_TESTER_H 00038 #define GRASP_TESTER_H 00039 00040 /* Minimum quality to accept grasp as stable. */ 00041 #define QUALITY_MIN_THRESHOLD 0.0 00042 00043 /* When a grasp is initially unstable, grasp_tester tries to 00044 step back from the object several times and determines the 00045 grasp quality there. This affects strongly the computing time. */ 00046 #define MAX_ITERATION_STEPS_PER_GRASP 20 00047 00048 /* Step size in mm when iterating backwards. */ 00049 #define BACK_ITERATION_STEP_SIZE 4.0 00050 00051 #define DEG_2_RAD M_PI/180.0 00052 00053 #include <QObject> 00054 #include <QFile> 00055 00056 #include <QTextStream> 00057 00058 #include <vector> 00059 00060 #include "matvec3D.h" 00061 #include "collisionStructures.h" 00062 #include "grasp_directions.h" 00063 #include "grasp_preshape.h" 00064 #include "grasp_grasps.h" 00065 00066 class SoQtExaminerViewer; 00067 class World; 00068 class Hand; 00069 class Grasp; 00070 class GraspableBody; 00071 class IVmgr; 00072 class QualityMeasure; 00073 class SoQtRenderArea; 00074 class SoGroup; 00075 class SoSensor; 00076 class SoSeparator; 00077 class Body; 00078 00079 00081 00115 class grasp_tester : public QObject 00116 { 00117 Q_OBJECT 00118 00119 private: 00120 00122 SoQtExaminerViewer *myViewer; 00123 00125 World *my_world; 00126 00128 Hand *my_hand; 00129 00131 GraspableBody *my_body; 00132 00134 Grasp *my_grasp; 00135 00137 IVmgr *ivmgr; 00138 00140 int whichQM; 00141 00143 bool saveToFile; 00144 00146 QFile graspFile; 00147 00149 QTextStream graspOut; 00150 00152 SoQtRenderArea *projectionViewer; 00153 00155 SoGroup *primitives; 00156 00158 CollisionReport colReport; 00159 00161 std::list<plannedGrasp*>* graspList; 00162 00164 bool render; 00165 00167 std::list<plannedGrasp*>::iterator it_gr; 00168 00170 transf origTran; 00171 00173 double *dofs; 00174 00176 SoSensor *idleSensor; 00177 00179 SoSeparator *glRoot; 00180 00182 int nrOfGrasps; 00183 00185 int actualGraspNr; 00186 00188 int maxItStepNr; 00189 00191 double backStepSize; 00192 00193 /* 00194 * methods 00195 */ 00196 bool putIt(plannedGrasp *pg, bool render_in=false); 00197 bool preshapeIt(preshape p, bool render_in=false); 00198 bool moveIt(cartesianGraspDirection gd, bool render_in=false); 00199 00200 // int moveTo(transf); 00201 bool checkContactToHand(GraspableBody* gb); 00202 void orderGraspListByQuality(std::list<plannedGrasp*>& grl); 00203 void saveGrasp(double quality); 00204 00205 void updateGlobals(); 00206 void savePosition(plannedGrasp& pg); 00207 bool handCollision(); 00208 00209 bool iteration(plannedGrasp& pg); 00210 static void testItCB(void *,SoSensor *sensor); 00211 void testIt(); 00212 00213 signals: 00215 void testingComplete(); 00216 00217 public: 00218 grasp_tester(); 00219 ~grasp_tester(); 00220 00221 void setupGraspVisWindow(GraspableBody* myBody,SoGroup *prim); 00222 void visualizePlannedGrasps(std::list<plannedGrasp*> grList); 00223 bool callTestIt(std::list<plannedGrasp*>& graspList_in, bool render_in); 00224 00225 bool set_testingParameters(int itStepNr, double stepSize); 00226 void get_testingParameters(int& itStepNr, double& stepSize); 00227 00229 void useQM(int qmNum) {whichQM = qmNum;} 00230 00231 void saveGraspsToFile(const QString& filename,bool append); 00232 void continueTests(); 00233 void pauseTests(); 00234 00235 // struct timeval get_computingTime(); 00236 }; 00237 00238 00239 #endif 00240 00241 /****************** 00242 Local Variables: 00243 mode:c++ 00244 End: 00245 ******************/ 00246 00247