#include <ompl/geometric/planners/AnytimePathShortening.h>

Public Member Functions | |
AnytimePathShortening (const base::SpaceInformationPtr &si) | |
Constructor requires the space information to plan in. More... | |
~AnytimePathShortening () override | |
Destructor. | |
void | addPlanner (base::PlannerPtr &planner) |
Adds the given planner to the set of planners used to compute candidate paths. More... | |
base::PlannerStatus | solve (const base::PlannerTerminationCondition &ptc) override |
Method that solves the motion planning problem. This method terminates under just two conditions, the given argument condition, or when the maximum path length in the optimization objective is met. More... | |
void | clear () override |
Clear all internal planning datastructures. Planner settings are not affected. Subsequent calls to solve() will ignore all previous work. More... | |
void | getPlannerData (base::PlannerData &data) const override |
Get information about the most recent run of the motion planner. More... | |
virtual void | getPlannerData (ompl::base::PlannerData &data, unsigned int idx) const |
Get information about the most recent run of the idxth motion planner. More... | |
void | setup () override |
Perform any necessary configuration steps. This method also invokes ompl::base::SpaceInformation::setup() if needed. This must be called before solving. More... | |
void | checkValidity () override |
Check to see if the planners are in a working state (setup has been called, a goal was set, the input states seem to be in order). In case of error, this function throws an exception. More... | |
unsigned int | getNumPlanners () const |
Retrieve the number of planners added. More... | |
base::PlannerPtr | getPlanner (unsigned int idx) const |
Retrieve a pointer to the ith planner instance. More... | |
bool | isShortcutting () const |
Return whether the anytime planner will perform shortcutting on paths. More... | |
void | setShortcut (bool shortcut) |
Enable/disable shortcutting on paths. More... | |
bool | isHybridizing () const |
Return whether the anytime planner will extract a hybrid path from the set of solution paths. More... | |
void | setHybridize (bool hybridize) |
Enable/disable path hybridization on the set of solution paths. More... | |
unsigned int | maxHybridizationPaths () const |
Return the maximum number of paths that will be hybridized. More... | |
void | setMaxHybridizationPath (unsigned int maxPathCount) |
Set the maximum number of paths that will be hybridized. More... | |
void | setPlanners (const std::string &plannerList) |
Set the list of planners to use. More... | |
std::string | getPlanners () const |
Get a string representation of the planners and their parameters in the format of setPlanners. More... | |
void | setDefaultNumPlanners (unsigned int numPlanners) |
Set default number of planners to use if none are specified. More... | |
unsigned int | getDefaultNumPlanners () const |
Get default number of planners used if none are specified. More... | |
std::string | getBestCost () const |
Return best cost found so far by algorithm. More... | |
void | printSettings (std::ostream &out) const override |
Print settings of this planner as well as those of the planner instances it contains. More... | |
![]() | |
Planner (const Planner &)=delete | |
Planner & | operator= (const Planner &)=delete |
Planner (SpaceInformationPtr si, std::string name) | |
Constructor. More... | |
virtual | ~Planner ()=default |
Destructor. | |
template<class T > | |
T * | as () |
Cast this instance to a desired type. More... | |
template<class T > | |
const T * | as () const |
Cast this instance to a desired type. More... | |
const SpaceInformationPtr & | getSpaceInformation () const |
Get the space information this planner is using. More... | |
const ProblemDefinitionPtr & | getProblemDefinition () const |
Get the problem definition the planner is trying to solve. More... | |
ProblemDefinitionPtr & | getProblemDefinition () |
Get the problem definition the planner is trying to solve. More... | |
const PlannerInputStates & | getPlannerInputStates () const |
Get the planner input states. More... | |
virtual void | setProblemDefinition (const ProblemDefinitionPtr &pdef) |
Set the problem definition for the planner. The problem needs to be set before calling solve(). Note: If this problem definition replaces a previous one, it may also be necessary to call clear() or clearQuery(). More... | |
virtual PlannerStatus | solve (const PlannerTerminationCondition &ptc)=0 |
Function that can solve the motion planning problem. This function can be called multiple times on the same problem, without calling clear() in between. This allows the planner to continue work for more time on an unsolved problem, for example. If this option is used, it is assumed the problem definition is not changed (unpredictable results otherwise). The only change in the problem definition that is accounted for is the addition of starting or goal states (but not changing previously added start/goal states). If clearQuery() is called, the planner may retain prior datastructures generated from a previous query on a new problem definition. The function terminates if the call to ptc returns true. More... | |
PlannerStatus | solve (const PlannerTerminationConditionFn &ptc, double checkInterval) |
Same as above except the termination condition is only evaluated at a specified interval. More... | |
PlannerStatus | solve (double solveTime) |
Same as above except the termination condition is solely a time limit: the number of seconds the algorithm is allowed to spend planning. More... | |
virtual void | clear () |
Clear all internal datastructures. Planner settings are not affected. Subsequent calls to solve() will ignore all previous work. More... | |
virtual void | clearQuery () |
Clears internal datastructures of any query-specific information from the previous query. Planner settings are not affected. The planner, if able, should retain all datastructures generated from previous queries that can be used to help solve the next query. Note that clear() should also clear all query-specific information along with all other datastructures in the planner. By default clearQuery() calls clear(). More... | |
virtual void | getPlannerData (PlannerData &data) const |
Get information about the current run of the motion planner. Repeated calls to this function will update data (only additions are made). This is useful to see what changed in the exploration datastructure, between calls to solve(), for example (without calling clear() in between). More... | |
const std::string & | getName () const |
Get the name of the planner. More... | |
void | setName (const std::string &name) |
Set the name of the planner. More... | |
const PlannerSpecs & | getSpecs () const |
Return the specifications (capabilities of this planner) More... | |
virtual void | setup () |
Perform extra configuration steps, if needed. This call will also issue a call to ompl::base::SpaceInformation::setup() if needed. This must be called before solving. More... | |
virtual void | checkValidity () |
Check to see if the planner is in a working state (setup has been called, a goal was set, the input states seem to be in order). In case of error, this function throws an exception. More... | |
bool | isSetup () const |
Check if setup() was called for this planner. More... | |
ParamSet & | params () |
Get the parameters for this planner. More... | |
const ParamSet & | params () const |
Get the parameters for this planner. More... | |
const PlannerProgressProperties & | getPlannerProgressProperties () const |
Retrieve a planner's planner progress property map. More... | |
virtual void | printProperties (std::ostream &out) const |
Print properties of the motion planner. More... | |
virtual void | printSettings (std::ostream &out) const |
Print information about the motion planner's settings. More... | |
Static Public Member Functions | |
template<typename PlannerType > | |
static std::shared_ptr< AnytimePathShortening > | createPlanner (const base::SpaceInformationPtr &si, unsigned int numPlanners=std::max(1u, std::thread::hardware_concurrency())) |
Factory for creating a shared pointer to an AnytimePathShortening instance with numPlanners instances of planners of type PlannerType. More... | |
template<typename ... PlannerTypes> | |
static std::shared_ptr< AnytimePathShortening > | createPlanner (const base::SpaceInformationPtr &si) |
Factory for creating a shared pointer to an AnytimePathShortening instance with planners of type PlannerType1, PlannerType2, ... More... | |
Protected Member Functions | |
void | addPath (const geometric::PathGeometricPtr &path, base::Planner *planner) |
add a path to set of solutions More... | |
virtual void | threadSolve (base::Planner *planner, const base::PlannerTerminationCondition &ptc) |
The function that the planning threads execute when solving a motion planning problem. More... | |
![]() | |
template<typename T , typename PlannerType , typename SetterType , typename GetterType > | |
void | declareParam (const std::string &name, const PlannerType &planner, const SetterType &setter, const GetterType &getter, const std::string &rangeSuggestion="") |
This function declares a parameter for this planner instance, and specifies the setter and getter functions. More... | |
template<typename T , typename PlannerType , typename SetterType > | |
void | declareParam (const std::string &name, const PlannerType &planner, const SetterType &setter, const std::string &rangeSuggestion="") |
This function declares a parameter for this planner instance, and specifies the setter function. More... | |
void | addPlannerProgressProperty (const std::string &progressPropertyName, const PlannerProgressProperty &prop) |
Add a planner progress property called progressPropertyName with a property querying function prop to this planner's progress property map. More... | |
Protected Attributes | |
std::vector< base::PlannerPtr > | planners_ |
The list of planners used for solving the problem. More... | |
bool | shortcut_ {true} |
Flag indicating whether to shortcut paths. More... | |
bool | hybridize_ {true} |
Flag indicating whether to hybridize the set of solution paths. More... | |
unsigned int | maxHybridPaths_ {24} |
The maximum number of paths that will be hybridized. This prohibits hybridization of a very large path set, which may take significant time. More... | |
unsigned int | defaultNumPlanners_ |
The number of planners to use if none are specified. This defaults to the number of cores. This parameter has no effect if planners have already been added. More... | |
base::Cost | bestCost_ {std::numeric_limits<double>::quiet_NaN()} |
Best cost found so far by algorithm. More... | |
std::mutex | lock_ |
mutex for updating bestCost_ More... | |
![]() | |
SpaceInformationPtr | si_ |
The space information for which planning is done. More... | |
ProblemDefinitionPtr | pdef_ |
The user set problem definition. More... | |
PlannerInputStates | pis_ |
Utility class to extract valid input states More... | |
std::string | name_ |
The name of this planner. More... | |
PlannerSpecs | specs_ |
The specifications of the planner (its capabilities) More... | |
ParamSet | params_ |
A map from parameter names to parameter instances for this planner. This field is populated by the declareParam() function. More... | |
PlannerProgressProperties | plannerProgressProperties_ |
A mapping between this planner's progress property names and the functions used for querying those progress properties. More... | |
bool | setup_ |
Flag indicating whether setup() has been called. More... | |
Additional Inherited Members | |
![]() | |
using | PlannerProgressProperty = std::function< std::string()> |
Definition of a function which returns a property about the planner's progress that can be queried by a benchmarking routine. More... | |
using | PlannerProgressProperties = std::map< std::string, PlannerProgressProperty > |
A dictionary which maps the name of a progress property to the function to be used for querying that property. More... | |
Detailed Description
- Short description
- Anytime path shortening is a generic wrapper around one or more geometric motion planners that repeatedly applies shortcutting (ompl::geometric::PathSimplifier) and hybridization (ompl::geometric::PathHybridization) to a set of solution paths with the goal of rapidly converging to a solution with minimal length. Any number and combination of planners can be specified, each is run in a separate thread. A path length objective may be set, otherwise the tool will run until the termination condition is met. The purpose of this tool is to add anytime properties to motion planners that are not typically viewed as optimal/optimizing algorithms. This implementation deviates from the published version. Here, n threads repeatedly produce solution paths (that are optionally shortcutted), which are then subsequently added to a shared pool of solutions paths. The threads run independently and don't need to synchronize. A seperate thread repeatedly applies path hybridization to the top paths and, optionally, applies path simplification to the best path found so far.
- External documentation
- R. Luna, I.A. Şucan, M. Moll, and L.E. Kavraki, Anytime Solution Optimization for Sampling-Based Motion Planning, in Proc. 2013 IEEE Intl. Conf. on Robotics and Automation, pp. 5053-5059, May. 2013. DOI: ICRA.2013.6631301
[PDF]
Definition at line 81 of file AnytimePathShortening.h.
Constructor & Destructor Documentation
◆ AnytimePathShortening()
ompl::geometric::AnytimePathShortening::AnytimePathShortening | ( | const base::SpaceInformationPtr & | si | ) |
Constructor requires the space information to plan in.
Definition at line 75 of file AnytimePathShortening.cpp.
Member Function Documentation
◆ addPath()
|
protected |
add a path to set of solutions
- Parameters
-
path solution path planner planner that produced the solution. If planner==this, the path is the result of hybridization/simplification and is only added if it improves the best known solution.
Definition at line 119 of file AnytimePathShortening.cpp.
◆ addPlanner()
void ompl::geometric::AnytimePathShortening::addPlanner | ( | base::PlannerPtr & | planner | ) |
Adds the given planner to the set of planners used to compute candidate paths.
Definition at line 98 of file AnytimePathShortening.cpp.
◆ checkValidity()
|
overridevirtual |
Check to see if the planners are in a working state (setup has been called, a goal was set, the input states seem to be in order). In case of error, this function throws an exception.
Reimplemented from ompl::base::Planner.
Definition at line 284 of file AnytimePathShortening.cpp.
◆ clear()
|
overridevirtual |
Clear all internal planning datastructures. Planner settings are not affected. Subsequent calls to solve() will ignore all previous work.
Reimplemented from ompl::base::Planner.
Definition at line 240 of file AnytimePathShortening.cpp.
◆ createPlanner() [1/2]
|
inlinestatic |
Factory for creating a shared pointer to an AnytimePathShortening instance with planners of type PlannerType1, PlannerType2, ...
Example: createPlanner<ompl::geometric::PRM, ompl::geometric::RRT, ompl::geometric::EST> would return a shared pointer to an AnytimePathShortening instance containing a PRM, RRT, and EST instance. Typenames can be repeated to get multiple planner instances of that type.
Definition at line 105 of file AnytimePathShortening.h.
◆ createPlanner() [2/2]
|
inlinestatic |
Factory for creating a shared pointer to an AnytimePathShortening instance with numPlanners instances of planners of type PlannerType.
Definition at line 87 of file AnytimePathShortening.h.
◆ getBestCost()
std::string ompl::geometric::AnytimePathShortening::getBestCost | ( | ) | const |
Return best cost found so far by algorithm.
Definition at line 341 of file AnytimePathShortening.cpp.
◆ getDefaultNumPlanners()
unsigned int ompl::geometric::AnytimePathShortening::getDefaultNumPlanners | ( | ) | const |
Get default number of planners used if none are specified.
Definition at line 336 of file AnytimePathShortening.cpp.
◆ getNumPlanners()
unsigned int ompl::geometric::AnytimePathShortening::getNumPlanners | ( | ) | const |
Retrieve the number of planners added.
Definition at line 290 of file AnytimePathShortening.cpp.
◆ getPlanner()
ompl::base::PlannerPtr ompl::geometric::AnytimePathShortening::getPlanner | ( | unsigned int | idx | ) | const |
Retrieve a pointer to the ith planner instance.
Definition at line 295 of file AnytimePathShortening.cpp.
◆ getPlannerData() [1/2]
|
overridevirtual |
Get information about the most recent run of the motion planner.
- Remarks
- This call is ambiguous in this tool. By default, the planner data for the first planner in the planner list is returned.
Reimplemented from ompl::base::Planner.
Definition at line 248 of file AnytimePathShortening.cpp.
◆ getPlannerData() [2/2]
|
virtual |
Get information about the most recent run of the idxth motion planner.
Definition at line 257 of file AnytimePathShortening.cpp.
◆ getPlanners()
std::string ompl::geometric::AnytimePathShortening::getPlanners | ( | ) | const |
Get a string representation of the planners and their parameters in the format of setPlanners.
Definition at line 428 of file AnytimePathShortening.cpp.
◆ isHybridizing()
bool ompl::geometric::AnytimePathShortening::isHybridizing | ( | ) | const |
Return whether the anytime planner will extract a hybrid path from the set of solution paths.
Definition at line 311 of file AnytimePathShortening.cpp.
◆ isShortcutting()
bool ompl::geometric::AnytimePathShortening::isShortcutting | ( | ) | const |
Return whether the anytime planner will perform shortcutting on paths.
Definition at line 301 of file AnytimePathShortening.cpp.
◆ maxHybridizationPaths()
unsigned int ompl::geometric::AnytimePathShortening::maxHybridizationPaths | ( | ) | const |
Return the maximum number of paths that will be hybridized.
Definition at line 321 of file AnytimePathShortening.cpp.
◆ printSettings()
|
overridevirtual |
Print settings of this planner as well as those of the planner instances it contains.
Reimplemented from ompl::base::Planner.
Definition at line 454 of file AnytimePathShortening.cpp.
◆ setDefaultNumPlanners()
void ompl::geometric::AnytimePathShortening::setDefaultNumPlanners | ( | unsigned int | numPlanners | ) |
Set default number of planners to use if none are specified.
Definition at line 331 of file AnytimePathShortening.cpp.
◆ setHybridize()
void ompl::geometric::AnytimePathShortening::setHybridize | ( | bool | hybridize | ) |
Enable/disable path hybridization on the set of solution paths.
Definition at line 316 of file AnytimePathShortening.cpp.
◆ setMaxHybridizationPath()
void ompl::geometric::AnytimePathShortening::setMaxHybridizationPath | ( | unsigned int | maxPathCount | ) |
Set the maximum number of paths that will be hybridized.
Definition at line 326 of file AnytimePathShortening.cpp.
◆ setPlanners()
void ompl::geometric::AnytimePathShortening::setPlanners | ( | const std::string & | plannerList | ) |
Set the list of planners to use.
- Parameters
-
plannerList A string containing a comma-separated list of planner names, e.g., "PRM,EST,RRT"
This will make the list of planners equal to PRM, EST, and RRT. Optionally, planner parameters can be passed to change the default: "PRM[max_nearest_neighbors=5],EST[goal_bias=.5],RRT[range=10. goal_bias=.1]" Use spaces to separate multiple parameter settings, as shown in the example.
Definition at line 346 of file AnytimePathShortening.cpp.
◆ setShortcut()
void ompl::geometric::AnytimePathShortening::setShortcut | ( | bool | shortcut | ) |
Enable/disable shortcutting on paths.
Definition at line 306 of file AnytimePathShortening.cpp.
◆ setup()
|
overridevirtual |
Perform any necessary configuration steps. This method also invokes ompl::base::SpaceInformation::setup() if needed. This must be called before solving.
Reimplemented from ompl::base::Planner.
Definition at line 264 of file AnytimePathShortening.cpp.
◆ solve()
|
overridevirtual |
Method that solves the motion planning problem. This method terminates under just two conditions, the given argument condition, or when the maximum path length in the optimization objective is met.
- Remarks
- This method spawns a separate thread for each planner employed, and applies a series of optimization methods to the set of paths generated by each planning thread.
Implements ompl::base::Planner.
Definition at line 134 of file AnytimePathShortening.cpp.
◆ threadSolve()
|
protectedvirtual |
The function that the planning threads execute when solving a motion planning problem.
Definition at line 216 of file AnytimePathShortening.cpp.
Member Data Documentation
◆ bestCost_
|
protected |
Best cost found so far by algorithm.
Definition at line 233 of file AnytimePathShortening.h.
◆ defaultNumPlanners_
|
protected |
The number of planners to use if none are specified. This defaults to the number of cores. This parameter has no effect if planners have already been added.
Definition at line 230 of file AnytimePathShortening.h.
◆ hybridize_
|
protected |
Flag indicating whether to hybridize the set of solution paths.
Definition at line 222 of file AnytimePathShortening.h.
◆ lock_
|
protected |
mutex for updating bestCost_
Definition at line 236 of file AnytimePathShortening.h.
◆ maxHybridPaths_
|
protected |
The maximum number of paths that will be hybridized. This prohibits hybridization of a very large path set, which may take significant time.
Definition at line 226 of file AnytimePathShortening.h.
◆ planners_
|
protected |
The list of planners used for solving the problem.
Definition at line 216 of file AnytimePathShortening.h.
◆ shortcut_
|
protected |
Flag indicating whether to shortcut paths.
Definition at line 219 of file AnytimePathShortening.h.
The documentation for this class was generated from the following files:
- ompl/geometric/planners/AnytimePathShortening.h
- ompl/geometric/planners/AnytimePathShortening.cpp