0.4.1
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
9/// @file GnssNavInfo.hpp
10/// @brief Navigation message information
11/// @author T. Topp (topp@ins.uni-stuttgart.de)
12/// @date 2022-04-21
13
14#pragma once
15
16#include <unordered_map>
17#include <utility>
18
24#include "util/Logger.hpp"
25
26namespace NAV
27{
28/// GNSS Navigation message information
30{
31 public:
32 /// @brief Returns the type of the data class
33 /// @return The data type
34 [[nodiscard]] static std::string type()
35 {
36 return "GnssNavInfo";
37 }
38
39 /// @brief Calculates position, velocity and acceleration of the satellite at transmission time
40 /// @param[in] satId Satellite identifier
41 /// @param[in] transTime Transmit time of the signal
42 [[nodiscard]] Orbit::Pos calcSatellitePos(const SatId& satId, const InsTime& transTime) const
43 {
44 return m_satellites.at(satId).calcSatellitePos(transTime);
45 }
46 /// @brief Calculates position, velocity and acceleration of the satellite at transmission time
47 /// @param[in] satId Satellite identifier
48 /// @param[in] transTime Transmit time of the signal
49 [[nodiscard]] Orbit::PosVel calcSatellitePosVel(const SatId& satId, const InsTime& transTime) const
50 {
51 return m_satellites.at(satId).calcSatellitePosVel(transTime);
52 }
53 /// @brief Calculates position, velocity and acceleration of the satellite at transmission time
54 /// @param[in] satId Satellite identifier
55 /// @param[in] transTime Transmit time of the signal
56 [[nodiscard]] Orbit::PosVelAccel calcSatellitePosVelAccel(const SatId& satId, const InsTime& transTime) const
57 {
58 return m_satellites.at(satId).calcSatellitePosVelAccel(transTime);
59 }
60
61 /// @brief Calculates clock bias and drift of the satellite
62 /// @param[in] satId Satellite identifier
63 /// @param[in] recvTime Receiver time of the signal
64 /// @param[in] dist Distance between receiver and satellite (normally the pseudorange) [m]
65 /// @param[in] freq Signal Frequency
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
71 /// @brief Calculates the Variance of the satellite position in [m]
72 /// @param[in] satId Satellite identifier
73 /// @param[in] recvTime Receiver time to calculate the satellite position for
74 [[nodiscard]] double calcSatellitePositionVariance(const SatId& satId, const InsTime& recvTime) const
75 {
76 return m_satellites.at(satId).calcSatellitePositionVariance(recvTime);
77 }
78
79 /// @brief Checks whether the signal is healthy
80 /// @param[in] satId Satellite identifier
81 /// @param[in] recvTime Receive time for the data lookup
82 [[nodiscard]] bool isHealthy(const SatId& satId, const InsTime& recvTime) const
83 {
84 return m_satellites.at(satId).isHealthy(recvTime);
85 }
86
87 /// @brief Adds the provided satellite navigation data to the satellite
88 /// @param[in] satId Satellite identifier
89 /// @param[in] satNavData Satellite Navigation Data to add
90 void addSatelliteNavData(const SatId& satId, const std::shared_ptr<SatNavData>& satNavData)
91 {
92 m_satellites[satId].addSatNavData(satNavData);
93 }
94
95 /// @brief Checks whether the satellite is included in the internal data
96 /// @param[in] satId Satellite identifier
97 /// @param[in] recvTime Receive time for the data lookup
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),
110 static_cast<double>(std::abs((navData->refTime - recvTime).count())));
111 }
112 return ret.substr(0, ret.length() - 2);
113 };
114
115 LOG_TRACE("[{}][{}]: No navigation data found. Available data are at time: {}", satId, recvTime.toYMDHMS(GPST), printNavData());
116 }
117
118 return satNavData;
119 }
120
121 /// @brief Returns the amount of satellites contained in this message
122 [[nodiscard]] size_t nSatellites() const
123 {
124 return m_satellites.size();
125 }
126
127 /// @brief Get the satellites
128 /// @return Reference to the internal satellites map
129 const auto& satellites() const
130 {
131 return m_satellites;
132 }
133
134 /// @brief Resets the data by clearing the member variables
135 void reset()
136 {
139 timeSysCorr.clear();
140 m_satellites.clear();
141 }
142
143 /// @brief Satellite Systems available
145
146 /// @brief Ionospheric correction values
148
149 /// @brief Time system correction parameters
151 {
152 double a0 = std::nan(""); ///< a0 / tau_c Coefficient of linear polynomial [s] Δt = a0 + a1 * (t - t_ref)
153 double a1 = std::nan(""); ///< a1 Coefficient of linear polynomial [s/s]
154 // TODO: Add a2 value
155 };
156
157 /// Time system correction parameters. Difference between GNSS system time and UTC or other time systems
158 std::unordered_map<std::pair<TimeSystem, TimeSystem>, TimeSystemCorrections> timeSysCorr;
159
160 private:
161 /// Map of satellites containing the navigation message data
162 std::unordered_map<SatId, Satellite> m_satellites;
163};
164
165} // 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.
Calculations and data related to satellite orbit, clock, ...
Frequency definition for different satellite systems.
Definition Frequency.hpp:59
GNSS Navigation message information.
Orbit::Pos calcSatellitePos(const SatId &satId, const InsTime &transTime) const
Calculates position, velocity and acceleration of the satellite at transmission time.
size_t nSatellites() const
Returns the amount of satellites contained in this message.
void addSatelliteNavData(const SatId &satId, const std::shared_ptr< SatNavData > &satNavData)
Adds the provided satellite navigation data to the satellite.
double calcSatellitePositionVariance(const SatId &satId, const InsTime &recvTime) const
Calculates the Variance of the satellite position in [m].
static std::string type()
Returns the type of the data class.
std::unordered_map< std::pair< TimeSystem, TimeSystem >, TimeSystemCorrections > timeSysCorr
Time system correction parameters. Difference between GNSS system time and UTC or other time systems.
const auto & satellites() const
Get the satellites.
Clock::Corrections calcSatelliteClockCorrections(const SatId &satId, const InsTime &recvTime, double dist, const Frequency &freq) const
Calculates clock bias and drift of the satellite.
std::shared_ptr< NAV::SatNavData > searchNavigationData(const SatId &satId, const InsTime &recvTime) const
Checks whether the satellite is included in the internal data.
bool isHealthy(const SatId &satId, const InsTime &recvTime) const
Checks whether the signal is healthy.
void reset()
Resets the data by clearing the member variables.
std::unordered_map< SatId, Satellite > m_satellites
Map of satellites containing the navigation message data.
Orbit::PosVel calcSatellitePosVel(const SatId &satId, const InsTime &transTime) const
Calculates position, velocity and acceleration of the satellite at transmission time.
Orbit::PosVelAccel calcSatellitePosVelAccel(const SatId &satId, const InsTime &transTime) const
Calculates position, velocity and acceleration of the satellite at transmission time.
IonosphericCorrections ionosphericCorrections
Ionospheric correction values.
SatelliteSystem satelliteSystems
Satellite Systems available.
The class is responsible for all time-related tasks.
Definition InsTime.hpp:710
constexpr InsTime_YMDHMS toYMDHMS(TimeSystem timesys=UTC, int digits=-1) const
Converts this time object into a different format.
Definition InsTime.hpp:871
@ GPST
GPS Time.
@ SatSys_None
No Satellite system.
Satellite clock corrections.
Definition Clock.hpp:28
Time system correction parameters.
double a0
a0 / tau_c Coefficient of linear polynomial [s] Δt = a0 + a1 * (t - t_ref)
double a1
a1 Coefficient of linear polynomial [s/s]
Satellite Position, Velocity and Acceleration.
Definition Orbit.hpp:40
Satellite Position and Velocity.
Definition Orbit.hpp:34
Satellite Position.
Definition Orbit.hpp:29
Identifies a satellite (satellite system and number)
Satellite System type.