Go to the documentation of this file.00001 #ifndef GRASP_PLANNING_GRASPIT_EIGENGRASPPLANNERNOQT_H
00002 #define GRASP_PLANNING_GRASPIT_EIGENGRASPPLANNERNOQT_H
00003
00025 #include <grasp_planning_graspit/GraspItSceneManager.h>
00026 #include <grasp_planning_graspit/EigenGraspResult.h>
00027 #include <grasp_planning_graspit/GraspItAccessor.h>
00028
00029 #include <vector>
00030 #include <string>
00031
00032 #define DEFAULT_MAX_PLANNING_STEPS 70000
00033
00034 #include <EGPlanner/search.h>
00035
00036 class GraspPlanningState;
00037 class GraspableBody;
00038 class EGPlanner;
00039 class SearchEnergy;
00040 class GraspPlanningState;
00041 class GraspItAccessor;
00042
00043 namespace GraspIt
00044 {
00045
00068 class EigenGraspPlannerNoQt: public GraspItAccessor
00069 {
00070 public:
00071
00072
00073
00074
00075
00076
00077
00078
00079 enum PlannerType {SimAnn};
00080
00084 EigenGraspPlannerNoQt(const std::string& name, const SHARED_PTR<GraspItSceneManager>& i);
00085 virtual ~EigenGraspPlannerNoQt();
00086
00094 bool plan(const int maxPlanningSteps = DEFAULT_MAX_PLANNING_STEPS, const PlannerType& planType = SimAnn);
00095
00110 bool plan(const std::string& handName, const std::string& objectName,
00111 const EigenTransform * objectPose = NULL,
00112 const int maxPlanningSteps = DEFAULT_MAX_PLANNING_STEPS, const PlannerType& planType = SimAnn);
00113
00125 bool saveResultsAsWorldFiles(const std::string& inDirectory, const std::string& fileNamePrefix,
00126 bool asGraspIt = true, bool asInventor = false, bool createDir = true);
00127
00131 void getResults(std::vector<EigenGraspResult>& allGrasps) const;
00132
00133 protected:
00134 virtual void idleEventFromSceneManager();
00135
00136 virtual void onSceneManagerShutdown();
00137
00138 private:
00146 bool initPlanner(const int maxPlanningSteps, const PlannerType& planType = SimAnn);
00147
00151
00152
00153
00161 void initSearchType(GraspPlanningState& stateTemplate, const StateType& st);
00162
00167 void initPlannerType(const GraspPlanningState& stateTemplate, const PlannerType& pt);
00168
00169
00173 void updateResults();
00174
00179 void plannerUpdate();
00180
00181
00186 void plannerComplete();
00187
00188
00194 void setPlanningParameters();
00195
00199 void printPlanningResults();
00200
00204 void plannerReset();
00205
00211
00212
00217 void printResult(int i, bool detailed = false);
00218
00222 EigenTransform getHandTransform(const GraspPlanningState * s) const;
00226 EigenTransform getObjectTransform(const GraspPlanningState * s) const;
00227
00231 bool checkStateValidity(const GraspPlanningState * s) const;
00232
00236 void getGraspJointDOFs(const GraspPlanningState * s, std::vector<double>& dofs) const;
00237
00242 void getPregraspJointDOFs(const GraspPlanningState * s, std::vector<double>& dofs) const;
00243
00247 void getEigenGraspValues(const GraspPlanningState * s, std::vector<double>& egVals) const;
00248
00249 static void statusThreadLoop(EigenGraspPlannerNoQt * _this);
00250
00251
00252 THREAD * statusThread;
00253
00254
00255
00256
00257 EGPlanner * graspitEgPlanner;
00258 RECURSIVE_MUTEX graspitEgPlannerMtx;
00259
00260
00261 StateType graspitStateType;
00262
00263
00264
00265
00266
00267
00268
00269 std::string graspitSearchEnergyType;
00270
00271
00272 bool useContacts;
00273
00274 std::vector<const GraspPlanningState*> results;
00275 };
00276
00277 }
00278 #endif // GRASP_PLANNING_GRASPIT_EIGENGRASPPLANNERNOQT_H