00001 //###################################################################### 00002 // 00003 // GraspIt! 00004 // Copyright (C) 2002-2009 Columbia University in the City of New York. 00005 // All rights reserved. 00006 // 00007 // This software is protected under a Research and Educational Use 00008 // Only license, (found in the file LICENSE.txt), that you should have 00009 // received with this distribution. 00010 // 00011 // Author(s): Matei T. Ciocarlie 00012 // 00013 // $Id: eigenTorques.h,v 1.5 2009/09/12 00:14:17 cmatei Exp $ 00014 // 00015 //###################################################################### 00016 00017 #ifndef _eigentorques_h_ 00018 #define _eigentorques_h_ 00019 00020 #include <vector> 00021 00022 #include "matrix.h" 00023 00024 namespace db_planner{ 00025 class DatabaseManager; 00026 class Grasp; 00027 } 00028 class Hand; 00029 class McGrip; 00030 00034 class GraspProcessor { 00035 protected: 00037 Hand *mHand; 00038 public: 00039 GraspProcessor(Hand *h) : mHand(h) {} 00040 virtual ~GraspProcessor(){} 00041 00043 virtual void reset(){} 00045 virtual void processGrasp() = 0; 00047 virtual void finalize() = 0; 00048 }; 00049 00056 class CGDBGraspProcessor 00057 { 00058 private: 00060 Hand *mHand; 00062 GraspProcessor* mProcessor; 00064 int mMaxGrasps; 00066 int mProcessedGrasps; 00068 db_planner::DatabaseManager *mDbMgr; 00069 00071 void processGrasps(std::vector<db_planner::Grasp*> *grasps); 00072 public: 00074 CGDBGraspProcessor(Hand *h); 00076 ~CGDBGraspProcessor(){delete mProcessor;} 00078 void run(); 00080 void reset(){mProcessedGrasps = 0; mProcessor->reset();} 00081 }; 00082 00087 class EigenTorqueComputer : public GraspProcessor 00088 { 00089 private: 00090 int mNumOptimal, mNumUnfeasible, mNumErrors; 00092 std::vector<Matrix> mOptimalTorques; 00093 public: 00094 EigenTorqueComputer(Hand *h) : GraspProcessor(h){} 00096 virtual void reset(); 00098 virtual void processGrasp(); 00100 virtual void finalize(); 00101 }; 00102 00106 class McGripAnalyzer : public GraspProcessor 00107 { 00108 private: 00109 FILE *fp; 00110 public: 00111 McGripAnalyzer(Hand *h) : GraspProcessor(h) {} 00112 00113 virtual void reset(){ 00114 fp = fopen("McGripAnalysis.txt","w"); 00115 } 00117 virtual void processGrasp(); 00118 virtual void finalize(){ 00119 fclose(fp); 00120 } 00121 }; 00122 00133 class McGripOptimizer : public GraspProcessor 00134 { 00135 private: 00137 std::list<Matrix*> JTD_negI_list; 00139 std::list<Matrix*> NegB_list; 00141 std::list<Matrix*> Th_list; 00143 std::list<Matrix*> GO_list; 00145 std::list<Matrix*> FO_list; 00147 std::list<Matrix*> SO_list; 00149 std::list<Matrix*> lowerBounds_list; 00151 std::list<Matrix*> upperBounds_list; 00152 00154 void clearList(std::list<Matrix*> &list); 00156 void printList(const std::list<Matrix*> &list, FILE *fp); 00157 public: 00158 McGripOptimizer(Hand *h) : GraspProcessor(h) {} 00159 virtual ~McGripOptimizer(){reset();} 00160 00162 virtual void reset(); 00163 00165 virtual void processGrasp(); 00166 00168 virtual void finalize(); 00169 }; 00170 00171 #endif