28 #ifndef PF_implementations_data_H
29 #define PF_implementations_data_H
46 using namespace mrpt::poses;
47 using namespace mrpt::bayes;
48 using namespace mrpt::math;
52 template <
class PARTICLETYPE,
class BINTYPE>
55 const TKLDParams &opts,
56 const PARTICLETYPE *currentParticleValue = NULL,
57 const TPose3D *newPoseToBeInserted = NULL );
63 template <
class PARTICLE_TYPE,
class MY
SELF>
68 m_accumRobotMovement2DIsValid(false),
69 m_accumRobotMovement3DIsValid(false)
102 template <
class BINTYPE>
103 static double PF_SLAM_particlesEvaluator_AuxPFStandard(
108 const void * observation );
110 template <
class BINTYPE>
111 static double PF_SLAM_particlesEvaluator_AuxPFOptimal(
116 const void *observation );
136 template <
class BINTYPE>
137 void PF_SLAM_implementation_pfAuxiliaryPFOptimal(
153 template <
class BINTYPE>
154 void PF_SLAM_implementation_pfAuxiliaryPFStandard(
166 template <
class BINTYPE>
167 void PF_SLAM_implementation_pfStandardProposal(
181 virtual const TPose3D * getLastPose(
const size_t i)
const = 0;
183 virtual void PF_SLAM_implementation_custom_update_particle_with_new_pose(
184 PARTICLE_TYPE *particleData,
185 const TPose3D &newPose)
const = 0;
193 virtual void PF_SLAM_implementation_replaceByNewParticleSet(
195 const vector<TPose3D> &newParticles,
197 const vector<size_t> &newParticlesDerivedFromIdx )
const
204 const size_t N = newParticles.size();
205 typename MYSELF::CParticleList newParticlesArray(N);
209 std::vector<bool> oldParticleAlreadyCopied(old_particles.size(),
false);
213 for (newPartIt=newParticlesArray.begin(),i=0;newPartIt!=newParticlesArray.end();newPartIt++,i++)
216 newPartIt->log_w = newParticlesWeight[i];
219 PARTICLE_TYPE *newPartData;
220 if (!oldParticleAlreadyCopied[newParticlesDerivedFromIdx[i]])
223 newPartData = old_particles[ newParticlesDerivedFromIdx[i] ].d;
224 oldParticleAlreadyCopied[newParticlesDerivedFromIdx[i]] =
true;
229 newPartData =
new PARTICLE_TYPE( *old_particles[ newParticlesDerivedFromIdx[i] ].d );
232 newPartIt->d = newPartData;
238 for (newPartIt=newParticlesArray.begin(),i=0;i<N;++newPartIt,++i)
239 PF_SLAM_implementation_custom_update_particle_with_new_pose( newPartIt->d, newParticles[i] );
242 for (
size_t i=0;i<old_particles.size();i++)
243 if (!oldParticleAlreadyCopied[i])
247 old_particles.resize( newParticlesArray.size() );
249 for (newPartIt=newParticlesArray.begin(),trgPartIt=old_particles.begin(); newPartIt!=newParticlesArray.end(); ++newPartIt, ++trgPartIt )
251 trgPartIt->log_w = newPartIt->log_w;
252 trgPartIt->d = newPartIt->d;
258 virtual bool PF_SLAM_implementation_doWeHaveValidObservations(
266 virtual bool PF_SLAM_implementation_skipRobotMovement()
const
272 virtual double PF_SLAM_computeObservationLikelihoodForParticle(
274 const size_t particleIndexForMap,
286 template <
class BINTYPE>
287 bool PF_SLAM_implementation_gatherActionsCheckBothActObs(
293 template <
class BINTYPE>
294 void PF_SLAM_implementation_pfAuxiliaryPFStandardAndOptimal(
299 const bool USE_OPTIMAL_SAMPLING );
301 template <
class BINTYPE>
302 void PF_SLAM_aux_perform_one_rejection_sampling_step(
303 const bool USE_OPTIMAL_SAMPLING,
304 const bool doResample,
305 const double maxMeanLik,
310 double & out_newParticleLogWeight);