BiEST.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_BIEST_
38 #define OMPL_GEOMETRIC_PLANNERS_EST_BIEST_
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 BiEST : public base::Planner
67  {
68  public:
69 
72 
73  virtual ~BiEST();
74 
76 
77  virtual void clear();
78 
84  void setRange(double distance)
85  {
86  maxDistance_ = distance;
87 
88  // Make the neighborhood radius smaller than sampling range to
89  // keep probabilities relatively high for rejection sampling
91  }
92 
94  double getRange() const
95  {
96  return maxDistance_;
97  }
98 
99  virtual void setup();
100 
101  virtual void getPlannerData(base::PlannerData &data) const;
102 
103  protected:
104 
106  class Motion
107  {
108  public:
109 
110  Motion() : state(NULL), parent(NULL), element(NULL), root(NULL)
111  {
112  }
113 
115  Motion(const base::SpaceInformationPtr &si) : state(si->allocState()), parent(NULL), element(NULL), root(NULL)
116  {
117  }
118 
119  ~Motion()
120  {
121  }
122 
125 
128 
131 
134  };
135 
137  double distanceFunction(const Motion *a, const Motion *b) const
138  {
139  return si_->distance(a->state, b->state);
140  }
141 
143  std::shared_ptr< NearestNeighbors<Motion*> > nnStart_;
144  std::shared_ptr< NearestNeighbors<Motion*> > nnGoal_;
145 
147  std::vector<Motion*> startMotions_;
148  std::vector<Motion*> goalMotions_;
149 
152  PDF<Motion*> goalPdf_;
153 
155  void freeMemory();
156 
158  void addMotion(Motion* motion, std::vector<Motion*>& motions,
159  PDF<Motion*>& pdf, std::shared_ptr< NearestNeighbors<Motion*> > nn,
160  const std::vector<Motion*>& neighbors);
161 
164 
166  double maxDistance_;
167 
170 
173 
175  std::pair<base::State*, base::State*> connectionPoint_;
176  };
177 
178  }
179 }
180 
181 #endif
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique...
Definition: PlannerData.h:163
base::ValidStateSamplerPtr sampler_
Valid state sampler.
Definition: BiEST.h:163
PDF< Motion * > startPdf_
The probability distribution function over states in each tree.
Definition: BiEST.h:151
A shared pointer wrapper for ompl::base::ValidStateSampler.
Motion * parent
The parent motion in the exploration tree.
Definition: BiEST.h:127
RNG rng_
The random number generator.
Definition: BiEST.h:172
std::shared_ptr< NearestNeighbors< Motion * > > nnStart_
A nearest-neighbors datastructure containing the tree of motions.
Definition: BiEST.h:143
Encapsulate a termination condition for a motion planner. Planners will call operator() to decide whe...
std::vector< Motion * > startMotions_
The set of all states in the start tree.
Definition: BiEST.h:147
double maxDistance_
The maximum length of a motion to be added to a tree.
Definition: BiEST.h:166
const base::State * root
The root node of the tree this motion is in.
Definition: BiEST.h:133
void freeMemory()
Free the memory allocated by this planner.
Definition: BiEST.cpp:99
A container that supports probabilistic sampling over weighted data.
Definition: PDF.h:48
double distanceFunction(const Motion *a, const Motion *b) const
Compute distance between motions (actually distance between contained states)
Definition: BiEST.h:137
Main namespace. Contains everything in this library.
Definition: Cost.h:42
Random number generation. An instance of this class cannot be used by multiple threads at once (membe...
Definition: RandomNumbers.h:58
The definition of a motion.
Definition: BiEST.h:106
Base class for a planner.
Definition: Planner.h:230
base::State * state
The state contained by the motion.
Definition: BiEST.h:124
BiEST(const base::SpaceInformationPtr &si)
Constructor.
Definition: BiEST.cpp:43
double nbrhoodRadius_
The radius considered for neighborhood.
Definition: BiEST.h:169
A class to store the exit status of Planner::solve()
Definition: PlannerStatus.h:48
A shared pointer wrapper for ompl::base::SpaceInformation.
Definition of an abstract state.
Definition: State.h:50
double getRange() const
Get the range the planner is using.
Definition: BiEST.h:94
A class that will hold data contained in the PDF.
Definition: PDF.h:53
Abstract representation of a container that can perform nearest neighbors queries.
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: BiEST.cpp:292
void addMotion(Motion *motion, std::vector< Motion * > &motions, PDF< Motion * > &pdf, std::shared_ptr< NearestNeighbors< Motion * > > nn, const std::vector< Motion * > &neighbors)
Add a motion to the exploration tree.
Definition: BiEST.cpp:275
Bi-directional Expansive Space Trees.
Definition: BiEST.h:66
virtual void clear()
Clear all internal datastructures. Planner settings are not affected. Subsequent calls to solve() wil...
Definition: BiEST.cpp:80
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: BiEST.cpp:116
Motion(const base::SpaceInformationPtr &si)
Constructor that allocates memory for the state.
Definition: BiEST.h:115
void setRange(double distance)
Set the range the planner is supposed to use.
Definition: BiEST.h:84
SpaceInformationPtr si_
The space information for which planning is done.
Definition: Planner.h:398
virtual void setup()
Perform extra configuration steps, if needed. This call will also issue a call to ompl::base::SpaceIn...
Definition: BiEST.cpp:58
std::pair< base::State *, base::State * > connectionPoint_
The pair of states in each tree connected during planning. Used for PlannerData computation.
Definition: BiEST.h:175
PDF< Motion * >::Element * element
A pointer to the corresponding element in the probability distribution function.
Definition: BiEST.h:130