37 #ifndef OMPL_CONTRIB_LAZY_LBTRRT_
38 #define OMPL_CONTRIB_LAZY_LBTRRT_
40 #include "ompl/geometric/planners/PlannerIncludes.h"
41 #include "ompl/datastructures/NearestNeighbors.h"
42 #include "ompl/base/goals/GoalSampleableRegion.h"
43 #include "ompl/datastructures/LPAstarOnGraph.h"
50 #include <boost/graph/graph_traits.hpp>
51 #include <boost/graph/adjacency_list.hpp>
73 virtual void clear(
void);
112 template<
template<
typename T>
class NN>
115 nn_.reset(
new NN<Motion*>());
118 virtual void setup(
void);
128 std::string getIterationCount()
const
132 std::string getBestCost()
const
163 typedef boost::property<boost::edge_weight_t, double> WeightProperty;
164 typedef boost::adjacency_list< boost::vecS,
179 double operator()(std::size_t i)
181 double lb_estimate = (*(alg_->LPAstarLb_))(i);
182 if (lb_estimate != std::numeric_limits<double>::infinity())
196 : goal_(goal), idToMotionMap_(idToMotionMap)
199 double operator()(std::size_t i)
202 goal_->
isSatisfied(idToMotionMap_[i]->state_, &dist);
208 std::vector<Motion*> &idToMotionMap_;
223 return si_->distance(a, b);
227 return si_->distance(a->state_, b->state_);
231 return si_->checkMotion(a,b);
233 bool checkMotion(
const Motion *a,
const Motion *b)
const
235 return si_->checkMotion(a->state_, b->state_);
238 Motion* getMotion(std::size_t
id)
const
240 assert (idToMotionMap_.size() > id);
241 return idToMotionMap_[id];
243 void addVertex(
const Motion *a)
245 boost::add_vertex(a->id_, graphApx_);
246 boost::add_vertex(a->id_, graphLb_);
249 void addEdgeApx(Motion *a, Motion *b,
double c)
251 WeightProperty w (c);
252 boost::add_edge(a->id_, b->id_, w, graphApx_);
253 LPAstarApx_->insertEdge(a->id_, b->id_, c);
254 LPAstarApx_->insertEdge(b->id_, a->id_, c);
256 void addEdgeLb(
const Motion *a,
const Motion *b,
double c)
258 WeightProperty w (c);
259 boost::add_edge(a->id_, b->id_, w, graphLb_);
260 LPAstarLb_->insertEdge(a->id_, b->id_, c);
261 LPAstarLb_->insertEdge(b->id_, a->id_, c);
263 bool edgeExistsApx(std::size_t a, std::size_t b)
265 return boost::edge(a, b, graphApx_).second;
267 bool edgeExistsApx(
const Motion *a,
const Motion *b)
269 return edgeExistsApx(a->id_, b->id_);
271 bool edgeExistsLb(
const Motion *a,
const Motion *b)
273 return boost::edge(a->id_, b->id_, graphLb_).second;
275 void removeEdgeLb(
const Motion *a,
const Motion *b)
277 boost::remove_edge(a->id_, b->id_, graphLb_);
278 LPAstarLb_->removeEdge(a->id_, b->id_);
279 LPAstarLb_->removeEdge(b->id_, a->id_);
282 std::tuple<Motion*, base::State*, double> rrtExtend(
283 const base::GoalSampleableRegion *goal_s, base::State *xstate,
284 Motion *rmotion,
double &approxdif);
285 void rrt(
const base::PlannerTerminationCondition &ptc,
286 base::GoalSampleableRegion *goal_s, base::State *xstate,
287 Motion *rmotion,
double &approxdif);
288 Motion* createMotion(
const base::GoalSampleableRegion *goal_s,
const base::State *st);
289 Motion* createGoalMotion(
const base::GoalSampleableRegion *goal_s);
291 void closeBounds(
const base::PlannerTerminationCondition &ptc);
303 std::shared_ptr< NearestNeighbors<Motion*> >
nn_;
321 BoostGraph graphApx_;
326 std::vector<Motion*> idToMotionMap_;
339 #endif //OMPL_CONTRIB_LAZY_LBTRRT_
base::State * state_
The state contained by the motion.
double distanceFunction(const base::State *a, const base::State *b) const
Compute distance between motions (actually distance between contained states)
base::StateSamplerPtr sampler_
State sampler.
unsigned int iterations_
Number of iterations the algorithm performed.
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique...
virtual void getPlannerData(base::PlannerData &data) const
Get information about the current run of the motion planner. Repeated calls to this function will upd...
A shared pointer wrapper for ompl::base::StateSampler.
Motion(const base::SpaceInformationPtr &si)
Constructor that allocates memory for the state.
void setGoalBias(double goalBias)
Set the goal bias.
Abstract definition of goals.
std::shared_ptr< NearestNeighbors< Motion * > > nn_
A nearest-neighbors datastructure containing the tree of motions.
Encapsulate a termination condition for a motion planner. Planners will call operator() to decide whe...
Motion * lastGoalMotion_
The most recent goal motion. Used for PlannerData computation.
virtual void clear(void)
Clear all internal datastructures. Planner settings are not affected. Subsequent calls to solve() wil...
double getApproximationFactor(void) const
Get the apprimation factor.
Representation of a motion.
void setRange(double distance)
Set the range the planner is supposed to use.
Abstract definition of a goal region that can be sampled.
double getRange(void) const
Get the range the planner is using.
Random number generation. An instance of this class cannot be used by multiple threads at once (membe...
void freeMemory(void)
Free the memory allocated by this planner.
Base class for a planner.
virtual void setup(void)
Perform extra configuration steps, if needed. This call will also issue a call to ompl::base::SpaceIn...
Rapidly-exploring Random Trees.
std::size_t id_
The id of the motion.
A class to store the exit status of Planner::solve()
Definition of an abstract state.
virtual bool isSatisfied(const State *st) const =0
Return true if the state satisfies the goal constraints.
double epsilon_
approximation factor
LazyLBTRRT(const base::SpaceInformationPtr &si)
Constructor.
double goalBias_
The fraction of time the goal is picked as the state to expand towards (if such a state is available)...
void setApproximationFactor(double epsilon)
Set the apprimation factor.
double getGoalBias(void) const
Get the goal bias the planner is using.
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...
void setNearestNeighbors(void)
Set a different nearest neighbors datastructure.
void sampleBiased(const base::GoalSampleableRegion *goal_s, base::State *rstate)
sample with goal biasing
double bestCost_
Best cost found so far by algorithm.
SpaceInformationPtr si_
The space information for which planning is done.
double maxDistance_
The maximum length of a motion to be added to a tree.
RNG rng_
The random number generator.