Main MRPT website > C++ reference
MRPT logo
CSimpleMap.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 #ifndef CSimpleMap_H
29 #define CSimpleMap_H
30 
33 #include <mrpt/poses/CPosePDF.h>
34 #include <mrpt/poses/CPose3DPDF.h>
35 
36 namespace mrpt
37 {
38 namespace slam
39 {
40  // This must be added to any CSerializable derived class:
42 
43  /** This class stores a sequence of <Probabilistic Pose,SensoryFrame> pairs, thus a "metric map" can be totally determined with this information.
44  * The pose of the sensory frame is not deterministic, but described by some PDF. Full 6D poses are used.
45  *
46  * \note Objects of this class are serialized into (possibly GZ-compressed) files with the extension ".simplemap".
47  *
48  * \note Before MRPT 0.9.0 the name of this class was "CSensFrameProbSequence", that's why there is a typedef with that name to allow backward compatibility.
49  * \sa CSensoryFrame, CPosePDF
50  * \ingroup mrpt_obs_grp
51  */
52  class OBS_IMPEXP CSimpleMap : public mrpt::utils::CSerializable
53  {
54  // This must be added to any CSerializable derived class:
56 
57  public:
58  /** Constructor
59  */
60  CSimpleMap();
61 
62  /** Copy constructor
63  */
64  CSimpleMap( const CSimpleMap &o );
65 
66  /** Copy constructor
67  */
68  CSimpleMap & operator = ( const CSimpleMap& o);
69 
70  /** Destructor:
71  */
72  virtual ~CSimpleMap();
73 
74  /** Save this object to a .simplemap binary file (compressed with gzip)
75  * \sa loadFromFile
76  * \return false on any error.
77  */
78  bool saveToFile(const std::string &filName) const;
79 
80  /** Load the contents of this object from a .simplemap binary file (possibly compressed with gzip)
81  * \sa saveToFile
82  * \return false on any error.
83  */
84  bool loadFromFile(const std::string &filName);
85 
86 
87  /** Returns the pairs count.
88  */
89  size_t size() const;
90 
91  /** Access to the i'th pair, first one is index '0'. NOTE: This method
92  * returns pointers to the objects inside the list, nor a copy of them,
93  * so <b>do neither modify them nor delete them</b>.
94  * NOTE: You can pass a NULL pointer if you dont need one of the two variables to be returned.
95  * \exception std::exception On index out of bounds.
96  */
97  void get(size_t index, CPose3DPDFPtr &out_posePDF, CSensoryFramePtr &out_SF ) const ;
98 
99  /** Changes the i'th pair, first one is index '0'.
100  * The referenced object is COPIED, so you can freely destroy the object passed as parameter after calling this.
101  * If one of the pointers is NULL, the corresponding contents of the current i'th pair is not modified (i.e. if you want just to modify one of the values).
102  * \exception std::exception On index out of bounds.
103  * \sa insert, get, remove
104  */
105  void set(size_t index, const CPose3DPDFPtr &in_posePDF, const CSensoryFramePtr &in_SF );
106 
107  /** Changes the i'th pair, first one is index '0'.
108  * The referenced object is COPIED, so you can freely destroy the object passed as parameter after calling this.
109  * If one of the pointers is NULL, the corresponding contents of the current i'th pair is not modified (i.e. if you want just to modify one of the values).
110  * This version for 2D PDFs just converts the 2D PDF into 3D before calling the 3D version.
111  * \exception std::exception On index out of bounds.
112  * \sa insert, get, remove
113  */
114  void set(size_t index, const CPosePDFPtr &in_posePDF, const CSensoryFramePtr &in_SF );
115 
116  /** Deletes the i'th pair, first one is index '0'.
117  * \exception std::exception On index out of bounds.
118  * \sa insert, get, set
119  */
120  void remove(size_t index);
121 
122  /** Add a new pair to the sequence. The objects are copied, so original ones can be free if desired after insertion. */
123  void insert( const CPose3DPDF *in_posePDF, const CSensoryFrame &in_SF );
124 
125  /** Add a new pair to the sequence, making a copy of the smart pointer (it's not made unique). */
126  void insert( const CPose3DPDF *in_posePDF, const CSensoryFramePtr &in_SF );
127 
128  /** Add a new pair to the sequence, making a copy of the smart pointer (it's not made unique). */
129  void insert( const CPose3DPDFPtr &in_posePDF, const CSensoryFramePtr &in_SF );
130 
131  /** Add a new pair to the sequence. The objects are copied, so original ones can be free if desired
132  * after insertion.
133  * This version for 2D PDFs just converts the 2D PDF into 3D before calling the 3D version.
134  */
135  void insert( const CPosePDFPtr &in_posePDF, const CSensoryFramePtr &in_SF );
136 
137  /** Add a new pair to the sequence. The objects are copied, so original ones can be free if desired
138  * after insertion.
139  * This version for 2D PDFs just converts the 2D PDF into 3D before calling the 3D version.
140  */
141  void insert( const CPosePDF *in_posePDF, const CSensoryFrame &in_SF );
142 
143  /** Add a new pair to the sequence. The objects are copied, so original ones can be free if desired
144  * after insertion.
145  * This version for 2D PDFs just converts the 2D PDF into 3D before calling the 3D version.
146  */
147  void insert( const CPosePDF *in_posePDF, const CSensoryFramePtr &in_SF );
148 
149  /** Remove all stored pairs.
150  * \sa remove
151  */
152  void clear();
153 
154  /** Change the coordinate origin of all stored poses, for consistency with future new poses to enter in the system. */
155  void changeCoordinatesOrigin( const CPose3D &newOrigin );
156 
157 
159  typedef std::deque<TPosePDFSensFramePair> TPosePDFSensFramePairList;
160 
161  typedef TPosePDFSensFramePairList::const_iterator const_iterator;
162  typedef TPosePDFSensFramePairList::iterator iterator;
163  typedef TPosePDFSensFramePairList::reverse_iterator reverse_iterator;
164  typedef TPosePDFSensFramePairList::const_reverse_iterator const_reverse_iterator;
165 
166 
167  inline const_iterator begin() const { return m_posesObsPairs.begin(); }
168  inline const_iterator end() const { return m_posesObsPairs.end(); }
169  inline iterator begin() { return m_posesObsPairs.begin(); }
170  inline iterator end() { return m_posesObsPairs.end(); }
171 
172  inline const_reverse_iterator rbegin() const { return m_posesObsPairs.rbegin(); }
173  inline const_reverse_iterator rend() const { return m_posesObsPairs.rend(); }
174  inline reverse_iterator rbegin() { return m_posesObsPairs.rbegin(); }
175  inline reverse_iterator rend() { return m_posesObsPairs.rend(); }
176 
177  private:
178  /** The stored data */
180 
181  }; // End of class def.
182 
183  // For compatibility with code < 0.9.0
184 #if MRPT_BACKCOMPATIB_08X
185  typedef CSimpleMap CSensFrameProbSequence;
186  typedef CSimpleMapPtr CSensFrameProbSequencePtr;
187 #endif
188 
189 
190  } // End of namespace
191 } // End of namespace
192 
193 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013