0.4.1
Loading...
Searching...
No Matches
BaroSimulator.hpp
Go to the documentation of this file.
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>
20#include <Eigen/src/Core/Matrix.h>
21
22namespace NAV
23{
24/// Convert RTKLib pos files into PosVel
25class BaroSimulator : public Node
26{
27 public:
28 /// @brief Default constructor
30 /// @brief Destructor
31 ~BaroSimulator() override;
32 /// @brief Copy constructor
33 BaroSimulator(const BaroSimulator&) = delete;
34 /// @brief Move constructor
36 /// @brief Copy assignment operator
38 /// @brief Move assignment operator
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²
86 /// pressure noise in hPa
87 double _pressurenoise = 0.0;
88
89 /// Random number generator for the pressure noise
91
92 /// save computations, by storing g * M / R0 / L;
94
95 /// Initial position in LLA [deg, deg, m] for the calculation of the local gravity through EGM96
96 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
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
118constexpr const char* to_string(NAV::BaroSimulator::GravityInput value)
119{
120 switch (value)
121 {
123 return "Manual";
125 return "Position";
127 return "";
128 }
129 return "";
130}
131
132} // namespace NAV
Holds all Constants.
nlohmann::json json
json namespace
Node Class.
Random Number Generator.
static constexpr size_t OUTPUT_PORT_INDEX_BAROPRESSURE
Flow.
double _pressurenoise
pressure noise in hPa
BaroSimulator(const BaroSimulator &)=delete
Copy constructor.
json save() const override
Saves the node into a json object.
static constexpr size_t INPUT_PORT_INDEX_POS
Flow.
double _gravity
Gravity in m / s²
static std::string typeStatic()
String representation of the Class Type.
void receiveObs(InputPin::NodeDataQueue &queue, size_t pinIdx)
Converts the RtklibPosObs into PosVel.
BaroSimulator(BaroSimulator &&)=delete
Move constructor.
~BaroSimulator() override
Destructor.
double _pressure0
Pressure at Sea level in hPa.
RandomNumberGenerator _pressureRng
Random number generator for the pressure noise.
double _temp0
Temperature at Sea level in deg K.
void guiConfig() override
ImGui config window which is shown on double click.
static std::string category()
String representation of the Class Category.
BaroSimulator()
Default constructor.
Eigen::Vector3d _initPos
Initial position in LLA [deg, deg, m] for the calculation of the local gravity through EGM96.
void deinitialize() override
Deinitialize the node.
double _lapserate
Temperature lapse rate in K / m.
bool initialize() override
Initialize the node.
GravityInput _gravityInput
Default gravity input type.
GravityInput
Available options for gravity input.
@ COUNT
Number of items in the enum.
@ Position
Entry of the position, gravity is then deducted from EGM96.
@ Manual
Manual entry of the gravity's magnitude.
double _geoidhgt
Geoid undulation in m.
void restore(const json &j) override
Restores the node from a json object.
BaroSimulator & operator=(const BaroSimulator &)=delete
Copy assignment operator.
double _exponent
save computations, by storing g * M / R0 / L;
std::string type() const override
String representation of the Class Type.
friend constexpr const char * to_string(GravityInput value)
Converts the enum to a string.
BaroSimulator & operator=(BaroSimulator &&)=delete
Move assignment operator.
TsDeque< std::shared_ptr< const NAV::NodeData > > NodeDataQueue
Node data queue type.
Definition Pin.hpp:707
static constexpr double Rg
Universal gas constant in [J/K/mol].
static constexpr double dMtr
Molar mass of dry air in [kg/mol].
static constexpr double G_NORM
Standard gravity in [m / s^2].
Definition Constants.hpp:40
Node(std::string name)
Constructor.
Definition Node.cpp:30
Manages a thread which calls a specified function at a specified interval.
const char * to_string(gui::widgets::PositionWithFrame::ReferenceFrame refFrame)
Converts the enum to a string.