0.2.0
Loading...
Searching...
No Matches
Algorithm.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 <fmt/format.h>
17#include <set>
18
25
28
29namespace NAV
30{
31
32namespace SPP
33{
34
37{
38 public:
40 enum class EstimatorType
41 {
45 COUNT,
46 };
47
54
59 bool ShowGuiWidgets(const char* id, float itemWidth, float unitWidth);
60
62 void reset();
63
69 std::shared_ptr<SppSolution> calcSppSolution(const std::shared_ptr<const GnssObs>& gnssObs,
70 const std::vector<const GnssNavInfo*>& gnssNavInfos,
71 const std::string& nameId);
72
75 /* available */ std::unordered_set{ GnssObs::Pseudorange, GnssObs::Doppler },
76 /* needed */ std::unordered_set{ GnssObs::Pseudorange } };
77
80
81 private:
83
86 [[nodiscard]] bool canCalculateVelocity(size_t nDoppMeas) const;
87
89 [[nodiscard]] bool canEstimateInterFrequencyBias() const;
90
95 void updateInterSystemTimeDifferences(const std::set<SatelliteSystem>& usedSatSystems, size_t nDoppMeas, const std::string& nameId);
96
100 void updateInterFrequencyBiases(const Observations& observations, const std::string& nameId);
101
106 std::vector<States::StateKeyTypes> determineStateKeys(const std::set<SatelliteSystem>& usedSatSystems, size_t nDoppMeas, const std::string& nameId) const;
107
113 std::vector<Meas::MeasKeyTypes> determineMeasKeys(const Observations& observations, size_t nPsrMeas, size_t nDoppMeas, const std::string& nameId) const;
114
121 [[nodiscard]] KeyedMatrixXd<Meas::MeasKeyTypes, States::StateKeyTypes> calcMatrixH(const std::vector<States::StateKeyTypes>& stateKeys,
122 const std::vector<Meas::MeasKeyTypes>& measKeys,
123 const Observations& observations,
124 const std::string& nameId) const;
125
131 [[nodiscard]] static KeyedMatrixXd<Meas::MeasKeyTypes, Meas::MeasKeyTypes> calcMatrixR(const std::vector<Meas::MeasKeyTypes>& measKeys,
132 const Observations& observations,
133 const std::string& nameId);
134
140 [[nodiscard]] static KeyedVectorXd<Meas::MeasKeyTypes> calcMeasInnovation(const std::vector<Meas::MeasKeyTypes>& measKeys,
141 const Observations& observations,
142 const std::string& nameId);
143
152 void assignLeastSquaresResult(const KeyedVectorXd<States::StateKeyTypes>& state,
154 const Eigen::Vector3d& e_oldPos,
155 size_t nParams, size_t nUniqueDopplerMeas, double dt, const std::string& nameId);
156
161 void assignKalmanFilterResult(const KeyedVectorXd<States::StateKeyTypes>& state,
163 const std::string& nameId);
164
166 std::array<Receiver, ReceiverType::ReceiverType_COUNT> _receiver = { { Receiver(Rover) } };
167
170
172 bool _estimateInterFreqBiases = true;
173
175 SPP::KalmanFilter _kalmanFilter;
176
178 InsTime _lastUpdate;
179
180 Eigen::Matrix3d _e_lastPositionCovarianceMatrix;
181 Eigen::Matrix3d _e_lastVelocityCovarianceMatrix;
182
183 friend void to_json(json& j, const Algorithm& obj);
184 friend void from_json(const json& j, Algorithm& obj);
185};
186
190void to_json(json& j, const Algorithm& obj);
194void from_json(const json& j, Algorithm& obj);
195
196} // namespace SPP
197
201[[nodiscard]] const char* to_string(SPP::Algorithm::EstimatorType estimatorType);
202
206[[nodiscard]] const char* to_string(SPP::Algorithm::ReceiverType receiver);
207
208} // namespace NAV
209
214std::ostream& operator<<(std::ostream& os, const NAV::SPP::Algorithm::EstimatorType& obj);
215
220std::ostream& operator<<(std::ostream& os, const NAV::SPP::Algorithm::ReceiverType& obj);
221
222#ifndef DOXYGEN_IGNORE
223
225template<>
226struct fmt::formatter<NAV::SPP::Algorithm::EstimatorType> : fmt::formatter<const char*>
227{
232 template<typename FormatContext>
233 auto format(const NAV::SPP::Algorithm::EstimatorType& type, FormatContext& ctx) const
234 {
235 return fmt::formatter<const char*>::format(NAV::to_string(type), ctx);
236 }
237};
238
240template<>
241struct fmt::formatter<NAV::SPP::Algorithm::ReceiverType> : fmt::formatter<const char*>
242{
247 template<typename FormatContext>
248 auto format(const NAV::SPP::Algorithm::ReceiverType& type, FormatContext& ctx) const
249 {
250 return fmt::formatter<const char*>::format(NAV::to_string(type), ctx);
251 }
252};
253
254#endif
std::ostream & operator<<(std::ostream &os, const NAV::SPP::Algorithm::EstimatorType &obj)
Stream insertion operator overload.
nlohmann::json json
json namespace
Definition FlowManager.hpp:21
GNSS Observation messages.
Keys for the SPP algorithm for use inside the KeyedMatrices.
Calculates Observation estimates.
Observation Filter.
Observation data used for calculations.
const char * to_string(gui::widgets::PositionWithFrame::ReferenceFrame refFrame)
Converts the enum to a string.
Receiver information.
SPP Algorithm output.
@ Doppler
Doppler (Pseudorange rate)
Definition GnssObs.hpp:39
@ Pseudorange
Pseudorange.
Definition GnssObs.hpp:37
Dynamic sized KeyedMatrix.
Definition KeyedMatrix.hpp:2055
Dynamic sized KeyedVector.
Definition KeyedMatrix.hpp:1569
Calculates Observation estimates.
Definition ObservationEstimator.hpp:44
Observation Filter.
Definition ObservationFilter.hpp:45
Single Point Positioning Algorithm.
Definition Algorithm.hpp:37
friend void to_json(json &j, const Algorithm &obj)
Converts the provided object into json.
void reset()
Reset the algorithm.
EstimatorType
Possible SPP estimation algorithms.
Definition Algorithm.hpp:41
@ WeightedLeastSquares
Weighted Linear Least Squares.
@ COUNT
Amount of items in the enum.
@ LeastSquares
Linear Least Squares.
ObservationFilter _obsFilter
Observation Filter.
Definition Algorithm.hpp:74
friend void from_json(const json &j, Algorithm &obj)
Converts the provided json object into a node object.
std::shared_ptr< SppSolution > calcSppSolution(const std::shared_ptr< const GnssObs > &gnssObs, const std::vector< const GnssNavInfo * > &gnssNavInfos, const std::string &nameId)
Calculate the SPP solution.
ReceiverType
Receiver Types.
Definition Algorithm.hpp:50
@ ReceiverType_COUNT
Amount of receiver types.
Definition Algorithm.hpp:52
@ Rover
Rover.
Definition Algorithm.hpp:51
ObservationEstimator _obsEstimator
Observation Estimator.
Definition Algorithm.hpp:79
bool ShowGuiWidgets(const char *id, float itemWidth, float unitWidth)
Shows the GUI input to select the options.
Observation storage type.
Definition Observation.hpp:38
Receiver information.
Definition Receiver.hpp:35