template class mrpt::bayes::CParticleFilterData

Overview

This template class declares the array of particles and its internal data, managing some memory-related issues and providing an easy implementation of virtual methods required for implementing a CParticleFilterCapable.

See also the methods in the base class CParticleFilterDataImpl<>.

Since CProbabilityParticle implements all the required operators, the member “m_particles” can be safely copied with “=” or copy constructor operators and new objects will be created internally instead of copying the internal pointers, which would lead to memory corruption.

See also:

CParticleFilter, CParticleFilterCapable, CParticleFilterDataImpl

#include <mrpt/bayes/CParticleFilterData.h>

template <
    class T,
    particle_storage_mode STORAGE = particle_storage_mode::POINTER
    >
class CParticleFilterData
{
public:
    // typedefs

    typedef T CParticleDataContent;
    typedef CProbabilityParticle<T, STORAGE> CParticleData;
    typedef std::deque<CParticleData> CParticleList;

    // fields

    static const particle_storage_mode PARTICLE_STORAGE = STORAGE;
    CParticleList m_particles;

    // construction

    CParticleFilterData();

    // methods

    void clearParticles();

    template <class STREAM>
    void writeParticlesToStream(STREAM& out) const;

    template <class STREAM>
    void readParticlesFromStream(STREAM& in);

    void getWeights(std::vector<double>& out_logWeights) const;
    std::vector<double> getWeights() const;
    const CParticleData* getMostLikelyParticle() const;
};

// direct descendants

class CPose3DPDFParticles;
class CPosePDFParticles;

Typedefs

typedef T CParticleDataContent

This is the type inside the corresponding CParticleData class.

typedef CProbabilityParticle<T, STORAGE> CParticleData

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

typedef std::deque<CParticleData> CParticleList

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

Fields

CParticleList m_particles

The array of particles.

Construction

CParticleFilterData()

Default constructor.

Methods

void clearParticles()

Free the memory of all the particles and reset the array “m_particles” to length zero

template <class STREAM>
void writeParticlesToStream(STREAM& out) const

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

See also:

readParticlesFromStream

template <class STREAM>
void readParticlesFromStream(STREAM& in)

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

See also:

writeParticlesToStream

void getWeights(std::vector<double>& out_logWeights) const

Fills out_logWeights with the logarithmic weights of all particles.

std::vector<double> getWeights() const

Returns a vector with the logarithmic weights of all particles.

const CParticleData* getMostLikelyParticle() const

Returns the particle with the highest weight.