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 #include <list> 00023 #include <vector> 00024 #include <fstream> 00025 using namespace std; 00026 00027 00028 00029 #include "solver.h" 00030 #include "random.h" 00031 #include "graph.h" 00032 #include "tree.h" 00033 #include "vector.h" 00034 #include "util.h" 00035 00037 class Planner: public Solver { 00038 protected: 00039 MSLRandomSource R; 00040 00042 MSLVector RandomState(); 00043 00045 MSLVector NormalState(MSLVector mean, double sd); 00046 00047 public: 00049 double CumulativePlanningTime; 00050 00052 double CumulativeConstructTime; 00053 00055 list<MSLVector> Path; 00056 00058 list<double> TimeList; 00059 00061 list<MSLVector> Policy1; 00062 00064 list<double> TimeList1; 00065 00067 list<MSLVector> Policy2; 00068 00070 list<double> TimeList2; 00071 00073 MSLVector GapState1; 00074 00076 MSLVector GapState2; 00077 00080 bool Holonomic; 00081 00083 MSLVector GapError; 00084 00087 MSLTree *T; 00088 00090 MSLTree *T2; 00091 00094 MSLGraph *Roadmap; 00095 00097 list<MSLVector> StateList; 00098 00100 list<MSLVector> InputList; 00101 00103 int NumNodes; 00104 00106 double PlannerDeltaT; 00107 00109 Planner(Problem *problem); 00110 00111 ~Planner(); 00112 00114 void Reset(); 00115 00117 virtual void Construct() = 0; 00118 00120 virtual bool Plan() = 0; 00121 00123 virtual void WriteGraphs(ofstream &fout) = 0; 00124 00126 virtual void ReadGraphs(ifstream &fin) = 0; 00127 00129 bool GapSatisfied(const MSLVector &x1, const MSLVector &x2); 00130 }; 00131 00132 00133 class IncrementalPlanner: public Planner { 00134 public: 00136 IncrementalPlanner(Problem *problem); 00137 00138 ~IncrementalPlanner() {}; 00139 00141 virtual void Construct(); 00142 00144 void RecordSolution(const list<MSLNode*> &glist, 00145 const list<MSLNode*> &g2list); 00146 00147 void RecordSolution(const list<MSLNode*> &glist); 00148 00150 virtual void WriteGraphs(ofstream &fout); 00151 00153 virtual void ReadGraphs(ifstream &fin); 00154 }; 00155 00156 00157 class RoadmapPlanner: public Planner { 00158 public: 00160 RoadmapPlanner(Problem *problem); 00161 00162 ~RoadmapPlanner() {}; 00163 00165 virtual void WriteGraphs(ofstream &fout); 00166 00168 virtual void ReadGraphs(ifstream &fin); 00169 }; 00170 00171 00172 #endif 00173 00174 00175