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  namespace geometric
48  {
65  class BiEST : public base::Planner
66  {
67  public:
70 
71  ~BiEST() override;
72 
74 
75  void clear() override;
76 
82  void setRange(double distance)
83  {
84  maxDistance_ = distance;
85 
86  // Make the neighborhood radius smaller than sampling range to
87  // keep probabilities relatively high for rejection sampling
89  }
90 
92  double getRange() const
93  {
94  return maxDistance_;
95  }
96 
97  void setup() override;
98 
99  void getPlannerData(base::PlannerData &data) const override;
100 
101  protected:
103  class Motion
104  {
105  public:
106  Motion() : state(nullptr), parent(nullptr), element(nullptr), root(nullptr)
107  {
108  }
109 
112  : state(si->allocState()), parent(nullptr), element(nullptr), root(nullptr)
113  {
114  }
115 
116  ~Motion() = default;
117 
120 
123 
126 
129  };
130 
132  double distanceFunction(const Motion *a, const Motion *b) const
133  {
134  return si_->distance(a->state, b->state);
135  }
136 
138  std::shared_ptr<NearestNeighbors<Motion *>> nnStart_;
139  std::shared_ptr<NearestNeighbors<Motion *>> nnGoal_;
140 
142  std::vector<Motion *> startMotions_;
143  std::vector<Motion *> goalMotions_;
144 
147  PDF<Motion *> goalPdf_;
148 
150  void freeMemory();
151 
153  void addMotion(Motion *motion, std::vector<Motion *> &motions, PDF<Motion *> &pdf,
154  const std::shared_ptr<NearestNeighbors<Motion *>> &nn,
155  const std::vector<Motion *> &neighbors);
156 
159 
161  double maxDistance_;
162 
165 
168 
170  std::pair<base::State *, base::State *> connectionPoint_;
171  };
172  }
173 }
174 
175 #endif
PDF< Motion * >::Element * element
A pointer to the corresponding element in the probability distribution function.
Definition: BiEST.h:125
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique...
Definition: PlannerData.h:174
std::vector< Motion * > startMotions_
The set of all states in the start tree.
Definition: BiEST.h:142
base::ValidStateSamplerPtr sampler_
Valid state sampler.
Definition: BiEST.h:158
A shared pointer wrapper for ompl::base::ValidStateSampler.
double getRange() const
Get the range the planner is using.
Definition: BiEST.h:92
Motion * parent
The parent motion in the exploration tree.
Definition: BiEST.h:122
RNG rng_
The random number generator.
Definition: BiEST.h:167
Encapsulate a termination condition for a motion planner. Planners will call operator() to decide whe...
double maxDistance_
The maximum length of a motion to be added to a tree.
Definition: BiEST.h:161
const base::State * root
The root node of the tree this motion is in.
Definition: BiEST.h:128
void freeMemory()
Free the memory allocated by this planner.
Definition: BiEST.cpp:105
A container that supports probabilistic sampling over weighted data.
Definition: PDF.h:48
Main namespace. Contains everything in this library.
Definition: AppBase.h:21
Random number generation. An instance of this class cannot be used by multiple threads at once (membe...
Definition: RandomNumbers.h:58
void setup() override
Perform extra configuration steps, if needed. This call will also issue a call to ompl::base::SpaceIn...
Definition: BiEST.cpp:58
The definition of a motion.
Definition: BiEST.h:103
Base class for a planner.
Definition: Planner.h:232
base::State * state
The state contained by the motion.
Definition: BiEST.h:119
base::PlannerStatus solve(const base::PlannerTerminationCondition &ptc) override
Function that can solve the motion planning problem. This function can be called multiple times on th...
Definition: BiEST.cpp:122
BiEST(const base::SpaceInformationPtr &si)
Constructor.
Definition: BiEST.cpp:43
double nbrhoodRadius_
The radius considered for neighborhood.
Definition: BiEST.h:164
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:49
A class that will hold data contained in the PDF.
Definition: PDF.h:52
Abstract representation of a container that can perform nearest neighbors queries.
void getPlannerData(base::PlannerData &data) const override
Get information about the current run of the motion planner. Repeated calls to this function will upd...
Definition: BiEST.cpp:301
void addMotion(Motion *motion, std::vector< Motion *> &motions, PDF< Motion *> &pdf, const std::shared_ptr< NearestNeighbors< Motion *>> &nn, const std::vector< Motion *> &neighbors)
Add a motion to the exploration tree.
Definition: BiEST.cpp:284
Bi-directional Expansive Space Trees.
Definition: BiEST.h:65
double distanceFunction(const Motion *a, const Motion *b) const
Compute distance between motions (actually distance between contained states)
Definition: BiEST.h:132
PDF< Motion * > startPdf_
The probability distribution function over states in each tree.
Definition: BiEST.h:146
void clear() override
Clear all internal datastructures. Planner settings are not affected. Subsequent calls to solve() wil...
Definition: BiEST.cpp:86
Motion(const base::SpaceInformationPtr &si)
Constructor that allocates memory for the state.
Definition: BiEST.h:111
std::pair< base::State *, base::State * > connectionPoint_
The pair of states in each tree connected during planning. Used for PlannerData computation.
Definition: BiEST.h:170
void setRange(double distance)
Set the range the planner is supposed to use.
Definition: BiEST.h:82
SpaceInformationPtr si_
The space information for which planning is done.
Definition: Planner.h:415
std::shared_ptr< NearestNeighbors< Motion * > > nnStart_
A nearest-neighbors datastructure containing the tree of motions.
Definition: BiEST.h:138