planners/atace/PL_RGD_Constraint.h

Go to the documentation of this file.
00001 #ifndef _HEADER_PL_RGD_CONSTRAINED_
00002 #define _HEADER_PL_RGD_CONSTRAINED_
00003 
00004 #include "planners/prm/PL_PRM.h"
00005 #include <LEDA\dynamic_trees.h>
00006 
00007 #undef array
00008 #undef vector
00009 #undef map
00010 #undef string
00011 #undef set
00012 
00013 #define STRATEGY_RRT  0
00014 #define STRATEGY_PRM  1
00015 
00016 #define CONSTRAINT_COLSURE      0
00017 #define CONSTRAINT_PLANAR       1
00018 #define CONSTRAINT_ORIENTATION  2
00019 #define CONSTRAINT_SPHERE       3
00020 #define CONSTRAINT_OTHER        4
00021 
00022 class IK_Jacobian;
00023 class LocalPlannerClosed;
00024 
00025 typedef list<Configuration> Fragment;
00026 //typedef double (*CostFunction)(const Configuration &conf, const Frame &pose);
00027 
00028 class PL_RGD_PRM: public PL_PRM
00029 {
00030 public:
00031         PL_RGD_PRM();
00032         ~PL_RGD_PRM();
00033 
00034         virtual bool Plan ();
00035         virtual void SetCollisionDetector (CD_BasicStyle* collisionDetector);
00036 
00037         bool GetSatisfiedConfiguration(Configuration &conf);
00038     void SetConstraintType(int type) {typeOfConstraint = type;};
00039         void SetUseJacobian(BOOL use) {useJacobian = (use == TRUE);};
00040         void SetUseGoalPose(BOOL use) {useGoalPose = (use == TRUE);}
00041 
00042     int GetConstraintType() {return typeOfConstraint;};
00043         BOOL GetUseJacobian( ) {return (useJacobian)?TRUE:FALSE;};
00044         BOOL GetUseGoalPose( ) {return (useGoalPose)?TRUE:FALSE;};
00045 
00046         //double Dist(const Configuration &p1, const Configuration &p2) const;
00047         double Error(const Configuration &p1) const;
00048         double Error1(const Configuration &p1, const Frame &pose) const;
00049         double Error2(const Configuration &p1, const Frame &pose) const;
00050         double Error3(const Configuration &p1, const Frame &pose) const;
00051         double Error4(const Configuration &p1, const Frame &pose) const;
00052         double Error5(const Configuration &p1, const Frame &pose) const;
00053         double Error6(const Configuration &p1, const Frame &pose) const;
00054 
00055         Frame GetToolFrame( const Configuration& config ) const;
00056         virtual bool GenerateRandomConfigForPose (Configuration& conf, Frame &endEffPose);
00057 
00058 protected:
00059         // Create the Random Configurations of the C-space.
00060         bool GetSatisfactoryConfiguration(Configuration &conf, Frame &pose);
00061         virtual Configuration GenerateRandomConfig ();
00062         virtual Configuration GenerateRandomConfig ( const Configuration& seed, const double& std_dev );
00063         virtual void ConnectEdgesFull( const node& n1, const double& radius_squared );  // Connects the given node with edges, Full PRM style.
00064         virtual bool IsInterfering ( const Configuration& c1, const Configuration& c2 );
00065         virtual bool IsInterfering ( const Configuration& c1 );
00066         virtual SuccessResultType TranslatePath();
00067         bool Plan_As_Usual ();
00068         void GetRotAngles( const Matrix4x4& frame, double& roll, double& pitch, double& yaw ) const;
00069 
00070 protected:
00071         Fragment *edgeFrag;
00072         CD_BasicStyle *pCollisionDetector;
00073         int typeOfConstraint;
00074         bool useJacobian;
00075         bool useGoalPose;
00076         Frame planeDesired; //Assume the plane parallel to x-z plane.
00077         Frame orientDesired;
00078         bool MakeItSatisfied(Configuration &conf);
00079         //bool ConnectNodes(Configuration &q1, Configuration &q2, Fragment *frag);
00080         bool IsSatisfied(const Configuration &conf) const;
00081         void UpdatePlanarConstraint();
00082         void UpdateOrientConstraint();
00083         void UpdateShpereConstraint();
00084 
00085 private:
00086         edge_map<Fragment> edgePath;
00087         LocalPlannerClosed* planner;
00088                                 //Record the position of plane, y-coordinate value;
00089 };
00090 
00091 
00092 class PL_RGD_RRT: public PL_RGD_PRM
00093 {
00094 public:
00095         PL_RGD_RRT();
00096         ~PL_RGD_RRT();
00097 
00098         virtual bool DrawExplicit () const;
00099         virtual bool Plan ();
00100 
00101 protected:
00102         vertex m_goalVert;
00103         vertex m_rootVert;
00104 
00105         //********* Tree related members
00106 protected:
00107         dynamic_trees m_trajTree;
00108         std::vector<vertex> m_vertices;
00109 
00110         bool CreateTree(Configuration &conf);
00111         void ClearTree();
00112         vertex AddNodeInTree(vertex parentVertex, Configuration &childConf, PA_Points &localPath);
00113         vertex FindClosestInTree(Configuration &conf);
00114         Configuration& GetConfigurationFromTree(vertex vert);
00115         PA_Points& GetPathFromTree(vertex vert);
00116         double Distance(const Configuration &conf1, const Configuration &conf2);
00117         int Extend(Configuration &fromConf, Configuration &toConf, Configuration dirConf, PA_Points &edgePath);
00118         //int ConnectToGoal(vertex fromVert);
00119         int ConnectToGoal();
00120 
00121 private:
00122         void RetrievePath(vertex &goalVert);
00123         inline void CopyPath(PA_Points &target, PA_Points &source){target = source;};
00124         void AppendPath(PA_Points &collect, PA_Points &local);
00125         void AppendPath(PA_Points &collect, PA_Points *local);
00126         void InsertPath(PA_Points &target, PA_Points &source);
00127 };
00128 
00129 class PL_RGD_Constraint: public PL_RGD_RRT
00130 {
00131 public:
00132         PL_RGD_Constraint();
00133         //~PL_RGD_Constraint();
00134 
00135         void SetStrategy(int strategy);
00136         int GetStrategy();
00137         virtual bool DrawExplicit () const;
00138         virtual bool Plan ();
00139 private:
00140         int m_strategy;
00141 };
00142 
00143 
00144 //typedef PL_RGD_PRM PL_PRM_ClosedChain;
00145 //typedef PL_RGD_RRT PL_PRM_ClosedChain;
00146 
00147 #endif

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