Main MRPT website > C++ reference
MRPT logo

CSimpleMap.h

Go to the documentation of this file.
00001 /* +---------------------------------------------------------------------------+
00002    |          The Mobile Robot Programming Toolkit (MRPT) C++ library          |
00003    |                                                                           |
00004    |                   http://mrpt.sourceforge.net/                            |
00005    |                                                                           |
00006    |   Copyright (C) 2005-2011  University of Malaga                           |
00007    |                                                                           |
00008    |    This software was written by the Machine Perception and Intelligent    |
00009    |      Robotics Lab, University of Malaga (Spain).                          |
00010    |    Contact: Jose-Luis Blanco  <jlblanco@ctima.uma.es>                     |
00011    |                                                                           |
00012    |  This file is part of the MRPT project.                                   |
00013    |                                                                           |
00014    |     MRPT is free software: you can redistribute it and/or modify          |
00015    |     it under the terms of the GNU General Public License as published by  |
00016    |     the Free Software Foundation, either version 3 of the License, or     |
00017    |     (at your option) any later version.                                   |
00018    |                                                                           |
00019    |   MRPT is distributed in the hope that it will be useful,                 |
00020    |     but WITHOUT ANY WARRANTY; without even the implied warranty of        |
00021    |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
00022    |     GNU General Public License for more details.                          |
00023    |                                                                           |
00024    |     You should have received a copy of the GNU General Public License     |
00025    |     along with MRPT.  If not, see <http://www.gnu.org/licenses/>.         |
00026    |                                                                           |
00027    +---------------------------------------------------------------------------+ */
00028 #ifndef CSimpleMap_H
00029 #define CSimpleMap_H
00030 
00031 #include <mrpt/utils/CSerializable.h>
00032 #include <mrpt/slam/CSensoryFrame.h>
00033 #include <mrpt/poses/CPosePDF.h>
00034 #include <mrpt/poses/CPose3DPDF.h>
00035 
00036 namespace mrpt
00037 {
00038 namespace slam
00039 {
00040         // This must be added to any CSerializable derived class:
00041         DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CSimpleMap, mrpt::utils::CSerializable, OBS_IMPEXP )
00042 
00043         /** This class stores a sequence of <Probabilistic Pose,SensoryFrame> pairs, thus a "metric map" can be totally determined with this information.
00044          *     The pose of the sensory frame is not deterministic, but described by some PDF. Full 6D poses are used.
00045          *
00046          *  \note Objects of this class are serialized into (possibly GZ-compressed) files with the extension ".simplemap".
00047          *
00048          * \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.
00049          * \sa CSensoryFrame, CPosePDF
00050          */
00051         class OBS_IMPEXP CSimpleMap : public mrpt::utils::CSerializable
00052         {
00053                 // This must be added to any CSerializable derived class:
00054                 DEFINE_SERIALIZABLE( CSimpleMap )
00055 
00056         public:
00057                 /** Constructor
00058                   */
00059                 CSimpleMap();
00060 
00061                 /** Copy constructor
00062                   */
00063                 CSimpleMap( const CSimpleMap &o );
00064 
00065                 /** Copy constructor
00066                   */
00067                 CSimpleMap & operator = ( const CSimpleMap& o);
00068 
00069                 /**  Destructor:
00070                   */
00071                 virtual ~CSimpleMap();
00072 
00073                 /** Save this object to a .simplemap binary file (compressed with gzip)
00074                   * \sa loadFromFile
00075                   * \return false on any error.
00076                   */
00077                 bool saveToFile(const std::string &filName) const;
00078 
00079                 /** Load the contents of this object from a .simplemap binary file (possibly compressed with gzip)
00080                   * \sa saveToFile
00081                   * \return false on any error.
00082                   */
00083                 bool loadFromFile(const std::string &filName);
00084 
00085 
00086                 /** Returns the pairs count.
00087                   */
00088                 size_t size() const;
00089 
00090                 /** Access to the i'th pair, first one is index '0'. NOTE: This method
00091                   *  returns pointers to the objects inside the list, nor a copy of them,
00092                   *  so <b>do neither modify them nor delete them</b>.
00093                   * NOTE: You can pass a NULL pointer if you dont need one of the two variables to be returned.
00094                   * \exception std::exception On index out of bounds.
00095                   */
00096                 void  get(size_t index, CPose3DPDFPtr &out_posePDF, CSensoryFramePtr &out_SF ) const ;
00097 
00098                 /** Changes the i'th pair, first one is index '0'.
00099                   *  The referenced object is COPIED, so you can freely destroy the object passed as parameter after calling this.
00100                   *  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).
00101                   * \exception std::exception On index out of bounds.
00102                   * \sa insert, get, remove
00103                   */
00104                 void  set(size_t index, const CPose3DPDFPtr &in_posePDF, const CSensoryFramePtr &in_SF );
00105 
00106                 /** Changes the i'th pair, first one is index '0'.
00107                   *  The referenced object is COPIED, so you can freely destroy the object passed as parameter after calling this.
00108                   *  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).
00109                   * This version for 2D PDFs just converts the 2D PDF into 3D before calling the 3D version.
00110                   * \exception std::exception On index out of bounds.
00111                   * \sa insert, get, remove
00112                   */
00113                 void  set(size_t index, const CPosePDFPtr &in_posePDF, const CSensoryFramePtr &in_SF );
00114 
00115                 /** Deletes the i'th pair, first one is index '0'.
00116                   * \exception std::exception On index out of bounds.
00117                   * \sa insert, get, set
00118                   */
00119                 void  remove(size_t index);
00120 
00121                 /** Add a new pair to the sequence. The objects are copied, so original ones can be free if desired after insertion. */
00122                 void  insert( const CPose3DPDF *in_posePDF, const CSensoryFrame &in_SF );
00123 
00124                 /** Add a new pair to the sequence, making a copy of the smart pointer (it's not made unique). */
00125                 void  insert( const CPose3DPDF *in_posePDF, const CSensoryFramePtr &in_SF );
00126 
00127                 /** Add a new pair to the sequence, making a copy of the smart pointer (it's not made unique). */
00128                 void  insert( const CPose3DPDFPtr &in_posePDF, const CSensoryFramePtr &in_SF );
00129 
00130                 /** Add a new pair to the sequence. The objects are copied, so original ones can be free if desired
00131                   *  after insertion.
00132                   * This version for 2D PDFs just converts the 2D PDF into 3D before calling the 3D version.
00133                   */
00134                 void  insert( const CPosePDFPtr &in_posePDF, const CSensoryFramePtr &in_SF );
00135 
00136                 /** Add a new pair to the sequence. The objects are copied, so original ones can be free if desired
00137                   *  after insertion.
00138                   * This version for 2D PDFs just converts the 2D PDF into 3D before calling the 3D version.
00139                   */
00140                 void  insert( const CPosePDF *in_posePDF, const CSensoryFrame &in_SF );
00141 
00142                 /** Add a new pair to the sequence. The objects are copied, so original ones can be free if desired
00143                   *  after insertion.
00144                   * This version for 2D PDFs just converts the 2D PDF into 3D before calling the 3D version.
00145                   */
00146                 void  insert( const CPosePDF *in_posePDF, const CSensoryFramePtr &in_SF );
00147 
00148                 /** Remove all stored pairs.
00149                   * \sa remove
00150                   */
00151                 void  clear();
00152 
00153                 /** Change the coordinate origin of all stored poses, for consistency with future new poses to enter in the system. */
00154                 void changeCoordinatesOrigin( const CPose3D  &newOrigin );
00155 
00156 
00157                 typedef std::pair<CPose3DPDFPtr,CSensoryFramePtr> TPosePDFSensFramePair;
00158                 typedef std::deque<TPosePDFSensFramePair> TPosePDFSensFramePairList;
00159 
00160                 typedef TPosePDFSensFramePairList::const_iterator       const_iterator;
00161                 typedef TPosePDFSensFramePairList::iterator             iterator;
00162                 typedef TPosePDFSensFramePairList::reverse_iterator reverse_iterator;
00163                 typedef TPosePDFSensFramePairList::const_reverse_iterator const_reverse_iterator;
00164 
00165 
00166                 inline const_iterator begin() const     { return m_posesObsPairs.begin(); }
00167                 inline const_iterator end() const               { return m_posesObsPairs.end(); }
00168                 inline iterator begin()                                 { return m_posesObsPairs.begin(); }
00169                 inline iterator end()                                   { return m_posesObsPairs.end(); }
00170 
00171                 inline const_reverse_iterator rbegin() const    { return m_posesObsPairs.rbegin(); }
00172                 inline const_reverse_iterator rend() const              { return m_posesObsPairs.rend(); }
00173                 inline reverse_iterator rbegin()                                { return m_posesObsPairs.rbegin(); }
00174                 inline reverse_iterator rend()                                  { return m_posesObsPairs.rend(); }
00175 
00176         private:
00177                 /** The stored data */
00178                 TPosePDFSensFramePairList               m_posesObsPairs;
00179 
00180         }; // End of class def.
00181 
00182         // For compatibility with code < 0.9.0
00183 #if MRPT_BACKCOMPATIB_08X
00184         typedef CSimpleMap              CSensFrameProbSequence;
00185         typedef CSimpleMapPtr   CSensFrameProbSequencePtr;
00186 #endif
00187 
00188 
00189         } // End of namespace
00190 } // End of namespace
00191 
00192 #endif



Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN: at Sat Mar 26 06:40:17 UTC 2011