Main MRPT website > C++ reference for MRPT 1.9.9
CMultiMetricMapPDF.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "slam-precomp.h" // Precompiled headers
11 
12 #include <mrpt/random.h>
13 #include <mrpt/utils/CTicTac.h>
14 #include <mrpt/utils/CFileStream.h>
15 #include <mrpt/system/os.h>
16 
26 
28 
29 using namespace mrpt;
30 using namespace mrpt::math;
31 using namespace mrpt::slam;
32 using namespace mrpt::obs;
33 using namespace mrpt::maps;
34 using namespace mrpt::poses;
35 using namespace mrpt::random;
36 using namespace mrpt::utils;
37 using namespace mrpt::system;
38 using namespace std;
39 
42 
43 /*---------------------------------------------------------------
44  Constructor
45  ---------------------------------------------------------------*/
47  const bayes::CParticleFilter::TParticleFilterOptions& opts,
48  const mrpt::maps::TSetOfMetricMapInitializers* mapsInitializers,
49  const TPredictionParams* predictionOptions)
50  : averageMap(mapsInitializers),
51  averageMapIsUpdated(false),
52  SFs(),
53  SF2robotPath(),
54  options(),
55  newInfoIndex(0)
56 {
57  m_poseParticles.m_particles.resize(opts.sampleSize);
58  for (CParticleList::iterator it = m_poseParticles.m_particles.begin();
59  it != m_poseParticles.m_particles.end(); ++it)
60  {
61  it->log_w = 0;
62  it->d.reset(new CRBPFParticleData(mapsInitializers));
63  }
64 
65  // Initialize:
66  const CPose3D nullPose(0, 0, 0);
67  clear(nullPose);
68 
69  // If provided, copy the whole set of params now:
70  if (predictionOptions != nullptr) options = *predictionOptions;
71 }
72 
73 /*---------------------------------------------------------------
74  clear
75  ---------------------------------------------------------------*/
76 void CMultiMetricMapPDF::clear(const CPose2D& initialPose)
77 {
78  CPose3D p(initialPose);
79  clear(p);
80 }
81 
82 /*---------------------------------------------------------------
83  clear
84  ---------------------------------------------------------------*/
85 void CMultiMetricMapPDF::clear(const CPose3D& initialPose)
86 {
87  const size_t M = m_poseParticles.m_particles.size();
88  for (size_t i = 0; i < M; i++)
89  {
90  m_poseParticles.m_particles[i].log_w = 0;
91 
92  m_poseParticles.m_particles[i].d->mapTillNow.clear();
93 
94  m_poseParticles.m_particles[i].d->robotPath.resize(1);
95  m_poseParticles.m_particles[i].d->robotPath[0] = initialPose;
96  }
97 
98  SFs.clear();
99  SF2robotPath.clear();
100 
101  averageMapIsUpdated = false;
102 }
103 
105  const mrpt::maps::CSimpleMap& prevMap,
106  const mrpt::poses::CPose3D& currentPose)
107 {
108  const size_t nParts = m_poseParticles.m_particles.size(), nOldKeyframes = prevMap.size();
109  if (nOldKeyframes == 0)
110  {
111  // prevMap is empty, so reset the map
112  clear(currentPose);
113  return;
114  }
115  for (size_t idxPart = 0; idxPart < nParts; idxPart++)
116  {
117  auto& p = m_poseParticles.m_particles[idxPart];
118  p.log_w = 0;
119 
120  p.d->mapTillNow.clear();
121 
122  p.d->robotPath.resize(nOldKeyframes);
123  for (size_t i = 0; i < nOldKeyframes; i++)
124  {
125  CPose3DPDF::Ptr keyframe_pose;
126  CSensoryFrame::Ptr sfkeyframe_sf;
127  prevMap.get(i, keyframe_pose, sfkeyframe_sf);
128 
129  // as pose, use: if the PDF is also a PF with the same number of
130  // samples, use those particles;
131  // otherwise, simply use the mean for all particles as an
132  // approximation (with loss of uncertainty).
133  mrpt::poses::CPose3D kf_pose;
134  bool kf_pose_set = false;
135  if (IS_CLASS(keyframe_pose, CPose3DPDFParticles))
136  {
137  const auto pdf_parts = dynamic_cast<const CPose3DPDFParticles*>(
138  keyframe_pose.get());
139  ASSERT_(pdf_parts);
140  if (pdf_parts->particlesCount() == nParts)
141  {
142  kf_pose = *pdf_parts->m_particles[idxPart].d;
143  kf_pose_set = true;
144  }
145  }
146  if (!kf_pose_set)
147  {
148  kf_pose = keyframe_pose->getMeanVal();
149  }
150  p.d->robotPath[i] = kf_pose;
151  for (const auto& obs : *sfkeyframe_sf)
152  {
153  p.d->mapTillNow.insertObservation(&(*obs), &kf_pose);
154  }
155  }
156  }
157 
158  SFs = prevMap; // copy
159  SF2robotPath.clear();
160  SF2robotPath.reserve(nOldKeyframes);
161  for (size_t i = 0; i < nOldKeyframes; i++) SF2robotPath.push_back(i);
162 
163  averageMapIsUpdated = false;
164 }
165 
166 /*---------------------------------------------------------------
167  getEstimatedPosePDF
168  Returns an estimate of the pose, (the mean, or mathematical expectation of the
169  PDF), computed
170  as a weighted average over all m_poseParticles.m_particles.
171  ---------------------------------------------------------------*/
172 void CMultiMetricMapPDF::getEstimatedPosePDF(
173  CPose3DPDFParticles& out_estimation) const
174 {
175  ASSERT_(m_poseParticles.m_particles[0].d->robotPath.size() > 0);
176  getEstimatedPosePDFAtTime(
177  m_poseParticles.m_particles[0].d->robotPath.size() - 1, out_estimation);
178 }
179 
180 /*---------------------------------------------------------------
181  getEstimatedPosePDFAtTime
182  ---------------------------------------------------------------*/
183 void CMultiMetricMapPDF::getEstimatedPosePDFAtTime(
184  size_t timeStep, CPose3DPDFParticles& out_estimation) const
185 {
186  // CPose3D p;
187  size_t i, n = m_poseParticles.m_particles.size();
188 
189  // Delete current content of "out_estimation":
190  out_estimation.clearParticles();
191 
192  // Create new m_poseParticles.m_particles:
193  out_estimation.m_particles.resize(n);
194  for (i = 0; i < n; i++)
195  {
196  out_estimation.m_particles[i].d.reset(
197  new CPose3D(m_poseParticles.m_particles[i].d->robotPath[timeStep]));
198  out_estimation.m_particles[i].log_w = m_poseParticles.m_particles[i].log_w;
199  }
200 }
201 
202 /*---------------------------------------------------------------
203  writeToStream
204  ---------------------------------------------------------------*/
205 void CRBPFParticleData::writeToStream(
206  mrpt::utils::CStream& out, int* version) const
207 {
208  MRPT_UNUSED_PARAM(out);
209  MRPT_UNUSED_PARAM(version);
210  THROW_EXCEPTION("Shouldn't arrive here")
211 }
212 
213 /*---------------------------------------------------------------
214  readFromStream
215  ---------------------------------------------------------------*/
216 void CRBPFParticleData::readFromStream(mrpt::utils::CStream& in, int version)
217 {
219  MRPT_UNUSED_PARAM(version);
220  THROW_EXCEPTION("Shouldn't arrive here")
221 }
222 
223 /*---------------------------------------------------------------
224  writeToStream
225  ---------------------------------------------------------------*/
226 void CMultiMetricMapPDF::writeToStream(
227  mrpt::utils::CStream& out, int* version) const
228 {
229  if (version)
230  *version = 0;
231  else
232  {
233  uint32_t i, n, j, m;
234 
235  // The data
236  n = static_cast<uint32_t>(m_poseParticles.m_particles.size());
237  out << n;
238  for (i = 0; i < n; i++)
239  {
240  out << m_poseParticles.m_particles[i].log_w << m_poseParticles.m_particles[i].d->mapTillNow;
241  m = static_cast<uint32_t>(m_poseParticles.m_particles[i].d->robotPath.size());
242  out << m;
243  for (j = 0; j < m; j++) out << m_poseParticles.m_particles[i].d->robotPath[j];
244  }
245  out << SFs << SF2robotPath;
246  }
247 }
248 
249 /*---------------------------------------------------------------
250  readFromStream
251  ---------------------------------------------------------------*/
252 void CMultiMetricMapPDF::readFromStream(mrpt::utils::CStream& in, int version)
253 {
254  switch (version)
255  {
256  case 0:
257  {
258  uint32_t i, n, j, m;
259 
260  // Delete current contents:
261  // --------------------------
262  m_poseParticles.clearParticles();
263  SFs.clear();
264  SF2robotPath.clear();
265 
266  averageMapIsUpdated = false;
267 
268  // Load the new data:
269  // --------------------
270  in >> n;
271 
272  m_poseParticles.m_particles.resize(n);
273  for (i = 0; i < n; i++)
274  {
275  m_poseParticles.m_particles[i].d.reset(new CRBPFParticleData());
276 
277  // Load
278  in >> m_poseParticles.m_particles[i].log_w >> m_poseParticles.m_particles[i].d->mapTillNow;
279 
280  in >> m;
281  m_poseParticles.m_particles[i].d->robotPath.resize(m);
282  for (j = 0; j < m; j++) in >> m_poseParticles.m_particles[i].d->robotPath[j];
283  }
284 
285  in >> SFs >> SF2robotPath;
286  }
287  break;
288  default:
290  };
291 }
292 
293 TPose3D CMultiMetricMapPDF::getLastPose(
294  const size_t i, bool& is_valid_pose) const
295 {
296  if (i >= m_poseParticles.m_particles.size())
297  THROW_EXCEPTION("Particle index out of bounds!");
298 
299  if (m_poseParticles.m_particles[i].d->robotPath.empty())
300  {
301  is_valid_pose = false;
302  return TPose3D(0, 0, 0, 0, 0, 0);
303  }
304  else
305  {
306  return *m_poseParticles.m_particles[i].d->robotPath.rbegin();
307  }
308 }
309 
310 const CMultiMetricMap* CMultiMetricMapPDF::getAveragedMetricMapEstimation()
311 {
312  rebuildAverageMap();
313  return &averageMap;
314 }
315 
316 /*---------------------------------------------------------------
317  getWeightedAveragedMap
318  ---------------------------------------------------------------*/
319 void CMultiMetricMapPDF::rebuildAverageMap()
320 {
321  float min_x = 1e6, max_x = -1e6, min_y = 1e6, max_y = -1e6;
323 
324  if (averageMapIsUpdated) return;
325 
326  // ---------------------------------------------------------
327  // GRID
328  // ---------------------------------------------------------
329  for (part = m_poseParticles.m_particles.begin(); part != m_poseParticles.m_particles.end(); ++part)
330  {
331  ASSERT_(part->d->mapTillNow.m_gridMaps.size() > 0);
332 
333  min_x = min(min_x, part->d->mapTillNow.m_gridMaps[0]->getXMin());
334  max_x = max(max_x, part->d->mapTillNow.m_gridMaps[0]->getXMax());
335  min_y = min(min_y, part->d->mapTillNow.m_gridMaps[0]->getYMin());
336  max_y = max(max_y, part->d->mapTillNow.m_gridMaps[0]->getYMax());
337  }
338 
339  // Asure all maps have the same dimensions:
340  for (part = m_poseParticles.m_particles.begin(); part != m_poseParticles.m_particles.end(); ++part)
341  part->d->mapTillNow.m_gridMaps[0]->resizeGrid(
342  min_x, max_x, min_y, max_y, 0.5f, false);
343 
344  for (part = m_poseParticles.m_particles.begin(); part != m_poseParticles.m_particles.end(); ++part)
345  {
346  min_x = min(min_x, part->d->mapTillNow.m_gridMaps[0]->getXMin());
347  max_x = max(max_x, part->d->mapTillNow.m_gridMaps[0]->getXMax());
348  min_y = min(min_y, part->d->mapTillNow.m_gridMaps[0]->getYMin());
349  max_y = max(max_y, part->d->mapTillNow.m_gridMaps[0]->getYMax());
350  }
351 
352  // Prepare target map:
353  ASSERT_(averageMap.m_gridMaps.size() > 0);
354  averageMap.m_gridMaps[0]->setSize(
355  min_x, max_x, min_y, max_y,
356  m_poseParticles.m_particles[0].d->mapTillNow.m_gridMaps[0]->getResolution(), 0);
357 
358  // Compute the sum of weights:
359  double sumLinearWeights = 0;
360  for (part = m_poseParticles.m_particles.begin(); part != m_poseParticles.m_particles.end(); ++part)
361  sumLinearWeights += exp(part->log_w);
362 
363  // CHECK:
364  for (part = m_poseParticles.m_particles.begin(); part != m_poseParticles.m_particles.end(); ++part)
365  {
366  ASSERT_(
367  part->d->mapTillNow.m_gridMaps[0]->getSizeX() ==
368  averageMap.m_gridMaps[0]->getSizeX());
369  ASSERT_(
370  part->d->mapTillNow.m_gridMaps[0]->getSizeY() ==
371  averageMap.m_gridMaps[0]->getSizeY());
372  }
373 
374  {
375  // ******************************************************
376  // Implementation WITHOUT the SSE Instructions Set
377  // ******************************************************
378  MRPT_START
379 
380  // Reserve a float grid-map, add weight all maps
381  // -------------------------------------------------------------------------------------------
382  std::vector<float> floatMap;
383  floatMap.resize(averageMap.m_gridMaps[0]->map.size(), 0);
384 
385  // For each particle in the RBPF:
386  double sumW = 0;
387  for (part = m_poseParticles.m_particles.begin(); part != m_poseParticles.m_particles.end(); ++part)
388  sumW += exp(part->log_w);
389 
390  if (sumW == 0) sumW = 1;
391 
392  for (part = m_poseParticles.m_particles.begin(); part != m_poseParticles.m_particles.end(); ++part)
393  {
394  // Variables:
397  part->d->mapTillNow.m_gridMaps[0]->map.begin();
399  part->d->mapTillNow.m_gridMaps[0]->map.end();
401 
402  // The weight of particle:
403  float w = exp(part->log_w) / sumW;
404 
405  ASSERT_(
406  part->d->mapTillNow.m_gridMaps[0]->map.size() ==
407  floatMap.size());
408 
409  // For each cell in individual maps:
410  for (srcCell = firstSrcCell, destCell = floatMap.begin();
411  srcCell != lastSrcCell; srcCell++, destCell++)
412  (*destCell) += w * (*srcCell);
413  }
414 
415  // Copy to fixed point map:
418  averageMap.m_gridMaps[0]->map.begin();
419 
420  ASSERT_(averageMap.m_gridMaps[0]->map.size() == floatMap.size());
421 
422  for (srcCell = floatMap.begin(); srcCell != floatMap.end();
423  srcCell++, destCell++)
424  *destCell = static_cast<COccupancyGridMap2D::cellType>(*srcCell);
425 
426  MRPT_END
427  } // End of SSE not supported
428 
429  // Don't calculate again until really necesary.
430  averageMapIsUpdated = true;
431 }
432 
433 /*---------------------------------------------------------------
434  insertObservation
435  ---------------------------------------------------------------*/
436 bool CMultiMetricMapPDF::insertObservation(CSensoryFrame& sf)
437 {
438  const size_t M = m_poseParticles.particlesCount();
439 
440  // Insert into SFs:
441  CPose3DPDFParticles::Ptr posePDF =
442  mrpt::make_aligned_shared<CPose3DPDFParticles>();
443  getEstimatedPosePDF(*posePDF);
444 
445  // Insert it into the SFs and the SF2robotPath list:
446  const uint32_t new_sf_id = SFs.size();
447  SFs.insert(posePDF, CSensoryFrame::Ptr(new CSensoryFrame(sf)));
448  SF2robotPath.resize(new_sf_id + 1);
449  SF2robotPath[new_sf_id] = m_poseParticles.m_particles[0].d->robotPath.size() - 1;
450 
451  bool anymap = false;
452  for (size_t i = 0; i < M; i++)
453  {
454  bool pose_is_valid;
455  const CPose3D robotPose = CPose3D(getLastPose(i, pose_is_valid));
456  // ASSERT_(pose_is_valid); // if not, use the default (0,0,0)
457  const bool map_modified = sf.insertObservationsInto(
458  &m_poseParticles.m_particles[i].d->mapTillNow, &robotPose);
459  anymap = anymap || map_modified;
460  }
461 
462  averageMapIsUpdated = false;
463  return anymap;
464 }
465 
466 /*---------------------------------------------------------------
467  getPath
468  ---------------------------------------------------------------*/
469 void CMultiMetricMapPDF::getPath(
470  size_t i, std::deque<math::TPose3D>& out_path) const
471 {
472  if (i >= m_poseParticles.m_particles.size()) THROW_EXCEPTION("Index out of bounds");
473  out_path = m_poseParticles.m_particles[i].d->robotPath;
474 }
475 
476 /*---------------------------------------------------------------
477  getCurrentEntropyOfPaths
478  ---------------------------------------------------------------*/
479 double CMultiMetricMapPDF::getCurrentEntropyOfPaths()
480 {
481  size_t i;
482  size_t N =
483  m_poseParticles.m_particles[0].d->robotPath.size(); // The poses count along the paths
484 
485  // Compute paths entropy:
486  // ---------------------------
487  double H_paths = 0;
488 
489  if (N)
490  {
491  // For each pose along the path:
492  for (i = 0; i < N; i++)
493  {
494  // Get pose est. as m_poseParticles.m_particles:
495  CPose3DPDFParticles posePDFParts;
496  getEstimatedPosePDFAtTime(i, posePDFParts);
497 
498  // Approximate to gaussian and compute entropy of covariance:
499  H_paths += posePDFParts.getCovarianceEntropy();
500  }
501  H_paths /= N;
502  }
503  return H_paths;
504 }
505 
506 /*---------------------------------------------------------------
507  getCurrentJointEntropy
508  ---------------------------------------------------------------*/
509 double CMultiMetricMapPDF::getCurrentJointEntropy()
510 {
511  double H_joint, H_paths, H_maps;
512  size_t i, M = m_poseParticles.m_particles.size();
514 
515  // Entropy of the paths:
516  H_paths = getCurrentEntropyOfPaths();
517 
518  float min_x = 1e6, max_x = -1e6, min_y = 1e6, max_y = -1e6;
520 
521  // ---------------------------------------------------------
522  // ASSURE ALL THE GRIDS ARE THE SAME SIZE!
523  // ---------------------------------------------------------
524  for (part = m_poseParticles.m_particles.begin(); part != m_poseParticles.m_particles.end(); ++part)
525  {
526  ASSERT_(part->d->mapTillNow.m_gridMaps.size() > 0);
527 
528  min_x = min(min_x, part->d->mapTillNow.m_gridMaps[0]->getXMin());
529  max_x = max(max_x, part->d->mapTillNow.m_gridMaps[0]->getXMax());
530  min_y = min(min_y, part->d->mapTillNow.m_gridMaps[0]->getYMin());
531  max_y = max(max_y, part->d->mapTillNow.m_gridMaps[0]->getYMax());
532  }
533 
534  // Asure all maps have the same dimensions:
535  for (part = m_poseParticles.m_particles.begin(); part != m_poseParticles.m_particles.end(); ++part)
536  part->d->mapTillNow.m_gridMaps[0]->resizeGrid(
537  min_x, max_x, min_y, max_y, 0.5f, false);
538 
539  // Sum of linear weights:
540  double sumLinearWeights = 0;
541  for (i = 0; i < M; i++) sumLinearWeights += exp(m_poseParticles.m_particles[i].log_w);
542 
543  // Compute weighted maps entropy:
544  // --------------------------------
545  H_maps = 0;
546  for (i = 0; i < M; i++)
547  {
548  ASSERT_(m_poseParticles.m_particles[i].d->mapTillNow.m_gridMaps.size() > 0);
549 
550  m_poseParticles.m_particles[i].d->mapTillNow.m_gridMaps[0]->computeEntropy(entropy);
551  H_maps += exp(m_poseParticles.m_particles[i].log_w) * entropy.H / sumLinearWeights;
552  }
553 
554  printf("H_paths=%e\n", H_paths);
555  printf("H_maps=%e\n", H_maps);
556 
557  H_joint = H_paths + H_maps;
558  return H_joint;
559 }
560 
561 const CMultiMetricMap* CMultiMetricMapPDF::getCurrentMostLikelyMetricMap() const
562 {
563  size_t i, max_i = 0, n = m_poseParticles.m_particles.size();
564  double max_w = m_poseParticles.m_particles[0].log_w;
565 
566  for (i = 0; i < n; i++)
567  {
568  if (m_poseParticles.m_particles[i].log_w > max_w)
569  {
570  max_w = m_poseParticles.m_particles[i].log_w;
571  max_i = i;
572  }
573  }
574 
575  // Return its map:
576  return &m_poseParticles.m_particles[max_i].d->mapTillNow;
577 }
578 
579 /*---------------------------------------------------------------
580  updateSensoryFrameSequence
581  ---------------------------------------------------------------*/
582 void CMultiMetricMapPDF::updateSensoryFrameSequence()
583 {
584  MRPT_START
585  CPose3DPDFParticles posePartsPDF;
586  CPose3DPDF::Ptr previousPosePDF;
587  CSensoryFrame::Ptr dummy;
588 
589  for (size_t i = 0; i < SFs.size(); i++)
590  {
591  // Get last estimation:
592  SFs.get(i, previousPosePDF, dummy);
593 
594  // Compute the new one:
595  getEstimatedPosePDFAtTime(SF2robotPath[i], posePartsPDF);
596 
597  // Copy into SFs:
598  previousPosePDF->copyFrom(posePartsPDF);
599  }
600 
601  MRPT_END
602 }
603 
604 /*---------------------------------------------------------------
605  saveCurrentPathEstimationToTextFile
606  ---------------------------------------------------------------*/
607 void CMultiMetricMapPDF::saveCurrentPathEstimationToTextFile(
608  const std::string& fil)
609 {
610  FILE* f = os::fopen(fil.c_str(), "wt");
611  if (!f) return;
612 
613  for (CParticleList::iterator it = m_poseParticles.m_particles.begin();
614  it != m_poseParticles.m_particles.end(); ++it)
615  {
616  for (size_t i = 0; i < it->d->robotPath.size(); i++)
617  {
618  const mrpt::math::TPose3D& p = it->d->robotPath[i];
619 
620  os::fprintf(
621  f, "%.04f %.04f %.04f %.04f %.04f %.04f ", p.x, p.y, p.z, p.yaw,
622  p.pitch, p.roll);
623  }
624  os::fprintf(f, " %e\n", it->log_w);
625  }
626 
627  os::fclose(f);
628 }
629 
630 /*---------------------------------------------------------------
631  TPredictionParams
632  ---------------------------------------------------------------*/
633 CMultiMetricMapPDF::TPredictionParams::TPredictionParams()
634  : pfOptimalProposal_mapSelection(0),
635  ICPGlobalAlign_MinQuality(0.70f),
636  update_gridMapLikelihoodOptions(),
637  KLD_params(),
638  icp_params()
639 {
640 }
641 
642 /*---------------------------------------------------------------
643  dumpToTextStream
644  ---------------------------------------------------------------*/
646  mrpt::utils::CStream& out) const
647 {
648  out.printf(
649  "\n----------- [CMultiMetricMapPDF::TPredictionParams] ------------ "
650  "\n\n");
651 
652  out.printf(
653  "pfOptimalProposal_mapSelection = %i\n",
654  pfOptimalProposal_mapSelection);
655  out.printf(
656  "ICPGlobalAlign_MinQuality = %f\n",
657  ICPGlobalAlign_MinQuality);
658 
659  KLD_params.dumpToTextStream(out);
660  icp_params.dumpToTextStream(out);
661  out.printf("\n");
662 }
663 
664 /*---------------------------------------------------------------
665  loadFromConfigFile
666  ---------------------------------------------------------------*/
668  const mrpt::utils::CConfigFileBase& iniFile, const std::string& section)
669 {
670  pfOptimalProposal_mapSelection = iniFile.read_int(
671  section, "pfOptimalProposal_mapSelection",
672  pfOptimalProposal_mapSelection, true);
673 
674  MRPT_LOAD_CONFIG_VAR(ICPGlobalAlign_MinQuality, float, iniFile, section);
675 
676  KLD_params.loadFromConfigFile(iniFile, section);
677  icp_params.loadFromConfigFile(iniFile, section);
678 }
A namespace of pseudo-random numbers genrators of diferent distributions.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
#define min(a, b)
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
Definition: math_frwds.h:30
This class stores a sequence of <Probabilistic Pose,SensoryFrame> pairs, thus a "metric map" can be t...
Definition: CSimpleMap.h:35
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:44
double getCovarianceEntropy() const
Compute the entropy of the estimated covariance matrix.
int void fclose(FILE *f)
An OS-independent version of fclose.
Definition: os.cpp:272
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
#define THROW_EXCEPTION(msg)
GLenum GLsizei n
Definition: glext.h:5074
Scalar * iterator
Definition: eigen_plugins.h:26
std::shared_ptr< CPose3DPDFParticles > Ptr
STL namespace.
A set of TMetricMapInitializer structures, passed to the constructor CMultiMetricMap::CMultiMetricMap...
void clear()
Clear the contents of this container.
Definition: ts_hash_map.h:189
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:4178
void loadFromConfigFile(const mrpt::utils::CConfigFileBase &source, const std::string &section) override
This method load the options from a ".ini"-like file or memory-stored string list.
This class allows loading and storing values and vectors of different types from a configuration text...
int read_int(const std::string &section, const std::string &name, int defaultValue, bool failIfNotFound=false) const
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
CParticleList m_particles
The array of particles.
double H
The target variable for absolute entropy, computed as: H(map)=Sumx,y{ -p(x,y)*ln(p(x,y)) -(1-p(x,y))*ln(1-p(x,y)) }
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
#define MRPT_END
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
std::shared_ptr< CPose3DPDF > Ptr
Definition: CPose3DPDF.h:45
This namespace contains representation of robot actions and observations.
Declares a class for storing a "sensory frame", a set of "observations" taken by the robot approximat...
Definition: CSensoryFrame.h:54
std::shared_ptr< CSensoryFrame > Ptr
Definition: CSensoryFrame.h:56
size_t size() const
Returns the count of pairs (pose,sensory data)
Definition: CSimpleMap.cpp:65
void get(size_t index, mrpt::poses::CPose3DPDF::Ptr &out_posePDF, mrpt::obs::CSensoryFrame::Ptr &out_SF) const
Access to the i&#39;th pair, first one is index &#39;0&#39;.
Definition: CSimpleMap.cpp:78
GLsizei const GLchar ** string
Definition: glext.h:4101
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CPoint.h:17
Auxiliary class used in mrpt::maps::CMultiMetricMapPDF.
int fprintf(FILE *fil, const char *format,...) noexcept MRPT_printf_format_check(2
An OS-independent version of fprintf.
Definition: os.cpp:405
#define MRPT_START
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:40
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
#define IS_CLASS(ptrObj, class_name)
Evaluates to true if the given pointer to an object (derived from mrpt::utils::CSerializable) is of t...
Definition: CObject.h:103
The struct for passing extra simulation parameters to the prediction/update stage when running a part...
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
GLuint in
Definition: glext.h:7274
#define ASSERT_(f)
void clearParticles()
Free the memory of all the particles and reset the array "m_particles" to length zero.
FILE * fopen(const char *fileName, const char *mode) noexcept
An OS-independent version of fopen.
Definition: os.cpp:254
void dumpToTextStream(mrpt::utils::CStream &out) const override
This method should clearly display all the contents of the structure in textual form, sending it to a CStream.
#define MRPT_LOAD_CONFIG_VAR( variableName, variableType, configFileObject, sectionNameStr)
An useful macro for loading variables stored in a INI-like file under a key with the same name that t...
This class stores any customizable set of metric maps.
unsigned __int32 uint32_t
Definition: rptypes.h:47
bool insertObservationsInto(mrpt::maps::CMetricMap *theMap, const mrpt::poses::CPose3D *robotPose=nullptr) const
Insert all the observations in this SF into a metric map or any kind (see mrpt::maps::CMetricMap).
Declares a class that represents a Rao-Blackwellized set of particles for solving the SLAM problem (T...
Used for returning entropy related information.
GLfloat GLfloat p
Definition: glext.h:6305
void clear()
Remove all stored pairs.
Definition: CSimpleMap.cpp:70
virtual int printf(const char *fmt,...) MRPT_printf_format_check(2
Writes a string to the stream in a textual form.
Definition: CStream.cpp:597
Declares a class that represents a Probability Density function (PDF) of a 3D pose.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019