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