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 BaroSimulator.hpp | ||
10 | /// @brief Barometer observation simulator | ||
11 | /// @author T. Hobiger (hobiger@ins.uni-stuttgart.de) | ||
12 | /// @date 2025-02-10 | ||
13 | |||
14 | #pragma once | ||
15 | |||
16 | #include <cstdint> | ||
17 | #include "internal/Node/Node.hpp" | ||
18 | #include "util/Random/RandomNumberGenerator.hpp" | ||
19 | #include "Navigation/Constants.hpp" | ||
20 | #include <Eigen/src/Core/Matrix.h> | ||
21 | |||
22 | namespace NAV | ||
23 | { | ||
24 | /// Convert RTKLib pos files into PosVel | ||
25 | class BaroSimulator : public Node | ||
26 | { | ||
27 | public: | ||
28 | /// @brief Default constructor | ||
29 | BaroSimulator(); | ||
30 | /// @brief Destructor | ||
31 | ~BaroSimulator() override; | ||
32 | /// @brief Copy constructor | ||
33 | BaroSimulator(const BaroSimulator&) = delete; | ||
34 | /// @brief Move constructor | ||
35 | BaroSimulator(BaroSimulator&&) = delete; | ||
36 | /// @brief Copy assignment operator | ||
37 | BaroSimulator& operator=(const BaroSimulator&) = delete; | ||
38 | /// @brief Move assignment operator | ||
39 | BaroSimulator& operator=(BaroSimulator&&) = delete; | ||
40 | |||
41 | /// @brief String representation of the Class Type | ||
42 | [[nodiscard]] static std::string typeStatic(); | ||
43 | |||
44 | /// @brief String representation of the Class Type | ||
45 | [[nodiscard]] std::string type() const override; | ||
46 | |||
47 | /// @brief String representation of the Class Category | ||
48 | [[nodiscard]] static std::string category(); | ||
49 | |||
50 | /// @brief ImGui config window which is shown on double click | ||
51 | /// @attention Don't forget to set _hasConfig to true in the constructor of the node | ||
52 | void guiConfig() override; | ||
53 | |||
54 | /// @brief Saves the node into a json object | ||
55 | [[nodiscard]] json save() const override; | ||
56 | |||
57 | /// @brief Restores the node from a json object | ||
58 | /// @param[in] j Json object with the node state | ||
59 | void restore(const json& j) override; | ||
60 | |||
61 | private: | ||
62 | constexpr static size_t OUTPUT_PORT_INDEX_BAROPRESSURE = 0; ///< @brief Flow | ||
63 | constexpr static size_t INPUT_PORT_INDEX_POS = 0; ///< @brief Flow | ||
64 | |||
65 | /// @brief Initialize the node | ||
66 | bool initialize() override; | ||
67 | |||
68 | /// @brief Deinitialize the node | ||
69 | void deinitialize() override; | ||
70 | |||
71 | /// @brief Converts the RtklibPosObs into PosVel | ||
72 | /// @param[in] queue Queue with all the received data messages | ||
73 | /// @param[in] pinIdx Index of the pin the data is received on | ||
74 | void receiveObs(InputPin::NodeDataQueue& queue, size_t pinIdx); | ||
75 | |||
76 | /// Temperature at Sea level in deg K | ||
77 | double _temp0 = 288.15; | ||
78 | /// Pressure at Sea level in hPa | ||
79 | double _pressure0 = 1013.25; | ||
80 | /// Temperature lapse rate in K / m | ||
81 | double _lapserate = 0.00976; | ||
82 | /// Geoid undulation in m | ||
83 | double _geoidhgt = 0.0; | ||
84 | /// Gravity in m / s² | ||
85 | double _gravity = InsConst::G_NORM; | ||
86 | /// pressure noise in hPa | ||
87 | double _pressurenoise = 0.0; | ||
88 | |||
89 | /// Random number generator for the pressure noise | ||
90 | RandomNumberGenerator _pressureRng; | ||
91 | |||
92 | /// save computations, by storing g * M / R0 / L; | ||
93 | double _exponent = InsConst::G_NORM * InsConst::dMtr / InsConst::Rg / _lapserate; | ||
94 | |||
95 | /// Initial position in LLA [deg, deg, m] for the calculation of the local gravity through EGM96 | ||
96 |
1/2✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
|
112 | Eigen::Vector3d _initPos{ 48.780509, 9.171712, 300.0 }; |
97 | |||
98 | /// @brief Available options for gravity input | ||
99 | enum class GravityInput : uint8_t | ||
100 | { | ||
101 | Manual, ///< Manual entry of the gravity's magnitude | ||
102 | Position, ///< Entry of the position, gravity is then deducted from EGM96 | ||
103 | COUNT, ///< Number of items in the enum | ||
104 | }; | ||
105 | |||
106 | /// Default gravity input type | ||
107 | GravityInput _gravityInput = GravityInput::Manual; | ||
108 | |||
109 | /// @brief Converts the enum to a string | ||
110 | /// @param[in] value Enum value to convert into text | ||
111 | /// @return String representation of the enum | ||
112 | friend constexpr const char* to_string(GravityInput value); | ||
113 | }; | ||
114 | |||
115 | /// @brief Converts the enum to a string | ||
116 | /// @param[in] value Enum value to convert into text | ||
117 | /// @return String representation of the enum | ||
118 | ✗ | constexpr const char* to_string(NAV::BaroSimulator::GravityInput value) | |
119 | { | ||
120 | ✗ | switch (value) | |
121 | { | ||
122 | ✗ | case NAV::BaroSimulator::GravityInput::Manual: | |
123 | ✗ | return "Manual"; | |
124 | ✗ | case NAV::BaroSimulator::GravityInput::Position: | |
125 | ✗ | return "Position"; | |
126 | ✗ | case NAV::BaroSimulator::GravityInput::COUNT: | |
127 | ✗ | return ""; | |
128 | } | ||
129 | ✗ | return ""; | |
130 | } | ||
131 | |||
132 | } // namespace NAV | ||
133 |