EigenGraspPlannerNoQt.h
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     // So far, only AxisAngle supported, as others not tested yet.
00072     // Later: enum SearchType {Complete, AxisAngle, Ellipsoid, Approach};
00073     // enum SearchType  {AxisAngle};
00074 
00075     // Type of planner ot use. So far, only simulated annealing supported, as
00076     // others are not tested.
00077     // TODO: implement other planner types as well.
00078     // Later this should be: enum PlannerType {SimAnn, Loop, MultiThreaded };
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     // void stopPlanner();
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     // void inputLoad(const std::string& inputGraspFile);
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     // thread that prints the status messages during planning process
00252     THREAD * statusThread;
00253 
00254 
00255     // for test purposes: to separately calculate energy of grasps
00256 
00257     EGPlanner * graspitEgPlanner;
00258     RECURSIVE_MUTEX graspitEgPlannerMtx;
00259 
00260     // The state type to use for GraspIt. Default is STATE_AXIS_ANGLE.
00261     StateType graspitStateType;
00262 
00263     // The search energy type to use. Is CONTACT_ENERGY by default.
00264     // Important: ENERGY_CONTACT_QUALITY doesn't work properly at the moment,
00265     // at least not with the Jaco hand, also not in the original simulator.... the energy
00266     // drops to -0. Reason to be found in SearchEnergy::potentialQualityEnergy, variable gq
00267     // gets 0. So far, only successfully tested method was CONTACT_ENERGY, though I didn't
00268     // test all others except ENERGY_CONTACT_QUALITY
00269     std::string graspitSearchEnergyType;
00270 
00271     // whether to use contacts information in the planner or not
00272     bool useContacts;
00273 
00274     std::vector<const GraspPlanningState*> results;
00275 };
00276 
00277 }  // namespace GraspIt
00278 #endif  //  GRASP_PLANNING_GRASPIT_EIGENGRASPPLANNERNOQT_H


grasp_planning_graspit
Author(s): Jennifer Buehler
autogenerated on Wed May 8 2019 02:53:36