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