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 "ImuPos.hpp" | ||
10 | |||
11 | #include <nlohmann/json.hpp> | ||
12 | using json = nlohmann::json; ///< json namespace | ||
13 | |||
14 | namespace NAV | ||
15 | { | ||
16 | /// @brief Converts the provided imu position into a json object | ||
17 | /// @param[out] j Json object which gets filled with the info | ||
18 | /// @param[in] pos Imu position to convert into json | ||
19 | ✗ | void to_json(json& j, const ImuPos& pos) | |
20 | { | ||
21 | ✗ | j = json{ | |
22 | ✗ | { "b_positionAccel", pos.b_positionAccel() }, | |
23 | ✗ | { "b_positionGyro", pos.b_positionGyro() }, | |
24 | ✗ | { "b_positionMag", pos.b_positionMag() }, | |
25 | ✗ | { "b_quatAccel_p", pos.b_quatAccel_p().coeffs() }, | |
26 | ✗ | { "b_quatGyro_p", pos.b_quatGyro_p().coeffs() }, | |
27 | ✗ | { "b_quatMag_p", pos.b_quatMag_p().coeffs() }, | |
28 | ✗ | }; | |
29 | ✗ | } | |
30 | /// @brief Converts the provided json object into a imu position object | ||
31 | /// @param[in] j Json object with the needed values | ||
32 | /// @param[out] pos Object to fill from the json | ||
33 | 64 | void from_json(const json& j, ImuPos& pos) | |
34 | { | ||
35 |
1/2✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
|
64 | if (j.contains("b_positionAccel")) |
36 | { | ||
37 | 64 | j.at("b_positionAccel").get_to(pos._b_positionAccel); | |
38 | } | ||
39 |
1/2✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
|
64 | if (j.contains("b_positionGyro")) |
40 | { | ||
41 | 64 | j.at("b_positionGyro").get_to(pos._b_positionGyro); | |
42 | } | ||
43 |
1/2✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
|
64 | if (j.contains("b_positionMag")) |
44 | { | ||
45 | 64 | j.at("b_positionMag").get_to(pos._b_positionMag); | |
46 | } | ||
47 |
1/2✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
|
64 | if (j.contains("b_quatAccel_p")) |
48 | { | ||
49 | 64 | j.at("b_quatAccel_p").get_to(pos._b_quatAccel_p.coeffs()); | |
50 | } | ||
51 |
1/2✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
|
64 | if (j.contains("b_quatGyro_p")) |
52 | { | ||
53 | 64 | j.at("b_quatGyro_p").get_to(pos._b_quatGyro_p.coeffs()); | |
54 | } | ||
55 |
1/2✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
|
64 | if (j.contains("b_quatMag_p")) |
56 | { | ||
57 | 64 | j.at("b_quatMag_p").get_to(pos._b_quatMag_p.coeffs()); | |
58 | } | ||
59 | 64 | } | |
60 | |||
61 | } // namespace NAV | ||
62 |