74 if (!detector.polyReg.windowSizeReached())
80 auto polynomial = detector.polyReg.calcPolynomial();
83 if (std::abs(measurementDifference - predictedValue) > threshold)
130 detector.second.polyReg.setWindowSize(windowSize);
143 detector.second.polyReg.setPolynomialDegree(polyDegree);
159 detector.second.polyReg.setStrategy(strategy);
190 return static_cast<double>((insTime - detector.
startTime).count());
211 auto polynomial = detector.polyReg.calcPolynomial();
217 [[nodiscard]] std::optional<Polynomial<double>>
calcPolynomial(
const Key& key)
const
221 return _detectors.at(key).polyReg.calcPolynomial();
233 detector.polyReg.push_back(
calcRelativeTime(insTime, detector), measurementDifference);
244template<
typename Key>
247 bool changed =
false;
249 bool enabled = polynomialCycleSlipDetector.
isEnabled();
250 if (ImGui::Checkbox(fmt::format(
"Enabled##{}", label).c_str(), &enabled))
253 polynomialCycleSlipDetector.
setEnabled(enabled);
256 if (!enabled) { ImGui::BeginDisabled(); }
258 ImGui::SetNextItemWidth(width);
259 if (
int windowSize =
static_cast<int>(polynomialCycleSlipDetector.
getWindowSize());
260 ImGui::InputIntL(fmt::format(
"Window size##{}", label).c_str(), &windowSize,
264 polynomialCycleSlipDetector.
setWindowSize(
static_cast<size_t>(windowSize));
267 ImGui::SetNextItemWidth(width);
269 ImGui::InputIntL(fmt::format(
"Polynomial Degree##{}", label).c_str(), &polyDegree,
270 0, std::min(
static_cast<int>(polynomialCycleSlipDetector.
getWindowSize()) - 1, std::numeric_limits<int>::max())))
276 ImGui::SetNextItemWidth(width);
284 if (!enabled) { ImGui::EndDisabled(); }
292template<
typename Key>
305template<
typename Key>
308 if (j.contains(
"enabled"))
310 auto enabled = j.at(
"enabled").get<
bool>();
313 if (j.contains(
"windowSize"))
315 auto windowSize = j.at(
"windowSize").get<
size_t>();
318 if (j.contains(
"polynomialDegree"))
320 auto polynomialDegree = j.at(
"polynomialDegree").get<
size_t>();
323 if (j.contains(
"strategy"))
325 auto strategy = j.at(
"strategy").get<
size_t>();
Combo representing an enumeration.
nlohmann::json json
json namespace
The class is responsible for all time-related tasks.
Utility functions for std::pair.
Polynomial curve fitting.
Structs identifying a unique satellite.
ankerl::unordered_dense::map< Key, T > unordered_map
Unordered map type.
Allows creation of GNSS measurement combinations.
The class is responsible for all time-related tasks.
size_t getPolynomialDegree() const
Get the degree of the polynomial which is used for fitting.
void setFitStrategy(Strategy strategy)
Sets the strategy used for fitting.
void setWindowSize(size_t windowSize)
Sets the amount of points used for the fit (sliding window)
void addMeasurement(const Key &key, InsTime insTime, double measurementDifference)
Add a measurement to the polynomial fit.
std::optional< double > predictValue(const Key &key, const InsTime &insTime) const
Predicts a value from the collected data and polynomial fit.
void setEnabled(bool enabled)
Sets the enabled state.
PolynomialRegressor<>::Strategy Strategy
Strategies for fitting.
friend class CycleSlipDetector
bool isEnabled() const
Is the cycle-slip detector enabled?
std::optional< double > calcRelativeTime(const Key &key, const InsTime &insTime) const
Calculate the relative time to the start time of the detector.
void setPolynomialDegree(size_t polyDegree)
Sets the degree of the polynomial which is used for fitting.
size_t getWindowSize() const
Get the window size for the polynomial fit.
static double calcRelativeTime(const InsTime &insTime, const SignalDetector &detector)
Calculate the relative time to the start time of the detector.
Strategy _strategy
Strategy used for fitting.
std::optional< Polynomial< double > > calcPolynomial(const Key &key) const
Calculates the polynomial from the collected data.
PolynomialCycleSlipDetectorResult checkForCycleSlip(const Key &key, InsTime insTime, double measurementDifference, double threshold)
Checks for a cycle slip.
size_t _windowSize
Window size for the sliding window.
bool _enabled
Whether the cycle-slip detector is enabled.
Strategy getFitStrategy() const
Get the strategy used for fitting.
size_t _polyDegree
Polynomial degree to fit.
void reset(const Key &key)
Reset the polynomial for the given combination.
unordered_map< Key, SignalDetector > _detectors
Detectors, one for each key.
PolynomialCycleSlipDetector(size_t windowSize, size_t polyDegree, bool enabled=true)
Constructor.
friend class GnssAnalyzer
void clear()
Empties the collected polynomials.
Polynomial Curve Fitting.
Strategy
Possible Fit strategies.
bool InputIntL(const char *label, int *v, int v_min, int v_max, int step, int step_fast, ImGuiInputTextFlags flags)
Shows a value limited InputText GUI element for 'int'.
void to_json(json &j, const Node &node)
Converts the provided node into a json object.
PolynomialCycleSlipDetectorResult
Cycle-slip detection result type.
@ NoCycleSlip
No cycle-slip found.
@ LessDataThanWindowSize
Less data than the specified window size (cannot predict cycle-slip yet)
@ Disabled
The cycle-slip detector is disabled.
@ CycleSlip
Cycle-slip found.
void from_json(const json &j, Node &node)
Converts the provided json object into a node object.
bool PolynomialCycleSlipDetectorGui(const char *label, PolynomialCycleSlipDetector< Key > &polynomialCycleSlipDetector, float width=0.0F)
Shows a GUI for advanced configuration of the PolynomialCycleSlipDetector.
SignalDetector(InsTime startTime, size_t windowSize, size_t polyDegree, Strategy strategy)
Constructor.
PolynomialRegressor< double > polyReg
Polynomial Regressor.
InsTime startTime
Time when the first message for this detector was received.