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



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