KrisLibrary  1.0.0
MotionPlanner.h
1 #ifndef ROBOTICS_MOTION_PLANNER_H
2 #define ROBOTICS_MOTION_PLANNER_H
3 
4 #include <KrisLibrary/graph/Tree.h>
5 #include <KrisLibrary/graph/UndirectedGraph.h>
6 #include <KrisLibrary/graph/ConnectedComponents.h>
7 #include <vector>
8 #include <list>
9 #include "CSpace.h"
10 #include "EdgePlanner.h"
11 #include "Path.h"
12 
13 class PointLocationBase;
14 
15 
24 {
25 public:
27 
29  virtual ~RoadmapPlanner();
30 
31  virtual void Cleanup();
32  virtual void GenerateConfig(Config& x);
33  virtual int AddMilestone(const Config& x);
34  virtual int TestAndAddMilestone(const Config& x);
35  virtual void ConnectEdge(int i,int j,const EdgePlannerPtr& e);
36  virtual EdgePlannerPtr TestAndConnectEdge(int i,int j);
37  virtual bool HasEdge(int i,int j) { return roadmap.FindEdge(i,j)!=NULL; }
38  virtual EdgePlannerPtr GetEdge(int i,int j) { return *roadmap.FindEdge(i,j); }
39  virtual bool AreConnected(int i,int j) { return ccs.SameComponent(i,j); }
40  virtual bool AreConnected(int i,int j) const { return ccs.SameComponent(i,j); }
41  virtual void ConnectToNeighbors(int i,Real connectionThreshold,bool ccReject=true);
42  virtual void ConnectToNearestNeighbors(int i,int k,bool ccReject=true);
43  virtual void Generate(int numSamples,Real connectionThreshold);
44  virtual void CreatePath(int i,int j,MilestonePath& path);
45 
46  CSpace* space;
47  Roadmap roadmap;
49  std::shared_ptr<PointLocationBase> pointLocator;
50 };
51 
52 
62 {
63 public:
64  struct Milestone
65  {
66  Config x;
67  int connectedComponent;
68  };
69 
71 
73  virtual ~TreeRoadmapPlanner();
74 
75  virtual void GenerateConfig(Config& x);
76  virtual Node* AddMilestone(const Config& x);
77  virtual Node* TestAndAddMilestone(const Config& x);
78  virtual Node* AddInfeasibleMilestone(const Config& x) { return NULL; }
79  virtual Node* Extend();
80  virtual void Cleanup();
81  virtual void ConnectToNeighbors(Node*);
82  virtual EdgePlannerPtr TryConnect(Node*,Node*);
83  virtual void DeleteSubtree(Node* n);
84  //helpers
85  //default implementation is O(n) search
86  virtual Node* ClosestMilestone(const Config& x);
87  virtual Node* ClosestMilestoneInComponent(int component,const Config& x);
88  virtual Node* ClosestMilestoneInSubtree(Node* node,const Config& x);
89  Node* Extend(Node* n,const Config& x);
90  Node* TryExtend(Node* n,const Config& x);
91  void AttachChild(Node* p, Node* c, const EdgePlannerPtr& e); //c will become a child of p
92  Node* SplitEdge(Node* p,Node* n,Real u);
93  void CreatePath(Node* a, Node* b, MilestonePath& path);
94 
95  CSpace* space;
96  std::vector<Node*> connectedComponents;
97  Real connectionThreshold;
98 
99  //temporary
100  std::vector<Node*> milestones;
101  Config x;
102 };
103 
104 
114 {
115 public:
117  virtual void GenerateConfig(Config& x);
118  virtual Node* AddMilestone(const Config& x);
119  virtual void Cleanup();
120 
121  //overrideable
122  virtual Node* SelectMilestone(const std::vector<Node*>& milestones);
123 
125  Real delta;
127  std::vector<Real> weights;
128 };
129 
138 {
139 public:
140  RRTPlanner(CSpace*s);
141  virtual Node* Extend();
142 
143  Real delta;
144 };
145 
156 {
157 public:
160  void Init(const Config& start, const Config& goal);
162  bool Plan();
164  void CreatePath(MilestonePath&) const;
165 };
166 
167 /*
168 class VisibilityPRM : public RandomizedPlanner
169 {
170 public:
171  VisibilityPRM(CSpace*s);
172  //may return NULL for rejected config
173  virtual Node* AddMilestone(const Config& x);
174  virtual Node* AddInfeasibleMilestone(const Config& x) { return NULL; }
175  virtual Node* Extend();
176  virtual Node* CanConnectComponent(int i,const Config& x);
177 };
178 */
179 
180 #endif
Definition: ConnectedComponents.h:9
A base class to be used for tree-based roadmap planners.
Definition: MotionPlanner.h:61
Vector Config
an alias for Vector
Definition: RobotKinematics3D.h:14
Motion planning configuration space base class. The configuration space implements an interpolation s...
Definition: CSpace.h:34
A sequence of locally planned paths between milestones.
Definition: planning/Path.h:15
A uniform abstract interface to point location data structures. The point locator operators in-place ...
Definition: PointLocation.h:12
A tree-based randomized planner that extends the roadmap by sampling the neighborhood of existing sam...
Definition: MotionPlanner.h:113
A tree graph structure, represented directly at the node level.
Definition: Tree.h:25
A base roadmap planner class.
Definition: MotionPlanner.h:23
Definition: MotionPlanner.h:64
Real delta
Neighborhood distance.
Definition: MotionPlanner.h:125
A single-query RRT (Rapidly-Exploring Random Tree) planner.
Definition: MotionPlanner.h:155
std::vector< Real > weights
Node selection weights.
Definition: MotionPlanner.h:127
A basic RRT (Rapidly-Exploring Random Tree) planner.
Definition: MotionPlanner.h:137