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
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
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
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 );
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;
00077 Frame orientDesired;
00078 bool MakeItSatisfied(Configuration &conf);
00079
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
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
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
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
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
00145
00146
00147 #endif