Main MRPT website > C++ reference for MRPT 1.5.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 #include <mrpt/slam/link_pragmas.h>
22 
23 namespace mrpt { namespace slam {
25 
26  /** This class can be used to make partitions on a map/graph build from
27  * observations taken at some poses/nodes.
28  * \ingroup mrpt_slam_grp
29  */
31  public mrpt::utils::COutputLogger,
32  public mrpt::utils::CSerializable
33  {
34  // This must be added to any CSerializable derived class:
36 
37  public:
38  CIncrementalMapPartitioner(); //!< ctor
39  virtual ~CIncrementalMapPartitioner(); //!< 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) MRPT_OVERRIDE; // See base docs
56  void dumpToTextStream(mrpt::utils::CStream &out) const MRPT_OVERRIDE; // See base docs
57 
58  /**\brief The partition threshold for bisection in range [0,2], default=1.0
59  *
60  */
62 
63  /*\brief For the occupancy grid maps of each node, default=0.10
64  *
65  */
67 
68  /*\brief Used in the computation of weights, default=0.20
69  *
70  */
72 
73  /*\brief Used in the computation of weights, default=2.0
74  *
75  */
77 
78  /*\brief If set to true (default), 1 or 2 clusters will be returned.
79  * Default=false -> Autodetermine the number of partitions.
80  */
82 
83  /** If set to true (default), adjacency matrix is computed from maps
84  * matching; otherwise, the method CObservation::likelihoodWith will be
85  * called directly from the SFs.
86  */
88 
89  /** If a partition leads to a cluster with less elements than this, it
90  * will be rejected even if had a good Ncut (default=1).
91  */
93 
94  } options;
95 
96  /**\name Add to the Map Frames
97  * \brief Add a new frame to the current graph
98  *
99  * Call this method each time a new observation is added to the map/graph,
100  * and whenever you want to update the partitions, call "updatePartitions"
101  *
102  * \param frame The sensed data
103  * \param robotPose*D An estimation of the robot global *D pose.
104  *
105  * \return { The index of the new pose in the internal list, which will be
106  * used to refer to the pose in the future. }
107  *
108  * \sa updatePartitions
109  */
110  /**\{*/
111  unsigned int addMapFrame(
112  const mrpt::obs::CSensoryFramePtr &frame,
113  const mrpt::poses::CPosePDFPtr &robotPose2D);
114  unsigned int addMapFrame(
115  const mrpt::obs::CSensoryFramePtr &frame,
116  const mrpt::poses::CPose3DPDFPtr &robotPose3D);
117  unsigned int addMapFrame(
118  const mrpt::obs::CSensoryFrame &frame,
119  const mrpt::poses::CPose3DPDF &robotPose3D);
120  /**\}*/
121 
122  /**\brief This method executed only the neccesary part of the partition to
123  * take into account the lastest added frames.
124  *
125  * \sa addMapFrame
126  */
127  void updatePartitions(std::vector<vector_uint> &partitions);
128 
129  /**\brief Get the total node count currently in the internal map/graph.
130  *
131  */
132  unsigned int getNodesCount();
133 
134  /**\brief Remove the stated nodes (0-based indexes) from the internal
135  * lists.
136  *
137  * If changeCoordsRef is true, coordinates are changed to leave the first
138  * node at (0,0,0).
139  */
140  void removeSetOfNodes(vector_uint indexesToRemove, bool changeCoordsRef=true);
141 
142  /**\brief Return a copy of the internal adjacency matrix. */
143  template <class MATRIX>
144  void getAdjacencyMatrix(MATRIX &outMatrix) const { outMatrix = m_A; }
145 
146  /**\brief Return a const ref to the internal adjacency matrix. */
147  const mrpt::math::CMatrixDouble& getAdjacencyMatrix() const { return m_A; }
148 
149  /**\brief Read-only access to the sequence of Sensory Frames
150  *
151  */
153  return &m_individualFrames;
154  }
155 
156  /** Access to the sequence of Sensory Frames
157  *
158  */
160  {
161  return &m_individualFrames;
162  }
163 
164  /** Mark all nodes for reconsideration in the next call to
165  * "updatePartitions", instead of considering just those affected by
166  * aditions of new arcs.
167  */
168  void markAllNodesForReconsideration();
169  /**\name Change Coordinates System
170  * \brief Change the coordinate origin of all stored poses
171  *
172  * Used for consistency with future new poses to enter in the system.
173  */
174  /**\{*/
175  void changeCoordinatesOrigin(const mrpt::poses::CPose3D &newOrigin);
176  /**\brief The new origin is given by the index of the pose that is to
177  * become the new origin.
178  */
179  void changeCoordinatesOriginPoseIndex(const unsigned &newOriginPose);
180  /**\}*/
181 
182  /**\brief Return a 3D representation of the current state: poses & links
183  * between them.
184  *
185  * The previous contents of "objs" will be discarded
186  */
187  void getAs3DScene(
188  mrpt::opengl::CSetOfObjectsPtr &objs,
189  const std::map< uint32_t, int64_t > *renameIndexes = NULL
190  ) const;
191 
192  private:
194  std::deque<mrpt::maps::CMultiMetricMap> m_individualMaps;
195 
196  /** Adjacency matrix */
198 
199  /** The last partition */
200  std::vector<vector_uint> m_last_partition;
201 
202  /** This will be true after adding new observations, and before an
203  * "updatePartitions" is invoked. */
205 
206  /** The list of keyframes to consider in the next update */
207  std::vector<uint8_t> m_modified_nodes;
208 
209  }; // End of class def.
211 
212 
213 } } // End of namespace
214 
215 #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:30
std::vector< uint32_t > vector_uint
Definition: types_simple.h:28
mrpt::math::CMatrixD m_A
Adjacency matrix.
This class stores a sequence of <Probabilistic Pose,SensoryFrame> pairs, thus a "metric map" can be t...
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:39
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
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 clear()
Clear the contents of this container.
Definition: ts_hash_map.h:113
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.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
const mrpt::math::CMatrixDouble & getAdjacencyMatrix() const
Return a const ref to the internal adjacency matrix.
Declares a class for storing a "sensory frame", a set of "observations" taken by the robot approximat...
GLsizei const GLchar ** string
Definition: glext.h:3919
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:72
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:3908
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
Declares a class that represents a Probability Density Function (PDF) of a 3D pose (6D actually)...
Definition: CPose3DPDF.h:40
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...
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.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020