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_RRT_H 00020 #define MSL_RRT_H 00021 00022 #include "planner.h" 00023 #include "util.h" 00024 00025 #ifdef USE_ANN 00026 #include <ANN/ANN.h> // ANN declarations 00027 #include "nn.h" 00028 #include "multiann.h" 00029 #endif 00030 00038 00039 00040 class RRT: public IncrementalPlanner { 00041 protected: 00043 virtual MSLVector SelectInput(const MSLVector &x1, 00044 const MSLVector &x2, 00045 MSLVector &nx_best, 00046 bool &success, 00047 bool forward); 00048 00050 virtual MSLNode* SelectNode(const MSLVector &x, MSLTree *t, 00051 bool forward); 00052 00054 virtual bool Extend(const MSLVector &x, MSLTree *t, MSLNode *&nn, 00055 bool forward); 00056 00058 virtual bool Connect(const MSLVector &x, MSLTree *t, MSLNode *&nn, 00059 bool forward); 00060 00062 virtual MSLVector ChooseState(); 00063 00064 public: 00065 00068 bool UseANN; 00069 00071 double GoalDist; 00072 00074 MSLVector BestState; 00075 00077 double ConnectTimeLimit; 00078 00079 #ifdef USE_ANN 00080 MultiANN MAG; 00081 MultiANN MAG2; 00082 #endif 00083 00085 RRT(Problem *problem); 00086 00088 virtual ~RRT() {}; 00089 00091 int SatisfiedCount; 00092 00094 virtual void Reset(); 00095 00097 virtual bool Plan(); 00098 00099 }; 00100 00101 00107 00108 class RRTGoalBias: public RRT { 00109 protected: 00110 virtual MSLVector ChooseState(); 00111 public: 00112 double GoalProb; 00113 RRTGoalBias(Problem *p); 00114 virtual ~RRTGoalBias() {}; 00115 }; 00116 00117 00118 00127 00128 00129 class RRTCon: public RRTGoalBias { 00130 public: 00131 RRTCon(Problem *p); 00132 00134 00135 virtual ~RRTCon() {}; 00136 00139 00140 virtual bool Plan(); 00141 }; 00142 00143 00144 00152 00153 00154 class RRTDual: public RRT { 00155 protected: 00156 void RecoverSolution(MSLNode *n1, MSLNode *n2); 00157 public: 00158 RRTDual(Problem *p); 00159 virtual ~RRTDual() {}; 00160 00161 00162 00166 00167 virtual bool Plan(); 00168 }; 00169 00170 00171 00184 00185 class RRTExtExt: public RRTDual { 00186 public: 00187 RRTExtExt(Problem *p); 00188 virtual ~RRTExtExt() {}; 00189 virtual bool Plan(); 00190 }; 00191 00192 00197 00198 class RRTGoalZoom: public RRT { 00199 protected: 00200 virtual MSLVector ChooseState(); 00201 public: 00202 double GoalProb,ZoomProb,ZoomFactor; 00203 RRTGoalZoom(Problem *p); 00204 virtual ~RRTGoalZoom() {}; 00205 }; 00206 00207 00211 00212 class RRTPolar: public RRT { 00213 protected: 00214 virtual MSLVector ChooseState(); 00215 virtual MSLVector SelectInput(const MSLVector &x1, const MSLVector &x2, 00216 MSLVector &nx_best, bool &success); 00217 public: 00218 double RadiusExp; 00219 RRTPolar(Problem *p); 00220 virtual ~RRTPolar() {}; 00221 }; 00222 00226 00227 class RRTHull: public RRT { 00228 protected: 00229 virtual MSLVector ChooseState(); 00230 public: 00231 double Radius; 00232 RRTHull(Problem *p); 00233 virtual ~RRTHull() {}; 00234 }; 00235 00236 00253 00254 class RRTExtCon: public RRTDual { 00255 public: 00256 RRTExtCon(Problem *p); 00257 virtual ~RRTExtCon() {}; 00258 00260 virtual bool Plan(); 00261 }; 00262 00263 00264 00281 00282 00283 class RRTConCon: public RRTDual { 00284 public: 00285 RRTConCon(Problem *p); 00286 virtual ~RRTConCon() {}; 00287 00290 virtual bool Plan(); 00291 }; 00292 00293 00312 00313 00314 class RRTBidirBalanced: public RRTDual { 00315 public: 00316 RRTBidirBalanced(Problem *p); 00317 virtual ~RRTBidirBalanced() {}; 00318 00321 virtual bool Plan(); 00322 }; 00323 00324 00329 00330 class RandomTree: public RRT { 00331 protected: 00332 virtual MSLNode* SelectNode(const MSLVector &x, MSLTree *t, 00333 bool forward); 00334 virtual MSLVector SelectInput(const MSLVector &x1, const MSLVector &x2, 00335 MSLVector &nx_best, bool &success, 00336 bool forward); 00337 public: 00338 RandomTree(Problem *p); 00339 virtual ~RandomTree() {}; 00340 }; 00341 00342 #endif 00343 00344 00345