0.3.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
24
25namespace NAV::SPP
26{
27
28namespace States
29{
30
31constexpr size_t POS_STATE_COUNT = 4;
32constexpr size_t VEL_STATE_COUNT = 4;
33
34constexpr size_t POS_VEL_STATE_COUNT = 6;
35
37using StateKeyType = std::variant<Keys::MotionModelKey, Keys::RecvClkBias, Keys::RecvClkDrift, Keys::InterFreqBias>;
38
39} // namespace States
40
41namespace Meas
42{
43
45struct Psr
46{
49 bool operator==(const Psr& rhs) const { return satSigId == rhs.satSigId; }
52};
53
54struct Doppler
55{
58 bool operator==(const Doppler& rhs) const { return satSigId == rhs.satSigId; }
61};
62
64using MeasKeyTypes = std::variant<Psr, Doppler>;
65
66} // namespace Meas
67
68} // namespace NAV::SPP
69
74std::ostream& operator<<(std::ostream& os, const NAV::SPP::Meas::Psr& obj);
75
80std::ostream& operator<<(std::ostream& os, const NAV::SPP::Meas::Doppler& obj);
81
86std::ostream& operator<<(std::ostream& os, const NAV::SPP::States::StateKeyType& obj);
87
92std::ostream& operator<<(std::ostream& os, const NAV::SPP::Meas::MeasKeyTypes& obj);
93
94namespace std
95{
97template<>
98struct hash<NAV::SPP::Meas::Psr>
99{
102 size_t operator()(const NAV::SPP::Meas::Psr& psr) const
103 {
104 return std::hash<NAV::SatSigId>()(psr.satSigId);
105 }
106};
107
108template<>
109struct hash<NAV::SPP::Meas::Doppler>
110{
113 size_t operator()(const NAV::SPP::Meas::Doppler& doppler) const
114 {
115 return std::hash<NAV::SatSigId>()(doppler.satSigId) << 12;
116 }
117};
118} // namespace std
119
120#ifndef DOXYGEN_IGNORE
121
123template<>
124struct fmt::formatter<NAV::SPP::Meas::Psr> : fmt::formatter<std::string>
125{
130 template<typename FormatContext>
131 auto format(const NAV::SPP::Meas::Psr& psr, FormatContext& ctx) const
132 {
133 return fmt::formatter<std::string>::format(fmt::format("psr({})", psr.satSigId), ctx);
134 }
135};
136
138template<>
139struct fmt::formatter<NAV::SPP::Meas::Doppler> : fmt::formatter<std::string>
140{
145 template<typename FormatContext>
146 auto format(const NAV::SPP::Meas::Doppler& doppler, FormatContext& ctx) const
147 {
148 return fmt::formatter<std::string>::format(fmt::format("dop({})", doppler.satSigId), ctx);
149 }
150};
151
153template<>
154struct fmt::formatter<NAV::SPP::States::StateKeyType> : fmt::formatter<std::string>
155{
160 template<typename FormatContext>
161 auto format(const NAV::SPP::States::StateKeyType& state, FormatContext& ctx) const
162 {
163 using namespace NAV::Keys; // NOLINT(google-build-using-namespace)
164
165 if (const auto* s = std::get_if<MotionModelKey>(&state))
166 {
167 return fmt::formatter<std::string>::format(fmt::format("{}", *s), ctx);
168 }
169 if (const auto* recvClkErr = std::get_if<RecvClkBias>(&state))
170 {
171 return fmt::formatter<std::string>::format(fmt::format("{}", *recvClkErr), ctx);
172 }
173 if (const auto* recvClkDrift = std::get_if<RecvClkDrift>(&state))
174 {
175 return fmt::formatter<std::string>::format(fmt::format("{}", *recvClkDrift), ctx);
176 }
177 if (const auto* interFreqBias = std::get_if<NAV::Keys::InterFreqBias>(&state))
178 {
179 return fmt::formatter<std::string>::format(fmt::format("{}", *interFreqBias), ctx);
180 }
181
182 return fmt::formatter<std::string>::format("ERROR", ctx);
183 }
184};
185
187template<>
188struct fmt::formatter<NAV::SPP::Meas::MeasKeyTypes> : fmt::formatter<std::string>
189{
194 template<typename FormatContext>
195 auto format(const NAV::SPP::Meas::MeasKeyTypes& meas, FormatContext& ctx) const
196 {
197 if (const auto* psr = std::get_if<NAV::SPP::Meas::Psr>(&meas))
198 {
199 return fmt::formatter<std::string>::format(fmt::format("{}", *psr), ctx);
200 }
201 if (const auto* doppler = std::get_if<NAV::SPP::Meas::Doppler>(&meas))
202 {
203 return fmt::formatter<std::string>::format(fmt::format("{}", *doppler), ctx);
204 }
205
206 return fmt::formatter<std::string>::format("ERROR", ctx);
207 }
208};
209
210#endif
std::variant< Keys::MotionModelKey, Keys::RecvClkBias, Keys::RecvClkDrift, Keys::InterFreqBias > StateKeyType
Alias for the state key type.
Definition Keys.hpp:37
std::ostream & operator<<(std::ostream &os, const NAV::SPP::Meas::Psr &obj)
Stream insertion operator overload.
constexpr size_t POS_VEL_STATE_COUNT
Amount of states.
Definition Keys.hpp:34
constexpr size_t VEL_STATE_COUNT
Amount of states to estimate for the velocity.
Definition Keys.hpp:32
constexpr size_t POS_STATE_COUNT
Amount of states to estimate for the position.
Definition Keys.hpp:31
std::variant< Psr, Doppler > MeasKeyTypes
Alias for the measurement key type.
Definition Keys.hpp:64
Inter Frequency Bias System Model.
Motion System Model.
Receiver Clock System Model.
Structs identifying a unique satellite.
Range-rate (doppler) measurement [m/s].
Definition Keys.hpp:55
SatSigId satSigId
Satellite Signal Id.
Definition Keys.hpp:60
bool operator==(const Doppler &rhs) const
Equal comparison operator.
Definition Keys.hpp:58
Pseudorange measurement [m].
Definition Keys.hpp:46
bool operator==(const Psr &rhs) const
Equal comparison operator.
Definition Keys.hpp:49
SatSigId satSigId
Satellite Signal Id.
Definition Keys.hpp:51
Identifies a satellite signal (satellite frequency and number)
Definition SatelliteIdentifier.hpp:67
size_t operator()(const NAV::SPP::Meas::Doppler &doppler) const
Hash function.
Definition Keys.hpp:113
size_t operator()(const NAV::SPP::Meas::Psr &psr) const
Hash function.
Definition Keys.hpp:102