The following C++ classes are the base for different PF implementations all across MRPT:
Both the specific particle filter algorithm to run and the resampling scheme to use can be independently selected in the options structuremrpt::bayes::CParticleFilter::TParticleFilterOptions:
Standard proposal distribution + weights according to likelihood function.
This method was introduced by Pitt and Shephard in 1999 [1].
Let's assume the filtered posterior is described by the following M weighted samples:
Then, each step in the algorithm consists of first drawing a sample of the particle index k which will be propragated from t − 1 into the new step t. These indexes are auxiliary variables only used as an intermediary step, hence the name of the algorithm. The indexes are drawn according to the likelihood of some reference point which in some way is related to the transition model xt | xt − 1 (for example, the mean, a sample, etc.):
This is repeated for i = 1,2,...,M, and using these indexes we can now draw the conditional samples:
Finally, the weights are updated to account for the mismatch between the likelihood at the actual sample and the predicted point :
Use the exact optimal proposal distribution (where available!, usually this will perform approximations).
In the case of the RBPF-SLAM implementation, this method follows [1].
Use the optimal proposal and a auxiliary particle filter (see paper[1]).
Both the specific particle filter algorithm to run and the resampling scheme to use can be independently selected in the options structuremrpt::bayes::CParticleFilter::TParticleFilterOptions:
This section reviews four different strategies for resampling a set of particles whose normalized weights are given by ω[i] for i = 1,...,N.
The methods are explained using a visual analogy with a "wheel" whose perimeter is assigned to the different particles in such a way that the length associated to the i 'th particle is proportional to its weight ω[i]. Therefore, picking a random direction in this "wheel" implies choosing a particle with a probability proportional to its weight. For a more formal description of the methods, please refer to the excellent paper by Douc, Cappé and Moulines.
The most straighforward method, where N independent random numbers are generated to pick a particle from the old set. In the "wheel" analogy, illustrated in the figure below, this method consists of picking N independent random directions.
The name of this method comes from the fact that the probability mass function for the duplication counts Ni is the multinomial distribution with the weights as parameters.
This method comprises of two stages. Firstly, particles are sampled deterministically by picking copies of the i'th particle. Then, multinomial sampling is performed with the residual weights
In this method, the "wheel" representing the old set of particles is divided into N equally-sized segments, as represented in the figure below. Then, N uniform numbers are independently generated like in multinomial sampling, but instead of mapping each draw to the entire circumference, they are mapped to its corresponding partition.
Also called universal sampling, this popular technique draws only one random number, i.e. one direction in the "wheel", with the others N-1 directions being fixed at 1/N increments from the random pick.
#pragma once #include <mrpt/core.h> using namespace mrpt; using namespace mrpt::bayes; using namespace mrpt::gui; using namespace mrpt::math; using namespace mrpt::slam; using namespace mrpt::utils; using namespace mrpt::random; using namespace std; struct CParticleVehicleData { float x,y, vx,vy; // Vehicle state (position & velocities) }; class CRangeBearingParticleFilter : public mrpt::bayes::CParticleFilterCapable, public mrpt::bayes::CParticleFilterData<CParticleVehicleData> { IMPLEMENT_PARTICLE_FILTER_CAPABLE(CParticleVehicleData); public: CRangeBearingParticleFilter(void); ~CRangeBearingParticleFilter(void); public: /** Update the m_particles, predicting the posterior of robot pose and map after a movement command. * This method has additional configuration parameters in "options". * Performs the update stage of the RBPF, using the sensed Sensorial Frame: * * \param action This is a pointer to CActionCollection, containing the pose change the robot has been commanded. * \param observation This must be a pointer to a CSensoryFrame object, with robot sensed observations. * * \sa options */ void prediction_and_update_pfStandardProposal( const mrpt::slam::CActionCollection * action, const mrpt::slam::CSensoryFrame * observation, const bayes::CParticleFilter::TParticleFilterOptions &PF_options ); void initializeParticles(size_t numParticles); /** Computes the average velocity & position */ void getMean( float &x, float &y, float &vx, float &vy ); };