Main MRPT website > C++ reference
MRPT logo
CObservation.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 COBSERVATION_H
29 #define COBSERVATION_H
30 
31 
32 #include <mrpt/obs/link_pragmas.h>
33 
35 #include <mrpt/utils/CStream.h>
36 #include <mrpt/system/os.h>
37 #include <mrpt/system/datetime.h>
38 
39 /** The main namespace for all the Mobile Robot Programming Toolkit (MRPT) C++ libraries. */
40 namespace mrpt
41 {
42  namespace poses
43  {
44  class CPosePDF;
45  class CPose2D;
46  class CPose3D;
47  }
48 
49  namespace math { struct TPose3D; }
50 
51  /** This namespace contains algorithms for SLAM, localization, map building, representation of robot's actions and observations, and representation of many kinds of metric maps.
52  */
53  namespace slam
54  {
55  using namespace poses;
56 
57  /** Used for CObservationBearingRange::TMeasurement::beaconID
58  * \ingroup mrpt_obs_grp
59  */
60  #define INVALID_LANDMARK_ID (-1)
61 
62  /** Used for CObservationBeaconRange
63  * \ingroup mrpt_obs_grp
64  */
65  #define INVALID_BEACON_ID (-1)
66 
68 
69  /** Declares a class that represents any robot's observation.
70  This is a base class for many types of sensors
71  observations. Users can add a new observation type
72  creating a new class deriving from this one.<br>
73  <b>IMPORTANT</b>: Observations doesn't include any information about the
74  robot pose beliefs, just the raw observation and, where
75  aplicable, information about sensor position or
76  orientation respect to robotic coordinates origin.
77  *
78  * \sa CSensoryFrame, CMetricMap
79  * \ingroup mrpt_obs_grp
80  */
81  class OBS_IMPEXP CObservation : public mrpt::utils::CSerializable
82  {
83  // This must be added to any CSerializable derived class:
85 
86  protected:
87  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.
88 
89  public:
90 
91  /** @name Data common to any observation
92  @{ */
93 
94  /** The associated time-stamp.
95  */
96  mrpt::system::TTimeStamp timestamp;
97 
98  /** An arbitrary label that can be used to identify the sensor.
99  */
100  std::string sensorLabel;
101 
102  /** @} */
103 
104  /** Constructor: It sets the initial timestamp to current time
105  */
106  CObservation();
107 
108 
109  /** This method is equivalent to:
110  * \code
111  * map->insertObservation(this, robotPose)
112  * \endcode
113  * \param theMap The map where this observation is to be inserted: the map will be updated.
114  * \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)
115  *
116  * \return Returns true if the map has been updated, or false if this observations
117  * has nothing to do with a metric map (for example, a sound observation).
118  *
119  * \sa CMetricMap, CMetricMap::insertObservation
120  */
121  template <class METRICMAP>
122  inline bool insertObservationInto( METRICMAP *theMap, const CPose3D *robotPose = NULL ) const
123  {
124  return theMap->insertObservation(this,robotPose);
125  }
126 
127  /** A general method to retrieve the sensor pose on the robot.
128  * Note that most sensors will return a full (6D) CPose3D, but see the derived classes for more details or special cases.
129  * \sa setSensorPose
130  */
131  virtual void getSensorPose( CPose3D &out_sensorPose ) const = 0;
132 
133  /** A general method to retrieve the sensor pose on the robot.
134  * Note that most sensors will return a full (6D) CPose3D, but see the derived classes for more details or special cases.
135  * \sa setSensorPose
136  */
137  void getSensorPose( mrpt::math::TPose3D &out_sensorPose ) const;
138 
139  /** A general method to change the sensor pose on the robot.
140  * Note that most sensors will use the full (6D) CPose3D, but see the derived classes for more details or special cases.
141  * \sa getSensorPose
142  */
143  virtual void setSensorPose( const CPose3D &newSensorPose ) = 0;
144 
145  /** A general method to change the sensor pose on the robot.
146  * Note that most sensors will use the full (6D) CPose3D, but see the derived classes for more details or special cases.
147  * \sa getSensorPose
148  */
149  void setSensorPose( const mrpt::math::TPose3D &newSensorPose );
150 
151  /** @name Delayed-load manual control methods.
152  @{ */
153 
154  /** Makes sure all images and other fields which may be externally stored are loaded in memory.
155  * 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.
156  * If all the data were alredy loaded or this object has no externally stored data fields, calling this method has no effects.
157  * \sa unload
158  */
159  virtual void load() const { /* Default implementation: do nothing */ }
160  /** Unload all images, for the case they being delayed-load images stored in external files (othewise, has no effect).
161  * \sa load
162  */
163  virtual void unload() { /* Default implementation: do nothing */ }
164 
165  /** @} */
166 
167  }; // End of class def.
168 
169 
170  } // End of namespace
171 } // End of namespace
172 
173 #endif



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