INSTINCT Code Coverage Report


Directory: src/
File: NodeData/GNSS/GnssCombination.hpp
Date: 2025-02-07 16:54:41
Exec Total Coverage
Lines: 5 33 15.2%
Functions: 2 6 33.3%
Branches: 4 76 5.3%

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 GnssCombination.hpp
10 /// @brief GNSS measurement combinations
11 /// @author T. Topp (topp@ins.uni-stuttgart.de)
12 /// @date 2023-10-17
13
14 #pragma once
15
16 #include <vector>
17 #include <tuple>
18
19 #include "NodeData/NodeData.hpp"
20 #include "GnssObs.hpp"
21 #include "Navigation/GNSS/Ambiguity/CycleSlipDetector/PolynomialCycleSlipDetector.hpp"
22
23 namespace NAV
24 {
25
26 /// GNSS measurement combinations
27 class GnssCombination : public NodeData
28 {
29 public:
30 /// @brief Returns the type of the data class
31 /// @return The data type
32 582110 [[nodiscard]] static std::string type()
33 {
34
1/2
✓ Branch 1 taken 582110 times.
✗ Branch 2 not taken.
1164220 return "GnssCombination";
35 }
36
37 /// @brief Returns the type of the data class
38 /// @return The data type
39 [[nodiscard]] std::string getType() const override { return type(); }
40
41 /// @brief Returns the parent types of the data class
42 /// @return The parent data types
43 112 [[nodiscard]] static std::vector<std::string> parentTypes()
44 {
45
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() };
46 112 }
47
48 /// Combination of GNSS measurements
49 struct Combination
50 {
51 /// Term of a combination equation
52 struct Term
53 {
54 int sign = +1; ///< +1 or -1
55 SatSigId satSigId = { Code::None, 0 }; ///< SignalId and satellite number
56 GnssObs::ObservationType obsType = GnssObs::ObservationType::Carrier; ///< Observation Type
57 std::optional<double> value; ///< Measurement (if present)
58 };
59
60 std::string description; ///< String describing the combination
61 std::optional<double> result; ///< Calculated combination (only set if all terms where present)
62 std::vector<Term> terms; ///< List of terms making up the combination
63
64 std::optional<PolynomialCycleSlipDetectorResult> cycleSlipResult; ///< Cycle-slip result
65 std::optional<double> cycleSlipPrediction; ///< Predicted value from the cycle-slip detector (polynomial fit)
66 std::optional<double> cycleSlipMeasMinPred; ///< Measurement minus predicted value from the cycle-slip detector
67 std::vector<std::tuple<InsTime, Polynomial<double>, double>> cycleSlipPolynomials; ///< Polynomial fits
68 };
69
70 /// List of combinations
71 std::vector<Combination> combinations;
72
73 /// @brief Returns a vector of data descriptors for the dynamic data
74 [[nodiscard]] std::vector<std::string> dynamicDataDescriptors() const override
75 {
76 std::vector<std::string> descriptors;
77 descriptors.reserve(combinations.size() * 4);
78
79 for (const auto& comb : combinations)
80 {
81 descriptors.push_back(comb.description);
82 descriptors.push_back(comb.description + " Cycle Slip");
83 descriptors.push_back(comb.description + " Prediction");
84 descriptors.push_back(comb.description + " Meas - Pred");
85 }
86
87 return descriptors;
88 }
89
90 /// @brief Get the value for the descriptor
91 /// @return Value if in the observation
92 [[nodiscard]] std::optional<double> getDynamicDataAt(const std::string& descriptor) const override
93 {
94 for (const auto& comb : combinations)
95 {
96 if (descriptor == comb.description) { return comb.result; }
97 if (descriptor == comb.description + " Cycle Slip" && comb.cycleSlipResult) { return static_cast<double>(*comb.cycleSlipResult); }
98 if (descriptor == comb.description + " Prediction") { return comb.cycleSlipPrediction; }
99 if (descriptor == comb.description + " Meas - Pred") { return comb.cycleSlipMeasMinPred; }
100 }
101 return std::nullopt;
102 }
103
104 /// @brief Returns a vector of data descriptors and values for the dynamic data
105 [[nodiscard]] std::vector<std::pair<std::string, double>> getDynamicData() const override
106 {
107 std::vector<std::pair<std::string, double>> dynData;
108 dynData.reserve(combinations.size() * 4);
109 for (const auto& comb : combinations)
110 {
111 if (comb.result) { dynData.emplace_back(comb.description, *comb.result); }
112 if (comb.cycleSlipResult) { dynData.emplace_back(comb.description + " Cycle Slip", static_cast<double>(*comb.cycleSlipResult)); }
113 if (comb.cycleSlipPrediction) { dynData.emplace_back(comb.description + " Prediction", *comb.cycleSlipPrediction); }
114 if (comb.cycleSlipMeasMinPred) { dynData.emplace_back(comb.description + " Meas - Pred", *comb.cycleSlipMeasMinPred); }
115 }
116 return dynData;
117 }
118 };
119
120 } // namespace NAV
121