0.2.0
Loading...
Searching...
No Matches
GnssObs.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 <limits>
17#include <optional>
18#include <vector>
19#include <algorithm>
20#include <Eigen/Core>
21
22#include "NodeData/NodeData.hpp"
23
26#include "util/Assert.h"
27
28namespace NAV
29{
31class GnssObs : public NodeData
32{
33 public:
42
45 {
48 {
50 double value = 0.0;
51
66 uint8_t SSI = 0;
67 };
68
71 {
73 double value = 0.0;
74
89 uint8_t SSI = 0;
90
92 uint8_t LLI = 0;
93 };
94
98
99#ifdef TESTING
107 std::optional<Pseudorange> pseudorange,
108 std::optional<CarrierPhase> carrierPhase,
109 std::optional<double> doppler,
110 std::optional<double> CN0)
115 CN0(CN0)
116 {}
117#endif
118
120 std::optional<Pseudorange> pseudorange;
121 std::optional<CarrierPhase> carrierPhase;
122 std::optional<double> doppler;
123 std::optional<double> CN0;
124 };
125
132
133#ifdef TESTING
135 GnssObs() = default;
136
141 GnssObs(const InsTime& insTime, std::vector<ObservationData> data, std::vector<SatelliteData> satData)
142 : data(std::move(data)), _satData(std::move(satData))
143 {
144 this->insTime = insTime;
145 }
146#endif
149 [[nodiscard]] static std::string type()
150 {
151 return "GnssObs";
152 }
153
156 [[nodiscard]] static std::vector<std::string> parentTypes()
157 {
158 return { NodeData::type() };
159 }
160
162 std::vector<ObservationData> data;
163
168 {
169 auto iter = std::find_if(_satData.begin(), _satData.end(), [&satId](const SatelliteData& sat) {
170 return sat.satId == satId;
171 });
172 if (iter != _satData.end())
173 {
174 return *iter;
175 }
176
177 _satData.emplace_back();
178 _satData.back().satId = satId;
179 return _satData.back();
180 }
181
185 [[nodiscard]] std::optional<std::reference_wrapper<const SatelliteData>> satData(const SatId& satId) const
186 {
187 auto iter = std::find_if(_satData.begin(), _satData.end(), [&satId](const SatelliteData& sat) {
188 return sat.satId == satId;
189 });
190 if (iter != _satData.end())
191 {
192 return *iter;
193 }
194 return std::nullopt;
195 }
196
200 [[nodiscard]] bool contains(const SatSigId& satSigId) const
201 {
202 auto iter = std::find_if(data.begin(), data.end(), [&satSigId](const ObservationData& idData) {
203 return idData.satSigId == satSigId;
204 });
205 return iter != data.end();
206 }
207
212 {
213 auto iter = std::find_if(data.begin(), data.end(), [&satSigId](const ObservationData& idData) {
214 return idData.satSigId == satSigId;
215 });
216 if (iter != data.end())
217 {
218 return *iter;
219 }
220
221 data.emplace_back(satSigId);
222 return data.back();
223 }
224
228 [[nodiscard]] std::optional<std::reference_wrapper<const ObservationData>> operator()(const SatSigId& satSigId) const
229 {
230 auto iter = std::find_if(data.begin(), data.end(), [&satSigId](const ObservationData& idData) {
231 return idData.satSigId == satSigId;
232 });
233
234 if (iter != data.end())
235 {
236 return *iter;
237 }
238 return std::nullopt;
239 }
240
242 [[nodiscard]] const std::vector<SatelliteData>& getSatData() const { return _satData; }
243
245 [[nodiscard]] std::vector<std::string> dynamicDataDescriptors() const override
246 {
247 std::vector<std::string> descriptors;
248 descriptors.reserve(data.size() * 7);
249
250 for (const auto& obsData : data)
251 {
252 descriptors.push_back(fmt::format("{} Pseudorange [m]", obsData.satSigId));
253 descriptors.push_back(fmt::format("{} Pseudorange SSI", obsData.satSigId));
254
255 descriptors.push_back(fmt::format("{} Carrier-phase [cycles]", obsData.satSigId));
256 descriptors.push_back(fmt::format("{} Carrier-phase SSI", obsData.satSigId));
257 descriptors.push_back(fmt::format("{} Carrier-phase LLI", obsData.satSigId));
258
259 descriptors.push_back(fmt::format("{} Doppler [Hz]", obsData.satSigId));
260 descriptors.push_back(fmt::format("{} Carrier-to-Noise density [dBHz]", obsData.satSigId));
261 }
262
263 return descriptors;
264 }
265
268 [[nodiscard]] std::optional<double> getDynamicDataAt(const std::string& descriptor) const override
269 {
270 for (const auto& obsData : data)
271 {
272 if (descriptor == fmt::format("{} Pseudorange [m]", obsData.satSigId) && obsData.pseudorange)
273 {
274 return obsData.pseudorange->value;
275 }
276 if (descriptor == fmt::format("{} Pseudorange SSI", obsData.satSigId) && obsData.pseudorange)
277 {
278 return obsData.pseudorange->SSI;
279 }
280 if (descriptor == fmt::format("{} Carrier-phase [cycles]", obsData.satSigId) && obsData.carrierPhase)
281 {
282 return obsData.carrierPhase->value;
283 }
284 if (descriptor == fmt::format("{} Carrier-phase SSI", obsData.satSigId) && obsData.carrierPhase)
285 {
286 return obsData.carrierPhase->SSI;
287 }
288 if (descriptor == fmt::format("{} Carrier-phase LLI", obsData.satSigId) && obsData.carrierPhase)
289 {
290 return obsData.carrierPhase->LLI;
291 }
292 if (descriptor == fmt::format("{} Doppler [Hz]", obsData.satSigId) && obsData.doppler)
293 {
294 return obsData.doppler.value();
295 }
296 if (descriptor == fmt::format("{} Carrier-to-Noise density [dBHz]", obsData.satSigId) && obsData.CN0)
297 {
298 return obsData.CN0.value();
299 }
300 }
301 return std::nullopt;
302 }
303
305 [[nodiscard]] std::vector<std::pair<std::string, double>> getDynamicData() const override
306 {
307 std::vector<std::pair<std::string, double>> dynData;
308 dynData.reserve(data.size() * 7);
309 for (const auto& obsData : data)
310 {
311 if (obsData.pseudorange) { dynData.emplace_back(fmt::format("{} Pseudorange [m]", obsData.satSigId), obsData.pseudorange->value); }
312 if (obsData.pseudorange) { dynData.emplace_back(fmt::format("{} Pseudorange SSI", obsData.satSigId), obsData.pseudorange->SSI); }
313
314 if (obsData.carrierPhase) { dynData.emplace_back(fmt::format("{} Carrier-phase [cycles]", obsData.satSigId), obsData.carrierPhase->value); }
315 if (obsData.carrierPhase) { dynData.emplace_back(fmt::format("{} Carrier-phase SSI", obsData.satSigId), obsData.carrierPhase->SSI); }
316 if (obsData.carrierPhase) { dynData.emplace_back(fmt::format("{} Carrier-phase LLI", obsData.satSigId), obsData.carrierPhase->LLI); }
317
318 if (obsData.doppler) { dynData.emplace_back(fmt::format("{} Doppler [Hz]", obsData.satSigId), obsData.doppler.value()); }
319
320 if (obsData.CN0) { dynData.emplace_back(fmt::format("{} Carrier-to-Noise density [dBHz]", obsData.satSigId), obsData.CN0.value()); }
321 }
322 return dynData;
323 }
324
327 {
329 std::optional<Eigen::Vector3d> e_approxPos;
330
332 std::string antennaType;
333
338 Eigen::Vector3d antennaDeltaNEU = Eigen::Vector3d::Zero();
339 };
340
342 std::optional<std::reference_wrapper<ReceiverInfo>> receiverInfo;
343
344 private:
346 std::vector<SatelliteData> _satData;
347};
348
352constexpr const char* to_string(GnssObs::ObservationType obsType)
353{
354 switch (obsType)
355 {
357 return "Pseudorange";
358 case GnssObs::Carrier:
359 return "Carrier";
360 case GnssObs::Doppler:
361 return "Doppler";
363 return "COUNT";
364 }
365 return "";
366}
367
368} // namespace NAV
369
370#ifndef DOXYGEN_IGNORE
371
372template<>
373struct fmt::formatter<NAV::GnssObs::ObservationType> : fmt::formatter<const char*>
374{
379 template<typename FormatContext>
380 auto format(const NAV::GnssObs::ObservationType& obsType, FormatContext& ctx)
381 {
382 return fmt::formatter<const char*>::format(to_string(obsType), ctx);
383 }
384};
385
386#endif
387
392std::ostream& operator<<(std::ostream& os, const NAV::GnssObs::ObservationType& obj);
Assertion helpers.
Code definitions.
@ Freq_None
None.
Definition Frequency.hpp:27
std::ostream & operator<<(std::ostream &os, const NAV::GnssObs::ObservationType &obj)
Stream insertion operator overload.
Abstract NodeData Class.
const char * to_string(gui::widgets::PositionWithFrame::ReferenceFrame refFrame)
Converts the enum to a string.
Structs identifying a unique satellite.
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:26
@ None
None.
Definition Code.hpp:93
Frequency definition for different satellite systems.
Definition Frequency.hpp:59
GNSS Observation message information.
Definition GnssObs.hpp:32
ObservationType
Observation types.
Definition GnssObs.hpp:36
@ Doppler
Doppler (Pseudorange rate)
Definition GnssObs.hpp:39
@ ObservationType_COUNT
Count.
Definition GnssObs.hpp:40
@ Carrier
Carrier-Phase.
Definition GnssObs.hpp:38
@ Pseudorange
Pseudorange.
Definition GnssObs.hpp:37
std::vector< std::string > dynamicDataDescriptors() const override
Returns a vector of data descriptors for the dynamic data.
Definition GnssObs.hpp:245
std::vector< std::pair< std::string, double > > getDynamicData() const override
Returns a vector of data descriptors and values for the dynamic data.
Definition GnssObs.hpp:305
std::optional< double > getDynamicDataAt(const std::string &descriptor) const override
Get the value for the descriptor.
Definition GnssObs.hpp:268
static std::string type()
Returns the type of the data class.
Definition GnssObs.hpp:149
static std::vector< std::string > parentTypes()
Returns the parent types of the data class.
Definition GnssObs.hpp:156
std::optional< std::reference_wrapper< const SatelliteData > > satData(const SatId &satId) const
Access the satellite data.
Definition GnssObs.hpp:185
bool contains(const SatSigId &satSigId) const
Checks if an element with the identifier exists.
Definition GnssObs.hpp:200
std::optional< std::reference_wrapper< ReceiverInfo > > receiverInfo
Optional Receiver Information, e.g. from RINEX header.
Definition GnssObs.hpp:342
SatelliteData & satData(const SatId &satId)
Access or insert the satellite data.
Definition GnssObs.hpp:167
ObservationData & operator()(const SatSigId &satSigId)
Return the element with the identifier or a newly constructed one if it did not exist.
Definition GnssObs.hpp:211
const std::vector< SatelliteData > & getSatData() const
Useful information of the satellites.
Definition GnssObs.hpp:242
std::vector< ObservationData > data
Satellite observations.
Definition GnssObs.hpp:162
std::optional< std::reference_wrapper< const ObservationData > > operator()(const SatSigId &satSigId) const
Return the element with the identifier.
Definition GnssObs.hpp:228
The class is responsible for all time-related tasks.
Definition InsTime.hpp:667
Parent class for all data transmitted over Flow pins.
Definition NodeData.hpp:27
static std::string type()
Returns the type of the data class.
Definition NodeData.hpp:44
InsTime insTime
Time at which the message was received.
Definition NodeData.hpp:89
Carrier phase.
Definition GnssObs.hpp:71
uint8_t LLI
Loss of Lock Indicator [0...6] (only associated with the phase observation)
Definition GnssObs.hpp:92
double value
Carrier phase measurement [cycles].
Definition GnssObs.hpp:73
uint8_t SSI
Signal Strength Indicator (SSI) projected into interval 1-9.
Definition GnssObs.hpp:89
Pseudorange.
Definition GnssObs.hpp:48
uint8_t SSI
Signal Strength Indicator (SSI) projected into interval 1-9.
Definition GnssObs.hpp:66
double value
Pseudorange measurement [m].
Definition GnssObs.hpp:50
Stores the satellites observations.
Definition GnssObs.hpp:45
std::optional< Pseudorange > pseudorange
Pseudorange measurement [m].
Definition GnssObs.hpp:120
std::optional< CarrierPhase > carrierPhase
Carrier phase measurement [cycles].
Definition GnssObs.hpp:121
ObservationData(const SatSigId &satSigId)
Constructor.
Definition GnssObs.hpp:97
std::optional< double > CN0
Carrier-to-Noise density [dBHz].
Definition GnssObs.hpp:123
SatSigId satSigId
SignalId and satellite number.
Definition GnssObs.hpp:119
std::optional< double > doppler
Doppler measurement [Hz].
Definition GnssObs.hpp:122
Receiver Information, e.g. from RINEX header.
Definition GnssObs.hpp:327
Eigen::Vector3d antennaDeltaNEU
Antenna Delta (North, East, Up) in [m].
Definition GnssObs.hpp:338
std::optional< Eigen::Vector3d > e_approxPos
< Approximate receiver position in [m], e.g. from RINEX header
Definition GnssObs.hpp:329
std::string antennaType
Antenna Type. Empty if unknown.
Definition GnssObs.hpp:332
Useful information of the satellites.
Definition GnssObs.hpp:128
Frequency frequencies
Frequencies transmitted by this satellite.
Definition GnssObs.hpp:130
SatId satId
Satellite identifier.
Definition GnssObs.hpp:129
Identifies a satellite (satellite system and number)
Definition SatelliteIdentifier.hpp:32
Identifies a satellite signal (satellite frequency and number)
Definition SatelliteIdentifier.hpp:62