MRPT  2.0.4
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-2020, 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 
11 #include <mrpt/math/TPose3D.h>
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 
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. */
62  std::string sensorLabel;
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  /** Return by value version of getDescriptionAsText(std::ostream&) */
143  std::string getDescriptionAsTextValue() const;
144 
145  /** @name Delayed-load manual control methods.
146  @{ */
147 
148  /** Makes sure all images and other fields which may be externally stored
149  * are loaded in memory.
150  * Note that for all CImages, calling load() is not required since the
151  * images will be automatically loaded upon first access, so load()
152  * shouldn't be needed to be called in normal cases by the user.
153  * If all the data were alredy loaded or this object has no externally
154  * stored data fields, calling this method has no effects.
155  * \sa unload
156  */
157  virtual void load() const
158  { /* Default implementation: do nothing */
159  }
160  /** Unload all images, for the case they being delayed-load images stored in
161  * external files (othewise, has no effect).
162  * \sa load
163  */
164  virtual void unload()
165  { /* Default implementation: do nothing */
166  }
167 
168  /** @} */
169 
170 }; // End of class def.
171 
172 } // namespace obs
173 } // namespace mrpt
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:86
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:157
std::string getDescriptionAsTextValue() const
Return by value version of getDescriptionAsText(std::ostream&)
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:164
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:85
Declares a class that represents any robot&#39;s observation.
Definition: CObservation.h:43
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
Definition: TPose3D.h:24
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 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020