Parasol Planning Library (PPL)
Friends
SamplerMethod Class Referenceabstract

#include <SamplerMethod.h>

Inheritance diagram for SamplerMethod:
Inheritance graph
[legend]
Collaboration diagram for SamplerMethod:
Collaboration graph
[legend]

Public Types

Motion Planning Types
typedef MPBaseObject::GroupCfgType GroupCfgType
 
Local Types
typedef std::vector< Cfg >::iterator InputIterator
 
typedef std::back_insert_iterator< std::vector< Cfg > > 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. More...
 
- Public Types inherited from MPBaseObject
typedef DefaultWeight< CfgWeightType
 
typedef GenericStateGraph< Cfg, WeightTypeRoadmapType
 
typedef GroupCfg< RoadmapTypeGroupCfgType
 
typedef GroupLocalPlan< RoadmapTypeGroupWeightType
 
typedef GroupRoadmap< GroupCfgType, GroupWeightTypeGroupRoadmapType
 

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)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
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)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
- Public Member Functions inherited from MPBaseObject
 MPBaseObject (const std::string &_label="", const std::string &_name="", bool _debug=false)
 
 MPBaseObject (XMLNode &_node)
 
virtual ~MPBaseObject ()
 
virtual void Print (std::ostream &_os) const
 
virtual void Initialize ()
 
const std::string & GetName () const
 Get the class name for this object. More...
 
const std::string & GetLabel () const
 Get the unique label for this object. More...
 
std::string GetNameAndLabel () const
 Get the unique string identifier for this object "m_name::m_label". More...
 
void SetLabel (const std::string &)
 Set the unique label for this object. More...
 
void SetMPLibrary (MPLibrary *) noexcept
 Set the owning MPLibrary. More...
 
MPLibraryGetMPLibrary () const noexcept
 Get the owning MPLibrary. More...
 
bool IsRunning () const noexcept
 Check the library's running flag. More...
 
MPProblemGetMPProblem () const noexcept
 Get the library's current MPProblem. More...
 
EnvironmentGetEnvironment () const noexcept
 Get the current environment. More...
 
MPTaskGetTask () const noexcept
 Get the current task. More...
 
GroupTaskGetGroupTask () const noexcept
 Get the current group task. More...
 
MPSolutionTypeGetMPSolution () const noexcept
 
RoadmapTypeGetRoadmap (Robot *const _r=nullptr) const noexcept
 Get the current free-space roadmap. More...
 
GroupRoadmapTypeGetGroupRoadmap (RobotGroup *const _g=nullptr) const noexcept
 Get the current free-space group roadmap. More...
 
RoadmapTypeGetBlockRoadmap (Robot *const _r=nullptr) const noexcept
 Get the current obstacle-space roadmap. More...
 
PathGetPath (Robot *const _r=nullptr) const noexcept
 
GroupPathGetGroupPath (RobotGroup *const _g=nullptr) const noexcept
 Get the current best group path. More...
 
StatClassGetStatClass () const noexcept
 Get the current StatClass. More...
 
LocalObstacleMapGetLocalObstacleMap () const noexcept
 Get the local obstacle map. More...
 

Protected Member Functions

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 (Cfg &_cfg, const Boundary *const _boundary, std::vector< Cfg > &_valid, std::vector< Cfg > &_invalid)
 
virtual bool Sampler (Cfg &_cfg, const Boundary *const _robotBoundary, const Boundary *const _eeBoundary, std::vector< Cfg > &_valid, std::vector< Cfg > &_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 Member Functions inherited from MPBaseObject
void SetName (const std::string &_s)
 
const std::string & GetBaseFilename () const
 

Friends

class MixSampler
 

Additional Inherited Members

- Protected Attributes inherited from MPBaseObject
bool m_debug
 Print debug info? More...
 

Detailed Description

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

size_t num, attempts;
Boundary* bounds;
std::vector<Cfg> valid;
auto s = this->GetSampler(m_sLabel);
s->Sample(num, attempts, bounds, std::back_inserter(valid));
Definition: Boundary.h:30

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

@usage

std::vector<Cfg> 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.
Examples
Samplers_UseCase.cpp.

Member Typedef Documentation

◆ BoundaryMap

typedef std::map<Robot*, const Boundary*> SamplerMethod::BoundaryMap

A map from robots to sampling boundaries.

◆ GroupCfgType

◆ GroupInputIterator

typedef std::vector<GroupCfgType>::iterator SamplerMethod::GroupInputIterator

◆ GroupOutputIterator

typedef std::back_insert_iterator<std::vector<GroupCfgType> > SamplerMethod::GroupOutputIterator

◆ InputIterator

typedef std::vector<Cfg>::iterator SamplerMethod::InputIterator

◆ OutputIterator

typedef std::back_insert_iterator<std::vector<Cfg> > SamplerMethod::OutputIterator

Constructor & Destructor Documentation

◆ SamplerMethod() [1/2]

SamplerMethod::SamplerMethod ( )
default

◆ SamplerMethod() [2/2]

SamplerMethod::SamplerMethod ( XMLNode _node)

◆ ~SamplerMethod()

SamplerMethod::~SamplerMethod ( )
pure virtualdefault

Member Function Documentation

◆ Filter() [1/4]

void SamplerMethod::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.

◆ Filter() [2/4]

void SamplerMethod::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() [3/4]

void SamplerMethod::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.

◆ Filter() [4/4]

void SamplerMethod::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.
Examples
Samplers_UseCase.cpp.

◆ Sample() [1/8]

void SamplerMethod::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() [2/8]

void SamplerMethod::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() [3/8]

void SamplerMethod::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() [4/8]

void SamplerMethod::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.
Examples
Samplers_UseCase.cpp.

◆ Sample() [5/8]

void SamplerMethod::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.

◆ Sample() [6/8]

void SamplerMethod::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() [7/8]

void SamplerMethod::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.

◆ Sample() [8/8]

void SamplerMethod::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.

◆ Sampler() [1/4]

bool SamplerMethod::Sampler ( Cfg _cfg,
const Boundary *const  _boundary,
std::vector< Cfg > &  _valid,
std::vector< Cfg > &  _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 BridgeTestSampler, MixSampler, GaussianSampler, UniformRandomSampler, UniformObstacleBasedSampler, and ObstacleBasedSampler.

◆ Sampler() [2/4]

bool SamplerMethod::Sampler ( Cfg _cfg,
const Boundary *const  _robotBoundary,
const Boundary *const  _eeBoundary,
std::vector< Cfg > &  _valid,
std::vector< Cfg > &  _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]

bool SamplerMethod::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 BridgeTestSampler, UniformRandomSampler, UniformObstacleBasedSampler, and ObstacleBasedSampler.

◆ Sampler() [4/4]

bool SamplerMethod::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, BridgeTestSampler, and ObstacleBasedSampler.

Friends And Related Function Documentation

◆ MixSampler

friend class MixSampler
friend

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