0.4.1
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
9/// @file Units.hpp
10/// @brief Units used by GNSS positioning
11/// @author T. Topp (topp@ins.uni-stuttgart.de)
12/// @date 2025-02-18
13
14#pragma once
15
16#include <cstddef>
17#include <string>
18#include <Eigen/Core>
19
20#include "util/Json.hpp"
21
22namespace NAV
23{
24
25namespace Units
26{
27
28/// Possible units for the uncertainty of the position
29enum class PositionUncertaintyUnits : uint8_t
30{
31 meter, ///< Standard deviation [m, m, m]
32 meter2, ///< Variance [m^2, m^2, m^2]
33 COUNT, ///< Amount of items in the enum
34};
35
36/// Possible units for the uncertainty of the velocity
37enum class VelocityUncertaintyUnits : uint8_t
38{
39 m_s, ///< Standard deviation [m/s]
40 m2_s2, ///< Variance [m^2/s^2]
41 COUNT, ///< Amount of items in the enum
42};
43
44/// Possible units for the uncertainty of the attitude
45enum class AttitudeUncertaintyUnits : uint8_t
46{
47 rad, ///< Standard deviation [radian]
48 deg, ///< Standard deviation [degree]
49 rad2, ///< Variance [radian^2]
50 deg2, ///< Variance [degree^2]
51 COUNT, ///< Amount of items in the enum
52};
53
54/// Possible units for the velocity
55enum class VelocityUnits : uint8_t
56{
57 m_s, ///< [m/s]
58 COUNT, ///< Amount of items in the enum
59};
60
61/// Possible units for the attitude
62enum class AttitudeUnits : uint8_t
63{
64 rad, ///< [radian]
65 deg, ///< [degree]
66 COUNT, ///< Amount of items in the enum
67};
68
69/// @brief Converts the provided data into a json object
70/// @param[out] j Json object which gets filled with the info
71/// @param[in] data Data to convert into json
72void to_json(json& j, const PositionUncertaintyUnits& data);
73/// @brief Converts the provided json object into the data object
74/// @param[in] j Json object with the needed values
75/// @param[out] data Object to fill from the json
76void from_json(const json& j, PositionUncertaintyUnits& data);
77
78/// @brief Converts the provided data into a json object
79/// @param[out] j Json object which gets filled with the info
80/// @param[in] data Data to convert into json
81void to_json(json& j, const VelocityUncertaintyUnits& data);
82/// @brief Converts the provided json object into the data object
83/// @param[in] j Json object with the needed values
84/// @param[out] data Object to fill from the json
85void from_json(const json& j, VelocityUncertaintyUnits& data);
86
87/// @brief Converts the provided data into a json object
88/// @param[out] j Json object which gets filled with the info
89/// @param[in] data Data to convert into json
90void to_json(json& j, const AttitudeUncertaintyUnits& data);
91/// @brief Converts the provided json object into the data object
92/// @param[in] j Json object with the needed values
93/// @param[out] data Object to fill from the json
94void from_json(const json& j, AttitudeUncertaintyUnits& data);
95
96/// @brief Converts the provided data into a json object
97/// @param[out] j Json object which gets filled with the info
98/// @param[in] data Data to convert into json
99void to_json(json& j, const VelocityUnits& data);
100/// @brief Converts the provided json object into the data object
101/// @param[in] j Json object with the needed values
102/// @param[out] data Object to fill from the json
103void from_json(const json& j, VelocityUnits& data);
104
105/// @brief Converts the provided data into a json object
106/// @param[out] j Json object which gets filled with the info
107/// @param[in] data Data to convert into json
108void to_json(json& j, const AttitudeUnits& data);
109/// @brief Converts the provided json object into the data object
110/// @param[in] j Json object with the needed values
111/// @param[out] data Object to fill from the json
112void from_json(const json& j, AttitudeUnits& data);
113
114} // namespace Units
115
116/// @brief Converts the value depending on the unit provided
117/// @param[in] value Value to convert
118/// @param[in] unit Unit the value is in
119/// @return Value in unit of the first item in the Unit enum
120[[nodiscard]] double convertUnit(const double& value, Units::PositionUncertaintyUnits unit);
121/// @brief Converts the value depending on the unit provided
122/// @param[in] value Value to convert
123/// @param[in] unit Unit the value is in
124/// @return Value in unit of the first item in the Unit enum
125[[nodiscard]] Eigen::Vector3d convertUnit(const Eigen::Vector3d& value, Units::PositionUncertaintyUnits unit);
126
127/// @brief Converts the value depending on the unit provided
128/// @param[in] value Value to convert
129/// @param[in] unit Unit the value is in
130/// @return Value in unit of the first item in the Unit enum
131[[nodiscard]] double convertUnit(const double& value, Units::VelocityUncertaintyUnits unit);
132/// @brief Converts the value depending on the unit provided
133/// @param[in] value Value to convert
134/// @param[in] unit Unit the value is in
135/// @return Value in unit of the first item in the Unit enum
136[[nodiscard]] Eigen::Vector3d convertUnit(const Eigen::Vector3d& value, Units::VelocityUncertaintyUnits unit);
137
138/// @brief Converts the value depending on the unit provided
139/// @param[in] value Value to convert
140/// @param[in] unit Unit the value is in
141/// @return Value in unit of the first item in the Unit enum
142[[nodiscard]] double convertUnit(const double& value, Units::AttitudeUncertaintyUnits unit);
143/// @brief Converts the value depending on the unit provided
144/// @param[in] value Value to convert
145/// @param[in] unit Unit the value is in
146/// @return Value in unit of the first item in the Unit enum
147[[nodiscard]] Eigen::Vector3d convertUnit(const Eigen::Vector3d& value, Units::AttitudeUncertaintyUnits unit);
148
149/// @brief Converts the value depending on the unit provided
150/// @param[in] value Value to convert
151/// @param[in] unit Unit the value is in
152/// @return Value in unit of the first item in the Unit enum
153[[nodiscard]] double convertUnit(const double& value, Units::VelocityUnits unit);
154/// @brief Converts the value depending on the unit provided
155/// @param[in] value Value to convert
156/// @param[in] unit Unit the value is in
157/// @return Value in unit of the first item in the Unit enum
158[[nodiscard]] Eigen::Vector3d convertUnit(const Eigen::Vector3d& value, Units::VelocityUnits unit);
159
160/// @brief Converts the value depending on the unit provided
161/// @param[in] value Value to convert
162/// @param[in] unit Unit the value is in
163/// @return Value in unit of the first item in the Unit enum
164[[nodiscard]] double convertUnit(const double& value, Units::AttitudeUnits unit);
165/// @brief Converts the value depending on the unit provided
166/// @param[in] value Value to convert
167/// @param[in] unit Unit the value is in
168/// @return Value in unit of the first item in the Unit enum
169[[nodiscard]] Eigen::Vector3d convertUnit(const Eigen::Vector3d& value, Units::AttitudeUnits unit);
170
171/// @brief Converts the unit into a string
172/// @param[in] unit Unit
173[[nodiscard]] std::string to_string(Units::PositionUncertaintyUnits unit);
174/// @brief Converts the unit into a string
175/// @param[in] unit Unit
176[[nodiscard]] std::string to_string(Units::VelocityUncertaintyUnits unit);
177/// @brief Converts the unit into a string
178/// @param[in] unit Unit
179[[nodiscard]] std::string to_string(Units::AttitudeUncertaintyUnits unit);
180
181/// @brief Converts the unit into a string
182/// @param[in] unit Unit
183[[nodiscard]] std::string to_string(Units::VelocityUnits unit);
184/// @brief Converts the unit into a string
185/// @param[in] unit Unit
186[[nodiscard]] std::string to_string(Units::AttitudeUnits unit);
187
188} // namespace NAV
nlohmann::json json
json namespace
Defines how to save certain datatypes to json.
AttitudeUncertaintyUnits
Possible units for the uncertainty of the attitude.
Definition Units.hpp:46
@ rad
Standard deviation [radian].
Definition Units.hpp:47
@ deg
Standard deviation [degree].
Definition Units.hpp:48
@ rad2
Variance [radian^2].
Definition Units.hpp:49
@ deg2
Variance [degree^2].
Definition Units.hpp:50
void to_json(json &j, const PositionUncertaintyUnits &data)
Converts the provided data into a json object.
Definition Units.cpp:18
PositionUncertaintyUnits
Possible units for the uncertainty of the position.
Definition Units.hpp:30
@ meter2
Variance [m^2, m^2, m^2].
Definition Units.hpp:32
@ COUNT
Amount of items in the enum.
Definition Units.hpp:33
@ meter
Standard deviation [m, m, m].
Definition Units.hpp:31
VelocityUncertaintyUnits
Possible units for the uncertainty of the velocity.
Definition Units.hpp:38
@ m_s
Standard deviation [m/s].
Definition Units.hpp:39
@ m2_s2
Variance [m^2/s^2].
Definition Units.hpp:40
void from_json(const json &j, PositionUncertaintyUnits &data)
Converts the provided json object into the data object.
Definition Units.cpp:22
AttitudeUnits
Possible units for the attitude.
Definition Units.hpp:63
VelocityUnits
Possible units for the velocity.
Definition Units.hpp:56
const char * to_string(gui::widgets::PositionWithFrame::ReferenceFrame refFrame)
Converts the enum to a string.
double convertUnit(const double &value, Units::PositionUncertaintyUnits unit)
Converts the value depending on the unit provided.
Definition Units.cpp:135