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

Inheritance diagram for ompl::geometric::AnytimePathShortening:

Public Member Functions

 AnytimePathShortening (const base::SpaceInformationPtr &si)
 Constructor requires the space information to plan in.
 
 ~AnytimePathShortening () override
 Destructor.
 
void addPlanner (base::PlannerPtr &planner)
 Adds the given planner to the set of planners used to compute candidate paths.
 
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.
 
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.
 
void setup () override
 Perform any necessary configuration steps. This method also invokes ompl::base::SpaceInformation::setup() if needed. This must be called before solving.
 
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.
 
unsigned int getNumPlanners () const
 Retrieve the number of planners added.
 
base::PlannerPtr getPlanner (unsigned int idx) const
 Retrieve a pointer to the ith planner instance.
 
bool isShortcutting () const
 Return whether the anytime planner will perform shortcutting on paths.
 
void setShortcut (bool shortcut)
 Enable/disable shortcutting on paths.
 
bool isHybridizing () const
 Return whether the anytime planner will extract a hybrid path from the set of solution paths.
 
void setHybridize (bool hybridize)
 Enable/disable path hybridization on the set of solution paths.
 
unsigned int maxHybridizationPaths () const
 Return the maximum number of paths that will be hybridized.
 
void setMaxHybridizationPath (unsigned int maxPathCount)
 Set the maximum number of paths that will be hybridized.
 
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.
 
void setDefaultNumPlanners (unsigned int numPlanners)
 Set default number of planners to use if none are specified.
 
unsigned int getDefaultNumPlanners () const
 Get default number of planners used if none are specified.
 
std::string getBestCost () const
 Return best cost found so far by algorithm.
 
void printSettings (std::ostream &out) const override
 Print settings of this planner as well as those of the planner instances it contains.
 
- Public Member Functions inherited from ompl::base::Planner
 Planner (const Planner &)=delete
 
Planneroperator= (const Planner &)=delete
 
 Planner (SpaceInformationPtr si, std::string name)
 Constructor.
 
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 SpaceInformationPtrgetSpaceInformation () const
 Get the space information this planner is using.
 
const ProblemDefinitionPtrgetProblemDefinition () const
 Get the problem definition the planner is trying to solve.
 
ProblemDefinitionPtrgetProblemDefinition ()
 Get the problem definition the planner is trying to solve.
 
const PlannerInputStatesgetPlannerInputStates () const
 Get the planner input states.
 
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().
 
PlannerStatus solve (const PlannerTerminationConditionFn &ptc, double checkInterval)
 Same as above except the termination condition is only evaluated at a specified interval.
 
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.
 
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().
 
const std::string & getName () const
 Get the name of the planner.
 
void setName (const std::string &name)
 Set the name of the planner.
 
const PlannerSpecsgetSpecs () const
 Return the specifications (capabilities of this planner)
 
bool isSetup () const
 Check if setup() was called for this planner.
 
ParamSetparams ()
 Get the parameters for this planner.
 
const ParamSetparams () const
 Get the parameters for this planner.
 
const PlannerProgressPropertiesgetPlannerProgressProperties () const
 Retrieve a planner's planner progress property map.
 
virtual void printProperties (std::ostream &out) const
 Print properties of the motion planner.
 

Static Public Member Functions

template<typename PlannerType >
static std::shared_ptr< AnytimePathShorteningcreatePlanner (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.
 
template<typename ... PlannerTypes>
static std::shared_ptr< AnytimePathShorteningcreatePlanner (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.
 
- Protected Member Functions inherited from ompl::base::Planner
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.
 
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.
 
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.
 

Protected Attributes

std::vector< base::PlannerPtr > planners_
 The list of planners used for solving the problem.
 
bool shortcut_ {true}
 Flag indicating whether to shortcut paths.
 
bool hybridize_ {true}
 Flag indicating whether to hybridize the set of solution paths.
 
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.
 
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.
 
base::Cost bestCost_ {std::numeric_limits<double>::quiet_NaN()}
 Best cost found so far by algorithm.
 
std::mutex lock_
 mutex for updating bestCost_
 
- Protected Attributes inherited from ompl::base::Planner
SpaceInformationPtr si_
 The space information for which planning is done.
 
ProblemDefinitionPtr pdef_
 The user set problem definition.
 
PlannerInputStates pis_
 Utility class to extract valid input states

 
std::string name_
 The name of this planner.
 
PlannerSpecs specs_
 The specifications of the planner (its capabilities)
 
ParamSet params_
 A map from parameter names to parameter instances for this planner. This field is populated by the declareParam() function.
 
PlannerProgressProperties plannerProgressProperties_
 A mapping between this planner's progress property names and the functions used for querying those progress properties.
 
bool setup_
 Flag indicating whether setup() has been called.
 

Additional Inherited Members

- Public Types inherited from ompl::base::Planner
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.
 
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.
 

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 145 of file AnytimePathShortening.h.

Member Function Documentation

◆ addPath()

void ompl::geometric::AnytimePathShortening::addPath ( const geometric::PathGeometricPtr &  path,
base::Planner planner 
)
protected

add a path to set of solutions

Parameters
pathsolution path
plannerplanner 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.

◆ createPlanner()

template<typename ... PlannerTypes>
static std::shared_ptr<AnytimePathShortening> ompl::geometric::AnytimePathShortening::createPlanner ( const base::SpaceInformationPtr &  si)
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 201 of file AnytimePathShortening.h.

◆ getPlannerData()

void ompl::geometric::AnytimePathShortening::getPlannerData ( base::PlannerData data) const
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.

◆ setPlanners()

void ompl::geometric::AnytimePathShortening::setPlanners ( const std::string &  plannerList)

Set the list of planners to use.

Parameters
plannerListA 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.

◆ solve()

ompl::base::PlannerStatus ompl::geometric::AnytimePathShortening::solve ( const base::PlannerTerminationCondition ptc)
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.


The documentation for this class was generated from the following files: