0.3.0
Loading...
Searching...
No Matches
Units.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 <cstddef>
17#include <string>
18
19#include "Navigation/Transformations/Units.hpp"
20#include "util/Eigen.hpp"
21#include "util/Json.hpp"
22
23namespace NAV
24{
25
26namespace Units
27{
28
30enum class ImuAccelerometerUnits : uint8_t
31{
32 m_s2,
33 COUNT,
34};
35
37enum class ImuGyroscopeUnits : uint8_t
38{
39 rad_s,
40 deg_s,
41 COUNT,
42};
43
45enum class ImuAccelerometerNoiseUnits : uint8_t
46{
49 COUNT,
50};
51
53enum class ImuGyroscopeNoiseUnits : uint8_t
54{
59 COUNT,
60};
61
63enum class ImuAccelerometerIRWUnits : uint8_t
64{
67 COUNT,
68};
69
71enum class ImuGyroscopeIRWUnits : uint8_t
72{
77 COUNT,
78};
79
83void to_json(json& j, const ImuAccelerometerUnits& data);
87void from_json(const json& j, ImuAccelerometerUnits& data);
88
92void to_json(json& j, const ImuGyroscopeUnits& data);
96void from_json(const json& j, ImuGyroscopeUnits& data);
97
101void to_json(json& j, const ImuAccelerometerNoiseUnits& data);
105void from_json(const json& j, ImuAccelerometerNoiseUnits& data);
106
110void to_json(json& j, const ImuGyroscopeNoiseUnits& data);
114void from_json(const json& j, ImuGyroscopeNoiseUnits& data);
115
119void to_json(json& j, const ImuAccelerometerIRWUnits& data);
123void from_json(const json& j, ImuAccelerometerIRWUnits& data);
124
128void to_json(json& j, const ImuGyroscopeIRWUnits& data);
132void from_json(const json& j, ImuGyroscopeIRWUnits& data);
133
134} // namespace Units
135
140template<typename Derived>
141[[nodiscard]] typename Derived::PlainObject convertUnit(const Eigen::MatrixBase<Derived>& value, Units::ImuAccelerometerUnits unit)
142{
143 switch (unit)
144 {
145 case Units::ImuAccelerometerUnits::m_s2:
146 return value;
147 case Units::ImuAccelerometerUnits::COUNT:
148 break;
149 }
150 return value;
151}
152
157template<typename Derived>
158[[nodiscard]] typename Derived::PlainObject convertUnit(const Eigen::MatrixBase<Derived>& value, Units::ImuGyroscopeUnits unit)
159{
160 switch (unit)
161 {
162 case Units::ImuGyroscopeUnits::rad_s:
163 return value;
164 case Units::ImuGyroscopeUnits::deg_s:
165 return deg2rad(value);
166 case Units::ImuGyroscopeUnits::COUNT:
167 break;
168 }
169 return value;
170}
171
176template<typename Derived>
177[[nodiscard]] typename Derived::PlainObject convertUnit(const Eigen::MatrixBase<Derived>& value, Units::ImuAccelerometerNoiseUnits unit)
178{
179 switch (unit)
180 {
181 case Units::ImuAccelerometerNoiseUnits::m_s2_sqrts:
182 return value;
183 case Units::ImuAccelerometerNoiseUnits::m_s2_sqrth:
184 return value / 60.0;
185 case Units::ImuAccelerometerNoiseUnits::COUNT:
186 break;
187 }
188 return value;
189}
190
195template<typename Derived>
196[[nodiscard]] typename Derived::PlainObject convertUnit(const Eigen::MatrixBase<Derived>& value, Units::ImuGyroscopeNoiseUnits unit)
197{
198 switch (unit)
199 {
200 case Units::ImuGyroscopeNoiseUnits::rad_s_sqrts:
201 return value;
202 case Units::ImuGyroscopeNoiseUnits::rad_s_sqrth:
203 return value / 60.0;
204 case Units::ImuGyroscopeNoiseUnits::deg_s_sqrts:
205 return deg2rad(value);
206 case Units::ImuGyroscopeNoiseUnits::deg_s_sqrth:
207 return deg2rad(value) / 60.0;
208 case Units::ImuGyroscopeNoiseUnits::COUNT:
209 break;
210 }
211 return value;
212}
213
218template<typename Derived>
219[[nodiscard]] typename Derived::PlainObject convertUnit(const Eigen::MatrixBase<Derived>& value, Units::ImuAccelerometerIRWUnits unit)
220{
221 switch (unit)
222 {
223 case Units::ImuAccelerometerIRWUnits::m_s3_sqrts:
224 return value;
225 case Units::ImuAccelerometerIRWUnits::m_s3_sqrth:
226 return value / 60.0;
227 case Units::ImuAccelerometerIRWUnits::COUNT:
228 break;
229 }
230 return value;
231}
232
237template<typename Derived>
238[[nodiscard]] typename Derived::PlainObject convertUnit(const Eigen::MatrixBase<Derived>& value, Units::ImuGyroscopeIRWUnits unit)
239{
240 switch (unit)
241 {
242 case Units::ImuGyroscopeIRWUnits::rad_s2_sqrts:
243 return value;
244 case Units::ImuGyroscopeIRWUnits::rad_s2_sqrth:
245 return value / 60.0;
246 case Units::ImuGyroscopeIRWUnits::deg_s2_sqrts:
247 return deg2rad(value);
248 case Units::ImuGyroscopeIRWUnits::deg_s2_sqrth:
249 return deg2rad(value) / 60.0;
250 case Units::ImuGyroscopeIRWUnits::COUNT:
251 break;
252 }
253 return value;
254}
255
258[[nodiscard]] std::string to_string(Units::ImuAccelerometerUnits unit);
261[[nodiscard]] std::string to_string(Units::ImuGyroscopeUnits unit);
264[[nodiscard]] std::string to_string(Units::ImuAccelerometerNoiseUnits unit);
267[[nodiscard]] std::string to_string(Units::ImuGyroscopeNoiseUnits unit);
270[[nodiscard]] std::string to_string(Units::ImuAccelerometerIRWUnits unit);
273[[nodiscard]] std::string to_string(Units::ImuGyroscopeIRWUnits unit);
274
275} // namespace NAV
Vector space operations.
nlohmann::json json
json namespace
Definition FlowManager.hpp:21
double convertUnit(const double &value, Units::CovarianceAccelUnits unit)
Converts the value depending on the unit provided.
ImuGyroscopeUnits
Possible units to specify an gyroscope bias with.
Definition Units.hpp:38
ImuAccelerometerIRWUnits
Possible units to specify an accelerometer IRW.
Definition Units.hpp:64
@ m_s3_sqrth
[m/s^3/sqrt(h)] (Standard deviation)
@ m_s3_sqrts
[m/s^3/sqrt(s)] (Standard deviation)
ImuAccelerometerNoiseUnits
Possible units to specify an accelerometer noise.
Definition Units.hpp:46
@ m_s2_sqrts
[m/s^2/sqrt(s)] (Standard deviation)
@ m_s2_sqrth
[m/s^2/sqrt(h)] (Standard deviation)
ImuGyroscopeIRWUnits
Possible units to specify an gyro RW.
Definition Units.hpp:72
@ rad_s2_sqrth
[rad/s^2/sqrt(h)] (Standard deviation)
@ deg_s2_sqrth
[deg/s^2/sqrt(h)] (Standard deviation)
@ deg_s2_sqrts
[deg/s^2/sqrt(s)] (Standard deviation)
@ rad_s2_sqrts
[rad/s^2/sqrt(s)] (Standard deviation)
ImuGyroscopeNoiseUnits
Possible units to specify an gyro noise.
Definition Units.hpp:54
@ deg_s_sqrth
[deg/s/sqrt(h)] (Standard deviation)
@ rad_s_sqrts
[rad/s/sqrt(s)] (Standard deviation)
@ rad_s_sqrth
[rad/s/sqrt(h)] (Standard deviation)
@ deg_s_sqrts
[deg/s/sqrt(s)] (Standard deviation)
ImuAccelerometerUnits
Possible units to specify an accelerometer with.
Definition Units.hpp:31
@ COUNT
Amount of items in the enum.
Defines how to save certain datatypes to json.
const char * to_string(gui::widgets::PositionWithFrame::ReferenceFrame refFrame)
Converts the enum to a string.