Main MRPT website > C++ reference for MRPT 1.9.9
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes
mrpt::hmtslam::CLSLAMParticleDataParticles Class Reference

Detailed Description

Definition at line 62 of file CLocalMetricHypothesis.h.

#include <mrpt/hmtslam/CLocalMetricHypothesis.h>

Inheritance diagram for mrpt::hmtslam::CLSLAMParticleDataParticles:
Inheritance graph

Public Types

typedef CLSLAMParticleData CParticleDataContent
 This is the type inside the corresponding CParticleData class. More...
 
typedef CProbabilityParticle< CLSLAMParticleDataCParticleData
 Use this to refer to each element in the m_particles array. More...
 
typedef std::deque< CParticleDataCParticleList
 Use this type to refer to the list of particles m_particles. More...
 
using TParticleProbabilityEvaluator = std::function< double(size_t index)>
 A callback function type for evaluating the probability of m_particles of being selected, used in "fastDrawSample". More...
 

Public Member Functions

void clearParticles ()
 Free the memory of all the particles and reset the array "m_particles" to length zero. More...
 
void writeParticlesToStream (STREAM &out) const
 Dumps the sequence of particles and their weights to a stream (requires T implementing CSerializable). More...
 
void readParticlesFromStream (STREAM &in)
 Reads the sequence of particles and their weights from a stream (requires T implementing CSerializable). More...
 
void getWeights (std::vector< double > &out_logWeights) const
 Returns a vector with the sequence of the logaritmic weights of all the samples. More...
 
const CParticleDatagetMostLikelyParticle () const
 Returns the particle with the highest weight. More...
 
const mrpt::bayes::CParticleFilterData< CLSLAMParticleData > & derived () const
 CRTP helper method. More...
 
mrpt::bayes::CParticleFilterData< CLSLAMParticleData > & derived ()
 CRTP helper method. More...
 
double getW (size_t i) const override
 Access to i'th particle (logarithm) weight, where first one is index 0. More...
 
void setW (size_t i, double w) override
 Modifies i'th particle (logarithm) weight, where first one is index 0. More...
 
size_t particlesCount () const override
 Get the m_particles count. More...
 
double normalizeWeights (double *out_max_log_w=nullptr) override
 Normalize the (logarithmic) weights, such as the maximum weight is zero. More...
 
double ESS () const override
 Returns the normalized ESS (Estimated Sample Size), in the range [0,1]. More...
 
void performSubstitution (const std::vector< size_t > &indx) override
 Replaces the old particles by copies determined by the indexes in "indx", performing an efficient copy of the necesary particles only and allowing the number of particles to change. More...
 
void prepareFastDrawSample (const bayes::CParticleFilter::TParticleFilterOptions &PF_options) const
 The default evaluator function, which simply returns the particle weight. More...
 
void prepareFastDrawSample (const bayes::CParticleFilter::TParticleFilterOptions &PF_options, TParticleProbabilityEvaluator partEvaluator) const
 Prepares data structures for calling fastDrawSample method next. More...
 
size_t fastDrawSample (const bayes::CParticleFilter::TParticleFilterOptions &PF_options) const
 Draws a random sample from the particle filter, in such a way that each particle has a probability proportional to its weight (in the standard PF algorithm). More...
 
void performResampling (const bayes::CParticleFilter::TParticleFilterOptions &PF_options, size_t out_particle_count=0)
 Performs a resample of the m_particles, using the method selected in the constructor. More...
 

Static Public Member Functions

static void computeResampling (CParticleFilter::TParticleResamplingAlgorithm method, const std::vector< double > &in_logWeights, std::vector< size_t > &out_indexes, size_t out_particle_count=0)
 A static method to perform the computation of the samples resulting from resampling a given set of particles, given their logarithmic weights, and a resampling method. More...
 
static void log2linearWeights (const std::vector< double > &in_logWeights, std::vector< double > &out_linWeights)
 A static method to compute the linear, normalized (the sum the unity) weights from log-weights. More...
 

Public Attributes

CParticleList m_particles
 The array of particles. More...
 

Protected Attributes

TFastDrawAuxVars m_fastDrawAuxiliary
 Auxiliary vectors, see CParticleFilterCapable::prepareFastDrawSample for more information. More...
 

Member Typedef Documentation

◆ CParticleData

Use this to refer to each element in the m_particles array.

Definition at line 203 of file CParticleFilterData.h.

◆ CParticleDataContent

This is the type inside the corresponding CParticleData class.

Definition at line 201 of file CParticleFilterData.h.

◆ CParticleList

Use this type to refer to the list of particles m_particles.

Definition at line 205 of file CParticleFilterData.h.

◆ TParticleProbabilityEvaluator

using mrpt::bayes::CParticleFilterCapable::TParticleProbabilityEvaluator = std::function<double(size_t index)>
inherited

A callback function type for evaluating the probability of m_particles of being selected, used in "fastDrawSample".

The default evaluator function "defaultEvaluator" simply returns the particle weight.

Parameters
indexThis is the index of the particle its probability is being computed.
actionThe value of this is the parameter passed to "prepareFastDrawSample"
observationThe value of this is the parameter passed to "prepareFastDrawSample" The action and the observation are declared as "void*" for a greater flexibility.
See also
prepareFastDrawSample

Definition at line 60 of file CParticleFilterCapable.h.

Member Function Documentation

◆ clearParticles()

void mrpt::bayes::CParticleFilterData< CLSLAMParticleData >::clearParticles ( )
inlineinherited

Free the memory of all the particles and reset the array "m_particles" to length zero.

Definition at line 214 of file CParticleFilterData.h.

◆ computeResampling()

void CParticleFilterCapable::computeResampling ( CParticleFilter::TParticleResamplingAlgorithm  method,
const std::vector< double > &  in_logWeights,
std::vector< size_t > &  out_indexes,
size_t  out_particle_count = 0 
)
staticinherited

A static method to perform the computation of the samples resulting from resampling a given set of particles, given their logarithmic weights, and a resampling method.

It returns the sequence of indexes from the resampling. The number of output samples is the same than the input population. This generic method just computes these indexes, to actually perform a resampling in a particle filter object, call performResampling

Parameters
[in]out_particle_countThe desired number of output particles after resampling; 0 means don't modify the current number.
See also
performResampling

Definition at line 61 of file CParticleFilterCapable.cpp.

References ASSERT_, mrpt::random::CRandomGenerator::drawUniform(), mrpt::random::CRandomGenerator::drawUniformVector(), mrpt::format(), mrpt::random::getRandomGenerator(), mrpt::math::maximum(), MRPT_END, MRPT_START, R, and THROW_EXCEPTION.

Here is the call graph for this function:

◆ derived() [1/2]

CRTP helper method.

Definition at line 35 of file CParticleFilterData.h.

◆ derived() [2/2]

CRTP helper method.

Definition at line 40 of file CParticleFilterData.h.

◆ ESS()

Returns the normalized ESS (Estimated Sample Size), in the range [0,1].

Note that you do NOT need to normalize the weights before calling this.

Implements mrpt::bayes::CParticleFilterCapable.

Definition at line 87 of file CParticleFilterData.h.

References mrpt::bayes::CParticleFilterDataImpl< Derived, particle_list_t >::derived(), MRPT_END, MRPT_START, and mrpt::math::square().

◆ fastDrawSample()

size_t CParticleFilterCapable::fastDrawSample ( const bayes::CParticleFilter::TParticleFilterOptions PF_options) const
inherited

Draws a random sample from the particle filter, in such a way that each particle has a probability proportional to its weight (in the standard PF algorithm).

This method can be used to generate a variable number of m_particles when resampling: to vary the number of m_particles in the filter. See prepareFastDrawSample for more information, or the Particle Filter tutorial.

NOTES:

  • You MUST call "prepareFastDrawSample" ONCE before calling this method. That method must be called after modifying the particle filter (executing one step, resampling, etc...)
  • This method returns ONE index for the selected ("drawn") particle, in the range [0,M-1]
  • You do not need to call "normalizeWeights" before calling this.
    See also
    prepareFastDrawSample

Definition at line 389 of file CParticleFilterCapable.cpp.

References mrpt::bayes::CParticleFilter::TParticleFilterOptions::adaptiveSampleSize, mrpt::random::CRandomGenerator::drawUniform(), mrpt::random::getRandomGenerator(), MRPT_END, MRPT_END_WITH_CLEAN_UP, MRPT_START, mrpt::bayes::CParticleFilter::TParticleFilterOptions::resamplingMethod, and THROW_EXCEPTION.

Here is the call graph for this function:

◆ getMostLikelyParticle()

const CParticleData* mrpt::bayes::CParticleFilterData< CLSLAMParticleData >::getMostLikelyParticle ( ) const
inlineinherited

Returns the particle with the highest weight.

Definition at line 270 of file CParticleFilterData.h.

◆ getW()

Access to i'th particle (logarithm) weight, where first one is index 0.

Implements mrpt::bayes::CParticleFilterCapable.

Definition at line 41 of file CParticleFilterData.h.

References mrpt::bayes::CParticleFilterDataImpl< Derived, particle_list_t >::derived(), and THROW_EXCEPTION_FMT.

◆ getWeights()

void mrpt::bayes::CParticleFilterData< CLSLAMParticleData >::getWeights ( std::vector< double > &  out_logWeights) const
inlineinherited

Returns a vector with the sequence of the logaritmic weights of all the samples.

Definition at line 256 of file CParticleFilterData.h.

◆ log2linearWeights()

void CParticleFilterCapable::log2linearWeights ( const std::vector< double > &  in_logWeights,
std::vector< double > &  out_linWeights 
)
staticinherited

A static method to compute the linear, normalized (the sum the unity) weights from log-weights.

See also
performResampling

Definition at line 455 of file CParticleFilterCapable.cpp.

References ASSERT_, MRPT_END, and MRPT_START.

◆ normalizeWeights()

double mrpt::bayes::CParticleFilterDataImpl< mrpt::bayes::CParticleFilterData< CLSLAMParticleData > , mrpt::bayes::CParticleFilterData< CLSLAMParticleData >::CParticleList >::normalizeWeights ( double *  out_max_log_w = nullptr)
inlineoverridevirtualinherited

Normalize the (logarithmic) weights, such as the maximum weight is zero.

Parameters
out_max_log_wIf provided, will return with the maximum log_w before normalizing, such as new_weights = old_weights - max_log_w.
Returns
The max/min ratio of weights ("dynamic range")

Implements mrpt::bayes::CParticleFilterCapable.

Definition at line 60 of file CParticleFilterData.h.

References mrpt::bayes::CParticleFilterDataImpl< Derived, particle_list_t >::derived(), MRPT_END, and MRPT_START.

◆ particlesCount()

◆ performResampling()

void CParticleFilterCapable::performResampling ( const bayes::CParticleFilter::TParticleFilterOptions PF_options,
size_t  out_particle_count = 0 
)
inherited

Performs a resample of the m_particles, using the method selected in the constructor.

After computing the surviving samples, this method internally calls "performSubstitution" to actually perform the particle replacement. This method is called automatically by CParticleFilter::execute, andshould not be invoked manually normally. To just obtaining the sequence of resampled indexes from a sequence of weights, use "resample"

Parameters
[in]out_particle_countThe desired number of output particles after resampling; 0 means don't modify the current number.
See also
resample

Definition at line 29 of file CParticleFilterCapable.cpp.

References ASSERT_, MRPT_END, MRPT_START, and mrpt::bayes::CParticleFilter::TParticleFilterOptions::resamplingMethod.

◆ performSubstitution()

void mrpt::bayes::CParticleFilterDataImpl< mrpt::bayes::CParticleFilterData< CLSLAMParticleData > , mrpt::bayes::CParticleFilterData< CLSLAMParticleData >::CParticleList >::performSubstitution ( const std::vector< size_t > &  indx)
inlineoverridevirtualinherited

Replaces the old particles by copies determined by the indexes in "indx", performing an efficient copy of the necesary particles only and allowing the number of particles to change.

Implements mrpt::bayes::CParticleFilterCapable.

Definition at line 114 of file CParticleFilterData.h.

References ASSERT_, mrpt::bayes::CParticleFilterDataImpl< Derived, particle_list_t >::derived(), MRPT_END, and MRPT_START.

◆ prepareFastDrawSample() [1/2]

void mrpt::bayes::CParticleFilterCapable::prepareFastDrawSample ( const bayes::CParticleFilter::TParticleFilterOptions PF_options) const
inlineinherited

The default evaluator function, which simply returns the particle weight.

The action and the observation are declared as "void*" for a greater flexibility.

See also
prepareFastDrawSample

Definition at line 68 of file CParticleFilterCapable.h.

References mrpt::bayes::CParticleFilterCapable::getW().

Here is the call graph for this function:

◆ prepareFastDrawSample() [2/2]

void CParticleFilterCapable::prepareFastDrawSample ( const bayes::CParticleFilter::TParticleFilterOptions PF_options,
TParticleProbabilityEvaluator  partEvaluator 
) const
inherited

Prepares data structures for calling fastDrawSample method next.

This method must be called once before using "fastDrawSample" (calling this more than once has no effect, but it takes time for nothing!) The behavior depends on the configuration of the PF (see CParticleFilter::TParticleFilterOptions):

  • DYNAMIC SAMPLE SIZE=NO: In this case this method fills out an internal array (m_fastDrawAuxiliary.alreadyDrawnIndexes) with the random indexes generated according to the selected resample scheme in TParticleFilterOptions. Those indexes are read sequentially by subsequent calls to fastDrawSample.
  • DYNAMIC SAMPLE SIZE=YES: Then:
    • If TParticleFilterOptions.resamplingMethod = prMultinomial, the internal buffers will be filled out (m_fastDrawAuxiliary.CDF, CDF_indexes & PDF) and then fastDrawSample can be called an arbitrary number of times to generate random indexes.
    • For the rest of resampling algorithms, an exception will be raised since they are not appropriate for a dynamic (unknown in advance) number of particles.

The function pointed by "partEvaluator" should take into account the particle filter algorithm selected in "m_PFAlgorithm". If called without arguments (defaultEvaluator), the default behavior is to draw samples with a probability proportional to their current weights. The action and the observation are declared as "void*" for a greater flexibility. For a more detailed information see the Particle Filter tutorial. Custom supplied "partEvaluator" functions must take into account the previous particle weight, i.e. multiplying the current observation likelihood by the weights.

See also
fastDrawSample

Definition at line 276 of file CParticleFilterCapable.cpp.

References mrpt::bayes::CParticleFilter::TParticleFilterOptions::adaptiveSampleSize, ASSERT_, mrpt::math::maximum(), MRPT_CHECK_NORMAL_NUMBER, MRPT_END, MRPT_END_WITH_CLEAN_UP, MRPT_START, mrpt::bayes::CParticleFilter::TParticleFilterOptions::resamplingMethod, and THROW_EXCEPTION.

Here is the call graph for this function:

◆ readParticlesFromStream()

void mrpt::bayes::CParticleFilterData< CLSLAMParticleData >::readParticlesFromStream ( STREAM &  in)
inlineinherited

Reads the sequence of particles and their weights from a stream (requires T implementing CSerializable).

See also
writeParticlesToStream

Definition at line 236 of file CParticleFilterData.h.

◆ setW()

Modifies i'th particle (logarithm) weight, where first one is index 0.

Implements mrpt::bayes::CParticleFilterCapable.

Definition at line 48 of file CParticleFilterData.h.

References mrpt::bayes::CParticleFilterDataImpl< Derived, particle_list_t >::derived(), and THROW_EXCEPTION_FMT.

◆ writeParticlesToStream()

void mrpt::bayes::CParticleFilterData< CLSLAMParticleData >::writeParticlesToStream ( STREAM &  out) const
inlineinherited

Dumps the sequence of particles and their weights to a stream (requires T implementing CSerializable).

See also
readParticlesFromStream

Definition at line 220 of file CParticleFilterData.h.

Member Data Documentation

◆ m_fastDrawAuxiliary

TFastDrawAuxVars mrpt::bayes::CParticleFilterCapable::m_fastDrawAuxiliary
mutableprotectedinherited

Auxiliary vectors, see CParticleFilterCapable::prepareFastDrawSample for more information.

Definition at line 237 of file CParticleFilterCapable.h.

◆ m_particles

The array of particles.

Definition at line 208 of file CParticleFilterData.h.




Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019