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
20#include "Navigation/Transformations/Units.hpp"
21#include "util/Eigen.hpp"
22#include "util/Json.hpp"
23
24namespace NAV
25{
26
27namespace Units
28{
29
31enum class ImuAccelerometerUnits : uint8_t
32{
34 g,
36};
37
39enum class ImuGyroscopeUnits : uint8_t
40{
44};
45
53
63
71
81
89
99
107
117
121void to_json(json& j, const ImuAccelerometerUnits& data);
126
130void to_json(json& j, const ImuGyroscopeUnits& data);
134void from_json(const json& j, ImuGyroscopeUnits& data);
135
144
148void to_json(json& j, const ImuGyroscopeNoiseUnits& data);
153
162
166void to_json(json& j, const ImuGyroscopeIRWUnits& data);
170void from_json(const json& j, ImuGyroscopeIRWUnits& data);
171
180
189
198
207
208} // namespace Units
209
214template<typename Derived>
215[[nodiscard]] typename Derived::PlainObject convertUnit(const Eigen::MatrixBase<Derived>& value, Units::ImuAccelerometerUnits unit)
216{
217 switch (unit)
218 {
220 return value;
222 return value * InsConst::G_NORM;
224 break;
225 }
226 return value;
227}
228
233template<typename Derived>
234[[nodiscard]] typename Derived::PlainObject convertUnit(const Eigen::MatrixBase<Derived>& value, Units::ImuGyroscopeUnits unit)
235{
236 switch (unit)
237 {
239 return value;
241 return deg2rad(value);
243 break;
244 }
245 return value;
246}
247
252template<typename Derived>
253[[nodiscard]] typename Derived::PlainObject convertUnit(const Eigen::MatrixBase<Derived>& value, Units::ImuAccelerometerNoiseUnits unit)
254{
255 switch (unit)
256 {
258 return value;
260 return value / 60.0;
262 break;
263 }
264 return value;
265}
266
271template<typename Derived>
272[[nodiscard]] typename Derived::PlainObject convertUnit(const Eigen::MatrixBase<Derived>& value, Units::ImuGyroscopeNoiseUnits unit)
273{
274 switch (unit)
275 {
277 return value;
279 return value / 60.0;
281 return deg2rad(value);
283 return deg2rad(value) / 60.0;
285 break;
286 }
287 return value;
288}
289
294template<typename Derived>
295[[nodiscard]] typename Derived::PlainObject convertUnit(const Eigen::MatrixBase<Derived>& value, Units::ImuAccelerometerIRWUnits unit)
296{
297 switch (unit)
298 {
300 return value;
302 return value / 60.0;
304 break;
305 }
306 return value;
307}
308
313template<typename Derived>
314[[nodiscard]] typename Derived::PlainObject convertUnit(const Eigen::MatrixBase<Derived>& value, Units::ImuGyroscopeIRWUnits unit)
315{
316 switch (unit)
317 {
319 return value;
321 return value / 60.0;
323 return deg2rad(value);
325 return deg2rad(value) / 60.0;
327 break;
328 }
329 return value;
330}
331
336template<typename Derived>
337[[nodiscard]] typename Derived::PlainObject convertUnit(const Eigen::MatrixBase<Derived>& value, Units::ImuAccelerometerFilterNoiseUnits unit)
338{
339 switch (unit)
340 {
342 return value;
344 return value * 1e-3 * InsConst::G_NORM;
346 break;
347 }
348 return value;
349}
350
355template<typename Derived>
356[[nodiscard]] typename Derived::PlainObject convertUnit(const Eigen::MatrixBase<Derived>& value, Units::ImuGyroscopeFilterNoiseUnits unit)
357{
358 switch (unit)
359 {
361 return value;
363 return value / 3600.0;
365 return deg2rad(value);
367 return deg2rad(value) / 3600.0;
369 break;
370 }
371 return value;
372}
373
378template<typename Derived>
379[[nodiscard]] typename Derived::PlainObject convertUnit(const Eigen::MatrixBase<Derived>& value, Units::ImuAccelerometerFilterBiasUnits unit)
380{
381 switch (unit)
382 {
384 return value;
386 return value * 1e-6 * InsConst::G_NORM;
388 break;
389 }
390 return value;
391}
392
397template<typename Derived>
398[[nodiscard]] typename Derived::PlainObject convertUnit(const Eigen::MatrixBase<Derived>& value, Units::ImuGyroscopeFilterBiasUnits unit)
399{
400 switch (unit)
401 {
403 return value;
405 return value / 3600.0;
407 return deg2rad(value);
409 return deg2rad(value) / 3600.0;
411 break;
412 }
413 return value;
414}
415
418[[nodiscard]] std::string to_string(Units::ImuAccelerometerUnits unit);
421[[nodiscard]] std::string to_string(Units::ImuGyroscopeUnits unit);
424[[nodiscard]] std::string to_string(Units::ImuAccelerometerNoiseUnits unit);
427[[nodiscard]] std::string to_string(Units::ImuGyroscopeNoiseUnits unit);
430[[nodiscard]] std::string to_string(Units::ImuAccelerometerIRWUnits unit);
433[[nodiscard]] std::string to_string(Units::ImuGyroscopeIRWUnits unit);
439[[nodiscard]] std::string to_string(Units::ImuGyroscopeFilterNoiseUnits unit);
442[[nodiscard]] std::string to_string(Units::ImuAccelerometerFilterBiasUnits unit);
445[[nodiscard]] std::string to_string(Units::ImuGyroscopeFilterBiasUnits unit);
446
447} // namespace NAV
Holds all Constants.
Vector space operations.
nlohmann::json json
json namespace
Definition FlowManager.hpp:21
void to_json(json &j, const PositionUncertaintyUnits &data)
Converts the provided data into a json object.
@ COUNT
Amount of items in the enum.
Definition Units.hpp:33
double convertUnit(const double &value, Units::PositionUncertaintyUnits unit)
Converts the value depending on the unit provided.
void from_json(const json &j, PositionUncertaintyUnits &data)
Converts the provided json object into the data object.
ImuGyroscopeUnits
Possible units to specify an gyroscope bias with.
Definition Units.hpp:40
@ deg_s
[deg/s]
Definition Units.hpp:42
@ COUNT
Amount of items in the enum.
Definition Units.hpp:43
@ rad_s
[rad/s]
Definition Units.hpp:41
ImuAccelerometerIRWUnits
Possible units to specify an accelerometer IRW.
Definition Units.hpp:66
@ COUNT
Amount of items in the enum.
Definition Units.hpp:69
@ m_s3_sqrth
[m/s^3/sqrt(h)] (Standard deviation)
Definition Units.hpp:68
@ m_s3_sqrts
[m/s^3/sqrt(s)] (Standard deviation)
Definition Units.hpp:67
ImuAccelerometerNoiseUnits
Possible units to specify an accelerometer noise.
Definition Units.hpp:48
@ m_s2_sqrts
[m/s^2/sqrt(s)] (Standard deviation)
Definition Units.hpp:49
@ COUNT
Amount of items in the enum.
Definition Units.hpp:51
@ m_s2_sqrth
[m/s^2/sqrt(h)] (Standard deviation)
Definition Units.hpp:50
ImuAccelerometerFilterNoiseUnits
Possible units to specify an accelerometer noise in a filter.
Definition Units.hpp:84
@ COUNT
Amount of items in the enum.
Definition Units.hpp:87
@ mg_sqrtHz
[mg / √(Hz)]
Definition Units.hpp:86
@ m_s2_sqrtHz
[m / s^2 / √(Hz)]
Definition Units.hpp:85
ImuAccelerometerFilterBiasUnits
Possible units for the accelerometer dynamic bias.
Definition Units.hpp:102
@ COUNT
Amount of items in the enum.
Definition Units.hpp:105
@ microg
[µg]
Definition Units.hpp:104
@ m_s2
[m / s^2]
Definition Units.hpp:103
ImuGyroscopeFilterBiasUnits
Possible units for the gyroscope dynamic bias.
Definition Units.hpp:110
@ deg_s
[°/s]
Definition Units.hpp:113
@ COUNT
Amount of items in the enum.
Definition Units.hpp:115
@ rad_s
[1/s]
Definition Units.hpp:111
@ deg_h
[°/h]
Definition Units.hpp:114
@ rad_h
[1/h]
Definition Units.hpp:112
ImuGyroscopeFilterNoiseUnits
Possible units to specify an gyro noise in a filter.
Definition Units.hpp:92
@ deg_hr_sqrtHz
[deg / hr /√(Hz)]
Definition Units.hpp:96
@ COUNT
Amount of items in the enum.
Definition Units.hpp:97
@ rad_s_sqrtHz
[rad / s /√(Hz)]
Definition Units.hpp:93
@ deg_s_sqrtHz
[deg / s /√(Hz)]
Definition Units.hpp:95
@ rad_hr_sqrtHz
[rad / hr /√(Hz)]
Definition Units.hpp:94
ImuGyroscopeIRWUnits
Possible units to specify an gyro RW.
Definition Units.hpp:74
@ rad_s2_sqrth
[rad/s^2/sqrt(h)] (Standard deviation)
Definition Units.hpp:76
@ COUNT
Amount of items in the enum.
Definition Units.hpp:79
@ deg_s2_sqrth
[deg/s^2/sqrt(h)] (Standard deviation)
Definition Units.hpp:78
@ deg_s2_sqrts
[deg/s^2/sqrt(s)] (Standard deviation)
Definition Units.hpp:77
@ rad_s2_sqrts
[rad/s^2/sqrt(s)] (Standard deviation)
Definition Units.hpp:75
ImuGyroscopeNoiseUnits
Possible units to specify an gyro noise.
Definition Units.hpp:56
@ deg_s_sqrth
[deg/s/sqrt(h)] (Standard deviation)
Definition Units.hpp:60
@ COUNT
Amount of items in the enum.
Definition Units.hpp:61
@ rad_s_sqrts
[rad/s/sqrt(s)] (Standard deviation)
Definition Units.hpp:57
@ rad_s_sqrth
[rad/s/sqrt(h)] (Standard deviation)
Definition Units.hpp:58
@ deg_s_sqrts
[deg/s/sqrt(s)] (Standard deviation)
Definition Units.hpp:59
ImuAccelerometerUnits
Possible units to specify an accelerometer with.
Definition Units.hpp:32
@ COUNT
Amount of items in the enum.
Definition Units.hpp:35
@ g
[g]
Definition Units.hpp:34
@ m_s2
[m/s^2]
Definition Units.hpp:33
Defines how to save certain datatypes to json.
const char * to_string(gui::widgets::PositionWithFrame::ReferenceFrame refFrame)
Converts the enum to a string.
static constexpr double G_NORM
Standard gravity in [m / s^2].
Definition Constants.hpp:40