Main MRPT website > C++ reference for MRPT 1.9.9
CIncrementalMapPartitioner.h
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 #pragma once
11 
16 #include <mrpt/maps/CSimpleMap.h>
18 #include <mrpt/poses/poses_frwds.h>
20 #include <functional>
21 #include <limits>
22 
23 namespace mrpt
24 {
25 namespace slam
26 {
27 
28 /** For use in CIncrementalMapPartitioner
29  * \ingroup mrpt_slam_grp */
31 {
35 };
36 
37 /** Map keyframe, comprising raw observations and they as a metric map.
38  * For use in CIncrementalMapPartitioner
39  * \ingroup mrpt_slam_grp */
41 {
45 };
46 
47 
48 /** Type of similarity evaluator for map keyframes.
49 * For use in CIncrementalMapPartitioner
50 * \ingroup mrpt_slam_grp */
51 using similarity_func_t = std::function<double(
52  const map_keyframe_t &kf1,
53  const map_keyframe_t &kf2,
54  const mrpt::poses::CPose3D &relPose2wrt1
55  )>;
56 
57 /** Finds partitions in metric maps based on N-cut graph partition theory.
58  * \ingroup mrpt_slam_grp
59  */
62 {
63  // This must be added to any CSerializable derived class:
65 
66  public:
67  /** ctor */
68  CIncrementalMapPartitioner() : COutputLogger("CIncrementalMapPartitioner") {}
69 
70  /** Configuration parameters */
72  {
73  void loadFromConfigFile(
75  const std::string& section) override;
77  const std::string& section) const;
78 
79  /**!< N-cut partition threshold [0,2] (default=1) */
80  double partitionThreshold{ 1.0 };
81 
82  /** These parameters are loaded/saved to config files
83  * with the prefix "mrp.{param_name}" */
85 
86  /* Force bisection (true) or automatically determine
87  * number of partitions (false=default).
88  */
89  bool forceBisectionOnly{ false };
90 
91  /** Defines the method for determining the adjacency matrix values.
92  * \sa CIncrementalMapPartitioner::setSimilarityMethod()
93  */
95 
96  /** If a partition leads to a cluster with less elements than this, it
97  * will be rejected even if had a good Ncut (default=1).
98  */
100 
101  /** Type and parameters of metric map(s) to build for each keyframe.
102  * Parameters can be loaded from a config file from sections
103  * with the prefix of this "TOptions" section + ".metricmap".
104  * Default: a CSimplePointsMap */
106 
107  /** Maximum distance, in KF identifier numbers, to check for similarity.
108  * Default=Infinite. Can be used to constraint the wrong detection of clusters
109  * after loop closures but before correcting global poses. */
110  uint64_t maxKeyFrameDistanceToEval{std::numeric_limits<uint64_t>::max()};
111 
112  TOptions();
113  };
114 
115  /** \name Main map partition API
116  * @{ */
117 
118  /** Algorithm parameters */
120 
121  /* Reset the internal state to an empty map */
122  void clear();
123 
124  /**\brief Insert a new keyframe to the graph.
125  *
126  * Call this method each time a new observation is added to the map/graph.
127  * Afterwards, call updatePartitions() to get the updated partitions.
128  *
129  * \param frame The sensed data
130  * \param robotPose An estimation of the robot global pose.
131  *
132  * \return The index of the new pose in the graph, which can be used to
133  * refer to this pose in the future.
134  *
135  * \sa updatePartitions
136  */
138  const mrpt::obs::CSensoryFrame& frame,
139  const mrpt::poses::CPose3DPDF& robotPose3D);
140 
141  /** Recalculate the map/graph partitions. \sa addMapFrame() */
142  void updatePartitions(std::vector<std::vector<uint32_t>>& partitions);
143 
144  /**Get the total node count currently in the internal map/graph. */
145  size_t getNodesCount();
146 
147  /** Remove a list of keyframes, with indices as returned by addMapFrame()
148  * \param changeCoordsRef If true, coordinates are changed to leave the first
149  * node at (0,0,0).
150  */
151  void removeSetOfNodes(
152  std::vector<uint32_t> indexesToRemove, bool changeCoordsRef = true);
153 
154  /**\name Change Coordinates System
155  * \brief Change the coordinate origin of all stored poses
156  *
157  * Used for consistency with future new poses to enter in the system.
158  */
159  void changeCoordinatesOrigin(const mrpt::poses::CPose3D& newOrigin);
160  /**\brief The new origin is given by the index of the pose that is to
161  * become the new origin.
162  */
163  void changeCoordinatesOriginPoseIndex(unsigned int newOriginPose);
164 
165  /** Select the similarity method to use for newly inserted keyframes */
167  options.simil_method = method;
168  }
169 
170  /** Sets a custom function for the similarity of new keyframes */
173  m_sim_func = func;
174  }
175  /** @} */
176 
177  /** \name Access API to internal graph data
178  * @{ */
179  /**Return a 3D representation of the graph: poses & links between them.
180  * The previous contents of "objs" will be discarded
181  */
182  void getAs3DScene(
184  const std::map<uint32_t, int64_t>* renameIndexes = NULL) const;
185 
186  /** Return a copy of the adjacency matrix. */
187  template <class MATRIX>
188  void getAdjacencyMatrix(MATRIX& outMatrix) const
189  {
190  outMatrix = m_A;
191  }
192 
193  /** Return a const ref to the internal adjacency matrix. */
195 
196  /** Read-only access to the sequence of Sensory Frames */
198  {
199  return &m_individualFrames;
200  }
201 
202  /** Access to the sequence of Sensory Frames */
204  {
205  return &m_individualFrames;
206  }
207  /** @} */
208 
209  private:
211  std::deque<mrpt::maps::CMultiMetricMap::Ptr> m_individualMaps;
212 
213  /** Adjacency matrix */
215 
216  /** The last partition */
217  std::vector<std::vector<uint32_t>> m_last_partition;
218 
219  /** This will be true after adding new observations, and before an
220  * "updatePartitions" is invoked. */
222 
224 
225 }; // End of class def.
226 }
227 } // End of namespace
228 
234 
mrpt::slam::CIncrementalMapPartitioner::TOptions
Configuration parameters.
Definition: CIncrementalMapPartitioner.h:71
mrpt::slam::CIncrementalMapPartitioner::TOptions::forceBisectionOnly
bool forceBisectionOnly
Definition: CIncrementalMapPartitioner.h:89
MRPT_ENUM_TYPE_END
#define MRPT_ENUM_TYPE_END()
Definition: TEnumType.h:74
mrpt::slam::CIncrementalMapPartitioner::getAs3DScene
void getAs3DScene(mrpt::opengl::CSetOfObjects::Ptr &objs, const std::map< uint32_t, int64_t > *renameIndexes=NULL) const
Return a 3D representation of the graph: poses & links between them.
Definition: CIncrementalMapPartitioner.cpp:351
mrpt::slam::CIncrementalMapPartitioner::updatePartitions
void updatePartitions(std::vector< std::vector< uint32_t >> &partitions)
Recalculate the map/graph partitions.
Definition: CIncrementalMapPartitioner.cpp:227
mrpt::slam::CIncrementalMapPartitioner::TOptions::saveToConfigFile
void saveToConfigFile(mrpt::config::CConfigFileBase &target, const std::string &section) const
This method saves the options to a ".ini"-like file or memory-stored string list.
Definition: CIncrementalMapPartitioner.cpp:86
mrpt::obs::CSensoryFrame::Ptr
std::shared_ptr< CSensoryFrame > Ptr
Definition: CSensoryFrame.h:56
mrpt::slam::CIncrementalMapPartitioner::TOptions::mrp
mrpt::maps::TMatchingRatioParams mrp
These parameters are loaded/saved to config files with the prefix "mrp.{param_name}".
Definition: CIncrementalMapPartitioner.h:84
mrpt::slam::CIncrementalMapPartitioner::setSimilarityMethod
void setSimilarityMethod(similarity_method_t method)
Select the similarity method to use for newly inserted keyframes.
Definition: CIncrementalMapPartitioner.h:166
CMultiMetricMap.h
mrpt::slam::smOBSERVATION_OVERLAP
@ smOBSERVATION_OVERLAP
Definition: CIncrementalMapPartitioner.h:33
mrpt::slam::smCUSTOM_FUNCTION
@ smCUSTOM_FUNCTION
Definition: CIncrementalMapPartitioner.h:34
mrpt::slam::CIncrementalMapPartitioner::m_individualFrames
mrpt::maps::CSimpleMap m_individualFrames
Definition: CIncrementalMapPartitioner.h:210
mrpt::slam::CIncrementalMapPartitioner::removeSetOfNodes
void removeSetOfNodes(std::vector< uint32_t > indexesToRemove, bool changeCoordsRef=true)
Remove a list of keyframes, with indices as returned by addMapFrame()
Definition: CIncrementalMapPartitioner.cpp:250
mrpt::slam::CIncrementalMapPartitioner::setSimilarityMethod
void setSimilarityMethod(similarity_func_t func)
Sets a custom function for the similarity of new keyframes.
Definition: CIncrementalMapPartitioner.h:171
mrpt::poses::CPose3DPDF
Declares a class that represents a Probability Density Function (PDF) of a 3D pose (6D actually).
Definition: CPose3DPDF.h:42
mrpt::slam::CIncrementalMapPartitioner::m_A
mrpt::math::CMatrixD m_A
Adjacency matrix.
Definition: CIncrementalMapPartitioner.h:214
mrpt::slam::CIncrementalMapPartitioner::m_individualMaps
std::deque< mrpt::maps::CMultiMetricMap::Ptr > m_individualMaps
Definition: CIncrementalMapPartitioner.h:211
mrpt::slam::CIncrementalMapPartitioner::clear
void clear()
Definition: CIncrementalMapPartitioner.cpp:102
mrpt::maps::TMatchingRatioParams
Parameters for CMetricMap::compute3DMatchingRatio()
Definition: metric_map_types.h:75
mrpt::slam::CIncrementalMapPartitioner::getSequenceOfFrames
mrpt::maps::CSimpleMap * getSequenceOfFrames()
Access to the sequence of Sensory Frames.
Definition: CIncrementalMapPartitioner.h:203
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
uint8_t
unsigned char uint8_t
Definition: rptypes.h:41
MRPT_ENUM_TYPE_BEGIN
#define MRPT_ENUM_TYPE_BEGIN(_ENUM_TYPE_WITH_NS)
Definition: TEnumType.h:58
mrpt::slam::smMETRIC_MAP_MATCHING
@ smMETRIC_MAP_MATCHING
Definition: CIncrementalMapPartitioner.h:32
source
GLsizei GLsizei GLchar * source
Definition: glext.h:4082
mrpt::slam::CIncrementalMapPartitioner::options
TOptions options
Algorithm parameters.
Definition: CIncrementalMapPartitioner.h:119
mrpt::maps::TSetOfMetricMapInitializers
A set of TMetricMapInitializer structures, passed to the constructor CMultiMetricMap::CMultiMetricMap...
Definition: TMetricMapInitializer.h:91
mrpt::slam::CIncrementalMapPartitioner::getSequenceOfFrames
const mrpt::maps::CSimpleMap * getSequenceOfFrames() const
Read-only access to the sequence of Sensory Frames.
Definition: CIncrementalMapPartitioner.h:197
mrpt::math::CMatrixTemplateNumeric< double >
mrpt::slam::CIncrementalMapPartitioner::TOptions::metricmap
mrpt::maps::TSetOfMetricMapInitializers metricmap
Type and parameters of metric map(s) to build for each keyframe.
Definition: CIncrementalMapPartitioner.h:105
mrpt::slam::CIncrementalMapPartitioner::TOptions::partitionThreshold
double partitionThreshold
!< N-cut partition threshold [0,2] (default=1)
Definition: CIncrementalMapPartitioner.h:80
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::slam::CIncrementalMapPartitioner::getAdjacencyMatrix
const mrpt::math::CMatrixDouble & getAdjacencyMatrix() const
Return a const ref to the internal adjacency matrix.
Definition: CIncrementalMapPartitioner.h:194
COutputLogger.h
mrpt::config::CConfigFileBase
This class allows loading and storing values and vectors of different types from a configuration text...
Definition: config/CConfigFileBase.h:44
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
mrpt::slam::map_keyframe_t::raw_observations
mrpt::obs::CSensoryFrame::Ptr raw_observations
Definition: CIncrementalMapPartitioner.h:44
TEnumType.h
uint64_t
unsigned __int64 uint64_t
Definition: rptypes.h:50
mrpt::slam::map_keyframe_t
Map keyframe, comprising raw observations and they as a metric map.
Definition: CIncrementalMapPartitioner.h:40
mrpt::config::CLoadableOptions
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...
Definition: config/CLoadableOptions.h:28
mrpt::serialization::CSerializable
The virtual base class which provides a unified interface for all persistent objects in MRPT.
Definition: CSerializable.h:32
mrpt::slam::CIncrementalMapPartitioner::m_last_last_partition_are_new_ones
bool m_last_last_partition_are_new_ones
This will be true after adding new observations, and before an "updatePartitions" is invoked.
Definition: CIncrementalMapPartitioner.h:221
mrpt::slam::CIncrementalMapPartitioner::TOptions::minimumNumberElementsEachCluster
uint64_t minimumNumberElementsEachCluster
If a partition leads to a cluster with less elements than this, it will be rejected even if had a goo...
Definition: CIncrementalMapPartitioner.h:99
mrpt::maps::CMultiMetricMap::Ptr
std::shared_ptr< CMultiMetricMap > Ptr
Definition: CMultiMetricMap.h:143
mrpt::opengl::CSetOfObjects::Ptr
std::shared_ptr< CSetOfObjects > Ptr
Definition: CSetOfObjects.h:30
mrpt::slam::map_keyframe_t::kf_id
uint32_t kf_id
Definition: CIncrementalMapPartitioner.h:42
mrpt::slam::CIncrementalMapPartitioner::changeCoordinatesOrigin
void changeCoordinatesOrigin(const mrpt::poses::CPose3D &newOrigin)
Definition: CIncrementalMapPartitioner.cpp:329
mrpt::system::COutputLogger
Versatile class for consistent logging and management of output messages.
Definition: system/COutputLogger.h:117
mrpt::slam::CIncrementalMapPartitioner::getNodesCount
size_t getNodesCount()
Get the total node count currently in the internal map/graph.
Definition: CIncrementalMapPartitioner.cpp:245
mrpt::slam::CIncrementalMapPartitioner::TOptions::loadFromConfigFile
void loadFromConfigFile(const mrpt::config::CConfigFileBase &source, const std::string &section) override
This method load the options from a ".ini"-like file or memory-stored string list.
Definition: CIncrementalMapPartitioner.cpp:61
mrpt::slam::CIncrementalMapPartitioner
Finds partitions in metric maps based on N-cut graph partition theory.
Definition: CIncrementalMapPartitioner.h:60
CLoadableOptions.h
poses_frwds.h
mrpt::slam::CIncrementalMapPartitioner::TOptions::simil_method
similarity_method_t simil_method
Defines the method for determining the adjacency matrix values.
Definition: CIncrementalMapPartitioner.h:94
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:102
mrpt::slam::CIncrementalMapPartitioner::addMapFrame
uint32_t addMapFrame(const mrpt::obs::CSensoryFrame &frame, const mrpt::poses::CPose3DPDF &robotPose3D)
Insert a new keyframe to the graph.
Definition: CIncrementalMapPartitioner.cpp:111
mrpt::slam::CIncrementalMapPartitioner::TOptions::TOptions
TOptions()
Definition: CIncrementalMapPartitioner.cpp:55
mrpt::slam::CIncrementalMapPartitioner::TOptions::maxKeyFrameDistanceToEval
uint64_t maxKeyFrameDistanceToEval
Maximum distance, in KF identifier numbers, to check for similarity.
Definition: CIncrementalMapPartitioner.h:110
mrpt::slam::CIncrementalMapPartitioner::m_last_partition
std::vector< std::vector< uint32_t > > m_last_partition
The last partition.
Definition: CIncrementalMapPartitioner.h:217
mrpt::maps::CSimpleMap
This class stores a sequence of <Probabilistic Pose,SensoryFrame> pairs, thus a "metric map" can be t...
Definition: CSimpleMap.h:35
mrpt::slam::CIncrementalMapPartitioner::CIncrementalMapPartitioner
CIncrementalMapPartitioner()
ctor
Definition: CIncrementalMapPartitioner.h:68
mrpt::math::CMatrixD
This class is a "CSerializable" wrapper for "CMatrixTemplateNumeric<double>".
Definition: CMatrixD.h:24
string
GLsizei const GLchar ** string
Definition: glext.h:4101
MRPT_FILL_ENUM_MEMBER
MRPT_FILL_ENUM_MEMBER(mrpt::slam, smMETRIC_MAP_MATCHING)
CSimpleMap.h
CSimplePointsMap.h
mrpt::slam::CIncrementalMapPartitioner::m_sim_func
similarity_func_t m_sim_func
Definition: CIncrementalMapPartitioner.h:223
mrpt::slam
Definition: CMultiMetricMapPDF.h:27
mrpt::slam::similarity_method_t
similarity_method_t
For use in CIncrementalMapPartitioner.
Definition: CIncrementalMapPartitioner.h:30
mrpt::slam::CIncrementalMapPartitioner::changeCoordinatesOriginPoseIndex
void changeCoordinatesOriginPoseIndex(unsigned int newOriginPose)
The new origin is given by the index of the pose that is to become the new origin.
Definition: CIncrementalMapPartitioner.cpp:335
uint32_t
unsigned __int32 uint32_t
Definition: rptypes.h:47
mrpt::slam::CIncrementalMapPartitioner::getAdjacencyMatrix
void getAdjacencyMatrix(MATRIX &outMatrix) const
Return a copy of the adjacency matrix.
Definition: CIncrementalMapPartitioner.h:188
mrpt::system::COutputLogger::COutputLogger
COutputLogger()
Default class constructor.
Definition: COutputLogger.cpp:59
mrpt::slam::similarity_func_t
std::function< double(const map_keyframe_t &kf1, const map_keyframe_t &kf2, const mrpt::poses::CPose3D &relPose2wrt1)> similarity_func_t
Type of similarity evaluator for map keyframes.
Definition: CIncrementalMapPartitioner.h:55
mrpt::slam::map_keyframe_t::metric_map
mrpt::maps::CMultiMetricMap::Ptr metric_map
Definition: CIncrementalMapPartitioner.h:43



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