Main MRPT website > C++ reference for MRPT 1.9.9
CSimpleMap.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 #ifndef CSimpleMap_H
10 #define CSimpleMap_H
11 
13 #include <mrpt/obs/CSensoryFrame.h>
14 #include <mrpt/poses/CPosePDF.h>
15 #include <mrpt/poses/CPose3DPDF.h>
16 #include <mrpt/obs/obs_frwds.h>
17 
18 namespace mrpt
19 {
20 namespace maps
21 {
22 /** This class stores a sequence of <Probabilistic Pose,SensoryFrame> pairs,
23  * thus a "metric map" can be totally determined with this information.
24  * The pose of the sensory frame is not deterministic, but described by some
25  * PDF. Full 6D poses are used.
26  *
27  * \note Objects of this class are serialized into (possibly GZ-compressed)
28  * files with the extension ".simplemap".
29  *
30  * \note Before MRPT 0.9.0 the name of this class was "CSensFrameProbSequence",
31  * that's why there is a type with that name to allow backward compatibility.
32  * \sa CSensoryFrame, CPosePDF
33  * \ingroup mrpt_obs_grp
34  */
36 {
38  public:
39  /** Default constructor (empty map) */
40  CSimpleMap() = default;
41  /** Copy constructor */
42  CSimpleMap(const CSimpleMap& o);
43  /** Copy */
44  CSimpleMap& operator=(const CSimpleMap& o);
45 
46  /** \name Map access and modification
47  * @{ */
48 
49  /** Save this object to a .simplemap binary file (compressed with gzip)
50  * \sa loadFromFile
51  * \return false on any error. */
52  bool saveToFile(const std::string& filName) const;
53 
54  /** Load the contents of this object from a .simplemap binary file (possibly
55  * compressed with gzip)
56  * \sa saveToFile
57  * \return false on any error. */
58  bool loadFromFile(const std::string& filName);
59 
60  /** Returns the count of pairs (pose,sensory data) */
61  size_t size() const;
62  /** Returns size()!=0 */
63  bool empty() const;
64 
65  /** Access to the i'th pair, first one is index '0'. NOTE: This method
66  * returns pointers to the objects inside the list, nor a copy of them,
67  * so <b>do neither modify them nor delete them</b>.
68  * NOTE: You can pass a nullptr pointer if you dont need one of the two
69  * variables to be returned.
70  * \exception std::exception On index out of bounds.
71  */
72  void get(
73  size_t index, mrpt::poses::CPose3DPDF::Ptr& out_posePDF,
74  mrpt::obs::CSensoryFrame::Ptr& out_SF) const;
75 
76  /** Changes the i'th pair, first one is index '0'.
77  * The referenced object is COPIED, so you can freely destroy the object
78  * passed as parameter after calling this.
79  * If one of the pointers is nullptr, the corresponding contents of the
80  * current i'th pair is not modified (i.e. if you want just to modify one of
81  * the values).
82  * \exception std::exception On index out of bounds.
83  * \sa insert, get, remove
84  */
85  void set(
86  size_t index, const mrpt::poses::CPose3DPDF::Ptr& in_posePDF,
87  const mrpt::obs::CSensoryFrame::Ptr& in_SF);
88 
89  /** Changes the i'th pair, first one is index '0'.
90  * The referenced object is COPIED, so you can freely destroy the object
91  * passed as parameter after calling this.
92  * If one of the pointers is nullptr, the corresponding contents of the
93  * current i'th pair is not modified (i.e. if you want just to modify one of
94  * the values).
95  * This version for 2D PDFs just converts the 2D PDF into 3D before calling
96  * the 3D version.
97  * \exception std::exception On index out of bounds.
98  * \sa insert, get, remove
99  */
100  void set(
101  size_t index, const mrpt::poses::CPosePDF::Ptr& in_posePDF,
102  const mrpt::obs::CSensoryFrame::Ptr& in_SF);
103 
104  /** Deletes the i'th pair, first one is index '0'.
105  * \exception std::exception On index out of bounds.
106  * \sa insert, get, set
107  */
108  void remove(size_t index);
109 
110  /** Add a new pair to the sequence. The objects are copied, so original ones
111  * can be free if desired after insertion. */
112  void insert(
113  const mrpt::poses::CPose3DPDF* in_posePDF,
114  const mrpt::obs::CSensoryFrame& in_SF);
115 
116  /** Add a new pair to the sequence, making a copy of the smart pointer (it's
117  * not made unique). */
118  void insert(
119  const mrpt::poses::CPose3DPDF* in_posePDF,
120  const mrpt::obs::CSensoryFrame::Ptr& in_SF);
121 
122  /** Add a new pair to the sequence, making a copy of the smart pointer (it's
123  * not made unique). */
124  void insert(
125  const mrpt::poses::CPose3DPDF::Ptr& in_posePDF,
126  const mrpt::obs::CSensoryFrame::Ptr& in_SF);
127 
128  /** Insert a new pair to the sequence, making a copy of the smart pointer
129  (it's
130  * not made unique) to
131  \param index Position in the simplemap where new element will be inserted to
132  */
133  void insertToPos(
134  size_t index, const mrpt::poses::CPose3DPDF::Ptr& in_posePDF,
135  const mrpt::obs::CSensoryFrame::Ptr& in_SF);
136 
137  /** Add a new pair to the sequence. The objects are copied, so original ones
138  * can be free if desired
139  * after insertion.
140  * This version for 2D PDFs just converts the 2D PDF into 3D before calling
141  * the 3D version.
142  */
143  void insert(
144  const mrpt::poses::CPosePDF::Ptr& in_posePDF,
145  const mrpt::obs::CSensoryFrame::Ptr& in_SF);
146 
147  /** Add a new pair to the sequence. The objects are copied, so original ones
148  * can be free if desired
149  * after insertion.
150  * This version for 2D PDFs just converts the 2D PDF into 3D before calling
151  * the 3D version.
152  */
153  void insert(
154  const mrpt::poses::CPosePDF* in_posePDF,
155  const mrpt::obs::CSensoryFrame& in_SF);
156 
157  /** Add a new pair to the sequence. The objects are copied, so original ones
158  * can be free if desired
159  * after insertion.
160  * This version for 2D PDFs just converts the 2D PDF into 3D before calling
161  * the 3D version.
162  */
163  void insert(
164  const mrpt::poses::CPosePDF* in_posePDF,
165  const mrpt::obs::CSensoryFrame::Ptr& in_SF);
166 
167  /** Remove all stored pairs. \sa remove */
168  void clear();
169 
170  /** Change the coordinate origin of all stored poses, for consistency with
171  * future new poses to enter in the system. */
172  void changeCoordinatesOrigin(const mrpt::poses::CPose3D& newOrigin);
173 
174  /** @} */
175 
176  /** \name Iterators API
177  * @{ */
178  using TPosePDFSensFramePair =
179  std::pair<mrpt::poses::CPose3DPDF::Ptr, mrpt::obs::CSensoryFrame::Ptr>;
180  using TPosePDFSensFramePairList = std::deque<TPosePDFSensFramePair>;
181 
184  using reverse_iterator = TPosePDFSensFramePairList::reverse_iterator;
185  using const_reverse_iterator =
186  TPosePDFSensFramePairList::const_reverse_iterator;
187 
188  inline const_iterator begin() const { return m_posesObsPairs.begin(); }
189  inline const_iterator end() const { return m_posesObsPairs.end(); }
190  inline iterator begin() { return m_posesObsPairs.begin(); }
191  inline iterator end() { return m_posesObsPairs.end(); }
193  {
194  return m_posesObsPairs.rbegin();
195  }
197  {
198  return m_posesObsPairs.rend();
199  }
200  inline reverse_iterator rbegin() { return m_posesObsPairs.rbegin(); }
201  inline reverse_iterator rend() { return m_posesObsPairs.rend(); }
202  /** @} */
203 
204  private:
205  /** The stored data */
207 
208 }; // End of class def.
209 
210 } // namespace maps
211 } // namespace mrpt
212 #endif
Scalar * iterator
Definition: eigen_plugins.h:26
std::pair< mrpt::poses::CPose3DPDF::Ptr, mrpt::obs::CSensoryFrame::Ptr > TPosePDFSensFramePair
Definition: CSimpleMap.h:179
bool empty() const
Returns size()!=0.
Definition: CSimpleMap.cpp:54
const_reverse_iterator rend() const
Definition: CSimpleMap.h:196
This class stores a sequence of <Probabilistic Pose,SensoryFrame> pairs, thus a "metric map" can be t...
Definition: CSimpleMap.h:35
const_reverse_iterator rbegin() const
Definition: CSimpleMap.h:192
TPosePDFSensFramePairList::iterator iterator
Definition: CSimpleMap.h:183
CSimpleMap & operator=(const CSimpleMap &o)
Copy.
Definition: CSimpleMap.cpp:40
bool loadFromFile(const std::string &filName)
Load the contents of this object from a .simplemap binary file (possibly compressed with gzip) ...
Definition: CSimpleMap.cpp:290
TPosePDFSensFramePairList::reverse_iterator reverse_iterator
Definition: CSimpleMap.h:184
const_iterator begin() const
Definition: CSimpleMap.h:188
GLuint index
Definition: glext.h:4054
const_iterator end() const
Definition: CSimpleMap.h:189
TPosePDFSensFramePairList::const_iterator const_iterator
Definition: CSimpleMap.h:182
TPosePDFSensFramePairList::const_reverse_iterator const_reverse_iterator
Definition: CSimpleMap.h:186
Declares a class for storing a "sensory frame", a set of "observations" taken by the robot approximat...
Definition: CSensoryFrame.h:54
size_t size() const
Returns the count of pairs (pose,sensory data)
Definition: CSimpleMap.cpp:53
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
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...
std::deque< TPosePDFSensFramePair > TPosePDFSensFramePairList
Definition: CSimpleMap.h:180
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
reverse_iterator rbegin()
Definition: CSimpleMap.h:200
void insertToPos(size_t index, const mrpt::poses::CPose3DPDF::Ptr &in_posePDF, const mrpt::obs::CSensoryFrame::Ptr &in_SF)
Insert a new pair to the sequence, making a copy of the smart pointer (it&#39;s not made unique) to...
Definition: CSimpleMap.cpp:195
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:32
CSimpleMap()=default
Default constructor (empty map)
void insert(const mrpt::poses::CPose3DPDF *in_posePDF, const mrpt::obs::CSensoryFrame &in_SF)
Add a new pair to the sequence.
Definition: CSimpleMap.cpp:136
void changeCoordinatesOrigin(const mrpt::poses::CPose3D &newOrigin)
Change the coordinate origin of all stored poses, for consistency with future new poses to enter in t...
Definition: CSimpleMap.cpp:260
const Scalar * const_iterator
Definition: eigen_plugins.h:27
TPosePDFSensFramePairList m_posesObsPairs
The stored data.
Definition: CSimpleMap.h:206
Declares a class that represents a Probability Density Function (PDF) of a 3D pose (6D actually)...
Definition: CPose3DPDF.h:42
reverse_iterator rend()
Definition: CSimpleMap.h:201
bool saveToFile(const std::string &filName) const
Save this object to a .simplemap binary file (compressed with gzip)
Definition: CSimpleMap.cpp:271
void clear()
Remove all stored pairs.
Definition: CSimpleMap.cpp:55



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019