INSTINCT Code Coverage Report


Directory: src/
File: NodeData/Baro/BaroPressObs.hpp
Date: 2025-06-02 15:19:59
Exec Total Coverage
Lines: 5 31 16.1%
Functions: 2 9 22.2%
Branches: 4 18 22.2%

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 BaroPressObs.hpp
10 /// @brief Barometric Pressure Storage Class
11 /// @author T. Hobiger (hobiger@ins.uni-stuttgart.de)
12 /// @date 2025-02-10
13
14 #pragma once
15
16 #include "NodeData/NodeData.hpp"
17 #include "util/Assert.h"
18
19 namespace NAV
20 {
21 /// Barometric pressure storage class
22 class BaroPressObs : public NodeData
23 {
24 public:
25 /// @brief Returns the type of the data class
26 /// @return The data type
27 479 [[nodiscard]] static std::string type()
28 {
29
1/2
✓ Branch 1 taken 479 times.
✗ Branch 2 not taken.
958 return "BaroPressObs";
30 }
31
32 /// @brief Returns the type of the data class
33 /// @return The data type
34 [[nodiscard]] std::string getType() const override { return type(); }
35
36 /// @brief Returns the parent types of the data class
37 /// @return The parent data types
38 112 [[nodiscard]] static std::vector<std::string> parentTypes()
39 {
40
3/6
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
✓ Branch 4 taken 112 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
336 return { NodeData::type() };
41 112 }
42
43 /// @brief Returns a vector of data descriptors
44 [[nodiscard]] static std::vector<std::string> GetStaticDataDescriptors()
45 {
46 return {
47 "BaroPressObs [hPa]",
48 "BaroPressObs StDev [hPa]"
49 };
50 }
51
52 /// @brief Get the number of descriptors
53 [[nodiscard]] static constexpr size_t GetStaticDescriptorCount() { return 2; }
54
55 /// @brief Returns a vector of data descriptors
56 [[nodiscard]] std::vector<std::string> staticDataDescriptors() const override { return GetStaticDataDescriptors(); }
57
58 /// @brief Get the number of descriptors
59 [[nodiscard]] size_t staticDescriptorCount() const override { return GetStaticDescriptorCount(); }
60
61 /// @brief Get the value at the index
62 /// @param idx Index corresponding to data descriptor order
63 /// @return Value if in the observation
64 [[nodiscard]] std::optional<double> getValueAt(size_t idx) const override
65 {
66 switch (idx)
67 {
68 case 0: // BaroPressObs [hPa]
69 return baro_pressure;
70 case 1: // BaroPressObs StDev [hPa]
71 return baro_pressureStdev;
72 default:
73 return std::nullopt;
74 }
75 return std::nullopt;
76 }
77
78 /// @brief Set the value at the index
79 /// @param idx Index corresponding to data descriptor order
80 /// @param value Value to set
81 /// @return True if the value was updated
82 [[nodiscard]] bool setValueAt(size_t idx, double value) override
83 {
84 INS_ASSERT(idx < GetStaticDescriptorCount());
85 switch (idx)
86 {
87 case 0: // Baro pressure [hPa]
88 baro_pressure = value;
89 break;
90 case 1: // Baro pressure StDev [hPa]
91 baro_pressureStdev = value;
92 break;
93 default:
94 return false;
95 }
96
97 return true;
98 }
99
100 /// Barometric pressure [hPa]
101 double baro_pressure{ std::nan("") };
102
103 /// Standard deviation of barometric pressure
104 std::optional<double> baro_pressureStdev;
105 };
106
107 } // namespace NAV
108