libmove3d  3.13.0
/home/slemaign/softs-local/BioMove3D-git/lightPlanner/proto/ManipulationPlanner.hpp
00001 #ifndef __MANIPULATIONPLANNER_HPP__
00002 #define __MANIPULATIONPLANNER_HPP__
00003 
00004 #if defined (LIGHT_PLANNER) && defined (GRASP_PLANNING)
00005 
00006 #include "P3d-pkg.h"
00007 #include "Localpath-pkg.h"
00008 
00009 #include "ManipulationStruct.h"
00010 #include "ManipulationUtils.hpp"
00011 #include "ManipulationConfigs.hpp"
00012 
00013 #include <map>
00014 
00016 class  ManipulationPlanner {
00017   public:
00018   /* ******************************* */
00019   /* ******* (Con)Destructor ******* */
00020   /* ******************************* */
00021     ManipulationPlanner(p3d_rob * robot);
00022     virtual ~ManipulationPlanner();
00023 
00024   /* ******************************* */
00025   /* *********** Cleaning ********** */
00026   /* ******************************* */
00028     void clear();
00030     int cleanRoadmap();
00032     int cleanTraj();
00033 
00034   /* ******************************* */
00035   /* ******* (Ge)Setters *********** */
00036   /* ******************************* */
00037     void setDebugMode(bool value);
00038 #ifdef MULTILOCALPATH
00039     void setDebugSoftMotionMode(bool value);
00040     
00042   int getBaseMLP() { return _BaseMLP; } 
00044   int getHeadMLP() { return _HeadMLP; }
00046   int getUpBodyMLP() { return _UpBodyMLP; }
00048   int getUpBodysmMLP() { return _UpBodySmMLP; }
00049 #endif
00050   
00051   // Set and reset the planning and smoothing
00052   // Functions used by the Manipulation planner
00053   void setPlanningMethod(p3d_traj* (*funct)(p3d_rob* robot, configPt qs, configPt qg));
00054   void resetPlanningMethod();
00055   void setSmoothingMethod(void (*funct)(p3d_rob* robot, p3d_traj* traj, int nbSteps, double maxTime));
00056   void resetSmoothingMethod();
00057   void setReplanningMethod(p3d_traj* (*funct)(p3d_rob* robotPt, p3d_traj* traj, p3d_vector3 target, int deformationViaPoint));
00058   //void resetReplanningMethod();
00059   
00060     void setPlanningTime(double time);
00061     double getPlanningTime(void) const;
00062   
00063     void setOptimizeSteps(int nbSteps);
00064     int getOptimizeSteps(void) const;
00065 
00066     void setOptimizeTime(double time);
00067     double getOptimizeTime(void) const;
00068 
00069     void setSafetyDistanceValue(double value);
00070     double getSafetyDistanceValue(void) const;
00071   
00072     void setPlacementTry(int nbTry);
00073     int getPlacementTry(void);
00074     
00075     void setRobotPath(p3d_traj* path) { _robotPath = _robot->tcur; } 
00076   
00077     inline p3d_rob* robot()  const{return _robot;}
00078 
00079     inline configPt robotStart() const{if (_robot != NULL) {return _robot->ROBOT_POS;} else {return NULL;}}
00080     inline configPt robotGoto() const{if (_robot != NULL) {return _robot->ROBOT_GOTO;} else {return NULL;}}
00081         
00082 
00083     inline ManipulationData& getManipulationData() {return _configs;}
00084     inline ManipulationConfigs getManipulationConfigs()  const {return _manipConf;}
00085         /* ******************************* */
00086   /* ******* Hands / Grasping ****** */
00087   /* ******************************* */
00089     MANIPULATION_TASK_MESSAGE computeManipulationData(int armId,p3d_rob* object, gpGrasp& grasp);
00090     MANIPULATION_TASK_MESSAGE findArmGraspsConfigs(int armId, p3d_rob* object, gpGrasp& grasp, ManipulationData& configs);
00091     MANIPULATION_TASK_MESSAGE getGraspOpenApproachExtractConfs(p3d_rob* object, int armId, gpGrasp& grasp, p3d_matrix4 tAtt, ManipulationData& configs) const;
00092     MANIPULATION_TASK_MESSAGE getHoldingOpenApproachExtractConfs(p3d_rob* object, std::vector<double> &objGoto, p3d_rob* placement, int armId, gpGrasp& grasp, p3d_matrix4 tAtt,  ManipulationData& configs) const;
00093         /* ******************************* */
00094   /* ******* Planning Modes ******** */
00095   /* ******************************* */
00097     void checkConfigForCartesianMode(configPt q, p3d_rob* object);
00099     void setArmCartesian(int armId, bool cartesian);
00101     bool getArmCartesian(int armId) const;
00102 
00103 
00104   /* ******************************* */
00105   /* ******* Motion Planning ******* */
00106   /* ******************************* */
00108     MANIPULATION_TASK_MESSAGE cutTrajInSmall ( p3d_traj* inputTraj, p3d_traj* outputTraj );
00110     MANIPULATION_TASK_MESSAGE concatTrajectories (std::vector<p3d_traj*>& trajs, p3d_traj** concatTraj);
00112     void fitConfigurationToRobotBounds(configPt q);
00114     MANIPULATION_TASK_MESSAGE computeRRT(int smoothingSteps, double smootingTime, bool biDir);
00116     /* TODO Add CXX PLanner computation*/
00117     MANIPULATION_TASK_MESSAGE armComputePRM(double ComputeTime);
00119     p3d_traj* computeTrajBetweenTwoConfigs(configPt qi, configPt qf, MANIPULATION_TASK_MESSAGE* status);
00120 #ifdef MULTILOCALPATH
00121 
00122     int computeSoftMotion(p3d_traj* traj, MANPIPULATION_TRAJECTORY_CONF_STR &confs, SM_TRAJ &smTraj);
00123 #endif
00124 
00125     MANIPULATION_TASK_MESSAGE armToFreePoint(int armId, configPt qStart, std::vector<double> &objGoto, p3d_rob* object, std::vector <p3d_traj*> &trajs);
00126     MANIPULATION_TASK_MESSAGE armExtract(int armId, configPt qStart, p3d_rob* object, std::vector <p3d_traj*> &trajs);
00127     MANIPULATION_TASK_MESSAGE armToFree(int armId, configPt qStart, configPt qGoal, bool useSafetyDistance, p3d_rob* object, std::vector <p3d_traj*> &trajs);
00128     
00130     MANIPULATION_TASK_MESSAGE armPickGoto(int armId, configPt qStart, p3d_rob* object, gpGrasp& grasp, std::vector <p3d_traj*> &trajs);
00131     MANIPULATION_TASK_MESSAGE armPickGoto(int armId, configPt qStart, p3d_rob* object, configPt graspConfig, configPt openConfig, configPt approachFreeConfig, std::vector <p3d_traj*> &trajs);
00132 
00134     MANIPULATION_TASK_MESSAGE armPickTakeToFreePoint(int armId, configPt qStart, std::vector<double> &objGoto, p3d_rob* object, p3d_rob* support, std::vector <p3d_traj*> &trajs);
00135     MANIPULATION_TASK_MESSAGE armPickTakeToFree(int armId, configPt qStart, configPt qGoal, p3d_rob* object, p3d_rob* support, std::vector <p3d_traj*> &trajs);
00136     MANIPULATION_TASK_MESSAGE armPickTakeToFree(int armId, configPt qStart, configPt qGoal, p3d_rob* object, p3d_rob* support, configPt approachGraspConfig, gpGrasp &grasp, std::vector <p3d_traj*> &trajs);
00137 
00139     MANIPULATION_TASK_MESSAGE armTakeToPlace(int armId, configPt qStart, p3d_rob* object, p3d_rob* support, p3d_rob* placement, std::vector <p3d_traj*> &trajs);
00140     MANIPULATION_TASK_MESSAGE armTakeToPlace(int armId, configPt qStart, p3d_rob* object, p3d_rob* support, std::vector<double> &objGoto, p3d_rob* placement, std::vector <p3d_traj*> &trajs);
00141     MANIPULATION_TASK_MESSAGE armTakeToPlace(int armId, configPt qStart, configPt approachGraspConfig, configPt approachGraspConfigPlacement, configPt qGoal, p3d_rob* object,  p3d_rob* support, p3d_rob* placement, std::vector <p3d_traj*> &trajs);
00142 
00144     MANIPULATION_TASK_MESSAGE armPlaceFromFree(int armId, configPt qStart, p3d_rob* object, p3d_rob* placement, std::vector <p3d_traj*> &trajs);
00145     MANIPULATION_TASK_MESSAGE armPlaceFromFree(int armId, configPt qStart, p3d_rob* object, std::vector<double> &objGoto, p3d_rob* placement, std::vector <p3d_traj*> &trajs);
00146     MANIPULATION_TASK_MESSAGE armPlaceFromFree(int armId, configPt qStart, p3d_rob* object, p3d_rob* placement, configPt approachGraspConfig, configPt depositConfig, std::vector <p3d_traj*> &trajs);
00147 
00149     MANIPULATION_TASK_MESSAGE armEscapeObject(int armId, configPt qStart, p3d_rob* object, std::vector <p3d_traj*> &trajs);
00150     MANIPULATION_TASK_MESSAGE armEscapeObject(int armId, configPt qStart, configPt openGraspConfig, configPt approachFreeConfig, p3d_rob* object, std::vector <p3d_traj*> &trajs);
00151   /* ******************************* */
00152   /* ******** Task Planning ******** */
00153   /* ******************************* */
00155     MANIPULATION_TASK_MESSAGE armReplan(p3d_vector3 target, int qSwitchId, SM_TRAJ &smTrajs);
00156   
00158     MANIPULATION_TASK_MESSAGE armPlanTask(MANIPULATION_TASK_TYPE_STR task, int armId, configPt qStart, configPt qGoal, std::vector<double> &objStart, std::vector<double> &objGoto, const char* objectName,  const char* supportName, const char* placementName, gpGrasp& grasp, std::vector <p3d_traj*> &trajs);
00159     
00160     MANIPULATION_TASK_MESSAGE armPlanTask(MANIPULATION_TASK_TYPE_STR task, int armId, configPt qStart, configPt qGoal, std::vector<double> &objStart, std::vector<double> &objGoto, const char* objectName,  const char* supportName, const char* placementName, std::vector <p3d_traj*> &trajs);
00161 
00162 #ifdef MULTILOCALPATH
00163 
00164     MANIPULATION_TASK_MESSAGE armPlanTask(MANIPULATION_TASK_TYPE_STR task, int armId, configPt qStart, configPt qGoal, std::vector<double> &objStart, std::vector<double> &objGoto, const char* objectName,  const char* supportName, const char* placementName, gpGrasp& grasp, std::vector <MANPIPULATION_TRAJECTORY_CONF_STR> &confs, std::vector <SM_TRAJ> &smTrajs);
00165     MANIPULATION_TASK_MESSAGE armPlanTask(MANIPULATION_TASK_TYPE_STR task, int armId, configPt qStart, configPt qGoal, std::vector<double> &objStart, std::vector<double> &objGoto, const char* objectName, const char* supportName, const char* placementName, std::vector <MANPIPULATION_TRAJECTORY_CONF_STR> &confs, std::vector <SM_TRAJ> &smTrajs);
00166 #endif
00167         
00168   private:
00169         
00171   p3d_rob * _robot;
00172     
00173   /* ******************************* */
00174   /* ******* Motion Planning ******* */
00175   /* ******************************* */
00176 #ifdef MULTILOCALPATH
00177 
00178     int _BaseMLP;
00180     int _HeadMLP;
00182     int _UpBodyMLP;
00184     int _UpBodySmMLP;
00185 #endif
00186 
00187     double _planningTime;
00189     int _optimizeSteps;
00191     double _optimizeTime;
00193     double _safetyDistanceValue;
00194     
00196     int _placementTry;
00197         
00198   /* ******************************* */
00199   /* *******  Manipulation Data **** */
00200   /* ******************************* */
00201         ManipulationData _configs;
00202   ManipulationConfigs _manipConf;
00203         
00204   /* ******************************* */
00205   /* ** Motion Planning funtions *** */
00206   /* ******************************* */
00207   
00209   p3d_traj* _robotPath;
00210   
00212   p3d_traj* (*_plannerMethod)(p3d_rob* robot, configPt qs, configPt qg);
00213   void (*_smoothingMethod)(p3d_rob* robot, p3d_traj* traj, int nbSteps, double maxTime);
00214   
00216   p3d_traj* (*_replanningMethod)(p3d_rob* robotPt, p3d_traj* traj, p3d_vector3 target, int deformationViaPoint);
00217   
00218 };
00219 
00220 #endif
00221 
00222 #endif 
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines