EST.h
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2015, Rice University
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of the Rice University nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34 
35 /* Author: Ryan Luna */
36 
37 #ifndef OMPL_GEOMETRIC_PLANNERS_EST_EST_
38 #define OMPL_GEOMETRIC_PLANNERS_EST_EST_
39 
40 #include "ompl/geometric/planners/PlannerIncludes.h"
41 #include "ompl/datastructures/NearestNeighbors.h"
42 #include "ompl/datastructures/PDF.h"
43 #include <vector>
44 
45 namespace ompl
46 {
47 
48  namespace geometric
49  {
50 
66  class EST : public base::Planner
67  {
68  public:
69 
71  EST(const base::SpaceInformationPtr &si);
72 
73  virtual ~EST();
74 
76 
77  virtual void clear();
78 
86  void setGoalBias(double goalBias)
87  {
88  goalBias_ = goalBias;
89  }
90 
92  double getGoalBias() const
93  {
94  return goalBias_;
95  }
96 
102  void setRange(double distance)
103  {
104  maxDistance_ = distance;
105  }
106 
108  double getRange() const
109  {
110  return maxDistance_;
111  }
112 
113  virtual void setup();
114 
115  virtual void getPlannerData(base::PlannerData &data) const;
116 
117  protected:
118 
120  class Motion
121  {
122  public:
123 
124  Motion() : state(NULL), parent(NULL), element(NULL)
125  {
126  }
127 
129  Motion(const base::SpaceInformationPtr &si) : state(si->allocState()), parent(NULL), element(NULL)
130  {
131  }
132 
133  ~Motion()
134  {
135  }
136 
139 
142 
145  };
146 
148  double distanceFunction(const Motion *a, const Motion *b) const
149  {
150  return si_->distance(a->state, b->state);
151  }
152 
154  std::shared_ptr< NearestNeighbors<Motion*> > nn_;
155 
157  std::vector<Motion*> motions_;
158 
161 
163  void freeMemory();
164 
166  void addMotion(Motion *motion, const std::vector<Motion*>& neighbors);
167 
170 
172  double goalBias_;
173 
175  double maxDistance_;
176 
179 
182 
185  };
186 
187  }
188 }
189 
190 #endif
RNG rng_
The random number generator.
Definition: EST.h:181
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique...
Definition: PlannerData.h:163
void addMotion(Motion *motion, const std::vector< Motion * > &neighbors)
Add a motion to the exploration tree.
Definition: EST.cpp:229
Motion * lastGoalMotion_
The most recent goal motion. Used for PlannerData computation.
Definition: EST.h:184
A shared pointer wrapper for ompl::base::ValidStateSampler.
double maxDistance_
The maximum length of a motion to be added to a tree.
Definition: EST.h:175
base::ValidStateSamplerPtr sampler_
Valid state sampler.
Definition: EST.h:169
Encapsulate a termination condition for a motion planner. Planners will call operator() to decide whe...
double nbrhoodRadius_
The radius considered for neighborhood.
Definition: EST.h:178
virtual void setup()
Perform extra configuration steps, if needed. This call will also issue a call to ompl::base::SpaceIn...
Definition: EST.cpp:60
base::State * state
The state contained by the motion.
Definition: EST.h:138
The definition of a motion.
Definition: EST.h:120
A container that supports probabilistic sampling over weighted data.
Definition: PDF.h:48
double getRange() const
Get the range the planner is using.
Definition: EST.h:108
Random number generation. An instance of this class cannot be used by multiple threads at once (membe...
Definition: RandomNumbers.h:58
std::vector< Motion * > motions_
The set of all states in the tree.
Definition: EST.h:157
PDF< Motion * > pdf_
The probability distribution function over states in the tree.
Definition: EST.h:160
Base class for a planner.
Definition: Planner.h:230
PDF< Motion * >::Element * element
A pointer to the corresponding element in the probability distribution function.
Definition: EST.h:144
Motion(const base::SpaceInformationPtr &si)
Constructor that allocates memory for the state.
Definition: EST.h:129
virtual void getPlannerData(base::PlannerData &data) const
Get information about the current run of the motion planner. Repeated calls to this function will upd...
Definition: EST.cpp:245
A class to store the exit status of Planner::solve()
Definition: PlannerStatus.h:48
virtual base::PlannerStatus solve(const base::PlannerTerminationCondition &ptc)
Function that can solve the motion planning problem. This function can be called multiple times on th...
Definition: EST.cpp:97
A shared pointer wrapper for ompl::base::SpaceInformation.
Definition of an abstract state.
Definition: State.h:50
void setRange(double distance)
Set the range the planner is supposed to use.
Definition: EST.h:102
A class that will hold data contained in the PDF.
Definition: PDF.h:53
std::shared_ptr< NearestNeighbors< Motion * > > nn_
A nearest-neighbors datastructure containing the tree of motions.
Definition: EST.h:154
virtual void clear()
Clear all internal datastructures. Planner settings are not affected. Subsequent calls to solve() wil...
Definition: EST.cpp:74
double getGoalBias() const
Get the goal bias the planner is using.
Definition: EST.h:92
void freeMemory()
Free the memory allocated by this planner.
Definition: EST.cpp:87
void setGoalBias(double goalBias)
In the process of randomly selecting states in the state space to attempt to go towards, the algorithm may in fact choose the actual goal state, if it knows it, with some probability. This probability is a real number between 0.0 and 1.0; its value should usually be around 0.05 and should not be too large. It is probably a good idea to use the default value.
Definition: EST.h:86
double distanceFunction(const Motion *a, const Motion *b) const
Compute distance between motions (actually distance between contained states)
Definition: EST.h:148
EST(const base::SpaceInformationPtr &si)
Constructor.
Definition: EST.cpp:43
Motion * parent
The parent motion in the exploration tree.
Definition: EST.h:141
SpaceInformationPtr si_
The space information for which planning is done.
Definition: Planner.h:398
Expansive Space Trees.
Definition: EST.h:66
double goalBias_
The fraction of time the goal is picked as the state to expand towards (if such a state is available)...
Definition: EST.h:172