Main MRPT website > C++ reference for MRPT 1.9.9
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 
13 #include <mrpt/system/datetime.h>
14 #include <mrpt/math/math_frwds.h>
15 
16 namespace mrpt
17 {
18 /** This namespace contains representation of robot actions and observations */
19 namespace obs
20 {
21 /** Used for CObservationBeaconRange, CBeacon, etc. \ingroup mrpt_obs_grp */
22 #define INVALID_BEACON_ID (-1)
23 /** Used for CObservationBearingRange::TMeasurement::beaconID and others.
24  * \ingroup mrpt_obs_grp */
25 #define INVALID_LANDMARK_ID (-1)
26 
27 /** Declares a class that represents any robot's observation.
28  * This is a base class for many types of sensor observations.
29  * Users can add new observation types creating a new class deriving from this
30  * one.
31  *
32  * <b>IMPORTANT</b>: Observations don't include any information about the robot
33  * pose,
34  * just raw sensory data and, where aplicable, information about the sensor
35  * position and
36  * orientation in the local frame of the robot.
37  *
38  * \sa CSensoryFrame, CMetricMap
39  * \ingroup mrpt_obs_grp
40  */
42 {
44 
45  protected:
46  /** Swap with another observation, ONLY the data defined here in the base
47  * class CObservation. It's protected since it'll be only called from child
48  * classes that should know what else to swap appart from these common data.
49  */
50  void swap(CObservation& o);
51 
52  public:
53  /** @name Data common to any observation
54  @{ */
55  /** The associated UTC time-stamp. Where available, this should contain the
56  * accurate satellite-based timestamp of the sensor reading. \sa
57  * getOriginalReceivedTimeStamp(), getTimeStamp() */
59  /** An arbitrary label that can be used to identify the sensor. */
61 
62  /** Returns CObservation::timestamp for all kind of observations \sa
63  * getOriginalReceivedTimeStamp() */
65  /** By default, returns CObservation::timestamp but in sensors capable of
66  * satellite (or otherwise) accurate UTC timing of readings, this contains
67  * the computer-based timestamp of reception, which may be slightly
68  * different than \a timestamp \sa getTimeStamp() */
70  {
71  return timestamp;
72  }
73  /** @} */
74 
75  /** Constructor: It sets the initial timestamp to current time */
76  CObservation();
77 
78  /** This method is equivalent to:
79  * \code
80  * map->insertObservation(this, robotPose)
81  * \endcode
82  * \param theMap The map where this observation is to be inserted: the map
83  *will be updated.
84  * \param robotPose The pose of the robot base for this observation, relative
85  *to the target metric map. Set to nullptr (default) to use (0,0,0deg)
86  *
87  * \return Returns true if the map has been updated, or false if this
88  *observations
89  * has nothing to do with a metric map (for example, a sound
90  *observation).
91  *
92  * See: \ref maps_observations
93  * \sa CMetricMap, CMetricMap::insertObservation
94  */
95  template <class METRICMAP>
96  inline bool insertObservationInto(
97  METRICMAP* theMap,
98  const mrpt::poses::CPose3D* robotPose = nullptr) const
99  {
100  return theMap->insertObservation(this, robotPose);
101  }
102 
103  /** A general method to retrieve the sensor pose on the robot.
104  * Note that most sensors will return a full (6D) CPose3D, but see the
105  * derived classes for more details or special cases.
106  * \sa setSensorPose
107  */
108  virtual void getSensorPose(mrpt::poses::CPose3D& out_sensorPose) const = 0;
109 
110  /** A general method to retrieve the sensor pose on the robot.
111  * Note that most sensors will return a full (6D) CPose3D, but see the
112  * derived classes for more details or special cases.
113  * \sa setSensorPose
114  */
115  void getSensorPose(mrpt::math::TPose3D& out_sensorPose) const;
116 
117  /** A general method to change the sensor pose on the robot.
118  * Note that most sensors will use the full (6D) CPose3D, but see the
119  * derived classes for more details or special cases.
120  * \sa getSensorPose
121  */
122  virtual void setSensorPose(const mrpt::poses::CPose3D& newSensorPose) = 0;
123 
124  /** A general method to change the sensor pose on the robot.
125  * Note that most sensors will use the full (6D) CPose3D, but see the
126  * derived classes for more details or special cases.
127  * \sa getSensorPose
128  */
129  void setSensorPose(const mrpt::math::TPose3D& newSensorPose);
130 
131  /** Build a detailed, multi-line textual description of the observation
132  * contents and dump it to the output stream.
133  * \note If overried by derived classes, call base
134  * CObservation::getDescriptionAsText() first to show common information.
135  * \note This is the text that appears in RawLogViewer when selecting an
136  * object in the dataset */
137  virtual void getDescriptionAsText(std::ostream& o) const;
138 
139  /** @name Delayed-load manual control methods.
140  @{ */
141 
142  /** Makes sure all images and other fields which may be externally stored
143  * are loaded in memory.
144  * Note that for all CImages, calling load() is not required since the
145  * images will be automatically loaded upon first access, so load()
146  * shouldn't be needed to be called in normal cases by the user.
147  * If all the data were alredy loaded or this object has no externally
148  * stored data fields, calling this method has no effects.
149  * \sa unload
150  */
151  virtual void load() const { /* Default implementation: do nothing */}
152  /** Unload all images, for the case they being delayed-load images stored in
153  * external files (othewise, has no effect).
154  * \sa load
155  */
156  virtual void unload() { /* Default implementation: do nothing */}
157 
158  /** @} */
159 
160 }; // End of class def.
161 
162 } // End of namespace
163 } // End of namespace
164 
165 #endif
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:32
mrpt::system::TTimeStamp getTimeStamp() const
Returns CObservation::timestamp for all kind of observations.
Definition: CObservation.h:64
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:44
CObservation()
Constructor: It sets the initial timestamp to current time.
virtual mrpt::system::TTimeStamp getOriginalReceivedTimeStamp() const
By default, returns CObservation::timestamp but in sensors capable of satellite (or otherwise) accura...
Definition: CObservation.h:69
void swap(CObservation &o)
Swap with another observation, ONLY the data defined here in the base class CObservation.
#define DEFINE_VIRTUAL_SERIALIZABLE(class_name)
This declaration must be inserted in virtual CSerializable classes definition:
virtual void getSensorPose(mrpt::poses::CPose3D &out_sensorPose) const =0
A general method to retrieve the sensor pose on the robot.
bool insertObservationInto(METRICMAP *theMap, const mrpt::poses::CPose3D *robotPose=nullptr) const
This method is equivalent to:
Definition: CObservation.h:96
virtual void setSensorPose(const mrpt::poses::CPose3D &newSensorPose)=0
A general method to change the sensor pose on the robot.
virtual void load() const
Makes sure all images and other fields which may be externally stored are loaded in memory...
Definition: CObservation.h:151
GLsizei const GLchar ** string
Definition: glext.h:4101
std::string sensorLabel
An arbitrary label that can be used to identify the sensor.
Definition: CObservation.h:60
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::system::TTimeStamp timestamp
The associated UTC time-stamp.
Definition: CObservation.h:58
virtual void unload()
Unload all images, for the case they being delayed-load images stored in external files (othewise...
Definition: CObservation.h:156
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
Declares a class that represents any robot&#39;s observation.
Definition: CObservation.h:41
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
virtual void getDescriptionAsText(std::ostream &o) const
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019