0.2.0
Loading...
Searching...
No Matches
GnssNavInfo.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 <unordered_map>
17#include <utility>
18
24#include "util/Logger.hpp"
25
26namespace NAV
27{
30{
31 public:
34 [[nodiscard]] static std::string type()
35 {
36 return "GnssNavInfo";
37 }
38
42 [[nodiscard]] Orbit::Pos calcSatellitePos(const SatId& satId, const InsTime& transTime) const
43 {
44 return m_satellites.at(satId).calcSatellitePos(transTime);
45 }
49 [[nodiscard]] Orbit::PosVel calcSatellitePosVel(const SatId& satId, const InsTime& transTime) const
50 {
51 return m_satellites.at(satId).calcSatellitePosVel(transTime);
52 }
56 [[nodiscard]] Orbit::PosVelAccel calcSatellitePosVelAccel(const SatId& satId, const InsTime& transTime) const
57 {
58 return m_satellites.at(satId).calcSatellitePosVelAccel(transTime);
59 }
60
66 [[nodiscard]] Clock::Corrections calcSatelliteClockCorrections(const SatId& satId, const InsTime& recvTime, double dist, const Frequency& freq) const
67 {
68 return m_satellites.at(satId).calcClockCorrections(recvTime, dist, freq);
69 }
70
74 [[nodiscard]] double calcSatellitePositionVariance(const SatId& satId, const InsTime& recvTime) const
75 {
76 return m_satellites.at(satId).calcSatellitePositionVariance(recvTime);
77 }
78
82 [[nodiscard]] bool isHealthy(const SatId& satId, const InsTime& recvTime) const
83 {
84 return m_satellites.at(satId).isHealthy(recvTime);
85 }
86
90 void addSatelliteNavData(const SatId& satId, const std::shared_ptr<SatNavData>& satNavData)
91 {
92 m_satellites[satId].addSatNavData(satNavData);
93 }
94
98 [[nodiscard]] std::shared_ptr<NAV::SatNavData> searchNavigationData(const SatId& satId, const InsTime& recvTime) const
99 {
100 if (!m_satellites.contains(satId)) { return nullptr; }
101
102 auto satNavData = m_satellites.at(satId).searchNavigationData(recvTime);
103 if (satNavData == nullptr)
104 {
105 [[maybe_unused]] auto printNavData = [&]() {
106 std::string ret;
107 for (const auto& navData : m_satellites.at(satId).getNavigationData())
108 {
109 ret += fmt::format("[{} - diff {:.0f}s], ", navData->refTime.toYMDHMS(GPST), std::abs((navData->refTime - recvTime).count()));
110 }
111 return ret.substr(0, ret.length() - 2);
112 };
113
114 LOG_TRACE("[{}][{}]: No navigation data found. Available data are at time: {}", satId, recvTime.toYMDHMS(GPST), printNavData());
115 }
116
117 return satNavData;
118 }
119
121 [[nodiscard]] size_t nSatellites() const
122 {
123 return m_satellites.size();
124 }
125
128 const auto& satellites() const
129 {
130 return m_satellites;
131 }
132
134 void reset()
135 {
138 timeSysCorr.clear();
139 m_satellites.clear();
140 }
141
144
147
150 {
151 double a0 = std::nan("");
152 double a1 = std::nan("");
153 // TODO: Add a2 value
154 };
155
157 std::unordered_map<std::pair<TimeSystem, TimeSystem>, TimeSystemCorrections> timeSysCorr;
158
159 private:
161 std::unordered_map<SatId, Satellite> m_satellites;
162};
163
164} // namespace NAV
Ionospheric Correction data.
Utility class for logging to console and file.
#define LOG_TRACE
Detailled info to trace the execution of the program. Should not be called on functions which receive...
Definition Logger.hpp:65
Utility functions for std::pair.
Structs identifying a unique satellite.
GNSS Satellite System.
@ SatSys_None
No Satellite system.
Definition SatelliteSystem.hpp:31
Calculations and data related to satellite orbit, clock, ...
@ GPST
GPS Time.
Definition TimeSystem.hpp:29
Frequency definition for different satellite systems.
Definition Frequency.hpp:59
GNSS Navigation message information.
Definition GnssNavInfo.hpp:30
Orbit::Pos calcSatellitePos(const SatId &satId, const InsTime &transTime) const
Calculates position, velocity and acceleration of the satellite at transmission time.
Definition GnssNavInfo.hpp:42
size_t nSatellites() const
Returns the amount of satellites contained in this message.
Definition GnssNavInfo.hpp:121
void addSatelliteNavData(const SatId &satId, const std::shared_ptr< SatNavData > &satNavData)
Adds the provided satellite navigation data to the satellite.
Definition GnssNavInfo.hpp:90
double calcSatellitePositionVariance(const SatId &satId, const InsTime &recvTime) const
Calculates the Variance of the satellite position in [m].
Definition GnssNavInfo.hpp:74
static std::string type()
Returns the type of the data class.
Definition GnssNavInfo.hpp:34
std::unordered_map< std::pair< TimeSystem, TimeSystem >, TimeSystemCorrections > timeSysCorr
Time system correction parameters. Difference between GNSS system time and UTC or other time systems.
Definition GnssNavInfo.hpp:157
const auto & satellites() const
Get the satellites.
Definition GnssNavInfo.hpp:128
Clock::Corrections calcSatelliteClockCorrections(const SatId &satId, const InsTime &recvTime, double dist, const Frequency &freq) const
Calculates clock bias and drift of the satellite.
Definition GnssNavInfo.hpp:66
std::shared_ptr< NAV::SatNavData > searchNavigationData(const SatId &satId, const InsTime &recvTime) const
Checks whether the satellite is included in the internal data.
Definition GnssNavInfo.hpp:98
bool isHealthy(const SatId &satId, const InsTime &recvTime) const
Checks whether the signal is healthy.
Definition GnssNavInfo.hpp:82
void reset()
Resets the data by clearing the member variables.
Definition GnssNavInfo.hpp:134
Orbit::PosVel calcSatellitePosVel(const SatId &satId, const InsTime &transTime) const
Calculates position, velocity and acceleration of the satellite at transmission time.
Definition GnssNavInfo.hpp:49
Orbit::PosVelAccel calcSatellitePosVelAccel(const SatId &satId, const InsTime &transTime) const
Calculates position, velocity and acceleration of the satellite at transmission time.
Definition GnssNavInfo.hpp:56
IonosphericCorrections ionosphericCorrections
Ionospheric correction values.
Definition GnssNavInfo.hpp:146
SatelliteSystem satelliteSystems
Satellite Systems available.
Definition GnssNavInfo.hpp:143
The class is responsible for all time-related tasks.
Definition InsTime.hpp:667
constexpr InsTime_YMDHMS toYMDHMS(TimeSystem timesys=UTC, int digits=-1) const
Converts this time object into a different format.
Definition InsTime.hpp:828
Ionospheric Corrections.
Definition IonosphericCorrections.hpp:30
void clear()
Empties the data.
Definition IonosphericCorrections.hpp:111
Satellite clock corrections.
Definition Clock.hpp:28
Time system correction parameters.
Definition GnssNavInfo.hpp:150
double a0
a0 / tau_c Coefficient of linear polynomial [s] Δt = a0 + a1 * (t - t_ref)
Definition GnssNavInfo.hpp:151
double a1
a1 Coefficient of linear polynomial [s/s]
Definition GnssNavInfo.hpp:152
Satellite Position, Velocity and Acceleration.
Definition Orbit.hpp:39
Satellite Position and Velocity.
Definition Orbit.hpp:33
Satellite Position.
Definition Orbit.hpp:28
Identifies a satellite (satellite system and number)
Definition SatelliteIdentifier.hpp:32
Satellite System type.
Definition SatelliteSystem.hpp:43