PPL API Reference
Overview Core Algorithm Abstractions Utilities Parallel Methods
Modules Class Hierarchy Classes Functions
Todo List Bug List Dead Code
List of all members | Protected Member Functions | Protected Attributes | Friends
SamplerMethod< MPTraits > Class Template Referenceabstract

Public Member Functions

Construction
 SamplerMethod ()=default
 
 SamplerMethod (XMLNode &_node)
 
virtual ~SamplerMethod ()=0
 
Individual Configuration Sampling
virtual void Sample (size_t _numNodes, size_t _maxAttempts, const Boundary *const _boundary, OutputIterator _valid, OutputIterator _invalid)
 
virtual void Sample (size_t _numNodes, size_t _maxAttempts, const Boundary *const _boundary, OutputIterator _valid)
 
virtual void Sample (size_t _numNodes, size_t _maxAttempts, const Boundary *const _robotBoundary, const Boundary *const _eeBoundary, OutputIterator _valid, OutputIterator _invalid)
 
virtual void Sample (size_t _numNodes, size_t _maxAttempts, const Boundary *const _robotBoundary, const Boundary *const _eeBoundary, OutputIterator _valid)
 
virtual void Filter (InputIterator _first, InputIterator _last, size_t _maxAttempts, const Boundary *const _boundary, OutputIterator _valid, OutputIterator _invalid)
 
void Filter (InputIterator _first, InputIterator _last, size_t _maxAttempts, const Boundary *const _boundary, OutputIterator _valid)
 
Group Configuration Sampling
virtual void Sample (size_t _numNodes, size_t _maxAttempts, const Boundary *const _boundary, GroupOutputIterator _valid, GroupOutputIterator _invalid)
 
virtual void Sample (size_t _numNodes, size_t _maxAttempts, const Boundary *const _boundary, GroupOutputIterator _valid)
 
virtual void Sample (size_t _numNodes, size_t _maxAttempts, const BoundaryMap &_boundary, GroupOutputIterator _valid, GroupOutputIterator _invalid)
 
virtual void Sample (size_t _numNodes, size_t _maxAttempts, const BoundaryMap &_boundary, GroupOutputIterator _valid)
 
virtual void Filter (GroupInputIterator _first, GroupInputIterator _last, size_t _maxAttempts, const Boundary *const _boundary, GroupOutputIterator _valid, GroupOutputIterator _invalid)
 
void Filter (GroupInputIterator _first, GroupInputIterator _last, size_t _maxAttempts, const Boundary *const _boundary, GroupOutputIterator _valid)
 
I/O
virtual void Print (std::ostream &_os) const
 
Initialization
virtual void Initialize ()
 
Name and Label Accessors
const std::string & GetName () const
 Get the class name for this object.
 
const std::string & GetLabel () const
 Get the unique label for this object.
 
std::string GetNameAndLabel () const
 Get the unique string identifier for this object "m_name::m_label".
 
void SetLabel (const std::string &)
 Set the unique label for this object.
 
MPLibrary Accessors
void SetMPLibrary (MPLibrary *) noexcept
 Set the owning MPLibrary.
 
MPLibraryGetMPLibrary () const noexcept
 Get the owning MPLibrary.
 
bool IsRunning () const noexcept
 Check the library's running flag.
 
DistanceMetricPointer GetDistanceMetric (const std::string &) const noexcept
 Get a distance metric by label from the owning MPLibrary.
 
ValidityCheckerPointer GetValidityChecker (const std::string &) const noexcept
 Get a validity checker by label from the owning MPLibrary.
 
NeighborhoodFinderPointer GetNeighborhoodFinder (const std::string &) const noexcept
 Get a neighborhood finder by label from the owning MPLibrary.
 
SamplerPointer GetSampler (const std::string &) const noexcept
 Get a sampler by label from the owning MPLibrary.
 
LocalPlannerPointer GetLocalPlanner (const std::string &) const noexcept
 Get a local planner by label from the owning MPLibrary.
 
ExtenderPointer GetExtender (const std::string &) const noexcept
 Get an extender by label from the owning MPLibrary.
 
PathModifierPointer GetPathModifier (const std::string &) const noexcept
 Get a path modifier by label from the owning MPLibrary.
 
ConnectorPointer GetConnector (const std::string &) const noexcept
 Get a connector by label from the owning MPLibrary.
 
MetricPointer GetMetric (const std::string &) const noexcept
 Get a metric by label from the owning MPLibrary.
 
MapEvaluatorPointer GetMapEvaluator (const std::string &) const noexcept
 Get a map evaluator by label from the owning MPLibrary.
 
MPStrategyPointer GetMPStrategy (const std::string &) const noexcept
 Get a strategy by label from the owning MPLibrary.
 
MPTraits::MPToolsGetMPTools () const noexcept
 Get the MPTools container from the owning MPLibrary.
 
Problem Accessors
MPProblemGetMPProblem () const noexcept
 Get the library's current MPProblem.
 
EnvironmentGetEnvironment () const noexcept
 Get the current environment.
 
MPTaskGetTask () const noexcept
 Get the current task.
 
GroupTaskGetGroupTask () const noexcept
 Get the current group task.
 
Solution Accessors
MPSolutionGetMPSolution () const noexcept
 
RoadmapTypeGetRoadmap (Robot *const _r=nullptr) const noexcept
 Get the current free-space roadmap.
 
GroupRoadmapTypeGetGroupRoadmap (RobotGroup *const _g=nullptr) const noexcept
 Get the current free-space group roadmap.
 
RoadmapTypeGetBlockRoadmap (Robot *const _r=nullptr) const noexcept
 Get the current obstacle-space roadmap.
 
PathGetPath (Robot *const _r=nullptr) const noexcept
 Get the current best path.
 
GroupPathGetGroupPath (RobotGroup *const _g=nullptr) const noexcept
 Get the current best group path.
 
StatClassGetStatClass () const noexcept
 Get the current StatClass.
 
LocalObstacleMapGetLocalObstacleMap () const noexcept
 Get the local obstacle map.
 
GoalTrackerGetGoalTracker () const noexcept
 Get the goal tracker.
 

Public Types

Motion Planning Types
typedef MPTraits::CfgType CfgType
 
typedef MPTraits::GroupCfgType GroupCfgType
 
Local Types
typedef std::vector< CfgType >::iterator InputIterator
 
typedef std::back_insert_iterator< std::vector< CfgType > > OutputIterator
 
typedef std::vector< GroupCfgType >::iterator GroupInputIterator
 
typedef std::back_insert_iterator< std::vector< GroupCfgType > > GroupOutputIterator
 
typedef std::map< Robot *, const Boundary * > BoundaryMap
 A map from robots to sampling boundaries.
 
Local Types
typedef MPTraits::RoadmapType RoadmapType
 
typedef MPTraits::GroupRoadmapType GroupRoadmapType
 
typedef MPTraits::LocalObstacleMap LocalObstacleMap
 
typedef MPTraits::Path Path
 
typedef MPTraits::GroupPathType GroupPath
 
typedef MPTraits::MPLibrary MPLibrary
 
typedef MPTraits::MPSolution MPSolution
 
typedef MPTraits::GoalTracker GoalTracker
 
typedef MPLibrary::SamplerPointer SamplerPointer
 
typedef MPLibrary::LocalPlannerPointer LocalPlannerPointer
 
typedef MPLibrary::ExtenderPointer ExtenderPointer
 
typedef MPLibrary::PathModifierPointer PathModifierPointer
 
typedef MPLibrary::ConnectorPointer ConnectorPointer
 
typedef MPLibrary::MetricPointer MetricPointer
 
typedef MPLibrary::MapEvaluatorPointer MapEvaluatorPointer
 
typedef MPLibrary::MPStrategyPointer MPStrategyPointer
 
typedef MPLibrary::DistanceMetricPointer DistanceMetricPointer
 
typedef MPLibrary::ValidityCheckerPointer ValidityCheckerPointer
 
typedef MPLibrary::NeighborhoodFinderPointer NeighborhoodFinderPointer
 

Protected Member Functions

void SetName (const std::string &_s)
 
const std::string & GetBaseFilename () const
 
Sampler Rule

The default implementations of these throw exceptions so that derived classes can avoid implementing unsupported functions (as opposed to making these pure virtual).

virtual bool Sampler (CfgType &_cfg, const Boundary *const _boundary, std::vector< CfgType > &_valid, std::vector< CfgType > &_invalid)
 
virtual bool Sampler (CfgType &_cfg, const Boundary *const _robotBoundary, const Boundary *const _eeBoundary, std::vector< CfgType > &_valid, std::vector< CfgType > &_invalid)
 
virtual bool Sampler (GroupCfgType &_cfg, const Boundary *const _boundary, std::vector< GroupCfgType > &_valid, std::vector< GroupCfgType > &_invalid)
 
virtual bool Sampler (GroupCfgType &_cfg, const BoundaryMap &_boundaryMap, std::vector< GroupCfgType > &_valid, std::vector< GroupCfgType > &_invalid)
 

Protected Attributes

bool m_debug
 Print debug info?
 

Friends

class MixSampler< MPTraits >
 

Detailed Description

template<typename MPTraits>
class SamplerMethod< MPTraits >

Base algorithm abstraction for Samplers.

SamplerMethod has three sets of important functions. The first two are the various public methods in the base class, Sample and Filter, and third is the private virtual function which the derived classes overload, Sampler.

Sample is called in various ways but they break down into two forms: desired number and input configurations. When specifying a desired number n of configurations the sampler attempts a attempts per desired sample. The output is placed on an output iterator.

Usage:\n
size_t num, attempts;
Boundary* bounds;
std::vector<CfgType> valid;
auto s = this->GetSampler(m_sLabel);
s->Sample(num, attempts, bounds, std::back_inserter(valid));
Definition: Boundary.h:30
SamplerPointer GetSampler(const std::string &) const noexcept
Get a sampler by label from the owning MPLibrary.
Definition: MPBaseObject.h:363

Filter sends a list of input configurations to apply the sampler rule to.

Usage:\n
std::vector<CfgType> input, valid;
size_t attempts;
Boundary* bounds;
auto s = this->GetSampler(m_sLabel);
s->Filter(input.begin(), input.end(), attempts, bounds,
std::back_inserter(valid));
Todo:
The present implementation of Sample temporarily saves invalid configurations whether we will use them or not. Avoiding this extraneous retention will likely have good performance benefits in sampling-intensive applications such as proteins and manipulators where the success rate is very low.
Todo:
The present layout of this class is confusing since the base method is actually generating uniform random samples which are filtered by the derived class. This does not work for many derived classes as evidenced by their overriding of Sample rather than Sampler: we should rework the design so that derived classes generate and filter their own samples. The base class can then implement its functions in terms of the generate and filter helpers.

Member Function Documentation

◆ Sample() [1/8]

template<typename MPTraits >
void SamplerMethod< MPTraits >::Sample ( size_t  _numNodes,
size_t  _maxAttempts,
const Boundary *const  _boundary,
OutputIterator  _valid,
OutputIterator  _invalid 
)
virtual

Try to sample a set number of new configurations from a given boundary.

Parameters
_numNodesThe number of samples desired.
_maxAttemptsThe maximum number of attempts for each sample.
_boundaryThe boundary to sample from.
_validAn iterator to storage for the new configurations.
_invalidAn (optional) iterator to storage for failed attempts.

◆ Sample() [2/8]

template<typename MPTraits >
void SamplerMethod< MPTraits >::Sample ( size_t  _numNodes,
size_t  _maxAttempts,
const Boundary *const  _boundary,
OutputIterator  _valid 
)
virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Sample() [3/8]

template<typename MPTraits >
void SamplerMethod< MPTraits >::Sample ( size_t  _numNodes,
size_t  _maxAttempts,
const Boundary *const  _robotBoundary,
const Boundary *const  _eeBoundary,
OutputIterator  _valid,
OutputIterator  _invalid 
)
virtual

Try to sample a set number of new configurations from a given boundary (for the entire robot), and additionally satisfying a constraint boundary for the end-effector (robot is presumed to have only one EE).

Parameters
_robotBoundaryThe boundary for the entire robot.
_eeBoundaryThe boundary for the end-effector.

◆ Sample() [4/8]

template<typename MPTraits >
void SamplerMethod< MPTraits >::Sample ( size_t  _numNodes,
size_t  _maxAttempts,
const Boundary *const  _robotBoundary,
const Boundary *const  _eeBoundary,
OutputIterator  _valid 
)
virtual

This version does not return invalid samples. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Filter() [1/4]

template<typename MPTraits >
void SamplerMethod< MPTraits >::Filter ( InputIterator  _first,
InputIterator  _last,
size_t  _maxAttempts,
const Boundary *const  _boundary,
OutputIterator  _valid,
OutputIterator  _invalid 
)
virtual

Apply the sampler rule to a set of existing configurations. The output will generally be a filtered or perturbed version of the input set.

Parameters
_firstAn iterator to the beginning of a list of input configurations.
_lastAn iterator to the end of a list of input configurations.
_maxAttemptsThe maximum number of attempts to successfully apply the sampler rule to each input.
_boundaryThe sampling boundary to use.
_validAn iterator to storage for the output configurations.
_invalidAn (optional) iterator to storage for failed attempts.

◆ Filter() [2/4]

template<typename MPTraits >
void SamplerMethod< MPTraits >::Filter ( InputIterator  _first,
InputIterator  _last,
size_t  _maxAttempts,
const Boundary *const  _boundary,
OutputIterator  _valid 
)

This version does not return invalid samples. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Sample() [5/8]

template<typename MPTraits >
void SamplerMethod< MPTraits >::Sample ( size_t  _numNodes,
size_t  _maxAttempts,
const Boundary *const  _boundary,
GroupOutputIterator  _valid,
GroupOutputIterator  _invalid 
)
virtual

Try to sample a set number of new configurations from a single boundary.

Parameters
_numNodesThe number of samples desired.
_maxAttemptsThe maximum number of attempts for each sample.
_boundaryThe boundary to sample from.
_validAn iterator to storage for the new configurations.
_invalidAn (optional) iterator to storage for failed attempts.

◆ Sample() [6/8]

template<typename MPTraits >
void SamplerMethod< MPTraits >::Sample ( size_t  _numNodes,
size_t  _maxAttempts,
const Boundary *const  _boundary,
GroupOutputIterator  _valid 
)
virtual

This version does not return invalid samples. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Sample() [7/8]

template<typename MPTraits >
void SamplerMethod< MPTraits >::Sample ( size_t  _numNodes,
size_t  _maxAttempts,
const BoundaryMap _boundary,
GroupOutputIterator  _valid,
GroupOutputIterator  _invalid 
)
virtual

Try to sample a set number of new configurations from a boundary for each robot.

Parameters
_numNodesThe number of samples desired.
_maxAttemptsThe maximum number of attempts for each sample.
_boundaryMapA map from robot to sampling boundary. Any robots which are not found in the map will use the environment boundary.
_validAn iterator to storage for the new configurations.
_invalidAn (optional) iterator to storage for failed attempts.

◆ Sample() [8/8]

template<typename MPTraits >
void SamplerMethod< MPTraits >::Sample ( size_t  _numNodes,
size_t  _maxAttempts,
const BoundaryMap _boundary,
GroupOutputIterator  _valid 
)
virtual

This version does not return invalid samples. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Filter() [3/4]

template<typename MPTraits >
void SamplerMethod< MPTraits >::Filter ( GroupInputIterator  _first,
GroupInputIterator  _last,
size_t  _maxAttempts,
const Boundary *const  _boundary,
GroupOutputIterator  _valid,
GroupOutputIterator  _invalid 
)
virtual

Apply the sampler rule to a set of existing configurations. The output will generally be a filtered or perturbed version of the input set.

Parameters
_firstAn iterator to the beginning of a list of input configurations.
_lastAn iterator to the end of a list of input configurations.
_maxAttemptsThe maximum number of attempts to successfully apply the sampler rule to each input.
_boundaryThe sampling boundary to use.
_validAn iterator to storage for the output configurations.
_invalidAn (optional) iterator to storage for failed attempts.

◆ Filter() [4/4]

template<typename MPTraits >
void SamplerMethod< MPTraits >::Filter ( GroupInputIterator  _first,
GroupInputIterator  _last,
size_t  _maxAttempts,
const Boundary *const  _boundary,
GroupOutputIterator  _valid 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Sampler() [1/4]

template<typename MPTraits >
bool SamplerMethod< MPTraits >::Sampler ( CfgType &  _cfg,
const Boundary *const  _boundary,
std::vector< CfgType > &  _valid,
std::vector< CfgType > &  _invalid 
)
protectedvirtual

Takes a single input configuration and applies the sampler rule to generate one or more output configurations.

Parameters
_cfgThe input configuration.
_boundaryThe sampling boundary.
_validThe resulting output configurations.
_invalidThe (optional) return for failed attempts.
Returns
True if a valid configuration was generated, false otherwise.

Reimplemented in UniformRandomSampler< MPTraits >.

◆ Sampler() [2/4]

template<typename MPTraits >
bool SamplerMethod< MPTraits >::Sampler ( CfgType &  _cfg,
const Boundary *const  _robotBoundary,
const Boundary *const  _eeBoundary,
std::vector< CfgType > &  _valid,
std::vector< CfgType > &  _invalid 
)
protectedvirtual

This version also specifies a boundary for the end-effector. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Sampler() [3/4]

template<typename MPTraits >
bool SamplerMethod< MPTraits >::Sampler ( GroupCfgType _cfg,
const Boundary *const  _boundary,
std::vector< GroupCfgType > &  _valid,
std::vector< GroupCfgType > &  _invalid 
)
protectedvirtual

Takes a single input configuration and applies the sampler rule to generate one or more output configurations.

Parameters
_cfgThe input group configuration.
_boundaryThe sampling boundary.
_validThe resulting output configurations.
_invalidThe (optional) return for failed attempts.
Returns
True if a valid configuration was generated, false otherwise.

Reimplemented in UniformRandomSampler< MPTraits >.

◆ Sampler() [4/4]

template<typename MPTraits >
bool SamplerMethod< MPTraits >::Sampler ( GroupCfgType _cfg,
const BoundaryMap _boundaryMap,
std::vector< GroupCfgType > &  _valid,
std::vector< GroupCfgType > &  _invalid 
)
protectedvirtual

This version specifies a (possibly different) boundary for each robot. Robots which are not in the boundary map will use the environment boundary. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Reimplemented in UniformRandomSampler< MPTraits >.

◆ Print()

template<typename MPTraits >
void MPBaseObject< MPTraits >::Print ( std::ostream &  _os) const
virtualinherited

◆ Initialize()

template<typename MPTraits >
virtual void MPBaseObject< MPTraits >::Initialize ( )
virtualinherited

Initialize this object for the current MPProblem. This should reset any internal state of the algorithms so that they are ready for execution. It is also the place to initialize any state that depends on the current problem.

Warning
This member will be called for every compiled algorithm in the planning library - even those that will not be used. If an algorithm needs to do expenisve setup, then this method should only set a flag that tells it to do so on first use. The only exceptions are the MPStrategies, which will only have their initialize called on first use.

Reimplemented in ConnectorMethod< MPTraits >, CBSQuery< MPTraits >, ComposeEvaluator< MPTraits >, LazyQuery< MPTraits >, QueryMethod< MPTraits >, SIPPMethod< MPTraits >, TimeEvaluator< MPTraits >, TimeMetric< MPTraits >, AdaptiveRRT< MPTraits >, BasicPRM< MPTraits >, BasicRRTStrategy< MPTraits >, TogglePRMStrategy< MPTraits >, ValidationStrategy< MPTraits >, LKHSearch< MPTraits >, ClearanceUtility< MPTraits >, ReachabilityUtil< MPTraits >, SafeIntervalTool< MPTraits >, and TopologicalMap< MPTraits >.

◆ SetName()

template<typename MPTraits >
void MPBaseObject< MPTraits >::SetName ( const std::string &  _s)
protectedinherited
Parameters
_sClass name

◆ GetBaseFilename()

template<typename MPTraits >
const std::string & MPBaseObject< MPTraits >::GetBaseFilename ( ) const
protectedinherited
Returns
base file name from MPProblem

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