INSTINCT Code Coverage Report


Directory: src/
File: Nodes/DataProcessor/Barometer/PressToHgt.hpp
Date: 2025-06-02 15:19:59
Exec Total Coverage
Lines: 1 10 10.0%
Functions: 0 1 0.0%
Branches: 1 6 16.7%

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