0.2.0
Loading...
Searching...
No Matches
GnssAnalyzer.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
13
14#pragma once
15
16#include <vector>
17
19
23
24namespace NAV
25{
27class GnssAnalyzer : public Node
28{
29 public:
33 ~GnssAnalyzer() override;
35 GnssAnalyzer(const GnssAnalyzer&) = delete;
42
44 [[nodiscard]] static std::string typeStatic();
45
47 [[nodiscard]] std::string type() const override;
48
50 [[nodiscard]] static std::string category();
51
54 void guiConfig() override;
55
57 [[nodiscard]] json save() const override;
58
61 void restore(const json& j) override;
62
63 private:
64 constexpr static size_t INPUT_PORT_INDEX_GNSS_OBS = 0;
65 constexpr static size_t OUTPUT_PORT_INDEX_GNSS_COMBINATION = 0;
66
68 struct Combination
69 {
71 enum class Unit
72 {
73 Meters,
74 Cycles,
75 };
76
78 Unit unit = Unit::Meters;
79
81 struct Term
82 {
84 enum class ObservationType
85 {
87 Carrier,
88 };
89
90 int sign = +1;
92 int8_t freqNum = -128;
94 bool receivedDuringRun = false;
95 };
96 std::vector<Term> terms{ Term() };
97
99 PolynomialCycleSlipDetector<std::string> polynomialCycleSlipDetector{ /* windowSize = */ 4, /* polyDegree = */ 2 };
101 double polynomialCycleSlipDetectorThresholdPercentage = 0.5;
103 bool polynomialCycleSlipDetectorOutputWhenWindowSizeNotReached = false;
105 bool polynomialCycleSlipDetectorOutputPolynomials = false;
107 std::vector<std::pair<InsTime, Polynomial<double>>> polynomials;
108
110 [[nodiscard]] std::string description() const
111 {
112 std::string desc;
113 for (const auto& term : terms)
114 {
115 if (!desc.empty()) { desc += " "; }
116 desc += term.sign == 1 ? "+" : "-";
117 desc += " ";
118 switch (term.obsType)
119 {
121 desc += unit == Unit::Cycles ? "P" : "p";
122 break;
124 desc += unit == Unit::Cycles ? "Φ" : "φ";
125 break;
126 }
127 desc += fmt::format("({})", term.satSigId);
128 }
129 if (unit == Unit::Cycles) { desc += " [cycles]"; }
130 else { desc += " [m]"; }
131
132 return desc;
133 }
134
136 [[nodiscard]] double calcCombinationFrequency() const
137 {
138 double combinedFreq = 0.0;
139 for (const auto& term : terms)
140 {
141 double freq = term.satSigId.freq().getFrequency(term.freqNum);
142 combinedFreq += static_cast<double>(term.sign) * freq;
143 }
144 return combinedFreq == 0 ? terms.front().satSigId.freq().getFrequency(terms.front().freqNum) : combinedFreq;
145 }
146 };
147
149 std::vector<Combination> _combinations{ Combination() };
150
152 bool initialize() override;
153
155 void deinitialize() override;
156
160 void receiveGnssObs(InputPin::NodeDataQueue& queue, size_t pinIdx);
161
165 friend void to_json(json& j, const Combination& data);
169 friend void from_json(const json& j, Combination& data);
173 friend void to_json(json& j, const Combination::Term& data);
177 friend void from_json(const json& j, Combination::Term& data);
178};
179
180} // namespace NAV
Combination of different cycle-slip detection algorithms.
nlohmann::json json
json namespace
Definition FlowManager.hpp:21
Node Class.
Polynomial.
Structs identifying a unique satellite.
@ G1C
GPS L1 - C/A-code.
Definition Code.hpp:95
Allows creation of GNSS measurement combinations.
Definition GnssAnalyzer.hpp:28
static std::string category()
String representation of the Class Category.
friend void from_json(const json &j, Combination::Term &data)
Read info from a json object.
static std::string typeStatic()
String representation of the Class Type.
friend void to_json(json &j, const Combination::Term &data)
Write info to a json object.
~GnssAnalyzer() override
Destructor.
GnssAnalyzer(GnssAnalyzer &&)=delete
Move constructor.
void guiConfig() override
ImGui config window which is shown on double click.
void restore(const json &j) override
Restores the node from a json object.
friend void from_json(const json &j, Combination &data)
Read info from a json object.
std::string type() const override
String representation of the Class Type.
GnssAnalyzer()
Default constructor.
GnssAnalyzer(const GnssAnalyzer &)=delete
Copy constructor.
GnssAnalyzer & operator=(const GnssAnalyzer &)=delete
Copy assignment operator.
json save() const override
Saves the node into a json object.
friend void to_json(json &j, const Combination &data)
Write info to a json object.
GnssAnalyzer & operator=(GnssAnalyzer &&)=delete
Move assignment operator.
TsDeque< std::shared_ptr< const NAV::NodeData > > NodeDataQueue
Node data queue type.
Definition Pin.hpp:703
Abstract parent class for all nodes.
Definition Node.hpp:86
Cycle-slip detection.
Definition PolynomialCycleSlipDetector.hpp:49
Term of a combination equation.
Definition GnssAnalyzer.hpp:82
int8_t freqNum
Frequency number. Only used for GLONASS G1 and G2 // TODO: Set this somewhere.
Definition GnssAnalyzer.hpp:92
SatSigId satSigId
SignalId and satellite number.
Definition GnssAnalyzer.hpp:91
ObservationType obsType
Observation Type.
Definition GnssAnalyzer.hpp:93
int sign
+1 or -1
Definition GnssAnalyzer.hpp:90
ObservationType
Observation types.
Definition GnssAnalyzer.hpp:85
bool receivedDuringRun
Flag weather the signal was received.
Definition GnssAnalyzer.hpp:94
Identifies a satellite signal (satellite frequency and number)
Definition SatelliteIdentifier.hpp:62