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