Main MRPT website > C++ reference for MRPT 1.9.9
CMetricMapBuilderICP.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/slam/CICP.h>
18 #include <mrpt/utils/CTicTac.h>
20 
21 using namespace std;
22 using namespace mrpt::slam;
23 using namespace mrpt::obs;
24 using namespace mrpt::maps;
25 using namespace mrpt::utils;
26 using namespace mrpt::poses;
27 using namespace mrpt::math;
28 
29 /*---------------------------------------------------------------
30  Constructor
31  ---------------------------------------------------------------*/
32 CMetricMapBuilderICP::CMetricMapBuilderICP()
33  : ICP_options(m_min_verbosity_level)
34 {
35  this->setLoggerName("CMetricMapBuilderICP");
36  this->initialize(CSimpleMap());
37 }
38 
39 /*---------------------------------------------------------------
40  Destructor
41  ---------------------------------------------------------------*/
43 {
44  // Asure, we have exit all critical zones:
47 
48  // Save current map to current file:
50 }
51 
52 /*---------------------------------------------------------------
53  Options
54  ---------------------------------------------------------------*/
56  mrpt::utils::VerbosityLevel& parent_verbosity_level)
57  : matchAgainstTheGrid(false),
58  insertionLinDistance(1.0),
59  insertionAngDistance(DEG2RAD(30)),
60  localizationLinDistance(0.20),
61  localizationAngDistance(DEG2RAD(30)),
62  minICPgoodnessToAccept(0.40),
63  verbosity_level(parent_verbosity_level),
64  mapInitializers()
65 {
66 }
67 
70 {
71  matchAgainstTheGrid = other.matchAgainstTheGrid;
72  insertionLinDistance = other.insertionLinDistance;
73  insertionAngDistance = other.insertionAngDistance;
74  localizationLinDistance = other.localizationLinDistance;
75  localizationAngDistance = other.localizationAngDistance;
76  minICPgoodnessToAccept = other.minICPgoodnessToAccept;
77  // We can't copy a reference type
78  // verbosity_level = other.verbosity_level;
79  mapInitializers = other.mapInitializers;
80  return *this;
81 }
82 
84  const mrpt::utils::CConfigFileBase& source, const std::string& section)
85 {
86  MRPT_LOAD_CONFIG_VAR(matchAgainstTheGrid, bool, source, section)
87  MRPT_LOAD_CONFIG_VAR(insertionLinDistance, double, source, section)
88  MRPT_LOAD_CONFIG_VAR_DEGREES(insertionAngDistance, source, section)
89  MRPT_LOAD_CONFIG_VAR(localizationLinDistance, double, source, section)
90  MRPT_LOAD_CONFIG_VAR_DEGREES(localizationAngDistance, source, section)
91  verbosity_level = source.read_enum<mrpt::utils::VerbosityLevel>(
92  section, "verbosity_level", verbosity_level);
93 
94  MRPT_LOAD_CONFIG_VAR(minICPgoodnessToAccept, double, source, section)
95 
96  mapInitializers.loadFromConfigFile(source, section);
97 }
98 
100 {
101  out.printf(
102  "\n----------- [CMetricMapBuilderICP::TConfigParams] ------------ "
103  "\n\n");
104 
105  out.printf(
106  "insertionLinDistance = %f m\n",
107  insertionLinDistance);
108  out.printf(
109  "insertionAngDistance = %f deg\n",
110  RAD2DEG(insertionAngDistance));
111  out.printf(
112  "localizationLinDistance = %f m\n",
113  localizationLinDistance);
114  out.printf(
115  "localizationAngDistance = %f deg\n",
116  RAD2DEG(localizationAngDistance));
117  out.printf(
118  "verbosity_level = %s\n",
120  verbosity_level)
121  .c_str());
122 
123  out.printf(" Now showing 'mapsInitializers':\n");
124  mapInitializers.dumpToTextStream(out);
125 }
126 
127 /*---------------------------------------------------------------
128  processObservation
129  This is the new entry point of the algorithm (the old one
130  was processActionObservation, which now is a wrapper to
131  this method).
132  ---------------------------------------------------------------*/
134 {
135  std::lock_guard<std::mutex> lock_cs(critZoneChangingMap);
136 
137  MRPT_START
138 
140  throw std::runtime_error(
141  "Neither grid maps nor points map: Have you called initialize() "
142  "after setting ICP_options.mapInitializers?");
143 
144  ASSERT_(obs)
145 
146  // Is it an odometry observation??
147  if (IS_CLASS(obs, CObservationOdometry))
148  {
149  MRPT_LOG_DEBUG("processObservation(): obs is CObservationOdometry");
151 
152  const CObservationOdometry::Ptr odo =
153  std::dynamic_pointer_cast<CObservationOdometry>(obs);
154  ASSERT_(odo->timestamp != INVALID_TIMESTAMP)
155 
156  CPose2D pose_before;
157  bool pose_before_valid = m_lastPoseEst.getLatestRobotPose(pose_before);
158 
159  // Move our estimation:
161  odo->odometry, odo->timestamp, odo->hasVelocities,
162  odo->velocityLocal);
163 
164  if (pose_before_valid)
165  {
166  // Accumulate movement:
167  CPose2D pose_after;
168  if (m_lastPoseEst.getLatestRobotPose(pose_after))
169  this->accumulateRobotDisplacementCounters(pose_after);
171  "processObservation(): obs is CObservationOdometry, new "
172  "post_after="
173  << pose_after);
174  }
175  } // end it's odometry
176  else
177  {
178  // Current robot pose given the timestamp of the observation (this can
179  // include a small extrapolation
180  // using the latest known robot velocities):
181  TPose2D initialEstimatedRobotPose(0, 0, 0);
182  {
183  mrpt::math::TTwist2D robotVelLocal, robotVelGlobal;
184  if (obs->timestamp != INVALID_TIMESTAMP)
185  {
187  "processObservation(): extrapolating pose from latest pose "
188  "and new observation timestamp...");
190  initialEstimatedRobotPose, robotVelLocal,
191  robotVelGlobal, obs->timestamp))
192  { // couldn't had a good extrapolation estimate... we'll have
193  // to live with the latest pose:
194  m_lastPoseEst.getLatestRobotPose(initialEstimatedRobotPose);
196  "processObservation(): new pose extrapolation failed, "
197  "using last pose as is.");
198  }
199  }
200  else
201  {
203  "processObservation(): invalid observation timestamp.");
204  m_lastPoseEst.getLatestRobotPose(initialEstimatedRobotPose);
205  }
206  }
207 
208  // To know the total path length:
209  CPose2D previousKnownRobotPose;
210  m_lastPoseEst.getLatestRobotPose(previousKnownRobotPose);
211 
212  // Increment (this may only include the effects of extrapolation with
213  // velocity...):
215  previousKnownRobotPose); // initialEstimatedRobotPose-previousKnownRobotPose);
216 
217  // We'll skip ICP-based localization for this observation only if:
218  // - We had some odometry since the last pose correction
219  // (m_there_has_been_an_odometry=true).
220  // - AND, the traversed distance is small enough:
221  const bool we_skip_ICP_pose_correction =
229 
231  "processObservation(): skipping ICP pose correction due to small "
232  "odometric displacement? : "
233  << (we_skip_ICP_pose_correction ? "YES" : "NO"));
234 
235  CICP::TReturnInfo icpReturn;
236  bool can_do_icp = false;
237 
238  // Select the map to match with ....
239  CMetricMap* matchWith = nullptr;
241  {
242  matchWith = static_cast<CMetricMap*>(metricMap.m_gridMaps[0].get());
243  MRPT_LOG_DEBUG("processObservation(): matching against gridmap.");
244  }
245  else
246  {
247  ASSERTMSG_(
249  "No points map in multi-metric map.")
250  matchWith =
251  static_cast<CMetricMap*>(metricMap.m_pointsMaps[0].get());
252  MRPT_LOG_DEBUG("processObservation(): matching against point map.");
253  }
254  ASSERT_(matchWith != nullptr)
255 
256  if (!we_skip_ICP_pose_correction)
257  {
259 
260  // --------------------------------------------------------------------------------------
261  // Any other observation:
262  // 1) If the observation generates points in a point map, do ICP
263  // 2) In any case, insert the observation if the minimum distance
264  // has been satisfaced.
265  // --------------------------------------------------------------------------------------
266  CSimplePointsMap sensedPoints;
267  sensedPoints.insertionOptions.minDistBetweenLaserPoints = 0.02f;
268  sensedPoints.insertionOptions.also_interpolate = false;
269 
270  // Create points representation of the observation:
271  // Insert only those planar range scans in the altitude of the grid
272  // map:
275  metricMap.m_gridMaps[0]->insertionOptions.useMapAltitude)
276  {
277  // Use grid altitude:
279  {
281  std::dynamic_pointer_cast<CObservation2DRangeScan>(obs);
282  if (std::abs(
284  ->insertionOptions.mapAltitude -
285  obsLaser->sensorPose.z()) < 0.01)
286  can_do_icp = sensedPoints.insertObservationPtr(obs);
287  }
288  }
289  else
290  {
291  // Do not use grid altitude:
292  can_do_icp = sensedPoints.insertObservationPtr(obs);
293  }
294 
295  if (IS_DERIVED(matchWith, CPointsMap) &&
296  static_cast<CPointsMap*>(matchWith)->empty())
297  can_do_icp = false; // The reference map is empty!
298 
299  if (can_do_icp)
300  {
301  // We DO HAVE points with this observation:
302  // Execute ICP over the current points map and the sensed
303  // points:
304  // ----------------------------------------------------------------------
305  CICP ICP;
306  float runningTime;
307 
308  ICP.options = ICP_params;
309 
310  CPosePDF::Ptr pestPose = ICP.Align(
311  matchWith, // Map 1
312  &sensedPoints, // Map 2
314  initialEstimatedRobotPose), // a first gross estimation
315  // of map 2 relative to map
316  // 1.
317  &runningTime, // Running time
318  &icpReturn // Returned information
319  );
320 
322  {
323  // save estimation:
324  CPosePDFGaussian pEst2D;
325  pEst2D.copyFrom(*pestPose);
326 
328  TPose2D(pEst2D.mean), obs->timestamp);
329  m_lastPoseEst_cov = pEst2D.cov;
330 
332 
333  // Debug output to console:
335  "processObservation: previousPose="
336  << previousKnownRobotPose << "-> currentPose="
337  << pEst2D.getMeanVal() << std::endl);
339  format(
340  "[CMetricMapBuilderICP] Fit:%.1f%% Itr:%i In "
341  "%.02fms \n",
342  icpReturn.goodness * 100, icpReturn.nIterations,
343  1000 * runningTime));
344  }
345  else
346  {
348  "Ignoring ICP of low quality: "
349  << icpReturn.goodness * 100 << std::endl);
350  }
351 
352  // Compute the transversed length:
353  CPose2D currentKnownRobotPose;
354  m_lastPoseEst.getLatestRobotPose(currentKnownRobotPose);
355 
357  currentKnownRobotPose); // currentKnownRobotPose -
358  // previousKnownRobotPose);
359 
360  } // end we can do ICP.
361  else
362  {
364  "Cannot do ICP: empty pointmap or not suitable "
365  "gridmap...\n");
366  }
367 
368  } // else, we do ICP pose correction
369 
370  // ----------------------------------------------------------
371  // CRITERION TO DECIDE MAP UPDATE:
372  // A distance large-enough from the last update for each sensor, AND
373  // either: (i) this was a good match or (ii) this is the first time
374  // for this sensor.
375  // ----------------------------------------------------------
376  const bool firstTimeForThisSensor =
377  m_distSinceLastInsertion.find(obs->sensorLabel) ==
379  bool update =
380  firstTimeForThisSensor ||
381  ((!can_do_icp ||
383  (m_distSinceLastInsertion[obs->sensorLabel].lin >=
385  m_distSinceLastInsertion[obs->sensorLabel].ang >=
387 
388  // Used any "options.alwaysInsertByClass" ??
389  if (options.alwaysInsertByClass.contains(obs->GetRuntimeClass()))
390  update = true;
391 
392  // We need to always insert ALL the observations at the beginning until
393  // the first one
394  // that actually insert some points into the map used as a reference,
395  // since otherwise
396  // we'll not be able to do ICP against an empty map!!
397  if (matchWith && matchWith->isEmpty()) update = true;
398 
400  "update map: " << (update ? "YES" : "NO")
401  << " options.enableMapUpdating: "
402  << (options.enableMapUpdating ? "YES" : "NO"));
403 
404  if (options.enableMapUpdating && update)
405  {
406  CTicTac tictac;
407 
408  tictac.Tic();
409 
410  // Insert the observation:
411  CPose2D currentKnownRobotPose;
412  m_lastPoseEst.getLatestRobotPose(currentKnownRobotPose);
413 
414  // Create new entry:
415  m_distSinceLastInsertion[obs->sensorLabel].last_update =
416  currentKnownRobotPose;
417 
418  // Reset distance counters:
419  resetRobotDisplacementCounters(currentKnownRobotPose);
420  // m_distSinceLastInsertion[obs->sensorLabel].updatePose(currentKnownRobotPose);
421 
423  mrpt::format(
424  "Updating map from pose %s\n",
425  currentKnownRobotPose.asString().c_str()));
426 
427  CPose3D estimatedPose3D(currentKnownRobotPose);
428  const bool anymap_update =
429  metricMap.insertObservationPtr(obs, &estimatedPose3D);
430  if (!anymap_update)
432  "**No map was updated** after inserting an observation of "
433  "type `"
434  << obs->GetRuntimeClass()->className << "`");
435 
436  // Add to the vector of "poses"-"SFs" pairs:
437  CPosePDFGaussian posePDF(currentKnownRobotPose);
438  CPose3DPDF::Ptr pose3D =
439  CPose3DPDF::Ptr(CPose3DPDF::createFrom2D(posePDF));
440 
441  CSensoryFrame::Ptr sf = mrpt::make_aligned_shared<CSensoryFrame>();
442  sf->insert(obs);
443 
444  SF_Poses_seq.insert(pose3D, sf);
445 
447  "Map updated OK. Done in "
448  << mrpt::system::formatTimeInterval(tictac.Tac()) << std::endl);
449  }
450 
451  } // end other observation
452 
453  // Robot path history:
454  {
455  TPose2D p;
457  }
458 
459  MRPT_END
460 
461 } // end processObservation
462 
463 /*---------------------------------------------------------------
464 
465  processActionObservation
466 
467  ---------------------------------------------------------------*/
469  CActionCollection& action, CSensoryFrame& in_SF)
470 {
471  // 1) process action:
472  CActionRobotMovement2D::Ptr movEstimation =
473  action.getBestMovementEstimation();
474  if (movEstimation)
475  {
477  m_auxAccumOdometry, movEstimation->poseChange->getMeanVal());
478 
480  mrpt::make_aligned_shared<CObservationOdometry>();
481  obs->timestamp = movEstimation->timestamp;
482  obs->odometry = m_auxAccumOdometry;
483  this->processObservation(obs);
484  }
485 
486  // 2) Process observations one by one:
487  for (CSensoryFrame::iterator i = in_SF.begin(); i != in_SF.end(); ++i)
488  this->processObservation(*i);
489 }
490 
491 /*---------------------------------------------------------------
492  setCurrentMapFile
493  ---------------------------------------------------------------*/
495 {
496  // Save current map to current file:
498 
499  // Sets new current map file:
500  currentMapFile = mapFile;
501 
502  // Load map from file or create an empty one:
503  if (currentMapFile.size()) loadCurrentMapFromFile(mapFile);
504 }
505 
506 /*---------------------------------------------------------------
507  getCurrentPoseEstimation
508  ---------------------------------------------------------------*/
510 {
511  CPosePDFGaussian pdf2D;
513  pdf2D.cov = m_lastPoseEst_cov;
514 
516  mrpt::make_aligned_shared<CPose3DPDFGaussian>();
517  pdf3D->copyFrom(pdf2D);
518  return pdf3D;
519 }
520 
521 /*---------------------------------------------------------------
522  initialize
523  ---------------------------------------------------------------*/
525  const CSimpleMap& initialMap, const CPosePDF* x0)
526 {
527  MRPT_START
528 
529  // Reset vars:
530  m_estRobotPath.clear();
531  m_auxAccumOdometry = CPose2D(0, 0, 0);
532 
534  m_distSinceLastInsertion.clear();
535 
537 
538  // Init path & map:
539  std::lock_guard<std::mutex> lock_cs(critZoneChangingMap);
540 
541  // Create metric maps:
543 
544  // copy map:
545  SF_Poses_seq = initialMap;
546 
547  // Parse SFs to the hybrid map:
548  // Set options:
549  // ---------------------
550  // if (metricMap.m_pointsMaps.size())
551  //{
552  // metricMap.m_pointsMaps[0]->insertionOptions.fuseWithExisting =
553  // false;
554  // metricMap.m_pointsMaps[0]->insertionOptions.minDistBetweenLaserPoints =
555  // 0.05f;
556  // metricMap.m_pointsMaps[0]->insertionOptions.disableDeletion =
557  // true;
558  // metricMap.m_pointsMaps[0]->insertionOptions.isPlanarMap =
559  // true;
560  // metricMap.m_pointsMaps[0]->insertionOptions.matchStaticPointsOnly =
561  // true;
562  //}
563 
564  // Load estimated pose from given PDF:
566 
567  if (x0)
569  x0->getMeanVal(), mrpt::system::now());
570 
571  for (size_t i = 0; i < SF_Poses_seq.size(); i++)
572  {
573  CPose3DPDF::Ptr posePDF;
575 
576  // Get the SF and its pose:
577  SF_Poses_seq.get(i, posePDF, SF);
578 
579  CPose3D estimatedPose3D;
580  posePDF->getMean(estimatedPose3D);
581 
582  // Insert observations into the map:
583  SF->insertObservationsInto(&metricMap, &estimatedPose3D);
584  }
585 
586  MRPT_LOG_INFO("loadCurrentMapFromFile() OK.\n");
587 
588  MRPT_END
589 }
590 
591 /*---------------------------------------------------------------
592  getCurrentMapPoints
593  ---------------------------------------------------------------*/
595  std::vector<float>& x, std::vector<float>& y)
596 {
597  // Critical section: We are using our global metric map
599 
601  metricMap.m_pointsMaps[0]->getAllPoints(x, y);
602 
603  // Exit critical zone.
605 }
606 
607 /*---------------------------------------------------------------
608  getCurrentlyBuiltMap
609  ---------------------------------------------------------------*/
611 {
612  out_map = SF_Poses_seq;
613 }
614 
616 {
617  return &metricMap;
618 }
619 
620 /*---------------------------------------------------------------
621  getCurrentlyBuiltMapSize
622  ---------------------------------------------------------------*/
624 {
625  return SF_Poses_seq.size();
626 }
627 
628 /*---------------------------------------------------------------
629  saveCurrentEstimationToImage
630  ---------------------------------------------------------------*/
632  const std::string& file, bool formatEMF_BMP)
633 {
634  MRPT_START
635 
636  CImage img;
637  const size_t nPoses = m_estRobotPath.size();
638 
640 
641  if (!formatEMF_BMP) THROW_EXCEPTION("Not implemented yet for BMP!");
642 
643  // grid map as bitmap:
644  // ----------------------------------
645  metricMap.m_gridMaps[0]->getAsImage(img);
646 
647  // Draw paths (using vectorial plots!) over the EMF file:
648  // -------------------------------------------------
649  // float SCALE = 1000;
650  CEnhancedMetaFile EMF(file, 1000);
651 
652  EMF.drawImage(0, 0, img);
653 
654  unsigned int imgHeight = img.getHeight();
655 
656  // Path hypothesis:
657  // ----------------------------------
658  int x1, x2, y1, y2;
659 
660  // First point: (0,0)
661  x2 = metricMap.m_gridMaps[0]->x2idx(0.0f);
662  y2 = metricMap.m_gridMaps[0]->y2idx(0.0f);
663 
664  // Draw path in the bitmap:
665  for (size_t j = 0; j < nPoses; j++)
666  {
667  // For next segment
668  x1 = x2;
669  y1 = y2;
670 
671  // Coordinates -> pixels
672  x2 = metricMap.m_gridMaps[0]->x2idx(m_estRobotPath[j].x);
673  y2 = metricMap.m_gridMaps[0]->y2idx(m_estRobotPath[j].y);
674 
675  // Draw line:
676  EMF.line(x1, imgHeight - 1 - y1, x2, imgHeight - 1 - y2, TColor::black());
677  }
678 
679  MRPT_END
680 }
681 
683  const CPose2D& new_pose)
684 {
686 
689  m_distSinceLastInsertion.begin();
690  it != m_distSinceLastInsertion.end(); ++it)
691  it->second.updateDistances(new_pose);
692 }
693 
695  const CPose2D& new_pose)
696 {
697  m_distSinceLastICP.updatePose(new_pose);
698 
701  m_distSinceLastInsertion.begin();
702  it != m_distSinceLastInsertion.end(); ++it)
703  it->second.updatePose(new_pose);
704 }
705 
707 {
708  mrpt::poses::CPose2D Ap = p - this->last_update;
709  lin = Ap.norm();
710  ang = std::abs(Ap.phi());
711 }
712 
714 {
715  this->last_update = p;
716  lin = 0;
717  ang = 0;
718 }
void saveCurrentMapToFile(const std::string &fileName, bool compressGZ=true) const
Save map (mrpt::maps::CSimpleMap) to a ".simplemap" file.
void copyFrom(const CPosePDF &o) override
Copy operator, translating if necesary (for example, between particles and gaussian representations) ...
EIGEN_STRONG_INLINE bool empty() const
double localizationAngDistance
Minimum robot angular (rad, deg when loaded from the .ini) displacement for a new observation to be u...
void updatePose(const mrpt::poses::CPose2D &p)
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
CPose2D mean
The mean value.
void asString(std::string &s) const
Returns a human-readable textual representation of the object (eg: "[x y yaw]", yaw in degrees) ...
Definition: CPose2D.cpp:433
mrpt::maps::TSetOfMetricMapInitializers mapInitializers
What maps to create (at least one points map and/or a grid map are needed).
#define min(a, b)
mrpt::maps::CMultiMetricMap metricMap
The metric map representation as a points map:
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
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.
ProxyFilterContainerByClass< mrpt::maps::CSimplePointsMap::Ptr, TListMaps > m_pointsMaps
STL-like proxy to access this kind of maps in maps.
double minICPgoodnessToAccept
Minimum ICP goodness (0,1) to accept the resulting corrected position (default: 0.40)
void getCurrentMapPoints(std::vector< float > &x, std::vector< float > &y)
Returns the 2D points of current local map.
This class stores a sequence of <Probabilistic Pose,SensoryFrame> pairs, thus a "metric map" can be t...
Definition: CSimpleMap.h:35
std::shared_ptr< CPose3DPDFGaussian > Ptr
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:118
mrpt::poses::CPosePDF::Ptr Align(const mrpt::maps::CMetricMap *m1, const mrpt::maps::CMetricMap *m2, const mrpt::poses::CPose2D &grossEst, float *runningTime=nullptr, void *info=nullptr)
The method for aligning a pair of metric maps, aligning only 2D + orientation.
Several implementations of ICP (Iterative closest point) algorithms for aligning two point maps or a ...
Definition: CICP.h:67
#define THROW_EXCEPTION(msg)
bool contains(const mrpt::utils::TRuntimeClassId *id) const
Does the list contains this class?
TDATA getMeanVal() const
Returns the mean, or mathematical expectation of the probability density distribution (PDF)...
std::deque< mrpt::math::TPose2D > m_estRobotPath
The estimated robot path:
void leaveCriticalSection()
Leave critical section for map updating.
Scalar * iterator
Definition: eigen_plugins.h:26
virtual ~CMetricMapBuilderICP()
Destructor:
bool getLatestRobotPose(mrpt::math::TPose2D &pose) const
Get the latest known robot pose, either from odometry or localization.
bool enableMapUpdating
Enable map updating, default is true.
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Definition: datetime.h:76
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans. ...
STL namespace.
std::string formatTimeInterval(const double timeSeconds)
Returns a formated string with the given time difference (passed as the number of seconds)...
Definition: datetime.cpp:231
std::shared_ptr< CObservation2DRangeScan > Ptr
mrpt::maps::CSimpleMap SF_Poses_seq
The set of observations that leads to current map:
TConfigParams options
The options employed by the ICP align.
Definition: CICP.h:185
void Tic()
Starts the stopwatch.
Definition: CTicTac.cpp:82
TConfigParams ICP_options
Options for the ICP-SLAM application.
double insertionAngDistance
Minimum robot angular (rad, deg when loaded from the .ini) displacement for a new observation to be i...
Helper types for STL containers with Eigen memory allocators.
void initialize(const mrpt::maps::CSimpleMap &initialMap=mrpt::maps::CSimpleMap(), const mrpt::poses::CPosePDF *x0=nullptr) override
Initialize the method, starting with a known location PDF "x0"(if supplied, set to nullptr to left un...
mrpt::math::CMatrixDouble33 cov
The 3x3 covariance matrix.
Declares a class for storing a collection of robot actions.
void reset()
Resets all internal state.
std::shared_ptr< CObservationOdometry > Ptr
bool matchAgainstTheGrid
(default:false) Match against the occupancy grid or the points map? The former is quicker but less pr...
void updateDistances(const mrpt::poses::CPose2D &p)
This class allows loading and storing values and vectors of different types from a configuration text...
void enterCriticalSection()
Enter critical section for map updating.
2D twist: 2D velocity vector (vx,vy) + planar angular velocity (omega)
const_iterator begin() const
Returns a constant iterator to the first observation: this is an example of usage: ...
CICP::TConfigParams ICP_params
Options for the ICP algorithm itself.
#define IS_DERIVED(ptrObj, class_name)
Evaluates to true if the given pointer to an object (derived from mrpt::utils::CSerializable) is an i...
Definition: CObject.h:109
float goodness
A goodness measure for the alignment, it is a [0,1] range indicator of percentage of correspondences...
Definition: CICP.h:202
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans or other sensors...
Definition: CPointsMap.h:63
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
std::shared_ptr< CPosePDF > Ptr
Definition: CPosePDF.h:44
Declares a class that represents a Probability Density function (PDF) of a 2D pose ...
#define MRPT_END
std::shared_ptr< CActionRobotMovement2D > Ptr
CActionRobotMovement2D::Ptr getBestMovementEstimation() const
Returns the best pose increment estimator in the collection, based on the determinant of its pose cha...
TConfigParams & operator=(const TConfigParams &other)
void processUpdateNewPoseLocalization(const mrpt::math::TPose2D &newPose, mrpt::system::TTimeStamp tim)
Updates the filter with new global-coordinates localization data from a localization or SLAM source...
double norm() const
Returns the euclidean norm of vector: .
Definition: CPoseOrPoint.h:252
#define MRPT_LOG_WARN(_STRING)
std::string currentMapFile
Current map file.
A helper class that can convert an enum value into its textual representation, and viceversa...
Definition: TEnumType.h:38
GLint GLvoid * img
Definition: glext.h:3763
TConfigParams(mrpt::utils::VerbosityLevel &parent_verbosity_level)
Initializer.
#define MRPT_LOG_INFO(_STRING)
const mrpt::maps::CMultiMetricMap * getCurrentlyBuiltMetricMap() const override
Returns the map built so far.
This class implements a high-performance stopwatch.
Definition: CTicTac.h:23
mrpt::utils::CListOfClasses alwaysInsertByClass
A list of observation classes (derived from mrpt::obs::CObservation) which will be always inserted in...
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::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:19
std::shared_ptr< CSensoryFrame > Ptr
Definition: CSensoryFrame.h:56
ProxyFilterContainerByClass< mrpt::maps::COccupancyGridMap2D::Ptr, TListMaps > m_gridMaps
STL-like proxy to access this kind of maps in maps.
#define MRPT_LOG_WARN_STREAM(__CONTENTS)
#define MRPT_LOG_DEBUG(_STRING)
void resetRobotDisplacementCounters(const mrpt::poses::CPose2D &new_pose)
size_t size() const
Returns the count of pairs (pose,sensory data)
Definition: CSimpleMap.cpp:65
std::shared_ptr< CObservation > Ptr
Definition: CObservation.h:43
void loadCurrentMapFromFile(const std::string &fileName)
Load map (mrpt::maps::CSimpleMap) from a ".simplemap" file.
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
#define DEG2RAD
unsigned short nIterations
The number of executed iterations until convergence.
Definition: CICP.h:199
GLsizei const GLchar ** string
Definition: glext.h:4101
Declares a class that represents a probability density function (pdf) of a 2D pose (x...
Definition: CPosePDF.h:41
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CPoint.h:17
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
Definition: datetime.h:16
void setCurrentMapFile(const char *mapFile)
Sets the "current map file", thus that map will be loaded if it exists or a new one will be created i...
mrpt::aligned_containers< std::string, TDist >::map_t m_distSinceLastInsertion
Indexed by sensor label.
void line(int x0, int y0, int x1, int y1, const mrpt::utils::TColor color, unsigned int width=1, TPenStyle penStyle=psSolid) override
Draws a line.
void processUpdateNewOdometry(const mrpt::math::TPose2D &newGlobalOdometry, mrpt::system::TTimeStamp cur_tim, bool hasVelocities=false, const mrpt::math::TTwist2D &newRobotVelLocal=mrpt::math::TTwist2D())
Updates the filter with new odometry readings.
bool also_interpolate
If set to true, far points (<1m) are interpolated with samples at "minDistSqrBetweenLaserPoints" inte...
Definition: CPointsMap.h:224
void drawImage(int x, int y, const utils::CImage &img) override
Draws an image as a bitmap at a given position.
#define MRPT_START
This class represents a Windows Enhanced Meta File (EMF) for generating and saving graphics...
mrpt::poses::CRobot2DPoseEstimator m_lastPoseEst
The pose estimation by the alignment algorithm (ICP).
#define RAD2DEG
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
#define MRPT_LOG_INFO_STREAM(__CONTENTS)
Declares a virtual base class for all metric maps storage classes.
Definition: CMetricMap.h:55
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
void setListOfMaps(const mrpt::maps::TSetOfMetricMapInitializers *initializers)
Sets the list of internal map according to the passed list of map initializers (Current maps&#39; content...
bool getCurrentEstimate(mrpt::math::TPose2D &pose, mrpt::math::TTwist2D &velLocal, mrpt::math::TTwist2D &velGlobal, mrpt::system::TTimeStamp tim_query=mrpt::system::now()) const
Get the estimate for a given timestamp (defaults to now()), obtained as:
const double & phi() const
Get the phi angle of the 2D pose (in radians)
Definition: CPose2D.h:91
#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
void composeFrom(const CPose2D &A, const CPose2D &B)
Makes .
Definition: CPose2D.cpp:124
The ICP algorithm return information.
Definition: CICP.h:195
bool insertObservationPtr(const mrpt::obs::CObservation::Ptr &obs, const mrpt::poses::CPose3D *robotPose=NULL)
A wrapper for smart pointers, just calls the non-smart pointer version.
Definition: CMetricMap.cpp:109
Lightweight 2D pose.
double Tac()
Stops the stopwatch.
Definition: CTicTac.cpp:97
GLsizei GLsizei GLchar * source
Definition: glext.h:4082
void processObservation(const mrpt::obs::CObservation::Ptr &obs)
The main method of this class: Process one odometry or sensor observation.
#define ASSERT_(f)
void getCurrentlyBuiltMap(mrpt::maps::CSimpleMap &out_map) const override
Fills "out_map" with the set of "poses"-"sensory-frames", thus the so far built map.
mrpt::math::CMatrixDouble33 m_lastPoseEst_cov
Last pose estimation (covariance)
double localizationLinDistance
Minimum robot linear (m) displacement for a new observation to be used to do ICP-based localization (...
GLenum GLint GLint y
Definition: glext.h:3538
TInsertionOptions insertionOptions
The options used when inserting observations in the map.
Definition: CPointsMap.h:256
mrpt::poses::CPose3DPDF::Ptr getCurrentPoseEstimation() const override
Returns a copy of the current best pose estimation as a pose PDF.
std::deque< CObservation::Ptr >::iterator iterator
You can use CSensoryFrame::begin to get a iterator to the first element.
#define MRPT_LOAD_CONFIG_VAR_DEGREES( variableName, configFileObject, sectionNameStr)
Loads a double variable, stored as radians but entered in the INI-file as degrees.
An observation of the current (cumulative) odometry for a wheeled robot.
#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...
GLenum GLint x
Definition: glext.h:3538
const_iterator end() const
Returns a constant iterator to the end of the list of observations: this is an example of usage: ...
This class stores any customizable set of metric maps.
void insert(const mrpt::poses::CPose3DPDF *in_posePDF, const mrpt::obs::CSensoryFrame &in_SF)
Add a new pair to the sequence.
Definition: CSimpleMap.cpp:177
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.
#define MRPT_LOG_DEBUG_STREAM(__CONTENTS)
#define ASSERTMSG_(f, __ERROR_MSG)
virtual bool isEmpty() const =0
Returns true if the map is empty/no observation has been inserted.
GLfloat GLfloat p
Definition: glext.h:6305
unsigned int getCurrentlyBuiltMapSize() override
Returns just how many sensory-frames are stored in the currently build map.
std::mutex critZoneChangingMap
Critical zones.
void processActionObservation(mrpt::obs::CActionCollection &action, mrpt::obs::CSensoryFrame &in_SF) override
Appends a new action and observations to update this map: See the description of the class at the top...
double insertionLinDistance
Minimum robot linear (m) displacement for a new observation to be inserted in the map...
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
void saveCurrentEstimationToImage(const std::string &file, bool formatEMF_BMP=true) override
A useful method for debugging: the current map (and/or poses) estimation is dumped to an image file...
float minDistBetweenLaserPoints
The minimum distance between points (in 3D): If two points are too close, one of them is not inserted...
Definition: CPointsMap.h:217
void accumulateRobotDisplacementCounters(const mrpt::poses::CPose2D &new_pose)
Traveled distances from last map update / ICP-based localization.



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