Main MRPT website > C++ reference for MRPT 1.5.9
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-2017, 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  #define INVALID_BEACON_ID (-1) //!< Used for CObservationBeaconRange, CBeacon, etc. \ingroup mrpt_obs_grp
25  #define INVALID_LANDMARK_ID (-1) //!< Used for CObservationBearingRange::TMeasurement::beaconID and others. \ingroup mrpt_obs_grp
26 
28 
29  /** Declares a class that represents any robot's observation.
30  * This is a base class for many types of sensor observations.
31  * Users can add new observation types creating a new class deriving from this one.
32  *
33  * <b>IMPORTANT</b>: Observations don't include any information about the robot pose,
34  * just raw sensory data and, where aplicable, information about the sensor position and
35  * orientation in the local frame of the robot.
36  *
37  * \sa CSensoryFrame, CMetricMap
38  * \ingroup mrpt_obs_grp
39  */
40  class OBS_IMPEXP CObservation : public mrpt::utils::CSerializable
41  {
42  // This must be added to any CSerializable derived class:
44 
45  protected:
46  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.
47 
48  public:
49 
50  /** @name Data common to any observation
51  @{ */
52  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()
53  std::string sensorLabel;//!< An arbitrary label that can be used to identify the sensor.
54 
55  /** Returns CObservation::timestamp for all kind of observations \sa getOriginalReceivedTimeStamp() */
56  mrpt::system::TTimeStamp getTimeStamp() const { return timestamp; }
57  /** 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() */
58  virtual mrpt::system::TTimeStamp getOriginalReceivedTimeStamp() const { return timestamp; }
59  /** @} */
60 
61  CObservation(); //!< Constructor: It sets the initial timestamp to current time
62 
63  /** This method is equivalent to:
64  * \code
65  * map->insertObservation(this, robotPose)
66  * \endcode
67  * \param theMap The map where this observation is to be inserted: the map will be updated.
68  * \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)
69  *
70  * \return Returns true if the map has been updated, or false if this observations
71  * has nothing to do with a metric map (for example, a sound observation).
72  *
73  * See: \ref maps_observations
74  * \sa CMetricMap, CMetricMap::insertObservation
75  */
76  template <class METRICMAP>
77  inline bool insertObservationInto( METRICMAP *theMap, const mrpt::poses::CPose3D *robotPose = NULL ) const
78  {
79  return theMap->insertObservation(this,robotPose);
80  }
81 
82  /** A general method to retrieve the sensor pose on the robot.
83  * Note that most sensors will return a full (6D) CPose3D, but see the derived classes for more details or special cases.
84  * \sa setSensorPose
85  */
86  virtual void getSensorPose( mrpt::poses::CPose3D &out_sensorPose ) const = 0;
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  void getSensorPose( mrpt::math::TPose3D &out_sensorPose ) const;
93 
94  /** A general method to change the sensor pose on the robot.
95  * Note that most sensors will use the full (6D) CPose3D, but see the derived classes for more details or special cases.
96  * \sa getSensorPose
97  */
98  virtual void setSensorPose( const mrpt::poses::CPose3D &newSensorPose ) = 0;
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  void setSensorPose( const mrpt::math::TPose3D &newSensorPose );
105 
106  /** Build a detailed, multi-line textual description of the observation contents and dump it to the output stream.
107  * \note If overried by derived classes, call base CObservation::getDescriptionAsText() first to show common information.
108  * \note This is the text that appears in RawLogViewer when selecting an object in the dataset */
109  virtual void getDescriptionAsText(std::ostream &o) const;
110 
111  /** @name Delayed-load manual control methods.
112  @{ */
113 
114  /** Makes sure all images and other fields which may be externally stored are loaded in memory.
115  * 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.
116  * If all the data were alredy loaded or this object has no externally stored data fields, calling this method has no effects.
117  * \sa unload
118  */
119  virtual void load() const { /* Default implementation: do nothing */ }
120  /** Unload all images, for the case they being delayed-load images stored in external files (othewise, has no effect).
121  * \sa load
122  */
123  virtual void unload() { /* Default implementation: do nothing */ }
124 
125  /** @} */
126 
127  }; // End of class def.
129 
130 
131  } // End of namespace
132 } // End of namespace
133 
134 #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:
mrpt::system::TTimeStamp getTimeStamp() const
Returns CObservation::timestamp for all kind of observations.
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:39
virtual mrpt::system::TTimeStamp getOriginalReceivedTimeStamp() const
By default, returns CObservation::timestamp but in sensors capable of satellite (or otherwise) accura...
#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...
virtual void load() const
Makes sure all images and other fields which may be externally stored are loaded in memory...
GLsizei const GLchar ** string
Definition: glext.h:3919
std::string sensorLabel
An arbitrary label that can be used to identify the sensor.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::system::TTimeStamp timestamp
The associated UTC time-stamp. Where available, this should contain the accurate satellite-based time...
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).
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020