Loading...
Searching...
No Matches
ATRRT.cpp
1/*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2025, Joris Chomarat
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 copyright holder 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: Joris Chomarat */
36
37#include "ompl/geometric/planners/rrt/ATRRT.h"
38#include "ompl/base/objectives/MechanicalWorkOptimizationObjective.h"
39#include "ompl/base/goals/GoalSampleableRegion.h"
40#include "ompl/tools/config/SelfConfig.h"
41#include "ompl/tools/config/MagicConstants.h"
42#include <limits>
43#include <boost/math/constants/constants.hpp>
44
45ompl::geometric::ATRRT::ATRRT(const base::SpaceInformationPtr &si) : base::Planner(si, "ATRRT")
46{
47 // Standard RRT Variables
48 specs_.approximateSolutions = true;
49 specs_.directed = true;
50
51 Planner::declareParam<double>("range", this, &ATRRT::setRange, &ATRRT::getRange, "0.:1.:10000.");
52 Planner::declareParam<double>("goal_bias", this, &ATRRT::setGoalBias, &ATRRT::getGoalBias, "0.:.05:1.");
53
54 // ATRRT Specific Variables
55 frontierThreshold_ = 0.0; // set in setup()
56 setTempChangeFactor(0.1); // how much to increase the temp each time
57 costThreshold_ = base::Cost(std::numeric_limits<double>::infinity());
58 initTemperature_ = 100; // where the temperature starts out
59 frontierNodeRatio_ = 0.1; // 1/10, or 1 nonfrontier for every 10 frontier
60
61 Planner::declareParam<double>("temp_change_factor", this, &ATRRT::setTempChangeFactor, &ATRRT::getTempChangeFactor,
62 "0.:.1:1.");
63 Planner::declareParam<double>("init_temperature", this, &ATRRT::setInitTemperature, &ATRRT::getInitTemperature);
64 Planner::declareParam<double>("frontier_threshold", this, &ATRRT::setFrontierThreshold,
66 Planner::declareParam<double>("frontier_node_ratio", this, &ATRRT::setFrontierNodeRatio,
68 Planner::declareParam<double>("cost_threshold", this, &ATRRT::setCostThreshold, &ATRRT::getCostThreshold);
69}
70
71ompl::geometric::ATRRT::~ATRRT()
72{
73 freeMemory();
74}
75
77{
78 Planner::clear();
79 sampler_.reset();
80 freeMemory();
82 nearestNeighbors_->clear();
83 lastGoalMotion_ = nullptr;
84
85 // Clear ATRRT specific variables ---------------------------------------------------------
88 frontierCount_ = 1; // init to 1 to prevent division by zero error
89 if (opt_)
90 bestCost_ = worstCost_ = opt_->infiniteCost();
91}
92
94{
95 Planner::setup();
96 tools::SelfConfig selfConfig(si_, getName());
97
98 if (!pdef_ || !pdef_->hasOptimizationObjective())
99 {
100 OMPL_INFORM("%s: No optimization objective specified. Defaulting to mechanical work minimization.",
101 getName().c_str());
102 opt_ = std::make_shared<base::MechanicalWorkOptimizationObjective>(si_);
103 }
104 else
105 opt_ = pdef_->getOptimizationObjective();
106
107 // Set maximum distance a new node can be from its nearest neighbor
108 if (maxDistance_ < std::numeric_limits<double>::epsilon())
109 {
112 }
113
114 // Set the threshold that decides if a new node is a frontier node or non-frontier node
115 if (frontierThreshold_ < std::numeric_limits<double>::epsilon())
116 {
117 frontierThreshold_ = si_->getMaximumExtent() * 0.01;
118 OMPL_DEBUG("%s: Frontier threshold detected to be %lf", getName().c_str(), frontierThreshold_);
119 }
120
121 // Create the nearest neighbor function the first time setup is run
124
125 // Set the distance function
126 nearestNeighbors_->setDistanceFunction([this](const Motion *a, const Motion *b) { return distanceFunction(a, b); });
127
128 // Setup ATRRT specific variables ---------------------------------------------------------
130 bestCost_ = worstCost_ = opt_->identityCost();
131}
132
134{
135 // Delete all motions, states and the nearest neighbors data structure
137 {
138 std::vector<Motion *> motions;
139 nearestNeighbors_->list(motions);
140 for (auto &motion : motions)
141 {
142 if (motion->state)
143 si_->freeState(motion->state);
144 delete motion;
145 }
146 }
147}
148
150{
151 // Basic error checking
153
154 // Goal information
155 base::Goal *goal = pdef_->getGoal().get();
156 auto *goalRegion = dynamic_cast<base::GoalSampleableRegion *>(goal);
157
158 if (goalRegion == nullptr)
159 {
160 OMPL_ERROR("%s: Unknown type of goal", getName().c_str());
162 }
163
164 if (!goalRegion->couldSample())
165 {
166 OMPL_ERROR("%s: Insufficient states in sampleable goal region", getName().c_str());
168 }
169
170 // Input States ---------------------------------------------------------------------------------
171
172 // Loop through valid input states and add to tree
173 Motion *startMotion = nullptr;
174 while (const base::State *state = pis_.nextStart())
175 {
176 // Allocate memory for a new start state motion based on the "space-information"-size
177 auto *motion = new Motion(si_);
178
179 // Copy destination <= source
180 si_->copyState(motion->state, state);
181
182 // Set cost for this start state
183 motion->cost = opt_->stateCost(motion->state);
184
185 if (nearestNeighbors_->size() == 0) // do not overwrite best/worst from previous call to solve
186 worstCost_ = bestCost_ = motion->cost;
187
188 // Add start motion to the tree
189 nearestNeighbors_->add(motion);
190
191 // Keep track of the start motion
192 if (startMotion == nullptr)
193 startMotion = motion;
194 }
195
196 // Check that input states exist
197 if (nearestNeighbors_->size() == 0)
198 {
199 OMPL_ERROR("%s: There are no valid initial states!", getName().c_str());
201 }
202
203 // Create state sampler if this is ATRRT's first run
204 if (!sampler_)
205 sampler_ = si_->allocStateSampler();
206
207 // Debug
208 OMPL_INFORM("%s: Starting planning with %u states already in datastructure", getName().c_str(),
209 nearestNeighbors_->size());
210
211 // Solver variables ------------------------------------------------------------------------------------
212
213 // the final solution
214 Motion *solution = nullptr;
215 // the approximate solution, returned if no final solution found
216 Motion *approxSolution = nullptr;
217 // track the distance from goal to closest solution yet found
218 double approxDifference = std::numeric_limits<double>::infinity();
219 // UsefulCycles constant
220 double volumeFreeSpace = 0.9 * si_->getMaximumExtent();
221 double volumeUnitBall2D = boost::math::constants::pi<double>();
222 unsigned int d = si_->getStateDimension();
223 gamma_ = 2.5 * 2 * std::pow((1.0 + 1.0 / d), 1.0 / d) * std::pow(volumeFreeSpace / volumeUnitBall2D, 1.0 / d);
224
225 // distance between states - the initial state and the interpolated state (may be the same)
226 double randMotionDistance;
227
228 // Create random motion and a pointer (for optimization) to its state
229 auto *randMotion = new Motion(si_);
230 Motion *nearMotion;
231
232 // STATES
233 // The random state
234 base::State *randState = randMotion->state;
235 // The new state that is generated between states *to* and *from*
236 base::State *interpolatedState = si_->allocState();
237 // The chosen state btw rand_state and interpolated_state
238 base::State *newState;
239
240 // Begin sampling --------------------------------------------------------------------------------------
241 while (!ptc)
242 {
243 // I.
244
245 // Sample random state (with goal biasing)
246 if (rng_.uniform01() < goalBias_ && goalRegion->canSample())
247 {
248 // Bias sample towards goal
249 goalRegion->sampleGoal(randState);
250 }
251 else
252 {
253 // Uniformly Sample
254 sampler_->sampleUniform(randState);
255 }
256
257 // II.
258
259 // Find closest state in the tree
260 nearMotion = nearestNeighbors_->nearest(randMotion);
261
262 // III.
263
264 // Distance from near state q_n to a random state
265 randMotionDistance = si_->distance(nearMotion->state, randState);
266
267 // Check if the rand_state is too far away
268 if (randMotionDistance > maxDistance_)
269 {
270 // Computes the state that lies at time t in [0, 1] on the segment that connects *from* state to *to* state.
271 // The memory location of *state* is not required to be different from the memory of either *from* or *to*.
272 si_->getStateSpace()->interpolate(nearMotion->state, randState, maxDistance_ / randMotionDistance,
273 interpolatedState);
274
275 // Update the distance between near and new with the interpolated_state
276 randMotionDistance = si_->distance(nearMotion->state, interpolatedState);
277
278 // Use the interpolated state as the new state
279 newState = interpolatedState;
280 }
281 else // Random state is close enough
282 newState = randState;
283
284 // IV.
285 // this stage integrates collision detections in the presence of obstacles and checks for collisions
286 if (!si_->checkMotion(nearMotion->state, newState))
287 continue; // try a new sample
288
289 // Minimum Expansion Control
290 // A possible side effect may appear when the tree expansion toward unexplored regions remains slow, and the
291 // new nodes contribute only to refine already explored regions.
292 if (solution == nullptr && !minExpansionControl(randMotionDistance))
293 continue; // try a new sample
294
295 base::Cost childCost = opt_->stateCost(newState);
296
297 // Only add this motion to the tree if the transition test accepts it
298 if (!transitionTest(opt_->motionCost(nearMotion->state, newState)))
299 continue; // try a new sample
300
301 // V.
302
303 // Create a motion
304 auto *motion = new Motion(si_);
305 si_->copyState(motion->state, newState);
306 addEdge(motion, nearMotion); // link q_new to q_near as an edge
307 motion->cost = childCost;
308
309 // Add motion to data structure
310 nearestNeighbors_->add(motion);
311
312 if (opt_->isCostBetterThan(motion->cost, bestCost_)) // motion->cost is better than the existing best
313 bestCost_ = motion->cost;
314 if (opt_->isCostBetterThan(worstCost_, motion->cost)) // motion->cost is worse than the existing worst
315 worstCost_ = motion->cost;
316
317 // VI.
318
319 // Check if this motion is the goal
320 double distToGoal = 0.0;
321 bool isSatisfied = goal->isSatisfied(motion->state, &distToGoal);
322 if (isSatisfied)
323 {
324 approxDifference = distToGoal; // the tolerated error distance btw state and goal
325 solution = motion; // set the final solution
326 }
327
328 // Is this the closest solution we've found so far
329 if (distToGoal < approxDifference)
330 {
331 approxDifference = distToGoal;
332 approxSolution = motion;
333 }
334
335 // VII. Add cycles to the graph if an initial solution exists
336 if (solution != nullptr)
337 addUsefulCycles(motion, nearMotion);
338
339 } // end of solver sampling loop
340
341 // Finish solution processing --------------------------------------------------------------------
342
343 bool solved = false;
344 bool approximate = false;
345
346 // Substitute an empty solution with the best approximation
347 if (solution == nullptr)
348 {
349 solution = approxSolution;
350 approximate = true;
351 }
352
353 // Generate solution path for real/approx solution
354 if (solution != nullptr)
355 {
356 lastGoalMotion_ = solution;
357
358 std::vector<Motion *> mpath = computeDijkstraLowestCostPath(startMotion, solution);
359
360 // set the solution path
361 auto path(std::make_shared<PathGeometric>(si_));
362 for (int i = mpath.size() - 1; i >= 0; --i)
363 path->append(mpath[i]->state);
364
365 pdef_->addSolutionPath(path, approximate, approxDifference, getName());
366 solved = true;
367 }
368
369 // Clean up ---------------------------------------------------------------------------------------
370
371 si_->freeState(interpolatedState);
372 if (randMotion->state)
373 si_->freeState(randMotion->state);
374 delete randMotion;
375
376 OMPL_INFORM("%s: Created %u states", getName().c_str(), nearestNeighbors_->size());
377
378 return {solved, approximate};
379}
380
382{
383 Planner::getPlannerData(data);
384
385 std::vector<Motion *> motions;
387 nearestNeighbors_->list(motions);
388
389 if (lastGoalMotion_)
391
392 for (auto &motion : motions)
393 {
394 if (motion->neighbors.empty())
395 data.addStartVertex(base::PlannerDataVertex(motion->state));
396 else
397 for (auto &neighbor : motion->neighbors)
398 data.addEdge(base::PlannerDataVertex(neighbor->state), base::PlannerDataVertex(motion->state));
399 }
400}
401
403{
404 // Disallow any cost that is not better than the cost threshold
405 if (!opt_->isCostBetterThan(motionCost, costThreshold_))
406 return false;
407
408 // Always accept if the cost is near or below zero
409 if (motionCost.value() < 1e-4)
410 return true;
411
412 double dCost = motionCost.value();
413 double transitionProbability = exp(-dCost / temp_);
414 if (transitionProbability > 0.5)
415 {
416 double costRange = worstCost_.value() - bestCost_.value();
417 if (fabs(costRange) > 1e-4) // Do not divide by zero
418 // Successful transition test. Decrease the temperature slightly
419 temp_ /= exp(dCost / (0.1 * costRange));
420
421 return true;
422 }
423
424 // The transition failed. Increase the temperature (slightly)
426 return false;
427}
428
429bool ompl::geometric::ATRRT::minExpansionControl(double randMotionDistance)
430{
431 if (randMotionDistance > frontierThreshold_)
432 {
433 // participates in the tree expansion
435
436 return true;
437 }
438 else
439 {
440 // participates in the tree refinement
441
442 // check our ratio first before accepting it
444 // reject this node as being too much refinement
445 return false;
446
448 return true;
449 }
450}
451
453{
454 // neighborhood radius
455 // double n = static_cast<double>(nearestNeighbors_->size()); // number of nodes in tree
456 // double d = static_cast<double>(si_->getStateDimension()); // dimension of state space
457 // double radius = gamma_ * std::pow((std::log(n) / n), 1.0 / d);
458 // TODO: This is a temporary solution to avoid the issue of the radius being too small
459 double radius = neighborhoodRadiusFactor_ * maxDistance_;
460
461 std::vector<Motion *> candidates;
462 nearestNeighbors_->nearestR(newMotion, radius, candidates);
463
464 for (auto *candidate : candidates)
465 {
466 // Skip if neighbor is the same as motion
467 if (candidate == newMotion || candidate == nearMotion)
468 continue;
469
470 // Cost of direct path between newMotion and neighbor
471 base::Cost costSpace = opt_->motionCost(newMotion->state, candidate->state);
472
473 // Cost of existing path in the graph
474 base::Cost costGraph = computeCostLowestCostPath(candidate, newMotion);
475
476 if ((opt_->isCostBetterThan(costSpace, costGraph)) && si_->checkMotion(candidate->state, newMotion->state))
477 {
478 // Add edge to the graph
479 addEdge(newMotion, candidate);
480 }
481 }
482}
483
485{
486 a->neighbors.push_back(b);
487 b->neighbors.push_back(a);
488}
489
490std::vector<ompl::geometric::ATRRT::Motion *> ompl::geometric::ATRRT::computeDijkstraLowestCostPath(Motion *a,
491 Motion *b)
492{
493 std::priority_queue<std::pair<Motion *, base::Cost>, std::vector<std::pair<Motion *, base::Cost>>,
495 pq;
496 std::unordered_map<Motion *, base::Cost> costMap;
497 std::unordered_map<Motion *, Motion *> parentMap;
498
499 pq.push({a, opt_->identityCost()});
500 costMap[a] = opt_->identityCost();
501 parentMap[a] = nullptr;
502
503 while (!pq.empty())
504 {
505 Motion *current = pq.top().first;
506 pq.pop();
507
508 if (current == b)
509 break;
510
511 for (Motion *neighbor : current->neighbors)
512 {
513 base::Cost newCost =
514 opt_->combineCosts(costMap[current], opt_->motionCost(current->state, neighbor->state));
515 if (costMap.find(neighbor) == costMap.end() || opt_->isCostBetterThan(newCost, costMap[neighbor]))
516 {
517 costMap[neighbor] = newCost;
518 parentMap[neighbor] = current;
519 pq.push({neighbor, newCost});
520 }
521 }
522 }
523
524 std::vector<Motion *> path;
525 for (Motion *m = b; m != nullptr; m = parentMap[m])
526 path.push_back(m);
527
528 std::reverse(path.begin(), path.end());
529 return path;
530}
531
533{
534 std::vector<Motion *> path = computeDijkstraLowestCostPath(a, b);
535 base::Cost pathCost = base::Cost{0.0};
536 for (size_t i = 1; i < path.size(); ++i)
537 pathCost = opt_->combineCosts(pathCost, opt_->motionCost(path[i - 1]->state, path[i]->state));
538 return pathCost;
539}
Definition of a cost value. Can represent the cost of a motion or the cost of a state.
Definition Cost.h:48
double value() const
The value of the cost.
Definition Cost.h:56
Abstract definition of a goal region that can be sampled.
Abstract definition of goals.
Definition Goal.h:63
virtual bool isSatisfied(const State *st) const =0
Return true if the state satisfies the goal constraints.
Base class for a vertex in the PlannerData structure. All derived classes must implement the clone an...
Definition PlannerData.h:59
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique,...
unsigned int addStartVertex(const PlannerDataVertex &v)
Adds the given vertex to the graph data, and marks it as a start vertex. The vertex index is returned...
unsigned int addGoalVertex(const PlannerDataVertex &v)
Adds the given vertex to the graph data, and marks it as a start vertex. The vertex index is returned...
virtual bool addEdge(unsigned int v1, unsigned int v2, const PlannerDataEdge &edge=PlannerDataEdge(), Cost weight=Cost(1.0))
Adds a directed edge between the given vertex indexes. An optional edge structure and weight can be s...
Encapsulate a termination condition for a motion planner. Planners will call operator() to decide whe...
PlannerInputStates pis_
Utility class to extract valid input states.
Definition Planner.h:407
PlannerSpecs specs_
The specifications of the planner (its capabilities).
Definition Planner.h:413
ProblemDefinitionPtr pdef_
The user set problem definition.
Definition Planner.h:404
const std::string & getName() const
Get the name of the planner.
Definition Planner.cpp:56
SpaceInformationPtr si_
The space information for which planning is done.
Definition Planner.h:401
virtual void checkValidity()
Check to see if the planner is in a working state (setup has been called, a goal was set,...
Definition Planner.cpp:106
Definition of an abstract state.
Definition State.h:50
Representation of a motion.
Definition ATRRT.h:228
std::vector< Motion * > neighbors
The connected motions in the exploration graph.
Definition ATRRT.h:243
base::State * state
The state contained by the motion.
Definition ATRRT.h:240
double frontierThreshold_
The distance between an old state and a new state that qualifies it as a frontier state.
Definition ATRRT.h:353
double getCostThreshold() const
Get the cost threshold (default is infinity). Any motion cost that is not better than this cost (acco...
Definition ATRRT.h:162
base::Cost worstCost_
The least desirable (e.g., maximum) cost value in the search tree.
Definition ATRRT.h:322
double getFrontierNodeRatio() const
Get the ratio between adding nonfrontier nodes to frontier nodes, for example .1 is 1/10 or one nonfr...
Definition ATRRT.h:204
void setGoalBias(double goalBias)
Set the goal bias.
Definition ATRRT.h:108
double getInitTemperature() const
Get the temperature at the start of planning.
Definition ATRRT.h:176
double distanceFunction(const Motion *a, const Motion *b) const
Compute distance between motions (actually distance between contained states).
Definition ATRRT.h:253
ompl::base::OptimizationObjectivePtr opt_
The optimization objective being optimized by ATRRT.
Definition ATRRT.h:335
Motion * lastGoalMotion_
The most recent goal motion. Used for PlannerData computation.
Definition ATRRT.h:295
ompl::base::Cost computeCostLowestCostPath(Motion *a, Motion *b)
Compute cost of lowest-cost path found by Dijkstra.
Definition ATRRT.cpp:532
double goalBias_
The fraction of time the goal is picked as the state to expand towards (if such a state is available)...
Definition ATRRT.h:286
void setInitTemperature(double initTemperature)
Set the initial temperature at the beginning of the algorithm. Should be high to allow for initial ex...
Definition ATRRT.h:169
double nonfrontierCount_
The number of non-frontier nodes in the search tree.
Definition ATRRT.h:348
ATRRT(const base::SpaceInformationPtr &si)
Constructor.
Definition ATRRT.cpp:45
double getGoalBias() const
Get the goal bias the planner is using.
Definition ATRRT.h:114
bool transitionTest(const base::Cost &motionCost)
Filter irrelevant configuration regarding the search of low-cost paths before inserting into tree.
Definition ATRRT.cpp:402
void freeMemory()
Free the memory allocated by this planner.
Definition ATRRT.cpp:133
bool minExpansionControl(double randMotionDistance)
Use ratio to prefer frontier nodes to nonfrontier ones.
Definition ATRRT.cpp:429
double getFrontierThreshold() const
Get the distance between a new state and the nearest neighbor that qualifies that state as being a fr...
Definition ATRRT.h:190
void setRange(double distance)
Set the range the planner is supposed to use.
Definition ATRRT.h:124
base::StateSamplerPtr sampler_
State sampler.
Definition ATRRT.h:279
double temp_
Temperature parameter used to control the difficulty level of transition tests. Low temperatures limi...
Definition ATRRT.h:316
double neighborhoodRadiusFactor_
Factor of maxDistance_ used to calculate neighborhood radius TODO: temporary solution.
Definition ATRRT.h:344
base::Cost bestCost_
The most desirable (e.g., minimum) cost value in the search tree.
Definition ATRRT.h:319
double maxDistance_
The maximum length of a motion to be added to a tree.
Definition ATRRT.h:289
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 ATRRT.cpp:381
void setFrontierThreshold(double frontier_threshold)
Set the distance between a new state and the nearest neighbor that qualifies that state as being a fr...
Definition ATRRT.h:183
void clear() override
Clear all internal datastructures. Planner settings are not affected. Subsequent calls to solve() wil...
Definition ATRRT.cpp:76
base::Cost costThreshold_
All motion costs must be better than this cost (default is infinity).
Definition ATRRT.h:325
double frontierCount_
The number of frontier nodes in the search tree.
Definition ATRRT.h:350
base::PlannerStatus solve(const base::PlannerTerminationCondition &plannerTerminationCondition) override
Function that can solve the motion planning problem. This function can be called multiple times on th...
Definition ATRRT.cpp:149
double getRange() const
Get the range the planner is using.
Definition ATRRT.h:130
double getTempChangeFactor() const
Get the factor by which the temperature rises based on current acceptance/rejection rate.
Definition ATRRT.h:146
RNG rng_
The random number generator.
Definition ATRRT.h:292
double frontierNodeRatio_
Target ratio of non-frontier nodes to frontier nodes. rho.
Definition ATRRT.h:355
double initTemperature_
The initial value of temp_.
Definition ATRRT.h:332
void setFrontierNodeRatio(double frontierNodeRatio)
Set the ratio between adding nonfrontier nodes to frontier nodes, for example .1 is 1/10 or one nonfr...
Definition ATRRT.h:197
double tempChangeFactor_
The value of the expression exp^T_rate. The temperature is increased by this factor whenever the tran...
Definition ATRRT.h:329
void setup() override
Perform extra configuration steps, if needed. This call will also issue a call to ompl::base::SpaceIn...
Definition ATRRT.cpp:93
std::vector< ompl::geometric::ATRRT::Motion * > computeDijkstraLowestCostPath(Motion *a, Motion *b)
Compute lowest-cost path in graph between two motions.
Definition ATRRT.cpp:490
void setCostThreshold(double maxCost)
Set the cost threshold (default is infinity). Any motion cost that is not better than this cost (acco...
Definition ATRRT.h:154
std::shared_ptr< NearestNeighbors< Motion * > > nearestNeighbors_
A nearest-neighbors datastructure containing the tree of motions.
Definition ATRRT.h:282
void addUsefulCycles(Motion *newMotion, Motion *nearMotion)
improve solution found by TRRT
Definition ATRRT.cpp:452
void addEdge(Motion *a, Motion *b)
Add bidirectional edge between two motions.
Definition ATRRT.cpp:484
void setTempChangeFactor(double factor)
Set the factor by which the temperature is increased after a failed transition test....
Definition ATRRT.h:140
double gamma_
Constant derived from the free space volume.
Definition ATRRT.h:340
This class contains methods that automatically configure various parameters for motion planning....
Definition SelfConfig.h:59
static NearestNeighbors< _T > * getDefaultNearestNeighbors(const base::Planner *planner)
Select a default nearest neighbor datastructure for the given space.
Definition SelfConfig.h:105
void configurePlannerRange(double &range)
Compute what a good length for motion segments is.
#define OMPL_INFORM(fmt,...)
Log a formatted information string.
Definition Console.h:68
#define OMPL_ERROR(fmt,...)
Log a formatted error string.
Definition Console.h:64
#define OMPL_DEBUG(fmt,...)
Log a formatted debugging string.
Definition Console.h:70
This namespace contains sampling based planning routines shared by both planning under geometric cons...
static const double COST_MAX_MOTION_LENGTH_AS_SPACE_EXTENT_FRACTION
For cost-based planners it has been observed that smaller ranges are typically suitable....
A class to store the exit status of Planner::solve().
@ INVALID_START
Invalid start state or no start state specified.
@ INVALID_GOAL
Invalid goal state.
@ UNRECOGNIZED_GOAL_TYPE
The goal is of a type that a planner does not recognize.
bool stating which motion cost is better
Definition ATRRT.h:299