Main MRPT website > C++ reference for MRPT 1.9.9
observations_overlap.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-2018, 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 
13 #include <mrpt/maps/CPointsMap.h>
15 
16 using namespace mrpt::slam;
17 using namespace mrpt::maps;
18 using namespace mrpt::obs;
19 using namespace mrpt::poses;
20 using namespace std;
21 
22 /** Estimates the "overlap" or "matching ratio" of two observations (range
23  * [0,1]), possibly taking into account their relative positions.
24  * \note This is used in mrpt::slam::CIncrementalMapPartitioner
25  */
28  const mrpt::poses::CPose3D* pose_o2_wrt_o1)
29 {
32  {
33  const CObservation2DRangeScan* this_obs =
34  static_cast<const CObservation2DRangeScan*>(o1);
35  const CObservation2DRangeScan* obs =
36  static_cast<const CObservation2DRangeScan*>(o2);
37 
38  const CPointsMap* map1 =
40  const CPointsMap* map2 =
42 
43  // if PDF is available, get "mean" value as an estimation:
44  CPose3D otherObsPose;
45  if (pose_o2_wrt_o1) otherObsPose = *pose_o2_wrt_o1;
46 
47  mrpt::tfest::TMatchingPairList correspondences;
48  mrpt::maps::TMatchingParams matchParams;
49  mrpt::maps::TMatchingExtraResults matchExtraResults;
50 
51  matchParams.maxDistForCorrespondence = 0.04f;
52  matchParams.maxAngularDistForCorrespondence = 0;
53  map1->determineMatching3D(
54  map2, // The other map
55  otherObsPose, // The other map pose
56  correspondences, matchParams, matchExtraResults);
57 
58  return matchExtraResults.correspondencesRatio;
59  }
60  else
61  {
62  // No idea...
63  return 0;
64  }
65 }
66 
67 /** Estimates the "overlap" or "matching ratio" of two set of observations
68  * (range [0,1]), possibly taking into account their relative positions.
69  * This method computes the average between each of the observations in each
70  * SF.
71  * \note This is used in mrpt::slam::CIncrementalMapPartitioner
72  */
75  const mrpt::poses::CPose3D* pose_sf2_wrt_sf1)
76 {
77  MRPT_UNUSED_PARAM(pose_sf2_wrt_sf1);
78  // Return the average value:
79  size_t N = 0;
80  double accum = 0;
81  for (CSensoryFrame::const_iterator i1 = sf1.begin(); i1 != sf1.end(); ++i1)
82  {
83  for (CSensoryFrame::const_iterator i2 = sf2.begin(); i2 != sf2.end();
84  ++i2)
85  {
86  accum += observationsOverlap(*i1, *i2);
87  N++;
88  }
89  }
90  return N ? (accum / N) : 0;
91 }
mrpt::maps::CPointsMap::determineMatching3D
virtual void determineMatching3D(const mrpt::maps::CMetricMap *otherMap, const mrpt::poses::CPose3D &otherMapPose, mrpt::tfest::TMatchingPairList &correspondences, const TMatchingParams &params, TMatchingExtraResults &extraResults) const override
Computes the matchings between this and another 3D points map - method used in 3D-ICP.
Definition: CPointsMap.cpp:1072
CPointsMap.h
mrpt::obs::CSensoryFrame::end
const_iterator end() const
Returns a constant iterator to the end of the list of observations: this is an example of usage:
Definition: CSensoryFrame.h:260
mrpt::obs::CObservation2DRangeScan
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
Definition: CObservation2DRangeScan.h:56
MRPT_UNUSED_PARAM
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
Definition: common.h:186
mrpt::maps::CPointsMap
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans or other sensors.
Definition: CPointsMap.h:64
mrpt::obs::CObservation2DRangeScan::buildAuxPointsMap
const POINTSMAP * buildAuxPointsMap(const void *options=nullptr) const
Returns a cached points map representing this laser scan, building it upon the first call.
Definition: CObservation2DRangeScan.h:195
mrpt::poses
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CHierarchicalMapMHPartition.h:25
mrpt::maps::TMatchingExtraResults::correspondencesRatio
float correspondencesRatio
The ratio [0,1] of points in otherMap with at least one correspondence.
Definition: metric_map_types.h:66
observations_overlap.h
mrpt::obs
This namespace contains representation of robot actions and observations.
Definition: CParticleFilter.h:17
mrpt::obs::CSensoryFrame
Declares a class for storing a "sensory frame", a set of "observations" taken by the robot approximat...
Definition: CSensoryFrame.h:54
mrpt::maps::TMatchingParams::maxDistForCorrespondence
float maxDistForCorrespondence
Maximum linear distance between two points to be paired (meters)
Definition: metric_map_types.h:25
mrpt::obs::CSensoryFrame::begin
const_iterator begin() const
Returns a constant iterator to the first observation: this is an example of usage:
Definition: CSensoryFrame.h:247
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
IS_CLASS
#define IS_CLASS(ptrObj, class_name)
Evaluates to true if the given pointer to an object (derived from mrpt::rtti::CObject) is of the give...
Definition: CObject.h:103
mrpt::obs::CSensoryFrame::const_iterator
std::deque< CObservation::Ptr >::const_iterator const_iterator
You can use CSensoryFrame::begin to get a iterator to the first element.
Definition: CSensoryFrame.h:233
mrpt::maps::TMatchingParams
Parameters for the determination of matchings between point clouds, etc.
Definition: metric_map_types.h:22
slam-precomp.h
mrpt::obs::CObservation
Declares a class that represents any robot's observation.
Definition: CObservation.h:43
mrpt::tfest::TMatchingPairList
A list of TMatchingPair.
Definition: TMatchingPair.h:83
mrpt::maps
Definition: CBeacon.h:24
mrpt::maps::TMatchingExtraResults
Additional results from the determination of matchings between point clouds, etc.,...
Definition: metric_map_types.h:62
mrpt::slam::observationsOverlap
double observationsOverlap(const mrpt::obs::CObservation *o1, const mrpt::obs::CObservation *o2, const mrpt::poses::CPose3D *pose_o2_wrt_o1=nullptr)
Estimates the "overlap" or "matching ratio" of two observations (range [0,1]), possibly taking into a...
Definition: observations_overlap.cpp:26
mrpt::slam
Definition: CMultiMetricMapPDF.h:27
mrpt::maps::TMatchingParams::maxAngularDistForCorrespondence
float maxAngularDistForCorrespondence
Allowed "angular error" (in radians): this permits larger pairing threshold distances to more distant...
Definition: metric_map_types.h:28
CObservation2DRangeScan.h



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST