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-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 #ifndef CINCREMENTALMAPPARTITIONER_H
11 #define CINCREMENTALMAPPARTITIONER_H
12 
17 #include <mrpt/maps/CSimpleMap.h>
19 #include <mrpt/poses/poses_frwds.h>
20 
21 namespace mrpt
22 {
23 namespace slam
24 {
25 /** This class can be used to make partitions on a map/graph build from
26  * observations taken at some poses/nodes.
27  * \ingroup mrpt_slam_grp
28  */
29 class CIncrementalMapPartitioner : public mrpt::utils::COutputLogger,
31 {
32  // This must be added to any CSerializable derived class:
34 
35  public:
36  /** ctor */
38  /** dtor */
40 
41  /*\brief Initialization: Start of a new map, new internal matrices,...
42  */
43  void clear();
44 
45  /** Configuration of the algorithm:
46  */
48  {
49  /*\brief Sets default values at object creation
50  */
51  TOptions();
52 
53  void loadFromConfigFile(
55  const std::string& section) override; // See base docs
56  void dumpToTextStream(
57  mrpt::utils::CStream& out) const override; // See base docs
58 
59  /**\brief The partition threshold for bisection in range [0,2],
60  * default=1.0
61  *
62  */
64 
65  /*\brief For the occupancy grid maps of each node, default=0.10
66  *
67  */
69 
70  /*\brief Used in the computation of weights, default=0.20
71  *
72  */
74 
75  /*\brief Used in the computation of weights, default=2.0
76  *
77  */
79 
80  /*\brief If set to true (default), 1 or 2 clusters will be returned.
81  * Default=false -> Autodetermine the number of partitions.
82  */
84 
85  /** If set to true (default), adjacency matrix is computed from maps
86  * matching; otherwise, the method CObservation::likelihoodWith will be
87  * called directly from the SFs.
88  */
90 
91  /** If a partition leads to a cluster with less elements than this, it
92  * will be rejected even if had a good Ncut (default=1).
93  */
95 
96  } options;
97 
98  /**\name Add to the Map Frames
99  * \brief Add a new frame to the current graph
100  *
101  * Call this method each time a new observation is added to the map/graph,
102  * and whenever you want to update the partitions, call "updatePartitions"
103  *
104  * \param frame The sensed data
105  * \param robotPose*D An estimation of the robot global *D pose.
106  *
107  * \return { The index of the new pose in the internal list, which will be
108  * used to refer to the pose in the future. }
109  *
110  * \sa updatePartitions
111  */
112  /**\{*/
113  unsigned int addMapFrame(
114  const mrpt::obs::CSensoryFrame::Ptr& frame,
115  const mrpt::poses::CPosePDF::Ptr& robotPose2D);
116  unsigned int addMapFrame(
117  const mrpt::obs::CSensoryFrame::Ptr& frame,
118  const mrpt::poses::CPose3DPDF::Ptr& robotPose3D);
119  unsigned int addMapFrame(
120  const mrpt::obs::CSensoryFrame& frame,
121  const mrpt::poses::CPose3DPDF& robotPose3D);
122  /**\}*/
123 
124  /**\brief This method executed only the neccesary part of the partition to
125  * take into account the lastest added frames.
126  *
127  * \sa addMapFrame
128  */
129  void updatePartitions(std::vector<vector_uint>& partitions);
130 
131  /**\brief Get the total node count currently in the internal map/graph.
132  *
133  */
134  unsigned int getNodesCount();
135 
136  /**\brief Remove the stated nodes (0-based indexes) from the internal
137  * lists.
138  *
139  * If changeCoordsRef is true, coordinates are changed to leave the first
140  * node at (0,0,0).
141  */
142  void removeSetOfNodes(
143  vector_uint indexesToRemove, bool changeCoordsRef = true);
144 
145  /**\brief Return a copy of the internal adjacency matrix. */
146  template <class MATRIX>
147  void getAdjacencyMatrix(MATRIX& outMatrix) const
148  {
149  outMatrix = m_A;
150  }
151 
152  /**\brief Return a const ref to the internal adjacency matrix. */
154  /**\brief Read-only access to the sequence of Sensory Frames
155  *
156  */
158  {
159  return &m_individualFrames;
160  }
161 
162  /** Access to the sequence of Sensory Frames
163  *
164  */
166  {
167  return &m_individualFrames;
168  }
169 
170  /** Mark all nodes for reconsideration in the next call to
171  * "updatePartitions", instead of considering just those affected by
172  * aditions of new arcs.
173  */
175  /**\name Change Coordinates System
176  * \brief Change the coordinate origin of all stored poses
177  *
178  * Used for consistency with future new poses to enter in the system.
179  */
180  /**\{*/
181  void changeCoordinatesOrigin(const mrpt::poses::CPose3D& newOrigin);
182  /**\brief The new origin is given by the index of the pose that is to
183  * become the new origin.
184  */
185  void changeCoordinatesOriginPoseIndex(const unsigned& newOriginPose);
186  /**\}*/
187 
188  /**\brief Return a 3D representation of the current state: poses & links
189  * between them.
190  *
191  * The previous contents of "objs" will be discarded
192  */
193  void getAs3DScene(
195  const std::map<uint32_t, int64_t>* renameIndexes = NULL) const;
196 
197  private:
199  std::deque<mrpt::maps::CMultiMetricMap> m_individualMaps;
200 
201  /** Adjacency matrix */
203 
204  /** The last partition */
205  std::vector<vector_uint> m_last_partition;
206 
207  /** This will be true after adding new observations, and before an
208  * "updatePartitions" is invoked. */
210 
211  /** The list of keyframes to consider in the next update */
212  std::vector<uint8_t> m_modified_nodes;
213 
214 }; // End of class def.
215 }
216 } // End of namespace
217 
218 #endif
void getAdjacencyMatrix(MATRIX &outMatrix) const
Return a copy of the internal adjacency matrix.
float partitionThreshold
The partition threshold for bisection in range [0,2], default=1.0.
std::deque< mrpt::maps::CMultiMetricMap > m_individualMaps
This class is a "CSerializable" wrapper for "CMatrixTemplateNumeric<double>".
Definition: CMatrixD.h:25
std::vector< uint32_t > vector_uint
Definition: types_simple.h:29
mrpt::math::CMatrixD m_A
Adjacency matrix.
unsigned int getNodesCount()
Get the total node count currently in the internal map/graph.
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
void markAllNodesForReconsideration()
Mark all nodes for reconsideration in the next call to "updatePartitions", instead of considering jus...
bool useMapMatching
If set to true (default), adjacency matrix is computed from maps matching; otherwise, the method CObservation::likelihoodWith will be called directly from the SFs.
void updatePartitions(std::vector< vector_uint > &partitions)
This method executed only the neccesary part of the partition to take into account the lastest added ...
void removeSetOfNodes(vector_uint indexesToRemove, bool changeCoordsRef=true)
Remove the stated nodes (0-based indexes) from the internal lists.
void changeCoordinatesOrigin(const mrpt::poses::CPose3D &newOrigin)
This class allows loading and storing values and vectors of different types from a configuration text...
mrpt::maps::CSimpleMap * getSequenceOfFrames()
Access to the sequence of Sensory Frames.
void changeCoordinatesOriginPoseIndex(const unsigned &newOriginPose)
The new origin is given by the index of the pose that is to become the new origin.
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 base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
std::shared_ptr< CPosePDF > Ptr
Definition: CPosePDF.h:44
const mrpt::math::CMatrixDouble & getAdjacencyMatrix() const
Return a const ref to the internal adjacency matrix.
std::shared_ptr< CPose3DPDF > Ptr
Definition: CPose3DPDF.h:45
std::shared_ptr< CSetOfObjects > Ptr
Definition: CSetOfObjects.h:32
Declares a class for storing a "sensory frame", a set of "observations" taken by the robot approximat...
Definition: CSensoryFrame.h:54
mrpt::slam::CIncrementalMapPartitioner::TOptions options
std::shared_ptr< CSensoryFrame > Ptr
Definition: CSensoryFrame.h:56
void getAs3DScene(mrpt::opengl::CSetOfObjects::Ptr &objs, const std::map< uint32_t, int64_t > *renameIndexes=NULL) const
Return a 3D representation of the current state: poses & links between them.
GLsizei const GLchar ** string
Definition: glext.h:4101
std::vector< vector_uint > m_last_partition
The last partition.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
This class can be used to make partitions on a map/graph build from observations taken at some poses/...
int minimumNumberElementsEachCluster
If a partition leads to a cluster with less elements than this, it will be rejected even if had a goo...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
bool m_last_last_partition_are_new_ones
This will be true after adding new observations, and before an "updatePartitions" is invoked...
GLsizei GLsizei GLchar * source
Definition: glext.h:4082
unsigned int addMapFrame(const mrpt::obs::CSensoryFrame::Ptr &frame, const mrpt::poses::CPosePDF::Ptr &robotPose2D)
Declares a class that represents a Probability Density Function (PDF) of a 3D pose (6D actually)...
Definition: CPose3DPDF.h:42
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...
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.
const mrpt::maps::CSimpleMap * getSequenceOfFrames() const
Read-only access to the sequence of Sensory Frames.
std::vector< uint8_t > m_modified_nodes
The list of keyframes to consider in the next update.



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