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 | #include "Units.hpp" | ||
10 | |||
11 | #include "util/Logger.hpp" | ||
12 | |||
13 | namespace NAV::Units | ||
14 | { | ||
15 | |||
16 | ✗ | void to_json(json& j, const ImuAccelerometerUnits& data) | |
17 | { | ||
18 | ✗ | j = to_string(data); | |
19 | ✗ | } | |
20 | 8 | void from_json(const json& j, ImuAccelerometerUnits& data) | |
21 | { | ||
22 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
|
8 | if (!j.is_string()) |
23 | { | ||
24 | ✗ | LOG_WARN("Could not parse '{}' into ImuAccelerometerUnits. Consider resaving the flow", j.dump()); | |
25 | 8 | return; | |
26 | } | ||
27 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | std::string str = j.get<std::string>(); |
28 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | for (size_t i = 0; i < static_cast<size_t>(ImuAccelerometerUnits::COUNT); i++) |
29 | { | ||
30 | 8 | auto enumItem = static_cast<ImuAccelerometerUnits>(i); | |
31 |
2/4✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
|
8 | if (str == to_string(enumItem)) |
32 | { | ||
33 | 8 | data = enumItem; | |
34 | 8 | return; | |
35 | } | ||
36 | } | ||
37 | 8 | } | |
38 | |||
39 | ✗ | void to_json(json& j, const ImuGyroscopeUnits& data) | |
40 | { | ||
41 | ✗ | j = to_string(data); | |
42 | ✗ | } | |
43 | 8 | void from_json(const json& j, ImuGyroscopeUnits& data) | |
44 | { | ||
45 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
|
8 | if (!j.is_string()) |
46 | { | ||
47 | ✗ | LOG_WARN("Could not parse '{}' into ImuGyroscopeUnits. Consider resaving the flow", j.dump()); | |
48 | 8 | return; | |
49 | } | ||
50 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | std::string str = j.get<std::string>(); |
51 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | for (size_t i = 0; i < static_cast<size_t>(ImuGyroscopeUnits::COUNT); i++) |
52 | { | ||
53 | 8 | auto enumItem = static_cast<ImuGyroscopeUnits>(i); | |
54 |
2/4✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
|
8 | if (str == to_string(enumItem)) |
55 | { | ||
56 | 8 | data = enumItem; | |
57 | 8 | return; | |
58 | } | ||
59 | } | ||
60 | 8 | } | |
61 | |||
62 | ✗ | void to_json(json& j, const ImuAccelerometerNoiseUnits& data) | |
63 | { | ||
64 | ✗ | j = to_string(data); | |
65 | ✗ | } | |
66 | 16 | void from_json(const json& j, ImuAccelerometerNoiseUnits& data) | |
67 | { | ||
68 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
|
16 | if (!j.is_string()) |
69 | { | ||
70 | ✗ | LOG_WARN("Could not parse '{}' into ImuAccelerometerNoiseUnits. Consider resaving the flow", j.dump()); | |
71 | 16 | return; | |
72 | } | ||
73 |
1/2✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
|
16 | std::string str = j.get<std::string>(); |
74 |
1/2✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
|
16 | for (size_t i = 0; i < static_cast<size_t>(ImuAccelerometerNoiseUnits::COUNT); i++) |
75 | { | ||
76 | 16 | auto enumItem = static_cast<ImuAccelerometerNoiseUnits>(i); | |
77 |
2/4✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 16 times.
✗ Branch 6 not taken.
|
16 | if (str == to_string(enumItem)) |
78 | { | ||
79 | 16 | data = enumItem; | |
80 | 16 | return; | |
81 | } | ||
82 | } | ||
83 | 16 | } | |
84 | |||
85 | ✗ | void to_json(json& j, const ImuGyroscopeNoiseUnits& data) | |
86 | { | ||
87 | ✗ | j = to_string(data); | |
88 | ✗ | } | |
89 | 16 | void from_json(const json& j, ImuGyroscopeNoiseUnits& data) | |
90 | { | ||
91 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
|
16 | if (!j.is_string()) |
92 | { | ||
93 | ✗ | LOG_WARN("Could not parse '{}' into ImuGyroscopeNoiseUnits. Consider resaving the flow", j.dump()); | |
94 | 16 | return; | |
95 | } | ||
96 |
1/2✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
|
16 | std::string str = j.get<std::string>(); |
97 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | for (size_t i = 0; i < static_cast<size_t>(ImuGyroscopeNoiseUnits::COUNT); i++) |
98 | { | ||
99 | 18 | auto enumItem = static_cast<ImuGyroscopeNoiseUnits>(i); | |
100 |
3/4✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 2 times.
|
18 | if (str == to_string(enumItem)) |
101 | { | ||
102 | 16 | data = enumItem; | |
103 | 16 | return; | |
104 | } | ||
105 | } | ||
106 | 16 | } | |
107 | |||
108 | ✗ | void to_json(json& j, const ImuAccelerometerIRWUnits& data) | |
109 | { | ||
110 | ✗ | j = to_string(data); | |
111 | ✗ | } | |
112 | 8 | void from_json(const json& j, ImuAccelerometerIRWUnits& data) | |
113 | { | ||
114 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
|
8 | if (!j.is_string()) |
115 | { | ||
116 | ✗ | LOG_WARN("Could not parse '{}' into ImuAccelerometerIRWUnits. Consider resaving the flow", j.dump()); | |
117 | 8 | return; | |
118 | } | ||
119 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | std::string str = j.get<std::string>(); |
120 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | for (size_t i = 0; i < static_cast<size_t>(ImuAccelerometerIRWUnits::COUNT); i++) |
121 | { | ||
122 | 8 | auto enumItem = static_cast<ImuAccelerometerIRWUnits>(i); | |
123 |
2/4✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
|
8 | if (str == to_string(enumItem)) |
124 | { | ||
125 | 8 | data = enumItem; | |
126 | 8 | return; | |
127 | } | ||
128 | } | ||
129 | 8 | } | |
130 | |||
131 | ✗ | void to_json(json& j, const ImuGyroscopeIRWUnits& data) | |
132 | { | ||
133 | ✗ | j = to_string(data); | |
134 | ✗ | } | |
135 | 8 | void from_json(const json& j, ImuGyroscopeIRWUnits& data) | |
136 | { | ||
137 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
|
8 | if (!j.is_string()) |
138 | { | ||
139 | ✗ | LOG_WARN("Could not parse '{}' into ImuGyroscopeIRWUnits. Consider resaving the flow", j.dump()); | |
140 | 8 | return; | |
141 | } | ||
142 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
8 | std::string str = j.get<std::string>(); |
143 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | for (size_t i = 0; i < static_cast<size_t>(ImuGyroscopeIRWUnits::COUNT); i++) |
144 | { | ||
145 | 8 | auto enumItem = static_cast<ImuGyroscopeIRWUnits>(i); | |
146 |
2/4✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
|
8 | if (str == to_string(enumItem)) |
147 | { | ||
148 | 8 | data = enumItem; | |
149 | 8 | return; | |
150 | } | ||
151 | } | ||
152 | 8 | } | |
153 | |||
154 | } // namespace NAV::Units | ||
155 | |||
156 | 8 | std::string NAV::to_string(Units::ImuAccelerometerUnits unit) | |
157 | { | ||
158 |
1/3✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
|
8 | switch (unit) |
159 | { | ||
160 | 8 | case Units::ImuAccelerometerUnits::m_s2: | |
161 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
16 | return "m/s^2"; |
162 | ✗ | case Units::ImuAccelerometerUnits::COUNT: | |
163 | ✗ | break; | |
164 | } | ||
165 | ✗ | return ""; | |
166 | } | ||
167 | |||
168 | 8 | std::string NAV::to_string(Units::ImuGyroscopeUnits unit) | |
169 | { | ||
170 |
1/4✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
8 | switch (unit) |
171 | { | ||
172 | 8 | case Units::ImuGyroscopeUnits::rad_s: | |
173 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
16 | return "rad/s"; |
174 | ✗ | case Units::ImuGyroscopeUnits::deg_s: | |
175 | ✗ | return "deg/s"; | |
176 | ✗ | case Units::ImuGyroscopeUnits::COUNT: | |
177 | ✗ | break; | |
178 | } | ||
179 | ✗ | return ""; | |
180 | } | ||
181 | |||
182 | 16 | std::string NAV::to_string(Units::ImuAccelerometerNoiseUnits unit) | |
183 | { | ||
184 |
1/4✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
16 | switch (unit) |
185 | { | ||
186 | 16 | case Units::ImuAccelerometerNoiseUnits::m_s2_sqrts: | |
187 |
1/2✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
|
32 | return "m/s^2/√(s)"; |
188 | ✗ | case Units::ImuAccelerometerNoiseUnits::m_s2_sqrth: | |
189 | ✗ | return "m/s^2/√(h)"; | |
190 | ✗ | case Units::ImuAccelerometerNoiseUnits::COUNT: | |
191 | ✗ | break; | |
192 | } | ||
193 | ✗ | return ""; | |
194 | } | ||
195 | |||
196 | 18 | std::string NAV::to_string(Units::ImuGyroscopeNoiseUnits unit) | |
197 | { | ||
198 |
3/6✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
18 | switch (unit) |
199 | { | ||
200 | 16 | case Units::ImuGyroscopeNoiseUnits::rad_s_sqrts: | |
201 |
1/2✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
|
32 | return "rad/s/√(s)"; |
202 | 1 | case Units::ImuGyroscopeNoiseUnits::rad_s_sqrth: | |
203 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return "rad/s/√(h)"; |
204 | 1 | case Units::ImuGyroscopeNoiseUnits::deg_s_sqrts: | |
205 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 | return "deg/s/√(s)"; |
206 | ✗ | case Units::ImuGyroscopeNoiseUnits::deg_s_sqrth: | |
207 | ✗ | return "deg/s/√(h)"; | |
208 | ✗ | case Units::ImuGyroscopeNoiseUnits::COUNT: | |
209 | ✗ | break; | |
210 | } | ||
211 | ✗ | return ""; | |
212 | } | ||
213 | |||
214 | 8 | std::string NAV::to_string(Units::ImuAccelerometerIRWUnits unit) | |
215 | { | ||
216 |
1/4✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
8 | switch (unit) |
217 | { | ||
218 | 8 | case Units::ImuAccelerometerIRWUnits::m_s3_sqrts: | |
219 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
16 | return "m/s^3/√(s)"; |
220 | ✗ | case Units::ImuAccelerometerIRWUnits::m_s3_sqrth: | |
221 | ✗ | return "m/s^3/√(h)"; | |
222 | ✗ | case Units::ImuAccelerometerIRWUnits::COUNT: | |
223 | ✗ | break; | |
224 | } | ||
225 | ✗ | return ""; | |
226 | } | ||
227 | |||
228 | 8 | std::string NAV::to_string(Units::ImuGyroscopeIRWUnits unit) | |
229 | { | ||
230 |
1/6✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
8 | switch (unit) |
231 | { | ||
232 | 8 | case Units::ImuGyroscopeIRWUnits::rad_s2_sqrts: | |
233 |
1/2✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
16 | return "rad/s^2/√(s)"; |
234 | ✗ | case Units::ImuGyroscopeIRWUnits::rad_s2_sqrth: | |
235 | ✗ | return "rad/s^2/√(h)"; | |
236 | ✗ | case Units::ImuGyroscopeIRWUnits::deg_s2_sqrts: | |
237 | ✗ | return "deg/s^2/√(s)"; | |
238 | ✗ | case Units::ImuGyroscopeIRWUnits::deg_s2_sqrth: | |
239 | ✗ | return "deg/s^2/√(h)"; | |
240 | ✗ | case Units::ImuGyroscopeIRWUnits::COUNT: | |
241 | ✗ | break; | |
242 | } | ||
243 | ✗ | return ""; | |
244 | } | ||
245 |