0.2.0
Loading...
Searching...
No Matches
Keys.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 <vector>
17#include <variant>
18#include <fmt/format.h>
19
21
22namespace NAV::SPP
23{
24
25namespace States
26{
40
41constexpr size_t POS_STATE_COUNT = 4;
42constexpr size_t VEL_STATE_COUNT = 4;
43
44constexpr size_t POS_VEL_STATE_COUNT = 6;
45
48{
51 bool operator==(const InterSysBias& rhs) const { return satSys == rhs.satSys; }
54};
57{
60 bool operator==(const InterSysDrift& rhs) const { return satSys == rhs.satSys; }
63};
66{
69 bool operator==(const InterFreqBias& rhs) const { return freq == rhs.freq; }
72};
73
75using StateKeyTypes = std::variant<SppStates, InterSysBias, InterSysDrift, InterFreqBias>;
77inline static const std::vector<StateKeyTypes> Pos = { SppStates::PosX, SppStates::PosY, SppStates::PosZ };
79inline static const std::vector<StateKeyTypes> Vel = { SppStates::VelX, SppStates::VelY, SppStates::VelZ };
81inline static const std::vector<StateKeyTypes> RecvClk = { SppStates::RecvClkErr, SppStates::RecvClkDrift };
83inline static const std::vector<StateKeyTypes> PosVel = { SppStates::PosX, SppStates::PosY, SppStates::PosZ,
84 SppStates::VelX, SppStates::VelY, SppStates::VelZ };
86inline static const std::vector<StateKeyTypes> PosVelRecvClkErr = { SppStates::PosX, SppStates::PosY, SppStates::PosZ,
87 SppStates::VelX, SppStates::VelY, SppStates::VelZ,
88 SppStates::RecvClkErr };
90inline static const std::vector<StateKeyTypes> PosVelRecvClk = { SppStates::PosX, SppStates::PosY, SppStates::PosZ,
91 SppStates::VelX, SppStates::VelY, SppStates::VelZ,
92 SppStates::RecvClkErr, SppStates::RecvClkDrift };
93
95inline static const std::vector<StateKeyTypes> PosRecvClkErr = { SppStates::PosX, SppStates::PosY, SppStates::PosZ,
96 SppStates::RecvClkErr };
98inline static const std::vector<StateKeyTypes> VelRecvClkDrift = { SppStates::VelX, SppStates::VelY, SppStates::VelZ,
99 SppStates::RecvClkDrift };
100
101} // namespace States
102
103namespace Meas
104{
105
107struct Psr
108{
111 bool operator==(const Psr& rhs) const { return satSigId == rhs.satSigId; }
114};
117{
120 bool operator==(const Doppler& rhs) const { return satSigId == rhs.satSigId; }
123};
124
126using MeasKeyTypes = std::variant<Psr, Doppler>;
127
128} // namespace Meas
129
130} // namespace NAV::SPP
131
136std::ostream& operator<<(std::ostream& os, const NAV::SPP::States::SppStates& obj);
137
142std::ostream& operator<<(std::ostream& os, const NAV::SPP::States::InterSysBias& obj);
143
148std::ostream& operator<<(std::ostream& os, const NAV::SPP::States::InterSysDrift& obj);
149
154std::ostream& operator<<(std::ostream& os, const NAV::SPP::States::InterFreqBias& obj);
155
160std::ostream& operator<<(std::ostream& os, const NAV::SPP::Meas::Psr& obj);
161
166std::ostream& operator<<(std::ostream& os, const NAV::SPP::Meas::Doppler& obj);
167
172std::ostream& operator<<(std::ostream& os, const NAV::SPP::States::StateKeyTypes& obj);
173
178std::ostream& operator<<(std::ostream& os, const NAV::SPP::Meas::MeasKeyTypes& obj);
179
180namespace std
181{
183template<>
184struct hash<NAV::SPP::States::InterSysBias>
185{
188 size_t operator()(const NAV::SPP::States::InterSysBias& interSysBias) const
189 {
190 return NAV::SPP::States::SppStates_COUNT + std::hash<NAV::SatelliteSystem>()(interSysBias.satSys);
191 }
192};
194template<>
195struct hash<NAV::SPP::States::InterSysDrift>
196{
199 size_t operator()(const NAV::SPP::States::InterSysDrift& interSysDrift) const
200 {
201 return NAV::SPP::States::SppStates_COUNT + std::hash<NAV::SatelliteSystem>()(interSysDrift.satSys);
202 }
203};
205template<>
206struct hash<NAV::SPP::States::InterFreqBias>
207{
210 size_t operator()(const NAV::SPP::States::InterFreqBias& interFreqBias) const
211 {
212 return NAV::SPP::States::SppStates_COUNT + std::hash<NAV::Frequency>()(interFreqBias.freq);
213 }
214};
216template<>
217struct hash<NAV::SPP::Meas::Psr>
218{
221 size_t operator()(const NAV::SPP::Meas::Psr& psr) const
222 {
223 return std::hash<NAV::SatSigId>()(psr.satSigId);
224 }
225};
227template<>
228struct hash<NAV::SPP::Meas::Doppler>
229{
232 size_t operator()(const NAV::SPP::Meas::Doppler& doppler) const
233 {
234 return std::hash<NAV::SatSigId>()(doppler.satSigId) << 12;
235 }
236};
237} // namespace std
238
239#ifndef DOXYGEN_IGNORE
240
242template<>
243struct fmt::formatter<NAV::SPP::States::SppStates> : fmt::formatter<const char*>
244{
249 template<typename FormatContext>
250 auto format(const NAV::SPP::States::SppStates& state, FormatContext& ctx)
251 {
252 using namespace NAV::SPP::States; // NOLINT(google-build-using-namespace)
253
254 switch (state)
255 {
256 case PosX:
257 return fmt::formatter<const char*>::format("PosX", ctx);
258 case PosY:
259 return fmt::formatter<const char*>::format("PosY", ctx);
260 case PosZ:
261 return fmt::formatter<const char*>::format("PosZ", ctx);
262 case VelX:
263 return fmt::formatter<const char*>::format("VelX", ctx);
264 case VelY:
265 return fmt::formatter<const char*>::format("VelY", ctx);
266 case VelZ:
267 return fmt::formatter<const char*>::format("VelZ", ctx);
268 case RecvClkErr:
269 return fmt::formatter<const char*>::format("RecvClkErr", ctx);
270 case RecvClkDrift:
271 return fmt::formatter<const char*>::format("RecvClkDrift", ctx);
272 case SppStates_COUNT:
273 return fmt::formatter<const char*>::format("SppStates_COUNT", ctx);
274 }
275
276 return fmt::formatter<const char*>::format("ERROR", ctx);
277 }
278};
279
281template<>
282struct fmt::formatter<NAV::SPP::States::InterSysBias> : fmt::formatter<std::string>
283{
288 template<typename FormatContext>
289 auto format(const NAV::SPP::States::InterSysBias& interSysBias, FormatContext& ctx)
290 {
291 return fmt::formatter<std::string>::format(fmt::format("InterSysBias({})", interSysBias.satSys), ctx);
292 }
293};
294
296template<>
297struct fmt::formatter<NAV::SPP::States::InterSysDrift> : fmt::formatter<std::string>
298{
303 template<typename FormatContext>
304 auto format(const NAV::SPP::States::InterSysDrift& interSysDrift, FormatContext& ctx)
305 {
306 return fmt::formatter<std::string>::format(fmt::format("InterSysDrift({})", interSysDrift.satSys), ctx);
307 }
308};
309
311template<>
312struct fmt::formatter<NAV::SPP::States::InterFreqBias> : fmt::formatter<std::string>
313{
318 template<typename FormatContext>
319 auto format(const NAV::SPP::States::InterFreqBias& interFreqBias, FormatContext& ctx)
320 {
321 return fmt::formatter<std::string>::format(fmt::format("InterFreqBias({})", interFreqBias.freq), ctx);
322 }
323};
324
326template<>
327struct fmt::formatter<NAV::SPP::Meas::Psr> : fmt::formatter<std::string>
328{
333 template<typename FormatContext>
334 auto format(const NAV::SPP::Meas::Psr& psr, FormatContext& ctx)
335 {
336 return fmt::formatter<std::string>::format(fmt::format("psr({})", psr.satSigId), ctx);
337 }
338};
339
341template<>
342struct fmt::formatter<NAV::SPP::Meas::Doppler> : fmt::formatter<std::string>
343{
348 template<typename FormatContext>
349 auto format(const NAV::SPP::Meas::Doppler& doppler, FormatContext& ctx)
350 {
351 return fmt::formatter<std::string>::format(fmt::format("dop({})", doppler.satSigId), ctx);
352 }
353};
354
356template<>
357struct fmt::formatter<NAV::SPP::States::StateKeyTypes> : fmt::formatter<std::string>
358{
363 template<typename FormatContext>
364 auto format(const NAV::SPP::States::StateKeyTypes& state, FormatContext& ctx)
365 {
366 using namespace NAV::SPP::States; // NOLINT(google-build-using-namespace)
367
368 if (const auto* s = std::get_if<NAV::SPP::States::SppStates>(&state))
369 {
370 switch (*s)
371 {
372 case PosX:
373 return fmt::formatter<std::string>::format("PosX", ctx);
374 case PosY:
375 return fmt::formatter<std::string>::format("PosY", ctx);
376 case PosZ:
377 return fmt::formatter<std::string>::format("PosZ", ctx);
378 case VelX:
379 return fmt::formatter<std::string>::format("VelX", ctx);
380 case VelY:
381 return fmt::formatter<std::string>::format("VelY", ctx);
382 case VelZ:
383 return fmt::formatter<std::string>::format("VelZ", ctx);
384 case RecvClkErr:
385 return fmt::formatter<std::string>::format("RecvClkErr", ctx);
386 case RecvClkDrift:
387 return fmt::formatter<std::string>::format("RecvClkDrift", ctx);
388 case SppStates_COUNT:
389 return fmt::formatter<std::string>::format("SppStates_COUNT", ctx);
390 }
391 }
392 if (const auto* interSysBias = std::get_if<NAV::SPP::States::InterSysBias>(&state))
393 {
394 return fmt::formatter<std::string>::format(fmt::format("InterSysBias({}))", interSysBias->satSys), ctx);
395 }
396 if (const auto* interSysDrift = std::get_if<NAV::SPP::States::InterSysDrift>(&state))
397 {
398 return fmt::formatter<std::string>::format(fmt::format("InterSysDrift({}))", interSysDrift->satSys), ctx);
399 }
400 if (const auto* interFreqBias = std::get_if<NAV::SPP::States::InterFreqBias>(&state))
401 {
402 return fmt::formatter<std::string>::format(fmt::format("InterFreqBias({}))", interFreqBias->freq), ctx);
403 }
404
405 return fmt::formatter<std::string>::format("ERROR", ctx);
406 }
407};
408
410template<>
411struct fmt::formatter<NAV::SPP::Meas::MeasKeyTypes> : fmt::formatter<std::string>
412{
417 template<typename FormatContext>
418 auto format(const NAV::SPP::Meas::MeasKeyTypes& meas, FormatContext& ctx)
419 {
420 if (const auto* psr = std::get_if<NAV::SPP::Meas::Psr>(&meas))
421 {
422 return fmt::formatter<std::string>::format(fmt::format("psr({})", psr->satSigId), ctx);
423 }
424 if (const auto* doppler = std::get_if<NAV::SPP::Meas::Doppler>(&meas))
425 {
426 return fmt::formatter<std::string>::format(fmt::format("doppler({})", doppler->satSigId), ctx);
427 }
428
429 return fmt::formatter<std::string>::format("ERROR", ctx);
430 }
431};
432
433#endif
static const std::vector< StateKeyTypes > VelRecvClkDrift
Vector with all velocity keys and receiver clock drift key (for LSE from pseudorange-rates)
Definition Keys.hpp:98
static const std::vector< StateKeyTypes > RecvClk
All receiver clock keys.
Definition Keys.hpp:81
static const std::vector< StateKeyTypes > Vel
All velocity keys.
Definition Keys.hpp:79
static const std::vector< StateKeyTypes > PosVelRecvClkErr
Vector with all position, velocity and receiver clock bias keys.
Definition Keys.hpp:86
constexpr size_t POS_VEL_STATE_COUNT
Amount of states.
Definition Keys.hpp:44
static const std::vector< StateKeyTypes > PosRecvClkErr
Vector with all position keys and receiver clock error key (for LSE from pseudoranges)
Definition Keys.hpp:95
static const std::vector< StateKeyTypes > PosVelRecvClk
Vector with all position, velocity and receiver clock state keys.
Definition Keys.hpp:90
std::ostream & operator<<(std::ostream &os, const NAV::SPP::States::SppStates &obj)
Stream insertion operator overload.
SppStates
State Keys of the SPP.
Definition Keys.hpp:29
@ PosZ
Position ECEF_Z [m].
Definition Keys.hpp:32
@ VelZ
Velocity ECEF_Z [m/s].
Definition Keys.hpp:35
@ PosX
Position ECEF_X [m].
Definition Keys.hpp:30
@ RecvClkErr
Receiver clock error [m].
Definition Keys.hpp:36
@ SppStates_COUNT
Count.
Definition Keys.hpp:38
@ PosY
Position ECEF_Y [m].
Definition Keys.hpp:31
@ VelY
Velocity ECEF_Y [m/s].
Definition Keys.hpp:34
@ VelX
Velocity ECEF_X [m/s].
Definition Keys.hpp:33
@ RecvClkDrift
Receiver clock drift [m/s].
Definition Keys.hpp:37
constexpr size_t VEL_STATE_COUNT
Amount of states to estimate for the velocity.
Definition Keys.hpp:42
constexpr size_t POS_STATE_COUNT
Amount of states to estimate for the position.
Definition Keys.hpp:41
std::variant< SppStates, InterSysBias, InterSysDrift, InterFreqBias > StateKeyTypes
Alias for the state key type.
Definition Keys.hpp:75
std::variant< Psr, Doppler > MeasKeyTypes
Alias for the measurement key type.
Definition Keys.hpp:126
Structs identifying a unique satellite.
Frequency definition for different satellite systems.
Definition Frequency.hpp:59
Position, Velocity and Attitude Storage Class.
Definition PosVel.hpp:23
Position, Velocity and Attitude Storage Class.
Definition Pos.hpp:29
Range-rate (doppler) measurement [m/s].
Definition Keys.hpp:117
SatSigId satSigId
Satellite Signal Id.
Definition Keys.hpp:122
bool operator==(const Doppler &rhs) const
Equal comparison operator.
Definition Keys.hpp:120
Pseudorange measurement [m].
Definition Keys.hpp:108
bool operator==(const Psr &rhs) const
Equal comparison operator.
Definition Keys.hpp:111
SatSigId satSigId
Satellite Signal Id.
Definition Keys.hpp:113
Inter-frequency bias.
Definition Keys.hpp:66
bool operator==(const InterFreqBias &rhs) const
Equal comparison operator.
Definition Keys.hpp:69
Frequency freq
Frequency.
Definition Keys.hpp:71
Inter-system clock errors (one for additional satellite system)
Definition Keys.hpp:48
SatelliteSystem satSys
Satellite system.
Definition Keys.hpp:53
bool operator==(const InterSysBias &rhs) const
Equal comparison operator.
Definition Keys.hpp:51
Inter-system clock drifts (one for additional satellite system)
Definition Keys.hpp:57
SatelliteSystem satSys
Satellite system.
Definition Keys.hpp:62
bool operator==(const InterSysDrift &rhs) const
Equal comparison operator.
Definition Keys.hpp:60
Identifies a satellite signal (satellite frequency and number)
Definition SatelliteIdentifier.hpp:62
Satellite System type.
Definition SatelliteSystem.hpp:43
size_t operator()(const NAV::SPP::Meas::Doppler &doppler) const
Hash function.
Definition Keys.hpp:232
size_t operator()(const NAV::SPP::Meas::Psr &psr) const
Hash function.
Definition Keys.hpp:221
size_t operator()(const NAV::SPP::States::InterFreqBias &interFreqBias) const
Hash function.
Definition Keys.hpp:210
size_t operator()(const NAV::SPP::States::InterSysBias &interSysBias) const
Hash function.
Definition Keys.hpp:188
size_t operator()(const NAV::SPP::States::InterSysDrift &interSysDrift) const
Hash function.
Definition Keys.hpp:199