KrisLibrary  1.0.0
AnyMotionPlanner.h
1 #ifndef ANY_MOTION_PLANNER_H
2 #define ANY_MOTION_PLANNER_H
3 
4 #include <KrisLibrary/Logger.h>
5 #include "MotionPlanner.h"
6 
7 class TiXmlElement;
8 
9 //forward declarations
10 class HaltingCondition;
14 class PropertyMap;
15 
24 {
25  public:
28  bool LoadJSON(const std::string& str);
30  std::string SaveJSON() const;
31 
35  int maxIters;
37  Real timeLimit;
42  Real costImprovementThreshold;
43 };
44 
67 {
68  public:
70 
72  virtual ~MotionPlannerInterface() {}
76  virtual std::string Plan(MilestonePath& path,const HaltingCondition& cond);
78  virtual int PlanMore()=0;
80  virtual void PlanMore(int numIters) { for(int i=0;i<numIters;i++) PlanMore(); }
82  virtual int NumIterations() const=0;
84  virtual int NumMilestones() const=0;
86  virtual int NumComponents() const=0;
88  virtual bool CanAddMilestone() const { return false; }
90  virtual int AddMilestone(const Config& q)=0;
92  virtual void GetMilestone(int,Config& q)=0;
94  virtual void ConnectHint(int m) { }
96  virtual bool ConnectHint(int ma,int mb) { return false; }
98  virtual bool IsConnected(int ma,int mb) const=0;
101  virtual bool IsPointToPoint() const { return true; }
103  virtual bool IsOptimizing() const { return false; }
106  virtual bool CanUseObjective() const { return false; }
108  virtual void SetObjective(std::shared_ptr<ObjectiveFunctionalBase> obj) {}
110  virtual bool IsLazy() const { return false; }
115  virtual bool IsLazyConnected(int ma,int mb) const { return IsConnected(ma,mb); }
120  virtual bool CheckPath(int ma,int mb) { return false; }
122  virtual int GetClosestMilestone(const Config& q);
127  virtual void GetPath(int ma,int mb,MilestonePath& path)=0;
134  virtual Real GetOptimalPath(int ma,const std::vector<int>& mb,MilestonePath& path) { return Inf; }
136  virtual bool IsSolved() { return IsConnected(0,1); }
140  virtual void GetSolution(MilestonePath& path) { return GetPath(0,1,path); }
142  virtual void GetRoadmap(Roadmap& roadmap) const {}
144  virtual void GetStats(PropertyMap& stats) const;
145 };
146 
147 
152 {
153  public:
156  MotionPlanningProblem(CSpace* space,const Config& a,const Config& b);
158  MotionPlanningProblem(CSpace* space,const Config& a,CSet* goalSet);
160  MotionPlanningProblem(CSpace* space,CSet* startSet,CSet* goalSet);
162  MotionPlanningProblem(CSpace* space,const Config& a,std::shared_ptr<ObjectiveFunctionalBase> objective);
163 
164  CSpace* space;
166  Config qstart,qgoal;
168  CSet *startSet, *goalSet;
170  std::shared_ptr<ObjectiveFunctionalBase> objective;
171 };
172 
258 {
259  public:
261  virtual ~MotionPlannerFactory() {}
263  virtual MotionPlannerInterface* Create(const MotionPlanningProblem& problem);
265  virtual MotionPlannerInterface* Create(CSpace* space);
267  virtual MotionPlannerInterface* Create(CSpace* space,const Config& a,const Config& b);
269  virtual MotionPlannerInterface* Create(CSpace* space,const Config& a,CSet* goalSet);
271  virtual MotionPlannerInterface* CreateRaw(CSpace* space);
273  virtual MotionPlannerInterface* ApplyModifiers(MotionPlannerInterface*,const MotionPlanningProblem& problem);
275  bool Load(TiXmlElement* e);
277  bool Save(TiXmlElement* e);
279  bool LoadJSON(const std::string& str);
281  std::string SaveJSON() const;
282 
283  std::string type;
284  int knn;
287  bool ignoreConnectedComponents; //for PRM (default false)
291  bool useGrid;
294  std::string pointLocation;
295  bool storeEdges;
296  bool shortcut;
297  bool restart;
298  std::string restartTermCond;
299 };
300 
301 
302 
303 #endif
std::shared_ptr< ObjectiveFunctionalBase > objective
Non-NULL if you&#39;d like to optimize some objective function.
Definition: AnyMotionPlanner.h:170
bool useGrid
for SBL, SBLPRT (default true): for SBL, uses grid-based random point selection
Definition: AnyMotionPlanner.h:291
virtual bool IsPointToPoint() const
Definition: AnyMotionPlanner.h:101
bool restart
true if you wish to restart the planner to get better paths with the remaining time (default false) ...
Definition: AnyMotionPlanner.h:297
virtual bool IsLazyConnected(int ma, int mb) const
Definition: AnyMotionPlanner.h:115
int perturbationIters
for SBL (default 5)
Definition: AnyMotionPlanner.h:289
virtual void ConnectHint(int m)
Manual indication that the milestone is a good candidate for connecting.
Definition: AnyMotionPlanner.h:94
std::string restartTermCond
used if restart is true, JSON string defining termination condition (default "{foundSolution:1;maxIte...
Definition: AnyMotionPlanner.h:298
virtual bool IsLazy() const
Returns true if this planner has lazy semantics.
Definition: AnyMotionPlanner.h:110
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:39
int randomizeFrequency
for SBL, SBLPRT (default 50): how often the grid projection is randomly perturbed ...
Definition: AnyMotionPlanner.h:293
virtual void SetObjective(std::shared_ptr< ObjectiveFunctionalBase > obj)
Must be implemented if CanUseObjective() = true.
Definition: AnyMotionPlanner.h:108
Real suboptimalityFactor
for RRT*, LazyPRM*, LazyRRG* (default 0)
Definition: AnyMotionPlanner.h:286
bool bidirectional
for RRT (default true)
Definition: AnyMotionPlanner.h:290
bool shortcut
true if you wish to perform shortcutting afterwards (default false)
Definition: AnyMotionPlanner.h:296
virtual bool IsOptimizing() const
Returns true if this planner can optimize the path after the first solution.
Definition: AnyMotionPlanner.h:103
A sequence of locally planned paths between milestones.
Definition: planning/Path.h:18
std::string SaveJSON() const
Save settings to JSON string.
Definition: AnyMotionPlanner.cpp:275
virtual void PlanMore(int numIters)
Performs numIters planning units.
Definition: AnyMotionPlanner.h:80
Config qstart
Non-empty if the start/end point is given.
Definition: AnyMotionPlanner.h:166
Real connectionThreshold
for PRM,RRT,SBL,SBLPRT,RRT*,PRM*,LazyPRM*,LazyRRG* (default Inf)
Definition: AnyMotionPlanner.h:285
A motion planner creator.
Definition: AnyMotionPlanner.h:257
Real perturbationRadius
for Perturbation,EST,RRT,SBL,SBLPRT (default 0.1)
Definition: AnyMotionPlanner.h:288
int knn
for PRM (default 10)
Definition: AnyMotionPlanner.h:284
virtual Real GetOptimalPath(int ma, const std::vector< int > &mb, MilestonePath &path)
Definition: AnyMotionPlanner.h:134
int maxIters
Stop when this number of iterations have been computed (default 1000)
Definition: AnyMotionPlanner.h:35
An abstract class for a sample-based motion planner.
Definition: AnyMotionPlanner.h:66
virtual bool IsSolved()
For single-query planners, returns true if the start and goal are connected.
Definition: AnyMotionPlanner.h:136
A structure to specify the space, endpoints, and cost function of a motion planning problem...
Definition: AnyMotionPlanner.h:151
CSet * startSet
Non-NULL if the start/end point must be in a given set.
Definition: AnyMotionPlanner.h:168
virtual bool CanAddMilestone() const
Returns true if a milestone can currently be added.
Definition: AnyMotionPlanner.h:88
A termination condition for a planner. Supports max iteration count, time limit, absolute cost...
Definition: AnyMotionPlanner.h:23
The logging system used in KrisLibrary.
Real gridResolution
for SBL, SBLPRT, FMM, FMM* (default 0): if nonzero, for SBL, specifies point selection grid size (def...
Definition: AnyMotionPlanner.h:292
virtual bool CheckPath(int ma, int mb)
Definition: AnyMotionPlanner.h:120
std::string pointLocation
for PRM, RRT*, PRM*, LazyPRM*, LazyRRG* (default ""): specifies a point location data structure ("ran...
Definition: AnyMotionPlanner.h:294
Real timeLimit
Stop when this time limit (in seconds) has expired (default Inf)
Definition: AnyMotionPlanner.h:37
virtual void GetRoadmap(Roadmap &roadmap) const
Returns a full-blown roadmap representation of the roadmap.
Definition: AnyMotionPlanner.h:142
virtual void GetSolution(MilestonePath &path)
Definition: AnyMotionPlanner.h:140
A simple map from keys to values.
Definition: PropertyMap.h:27
Real costImprovementPeriod
Stop when the solution cost improvement over the given period of time decreases below costImprovement...
Definition: AnyMotionPlanner.h:41
virtual bool CanUseObjective() const
Definition: AnyMotionPlanner.h:106
virtual bool ConnectHint(int ma, int mb)
Manual indication that the milestones are good candidates for connecting.
Definition: AnyMotionPlanner.h:96
Real costThreshold
Stop when the solution cost decreases below the threshold (default 0)
Definition: AnyMotionPlanner.h:39
bool storeEdges
true if local planner data is stored during planning (false may save memory, default) ...
Definition: AnyMotionPlanner.h:295
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
bool foundSolution
Stop on the first solution found.
Definition: AnyMotionPlanner.h:33
Definition: PropertyMap.cpp:9
bool LoadJSON(const std::string &str)
Load settings from JSON string.
Definition: AnyMotionPlanner.cpp:262
A specialization of a Graph to be an undirected graph.
Definition: UndirectedGraph.h:17