KrisLibrary  1.0.0
KinodynamicMotionPlanner.h
1 #ifndef ROBOTICS_KINODYNAMIC_MOTION_PLANNER_H
2 #define ROBOTICS_KINODYNAMIC_MOTION_PLANNER_H
3 
4 #include "KinodynamicSpace.h"
5 #include "KinodynamicPath.h"
6 #include "PointLocation.h"
7 #include "DensityEstimator.h"
8 #include "Objective.h"
9 #include <KrisLibrary/graph/Tree.h>
10 #include <queue>
11 typedef Vector State;
12 typedef Vector ControlInput;
13 
25 {
26 public:
27  struct EdgeData
28  {
30  EdgePlannerPtr checker;
31  };
33 
35  ~KinodynamicTree();
36  void Init(const State& initialState);
37  void EnablePointLocation(const char* type=NULL);
38  void Clear();
39  Node* AddMilestone(Node* parent,const ControlInput& u);
40  Node* AddMilestone(Node* parent,const ControlInput& u,const InterpolatorPtr& path,const EdgePlannerPtr& e);
41  Node* AddMilestone(Node* parent,KinodynamicMilestonePath& path,const EdgePlannerPtr& e=NULL);
42  void AddPath(Node* n0,const KinodynamicMilestonePath& path,std::vector<Node*>& res);
43  void Reroot(Node* n);
44  Node* PickRandom();
45  Node* FindClosest(const State& x);
50  void DeleteSubTree(Node* n,bool rebuild=true);
51  void RebuildPointLocation();
52 
53  static void GetPath(Node* start,Node* goal,KinodynamicMilestonePath& path);
54 
55  KinodynamicSpace* space;
56  Node* root;
57 
59  std::shared_ptr<PointLocationBase> pointLocation;
60  std::vector<Node*> index;
61  std::vector<Vector> pointRefs;
62 };
63 
65 {
66 public:
68  virtual ~KinodynamicPlannerBase() {}
69  virtual void Init(const State& xinit,CSet* goalSet)=0;
70  virtual void Init(const State& xinit,const State& xgoal,Real goalRadius);
71  virtual bool Plan(int maxIters)=0;
72  virtual bool Done() const=0;
73  virtual bool GetPath(KinodynamicMilestonePath& path)=0;
74  virtual void GetStats(PropertyMap& stats) const {}
75 
76  KinodynamicSpace* space;
77  CSet* goalSet;
78 };
79 
83 {
84 public:
86 
88  virtual ~RRTKinodynamicPlanner() {}
89  virtual void Init(const State& xinit,CSet* goalSet);
90  virtual bool Plan(int maxIters);
91  virtual bool Done() const;
92  virtual bool GetPath(KinodynamicMilestonePath& path);
93 
94  virtual Node* Extend();
95  virtual Node* ExtendToward(const State& xdest);
96  virtual void PickDestination(State& xdest);
97 
98  //default move uses steering function, if available, and if not, uses a RandomSamplingSteeringFunction
99  virtual bool PickControl(const State& x0, const State& xDest,KinodynamicMilestonePath& e);
100 
102  virtual bool FilterExtension(Node* n,const KinodynamicMilestonePath& path) { return false; }
103 
104  virtual void GetStats(PropertyMap& stats) const;
105 
106  Real goalSeekProbability;
107  KinodynamicTree tree;
108  Real delta;
109 
110  //temporary output
111  Node* goalNode;
112  int numIters,numInfeasibleControls,numInfeasibleEndpoints,numFilteredExtensions,numSuccessfulExtensions;
113  Real nnTime,pickControlTime,visibleTime,overheadTime;
114 };
115 
116 
130 {
131 public:
132  typedef KinodynamicTree::Node Node;
133 
135  virtual ~ESTKinodynamicPlanner() {}
136  void EnableExtensionCaching(int cacheSize=100);
137  void SetDensityEstimatorResolution(Real res);
138  void SetDensityEstimatorResolution(const Vector& res);
139  virtual void Init(const State& xinit,CSet* goalSet);
140  virtual bool Plan(int maxIters);
141  virtual bool Done() const;
142  virtual bool GetPath(KinodynamicMilestonePath& path);
144  virtual bool FilterExtension(Node* n,const KinodynamicMilestonePath& path) { return false; }
145  virtual void GetStats(PropertyMap& stats) const;
146 
147  void RebuildDensityEstimator();
148 
149  KinodynamicTree tree;
150  std::shared_ptr<DensityEstimatorBase> densityEstimator;
151  int extensionCacheSize;
152 
155  std::vector<Node*> extensionCache;
156  std::vector<double> extensionWeights;
157 
158  //temporary output
159  Node* goalNode;
160  int numIters,numFilteredExtensions,numSuccessfulExtensions;
161  Real sampleTime,simulateTime,visibleTime,overheadTime;
162 };
163 
164 
168 {
169 public:
171  virtual ~LazyRRTKinodynamicPlanner() {}
172  virtual bool Plan(int maxIters);
173  virtual Node* ExtendToward(const State& xdest);
174  bool CheckPath(Node* n);
175 };
176 
180 {
181 public:
182  typedef KinodynamicTree::Node Node;
183 
185  virtual ~BidirectionalRRTKP() {}
186  void Init(const State& xStart,const State& xGoal);
187  virtual void Init(const State& xinit,CSet* goalSet);
188  virtual bool Plan(int maxIters);
189  virtual bool Done() const;
190  virtual bool GetPath(KinodynamicMilestonePath& path);
191  Node* ExtendStart();
192  Node* ExtendGoal();
193 
194  //if this returns true, there's a visible path between nStart and nGoal.
195  //bridge is filled out with the connection information.
196  bool ConnectTrees(Node* nStart,Node* nGoal);
197 
198  //default move uses steering function
199  virtual bool PickControl(const State& x0, const State& xDest, KinodynamicMilestonePath& path);
200  virtual bool PickReverseControl(const State& x1, const State& xDest, KinodynamicMilestonePath& path);
201 
202  KinodynamicTree start,goal;
203  Real connectionTolerance;
204 
205  struct Bridge
206  {
207  Node *nStart,*nGoal;
209  EdgePlannerPtr checker;
210  };
211 
212  Bridge bridge;
213 };
214 
215 
216 #endif
std::shared_ptr< PointLocationBase > pointLocation
If point location is enabled, this will contain a point location data structure.
Definition: KinodynamicMotionPlanner.h:59
virtual bool FilterExtension(Node *n, const KinodynamicMilestonePath &path)
Subclasses can overload this to eliminate certain extensions of the tree.
Definition: KinodynamicMotionPlanner.h:102
Definition: KinodynamicMotionPlanner.h:64
Definition: KinodynamicMotionPlanner.h:27
Data structure for a kinodynamic planning tree.
Definition: KinodynamicMotionPlanner.h:24
Definition: KinodynamicMotionPlanner.h:205
A bidirectional RRT planner for kinodynamic systems.
Definition: KinodynamicMotionPlanner.h:179
Stores a kinodynamic path with piecewise constant controls.
Definition: KinodynamicPath.h:23
A lazy version of kinodynamic RRT.
Definition: KinodynamicMotionPlanner.h:167
The RRT planner for kinodynamic systems.
Definition: KinodynamicMotionPlanner.h:82
A class used for kinodynamic planning. Combines a CSpace defining the state space, as well as a ControlSpace.
Definition: KinodynamicSpace.h:22
A tree graph structure, represented directly at the node level.
Definition: Tree.h:25
std::vector< Node * > extensionCache
Definition: KinodynamicMotionPlanner.h:155
The EST planner for kinodynamic systems.
Definition: KinodynamicMotionPlanner.h:129
A simple map from keys to values.
Definition: PropertyMap.h:27
A subset of a CSpace, which establishes a constraint for a configuration must meet. Mathematically, this is a set S which imposes the constraint [q in S].
Definition: CSet.h:20
virtual bool FilterExtension(Node *n, const KinodynamicMilestonePath &path)
Subclasses can overload this to eliminate certain extensions of the tree.
Definition: KinodynamicMotionPlanner.h:144
void DeleteSubTree(Node *n, bool rebuild=true)
Definition: KinodynamicMotionPlanner.cpp:210