RLRT.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 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_RLRT_RLRT_H_
38 #define OMPL_GEOMETRIC_PLANNERS_RLRT_RLRT_H_
39 
40 #include "ompl/geometric/planners/PlannerIncludes.h"
41 #include <vector>
42 
43 namespace ompl
44 {
45  namespace geometric
46  {
62  class RLRT : public base::Planner
64  {
65  public:
66  RLRT(const base::SpaceInformationPtr &si);
67 
68  virtual ~RLRT();
69 
70  virtual void getPlannerData(base::PlannerData &data) const;
71 
72  virtual base::PlannerStatus solve(const base::PlannerTerminationCondition &ptc);
73 
74  virtual void clear();
75 
84  void setGoalBias(double goalBias)
85  {
86  goalBias_ = goalBias;
87  }
88 
90  double getGoalBias() const
91  {
92  return goalBias_;
93  }
94 
96  void setRange(double distance)
97  {
98  range_ = distance;
99  }
100 
102  double getRange() const
103  {
104  return range_;
105  }
106 
110  bool getKeepLast() const
111  {
112  return keepLast_;
113  }
114 
119  void setKeepLast(bool keepLast)
120  {
121  keepLast_ = keepLast;
122  }
123 
124  virtual void setup();
125 
126  protected:
128  class Motion
129  {
130  public:
132  Motion(const base::SpaceInformationPtr &si) : state(si->allocState())
133  {
134  }
135 
136  ~Motion() = default;
137 
139  base::State *state{nullptr};
140 
142  Motion *parent{nullptr};
143  };
144 
146  void freeMemory();
147 
149  base::StateSamplerPtr sampler_;
150 
153  double goalBias_{0.05};
154 
156  double range_{0.};
157 
160  bool keepLast_{false};
161 
163  RNG rng_;
164 
167  Motion *lastGoalMotion_{nullptr};
168 
169  std::vector<Motion *> motions_;
170  };
171 
172  } // namespace geometric
173 } // namespace ompl
174 
175 #endif
base::StateSamplerPtr sampler_
State sampler.
Definition: RLRT.h:245
void setGoalBias(double goalBias)
Set the goal bias In the process of randomly selecting states in the state space to attempt to go tow...
Definition: RLRT.h:180
virtual void setup()
Perform extra configuration steps, if needed. This call will also issue a call to ompl::base::SpaceIn...
Definition: RLRT.cpp:65
void setKeepLast(bool keepLast)
Set whether the planner will use the range or keep last heuristic. If keepLast = false,...
Definition: RLRT.h:215
Motion(const base::SpaceInformationPtr &si)
Constructor that allocates memory for the state.
Definition: RLRT.h:228
double range_
The maximum length of a motion to be added to a tree.
Definition: RLRT.h:252
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: RLRT.cpp:88
Motion * lastGoalMotion_
The most recent goal motion. Used for PlannerData computation.
Definition: RLRT.h:263
Motion * parent
The parent motion in the exploration tree.
Definition: RLRT.h:238
virtual void clear()
Clear all internal datastructures. Planner settings are not affected. Subsequent calls to solve() wil...
Definition: RLRT.cpp:57
double goalBias_
The fraction of time the goal is picked as the state to expand towards (if such a state is available)...
Definition: RLRT.h:249
base::State * state
The state contained by the motion.
Definition: RLRT.h:235
void setRange(double distance)
Set the maximum distance between states in the tree.
Definition: RLRT.h:192
bool getKeepLast() const
If true, the planner will not have the range limitation. Instead, if a collision is detected,...
Definition: RLRT.h:206
bool keepLast_
If true, the planner will retain the last valid state during local planner. Default is false.
Definition: RLRT.h:256
void freeMemory()
Free the memory allocated by this planner.
Definition: RLRT.cpp:76
double getGoalBias() const
Get the goal bias the planner is using.
Definition: RLRT.h:186
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: RLRT.cpp:226
RNG rng_
The random number generator.
Definition: RLRT.h:259
Main namespace. Contains everything in this library.
double getRange() const
Get the maximum distance between states in the tree.
Definition: RLRT.h:198