9 #ifndef PF_implementations_data_H
10 #define PF_implementations_data_H
27 template <
class PARTICLETYPE,
class BINTYPE>
30 const PARTICLETYPE* currentParticleValue =
nullptr,
38 class PARTICLE_TYPE,
class PDF_TYPE,
39 class CParticleList =
typename PDF_TYPE::CParticleList>
63 mutable std::vector<mrpt::math::TPose3D>
73 template <
class BINTYPE>
78 const void* action,
const void* observation);
90 const size_t i,
bool& is_valid_pose)
const = 0;
93 PARTICLE_TYPE* particleData,
106 CParticleList& old_particles,
107 const std::vector<mrpt::math::TPose3D>& newParticles,
108 const std::vector<double>& newParticlesWeight,
109 const std::vector<size_t>& newParticlesDerivedFromIdx)
const
117 const size_t N = newParticles.size(), N_old = old_particles.size();
118 CParticleList newParticlesArray(N);
123 std::vector<bool> oldParticleAlreadyCopied(N_old,
false);
124 std::vector<PARTICLE_TYPE*> oldParticleFirstCopies(N_old,
nullptr);
128 for (newPartIt = newParticlesArray.begin(), i = 0;
129 newPartIt != newParticlesArray.end(); ++newPartIt, ++i)
132 newPartIt->log_w = newParticlesWeight[i];
135 PARTICLE_TYPE* newPartData;
136 const size_t i_in_old = newParticlesDerivedFromIdx[i];
137 if (!oldParticleAlreadyCopied[i_in_old])
140 newPartData = old_particles[i_in_old].d.release();
141 oldParticleAlreadyCopied[i_in_old] =
true;
142 oldParticleFirstCopies[i_in_old] = newPartData;
147 ASSERT_(oldParticleFirstCopies[i_in_old]);
149 new PARTICLE_TYPE(*oldParticleFirstCopies[i_in_old]);
152 newPartIt->d.reset(newPartData);
159 for (newPartIt = newParticlesArray.begin(), i = 0; i < N;
162 newPartIt->d.get(), newParticles[i]);
168 old_particles.resize(newParticlesArray.size());
170 for (newPartIt = newParticlesArray.begin(),
171 trgPartIt = old_particles.begin();
172 newPartIt != newParticlesArray.end(); ++newPartIt, ++trgPartIt)
174 trgPartIt->log_w = newPartIt->log_w;
175 trgPartIt->d.move_from(newPartIt->d);
181 PARTICLE_TYPE>::CParticleList& particles,
199 const size_t particleIndexForMap,
This virtual class defines the interface that any particles based PDF class must implement in order t...
This template class declares the array of particles and its internal data, managing some memory-relat...
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction.
Represents a probabilistic 2D movement of the robot mobile base.
Declares a class for storing a "sensory frame", a set of "observations" taken by the robot approximat...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Declares a class that represents a Probability Density function (PDF) of a 3D pose .
An efficient generator of random samples drawn from a given 2D (CPosePDF) or 3D (CPose3DPDF) pose pro...
A set of common data shared by PF implementations for both SLAM and localization.
virtual void PF_SLAM_implementation_custom_update_particle_with_new_pose(PARTICLE_TYPE *particleData, const mrpt::math::TPose3D &newPose) const =0
virtual void PF_SLAM_implementation_replaceByNewParticleSet(CParticleList &old_particles, const std::vector< mrpt::math::TPose3D > &newParticles, const std::vector< double > &newParticlesWeight, const std::vector< size_t > &newParticlesDerivedFromIdx) const
This is the default algorithm to efficiently replace one old set of samples by another new set.
mrpt::math::CVectorDouble m_pfAuxiliaryPFOptimal_estimatedProb
Auxiliary variable used in the "pfAuxiliaryPFOptimal" algorithm.
virtual double PF_SLAM_computeObservationLikelihoodForParticle(const mrpt::bayes::CParticleFilter::TParticleFilterOptions &PF_options, const size_t particleIndexForMap, const mrpt::obs::CSensoryFrame &observation, const mrpt::poses::CPose3D &x) const =0
Evaluate the observation likelihood for one particle at a given location.
static double PF_SLAM_particlesEvaluator_AuxPFStandard(const mrpt::bayes::CParticleFilter::TParticleFilterOptions &PF_options, const mrpt::bayes::CParticleFilterCapable *obj, size_t index, const void *action, const void *observation)
Compute w[i]*p(z_t | mu_t^i), with mu_t^i being the mean of the new robot pose.
mrpt::poses::CPose3DPDFGaussian m_accumRobotMovement3D
virtual mrpt::math::TPose3D getLastPose(const size_t i, bool &is_valid_pose) const =0
Return the last robot pose in the i'th particle; is_valid_pose will be false if there is no such last...
std::vector< bool > m_pfAuxiliaryPFOptimal_maxLikMovementDrawHasBeenUsed
virtual bool PF_SLAM_implementation_skipRobotMovement() const
Make a specialization if needed, eg.
mrpt::math::CVectorDouble m_pfAuxiliaryPFStandard_estimatedProb
Auxiliary variable used in the "pfAuxiliaryPFStandard" algorithm.
bool m_accumRobotMovement3DIsValid
bool m_accumRobotMovement2DIsValid
mrpt::obs::CActionRobotMovement2D m_accumRobotMovement2D
mrpt::math::CVectorDouble m_pfAuxiliaryPFOptimal_maxLikelihood
Auxiliary variable used in the "pfAuxiliaryPFOptimal" algorithm.
std::vector< mrpt::math::TPose3D > m_pfAuxiliaryPFOptimal_maxLikDrawnMovement
Auxiliary variable used in the "pfAuxiliaryPFOptimal" algorithm.
virtual bool PF_SLAM_implementation_doWeHaveValidObservations(const typename mrpt::bayes::CParticleFilterData< PARTICLE_TYPE >::CParticleList &particles, const mrpt::obs::CSensoryFrame *sf) const
mrpt::poses::CPoseRandomSampler m_movementDrawer
Used in al PF implementations.
Option set for KLD algorithm.
GLsizei GLsizei GLuint * obj
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
void KLF_loadBinFromParticle(BINTYPE &outBin, const TKLDParams &opts, const PARTICLETYPE *currentParticleValue=nullptr, const mrpt::math::TPose3D *newPoseToBeInserted=nullptr)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
The configuration of a particle filter.
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).