00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://www.mrpt.org/ | 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 * \ingroup mrpt_obs_grp 00051 */ 00052 class OBS_IMPEXP CSimpleMap : public mrpt::utils::CSerializable 00053 { 00054 // This must be added to any CSerializable derived class: 00055 DEFINE_SERIALIZABLE( CSimpleMap ) 00056 00057 public: 00058 /** Constructor 00059 */ 00060 CSimpleMap(); 00061 00062 /** Copy constructor 00063 */ 00064 CSimpleMap( const CSimpleMap &o ); 00065 00066 /** Copy constructor 00067 */ 00068 CSimpleMap & operator = ( const CSimpleMap& o); 00069 00070 /** Destructor: 00071 */ 00072 virtual ~CSimpleMap(); 00073 00074 /** Save this object to a .simplemap binary file (compressed with gzip) 00075 * \sa loadFromFile 00076 * \return false on any error. 00077 */ 00078 bool saveToFile(const std::string &filName) const; 00079 00080 /** Load the contents of this object from a .simplemap binary file (possibly compressed with gzip) 00081 * \sa saveToFile 00082 * \return false on any error. 00083 */ 00084 bool loadFromFile(const std::string &filName); 00085 00086 00087 /** Returns the pairs count. 00088 */ 00089 size_t size() const; 00090 00091 /** Access to the i'th pair, first one is index '0'. NOTE: This method 00092 * returns pointers to the objects inside the list, nor a copy of them, 00093 * so <b>do neither modify them nor delete them</b>. 00094 * NOTE: You can pass a NULL pointer if you dont need one of the two variables to be returned. 00095 * \exception std::exception On index out of bounds. 00096 */ 00097 void get(size_t index, CPose3DPDFPtr &out_posePDF, CSensoryFramePtr &out_SF ) const ; 00098 00099 /** Changes the i'th pair, first one is index '0'. 00100 * The referenced object is COPIED, so you can freely destroy the object passed as parameter after calling this. 00101 * 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). 00102 * \exception std::exception On index out of bounds. 00103 * \sa insert, get, remove 00104 */ 00105 void set(size_t index, const CPose3DPDFPtr &in_posePDF, const CSensoryFramePtr &in_SF ); 00106 00107 /** Changes the i'th pair, first one is index '0'. 00108 * The referenced object is COPIED, so you can freely destroy the object passed as parameter after calling this. 00109 * 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). 00110 * This version for 2D PDFs just converts the 2D PDF into 3D before calling the 3D version. 00111 * \exception std::exception On index out of bounds. 00112 * \sa insert, get, remove 00113 */ 00114 void set(size_t index, const CPosePDFPtr &in_posePDF, const CSensoryFramePtr &in_SF ); 00115 00116 /** Deletes the i'th pair, first one is index '0'. 00117 * \exception std::exception On index out of bounds. 00118 * \sa insert, get, set 00119 */ 00120 void remove(size_t index); 00121 00122 /** Add a new pair to the sequence. The objects are copied, so original ones can be free if desired after insertion. */ 00123 void insert( const CPose3DPDF *in_posePDF, const CSensoryFrame &in_SF ); 00124 00125 /** Add a new pair to the sequence, making a copy of the smart pointer (it's not made unique). */ 00126 void insert( const CPose3DPDF *in_posePDF, const CSensoryFramePtr &in_SF ); 00127 00128 /** Add a new pair to the sequence, making a copy of the smart pointer (it's not made unique). */ 00129 void insert( const CPose3DPDFPtr &in_posePDF, const CSensoryFramePtr &in_SF ); 00130 00131 /** Add a new pair to the sequence. The objects are copied, so original ones can be free if desired 00132 * after insertion. 00133 * This version for 2D PDFs just converts the 2D PDF into 3D before calling the 3D version. 00134 */ 00135 void insert( const CPosePDFPtr &in_posePDF, const CSensoryFramePtr &in_SF ); 00136 00137 /** Add a new pair to the sequence. The objects are copied, so original ones can be free if desired 00138 * after insertion. 00139 * This version for 2D PDFs just converts the 2D PDF into 3D before calling the 3D version. 00140 */ 00141 void insert( const CPosePDF *in_posePDF, const CSensoryFrame &in_SF ); 00142 00143 /** Add a new pair to the sequence. The objects are copied, so original ones can be free if desired 00144 * after insertion. 00145 * This version for 2D PDFs just converts the 2D PDF into 3D before calling the 3D version. 00146 */ 00147 void insert( const CPosePDF *in_posePDF, const CSensoryFramePtr &in_SF ); 00148 00149 /** Remove all stored pairs. 00150 * \sa remove 00151 */ 00152 void clear(); 00153 00154 /** Change the coordinate origin of all stored poses, for consistency with future new poses to enter in the system. */ 00155 void changeCoordinatesOrigin( const CPose3D &newOrigin ); 00156 00157 00158 typedef std::pair<CPose3DPDFPtr,CSensoryFramePtr> TPosePDFSensFramePair; 00159 typedef std::deque<TPosePDFSensFramePair> TPosePDFSensFramePairList; 00160 00161 typedef TPosePDFSensFramePairList::const_iterator const_iterator; 00162 typedef TPosePDFSensFramePairList::iterator iterator; 00163 typedef TPosePDFSensFramePairList::reverse_iterator reverse_iterator; 00164 typedef TPosePDFSensFramePairList::const_reverse_iterator const_reverse_iterator; 00165 00166 00167 inline const_iterator begin() const { return m_posesObsPairs.begin(); } 00168 inline const_iterator end() const { return m_posesObsPairs.end(); } 00169 inline iterator begin() { return m_posesObsPairs.begin(); } 00170 inline iterator end() { return m_posesObsPairs.end(); } 00171 00172 inline const_reverse_iterator rbegin() const { return m_posesObsPairs.rbegin(); } 00173 inline const_reverse_iterator rend() const { return m_posesObsPairs.rend(); } 00174 inline reverse_iterator rbegin() { return m_posesObsPairs.rbegin(); } 00175 inline reverse_iterator rend() { return m_posesObsPairs.rend(); } 00176 00177 private: 00178 /** The stored data */ 00179 TPosePDFSensFramePairList m_posesObsPairs; 00180 00181 }; // End of class def. 00182 00183 // For compatibility with code < 0.9.0 00184 #if MRPT_BACKCOMPATIB_08X 00185 typedef CSimpleMap CSensFrameProbSequence; 00186 typedef CSimpleMapPtr CSensFrameProbSequencePtr; 00187 #endif 00188 00189 00190 } // End of namespace 00191 } // End of namespace 00192 00193 #endif
| Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011 |