0.4.1
Loading...
Searching...
No Matches
MeasurementErrors.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 MeasurementErrors.hpp
10/// @brief Errors concerning GNSS observations
11/// @author T. Topp (topp@ins.uni-stuttgart.de)
12/// @date 2023-06-09
13/// #### Model descriptions
14/// @anchor GNSS-MeasErrorModel
15
16#pragma once
17
18#include <array>
19
23
25
26namespace NAV
27{
28
29/// @brief Errors concerning GNSS observations
31{
32 public:
33 /// @brief Default constructor
35
36 /// @brief Models
37 enum Model : uint8_t
38 {
39 None, ///< Measurement error model turned off
40 SINE, ///< Sine. See \cite Dach2015 Dach 2015
41 SINE_OFFSET, ///< Sine with offset. See \cite Zhang2021 Zhang 2021 eq. 7, p. 3
42 SINE_CN0, ///< Sine and CN0 dependent. See \cite Groves2013 Groves, ch. 9.4.2.4, eq. 9.168, p. 422 (range acceleration is neglected)
43 RTKLIB, ///< RTKLIB error model. See \cite RTKLIB RTKLIB ch. E.6, eq. E.6.24, p. 162
44 SINE_SQRT, ///< Sine square-root. See \cite Kiliszek2022 Kiliszek 2022, table 2, p. 5
45 EXPONENTIAL, ///< Exponential. See \cite EulerGoad1991 Euler and Goad 1991 / \cite Li2016 Li et al. 2016
46 COSINE_TYPE, ///< Cosine Type. See \cite Hadas2020 Hadas 2020 eq. 14, p. 8
47 COUNT, ///< Amount of items in the enum
48 };
49
50 /// @brief Calculates the measurement Error Variance for pseudorange observations
51 /// @param[in] satSys Satellite System
52 /// @param[in] elevation Satellite Elevation in [rad]
53 /// @param[in] cn0 Carrier-to-Noise density [dB-Hz]
54 /// @return Variance of the measurement error [m^2]
55 [[nodiscard]] double psrMeasErrorVar(const SatelliteSystem& satSys, double elevation, double cn0) const;
56
57 /// @brief Calculates the measurement Error Variance for carrier-phase observations
58 /// @param[in] satSys Satellite System
59 /// @param[in] elevation Satellite Elevation in [rad]
60 /// @param[in] cn0 Carrier-to-Noise density [dB-Hz]
61 /// @return Variance of the measurement error [m^2]
62 [[nodiscard]] double carrierMeasErrorVar(const SatelliteSystem& satSys, double elevation, double cn0) const;
63
64 /// @brief Returns the Pseudo-range rate Error Variance
65 /// @param[in] freq Frequency the measurement originates from
66 /// @param[in] num Frequency number. Only used for GLONASS G1 and G2
67 /// @param[in] elevation Satellite Elevation in [rad]
68 /// @param[in] cn0 Carrier-to-Noise density [dB-Hz]
69 /// @return Variance of the Pseudo-range rate error [m^2/s^2]
70 [[nodiscard]] double psrRateMeasErrorVar(const Frequency& freq, int8_t num, double elevation, double cn0) const;
71
72 /// @brief Returns the Code Bias Error Variance
73 /// @return Variance of the code bias error [m^2]
74 [[nodiscard]] double codeBiasErrorVar() const;
75
76 /// @brief Shows a GUI widgets
77 /// @param[in] id Unique id for ImGui.
78 /// @param[in] width Width of the widgets
79 bool ShowGuiWidgets(const char* id, float width);
80
81 private:
82 /// @brief Model to use
84
85 /// Carrier Measurement error standard deviation per Frequency [m]
86 double _carrierStdDev = 0.003;
87 /// Code/Pseudorange Measurement error standard deviation per Frequency [m]
88 double _codeStdDev = 0.9;
89 /// Doppler Frequency error factor [Hz] - Measurement error standard deviation
90 double _dopplerStdDev = 1;
91
92 /// @brief Carrier-to-Noise density [dB-Hz] to use in the plot
93 double _plotCN0 = 30;
94
95 // #######################################################################################################
96
97 /// Model parameters for the 'sine' model
99 {
100 double a = 1.0; ///< Coefficient
101 };
102 /// Model parameters for the 'sine' model
104
105 /// Model parameters for the 'sine + offset' model
107 {
108 double a = 0.5; ///< Coefficient
109 double b = 0.5; ///< Coefficient
110 };
111 /// Model parameters for the 'sine + offset' model
113
114 /// Model parameters for the 'sine + CN0' model
116 {
117 double a = 1.0; ///< Coefficient
118 double b = 1.0; ///< Coefficient
119 double c = 1.0; ///< Factor to weight the CN0 dependant part
120 };
121 /// Model parameters for the 'sine + CN0' model
123
124 /// Model parameters for the 'RTKLIB' model
126 {
127 double a = 1.0; ///< Coefficient
128 double b = 1.0; ///< Coefficient
129 };
130 /// Model parameters for the 'RTKLIB' model
132
133 /// Model parameters for the 'sine - sqrt' model
135 {
136 double a = 0.8; ///< Coefficient
137 double b = 0.6; ///< Coefficient
138 };
139 /// Model parameters for the 'sine - sqrt' model
141
142 /// Model parameters for the 'exponential' model
144 {
145 double a = 1.0; ///< Coefficient
146 double b = 3.5; ///< Coefficient
147 double e0 = 9; ///< Coefficient [deg]
148 };
149 /// Model parameters for the 'exponential' model
151
152 /// Model parameters for the 'cosine - type' model
154 {
155 double a = 1.0; ///< Coefficient
156 double b = 4.0; ///< Coefficient
157 int n = 8; ///< Coefficient
158 };
159 /// Model parameters for the 'cosine - type' model
161
162 // #######################################################################################################
163
164 /// @brief Amount of samples for the plot
165 static constexpr size_t PLOT_SAMPLES = 9001;
166 /// @brief Elevation data for plotting [rad]
167 static constexpr std::array<double, PLOT_SAMPLES> _elevation = genRangeArray<PLOT_SAMPLES>(0.0, deg2rad(0.01), deg2rad(90.001));
168 /// @brief Elevation data for plotting [rad]
169 static constexpr std::array<double, PLOT_SAMPLES> _elevation_deg = genRangeArray<PLOT_SAMPLES>(0.0, 0.01, 90.001);
170 /// @brief Standard deviations for plotting
171 std::vector<std::vector<double>> _stdDevCurvePlot{ Model::COUNT, std::vector<double>(PLOT_SAMPLES) };
172
173 /// @brief Calculates the weighting function for the standard deviation
174 /// @param[in] model Model to use
175 /// @param[in] elevation Satellite Elevation in [rad]
176 /// @param[in] cn0 Carrier-to-Noise density [dB-Hz]
177 [[nodiscard]] double weightingFunction(Model model, double elevation, double cn0) const;
178
179 /// @brief Returns an error factor for the variance depending on the satellite system
180 /// @param satSys Satellite system
181 [[nodiscard]] static double satSysErrorFactorVariance(const SatelliteSystem& satSys);
182
183 /// @brief Updates the curve plot data for the given model
184 /// @param model Error model to use
185 void updateStdDevCurvePlot(Model model);
186
187 friend void to_json(json& j, const GnssMeasurementErrorModel& obj);
188 friend void from_json(const json& j, GnssMeasurementErrorModel& obj);
189
190 friend void to_json(json& j, const ModelParametersSine& obj);
191 friend void from_json(const json& j, ModelParametersSine& obj);
192
193 friend void to_json(json& j, const ModelParametersSineOffset& obj);
194 friend void from_json(const json& j, ModelParametersSineOffset& obj);
195
196 friend void to_json(json& j, const ModelParametersSineCN0& obj);
197 friend void from_json(const json& j, ModelParametersSineCN0& obj);
198
199 friend void to_json(json& j, const ModelParametersRtklib& obj);
200 friend void from_json(const json& j, ModelParametersRtklib& obj);
201
202 friend void to_json(json& j, const ModelParametersSineSqrt& obj);
203 friend void from_json(const json& j, ModelParametersSineSqrt& obj);
204
205 friend void to_json(json& j, const ModelParametersExponential& obj);
206 friend void from_json(const json& j, ModelParametersExponential& obj);
207
208 friend void to_json(json& j, const ModelParametersCosineType& obj);
209 friend void from_json(const json& j, ModelParametersCosineType& obj);
210};
211
212/// @brief Converts the enum to a string
213/// @param[in] model Enum value to convert into text
214/// @return String representation of the enum
216
217/// @brief Converts the provided object into json
218/// @param[out] j Json object which gets filled with the info
219/// @param[in] obj Object to convert into json
220void to_json(json& j, const GnssMeasurementErrorModel& obj);
221/// @brief Converts the provided json object into a node object
222/// @param[in] j Json object with the needed values
223/// @param[out] obj Object to fill from the json
224void from_json(const json& j, GnssMeasurementErrorModel& obj);
225
226/// @brief Converts the provided object into json
227/// @param[out] j Json object which gets filled with the info
228/// @param[in] obj Object to convert into json
229void to_json(json& j, const GnssMeasurementErrorModel::ModelParametersSine& obj);
230/// @brief Converts the provided json object into a node object
231/// @param[in] j Json object with the needed values
232/// @param[out] obj Object to fill from the json
233void from_json(const json& j, GnssMeasurementErrorModel::ModelParametersSine& obj);
234
235/// @brief Converts the provided object into json
236/// @param[out] j Json object which gets filled with the info
237/// @param[in] obj Object to convert into json
238void to_json(json& j, const GnssMeasurementErrorModel::ModelParametersSineOffset& obj);
239/// @brief Converts the provided json object into a node object
240/// @param[in] j Json object with the needed values
241/// @param[out] obj Object to fill from the json
242void from_json(const json& j, GnssMeasurementErrorModel::ModelParametersSineOffset& obj);
243
244/// @brief Converts the provided object into json
245/// @param[out] j Json object which gets filled with the info
246/// @param[in] obj Object to convert into json
247void to_json(json& j, const GnssMeasurementErrorModel::ModelParametersSineCN0& obj);
248/// @brief Converts the provided json object into a node object
249/// @param[in] j Json object with the needed values
250/// @param[out] obj Object to fill from the json
251void from_json(const json& j, GnssMeasurementErrorModel::ModelParametersSineCN0& obj);
252
253/// @brief Converts the provided object into json
254/// @param[out] j Json object which gets filled with the info
255/// @param[in] obj Object to convert into json
256void to_json(json& j, const GnssMeasurementErrorModel::ModelParametersRtklib& obj);
257/// @brief Converts the provided json object into a node object
258/// @param[in] j Json object with the needed values
259/// @param[out] obj Object to fill from the json
260void from_json(const json& j, GnssMeasurementErrorModel::ModelParametersRtklib& obj);
261
262/// @brief Converts the provided object into json
263/// @param[out] j Json object which gets filled with the info
264/// @param[in] obj Object to convert into json
265void to_json(json& j, const GnssMeasurementErrorModel::ModelParametersSineSqrt& obj);
266/// @brief Converts the provided json object into a node object
267/// @param[in] j Json object with the needed values
268/// @param[out] obj Object to fill from the json
269void from_json(const json& j, GnssMeasurementErrorModel::ModelParametersSineSqrt& obj);
270
271/// @brief Converts the provided object into json
272/// @param[out] j Json object which gets filled with the info
273/// @param[in] obj Object to convert into json
274void to_json(json& j, const GnssMeasurementErrorModel::ModelParametersExponential& obj);
275/// @brief Converts the provided json object into a node object
276/// @param[in] j Json object with the needed values
277/// @param[out] obj Object to fill from the json
278void from_json(const json& j, GnssMeasurementErrorModel::ModelParametersExponential& obj);
279
280/// @brief Converts the provided object into json
281/// @param[out] j Json object which gets filled with the info
282/// @param[in] obj Object to convert into json
283void to_json(json& j, const GnssMeasurementErrorModel::ModelParametersCosineType& obj);
284/// @brief Converts the provided json object into a node object
285/// @param[in] j Json object with the needed values
286/// @param[out] obj Object to fill from the json
287void from_json(const json& j, GnssMeasurementErrorModel::ModelParametersCosineType& obj);
288
289} // namespace NAV
Array Utility functions.
nlohmann::json json
json namespace
Frequency definition for different satellite systems.
GNSS Satellite System.
Frequency definition for different satellite systems.
Definition Frequency.hpp:59
Errors concerning GNSS observations.
void updateStdDevCurvePlot(Model model)
Updates the curve plot data for the given model.
ModelParametersCosineType _modelParametersCosineType
Model parameters for the 'cosine - type' model.
ModelParametersExponential _modelParametersExponential
Model parameters for the 'exponential' model.
double _carrierStdDev
Carrier Measurement error standard deviation per Frequency [m].
double carrierMeasErrorVar(const SatelliteSystem &satSys, double elevation, double cn0) const
Calculates the measurement Error Variance for carrier-phase observations.
double _codeStdDev
Code/Pseudorange Measurement error standard deviation per Frequency [m].
GnssMeasurementErrorModel()
Default constructor.
ModelParametersSine _modelParametersSine
Model parameters for the 'sine' model.
double weightingFunction(Model model, double elevation, double cn0) const
Calculates the weighting function for the standard deviation.
friend void to_json(json &j, const GnssMeasurementErrorModel &obj)
Converts the provided object into json.
ModelParametersSineOffset _modelParametersSineOffset
Model parameters for the 'sine + offset' model.
double _plotCN0
Carrier-to-Noise density [dB-Hz] to use in the plot.
std::vector< std::vector< double > > _stdDevCurvePlot
Standard deviations for plotting.
double codeBiasErrorVar() const
Returns the Code Bias Error Variance.
@ SINE_CN0
Sine and CN0 dependent. See groves2013 Groves, ch. 9.4.2.4, eq. 9.168, p. 422 (range acceleration is ...
@ None
Measurement error model turned off.
@ COUNT
Amount of items in the enum.
@ EXPONENTIAL
Exponential. See eulergoad1991 Euler and Goad 1991 / li2016 Li et al. 2016.
@ SINE
Sine. See dach2015 Dach 2015.
@ RTKLIB
RTKLIB error model. See rtklib RTKLIB ch. E.6, eq. E.6.24, p. 162.
@ COSINE_TYPE
Cosine Type. See hadas2020 Hadas 2020 eq. 14, p. 8.
@ SINE_SQRT
Sine square-root. See kiliszek2022 Kiliszek 2022, table 2, p. 5.
@ SINE_OFFSET
Sine with offset. See zhang2021 Zhang 2021 eq. 7, p. 3.
friend void from_json(const json &j, GnssMeasurementErrorModel &obj)
Converts the provided json object into a node object.
bool ShowGuiWidgets(const char *id, float width)
Shows a GUI widgets.
double psrRateMeasErrorVar(const Frequency &freq, int8_t num, double elevation, double cn0) const
Returns the Pseudo-range rate Error Variance.
static constexpr size_t PLOT_SAMPLES
Amount of samples for the plot.
ModelParametersSineCN0 _modelParametersSineCN0
Model parameters for the 'sine + CN0' model.
static constexpr std::array< double, PLOT_SAMPLES > _elevation_deg
Elevation data for plotting [rad].
double psrMeasErrorVar(const SatelliteSystem &satSys, double elevation, double cn0) const
Calculates the measurement Error Variance for pseudorange observations.
static double satSysErrorFactorVariance(const SatelliteSystem &satSys)
Returns an error factor for the variance depending on the satellite system.
double _dopplerStdDev
Doppler Frequency error factor [Hz] - Measurement error standard deviation.
ModelParametersRtklib _modelParametersRtklib
Model parameters for the 'RTKLIB' model.
ModelParametersSineSqrt _modelParametersSineSqrt
Model parameters for the 'sine - sqrt' model.
static constexpr std::array< double, PLOT_SAMPLES > _elevation
Elevation data for plotting [rad].
void to_json(json &j, const Node &node)
Converts the provided node into a json object.
Definition Node.cpp:990
constexpr std::array< Scalar, N > genRangeArray(Scalar start, Scalar stepSize, Scalar end)
Returns a container filled with the given range.
Definition Array.hpp:52
const char * to_string(gui::widgets::PositionWithFrame::ReferenceFrame refFrame)
Converts the enum to a string.
void from_json(const json &j, Node &node)
Converts the provided json object into a node object.
Definition Node.cpp:1007
constexpr auto deg2rad(const T &deg)
Convert Degree to Radians.
Definition Units.hpp:21
Model parameters for the 'cosine - type' model.
Model parameters for the 'exponential' model.
Model parameters for the 'sine + CN0' model.
double c
Factor to weight the CN0 dependant part.
Model parameters for the 'sine + offset' model.
Model parameters for the 'sine - sqrt' model.
Satellite System type.