Main MRPT website > C++ reference
MRPT logo
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-2014, 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/utils/CStream.h>
17 #include <mrpt/system/os.h>
18 #include <mrpt/system/datetime.h>
19 
20 /** The main namespace for all the Mobile Robot Programming Toolkit (MRPT) C++ libraries. */
21 namespace mrpt
22 {
23  namespace poses
24  {
25  class CPosePDF;
26  class CPose2D;
27  class CPose3D;
28  }
29 
30  namespace math { struct TPose3D; }
31 
32  /** This namespace contains algorithms for SLAM, localization, map building, representation of robot's actions and observations, and representation of many kinds of metric maps.
33  */
34  namespace slam
35  {
36  using namespace poses;
37 
38  /** Used for CObservationBearingRange::TMeasurement::beaconID
39  * \ingroup mrpt_obs_grp
40  */
41  #define INVALID_LANDMARK_ID (-1)
42 
43  /** Used for CObservationBeaconRange
44  * \ingroup mrpt_obs_grp
45  */
46  #define INVALID_BEACON_ID (-1)
47 
49 
50  /** Declares a class that represents any robot's observation.
51  * This is a base class for many types of sensor observations.
52  * Users can add new observation types creating a new class deriving from this one.
53  *
54  * <b>IMPORTANT</b>: Observations don't include any information about the robot pose,
55  * just raw sensory data and, where aplicable, information about the sensor position and
56  * orientation in the local frame of the robot.
57  *
58  * \sa CSensoryFrame, CMetricMap
59  * \ingroup mrpt_obs_grp
60  */
61  class OBS_IMPEXP CObservation : public mrpt::utils::CSerializable
62  {
63  // This must be added to any CSerializable derived class:
65 
66  protected:
67  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.
68 
69  public:
70 
71  /** @name Data common to any observation
72  @{ */
73 
74  /** The associated time-stamp.
75  */
77 
78  /** An arbitrary label that can be used to identify the sensor.
79  */
80  std::string sensorLabel;
81 
82  /** @} */
83 
84  /** Constructor: It sets the initial timestamp to current time
85  */
86  CObservation();
87 
88 
89  /** This method is equivalent to:
90  * \code
91  * map->insertObservation(this, robotPose)
92  * \endcode
93  * \param theMap The map where this observation is to be inserted: the map will be updated.
94  * \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)
95  *
96  * \return Returns true if the map has been updated, or false if this observations
97  * has nothing to do with a metric map (for example, a sound observation).
98  *
99  * \sa CMetricMap, CMetricMap::insertObservation
100  */
101  template <class METRICMAP>
102  inline bool insertObservationInto( METRICMAP *theMap, const CPose3D *robotPose = NULL ) const
103  {
104  return theMap->insertObservation(this,robotPose);
105  }
106 
107  /** A general method to retrieve the sensor pose on the robot.
108  * Note that most sensors will return a full (6D) CPose3D, but see the derived classes for more details or special cases.
109  * \sa setSensorPose
110  */
111  virtual void getSensorPose( 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 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 derived classes for more details or special cases.
121  * \sa getSensorPose
122  */
123  virtual void setSensorPose( const CPose3D &newSensorPose ) = 0;
124 
125  /** A general method to change the sensor pose on the robot.
126  * Note that most sensors will use the full (6D) CPose3D, but see the derived classes for more details or special cases.
127  * \sa getSensorPose
128  */
129  void setSensorPose( const mrpt::math::TPose3D &newSensorPose );
130 
131  /** @name Delayed-load manual control methods.
132  @{ */
133 
134  /** Makes sure all images and other fields which may be externally stored are loaded in memory.
135  * 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.
136  * If all the data were alredy loaded or this object has no externally stored data fields, calling this method has no effects.
137  * \sa unload
138  */
139  virtual void load() const { /* Default implementation: do nothing */ }
140  /** Unload all images, for the case they being delayed-load images stored in external files (othewise, has no effect).
141  * \sa load
142  */
143  virtual void unload() { /* Default implementation: do nothing */ }
144 
145  /** @} */
146 
147  }; // End of class def.
148 
149 
150  } // End of namespace
151 } // End of namespace
152 
153 #endif
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:28
mrpt::system::TTimeStamp timestamp
The associated time-stamp.
Definition: CObservation.h:76
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:32
virtual void unload()
Unload all images, for the case they being delayed-load images stored in external files (othewise...
Definition: CObservation.h:143
#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...
Declares a class that represents any robot&#39;s observation.
Definition: CObservation.h:61
std::string sensorLabel
An arbitrary label that can be used to identify the sensor.
Definition: CObservation.h:80
bool insertObservationInto(METRICMAP *theMap, const CPose3D *robotPose=NULL) const
This method is equivalent to:
Definition: CObservation.h:102
virtual void load() const
Makes sure all images and other fields which may be externally stored are loaded in memory...
Definition: CObservation.h:139
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:71
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).



Page generated by Doxygen 1.8.14 for MRPT 1.1.0 SVN: at lun oct 28 00:54:49 CET 2019 Hosted on:
SourceForge.net Logo