0.3.0
Loading...
Searching...
No Matches
ImuObs.hpp
Go to the documentation of this file.
1// This file is part of INSTINCT, the INS Toolkit for Integrated
2// Navigation Concepts and Training by the Institute of Navigation of
3// the University of Stuttgart, Germany.
4//
5// This Source Code Form is subject to the terms of the Mozilla Public
6// License, v. 2.0. If a copy of the MPL was not distributed with this
7// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
13
14#pragma once
15
16#include "NodeData/NodeData.hpp"
17
18#include "ImuPos.hpp"
19
20namespace NAV
21{
23class ImuObs : public NodeData
24{
25 public:
28 explicit ImuObs(const ImuPos& imuPos)
29 : imuPos(imuPos) {}
30
33 [[nodiscard]] static std::string type()
34 {
35 return "ImuObs";
36 }
37
40 [[nodiscard]] std::string getType() const override { return type(); }
41
44 [[nodiscard]] static std::vector<std::string> parentTypes()
45 {
46 return { NodeData::type() };
47 }
48
50 [[nodiscard]] static std::vector<std::string> GetStaticDataDescriptors()
51 {
52 return {
53 "Accel X [m/s^2]",
54 "Accel Y [m/s^2]",
55 "Accel Z [m/s^2]",
56 "Gyro X [rad/s]",
57 "Gyro Y [rad/s]",
58 "Gyro Z [rad/s]",
59 "Mag X [Gauss]",
60 "Mag Y [Gauss]",
61 "Mag Z [Gauss]",
62 "Temperature [°C]",
63 };
64 }
65
67 [[nodiscard]] static constexpr size_t GetStaticDescriptorCount() { return 10; }
68
70 [[nodiscard]] std::vector<std::string> staticDataDescriptors() const override { return GetStaticDataDescriptors(); }
71
73 [[nodiscard]] size_t staticDescriptorCount() const override { return GetStaticDescriptorCount(); }
74
78 [[nodiscard]] std::optional<double> getValueAt(size_t idx) const override
79 {
81 switch (idx)
82 {
83 case 0: // Accel X [m/s^2]
84 return p_acceleration.x();
85 case 1: // Accel Y [m/s^2]
86 return p_acceleration.y();
87 case 2: // Accel Z [m/s^2]
88 return p_acceleration.z();
89 case 3: // Gyro X [rad/s]
90 return p_angularRate.x();
91 case 4: // Gyro Y [rad/s]
92 return p_angularRate.y();
93 case 5: // Gyro Z [rad/s]
94 return p_angularRate.z();
95 case 6: // Mag X [Gauss]
96 if (p_magneticField.has_value()) { return p_magneticField->x(); }
97 break;
98 case 7: // Mag Y [Gauss]
99 if (p_magneticField.has_value()) { return p_magneticField->y(); }
100 break;
101 case 8: // Mag Z [Gauss]
102 if (p_magneticField.has_value()) { return p_magneticField->z(); }
103 break;
104 case 9: // Temperature [°C]
105 return temperature;
106 default:
107 return std::nullopt;
108 }
109 return std::nullopt;
110 }
111
116 [[nodiscard]] bool setValueAt(size_t idx, double value) override
117 {
119
120 switch (idx)
121 {
122 case 0: // Accel X [m/s^2]
123 p_acceleration.x() = value;
124 return true;
125 case 1: // Accel Y [m/s^2]
126 p_acceleration.y() = value;
127 return true;
128 case 2: // Accel Z [m/s^2]
129 p_acceleration.z() = value;
130 return true;
131 case 3: // Gyro X [rad/s]
132 p_angularRate.x() = value;
133 return true;
134 case 4: // Gyro Y [rad/s]
135 p_angularRate.y() = value;
136 return true;
137 case 5: // Gyro Z [rad/s]
138 p_angularRate.z() = value;
139 return true;
140 case 6: // Mag X [Gauss]
141 if (p_magneticField.has_value())
142 {
143 p_magneticField->x() = value;
144 return true;
145 }
146 break;
147 case 7: // Mag Y [Gauss]
148 if (p_magneticField.has_value())
149 {
150 p_magneticField->y() = value;
151 return true;
152 }
153 break;
154 case 8: // Mag Z [Gauss]
155 if (p_magneticField.has_value())
156 {
157 p_magneticField->z() = value;
158 return true;
159 }
160 break;
161 case 9: // Temperature [°C]
162 temperature = value;
163 return true;
164 default:
165 return false;
166 }
167
168 return false;
169 }
170
173
175 Eigen::Vector3d p_acceleration;
177 Eigen::Vector3d p_angularRate;
178
180 std::optional<Eigen::Vector3d> p_magneticField;
182 std::optional<double> temperature = 0.0;
183};
184
185} // namespace NAV
#define INS_ASSERT(_EXPR)
Assert function wrapper.
Definition Assert.h:19
Imu Position Data.
Abstract NodeData Class.
Eigen::Vector3d p_acceleration
The IMU acceleration measured in units of [m/s^2], given in the platform frame.
Definition ImuObs.hpp:175
std::optional< double > temperature
The IMU temperature measured in units of [Celsius].
Definition ImuObs.hpp:182
bool setValueAt(size_t idx, double value) override
Set the value at the index.
Definition ImuObs.hpp:116
static std::string type()
Returns the type of the data class.
Definition ImuObs.hpp:33
Eigen::Vector3d p_angularRate
The IMU angular rate measured in units of [rad/s], given in the platform frame.
Definition ImuObs.hpp:177
std::vector< std::string > staticDataDescriptors() const override
Returns a vector of data descriptors.
Definition ImuObs.hpp:70
static std::vector< std::string > parentTypes()
Returns the parent types of the data class.
Definition ImuObs.hpp:44
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
Definition ImuObs.hpp:50
std::string getType() const override
Returns the type of the data class.
Definition ImuObs.hpp:40
static constexpr size_t GetStaticDescriptorCount()
Get the amount of descriptors.
Definition ImuObs.hpp:67
std::optional< double > getValueAt(size_t idx) const override
Get the value at the index.
Definition ImuObs.hpp:78
ImuObs(const ImuPos &imuPos)
Constructor.
Definition ImuObs.hpp:28
size_t staticDescriptorCount() const override
Get the amount of descriptors.
Definition ImuObs.hpp:73
const ImuPos & imuPos
Position and rotation information for conversion from platform to body frame.
Definition ImuObs.hpp:172
std::optional< Eigen::Vector3d > p_magneticField
The IMU magnetic field measured in units of [Gauss], given in the platform frame.
Definition ImuObs.hpp:180
IMU Position.
Definition ImuPos.hpp:26
NodeData()=default
Default constructor.
static std::string type()
Returns the type of the data class.
Definition NodeData.hpp:45