Line |
Branch |
Exec |
Source |
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 Keys.hpp |
10 |
|
|
/// @brief Inertial Navigation System Keys |
11 |
|
|
/// @author T. Topp (topp@ins.uni-stuttgart.de) |
12 |
|
|
/// @date 2025-03-12 |
13 |
|
|
|
14 |
|
|
#pragma once |
15 |
|
|
|
16 |
|
|
#include <array> |
17 |
|
|
#include <cmath> |
18 |
|
|
#include <iostream> |
19 |
|
|
#include <fmt/format.h> |
20 |
|
|
|
21 |
|
|
namespace NAV::Keys |
22 |
|
|
{ |
23 |
|
|
|
24 |
|
|
/// Keys used in the model |
25 |
|
|
enum InertialNavigationKey : uint8_t |
26 |
|
|
{ |
27 |
|
|
AccelBiasX, ///< Accelerometer bias X [m/s^2] |
28 |
|
|
AccelBiasY, ///< Accelerometer bias Y [m/s^2] |
29 |
|
|
AccelBiasZ, ///< Accelerometer bias Z [m/s^2] |
30 |
|
|
GyroBiasX, ///< Gyroscope bias X [rad/s] |
31 |
|
|
GyroBiasY, ///< Gyroscope bias Y [rad/s] |
32 |
|
|
GyroBiasZ, ///< Gyroscope bias Z [rad/s] |
33 |
|
|
|
34 |
|
|
AccelScaleFactorX, ///< Accelerometer scale factor X [-] |
35 |
|
|
AccelScaleFactorY, ///< Accelerometer scale factor Y [-] |
36 |
|
|
AccelScaleFactorZ, ///< Accelerometer scale factor Z [-] |
37 |
|
|
GyroScaleFactorX, ///< Gyroscope scale factor X [-] |
38 |
|
|
GyroScaleFactorY, ///< Gyroscope scale factor Y [-] |
39 |
|
|
GyroScaleFactorZ, ///< Gyroscope scale factor Z [-] |
40 |
|
|
|
41 |
|
|
AccelMisalignmentQ1, ///< Accelerometer misalignment quaternion x: Coefficient of i |
42 |
|
|
AccelMisalignmentQ2, ///< Accelerometer misalignment quaternion y: Coefficient of j |
43 |
|
|
AccelMisalignmentQ3, ///< Accelerometer misalignment quaternion z: Coefficient of k |
44 |
|
|
AccelMisalignmentQ0, ///< Accelerometer misalignment quaternion w: Real (scalar) part of the Quaternion |
45 |
|
|
GyroMisalignmentQ1, ///< Gyroscope misalignment quaternion x: Coefficient of i |
46 |
|
|
GyroMisalignmentQ2, ///< Gyroscope misalignment quaternion y: Coefficient of j |
47 |
|
|
GyroMisalignmentQ3, ///< Gyroscope misalignment quaternion z: Coefficient of k |
48 |
|
|
GyroMisalignmentQ0, ///< Gyroscope misalignment quaternion w: Real (scalar) part of the Quaternion |
49 |
|
|
|
50 |
|
|
InertialNavigationKey_COUNT, ///< Count |
51 |
|
|
}; |
52 |
|
|
|
53 |
|
|
/// @brief All accelerometer bias keys |
54 |
|
|
template<typename StateKeyType> |
55 |
|
|
constexpr std::array<StateKeyType, 3> AccelBias = { Keys::AccelBiasX, Keys::AccelBiasY, Keys::AccelBiasZ }; |
56 |
|
|
/// @brief All gyroscope bias keys |
57 |
|
|
template<typename StateKeyType> |
58 |
|
|
constexpr std::array<StateKeyType, 3> GyroBias = { Keys::GyroBiasX, Keys::GyroBiasY, Keys::GyroBiasZ }; |
59 |
|
|
|
60 |
|
|
/// @brief All accelerometer scale factor keys |
61 |
|
|
template<typename StateKeyType> |
62 |
|
|
constexpr std::array<StateKeyType, 3> AccelScaleFactor = { Keys::AccelScaleFactorX, Keys::AccelScaleFactorY, Keys::AccelScaleFactorZ }; |
63 |
|
|
/// @brief All gyroscope scale factor keys |
64 |
|
|
template<typename StateKeyType> |
65 |
|
|
constexpr std::array<StateKeyType, 3> GyroScaleFactor = { Keys::GyroScaleFactorX, Keys::GyroScaleFactorY, Keys::GyroScaleFactorZ }; |
66 |
|
|
|
67 |
|
|
/// @brief All accelerometer misalignment quaternion keys |
68 |
|
|
template<typename StateKeyType> |
69 |
|
|
constexpr std::array<StateKeyType, 4> AccelMisalignment = { Keys::AccelMisalignmentQ1, Keys::AccelMisalignmentQ2, Keys::AccelMisalignmentQ3, Keys::AccelMisalignmentQ0 }; |
70 |
|
|
/// @brief All gyroscope misalignment quaternion keys |
71 |
|
|
template<typename StateKeyType> |
72 |
|
|
constexpr std::array<StateKeyType, 4> GyroMisalignment = { Keys::GyroMisalignmentQ1, Keys::GyroMisalignmentQ2, Keys::GyroMisalignmentQ3, Keys::GyroMisalignmentQ0 }; |
73 |
|
|
|
74 |
|
|
} // namespace NAV::Keys |
75 |
|
|
|
76 |
|
|
/// @brief Stream insertion operator overload |
77 |
|
|
/// @param[in, out] os Output stream object to stream the time into |
78 |
|
|
/// @param[in] obj Object to print |
79 |
|
|
/// @return Returns the output stream object in order to chain stream insertions |
80 |
|
|
std::ostream& operator<<(std::ostream& os, const NAV::Keys::InertialNavigationKey& obj); |
81 |
|
|
|
82 |
|
|
#ifndef DOXYGEN_IGNORE |
83 |
|
|
|
84 |
|
|
/// @brief Formatter |
85 |
|
|
template<> |
86 |
|
|
struct fmt::formatter<NAV::Keys::InertialNavigationKey> : fmt::formatter<const char*> |
87 |
|
|
{ |
88 |
|
|
/// @brief Defines how to format structs |
89 |
|
|
/// @param[in] state Struct to format |
90 |
|
|
/// @param[in, out] ctx Format context |
91 |
|
|
/// @return Output iterator |
92 |
|
|
template<typename FormatContext> |
93 |
|
✗ |
auto format(const NAV::Keys::InertialNavigationKey& state, FormatContext& ctx) const |
94 |
|
|
{ |
95 |
|
|
using namespace NAV::Keys; // NOLINT(google-build-using-namespace) |
96 |
|
|
|
97 |
|
✗ |
switch (state) |
98 |
|
|
{ |
99 |
|
✗ |
case AccelBiasX: |
100 |
|
✗ |
return fmt::formatter<const char*>::format("AccelBiasX", ctx); |
101 |
|
✗ |
case AccelBiasY: |
102 |
|
✗ |
return fmt::formatter<const char*>::format("AccelBiasY", ctx); |
103 |
|
✗ |
case AccelBiasZ: |
104 |
|
✗ |
return fmt::formatter<const char*>::format("AccelBiasZ", ctx); |
105 |
|
✗ |
case GyroBiasX: |
106 |
|
✗ |
return fmt::formatter<const char*>::format("GyroBiasX", ctx); |
107 |
|
✗ |
case GyroBiasY: |
108 |
|
✗ |
return fmt::formatter<const char*>::format("GyroBiasY", ctx); |
109 |
|
✗ |
case GyroBiasZ: |
110 |
|
✗ |
return fmt::formatter<const char*>::format("GyroBiasZ", ctx); |
111 |
|
✗ |
case AccelScaleFactorX: |
112 |
|
✗ |
return fmt::formatter<const char*>::format("AccelScaleFactorX", ctx); |
113 |
|
✗ |
case AccelScaleFactorY: |
114 |
|
✗ |
return fmt::formatter<const char*>::format("AccelScaleFactorY", ctx); |
115 |
|
✗ |
case AccelScaleFactorZ: |
116 |
|
✗ |
return fmt::formatter<const char*>::format("AccelScaleFactorZ", ctx); |
117 |
|
✗ |
case GyroScaleFactorX: |
118 |
|
✗ |
return fmt::formatter<const char*>::format("GyroScaleFactorX", ctx); |
119 |
|
✗ |
case GyroScaleFactorY: |
120 |
|
✗ |
return fmt::formatter<const char*>::format("GyroScaleFactorY", ctx); |
121 |
|
✗ |
case GyroScaleFactorZ: |
122 |
|
✗ |
return fmt::formatter<const char*>::format("GyroScaleFactorZ", ctx); |
123 |
|
✗ |
case AccelMisalignmentQ1: |
124 |
|
✗ |
return fmt::formatter<const char*>::format("AccelMisalignmentQ1", ctx); |
125 |
|
✗ |
case AccelMisalignmentQ2: |
126 |
|
✗ |
return fmt::formatter<const char*>::format("AccelMisalignmentQ2", ctx); |
127 |
|
✗ |
case AccelMisalignmentQ3: |
128 |
|
✗ |
return fmt::formatter<const char*>::format("AccelMisalignmentQ3", ctx); |
129 |
|
✗ |
case AccelMisalignmentQ0: |
130 |
|
✗ |
return fmt::formatter<const char*>::format("AccelMisalignmentQ0", ctx); |
131 |
|
✗ |
case GyroMisalignmentQ1: |
132 |
|
✗ |
return fmt::formatter<const char*>::format("GyroMisalignmentQ1", ctx); |
133 |
|
✗ |
case GyroMisalignmentQ2: |
134 |
|
✗ |
return fmt::formatter<const char*>::format("GyroMisalignmentQ2", ctx); |
135 |
|
✗ |
case GyroMisalignmentQ3: |
136 |
|
✗ |
return fmt::formatter<const char*>::format("GyroMisalignmentQ3", ctx); |
137 |
|
✗ |
case GyroMisalignmentQ0: |
138 |
|
✗ |
return fmt::formatter<const char*>::format("GyroMisalignmentQ0", ctx); |
139 |
|
✗ |
case InertialNavigationKey_COUNT: |
140 |
|
✗ |
return fmt::formatter<const char*>::format("InertialNavigationKey_COUNT", ctx); |
141 |
|
|
} |
142 |
|
|
|
143 |
|
✗ |
return fmt::formatter<const char*>::format("ERROR", ctx); |
144 |
|
|
} |
145 |
|
|
}; |
146 |
|
|
|
147 |
|
|
#endif |
148 |
|
|
|