00001 //---------------------------------------------------------------------- 00002 // The Motion Strategy Library (MSL) 00003 //---------------------------------------------------------------------- 00004 // 00005 // Copyright (c) University of Illinois and Steven M. LaValle. 00006 // All Rights Reserved. 00007 // 00008 // Permission to use, copy, and distribute this software and its 00009 // documentation is hereby granted free of charge, provided that 00010 // (1) it is not a component of a commercial product, and 00011 // (2) this notice appears in all copies of the software and 00012 // related documentation. 00013 // 00014 // The University of Illinois and the author make no representations 00015 // about the suitability or fitness of this software for any purpose. 00016 // It is provided "as is" without express or implied warranty. 00017 //---------------------------------------------------------------------- 00018 00019 #ifndef MSL_PLANNER_H 00020 #define MSL_PLANNER_H 00021 00022 #ifdef WIN32 00023 #include <list> 00024 #include <fstream> 00025 using namespace std; 00026 #else 00027 #include <fstream.h> 00028 #include <list.h> 00029 #include <vector.h> 00030 #endif 00031 00032 00033 #include "solver.h" 00034 #include "random.h" 00035 #include "graph.h" 00036 #include "tree.h" 00037 #include "vector.h" 00038 #include "util.h" 00039 00041 class Planner: public Solver { 00042 protected: 00043 MSLRandomSource R; 00044 00046 MSLVector RandomState(); 00047 00049 MSLVector NormalState(MSLVector mean, double sd); 00050 00051 public: 00053 double CumulativePlanningTime; 00054 00056 double CumulativeConstructTime; 00057 00059 list<MSLVector> Path; 00060 00062 list<MSLVector> Policy; 00063 00065 MSLVector GapState; 00066 00069 bool Holonomic; 00070 00072 MSLVector GapError; 00073 00076 MSLTree *T; 00077 00079 MSLTree *T2; 00080 00083 MSLGraph *Roadmap; 00084 00086 list<double> TimeList; 00087 00089 list<MSLVector> StateList; 00090 00092 list<MSLVector> InputList; 00093 00095 int NumNodes; 00096 00098 double PlannerDeltaT; 00099 00101 Planner(Problem *problem); 00102 00103 ~Planner(); 00104 00106 void Reset(); 00107 00109 virtual void Construct() = 0; 00110 00112 virtual bool Plan() = 0; 00113 00115 virtual void WriteGraphs(ofstream &fout) = 0; 00116 00118 virtual void ReadGraphs(ifstream &fin) = 0; 00119 00121 bool GapSatisfied(const MSLVector &x1, const MSLVector &x2); 00122 }; 00123 00124 00125 class IncrementalPlanner: public Planner { 00126 public: 00128 IncrementalPlanner(Problem *problem); 00129 00130 ~IncrementalPlanner() {}; 00131 00133 virtual void Construct(); 00134 00136 void RecordSolution(const list<MSLNode*> &glist, 00137 const list<MSLNode*> &g2list); 00138 00139 void RecordSolution(const list<MSLNode*> &glist); 00140 00142 virtual void WriteGraphs(ofstream &fout); 00143 00145 virtual void ReadGraphs(ifstream &fin); 00146 }; 00147 00148 00149 class RoadmapPlanner: public Planner { 00150 public: 00152 RoadmapPlanner(Problem *problem); 00153 00154 ~RoadmapPlanner() {}; 00155 00157 virtual void WriteGraphs(ofstream &fout); 00158 00160 virtual void ReadGraphs(ifstream &fin); 00161 }; 00162 00163 00164 #endif 00165 00166 00167