RobWorkProject
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
QSampler Class Referenceabstract

Interface for the sampling a configuration. More...

#include <QSampler.hpp>

Inherited by RandomSampler.

Public Types

typedef rw::common::Ptr< QSamplerPtr
 smart pointer type to this class
 
typedef rw::common::Ptr< const QSamplerCPtr
 smart pointer type to this const class
 

Public Member Functions

rw::math::Q sample ()
 Sample a configuration. More...
 
bool empty () const
 True if the sampler is known to contain no more configurations.
 
virtual ~QSampler ()
 Destructor.
 

Static Public Member Functions

static QSampler::Ptr makeEmpty ()
 Empty sampler.
 
static QSampler::Ptr makeFixed (const rw::math::Q &q)
 Sampler that always returns the same configuration. More...
 
static QSampler::Ptr makeSingle (const rw::math::Q &q)
 Sampler that always returns a single configuration. More...
 
static QSampler::Ptr makeFinite (const std::vector< rw::math::Q > &qs)
 Sampler for the values of a finite sequence. More...
 
static QSampler::Ptr makeFinite (QSampler::Ptr sampler, int cnt)
 A sampler to that returns only the first cnt samples from another sampler. More...
 
static QSampler::Ptr makeUniform (const rw::models::Device::QBox &bounds)
 Uniform random sampling for a box of the configuration space.
 
static QSampler::Ptr makeUniform (const rw::models::Device &device)
 Uniform random sampling for a device.
 
static QSampler::Ptr makeUniform (rw::models::Device::CPtr device)
 Uniform random sampling for a device.
 
static QSampler::Ptr makeNormalized (QSampler::Ptr sampler, const QNormalizer &normalizer)
 Map a sampler of standard configurations into a sampler of normalized configurations.
 
static QSampler::Ptr make (rw::common::Ptr< QIKSampler > sampler, const rw::math::Transform3D<> &target)
 A sampler of IK solutions for a specific target. More...
 
static QSampler::Ptr makeConstrained (QSampler::Ptr sampler, rw::common::Ptr< const QConstraint > constraint, int maxAttempts=-1)
 A sampler filtered by a constraint. More...
 
static QSampler::Ptr makeBoxDirectionSampler (const rw::models::Device::QBox &bounds)
 Sampler of direction vectors for a box shaped configuration space. More...
 

Protected Member Functions

 QSampler ()
 Constructor.
 
virtual rw::math::Q doSample ()=0
 Subclass implementation of the sample() method.
 
virtual bool doEmpty () const
 Subclass implementation of the empty() method. More...
 

Detailed Description

Interface for the sampling a configuration.

Member Function Documentation

◆ doEmpty()

virtual bool doEmpty ( ) const
protectedvirtual

Subclass implementation of the empty() method.

By default the sampler is assumed to be sampling an infinite set of configurations. IOW. the function returns false by default.

◆ make()

static QSampler::Ptr make ( rw::common::Ptr< QIKSampler sampler,
const rw::math::Transform3D<> &  target 
)
static

A sampler of IK solutions for a specific target.

Parameters
sampler[in] Sampler of IK solutions for target.
target[in] Target for IK solver.

◆ makeBoxDirectionSampler()

static QSampler::Ptr makeBoxDirectionSampler ( const rw::models::Device::QBox bounds)
static

Sampler of direction vectors for a box shaped configuration space.

Each random direction vector is found by sampling a configuration uniformly at random from bounds, and returning the vector from the center of the box to the configuration. The returned direction vector can therefore be of length zero.

◆ makeConstrained()

static QSampler::Ptr makeConstrained ( QSampler::Ptr  sampler,
rw::common::Ptr< const QConstraint constraint,
int  maxAttempts = -1 
)
static

A sampler filtered by a constraint.

For each call of sample() up to maxAttempts configurations are extracted from sampler and checked by constraint. The first sample that satisfies the constraint is returned; if no such were found the empty configuration is returned.

If maxAttempts is negative (this is the default), then sampler is sampled forever until either the sampler is empty or a configuration satisfying constraint is found.

◆ makeFinite() [1/2]

static QSampler::Ptr makeFinite ( const std::vector< rw::math::Q > &  qs)
static

Sampler for the values of a finite sequence.

sample() returns each of the values of qs in order. When all of these samples have been returned, empty() returns true and sample() returns the empty configuration.

◆ makeFinite() [2/2]

static QSampler::Ptr makeFinite ( QSampler::Ptr  sampler,
int  cnt 
)
static

A sampler to that returns only the first cnt samples from another sampler.

The sampler is considered empty as soon as sampler is empty or the sampler has been called cnt times or more.

◆ makeFixed()

static QSampler::Ptr makeFixed ( const rw::math::Q q)
static

Sampler that always returns the same configuration.

The sampler is considered never empty (empty() always returns false).

◆ makeSingle()

static QSampler::Ptr makeSingle ( const rw::math::Q q)
static

Sampler that always returns a single configuration.

The sample() returns q the first time the method is called and the empty configuration otherwise. empty() returns true after the first call of sample().

◆ sample()

rw::math::Q sample ( )
inline

Sample a configuration.

If sampling fails, the sampler may return the empty configuration. If empty() is true then the sampler has no more configurations. Otherwise sample() may (or may not) succeed if called a second time.


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