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
mrpt::maps::CSimpleMap::TPosePDFSensFramePair
std::pair< mrpt::poses::CPose3DPDF::Ptr, mrpt::obs::CSensoryFrame::Ptr > TPosePDFSensFramePair
Definition: CSimpleMap.h:179
mrpt::maps::CSimpleMap::empty
bool empty() const
Returns size()!=0.
Definition: CSimpleMap.cpp:54
const_iterator
const Scalar * const_iterator
Definition: eigen_plugins.h:27
mrpt::obs::CSensoryFrame::Ptr
std::shared_ptr< CSensoryFrame > Ptr
Definition: CSensoryFrame.h:56
mrpt::maps::CSimpleMap::rend
const_reverse_iterator rend() const
Definition: CSimpleMap.h:196
mrpt::poses::CPose3DPDF
Declares a class that represents a Probability Density Function (PDF) of a 3D pose (6D actually).
Definition: CPose3DPDF.h:42
mrpt::maps::CSimpleMap::rbegin
const_reverse_iterator rbegin() const
Definition: CSimpleMap.h:192
mrpt::maps::CSimpleMap::reverse_iterator
TPosePDFSensFramePairList::reverse_iterator reverse_iterator
Definition: CSimpleMap.h:184
mrpt::maps::CSimpleMap::operator=
CSimpleMap & operator=(const CSimpleMap &o)
Copy.
Definition: CSimpleMap.cpp:40
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::maps::CSimpleMap::iterator
TPosePDFSensFramePairList::iterator iterator
Definition: CSimpleMap.h:183
mrpt::maps::CSimpleMap::loadFromFile
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
mrpt::maps::CSimpleMap::begin
iterator begin()
Definition: CSimpleMap.h:190
mrpt::maps::CSimpleMap::end
const_iterator end() const
Definition: CSimpleMap.h:189
mrpt::maps::CSimpleMap::begin
const_iterator begin() const
Definition: CSimpleMap.h:188
mrpt::obs::CSensoryFrame
Declares a class for storing a "sensory frame", a set of "observations" taken by the robot approximat...
Definition: CSensoryFrame.h:54
mrpt::maps::CSimpleMap::const_iterator
TPosePDFSensFramePairList::const_iterator const_iterator
Definition: CSimpleMap.h:182
CPosePDF.h
mrpt::maps::CSimpleMap::const_reverse_iterator
TPosePDFSensFramePairList::const_reverse_iterator const_reverse_iterator
Definition: CSimpleMap.h:186
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
index
GLuint index
Definition: glext.h:4054
mrpt::maps::CSimpleMap::size
size_t size() const
Returns the count of pairs (pose,sensory data)
Definition: CSimpleMap.cpp:53
mrpt::maps::CSimpleMap::set
void set(size_t index, const mrpt::poses::CPose3DPDF::Ptr &in_posePDF, const mrpt::obs::CSensoryFrame::Ptr &in_SF)
Changes the i'th pair, first one is index '0'.
Definition: CSimpleMap.cpp:73
mrpt::serialization::CSerializable
The virtual base class which provides a unified interface for all persistent objects in MRPT.
Definition: CSerializable.h:32
mrpt::maps::CSimpleMap::get
void get(size_t index, mrpt::poses::CPose3DPDF::Ptr &out_posePDF, mrpt::obs::CSensoryFrame::Ptr &out_SF) const
Access to the i'th pair, first one is index '0'.
Definition: CSimpleMap.cpp:56
obs_frwds.h
mrpt::maps::CSimpleMap::TPosePDFSensFramePairList
std::deque< TPosePDFSensFramePair > TPosePDFSensFramePairList
Definition: CSimpleMap.h:180
CSensoryFrame.h
mrpt::poses::CPosePDF
Declares a class that represents a probability density function (pdf) of a 2D pose (x,...
Definition: CPosePDF.h:41
mrpt::maps::CSimpleMap::rbegin
reverse_iterator rbegin()
Definition: CSimpleMap.h:200
mrpt::maps::CSimpleMap::CSimpleMap
CSimpleMap()=default
Default constructor (empty map)
mrpt::maps::CSimpleMap::insertToPos
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's not made unique) to.
Definition: CSimpleMap.cpp:195
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:102
mrpt::maps::CSimpleMap
This class stores a sequence of <Probabilistic Pose,SensoryFrame> pairs, thus a "metric map" can be t...
Definition: CSimpleMap.h:35
mrpt::poses::CPose3DPDF::Ptr
std::shared_ptr< CPose3DPDF > Ptr
Definition: CPose3DPDF.h:45
CPose3DPDF.h
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::maps::CSimpleMap::insert
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
iterator
Scalar * iterator
Definition: eigen_plugins.h:26
mrpt::maps::CSimpleMap::m_posesObsPairs
TPosePDFSensFramePairList m_posesObsPairs
The stored data.
Definition: CSimpleMap.h:206
mrpt::maps::CSimpleMap::changeCoordinatesOrigin
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
CSerializable.h
mrpt::maps::CSimpleMap::clear
void clear()
Remove all stored pairs.
Definition: CSimpleMap.cpp:55
mrpt::poses::CPosePDF::Ptr
std::shared_ptr< CPosePDF > Ptr
Definition: CPosePDF.h:44
mrpt::maps::CSimpleMap::saveToFile
bool saveToFile(const std::string &filName) const
Save this object to a .simplemap binary file (compressed with gzip)
Definition: CSimpleMap.cpp:271
mrpt::maps::CSimpleMap::rend
reverse_iterator rend()
Definition: CSimpleMap.h:201
mrpt::maps::CSimpleMap::end
iterator end()
Definition: CSimpleMap.h:191
mrpt::maps::CSimpleMap::remove
void remove(size_t index)
Deletes the i'th pair, first one is index '0'.
Definition: CSimpleMap.cpp:65



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST