0.2.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#include "util/Eigen.hpp"
20
21namespace NAV
22{
24class ImuObs : public NodeData
25{
26 public:
29 explicit ImuObs(const ImuPos& imuPos)
30 : imuPos(imuPos) {}
31
34 [[nodiscard]] static std::string type()
35 {
36 return "ImuObs";
37 }
38
41 [[nodiscard]] static std::vector<std::string> parentTypes()
42 {
43 return { NodeData::type() };
44 }
45
47 [[nodiscard]] static std::vector<std::string> GetStaticDataDescriptors()
48 {
49 return {
50 "Time since startup [ns]",
51 "Accel X [m/s^2]",
52 "Accel Y [m/s^2]",
53 "Accel Z [m/s^2]",
54 "Gyro X [rad/s]",
55 "Gyro Y [rad/s]",
56 "Gyro Z [rad/s]",
57 "Mag X [Gauss]",
58 "Mag Y [Gauss]",
59 "Mag Z [Gauss]",
60 "Temperature [°C]",
61 };
62 }
63
65 [[nodiscard]] static constexpr size_t GetStaticDescriptorCount() { return 11; }
66
68 [[nodiscard]] std::vector<std::string> staticDataDescriptors() const override { return GetStaticDataDescriptors(); }
69
71 [[nodiscard]] size_t staticDescriptorCount() const override { return GetStaticDescriptorCount(); }
72
76 [[nodiscard]] std::optional<double> getValueAt(size_t idx) const override
77 {
79 switch (idx)
80 {
81 case 0: // Time since startup [ns]
82 if (timeSinceStartup.has_value()) { return static_cast<double>(timeSinceStartup.value()); }
83 break;
84 case 1: // Accel X [m/s^2]
85 return p_acceleration.x();
86 case 2: // Accel Y [m/s^2]
87 return p_acceleration.y();
88 case 3: // Accel Z [m/s^2]
89 return p_acceleration.z();
90 case 4: // Gyro X [rad/s]
91 return p_angularRate.x();
92 case 5: // Gyro Y [rad/s]
93 return p_angularRate.y();
94 case 6: // Gyro Z [rad/s]
95 return p_angularRate.z();
96 case 7: // Mag X [Gauss]
97 if (p_magneticField.has_value()) { return p_magneticField->x(); }
98 break;
99 case 8: // Mag Y [Gauss]
100 if (p_magneticField.has_value()) { return p_magneticField->y(); }
101 break;
102 case 9: // Mag Z [Gauss]
103 if (p_magneticField.has_value()) { return p_magneticField->z(); }
104 break;
105 case 10: // Temperature [°C]
106 if (temperature.has_value()) { return temperature.value(); }
107 break;
108 default:
109 return std::nullopt;
110 }
111 return std::nullopt;
112 }
113
116
118 std::optional<uint64_t> timeSinceStartup;
119
121 Eigen::Vector3d p_acceleration;
123 Eigen::Vector3d p_angularRate;
124
126 std::optional<Eigen::Vector3d> p_magneticField;
128 std::optional<double> temperature = 0.0;
129};
130
131} // namespace NAV
#define INS_ASSERT(_EXPR)
Assert function wrapper.
Definition Assert.h:19
Vector space operations.
Imu Position Data.
Abstract NodeData Class.
IMU Observation storage class.
Definition ImuObs.hpp:25
Eigen::Vector3d p_acceleration
The IMU acceleration measured in units of [m/s^2], given in the platform frame.
Definition ImuObs.hpp:121
std::optional< double > temperature
The IMU temperature measured in units of [Celsius].
Definition ImuObs.hpp:128
static std::string type()
Returns the type of the data class.
Definition ImuObs.hpp:34
Eigen::Vector3d p_angularRate
The IMU angular rate measured in units of [rad/s], given in the platform frame.
Definition ImuObs.hpp:123
std::optional< uint64_t > timeSinceStartup
The system time since startup measured in [nano seconds].
Definition ImuObs.hpp:118
std::vector< std::string > staticDataDescriptors() const override
Returns a vector of data descriptors.
Definition ImuObs.hpp:68
static std::vector< std::string > parentTypes()
Returns the parent types of the data class.
Definition ImuObs.hpp:41
static std::vector< std::string > GetStaticDataDescriptors()
Returns a vector of data descriptors.
Definition ImuObs.hpp:47
static constexpr size_t GetStaticDescriptorCount()
Get the amount of descriptors.
Definition ImuObs.hpp:65
std::optional< double > getValueAt(size_t idx) const override
Get the value at the index.
Definition ImuObs.hpp:76
ImuObs(const ImuPos &imuPos)
Constructor.
Definition ImuObs.hpp:29
size_t staticDescriptorCount() const override
Get the amount of descriptors.
Definition ImuObs.hpp:71
const ImuPos & imuPos
Position and rotation information for conversion from platform to body frame.
Definition ImuObs.hpp:115
std::optional< Eigen::Vector3d > p_magneticField
The IMU magnetic field measured in units of [Gauss], given in the platform frame.
Definition ImuObs.hpp:126
IMU Position.
Definition ImuPos.hpp:26
Parent class for all data transmitted over Flow pins.
Definition NodeData.hpp:27
static std::string type()
Returns the type of the data class.
Definition NodeData.hpp:44