Main MRPT website > C++ reference for MRPT 1.4.0
obs/CObservation.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2016, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 #ifndef COBSERVATION_H
10 #define COBSERVATION_H
11 
12 
13 #include <mrpt/obs/link_pragmas.h>
14 
16 #include <mrpt/system/datetime.h>
17 #include <mrpt/math/math_frwds.h>
18 
19 namespace mrpt
20 {
21  /** This namespace contains representation of robot actions and observations */
22  namespace obs
23  {
24  /** Used for CObservationBearingRange::TMeasurement::beaconID
25  * \ingroup mrpt_obs_grp
26  */
27  #define INVALID_LANDMARK_ID (-1)
28 
29  /** Used for CObservationBeaconRange
30  * \ingroup mrpt_obs_grp
31  */
32  #define INVALID_BEACON_ID (-1)
33 
35 
36  /** Declares a class that represents any robot's observation.
37  * This is a base class for many types of sensor observations.
38  * Users can add new observation types creating a new class deriving from this one.
39  *
40  * <b>IMPORTANT</b>: Observations don't include any information about the robot pose,
41  * just raw sensory data and, where aplicable, information about the sensor position and
42  * orientation in the local frame of the robot.
43  *
44  * \sa CSensoryFrame, CMetricMap
45  * \ingroup mrpt_obs_grp
46  */
47  class OBS_IMPEXP CObservation : public mrpt::utils::CSerializable
48  {
49  // This must be added to any CSerializable derived class:
51 
52  protected:
53  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.
54 
55  public:
56 
57  /** @name Data common to any observation
58  @{ */
59  mrpt::system::TTimeStamp timestamp; //!< The associated UTC time-stamp. Where available, this should contain the accurate satellite-based timestamp of the sensor reading. \sa getOriginalReceivedTimeStamp(), getTimeStamp()
60  std::string sensorLabel;//!< An arbitrary label that can be used to identify the sensor.
61 
62  /** Returns CObservation::timestamp for all kind of observations \sa getOriginalReceivedTimeStamp() */
63  mrpt::system::TTimeStamp getTimeStamp() const { return timestamp; }
64  /** By default, returns CObservation::timestamp but in sensors capable of satellite (or otherwise) accurate UTC timing of readings, this contains the computer-based timestamp of reception, which may be slightly different than \a timestamp \sa getTimeStamp() */
65  virtual mrpt::system::TTimeStamp getOriginalReceivedTimeStamp() const { return timestamp; }
66  /** @} */
67 
68  CObservation(); //!< Constructor: It sets the initial timestamp to current time
69 
70  /** This method is equivalent to:
71  * \code
72  * map->insertObservation(this, robotPose)
73  * \endcode
74  * \param theMap The map where this observation is to be inserted: the map will be updated.
75  * \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)
76  *
77  * \return Returns true if the map has been updated, or false if this observations
78  * has nothing to do with a metric map (for example, a sound observation).
79  *
80  * \sa CMetricMap, CMetricMap::insertObservation
81  */
82  template <class METRICMAP>
83  inline bool insertObservationInto( METRICMAP *theMap, const mrpt::poses::CPose3D *robotPose = NULL ) const
84  {
85  return theMap->insertObservation(this,robotPose);
86  }
87 
88  /** A general method to retrieve the sensor pose on the robot.
89  * Note that most sensors will return a full (6D) CPose3D, but see the derived classes for more details or special cases.
90  * \sa setSensorPose
91  */
92  virtual void getSensorPose( mrpt::poses::CPose3D &out_sensorPose ) const = 0;
93 
94  /** A general method to retrieve the sensor pose on the robot.
95  * Note that most sensors will return a full (6D) CPose3D, but see the derived classes for more details or special cases.
96  * \sa setSensorPose
97  */
98  void getSensorPose( mrpt::math::TPose3D &out_sensorPose ) const;
99 
100  /** A general method to change the sensor pose on the robot.
101  * Note that most sensors will use the full (6D) CPose3D, but see the derived classes for more details or special cases.
102  * \sa getSensorPose
103  */
104  virtual void setSensorPose( const mrpt::poses::CPose3D &newSensorPose ) = 0;
105 
106  /** A general method to change the sensor pose on the robot.
107  * Note that most sensors will use the full (6D) CPose3D, but see the derived classes for more details or special cases.
108  * \sa getSensorPose
109  */
110  void setSensorPose( const mrpt::math::TPose3D &newSensorPose );
111 
112  /** Build a detailed, multi-line textual description of the observation contents and dump it to the output stream.
113  * \note If overried by derived classes, call base CObservation::getDescriptionAsText() first to show common information.
114  * \note This is the text that appears in RawLogViewer when selecting an object in the dataset */
115  virtual void getDescriptionAsText(std::ostream &o) const;
116 
117  /** @name Delayed-load manual control methods.
118  @{ */
119 
120  /** Makes sure all images and other fields which may be externally stored are loaded in memory.
121  * 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.
122  * If all the data were alredy loaded or this object has no externally stored data fields, calling this method has no effects.
123  * \sa unload
124  */
125  virtual void load() const { /* Default implementation: do nothing */ }
126  /** Unload all images, for the case they being delayed-load images stored in external files (othewise, has no effect).
127  * \sa load
128  */
129  virtual void unload() { /* Default implementation: do nothing */ }
130 
131  /** @} */
132 
133  }; // End of class def.
135 
136 
137  } // End of namespace
138 } // End of namespace
139 
140 #endif
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:30
bool insertObservationInto(METRICMAP *theMap, const mrpt::poses::CPose3D *robotPose=NULL) const
This method is equivalent to:
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:39
STL namespace.
#define DEFINE_VIRTUAL_SERIALIZABLE(class_name)
This declaration must be inserted in virtual CSerializable classes definition:
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
virtual void unload()
Unload all images, for the case they being delayed-load images stored in external files (othewise...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:72
Declares a class that represents any robot&#39;s observation.
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
virtual void load() const
Makes sure all images and other fields which may be externally stored are loaded in memory...
virtual mrpt::system::TTimeStamp getOriginalReceivedTimeStamp() const
By default, returns CObservation::timestamp but in sensors capable of satellite (or otherwise) accura...
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)



Page generated by Doxygen 1.8.11 for MRPT 1.4.0 SVN:Unversioned directory at Sun Jul 10 11:38:36 UTC 2016