planners/atace/PL_ATACE.h

Go to the documentation of this file.
00001 
00002 //
00003 //Contents: Class PL_ATACE, (used to be call PL_JPRM and PL_APACE)
00004 // 
00006 
00007 #ifndef _PL_ATACE_HEADER_
00008 #define _PL_ATACE_HEADER_
00009 
00010 //Return value for different result
00011 #define ERR_FAIL            0xff
00012 #define ERR_SUCCESS         0x00
00013 #define ERR_TIMEOUT         0x10
00014 #define ERR_ILLPARAMETER    0x20
00015 
00016 //Flag for node in the random tree
00017 #define FLAG_NEW            0x01 //Normal node
00018 #define FLAG_OBSOLETE       0x02 //Node which has been deleted
00019 
00020 //Flags for task defintion
00021 #define TYPE_START_CONF     0x01
00022 #define TYPE_START_POSE     0x02
00023 #define TYPE_GOAL_CONF      0x04
00024 #define TYPE_GOAL_POSE      0x08
00025 
00026 //Metrics for random tree extension
00027 #define FLAG_C_METRICS      0x10 //C-space metrics
00028 #define FLAG_P_METRICS      0x01 //Phy-space metrics
00029 #define FLAG_B_METRICS      (FLAG_C_METRICS|FLAG_P_METRICS) //Combined
00030 
00031 //Different Local planners
00032 #define LOCAL_JACOBIAN          0  //Deterministic Jacobian-based local planner
00033 #define LOCAL_RRT                       1  //Probabilistic local planner
00034 
00035 #pragma warning( disable : 4250 )
00036 
00037 #include "kinematics/Configuration.h"
00038 #include "geometry/Frame.h"
00039 #include "Planners/PL_Boolean_Output.h"
00040 #include "Planners/PL_OpenGL.h"
00041 //#include "CollisionDetectors\CD_BasicStyle.h"
00042 #include "planners/inversekin/IK_InvKinBase.h"
00043 #include "robots/R_OpenChain.h"
00044 #include <LEDA/dynamic_trees.h>
00045 //#include "LocalPlanner.h"
00046 #include "kinematics/Pose.h"
00047 
00048 #undef array
00049 #undef vector
00050 #undef map
00051 #undef string
00052 #undef set
00053 
00054 class TrajPlanner;
00055 
00056 typedef PA_Points Path;
00057 typedef vertex Vertex;
00058 typedef std::vector<Frame> EEPath;
00059 //typedef Frame Pose;
00060 
00061 //Data structure for a landmark before it is put into the tree
00062 typedef struct
00063 {
00064         //int flag;
00065         Pose pose;
00066         Configuration conf;
00067 }
00068 Node;
00069 
00070 //Data structure for the landmark that is in the tree
00071 typedef struct
00072 {
00073         int flag;
00074         bool collisionChecked;
00075         Pose pose;
00076         Configuration conf;
00077         Pose dirPose;
00078         Configuration dirConf;
00079         Path edge;
00080         EEPath eeEdge;
00081 }
00082 VertexInfo;
00083 
00084 //All callback functions for constraints
00085 typedef bool (*ProcIsStaified)(Frame &pose);
00086 typedef void (*ProcAdjustToSatisfy)(Frame &pose);
00087 typedef void (*ProcGetVelocity)(Frame &pose, VectorN &vel);
00088 typedef void (*ProcGetDirectedVelocity)(Frame &pose, Frame &dir, VectorN &vel, Frame &projection, bool greedy, double timeInterval);
00089 
00090 class PL_ATACE: public IK_InvKinBase //public PL_Boolean_Output, public PL_OpenGL
00091 {
00092 public:
00093         PL_ATACE();
00094         virtual ~PL_ATACE();
00095 
00096         //Inherited form ancestor
00097         virtual void SetCollisionDetector (CD_BasicStyle* collisionDetector);
00098         virtual bool DrawExplicit () const;
00099         virtual bool Plan ();
00100         Frame GetToolFrame( const Configuration& config ) const;
00101 
00102         //Member functions for task-definition
00103         virtual void SetStartConfig( const Configuration& config );
00104         virtual void SetGoalConfig ( const Configuration& config );
00105         void SetStartPose(const Pose &start);
00106         void SetGoalPose(const Pose &goal);
00107         void SetProblemType(unsigned int type);
00108         bool IsReady();       //To check whether a task is properly set.
00109 
00110         //Parameter functions
00111         //Sampling time interval when explore for end-effector path in the task space
00112         void SetTimeInterval(double interval){m_timeInterval = interval;}
00113         double GetTimeInterval(){return m_timeInterval;}
00114         
00115         //Set step size, the distance between two landmarks, in the task space.
00116         void SetStepSize(double step){m_stepSize = step;}
00117         double GetStepSize(){return m_stepSize;}
00118         
00119         //Set the metrics for random tree extension, possible choice listed in macro definition.
00120         void SetMetrics(int metrics){m_metrics = metrics;}
00121         int GetMetrics(){return m_metrics;}
00122         
00123         //Set what projection of the random tree to be renderred. C-space or phy-space
00124         void SetDrawSpace(bool drawCSpace){m_drawCSpace = drawCSpace;}
00125         bool GetDrawSpace(){return m_drawCSpace;}
00126         
00127         //Set orientation option.
00128         void SetOrientation(bool considered, bool always){m_useOrientation = considered; m_useOrientationAlways = always;}
00129         bool GetOrientation(){return m_useOrientation;}
00130 
00131         //Set Lazy option. Whether or not use Lazy strategy.
00132         void SetLazy(bool use){m_useLazy = use;}
00133         bool GetLazy(){return m_useLazy;}
00134 
00135         //Set which local planner is used
00136         void SetLocalPlanner(int localPlanner);
00137         int GetLocalPlanner(){return m_nLocalPlanner;}
00138 
00139 protected:
00140         R_OpenChain *m_robot;        //Access to the planner in CollisionDetector.
00141         int  m_toolFrame;            //Frame ID of the toolframe in the given robot
00142         TrajPlanner *m_localPlanner; //Pointer to local planner
00143         int m_nLocalPlanner;         //Which local planner to use, (*m_localPlanner)
00144         int m_metrics;               //Which metric to use
00145         bool m_useLazy;              //Whether use Lazy strategy
00146         bool m_drawCSpace;           //Which projection of random tree to draw
00147         bool m_useOrientation;       //Whether consider orientation at goal
00148         bool m_useOrientationAlways; //Whether consider orienation all the time
00149         double m_stepSize;           //Step size between landmarks
00150         double m_timeInterval;       //Sampling time along the end-effector path
00151 
00152         Pose m_startPose;            //Start End-effector pose
00153         Pose m_goalPose;             //Goal End-effector Pose
00154         bool m_useGoalPose;          //Whether task
00155         bool m_useGoalConf;          
00156         bool m_useStartPose;
00157         bool m_useStartConf;
00158         bool m_isGoalPoseSet;
00159         bool m_isGoalConfSet;
00160         bool m_isStartPoseSet;
00161         bool m_isStartConfSet;
00162 
00163 protected:
00164         Vertex m_goalVert;
00165         int ExtendWithConstraint(Node &fromNode, Pose &dirPose, Node &toNode, Path &path, EEPath &endeffpath, bool greedy);
00166         int ExtendToGoal(Vertex &fromVert, Pose &dirPose, Vertex &endVert);
00167         int LazyTrackEEPath();
00168         void RetrievePath(Vertex &goalVert);
00169         void GenerateRandomNode(Node &randomNode);
00170         Configuration GenerateRandomConfig();
00171 
00172 protected:  //********* About collision detector
00173         Universe *m_trajUniverse;
00174         CD_BasicStyle *m_trajCollisionDetector;
00175         void CreateTrajectoryCD(CD_BasicStyle* collisionDetector);
00176         void DeleteTrajectoryCD();
00177         bool IsInterfering (const Pose& pose1, const Pose& pose2);
00178 
00179 private:  //********* All about metrics
00180         VectorN distWeight;
00181         double Distance(const Pose &pos1, const Pose &pos2);
00182         double Distance(const Configuration &conf1, const Configuration &conf2);
00183 
00184 private:  //********* Tree related members
00185         Vertex m_rootVert;              //Root of the tree
00186         dynamic_trees m_trajTree;       //Data structure for the edges
00187         std::vector<vertex> m_vertices; //Data structure for the nodes
00188 
00189         bool CreateTree(Node &rootNode);   //Create the random tree
00190         void ClearTree();                  //Destroy the random tree
00191         void TrimTreeFrom(Vertex failVert);//Delete part of a tree
00192         //Add a new node into the rand tree
00193         Vertex AddNodeInTree(Vertex parentVertex, Node &childNode, Pose &dirPose, Path &localPath, EEPath &endeffPath);
00194         //The following functions get the cloest neighbor, w.r.t different space
00195         Vertex FindClosestInTree(Pose &pose); 
00196         Vertex FindClosestInTree(Configuration &conf); 
00197         Vertex FindClosestInTree(Node node); 
00198         //The following functions get corresponding information of a node
00199         Configuration& GetConfigurationFromTree(Vertex vert);
00200         Pose& GetPoseFromTree(Vertex vert);
00201         Path& GetPathFromTree(Vertex vert);
00202 
00203 public:  //********* About Constraints
00204         //The following functions set call-back functions which will be set by user.
00205         void SetPoseChecker(ProcIsStaified proc); 
00206         void SetPoseAdjuster(ProcAdjustToSatisfy proc);
00207         void SetVelocityChecker(ProcGetVelocity proc);
00208         void SetDirectedVelocityChecker(ProcGetDirectedVelocity proc);
00209 private:
00210         //Function pointers to store the call-back functions
00211         ProcIsStaified            IsPoseSatified;
00212         ProcAdjustToSatisfy       AdjustPoseToSatisfy;
00213         ProcGetVelocity           GetVelocity;
00214         ProcGetDirectedVelocity   GetDirectedVelocity;
00215     //Compute next feasible pose, with the given call back function.
00216         void GetNextPose(Pose &prePose, Pose &dirPose, Pose &postPose, bool greedy);
00217 
00218 private:  //********* About path manipulation
00219         inline void CopyPath(Path &target, Path &source);
00220         inline void CopyEEPath(EEPath &target, EEPath &source);
00221         void AppendPath(Path &collect, Path &local);
00222         void AppendPath(Path &collect, PA_Points *local);
00223         void InsertPath(Path &target, Path &source);
00224         void InterpolatePath(Path &target, Configuration &start, Configuration &end);
00225 };
00226 
00227 #endif

Generated on Sat Apr 1 21:30:40 2006 for Motion Planning Kernel by  doxygen 1.4.6-NO