Parasol Planning Library (PPL)
EET.h
Go to the documentation of this file.
1 #ifndef PMPL_EET_H_
2 #define PMPL_EET_H_
3 
4 #include "BasicRRTStrategy.h"
6 
7 /* HYPERPARAMETER NOTES THAT ANANYA NEEDS TO MOVE
8 
9 1. THE MINIMUM RADIUS IS HIGHLY DEPENDENT ON THE CLEARANCE OF
10  THE AREA. LOWER CLEARANCE, YOU NEED TO STEP DOWN THE MIN RADIUS
11  BY AN ORDER OF MAGNITUDE OR SO.
12 2. THE MINIMUM RADIUS IS HIGHLY FINNICKY. IN ONE TEST, MIN RADIUS
13  0.1 WAS TOO BIG, 0.01 TOOK FOREVER (TOO SMALL) AND 0.05 WAS JUST RIGHT
14 3. WHEN CHANGING MIN RADIUS YOU ALSO NEED TO CHANGE NUM SAMPLES
15 TAKEN ON SPHERE. RADIUS INCREASES, NUM POINTS SHOULD INCREASE (I THINK)
16 
17 */
18 
19 
20 class EET : public BasicRRTStrategy {
21  public:
22  typedef typename mathtool::Point3d Point;
25  typedef typename RoadmapType::VID VID;
26  typedef typename RoadmapType::EID EID;
28 
29 
30  // Constructors
31  EET();
32  EET(XMLNode& _node);
33  // virtual ~EET() = default;
34 
35  protected:
36  // Standard lifecycle functions
37  virtual void Initialize() override;
38  virtual void Iterate() override;
39 
40 
41  // WAVEFRONT expansion functions
42  void Wavefront();
43  double DistanceToObstacles(Point _p);
44  double Distance(Point _p1, Point _p2);
45 
46  // overrides of BasicRRT functions
47  virtual Cfg SelectTarget() override;
48  virtual VID ExpandTree(const VID _nearestVID, const Cfg& _target) override;
49 
50 
51  // Start and goal points (not cfgs)
54 
55  // Algorithm parameters (taken from XML or hard-defaulted here).
57  double m_minSphereRadius{0.001};
58  double m_defaultExploreExploit{1./3.}; // "gamma". Default value provided in paper.
60  double m_controlManipulation{0.01}; // "alpha". Default value provided in paper.
61  double m_pGoalState{0.5}; // "rho". Default value provided in paper.
62 
63  // Saved labels from XML.
66 
67  // Data structure Sphere, for wavefront expansion and guidance.
68  struct Sphere{
70  double radius;
71  double priority;
74 
75  Sphere(const Point _center, double _radius, double _priority, VID _parentVID)
76  : center(_center), radius(_radius), priority(_priority), parentVID(_parentVID) {
77  // Priority=distance to goal(ish). Always > 0.
78  // So we want the lower numbers to be processed first.
79  priority *= -1;
80  }
81 
82  Sphere() {
83  radius = 0;
84  priority = 0;
87  center = Point();
88  }
89 
90  // Is this sphere some sort of dumb object?
91  bool isEmpty() {
92  return radius == 0
93  && priority == 0
96  && center == Point();
97  }
98 
99  /* The below three are required for us to use GenericStateGraph. */
100  bool operator==(const Sphere& _other) const {
101  return center == _other.center
102  && radius == _other.radius
103  && priority == _other.priority;
104  }
105 
106  bool operator!=(const Sphere& _other) const {
107  return !(*this == _other);
108  }
109 
110  friend std::ostream& operator<<(std::ostream& _os, const Sphere& _vertex) {
111  _os << _vertex.center[0] << " "
112  << _vertex.center[1] << " "
113  << _vertex.center[2];
114  return _os;
115  }
116 
117  /* For pqueue. */
118  bool operator < (const Sphere& rhs) const {
119  return priority < rhs.priority;
120  }
121  };
122 
123  /* WAVEFRONT expansion structures. */
124  // Tree for actual WAVEFRONT expansion.
126  // Keep track of the spheres and their VIDs in the above graph.
127  std::unordered_map<VID, Sphere> wavefrontExpansionSpheres;
128  // Root of the Wavefront.
130 
131  private:
132 
138  Sphere InsertSphereIntoPQ(Point pCenter,
139  VID parentVID,
140  std::priority_queue<Sphere>& q);
141 
142  Sphere goalSphere; // The sphere that contains the goal.
143  Sphere currentSphere; // The sphere we are currently investigating. (In Iterate())
144 
145  // More (mutable) algorithm parameters.
146  double exploreExploitBias; // "sigma"
147 
148  // Is environment 3D?
149  bool threeD{true};
150 };
151 
152 #endif
#define INVALID_VID
Definition: GenericStateGraph.h:23
Definition: BasicRRTStrategy.h:48
std::string m_samplerLabel
The sampler label.
Definition: BasicRRTStrategy.h:197
size_t VID
Definition: BasicRRTStrategy.h:55
Definition: Cfg.h:38
Definition: Weight.h:36
Definition: EET.h:20
RoadmapType::EID EID
Definition: EET.h:26
EET()
Definition: EET.cpp:13
virtual void Initialize() override
Definition: EET.cpp:47
std::string m_gaussianSamplerLabel
Definition: EET.h:65
virtual void Iterate() override
Execute one iteration of the strategy.
Definition: EET.cpp:71
MPBaseObject::RoadmapType RoadmapType
Definition: EET.h:24
double m_wavefrontExplorationBias
Definition: EET.h:59
Sphere wavefrontRoot
Definition: EET.h:129
RoadmapType::VertexSet VertexSet
Definition: EET.h:27
std::string m_samplerLabel
Definition: EET.h:64
VID startVID
Definition: EET.h:53
mathtool::Point3d Point
Definition: EET.h:22
virtual VID ExpandTree(const VID _nearestVID, const Cfg &_target) override
Definition: EET.cpp:414
int m_nSphereSamples
Definition: EET.h:56
double DistanceToObstacles(Point _p)
Definition: EET.cpp:281
RoadmapType::VID VID
Definition: EET.h:25
double Distance(Point _p1, Point _p2)
Definition: EET.cpp:267
double m_defaultExploreExploit
Definition: EET.h:58
double m_minSphereRadius
Definition: EET.h:57
double m_controlManipulation
Definition: EET.h:60
double m_pGoalState
Definition: EET.h:61
virtual Cfg SelectTarget() override
Get a random configuration to grow towards.
Definition: EET.cpp:359
GenericStateGraph< Sphere, std::vector< Sphere > > wavefrontExpansion
Definition: EET.h:125
Point pGoal
Definition: EET.h:52
std::unordered_map< VID, Sphere > wavefrontExpansionSpheres
Definition: EET.h:127
void Wavefront()
Definition: EET.cpp:143
MPBaseObject::WeightType WeightType
Definition: EET.h:23
Definition: GenericStateGraph.h:67
STAPLGraph::vertex_descriptor VID
Definition: GenericStateGraph.h:83
STAPLGraph::edge_descriptor EID
Definition: GenericStateGraph.h:84
std::unordered_set< VID > VertexSet
Definition: GenericStateGraph.h:86
Definition: XMLNode.h:27
Definition: EET.h:68
bool operator!=(const Sphere &_other) const
Definition: EET.h:106
VID parentVID
Definition: EET.h:73
Point center
Definition: EET.h:69
bool operator==(const Sphere &_other) const
Definition: EET.h:100
Sphere(const Point _center, double _radius, double _priority, VID _parentVID)
Definition: EET.h:75
bool isEmpty()
Definition: EET.h:91
double priority
Definition: EET.h:71
friend std::ostream & operator<<(std::ostream &_os, const Sphere &_vertex)
Definition: EET.h:110
VID wavefrontVID
Definition: EET.h:72
bool operator<(const Sphere &rhs) const
Definition: EET.h:118
Sphere()
Definition: EET.h:82
double radius
Definition: EET.h:70