MRPT  2.0.3
CObservationIMU.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/CMatrixD.h>
12 #include <mrpt/obs/CObservation.h>
13 #include <mrpt/poses/CPose2D.h>
14 #include <mrpt/poses/CPose3D.h>
16 
17 namespace mrpt::obs
18 {
19 /** Symbolic names for the indices of IMU data (refer to
20  * mrpt::obs::CObservationIMU)
21  * \ingroup mrpt_obs_grp
22  */
24 {
25  /** x-axis acceleration (local/vehicle frame) (m/sec<sup>2</sup>) */
26  IMU_X_ACC = 0,
27  /** y-axis acceleration (local/vehicle frame) (m/sec<sup>2</sup>) */
29  /** z-axis acceleration (local/vehicle frame) (m/sec<sup>2</sup>) */
31  /** yaw angular velocity (local/vehicle frame) (rad/sec) */
33  /** angular velocity - z (local/vehicle frame) (rad/sec) */
35  /** pitch angular velocity (local/vehicle frame) (rad/sec) */
37  /** angular velocity - y (local/vehicle frame) (rad/sec) */
39  /** roll angular velocity (local/vehicle frame) (rad/sec) */
41  /** angular velocity - x (local/vehicle frame) (rad/sec) */
43  /** x-axis velocity (global/navigation frame) (m/sec) */
45  /** y-axis velocity (global/navigation frame) (m/sec) */
47  /** z-axis velocity (global/navigation frame) (m/sec) */
49  /** orientation yaw absolute value (global/navigation frame) (rad) */
51  /** orientation pitch absolute value (global/navigation frame) (rad) */
53  /** orientation roll absolute value (global/navigation frame) (rad) */
55  /** x absolute value (global/navigation frame) (meters) */
57  /** y absolute value (global/navigation frame) (meters) */
59  /** z absolute value (global/navigation frame) (meters) */
61  /** x magnetic field value (local/vehicle frame) (gauss) */
63  /** y magnetic field value (local/vehicle frame) (gauss) */
65  /** z magnetic field value (local/vehicle frame) (gauss) */
67  /** air pressure (Pascals) */
69  /** altitude from an altimeter (meters) */
71  /** temperature (degrees Celsius) */
73  /** Orientation Quaternion X (global/navigation frame) */
75  /** Orientation Quaternion Y (global/navigation frame) */
77  /** Orientation Quaternion Z (global/navigation frame) */
79  /** Orientation Quaternion W (global/navigation frame) */
81  /** yaw angular velocity (global/navigation frame) (rad/sec) */
83  /** pitch angular velocity (global/navigation frame) (rad/sec) */
85  /** roll angular velocity (global/navigation frame) (rad/sec) */
87  /** x-axis acceleration (global/navigation frame) (m/sec<sup>2</sup>) */
89  /** y-axis acceleration (global/navigation frame) (m/sec<sup>2</sup>) */
91  /** z-axis acceleration (global/navigation frame) (m/sec<sup>2</sup>) */
93 
94  // Always leave this last value to reflect the number of enum values
96 };
97 
98 /** This class stores measurements from an Inertial Measurement Unit (IMU)
99  * (attitude estimation, raw gyroscope and accelerometer values), altimeters or
100  * magnetometers.
101  *
102  * The order of the values in each entry of
103  * mrpt::obs::CObservationIMU::rawMeasurements is defined as symbolic names in
104  * the enum mrpt::obs::TIMUDataIndex.
105  * Check it out also for reference on the unit and the coordinate frame used
106  * for each value.
107  *
108  * \sa CObservation
109  * \ingroup mrpt_obs_grp
110  */
112 {
114 
115  public:
116  CObservationIMU() = default;
117  ~CObservationIMU() override = default;
118 
119  /** The pose of the sensor on the robot. */
121 
122  /** Each entry in this vector is true if the corresponding data index
123  * contains valid data (the IMU unit supplies that kind of data).
124  * See the top of this page for the meaning of the indices.
125  */
126  std::vector<bool> dataIsPresent =
127  std::vector<bool>(mrpt::obs::COUNT_IMU_DATA_FIELDS, false);
128 
129  /** The accelerometer and/or gyroscope measurements taken by the IMU at the
130  * given timestamp.
131  * \sa dataIsPresent, CObservation::timestamp
132  */
133  std::vector<double> rawMeasurements =
134  std::vector<double>(mrpt::obs::COUNT_IMU_DATA_FIELDS, 0);
135 
136  /** Sets a given data type, and mark it as present. \sa has(), set() */
137  void set(TIMUDataIndex idx, double value)
138  {
139  rawMeasurements.at(idx) = value;
140  dataIsPresent.at(idx) = true;
141  }
142 
143  /** Gets a given data type, throws if not set. \sa has(), get() */
144  double get(TIMUDataIndex idx) const
145  {
146  ASSERTMSG_(dataIsPresent.at(idx), "Trying to access non-set value");
147  return rawMeasurements.at(idx);
148  }
149  /** Returns true if the given data type is set. \sa set(), get() */
150  bool has(TIMUDataIndex idx) const { return dataIsPresent.at(idx); }
151 
152  // See base class docs
153  void getSensorPose(mrpt::poses::CPose3D& out_sensorPose) const override
154  {
155  out_sensorPose = sensorPose;
156  }
157  void setSensorPose(const mrpt::poses::CPose3D& newSensorPose) override
158  {
159  sensorPose = newSensorPose;
160  }
161  void getDescriptionAsText(std::ostream& o) const override;
162 
163 }; // End of class def.
164 
165 } // namespace mrpt::obs
mrpt::obs::IMU_YAW_VEL_GLOBAL
@ IMU_YAW_VEL_GLOBAL
yaw angular velocity (global/navigation frame) (rad/sec)
Definition: CObservationIMU.h:82
mrpt::obs::IMU_X_ACC_GLOBAL
@ IMU_X_ACC_GLOBAL
x-axis acceleration (global/navigation frame) (m/sec2)
Definition: CObservationIMU.h:88
mrpt::obs::IMU_MAG_Y
@ IMU_MAG_Y
y magnetic field value (local/vehicle frame) (gauss)
Definition: CObservationIMU.h:64
mrpt::obs::CObservationIMU::rawMeasurements
std::vector< double > rawMeasurements
The accelerometer and/or gyroscope measurements taken by the IMU at the given timestamp.
Definition: CObservationIMU.h:133
mrpt::obs::IMU_ALTITUDE
@ IMU_ALTITUDE
altitude from an altimeter (meters)
Definition: CObservationIMU.h:70
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name, NS)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:152
mrpt::obs::IMU_Z_VEL
@ IMU_Z_VEL
z-axis velocity (global/navigation frame) (m/sec)
Definition: CObservationIMU.h:48
mrpt::obs::IMU_PITCH
@ IMU_PITCH
orientation pitch absolute value (global/navigation frame) (rad)
Definition: CObservationIMU.h:52
mrpt::obs::CObservationIMU::setSensorPose
void setSensorPose(const mrpt::poses::CPose3D &newSensorPose) override
A general method to change the sensor pose on the robot.
Definition: CObservationIMU.h:157
mrpt::obs::IMU_MAG_X
@ IMU_MAG_X
x magnetic field value (local/vehicle frame) (gauss)
Definition: CObservationIMU.h:62
mrpt::obs::IMU_ROLL_VEL
@ IMU_ROLL_VEL
roll angular velocity (local/vehicle frame) (rad/sec)
Definition: CObservationIMU.h:40
mrpt::obs::IMU_WY
@ IMU_WY
angular velocity - y (local/vehicle frame) (rad/sec)
Definition: CObservationIMU.h:38
mrpt::obs::IMU_ROLL
@ IMU_ROLL
orientation roll absolute value (global/navigation frame) (rad)
Definition: CObservationIMU.h:54
mrpt::obs::CObservationIMU::getSensorPose
void getSensorPose(mrpt::poses::CPose3D &out_sensorPose) const override
A general method to retrieve the sensor pose on the robot.
Definition: CObservationIMU.h:153
mrpt::obs::IMU_PRESSURE
@ IMU_PRESSURE
air pressure (Pascals)
Definition: CObservationIMU.h:68
mrpt::obs::CObservationIMU
This class stores measurements from an Inertial Measurement Unit (IMU) (attitude estimation,...
Definition: CObservationIMU.h:111
CPose2D.h
mrpt::obs::IMU_WZ
@ IMU_WZ
angular velocity - z (local/vehicle frame) (rad/sec)
Definition: CObservationIMU.h:34
mrpt::obs
This namespace contains representation of robot actions and observations.
Definition: CParticleFilter.h:17
mrpt::obs::IMU_ORI_QUAT_W
@ IMU_ORI_QUAT_W
Orientation Quaternion W (global/navigation frame)
Definition: CObservationIMU.h:80
mrpt::obs::IMU_PITCH_VEL
@ IMU_PITCH_VEL
pitch angular velocity (local/vehicle frame) (rad/sec)
Definition: CObservationIMU.h:36
mrpt::obs::IMU_Y_VEL
@ IMU_Y_VEL
y-axis velocity (global/navigation frame) (m/sec)
Definition: CObservationIMU.h:46
mrpt::obs::COUNT_IMU_DATA_FIELDS
@ COUNT_IMU_DATA_FIELDS
Definition: CObservationIMU.h:95
mrpt::obs::IMU_Z_ACC
@ IMU_Z_ACC
z-axis acceleration (local/vehicle frame) (m/sec2)
Definition: CObservationIMU.h:30
mrpt::obs::CObservationIMU::CObservationIMU
CObservationIMU()=default
mrpt::obs::IMU_MAG_Z
@ IMU_MAG_Z
z magnetic field value (local/vehicle frame) (gauss)
Definition: CObservationIMU.h:66
mrpt::obs::IMU_ORI_QUAT_Y
@ IMU_ORI_QUAT_Y
Orientation Quaternion Y (global/navigation frame)
Definition: CObservationIMU.h:76
mrpt::obs::IMU_TEMPERATURE
@ IMU_TEMPERATURE
temperature (degrees Celsius)
Definition: CObservationIMU.h:72
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:85
mrpt::obs::CObservationIMU::get
double get(TIMUDataIndex idx) const
Gets a given data type, throws if not set.
Definition: CObservationIMU.h:144
mrpt::obs::IMU_Y
@ IMU_Y
y absolute value (global/navigation frame) (meters)
Definition: CObservationIMU.h:58
mrpt::obs::IMU_Z_ACC_GLOBAL
@ IMU_Z_ACC_GLOBAL
z-axis acceleration (global/navigation frame) (m/sec2)
Definition: CObservationIMU.h:92
mrpt::obs::IMU_X_ACC
@ IMU_X_ACC
x-axis acceleration (local/vehicle frame) (m/sec2)
Definition: CObservationIMU.h:26
CMatrixD.h
mrpt::obs::IMU_ORI_QUAT_Z
@ IMU_ORI_QUAT_Z
Orientation Quaternion Z (global/navigation frame)
Definition: CObservationIMU.h:78
mrpt::obs::CObservationIMU::dataIsPresent
std::vector< bool > dataIsPresent
Each entry in this vector is true if the corresponding data index contains valid data (the IMU unit s...
Definition: CObservationIMU.h:126
ASSERTMSG_
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
Definition: exceptions.h:108
CPose3D.h
mrpt::obs::IMU_Y_ACC
@ IMU_Y_ACC
y-axis acceleration (local/vehicle frame) (m/sec2)
Definition: CObservationIMU.h:28
mrpt::obs::TIMUDataIndex
TIMUDataIndex
Symbolic names for the indices of IMU data (refer to mrpt::obs::CObservationIMU)
Definition: CObservationIMU.h:23
mrpt::obs::CObservationIMU::has
bool has(TIMUDataIndex idx) const
Returns true if the given data type is set.
Definition: CObservationIMU.h:150
mrpt::obs::IMU_X
@ IMU_X
x absolute value (global/navigation frame) (meters)
Definition: CObservationIMU.h:56
CObservation.h
mrpt::obs::IMU_PITCH_VEL_GLOBAL
@ IMU_PITCH_VEL_GLOBAL
pitch angular velocity (global/navigation frame) (rad/sec)
Definition: CObservationIMU.h:84
mrpt::obs::CObservationIMU::sensorPose
mrpt::poses::CPose3D sensorPose
The pose of the sensor on the robot.
Definition: CObservationIMU.h:120
mrpt::obs::CObservationIMU::getDescriptionAsText
void getDescriptionAsText(std::ostream &o) const override
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...
Definition: CObservationIMU.cpp:97
mrpt::obs::CObservation
Declares a class that represents any robot's observation.
Definition: CObservation.h:43
mrpt::obs::IMU_YAW
@ IMU_YAW
orientation yaw absolute value (global/navigation frame) (rad)
Definition: CObservationIMU.h:50
mrpt::obs::IMU_ROLL_VEL_GLOBAL
@ IMU_ROLL_VEL_GLOBAL
roll angular velocity (global/navigation frame) (rad/sec)
Definition: CObservationIMU.h:86
mrpt::obs::IMU_YAW_VEL
@ IMU_YAW_VEL
yaw angular velocity (local/vehicle frame) (rad/sec)
Definition: CObservationIMU.h:32
mrpt::obs::IMU_Y_ACC_GLOBAL
@ IMU_Y_ACC_GLOBAL
y-axis acceleration (global/navigation frame) (m/sec2)
Definition: CObservationIMU.h:90
CSerializable.h
mrpt::obs::CObservationIMU::set
void set(TIMUDataIndex idx, double value)
Sets a given data type, and mark it as present.
Definition: CObservationIMU.h:137
mrpt::obs::IMU_WX
@ IMU_WX
angular velocity - x (local/vehicle frame) (rad/sec)
Definition: CObservationIMU.h:42
mrpt::obs::IMU_Z
@ IMU_Z
z absolute value (global/navigation frame) (meters)
Definition: CObservationIMU.h:60
mrpt::obs::CObservationIMU::~CObservationIMU
~CObservationIMU() override=default
mrpt::obs::IMU_ORI_QUAT_X
@ IMU_ORI_QUAT_X
Orientation Quaternion X (global/navigation frame)
Definition: CObservationIMU.h:74
mrpt::obs::IMU_X_VEL
@ IMU_X_VEL
x-axis velocity (global/navigation frame) (m/sec)
Definition: CObservationIMU.h:44



Page generated by Doxygen 1.8.17 for MRPT 2.0.3 at Fri May 29 13:06:46 UTC 2020