Main MRPT website > C++ reference
MRPT logo
CObservation.h
Go to the documentation of this file.
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 COBSERVATION_H
00029 #define COBSERVATION_H
00030 
00031 
00032 #include <mrpt/obs/link_pragmas.h>
00033 
00034 #include <mrpt/utils/CSerializable.h>
00035 #include <mrpt/utils/CStream.h>
00036 #include <mrpt/system/os.h>
00037 #include <mrpt/system/datetime.h>
00038 
00039 /** The main namespace for all the Mobile Robot Programming Toolkit (MRPT) C++ libraries. */
00040 namespace mrpt
00041 {
00042         namespace poses
00043         {
00044                 class CPosePDF;
00045                 class CPose2D;
00046                 class CPose3D;
00047         }
00048 
00049         namespace math { struct TPose3D; }
00050 
00051         /** This namespace contains algorithms for SLAM, localization, map building, representation of robot's actions and observations, and representation of many kinds of metric maps.
00052           */
00053         namespace slam
00054         {
00055                 using namespace poses;
00056 
00057                 /** Used for CObservationBearingRange::TMeasurement::beaconID
00058                  * \ingroup mrpt_obs_grp
00059                   */
00060                 #define INVALID_LANDMARK_ID     (-1)
00061 
00062                 /** Used for CObservationBeaconRange
00063                  * \ingroup mrpt_obs_grp
00064                   */
00065                 #define INVALID_BEACON_ID               (-1)
00066 
00067                 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CObservation, mrpt::utils::CSerializable,OBS_IMPEXP )
00068 
00069                 /** Declares a class that represents any robot's observation.
00070                            This is a base class for many types of sensors
00071                                  observations. Users can add a new observation type
00072                                  creating a new class deriving from this one.<br>
00073                            <b>IMPORTANT</b>: Observations doesn't include any information about the
00074                                 robot pose beliefs, just the raw observation and, where
00075                                 aplicable, information about sensor position or
00076                                 orientation respect to robotic coordinates origin.
00077                  *
00078                  * \sa CSensoryFrame, CMetricMap
00079                  * \ingroup mrpt_obs_grp
00080                  */
00081                 class OBS_IMPEXP CObservation : public mrpt::utils::CSerializable
00082                 {
00083                         // This must be added to any CSerializable derived class:
00084                         DEFINE_VIRTUAL_SERIALIZABLE(CObservation)
00085 
00086                 protected:
00087                         void swap(CObservation &o);  //!< Swap with another observation, ONLY the data defined here in the base class CObservation. It's protected since it'll be only called from child classes that should know what else to swap appart from these common data.
00088 
00089                  public:
00090 
00091                  /** @name Data common to any observation
00092                      @{ */
00093 
00094                         /** The associated time-stamp.
00095                         */
00096                         mrpt::system::TTimeStamp        timestamp;
00097 
00098                         /** An arbitrary label that can be used to identify the sensor.
00099                         */
00100                         std::string                     sensorLabel;
00101 
00102                 /** @} */
00103 
00104                 /** Constructor: It sets the initial timestamp to current time
00105                 */
00106                 CObservation();
00107 
00108 
00109                 /** This method is equivalent to:
00110                 * \code
00111                 *               map->insertObservation(this, robotPose)
00112                 * \endcode
00113                 * \param theMap The map where this observation is to be inserted: the map will be updated.
00114                 * \param robotPose The pose of the robot base for this observation, relative to the target metric map. Set to NULL (default) to use (0,0,0deg)
00115                 *
00116                 * \return Returns true if the map has been updated, or false if this observations
00117                 *                       has nothing to do with a metric map (for example, a sound observation).
00118                 *
00119                 * \sa CMetricMap, CMetricMap::insertObservation
00120                 */
00121                 template <class METRICMAP>
00122                 inline bool insertObservationInto( METRICMAP *theMap, const CPose3D *robotPose = NULL ) const
00123                 {
00124                         return theMap->insertObservation(this,robotPose);
00125                 }
00126 
00127                 /** A general method to retrieve the sensor pose on the robot.
00128                 *  Note that most sensors will return a full (6D) CPose3D, but see the derived classes for more details or special cases.
00129                 * \sa setSensorPose
00130                 */
00131                 virtual void getSensorPose( CPose3D &out_sensorPose ) const = 0;
00132 
00133                 /** A general method to retrieve the sensor pose on the robot.
00134                 *  Note that most sensors will return a full (6D) CPose3D, but see the derived classes for more details or special cases.
00135                 * \sa setSensorPose
00136                 */
00137                 void getSensorPose( mrpt::math::TPose3D &out_sensorPose ) const;
00138 
00139                 /** A general method to change the sensor pose on the robot.
00140                 *  Note that most sensors will use the full (6D) CPose3D, but see the derived classes for more details or special cases.
00141                 * \sa getSensorPose
00142                 */
00143                 virtual void setSensorPose( const CPose3D &newSensorPose ) = 0;
00144 
00145                 /** A general method to change the sensor pose on the robot.
00146                 *  Note that most sensors will use the full (6D) CPose3D, but see the derived classes for more details or special cases.
00147                 * \sa getSensorPose
00148                 */
00149                 void setSensorPose( const mrpt::math::TPose3D &newSensorPose );
00150 
00151                 /** @name Delayed-load manual control methods.
00152                     @{ */
00153 
00154                 /** Makes sure all images and other fields which may be externally stored are loaded in memory.
00155                   *  Note that for all CImages, calling load() is not required since the images will be automatically loaded upon first access, so load() shouldn't be needed to be called in normal cases by the user.
00156                   *  If all the data were alredy loaded or this object has no externally stored data fields, calling this method has no effects.
00157                   * \sa unload
00158                   */
00159                 virtual void load() const { /* Default implementation: do nothing */ } 
00160                 /** Unload all images, for the case they being delayed-load images stored in external files (othewise, has no effect).
00161                   * \sa load
00162                   */
00163                 virtual void unload() { /* Default implementation: do nothing */ } 
00164 
00165                 /** @} */
00166 
00167                 }; // End of class def.
00168 
00169 
00170         } // End of namespace
00171 } // End of namespace
00172 
00173 #endif



Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011