28#include <Eigen/src/Core/Matrix.h>
29#include <fmt/format.h>
88 for (
const auto& satSys : satelliteSystems)
114 if (std::holds_alternative<Keys::RecvClkDrift>(key) && !states.
hasRow(key))
128void KalmanFilter::predict(
const double& dt,
const Eigen::Vector3d& lla_pos, [[maybe_unused]]
const std::string& nameId)
172 [[maybe_unused]]
const std::string& nameId)
197bool KalmanFilter::ShowGuiWidgets(
const char*
id,
bool useDoppler,
bool multiConstellation,
bool estimateInterFrequencyBiases,
float itemWidth,
float unitWidth)
199 bool changed =
false;
201 itemWidth -= ImGui::GetStyle().IndentSpacing;
202 float configWidth = itemWidth + unitWidth;
204 ImGui::SetNextItemOpen(
true, ImGuiCond_FirstUseEver);
205 if (ImGui::TreeNode(fmt::format(
"System/Process noise##{}",
id).c_str()))
209 changed |=
_motionModel.ShowGui(configWidth, unitWidth,
id);
211 if (estimateInterFrequencyBiases)
221 ImGui::SetNextItemOpen(
true, ImGuiCond_FirstUseEver);
222 if (ImGui::TreeNode(fmt::format(
"Initial Error Covariance Matrix P##{}",
id).c_str()))
228 0.0, 0.0,
"%.2e", ImGuiInputTextFlags_CharsScientific))
237 ?
"Standard deviation"
242 0.0, 0.0,
"%.2e", ImGuiInputTextFlags_CharsScientific))
248 if (multiConstellation
252 ?
"Standard deviation"
257 0.0, 0.0,
"%.2e", ImGuiInputTextFlags_CharsScientific))
268 ImGui::SetNextItemOpen(
false, ImGuiCond_FirstUseEver);
269 if (ImGui::TreeNode(fmt::format(
"Kalman Filter matrices##{}",
id).c_str()))
282 if (
const auto* bias = std::get_if<Keys::RecvClkBias>(&state))
317 if (j.contains(
"motionModel")) { j.at(
"motionModel").get_to(data.
_motionModel); }
318 if (j.contains(
"receiverClockModel")) { j.at(
"receiverClockModel").get_to(data.
_receiverClockModel); }
319 if (j.contains(
"interFrequencyBiasModel")) { j.at(
"interFrequencyBiasModel").get_to(data.
_interFrequencyBiasModel); }
Transformation collection.
nlohmann::json json
json namespace
Keys for the SPP algorithm for use inside the KeyedMatrices.
Inter Frequency Bias System Model.
Utility class for logging to console and file.
#define LOG_DEBUG
Debug information. Should not be called on functions which receive observations (spamming)
#define LOG_DATA
All output which occurs repeatedly every time observations are received.
Receiver Clock System Model.
Frequency definition for different satellite systems.
SatelliteSystem getSatSys() const
Get the satellite system for which this frequency is defined.
static constexpr double C
Speed of light [m/s].
void predict()
Do a Time Update.
The Spp Kalman Filter related options.
MotionModel< SPP::States::StateKeyType > _motionModel
Motion Model.
InitCovarianceClockDriftUnits _gui_initCovarianceClockDriftUnit
Gui selection for the Unit of the P matrix initialization clock drift uncertainty.
void deinitialize()
Deinitialize the KF (can be used to reinitialize the Filter when results seem strange)
void setClockBiasErrorCovariance(double clkPhaseDrift)
Set the P matrix entry for the covariance of the clock phase drift.
const std::vector< SPP::States::StateKeyType > & getStateKeys() const
Get the States in the Kalman Filter.
const std::array< SPP::States::StateKeyType, 6 > & PosVelKey
All position and velocity keys.
void reset(const std::vector< SatelliteSystem > &satelliteSystems)
Resets the filter.
void update(const std::vector< Meas::MeasKeyTypes > &measKeys, const KeyedMatrixXd< Meas::MeasKeyTypes, States::StateKeyType > &H, const KeyedMatrixXd< Meas::MeasKeyTypes, Meas::MeasKeyTypes > &R, const KeyedVectorXd< Meas::MeasKeyTypes > &dz, const std::string &nameId)
Does the Kalman Filter update.
const KeyedVectorXd< States::StateKeyType > & getState() const
Returns the State vector x̂
ReceiverClockModel< SPP::States::StateKeyType > _receiverClockModel
Receiver clock Model.
double _initCovarianceClockDrift
Covariance of the P matrix initialization clock drift uncertainty [m²/s²].
void initialize(const KeyedVectorXd< States::StateKeyType > &states, const KeyedMatrixXd< States::StateKeyType, States::StateKeyType > &variance)
Initialize the filter.
double _initCovarianceInterSysClockDrift
Covariance of the P matrix initialization inter system clock drift uncertainty [m²/s²].
void addInterFrequencyBias(const Frequency &freq)
Adds the frequency as inter-frequency bias state.
InitCovarianceClockDriftUnits _gui_initCovarianceInterSysClockDriftUnit
Gui selection for the Unit of the P matrix initialization inter system clock drift uncertainty.
SystemModelCalcAlgorithm _systemModelCalcAlgorithm
Algorithm to calculate the system models with.
InterFrequencyBiasModel< SPP::States::StateKeyType > _interFrequencyBiasModel
Inter-frequency bias Model.
InitCovarianceVelocityUnits _gui_initCovarianceVelocityUnit
Gui selection for the Unit of the P matrix initialization velocity uncertainty.
double _gui_initCovarianceVelocity
GUI selection for the P matrix initialization velocity uncertainty.
KeyedKalmanFilterD< SPP::States::StateKeyType, SPP::Meas::MeasKeyTypes > _kalmanFilter
Kalman Filter representation.
double _gui_initCovarianceClockDrift
GUI selection for the P matrix initialization clock drift uncertainty.
const std::array< SPP::States::StateKeyType, 3 > & VelKey
All velocity keys.
double _initCovarianceVelocity
Covariance of the P matrix initialization velocity uncertainty [m²/s²].
bool _initialized
Boolean that determines, if Kalman Filter is initialized (from weighted LSE solution)
double _gui_initCovarianceInterSysClockDrift
GUI selection for the P matrix initialization inter system clock drift uncertainty.
bool ShowGuiWidgets(const char *id, bool useDoppler, bool multiConstellation, bool estimateInterFrequencyBiases, float itemWidth, float unitWidth)
Shows the GUI input to select the options.
const KeyedMatrixXd< States::StateKeyType, States::StateKeyType > & getErrorCovarianceMatrix() const
Returns the Error covariance matrix 𝐏
bool hasRow(const RowKeyType &key) const
Checks if the matrix has the key.
const std::vector< RowKeyType > & rowKeys() const
Returns the row keys.
bool hasAnyRows(std::span< const RowKeyType > keys) const
Checks if the matrix has any key.
std::variant< Psr, Doppler > MeasKeyTypes
Alias for the measurement key type.
std::variant< Keys::MotionModelKey, Keys::RecvClkBias, Keys::RecvClkDrift, Keys::InterFreqBias > StateKeyType
Alias for the state key type.
void to_json(json &j, const Algorithm &obj)
Converts the provided object into json.
void from_json(const json &j, Algorithm &obj)
Converts the provided json object into a node object.
bool SystemModelGui(SystemModelCalcAlgorithm &algorithm, float itemWidth, const char *id)
Shows a GUI.
KeyedVectorX< double, RowKeyType > KeyedVectorXd
Dynamic size KeyedVector with double types.
KeyedKalmanFilter< double, StateKeyType, MeasKeyType > KeyedKalmanFilterD
Keyed Kalman Filter class with double as type.
KeyedVector< Scalar, RowKeyType, Eigen::Dynamic > KeyedVectorX
Dynamic size KeyedVector.
static const internal::all_t all
Used to request all rows or columns in KeyedMatrices.
KeyedMatrixX< double, RowKeyType, ColKeyType > KeyedMatrixXd
Dynamic size KeyedMatrix with double types.
Receiver clock error [m].
Receiver clock drift [m/s].