0.3.0
Loading...
Searching...
No Matches
InterFrequencyBiasModel.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 "Units.hpp"
17
20#include <fmt/format.h>
24
25#include "util/Logger.hpp"
26
27namespace NAV
28{
29
30namespace Keys
31{
32
35{
38 bool operator==(const InterFreqBias& rhs) const { return freq == rhs.freq; }
41};
42
43} // namespace Keys
44
46template<typename StateKeyType>
48{
49 public:
52 {
53 // Covariance of the inter-frequency bias [m²/s]
55 }
56
62 template<typename Scalar, int Size>
74
79 template<typename Scalar, int Size>
82 double dt)
83 {
84 for (const auto& key : Phi.rowKeys())
85 {
86 if (const auto* bias = std::get_if<Keys::InterFreqBias>(&key))
87 {
88 Phi(*bias, *bias) = 1;
89 Q(*bias, *bias) = _covarianceInterFrequencyBias * dt;
90 }
91 }
92 }
93
98 [[nodiscard]] std::pair<double, double> calcPhiAndQ(double dt, const Frequency& freq)
99 {
100 std::vector<StateKeyType> key = { Keys::InterFreqBias{ freq } };
101
102 KeyedMatrix<double, StateKeyType, StateKeyType, 1, 1> Phi(Eigen::Matrix<double, 1, 1>::Zero(), key, key);
103 KeyedMatrix<double, StateKeyType, StateKeyType, 1, 1> Q(Eigen::Matrix<double, 1, 1>::Zero(), key, key);
104 updatePhiAndQ(Phi, Q, dt);
105
106 return { Phi(all, all)(0), Q(all, all)(0) };
107 }
108
114 bool ShowGui(float itemWidth, float unitWidth, const char* id)
115 {
116 bool changed = false;
117
118 if (gui::widgets::InputDoubleWithUnit(fmt::format("{} of the inter-frequency bias (RW)##{}",
120 ? "StdDev"
121 : "Variance",
122 id)
123 .c_str(),
124 itemWidth, unitWidth, &_gui_covarianceInterFrequencyBias,
127 0.0, 0.0, "%.2e", ImGuiInputTextFlags_CharsScientific))
128 {
129 LOG_DEBUG("{}: _gui_covarianceInterFrequencyBias changed to {}", id, _gui_covarianceInterFrequencyBias);
130 LOG_DEBUG("{}: _gui_covarianceInterFrequencyBiasUnit changed to {}", id, to_string(_gui_covarianceInterFrequencyBiasUnit));
131 changed = true;
132 }
133
134 return changed;
135 }
136
137 private:
140
142 double _gui_covarianceInterFrequencyBias = 1e-6 /* [m²/s] */;
145
149 friend void to_json(json& j, const InterFrequencyBiasModel& data)
150 {
151 j = {
152 { "covarianceInterFrequencyBiasUnit", data._gui_covarianceInterFrequencyBiasUnit },
153 { "covarianceInterFrequencyBias", data._gui_covarianceInterFrequencyBias },
154 };
155 }
156
160 friend void from_json(const json& j, InterFrequencyBiasModel& data)
161 {
162 if (j.contains("covarianceInterFrequencyBiasUnit")) { j.at("covarianceInterFrequencyBiasUnit").get_to(data._gui_covarianceInterFrequencyBiasUnit); }
163 if (j.contains("covarianceInterFrequencyBias")) { j.at("covarianceInterFrequencyBias").get_to(data._gui_covarianceInterFrequencyBias); }
164 }
165};
166
167} // namespace NAV
168
173std::ostream& operator<<(std::ostream& os, const NAV::Keys::InterFreqBias& obj);
174
175namespace std
176{
177
179template<>
180struct hash<NAV::Keys::InterFreqBias>
181{
184 size_t operator()(const NAV::Keys::InterFreqBias& interFreqBias) const
185 {
186 return std::hash<NAV::Frequency>()(interFreqBias.freq);
187 }
188};
189
190} // namespace std
191
192#ifndef DOXYGEN_IGNORE
193
195template<>
196struct fmt::formatter<NAV::Keys::InterFreqBias> : fmt::formatter<std::string>
197{
202 template<typename FormatContext>
203 auto format(const NAV::Keys::InterFreqBias& interFreqBias, FormatContext& ctx) const
204 {
205 return fmt::formatter<std::string>::format(fmt::format("InterFreqBias({})", interFreqBias.freq), ctx);
206 }
207};
208
209#endif
nlohmann::json json
json namespace
Definition FlowManager.hpp:21
Frequency definition for different satellite systems.
double convertUnit(const double &value, Units::PositionUncertaintyUnits unit)
Converts the value depending on the unit provided.
Units used by the system model parameters.
CovarianceClkPhaseDriftUnits
Possible Units for the Standard deviation of the clock phase drift.
Definition Units.hpp:49
@ m2_s
[ m^2 / s ]
Definition Units.hpp:50
@ m_sqrts
[ m / √(s) ]
Definition Units.hpp:51
Defines Widgets which allow the input of values and the selection of the unit.
InputWithUnitChange InputDoubleWithUnit(const char *label, float itemWidth, float unitWidth, double *v, U &combo_current_item, const char *combo_items_separated_by_zeros, double step=0.0, double step_fast=0.0, const char *format="%.6f", ImGuiInputTextFlags flags=0, int combo_popup_max_height_in_items=-1)
Shows an InputText GUI element to modify the provided value and also set its unit.
Definition InputWithUnit.hpp:285
std::string MakeComboItems()
Units separated by '\0' and terminated by double '\0'.
Definition InputWithUnit.hpp:28
std::ostream & operator<<(std::ostream &os, const NAV::Keys::InterFreqBias &obj)
Stream insertion operator overload.
Utility class for logging to console and file.
#define LOG_DEBUG
Debug information. Should not be called on functions which receive observations (spamming)
Definition Logger.hpp:67
const char * to_string(gui::widgets::PositionWithFrame::ReferenceFrame refFrame)
Converts the enum to a string.
System Model.
Frequency definition for different satellite systems.
Definition Frequency.hpp:59
Inter Frequency Bias System Model.
Definition InterFrequencyBiasModel.hpp:48
void updatePhiAndQ(KeyedMatrix< Scalar, StateKeyType, StateKeyType, Size, Size > &Phi, KeyedMatrix< Scalar, StateKeyType, StateKeyType, Size, Size > &Q, double dt)
Updates the provided Phi and Q matrix.
Definition InterFrequencyBiasModel.hpp:80
std::pair< double, double > calcPhiAndQ(double dt, const Frequency &freq)
Calculates the state transition matrix (𝚽) and the process noise covariance matrix (𝐐)
Definition InterFrequencyBiasModel.hpp:98
friend void to_json(json &j, const InterFrequencyBiasModel &data)
Converts the provided data into a json object.
Definition InterFrequencyBiasModel.hpp:149
double _covarianceInterFrequencyBias
Covariance of the inter-frequency bias [m²/s].
Definition InterFrequencyBiasModel.hpp:144
void initialize()
Initializes the inter-frequency bias.
Definition InterFrequencyBiasModel.hpp:51
double _gui_covarianceInterFrequencyBias
GUI selection for the Standard deviation of the inter-frequency bias.
Definition InterFrequencyBiasModel.hpp:142
bool ShowGui(float itemWidth, float unitWidth, const char *id)
Shows a GUI.
Definition InterFrequencyBiasModel.hpp:114
Units::CovarianceClkPhaseDriftUnits _gui_covarianceInterFrequencyBiasUnit
Gui selection for the Unit of the inter-frequency covarianceInterFrequencyBias parameter.
Definition InterFrequencyBiasModel.hpp:139
void initialize(Keys::InterFreqBias bias, KeyedMatrix< Scalar, StateKeyType, StateKeyType, Size, Size > &F, KeyedMatrix< Scalar, StateKeyType, StateKeyType, Size, Size > &G, KeyedMatrix< Scalar, StateKeyType, StateKeyType, Size, Size > &W)
Initializes the inter-frequency bias.
Definition InterFrequencyBiasModel.hpp:63
friend void from_json(const json &j, InterFrequencyBiasModel &data)
Converts the provided json object into the data object.
Definition InterFrequencyBiasModel.hpp:160
Static sized KeyedMatrix.
Definition KeyedMatrix.hpp:1921
const std::vector< RowKeyType > & rowKeys() const
Returns the row keys.
Definition KeyedMatrix.hpp:80
Inter-frequency bias.
Definition InterFrequencyBiasModel.hpp:35
bool operator==(const InterFreqBias &rhs) const
Equal comparison operator.
Definition InterFrequencyBiasModel.hpp:38
Frequency freq
Frequency.
Definition InterFrequencyBiasModel.hpp:40
size_t operator()(const NAV::Keys::InterFreqBias &interFreqBias) const
Hash function.
Definition InterFrequencyBiasModel.hpp:184
Matrix which can be accessed by keys.
static const internal::all_t all
Used to request all rows or columns in KeyedMatrices.
Definition KeyedMatrix.hpp:1457