9 #ifndef PF_implementations_data_H    10 #define PF_implementations_data_H    29                 template <
class PARTICLETYPE, 
class BINTYPE>
    32                         const TKLDParams        &opts,
    33                         const PARTICLETYPE      *currentParticleValue = NULL,
    40                 template <
class PARTICLE_TYPE, 
class MY
SELF>
    42                         public mrpt::utils::COutputLogger
    46                                 mrpt::utils::COutputLogger(
"PF_implementation"),
    73                         template <
class BINTYPE> 
    79                                 const void * observation );
    81                         template <
class BINTYPE> 
    87                                 const void                              *observation );
   107                         template <
class BINTYPE>
   124                         template <
class BINTYPE>
   137                         template <
class BINTYPE>
   155                                 PARTICLE_TYPE *particleData,
   166                                 const std::vector<mrpt::math::TPose3D>          &newParticles,
   167                                 const std::vector<double>               &newParticlesWeight,
   168                                 const std::vector<size_t>               &newParticlesDerivedFromIdx )
 const   175                                 const size_t N = newParticles.size(), N_old = old_particles.size();
   176                                 typename MYSELF::CParticleList newParticlesArray(N);
   180                                 std::vector<bool> oldParticleAlreadyCopied(N_old,
false);
   181                                 std::vector<PARTICLE_TYPE *> oldParticleFirstCopies(N_old, NULL);
   185                                 for (newPartIt=newParticlesArray.begin(),i=0;newPartIt!=newParticlesArray.end();++newPartIt,++i)
   188                                         newPartIt->log_w = newParticlesWeight[i];
   191                                         PARTICLE_TYPE *newPartData;
   192                                         const size_t i_in_old = newParticlesDerivedFromIdx[i];
   193                                         if (!oldParticleAlreadyCopied[i_in_old])
   196                                                 newPartData = old_particles[i_in_old].d.release();
   197                                                 oldParticleAlreadyCopied[i_in_old] = 
true;
   198                                                 oldParticleFirstCopies[i_in_old] = newPartData;
   203                                                 ASSERT_(oldParticleFirstCopies[i_in_old]);
   204                                                 newPartData = 
new PARTICLE_TYPE(*oldParticleFirstCopies[i_in_old]);
   207                                         newPartIt->d.reset(newPartData);
   213                                 for (newPartIt=newParticlesArray.begin(),i=0;i<N;++newPartIt,++i)
   219                                 old_particles.resize( newParticlesArray.size() );
   221                                 for (newPartIt=newParticlesArray.begin(),trgPartIt=old_particles.begin(); newPartIt!=newParticlesArray.end(); ++newPartIt, ++trgPartIt )
   223                                         trgPartIt->log_w = newPartIt->log_w;
   224                                         trgPartIt->d.move_from( newPartIt->d );
   247                                 const size_t                    particleIndexForMap,
   259                 template <
class BINTYPE> 
   266                         template <
class BINTYPE>
   272                                 const bool USE_OPTIMAL_SAMPLING  );
   274                         template <
class BINTYPE>
   276                                 const bool              USE_OPTIMAL_SAMPLING,
   277                                 const bool              doResample,
   278                                 const double    maxMeanLik,
   283                                 double                  & out_newParticleLogWeight);
 
void PF_SLAM_implementation_pfAuxiliaryPFStandardAndOptimal(const mrpt::obs::CActionCollection *actions, const mrpt::obs::CSensoryFrame *sf, const mrpt::bayes::CParticleFilter::TParticleFilterOptions &PF_options, const TKLDParams &KLD_options, const bool USE_OPTIMAL_SAMPLING)
The shared implementation body of two PF methods: APF and Optimal-APF, depending on USE_OPTIMAL_SAMPL...
 
mrpt::obs::CActionRobotMovement2D m_accumRobotMovement2D
 
static double PF_SLAM_particlesEvaluator_AuxPFOptimal(const mrpt::bayes::CParticleFilter::TParticleFilterOptions &PF_options, const mrpt::bayes::CParticleFilterCapable *obj, size_t index, const void *action, const void *observation)
 
bool m_accumRobotMovement3DIsValid
 
mrpt::math::CVectorDouble m_pfAuxiliaryPFStandard_estimatedProb
Auxiliary variable used in the "pfAuxiliaryPFStandard" algorithm. 
 
void PF_SLAM_implementation_pfAuxiliaryPFStandard(const mrpt::obs::CActionCollection *actions, const mrpt::obs::CSensoryFrame *sf, const mrpt::bayes::CParticleFilter::TParticleFilterOptions &PF_options, const TKLDParams &KLD_options)
A generic implementation of the PF method "prediction_and_update_pfAuxiliaryPFStandard" (Auxiliary pa...
 
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction...
 
Option set for KLD algorithm. 
 
bool PF_SLAM_implementation_gatherActionsCheckBothActObs(const mrpt::obs::CActionCollection *actions, const mrpt::obs::CSensoryFrame *sf)
Auxiliary method called by PF implementations: return true if we have both action & observation...
 
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. 
 
mrpt::poses::CPoseRandomSampler m_movementDrawer
Used in al PF implementations. 
 
virtual bool PF_SLAM_implementation_skipRobotMovement() const
Make a specialization if needed, eg. 
 
GLsizei GLsizei GLuint * obj
 
Declares a class for storing a collection of robot actions. 
 
virtual mrpt::math::TPose3D getLastPose(const size_t i, bool &pose_is_valid) const =0
Return the last robot pose in the i'th particle; pose_is_valid will be false if particle is a path an...
 
A set of common data shared by PF implementations for both SLAM and localization. ...
 
Represents a probabilistic 2D movement of the robot mobile base. 
 
void PF_SLAM_aux_perform_one_rejection_sampling_step(const bool USE_OPTIMAL_SAMPLING, const bool doResample, const double maxMeanLik, size_t k, const mrpt::obs::CSensoryFrame *sf, const mrpt::bayes::CParticleFilter::TParticleFilterOptions &PF_options, mrpt::poses::CPose3D &out_newPose, double &out_newParticleLogWeight)
 
void PF_SLAM_implementation_pfAuxiliaryPFOptimal(const mrpt::obs::CActionCollection *actions, const mrpt::obs::CSensoryFrame *sf, const mrpt::bayes::CParticleFilter::TParticleFilterOptions &PF_options, const TKLDParams &KLD_options)
A generic implementation of the PF method "prediction_and_update_pfAuxiliaryPFOptimal" (optimal sampl...
 
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler. 
 
mrpt::math::CVectorDouble m_pfAuxiliaryPFOptimal_maxLikelihood
Auxiliary variable used in the "pfAuxiliaryPFOptimal" algorithm. 
 
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. 
 
Declares a class for storing a "sensory frame", a set of "observations" taken by the robot approximat...
 
This virtual class defines the interface that any particles based PDF class must implement in order t...
 
bool m_accumRobotMovement2DIsValid
 
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries. 
 
std::deque< CParticleData > CParticleList
Use this type to refer to the list of particles m_particles. 
 
A class used to store a 3D pose (a 3D translation + a rotation in 3D). 
 
The configuration of a particle filter. 
 
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates). 
 
virtual bool PF_SLAM_implementation_doWeHaveValidObservations(const typename mrpt::bayes::CParticleFilterData< PARTICLE_TYPE >::CParticleList &particles, const mrpt::obs::CSensoryFrame *sf) const
 
Declares a class that represents a Probability Density function (PDF) of a 3D pose ...
 
void KLF_loadBinFromParticle(BINTYPE &outBin, const TKLDParams &opts, const PARTICLETYPE *currentParticleValue=NULL, const mrpt::math::TPose3D *newPoseToBeInserted=NULL)
 
mrpt::poses::CPose3DPDFGaussian m_accumRobotMovement3D
 
An efficient generator of random samples drawn from a given 2D (CPosePDF) or 3D (CPose3DPDF) pose pro...
 
void PF_SLAM_implementation_pfStandardProposal(const mrpt::obs::CActionCollection *actions, const mrpt::obs::CSensoryFrame *sf, const mrpt::bayes::CParticleFilter::TParticleFilterOptions &PF_options, const TKLDParams &KLD_options)
A generic implementation of the PF method "pfStandardProposal" (standard proposal distribution...
 
std::vector< bool > m_pfAuxiliaryPFOptimal_maxLikMovementDrawHasBeenUsed
 
virtual void PF_SLAM_implementation_custom_update_particle_with_new_pose(PARTICLE_TYPE *particleData, const mrpt::math::TPose3D &newPose) const =0
 
std::vector< mrpt::math::TPose3D > m_pfAuxiliaryPFOptimal_maxLikDrawnMovement
Auxiliary variable used in the "pfAuxiliaryPFOptimal" algorithm. 
 
mrpt::math::CVectorDouble m_pfAuxiliaryPFOptimal_estimatedProb
Auxiliary variable used in the "pfAuxiliaryPFOptimal" algorithm. 
 
virtual void PF_SLAM_implementation_replaceByNewParticleSet(typename mrpt::bayes::CParticleFilterData< PARTICLE_TYPE >::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...