LazyRRT.h
1 
2 /*********************************************************************
3 * Software License Agreement (BSD License)
4 *
5 * Copyright (c) 2008, Willow Garage, Inc.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided
17 * with the distribution.
18 * * Neither the name of the Willow Garage nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 *********************************************************************/
35 
36 /* Author: Ioan Sucan */
37 
38 #ifndef OMPL_GEOMETRIC_PLANNERS_RRT_LAZY_RRT_
39 #define OMPL_GEOMETRIC_PLANNERS_RRT_LAZY_RRT_
40 
41 #include "ompl/geometric/planners/PlannerIncludes.h"
42 #include "ompl/datastructures/NearestNeighbors.h"
43 #include <vector>
44 
45 namespace ompl
46 {
47 
48  namespace geometric
49  {
50 
78  class LazyRRT : public base::Planner
79  {
80  public:
81 
84 
85  virtual ~LazyRRT();
86 
87  virtual void getPlannerData(base::PlannerData &data) const;
88 
90 
91  virtual void clear();
92 
102  void setGoalBias(double goalBias)
103  {
104  goalBias_ = goalBias;
105  }
106 
108  double getGoalBias() const
109  {
110  return goalBias_;
111  }
112 
118  void setRange(double distance)
119  {
120  maxDistance_ = distance;
121  }
122 
124  double getRange() const
125  {
126  return maxDistance_;
127  }
128 
130  template<template<typename T> class NN>
132  {
133  nn_.reset(new NN<Motion*>());
134  }
135 
136  virtual void setup();
137 
138  protected:
139 
141  class Motion
142  {
143  public:
144 
145  Motion() : state(NULL), parent(NULL), valid(false)
146  {
147  }
148 
150  Motion(const base::SpaceInformationPtr &si) : state(si->allocState()), parent(NULL), valid(false)
151  {
152  }
153 
154  ~Motion()
155  {
156  }
157 
160 
163 
165  bool valid;
166 
168  std::vector<Motion*> children;
169  };
170 
172  void freeMemory();
173 
175  void removeMotion(Motion *motion);
176 
178  double distanceFunction(const Motion *a, const Motion *b) const
179  {
180  return si_->distance(a->state, b->state);
181  }
182 
185 
187  boost::shared_ptr< NearestNeighbors<Motion*> > nn_;
188 
190  double goalBias_;
191 
193  double maxDistance_;
194 
197 
200 
201  };
202 
203  }
204 }
205 
206 #endif
void setNearestNeighbors()
Set a different nearest neighbors datastructure.
Definition: LazyRRT.h:131
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique...
Definition: PlannerData.h:164
double getRange() const
Get the range the planner is using.
Definition: LazyRRT.h:124
virtual void clear()
Clear all internal datastructures. Planner settings are not affected. Subsequent calls to solve() wil...
Definition: LazyRRT.cpp:69
void setGoalBias(double goalBias)
Set the goal biasing.
Definition: LazyRRT.h:102
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: LazyRRT.cpp:94
A boost shared pointer wrapper for ompl::base::StateSampler.
boost::shared_ptr< NearestNeighbors< Motion * > > nn_
A nearest-neighbors datastructure containing the tree of motions.
Definition: LazyRRT.h:187
Encapsulate a termination condition for a motion planner. Planners will call operator() to decide whe...
void removeMotion(Motion *motion)
Remove a motion from the tree datastructure.
Definition: LazyRRT.cpp:207
std::vector< Motion * > children
The set of motions that descend from this one.
Definition: LazyRRT.h:168
double maxDistance_
The maximum length of a motion to be added to a tree.
Definition: LazyRRT.h:193
Representation of a motion.
Definition: LazyRRT.h:141
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:54
Motion * lastGoalMotion_
The most recent goal motion. Used for PlannerData computation.
Definition: LazyRRT.h:199
void setRange(double distance)
Set the range the planner is supposed to use.
Definition: LazyRRT.h:118
Base class for a planner.
Definition: Planner.h:232
virtual void setup()
Perform extra configuration steps, if needed. This call will also issue a call to ompl::base::SpaceIn...
Definition: LazyRRT.cpp:58
double goalBias_
The fraction of time the goal is picked as the state to expand towards (if such a state is available)...
Definition: LazyRRT.h:190
A class to store the exit status of Planner::solve()
Definition: PlannerStatus.h:48
RNG rng_
The random number generator.
Definition: LazyRRT.h:196
A boost shared pointer wrapper for ompl::base::SpaceInformation.
double getGoalBias() const
Get the goal bias the planner is using.
Definition: LazyRRT.h:108
Definition of an abstract state.
Definition: State.h:50
base::State * state
The state contained by the motion.
Definition: LazyRRT.h:159
void freeMemory()
Free the memory allocated by this planner.
Definition: LazyRRT.cpp:79
bool valid
Flag indicating whether this motion has been validated.
Definition: LazyRRT.h:165
LazyRRT(const base::SpaceInformationPtr &si)
Constructor.
Definition: LazyRRT.cpp:42
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: LazyRRT.cpp:235
SpaceInformationPtr si_
The space information for which planning is done.
Definition: Planner.h:397
Motion * parent
The parent motion in the exploration tree.
Definition: LazyRRT.h:162
base::StateSamplerPtr sampler_
State sampler.
Definition: LazyRRT.h:184
Motion(const base::SpaceInformationPtr &si)
Constructor that allocates memory for the state.
Definition: LazyRRT.h:150
double distanceFunction(const Motion *a, const Motion *b) const
Compute distance between motions (actually distance between contained states)
Definition: LazyRRT.h:178