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



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020