00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef PL_GraphBase_h
00012 #define PL_GraphBase_h 1
00013
00014 #pragma warning( disable : 4250 )
00015
00016
00017 #include <LEDA/graph.h>
00018 #include <LEDA/node_list.h>
00019 #include "kinematics/Configuration.h"
00020
00021
00022
00023 #include "Planners\PL_Boolean_Output.h"
00024 #include "Planners\PL_OpenGL.h"
00025
00026
00027 enum SuccessResultType;
00028
00029
00030
00031
00032
00033
00034 class PL_GraphBase :
00035 virtual public PL_Boolean_Output,
00036 virtual public PL_OpenGL
00037 {
00038
00039 public:
00040
00041 PL_GraphBase();
00042
00043
00044 virtual ~PL_GraphBase();
00045
00046 virtual bool DrawExplicit () const;
00047
00048 virtual bool Load (const char *filename);
00049
00050 virtual bool Plan ();
00051
00052 bool Save (const char *filename) const;
00053
00054 virtual void SetStartConfig( const Configuration& configuration );
00055 virtual void SetGoalConfig( const Configuration& config );
00056
00057 virtual void SetCollisionDetector (CD_BasicStyle* collisionDetector);
00058
00059
00060
00061
00062
00063 inline int NodeCount() const { return G.number_of_nodes(); };
00064 inline int EdgeCount() const { return G.number_of_edges(); };
00065
00066 virtual void ClearGraph();
00067 void ClearGraphPath();
00068
00069
00070
00071 void NormDistWeight();
00072 virtual void SetDistWeight( const VectorN& weights );
00073 VectorN GetDistWeight() const { return distWeight; };
00074
00075 void CopySettings( PlannerBase* original );
00076
00077 protected:
00078
00079
00080
00081
00082
00083
00084 virtual double Distance ( const node& a, const node& b ) const;
00085 virtual double Distance ( const Configuration& a, const Configuration& b ) const;
00086 virtual double Distance ( const node& a, const node& b, const VectorN& weight ) const;
00087 virtual double Distance ( const Configuration& a, const Configuration& b, const VectorN& weight ) const;
00088 virtual VectorN DiffV ( const node& a, const node& b ) const;
00089 virtual VectorN DiffV ( const Configuration& a, const Configuration& b ) const;
00090
00091
00092
00093 double Length ( const edge& e1 ) const;
00094
00095
00096
00097
00098 double Measure ( const edge& e1 ) const;
00099 double Measure ( const edge& e1, const VectorN& weight ) const;
00100
00101
00102
00103
00104
00105 double GetCspaceRange( const VectorN& weight ) const;
00106 double GetCspaceRange() const ;
00107
00108
00109
00110
00111
00112 node FindConfig( const Configuration& c1 ) const;
00113
00114
00115
00116
00117 edge FindEdge( const node& n1, const node& n2 ) const;
00118
00119
00120 virtual Configuration GenerateRandomConfig ();
00121 virtual Configuration GenerateRandomConfig ( const Configuration& seed, const double& std_dev );
00122 virtual Configuration GenerateRandomConfig ( const Configuration& centre );
00123
00124
00125
00126
00127 virtual bool IsInterfering ( const edge& e1 );
00128 virtual bool IsInterfering ( const node& n1 );
00129 virtual bool IsInterfering ( const Configuration& c1 );
00130 virtual bool IsInterfering ( const node& n1, const node& n2 );
00131 virtual bool IsInterfering ( const Configuration& c1, const Configuration& c2 );
00132
00133
00134
00135
00136
00137 void GetCoords( const node n1, double& Xcor, double& Ycor, double& Zcor ) const;
00138 void GetCoords( const Configuration& c1, double& Xcor, double& Ycor, double& Zcor ) const;
00139
00140
00141 virtual bool DrawSpecific() const;
00142
00143
00144
00145
00146
00147 bool PrioritizeEdge(node prev, node curr);
00148 bool PrioritizeEdge(node source, edge e1);
00149
00150
00151
00152 Configuration GetMidPoint( const Configuration& a, const Configuration& b ) const;
00153
00154
00155
00156 virtual SuccessResultType TranslatePath();
00157
00158
00159
00160 virtual bool SaveContents( std::ofstream& outfile ) const;
00161
00162
00163
00164 virtual bool LoadContents( std::ifstream& infile );
00165
00166
00167
00168 node TranslateNodeID( const int& nodeID ) const;
00169
00170
00171
00172
00173
00174
00175
00176 GRAPH<Configuration,double> G;
00177
00178
00179
00180 node startNode;
00181 node goalNode;
00182
00183
00184 node_list graphPath;
00185
00186
00187
00188 VectorN distWeight;
00189
00190
00191
00192 char fileext[10];
00193 char fileheader[20];
00194 static const int NIL_ID;
00195
00196 private:
00197
00198
00199 private:
00200
00201
00202 };
00203
00204
00205
00206
00207 enum SuccessResultType
00208 {
00209 TIMER_EXPIRED = -1,
00210 FAIL = 0,
00211 PASS = 1
00212 };
00213
00214
00215 #endif