0.4.1
Loading...
Searching...
No Matches
ReceiverClock.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 ReceiverClock.hpp
10/// @brief Receiver Clock information
11/// @author T. Topp (topp@ins.uni-stuttgart.de)
12/// @date 2023-02-07
13
14#pragma once
15
16#include <algorithm>
17#include <array>
18#include <cstddef>
19#include <cstdint>
20#include <optional>
21#include <vector>
22
25#include "util/Logger.hpp"
26
27namespace NAV
28{
29
30/// Receiver Clock information
32{
33 /// @brief Constructor
34 /// @param[in] satelliteSystems Satellite systems to add
35 explicit ReceiverClock(std::vector<SatelliteSystem> satelliteSystems)
37 {
38 bias.resize(this->satelliteSystems.size());
39 biasStdDev.resize(this->satelliteSystems.size());
40 drift.resize(this->satelliteSystems.size());
41 driftStdDev.resize(this->satelliteSystems.size());
42 }
43
44 /// @brief Add a new system
45 /// @param[in] satSys Satellite System to add
47 {
48 if (std::ranges::find(satelliteSystems, satSys) != satelliteSystems.end())
49 {
50 return;
51 }
52 satelliteSystems.push_back(satSys);
53 bias.emplace_back();
54 biasStdDev.emplace_back();
55 drift.emplace_back();
56 driftStdDev.emplace_back();
57 }
58
59 /// @brief Clear all the structures
60 void clear()
61 {
62 satelliteSystems.clear();
63 bias.clear();
64 biasStdDev.clear();
65 drift.clear();
66 driftStdDev.clear();
67 }
68
69 /// @brief Resets all structures to 0 (not removing them)
70 void reset()
71 {
72 std::ranges::for_each(bias, [](double& v) { v = 0; });
73 std::ranges::for_each(biasStdDev, [](double& v) { v = 0; });
74 std::ranges::for_each(drift, [](double& v) { v = 0; });
75 std::ranges::for_each(driftStdDev, [](double& v) { v = 0; });
76 }
77
78 /// @brief Get the bias for the given satellite system
79 /// @param[in] satSys Satellite system
80 /// @return The bias in [s] for the given satellite system. Or null if it is not found
81 [[nodiscard]] const double* biasFor(SatelliteSystem satSys) const
82 {
83 if (auto i = getIdx(satSys)) { return &bias.at(*i); }
84 return nullptr;
85 }
86 /// @brief Get the bias for the given satellite system
87 /// @param[in] satSys Satellite system
88 /// @return The bias in [s] for the given satellite system. Or null if it is not found
89 [[nodiscard]] double* biasFor(SatelliteSystem satSys)
90 {
91 if (auto i = getIdx(satSys)) { return &bias.at(*i); }
92 return nullptr;
93 }
94
95 /// @brief Get the bias StdDev for the given satellite system
96 /// @param[in] satSys Satellite system
97 /// @return The bias StdDev in [s] for the given satellite system. Or null if it is not found
98 [[nodiscard]] const double* biasStdDevFor(SatelliteSystem satSys) const
99 {
100 if (auto i = getIdx(satSys)) { return &biasStdDev.at(*i); }
101 return nullptr;
102 }
103 /// @brief Get the bias StdDev for the given satellite system
104 /// @param[in] satSys Satellite system
105 /// @return The bias StdDev in [s] for the given satellite system. Or null if it is not found
106 [[nodiscard]] double* biasStdDevFor(SatelliteSystem satSys)
107 {
108 if (auto i = getIdx(satSys)) { return &biasStdDev.at(*i); }
109 return nullptr;
110 }
111
112 /// @brief Get the drift for the given satellite system
113 /// @param[in] satSys Satellite system
114 /// @return The drift in [s/s] for the given satellite system. Or null if it is not found
115 [[nodiscard]] const double* driftFor(SatelliteSystem satSys) const
116 {
117 if (auto i = getIdx(satSys)) { return &drift.at(*i); }
118 return nullptr;
119 }
120 /// @brief Get the drift for the given satellite system
121 /// @param[in] satSys Satellite system
122 /// @return The drift in [s/s] for the given satellite system. Or null if it is not found
123 [[nodiscard]] double* driftFor(SatelliteSystem satSys)
124 {
125 if (auto i = getIdx(satSys)) { return &drift.at(*i); }
126 return nullptr;
127 }
128
129 /// @brief Get the drift StdDev for the given satellite system
130 /// @param[in] satSys Satellite system
131 /// @return The drift StdDev in [s/s] for the given satellite system. Or null if it is not found
132 [[nodiscard]] const double* driftStdDevFor(SatelliteSystem satSys) const
133 {
134 if (auto i = getIdx(satSys)) { return &driftStdDev.at(*i); }
135 return nullptr;
136 }
137 /// @brief Get the drift StdDev for the given satellite system
138 /// @param[in] satSys Satellite system
139 /// @return The drift StdDev in [s/s] for the given satellite system. Or null if it is not found
140 [[nodiscard]] double* driftStdDevFor(SatelliteSystem satSys)
141 {
142 if (auto i = getIdx(satSys)) { return &driftStdDev.at(*i); }
143 return nullptr;
144 }
145
146 /// @brief Get the index of the sat system
147 /// @param[in] satSys Satellite system
148 /// @return The index if it was in the list
149 [[nodiscard]] std::optional<size_t> getIdx(SatelliteSystem satSys) const
150 {
151 for (size_t i = 0; i < satelliteSystems.size(); i++)
152 {
153 if (satelliteSystems.at(i) == satSys) { return i; }
154 }
155 return std::nullopt;
156 }
157
158 /// Order of satellite systems
159 std::vector<SatelliteSystem> satelliteSystems;
160
161 /// Receiver clock biases for each satellite system [s]
162 std::vector<double> bias;
163 /// StdDev of the receiver clock biases for each satellite system [s]
164 std::vector<double> biasStdDev;
165 /// Receiver clock drifts for each satellite system [s/s]
166 std::vector<double> drift;
167 /// StdDev of the receiver clock drifts for each satellite system [s]
168 std::vector<double> driftStdDev;
169};
170
171} // namespace NAV
Utility class for logging to console and file.
GNSS Satellite System.
Values with an uncertainty (Standard Deviation)
void move(std::vector< T > &v, size_t sourceIdx, size_t targetIdx)
Moves an element within a vector to a new position.
Definition Vector.hpp:27
std::vector< double > drift
Receiver clock drifts for each satellite system [s/s].
double * biasStdDevFor(SatelliteSystem satSys)
Get the bias StdDev for the given satellite system.
const double * biasFor(SatelliteSystem satSys) const
Get the bias for the given satellite system.
std::vector< double > biasStdDev
StdDev of the receiver clock biases for each satellite system [s].
std::vector< double > driftStdDev
StdDev of the receiver clock drifts for each satellite system [s].
double * driftFor(SatelliteSystem satSys)
Get the drift for the given satellite system.
std::vector< double > bias
Receiver clock biases for each satellite system [s].
std::vector< SatelliteSystem > satelliteSystems
Order of satellite systems.
const double * biasStdDevFor(SatelliteSystem satSys) const
Get the bias StdDev for the given satellite system.
void clear()
Clear all the structures.
const double * driftStdDevFor(SatelliteSystem satSys) const
Get the drift StdDev for the given satellite system.
std::optional< size_t > getIdx(SatelliteSystem satSys) const
Get the index of the sat system.
double * driftStdDevFor(SatelliteSystem satSys)
Get the drift StdDev for the given satellite system.
double * biasFor(SatelliteSystem satSys)
Get the bias for the given satellite system.
void reset()
Resets all structures to 0 (not removing them)
ReceiverClock(std::vector< SatelliteSystem > satelliteSystems)
Constructor.
void addSystem(SatelliteSystem satSys)
Add a new system.
const double * driftFor(SatelliteSystem satSys) const
Get the drift for the given satellite system.
Satellite System type.