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
44ompl::geometric::ATRRT::ATRRT(const base::SpaceInformationPtr &si) : base::Planner(si, "ATRRT")
45{
46 // Standard RRT Variables
47 specs_.approximateSolutions = true;
48 specs_.directed = true;
49
50 Planner::declareParam<double>("range", this, &ATRRT::setRange, &ATRRT::getRange, "0.:1.:10000.");
51 Planner::declareParam<double>("goal_bias", this, &ATRRT::setGoalBias, &ATRRT::getGoalBias, "0.:.05:1.");
52
53 // ATRRT Specific Variables
54 frontierThreshold_ = 0.0; // set in setup()
55 setTempChangeFactor(0.1); // how much to increase the temp each time
56 costThreshold_ = base::Cost(std::numeric_limits<double>::infinity());
57 initTemperature_ = 100; // where the temperature starts out
58 frontierNodeRatio_ = 0.1; // 1/10, or 1 nonfrontier for every 10 frontier
59
60 Planner::declareParam<double>("temp_change_factor", this, &ATRRT::setTempChangeFactor, &ATRRT::getTempChangeFactor,
61 "0.:.1:1.");
62 Planner::declareParam<double>("init_temperature", this, &ATRRT::setInitTemperature, &ATRRT::getInitTemperature);
63 Planner::declareParam<double>("frontier_threshold", this, &ATRRT::setFrontierThreshold,
65 Planner::declareParam<double>("frontier_node_ratio", this, &ATRRT::setFrontierNodeRatio,
67 Planner::declareParam<double>("cost_threshold", this, &ATRRT::setCostThreshold, &ATRRT::getCostThreshold);
68}
69
70ompl::geometric::ATRRT::~ATRRT()
71{
72 freeMemory();
73}
74
76{
77 Planner::clear();
78 sampler_.reset();
79 freeMemory();
81 nearestNeighbors_->clear();
82 lastGoalMotion_ = nullptr;
83
84 // Clear ATRRT specific variables ---------------------------------------------------------
87 frontierCount_ = 1; // init to 1 to prevent division by zero error
88 if (opt_)
89 bestCost_ = worstCost_ = opt_->infiniteCost();
90}
91
93{
94 Planner::setup();
95 tools::SelfConfig selfConfig(si_, getName());
96
97 if (!pdef_ || !pdef_->hasOptimizationObjective())
98 {
99 OMPL_INFORM("%s: No optimization objective specified. Defaulting to mechanical work minimization.",
100 getName().c_str());
101 opt_ = std::make_shared<base::MechanicalWorkOptimizationObjective>(si_);
102 }
103 else
104 opt_ = pdef_->getOptimizationObjective();
105
106 // Set maximum distance a new node can be from its nearest neighbor
107 if (maxDistance_ < std::numeric_limits<double>::epsilon())
108 {
111 }
112
113 // Set the threshold that decides if a new node is a frontier node or non-frontier node
114 if (frontierThreshold_ < std::numeric_limits<double>::epsilon())
115 {
116 frontierThreshold_ = si_->getMaximumExtent() * 0.01;
117 OMPL_DEBUG("%s: Frontier threshold detected to be %lf", getName().c_str(), frontierThreshold_);
118 }
119
120 // Create the nearest neighbor function the first time setup is run
123
124 // Set the distance function
125 nearestNeighbors_->setDistanceFunction([this](const Motion *a, const Motion *b) { return distanceFunction(a, b); });
126
127 // Setup ATRRT specific variables ---------------------------------------------------------
129 bestCost_ = worstCost_ = opt_->identityCost();
130}
131
133{
134 // Delete all motions, states and the nearest neighbors data structure
136 {
137 std::vector<Motion *> motions;
138 nearestNeighbors_->list(motions);
139 for (auto &motion : motions)
140 {
141 if (motion->state)
142 si_->freeState(motion->state);
143 delete motion;
144 }
145 }
146}
147
149{
150 // Basic error checking
152
153 // Goal information
154 base::Goal *goal = pdef_->getGoal().get();
155 auto *goalRegion = dynamic_cast<base::GoalSampleableRegion *>(goal);
156
157 if (goalRegion == nullptr)
158 {
159 OMPL_ERROR("%s: Unknown type of goal", getName().c_str());
161 }
162
163 if (!goalRegion->couldSample())
164 {
165 OMPL_ERROR("%s: Insufficient states in sampleable goal region", getName().c_str());
167 }
168
169 // Input States ---------------------------------------------------------------------------------
170
171 // Loop through valid input states and add to tree
172 Motion *startMotion = nullptr;
173 while (const base::State *state = pis_.nextStart())
174 {
175 // Allocate memory for a new start state motion based on the "space-information"-size
176 auto *motion = new Motion(si_);
177
178 // Copy destination <= source
179 si_->copyState(motion->state, state);
180
181 // Set cost for this start state
182 motion->cost = opt_->stateCost(motion->state);
183
184 if (nearestNeighbors_->size() == 0) // do not overwrite best/worst from previous call to solve
185 worstCost_ = bestCost_ = motion->cost;
186
187 // Add start motion to the tree
188 nearestNeighbors_->add(motion);
189
190 // Keep track of the start motion
191 if (startMotion == nullptr)
192 startMotion = motion;
193 }
194
195 // Check that input states exist
196 if (nearestNeighbors_->size() == 0)
197 {
198 OMPL_ERROR("%s: There are no valid initial states!", getName().c_str());
200 }
201
202 // Create state sampler if this is ATRRT's first run
203 if (!sampler_)
204 sampler_ = si_->allocStateSampler();
205
206 // Debug
207 OMPL_INFORM("%s: Starting planning with %u states already in datastructure", getName().c_str(),
208 nearestNeighbors_->size());
209
210 // Solver variables ------------------------------------------------------------------------------------
211
212 // the final solution
213 Motion *solution = nullptr;
214 // the approximate solution, returned if no final solution found
215 Motion *approxSolution = nullptr;
216 // track the distance from goal to closest solution yet found
217 double approxDifference = std::numeric_limits<double>::infinity();
218 // UsefulCycles constant
219 double volumeFreeSpace = 0.9 * si_->getMaximumExtent();
220 double volumeUnitBall2D = M_PI;
221 unsigned int d = si_->getStateDimension();
222 gamma_ = 2.5 * 2 * std::pow((1.0 + 1.0 / d), 1.0 / d) * std::pow(volumeFreeSpace / volumeUnitBall2D, 1.0 / d);
223
224 // distance between states - the initial state and the interpolated state (may be the same)
225 double randMotionDistance;
226
227 // Create random motion and a pointer (for optimization) to its state
228 auto *randMotion = new Motion(si_);
229 Motion *nearMotion;
230
231 // STATES
232 // The random state
233 base::State *randState = randMotion->state;
234 // The new state that is generated between states *to* and *from*
235 base::State *interpolatedState = si_->allocState();
236 // The chosen state btw rand_state and interpolated_state
237 base::State *newState;
238
239 // Begin sampling --------------------------------------------------------------------------------------
240 while (!ptc)
241 {
242 // I.
243
244 // Sample random state (with goal biasing)
245 if (rng_.uniform01() < goalBias_ && goalRegion->canSample())
246 {
247 // Bias sample towards goal
248 goalRegion->sampleGoal(randState);
249 }
250 else
251 {
252 // Uniformly Sample
253 sampler_->sampleUniform(randState);
254 }
255
256 // II.
257
258 // Find closest state in the tree
259 nearMotion = nearestNeighbors_->nearest(randMotion);
260
261 // III.
262
263 // Distance from near state q_n to a random state
264 randMotionDistance = si_->distance(nearMotion->state, randState);
265
266 // Check if the rand_state is too far away
267 if (randMotionDistance > maxDistance_)
268 {
269 // Computes the state that lies at time t in [0, 1] on the segment that connects *from* state to *to* state.
270 // The memory location of *state* is not required to be different from the memory of either *from* or *to*.
271 si_->getStateSpace()->interpolate(nearMotion->state, randState, maxDistance_ / randMotionDistance,
272 interpolatedState);
273
274 // Update the distance between near and new with the interpolated_state
275 randMotionDistance = si_->distance(nearMotion->state, interpolatedState);
276
277 // Use the interpolated state as the new state
278 newState = interpolatedState;
279 }
280 else // Random state is close enough
281 newState = randState;
282
283 // IV.
284 // this stage integrates collision detections in the presence of obstacles and checks for collisions
285 if (!si_->checkMotion(nearMotion->state, newState))
286 continue; // try a new sample
287
288 // Minimum Expansion Control
289 // A possible side effect may appear when the tree expansion toward unexplored regions remains slow, and the
290 // new nodes contribute only to refine already explored regions.
291 if (solution == nullptr && !minExpansionControl(randMotionDistance))
292 continue; // try a new sample
293
294 base::Cost childCost = opt_->stateCost(newState);
295
296 // Only add this motion to the tree if the transition test accepts it
297 if (!transitionTest(opt_->motionCost(nearMotion->state, newState)))
298 continue; // try a new sample
299
300 // V.
301
302 // Create a motion
303 auto *motion = new Motion(si_);
304 si_->copyState(motion->state, newState);
305 addEdge(motion, nearMotion); // link q_new to q_near as an edge
306 motion->cost = childCost;
307
308 // Add motion to data structure
309 nearestNeighbors_->add(motion);
310
311 if (opt_->isCostBetterThan(motion->cost, bestCost_)) // motion->cost is better than the existing best
312 bestCost_ = motion->cost;
313 if (opt_->isCostBetterThan(worstCost_, motion->cost)) // motion->cost is worse than the existing worst
314 worstCost_ = motion->cost;
315
316 // VI.
317
318 // Check if this motion is the goal
319 double distToGoal = 0.0;
320 bool isSatisfied = goal->isSatisfied(motion->state, &distToGoal);
321 if (isSatisfied)
322 {
323 approxDifference = distToGoal; // the tolerated error distance btw state and goal
324 solution = motion; // set the final solution
325 }
326
327 // Is this the closest solution we've found so far
328 if (distToGoal < approxDifference)
329 {
330 approxDifference = distToGoal;
331 approxSolution = motion;
332 }
333
334 // VII. Add cycles to the graph if an initial solution exists
335 if (solution != nullptr)
336 addUsefulCycles(motion, nearMotion);
337
338 } // end of solver sampling loop
339
340 // Finish solution processing --------------------------------------------------------------------
341
342 bool solved = false;
343 bool approximate = false;
344
345 // Substitute an empty solution with the best approximation
346 if (solution == nullptr)
347 {
348 solution = approxSolution;
349 approximate = true;
350 }
351
352 // Generate solution path for real/approx solution
353 if (solution != nullptr)
354 {
355 lastGoalMotion_ = solution;
356
357 std::vector<Motion *> mpath = computeDijkstraLowestCostPath(startMotion, solution);
358
359 // set the solution path
360 auto path(std::make_shared<PathGeometric>(si_));
361 for (int i = mpath.size() - 1; i >= 0; --i)
362 path->append(mpath[i]->state);
363
364 pdef_->addSolutionPath(path, approximate, approxDifference, getName());
365 solved = true;
366 }
367
368 // Clean up ---------------------------------------------------------------------------------------
369
370 si_->freeState(interpolatedState);
371 if (randMotion->state)
372 si_->freeState(randMotion->state);
373 delete randMotion;
374
375 OMPL_INFORM("%s: Created %u states", getName().c_str(), nearestNeighbors_->size());
376
377 return {solved, approximate};
378}
379
381{
382 Planner::getPlannerData(data);
383
384 std::vector<Motion *> motions;
386 nearestNeighbors_->list(motions);
387
388 if (lastGoalMotion_)
390
391 for (auto &motion : motions)
392 {
393 if (motion->neighbors.empty())
394 data.addStartVertex(base::PlannerDataVertex(motion->state));
395 else
396 for (auto &neighbor : motion->neighbors)
397 data.addEdge(base::PlannerDataVertex(neighbor->state), base::PlannerDataVertex(motion->state));
398 }
399}
400
402{
403 // Disallow any cost that is not better than the cost threshold
404 if (!opt_->isCostBetterThan(motionCost, costThreshold_))
405 return false;
406
407 // Always accept if the cost is near or below zero
408 if (motionCost.value() < 1e-4)
409 return true;
410
411 double dCost = motionCost.value();
412 double transitionProbability = exp(-dCost / temp_);
413 if (transitionProbability > 0.5)
414 {
415 double costRange = worstCost_.value() - bestCost_.value();
416 if (fabs(costRange) > 1e-4) // Do not divide by zero
417 // Successful transition test. Decrease the temperature slightly
418 temp_ /= exp(dCost / (0.1 * costRange));
419
420 return true;
421 }
422
423 // The transition failed. Increase the temperature (slightly)
425 return false;
426}
427
428bool ompl::geometric::ATRRT::minExpansionControl(double randMotionDistance)
429{
430 if (randMotionDistance > frontierThreshold_)
431 {
432 // participates in the tree expansion
434
435 return true;
436 }
437 else
438 {
439 // participates in the tree refinement
440
441 // check our ratio first before accepting it
443 // reject this node as being too much refinement
444 return false;
445
447 return true;
448 }
449}
450
452{
453 // neighborhood radius
454 // double n = static_cast<double>(nearestNeighbors_->size()); // number of nodes in tree
455 // double d = static_cast<double>(si_->getStateDimension()); // dimension of state space
456 // double radius = gamma_ * std::pow((std::log(n) / n), 1.0 / d);
457 // TODO: This is a temporary solution to avoid the issue of the radius being too small
458 double radius = neighborhoodRadiusFactor_ * maxDistance_;
459
460 std::vector<Motion *> candidates;
461 nearestNeighbors_->nearestR(newMotion, radius, candidates);
462
463 for (auto *candidate : candidates)
464 {
465 // Skip if neighbor is the same as motion
466 if (candidate == newMotion || candidate == nearMotion)
467 continue;
468
469 // Cost of direct path between newMotion and neighbor
470 base::Cost costSpace = opt_->motionCost(newMotion->state, candidate->state);
471
472 // Cost of existing path in the graph
473 base::Cost costGraph = computeCostLowestCostPath(candidate, newMotion);
474
475 if ((opt_->isCostBetterThan(costSpace, costGraph)) && si_->checkMotion(candidate->state, newMotion->state))
476 {
477 // Add edge to the graph
478 addEdge(newMotion, candidate);
479 }
480 }
481}
482
484{
485 a->neighbors.push_back(b);
486 b->neighbors.push_back(a);
487}
488
489std::vector<ompl::geometric::ATRRT::Motion *> ompl::geometric::ATRRT::computeDijkstraLowestCostPath(Motion *a,
490 Motion *b)
491{
492 std::priority_queue<std::pair<Motion *, base::Cost>, std::vector<std::pair<Motion *, base::Cost>>,
494 pq;
495 std::unordered_map<Motion *, base::Cost> costMap;
496 std::unordered_map<Motion *, Motion *> parentMap;
497
498 pq.push({a, opt_->identityCost()});
499 costMap[a] = opt_->identityCost();
500 parentMap[a] = nullptr;
501
502 while (!pq.empty())
503 {
504 Motion *current = pq.top().first;
505 pq.pop();
506
507 if (current == b)
508 break;
509
510 for (Motion *neighbor : current->neighbors)
511 {
512 base::Cost newCost =
513 opt_->combineCosts(costMap[current], opt_->motionCost(current->state, neighbor->state));
514 if (costMap.find(neighbor) == costMap.end() || opt_->isCostBetterThan(newCost, costMap[neighbor]))
515 {
516 costMap[neighbor] = newCost;
517 parentMap[neighbor] = current;
518 pq.push({neighbor, newCost});
519 }
520 }
521 }
522
523 std::vector<Motion *> path;
524 for (Motion *m = b; m != nullptr; m = parentMap[m])
525 path.push_back(m);
526
527 std::reverse(path.begin(), path.end());
528 return path;
529}
530
532{
533 std::vector<Motion *> path = computeDijkstraLowestCostPath(a, b);
534 base::Cost pathCost = base::Cost{0.0};
535 for (size_t i = 1; i < path.size(); ++i)
536 pathCost = opt_->combineCosts(pathCost, opt_->motionCost(path[i - 1]->state, path[i]->state));
537 return pathCost;
538}
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:531
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:44
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:401
void freeMemory()
Free the memory allocated by this planner.
Definition ATRRT.cpp:132
bool minExpansionControl(double randMotionDistance)
Use ratio to prefer frontier nodes to nonfrontier ones.
Definition ATRRT.cpp:428
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:380
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:75
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:148
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:92
std::vector< ompl::geometric::ATRRT::Motion * > computeDijkstraLowestCostPath(Motion *a, Motion *b)
Compute lowest-cost path in graph between two motions.
Definition ATRRT.cpp:489
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:451
void addEdge(Motion *a, Motion *b)
Add bidirectional edge between two motions.
Definition ATRRT.cpp:483
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