GNSS-SDR 0.0.21
An Open Source GNSS Software Defined Receiver
Loading...
Searching...
No Matches
gps_navigation_message.h
Go to the documentation of this file.
1/*!
2 * \file gps_navigation_message.h
3 * \brief Interface of a GPS NAV Data message decoder
4 * \author Javier Arribas, 2011. jarribas(at)cttc.es
5 *
6 *
7 * -----------------------------------------------------------------------------
8 *
9 * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
10 * This file is part of GNSS-SDR.
11 *
12 * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
13 * SPDX-License-Identifier: GPL-3.0-or-later
14 *
15 * -----------------------------------------------------------------------------
16 */
17
18
19#ifndef GNSS_SDR_GPS_NAVIGATION_MESSAGE_H
20#define GNSS_SDR_GPS_NAVIGATION_MESSAGE_H
21
22
23#include "GPS_L1_CA.h"
24#include "gps_almanac.h"
25#include "gps_ephemeris.h"
26#include "gps_iono.h"
27#include "gps_utc_model.h"
28#include <bitset>
29#include <cstdint>
30#include <map>
31#include <string>
32#include <utility> // for pair
33#include <vector>
34
35/** \addtogroup Core
36 * \{ */
37/** \addtogroup System_Parameters
38 * \{ */
39
40enum class LnavSystem
41{
42 GPS,
43 QZSS
44};
45
46/*!
47 * \brief This class decodes a GPS NAV Data message as described in IS-GPS-200M
48 *
49 * See https://www.gps.gov/sites/default/files/2025-07/IS-GPS-200M.pdf Appendix II
50 */
52{
53public:
54 /*!
55 * Default constructor
56 */
57 explicit Gps_Navigation_Message(LnavSystem system = LnavSystem::GPS);
58
59 /*!
60 * \brief Obtain a GPS SV Ephemeris class filled with current SV data
61 */
63
64 /*!
65 * \brief Obtain a GPS ionospheric correction parameters class filled with current SV data
66 */
68
69 /*!
70 * \brief Obtain a GPS almanac class filled with current SV data
71 */
73
74 /*!
75 * \brief Obtain a GPS Almanac model parameters class filled with current SV data
76 */
78
79 /*!
80 * \brief Decodes the GPS NAV message
81 */
82 int32_t subframe_decoder(const char* subframe);
83
84 /*!
85 * \brief Computes the Coordinated Universal Time (UTC) and
86 * returns it in [s] (IS-GPS-200M, 20.3.3.5.2.4)
87 */
88 double utc_time(double gpstime_corrected) const;
89
90 /*!
91 * \brief Gets Time of Week, in seconds
92 */
93 inline int32_t get_TOW() const
94 {
95 return d_TOW;
96 }
97
98 /*!
99 * \brief Gets GPS Week Number
100 */
101 inline int32_t get_GPS_week() const
102 {
103 return i_GPS_week;
104 }
105
106 /*!
107 * \brief Sets satellite PRN number
108 */
109 inline void set_satellite_PRN(uint32_t prn)
110 {
111 i_satellite_PRN = prn;
112 }
113
114 /*!
115 * \brief Gets satellite PRN number
116 */
117 inline uint32_t get_satellite_PRN() const
118 {
119 return i_satellite_PRN;
120 }
121
122 /*!
123 * \brief Sets channel ID
124 */
125 inline void set_channel(int32_t channel_id)
126 {
127 i_channel_ID = channel_id;
128 }
129
130 /*!
131 * \brief Gets flag_iono_valid
132 */
133 inline bool get_flag_iono_valid() const
134 {
135 return flag_iono_valid;
136 }
137
138 /*!
139 * \brief Gets flag_utc_model_valid
140 */
141 inline bool get_flag_utc_model_valid() const
142 {
143 return flag_utc_model_valid;
144 }
145
146 bool satellite_validation();
147 bool almanac_validation() const;
148
149private:
150 uint64_t read_navigation_unsigned(const std::bitset<GPS_SUBFRAME_BITS>& bits, const std::vector<std::pair<int32_t, int32_t>>& parameter) const;
151 int64_t read_navigation_signed(const std::bitset<GPS_SUBFRAME_BITS>& bits, const std::vector<std::pair<int32_t, int32_t>>& parameter) const;
152 bool read_navigation_bool(const std::bitset<GPS_SUBFRAME_BITS>& bits, const std::vector<std::pair<int32_t, int32_t>>& parameter) const;
153 void print_gps_word_bytes(uint32_t GPS_word) const;
154
155 std::map<int32_t, int32_t> almanacHealth; //!< Map that stores the health information stored in the almanac
156
157 std::map<int32_t, std::string> satelliteBlock; //!< Map that stores to which block the PRN belongs https://www.navcen.uscg.gov/?Do=constellationStatus
158
159 LnavSystem d_system;
160
161 // broadcast orbit 1
162 int32_t d_TOW{}; // Time of GPS Week of the ephemeris set (taken from subframes TOW) [s]
163 int32_t d_TOW_SF1{}; // Time of GPS Week from HOW word of Subframe 1 [s]
164 int32_t d_TOW_SF2{}; // Time of GPS Week from HOW word of Subframe 2 [s]
165 int32_t d_TOW_SF3{}; // Time of GPS Week from HOW word of Subframe 3 [s]
166 int32_t d_TOW_SF4{}; // Time of GPS Week from HOW word of Subframe 4 [s]
167 int32_t d_TOW_SF5{}; // Time of GPS Week from HOW word of Subframe 5 [s]
168 int32_t d_IODE_SF2{};
169 int32_t d_IODE_SF3{};
170 double d_Crs{}; // Amplitude of the Sine Harmonic Correction Term to the Orbit Radius [m]
171 double d_Delta_n{}; // Mean Motion Difference From Computed Value [semi-circles/s]
172 double d_M_0{}; // Mean Anomaly at Reference Time [semi-circles]
173 // broadcast orbit 2
174 double d_Cuc{}; // Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad]
175 double d_e_eccentricity{}; // Eccentricity [dimensionless]
176 double d_Cus{}; // Amplitude of the Sine Harmonic Correction Term to the Argument of Latitude [rad]
177 double d_sqrt_A{}; // Square Root of the Semi-Major Axis [sqrt(m)]
178 // broadcast orbit 3
179 int32_t d_Toe{}; // Ephemeris data reference time of week (Ref. 20.3.3.4.3 IS-GPS-200M) [s]
180 int32_t d_Toc{}; // clock data reference time (Ref. 20.3.3.3.3.1 IS-GPS-200M) [s]
181 double d_Cic{}; // Amplitude of the Cosine Harmonic Correction Term to the Angle of Inclination [rad]
182 double d_OMEGA0{}; // Longitude of Ascending Node of Orbit Plane at Weekly Epoch [semi-circles]
183 double d_Cis{}; // Amplitude of the Sine Harmonic Correction Term to the Angle of Inclination [rad]
184 // broadcast orbit 4
185 double d_i_0{}; // Inclination Angle at Reference Time [semi-circles]
186 double d_Crc{}; // Amplitude of the Cosine Harmonic Correction Term to the Orbit Radius [m]
187 double d_OMEGA{}; // Argument of Perigee [semi-cicles]
188 double d_OMEGA_DOT{}; // Rate of Right Ascension [semi-circles/s]
189 // broadcast orbit 5
190 double d_IDOT{}; // Rate of Inclination Angle [semi-circles/s]
191 int32_t i_code_on_L2{}; // If 1, P code ON in L2; if 2, C/A code ON in L2;
192 int32_t i_GPS_week{}; // GPS week number, aka WN [week]
193 bool b_L2_P_data_flag{}; // When true, indicates that the NAV data stream was commanded OFF on the P-code of the L2 channel
194 // broadcast orbit 6
195 int32_t i_SV_accuracy{}; // User Range Accuracy (URA) index of the SV (reference paragraph 6.2.1) for the standard positioning service user (Ref 20.3.3.3.1.3 IS-GPS-200M)
196 int32_t i_SV_health{};
197 double d_TGD{}; // Estimated Group Delay Differential: L1-L2 correction term only for the benefit of "L1 P(Y)" or "L2 P(Y)" s users [s]
198 int32_t d_IODC{}; // Issue of Data, Clock
199 // broadcast orbit 7
200 int32_t i_AODO{}; // Age of Data Offset (AODO) term for the navigation message correction table (NMCT) contained in subframe 4 (reference paragraph 20.3.3.5.1.9) [s]
201 bool b_fit_interval_flag{}; // indicates the curve-fit interval used by the CS (Block II/IIA/IIR/IIR-M/IIF) and SS (Block IIIA) in determining the ephemeris parameters, as follows: 0 = 4 hours, 1 = greater than 4 hours.
202 double d_spare1{};
203 double d_spare2{};
204 double d_A_f0{}; // Coefficient 0 of code phase offset model [s]
205 double d_A_f1{}; // Coefficient 1 of code phase offset model [s/s]
206 double d_A_f2{}; // Coefficient 2 of code phase offset model [s/s^2]
207
208 // Almanac
209 int32_t i_Toa{}; // Almanac reference time [s]
210 int32_t i_WN_A{}; // Modulo 256 of the GPS week number to which the almanac reference time (i_Toa) is referenced
211 int32_t SV_Health{}; // Almanac SV health
212 uint32_t a_PRN{}; // Almanac PRN
213 double a_delta_i{}; // Inclination Angle at Reference Time (relative to i_0 = 0.30 semi-circles)
214 double a_M_0{}; // Mean Anomaly at Reference Time [semi-circles]
215 double a_ecc{}; // Eccentricity [dimensionless]
216 double a_sqrtA{}; // Square Root of the Semi-Major Axis [sqrt(m)]
217 double a_OMEGA_0{}; // Longitude of Ascending Node of Orbit Plane at Weekly Epoch [semi-circles]
218 double a_omega{}; // Argument of Perigee [semi-cicles]
219 double a_OMEGAdot{}; // Rate of Right Ascension [semi-circles/s]
220 double a_af0{}; // Coefficient 0 of code phase offset model [s]
221 double a_af1{}; // Coefficient 1 of code phase offset model [s/s]
222
223 // satellite identification info
224 int32_t i_channel_ID{};
225 uint32_t i_satellite_PRN{};
226
227 // Ionospheric parameters
228 double d_alpha0{}; // Coefficient 0 of a cubic equation representing the amplitude of the vertical delay [s]
229 double d_alpha1{}; // Coefficient 1 of a cubic equation representing the amplitude of the vertical delay [s/semi-circle]
230 double d_alpha2{}; // Coefficient 2 of a cubic equation representing the amplitude of the vertical delay [s(semi-circle)^2]
231 double d_alpha3{}; // Coefficient 3 of a cubic equation representing the amplitude of the vertical delay [s(semi-circle)^3]
232 double d_beta0{}; // Coefficient 0 of a cubic equation representing the period of the model [s]
233 double d_beta1{}; // Coefficient 1 of a cubic equation representing the period of the model [s/semi-circle]
234 double d_beta2{}; // Coefficient 2 of a cubic equation representing the period of the model [s(semi-circle)^2]
235 double d_beta3{}; // Coefficient 3 of a cubic equation representing the period of the model [s(semi-circle)^3]
236
237 // UTC parameters
238 double d_A0{}; // Constant of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200M) [s]
239 double d_A1{}; // 1st order term of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200M) [s/s]
240
241 int32_t d_t_OT{}; // Reference time for UTC data (reference 20.3.4.5 and 20.3.3.5.2.4 IS-GPS-200M) [s]
242 int32_t i_WN_T{}; // UTC reference week number [weeks]
243 int32_t d_DeltaT_LS{}; // delta time due to leap seconds [s]. Number of leap seconds since 6-Jan-1980 as transmitted by the GPS almanac.
244 int32_t i_WN_LSF{}; // Week number at the end of which the leap second becomes effective [weeks]
245 int32_t i_DN{}; // Day number (DN) at the end of which the leap second becomes effective [days]
246 int32_t d_DeltaT_LSF{}; // Scheduled future or recent past (relative to NAV message upload) value of the delta time due to leap seconds [s]
247
248 // Flags
249 bool b_valid_ephemeris_set_flag{}; // flag indicating that this ephemeris set have passed the validation check
250 bool flag_iono_valid{}; // If set, it indicates that the ionospheric parameters are filled (page 18 has arrived and decoded)
251 bool flag_utc_model_valid{}; // If set, it indicates that the UTC model parameters are filled
252 bool flag_almanac_valid{}; // If set, it indicates that the almanac is filled
253 bool flag_almanac_week_valid{}; // If set, it indicates that the almanac week is valid
254 /* If true, enhanced level of integrity assurance.
255 *
256 * If false, indicates that the conveying signal is provided with the legacy level of integrity assurance.
257 * That is, the probability that the instantaneous URE of the conveying signal exceeds 4.42 times the upper bound
258 * value of the current broadcast URA index, for more than 5.2 seconds, without an accompanying alert, is less
259 * than 1E-5 per hour. If true, indicates that the conveying signal is provided with an enhanced level of
260 * integrity assurance. That is, the probability that the instantaneous URE of the conveying signal exceeds 5.73
261 * times the upper bound value of the current broadcast URA index, for more than 5.2 seconds, without an
262 * accompanying alert, is less than 1E-8 per hour.
263 */
264 bool b_integrity_status_flag{};
265 bool b_alert_flag{}; // If true, indicates that the SV URA may be worse than indicated in d_SV_accuracy, use that SV at our own risk.
266 bool b_antispoofing_flag{}; // If true, the AntiSpoofing mode is ON in that SV
267};
268
269
270/** \} */
271/** \} */
272#endif // GNSS_SDR_GPS_NAVIGATION_MESSAGE_H
Defines system parameters for GPS L1 C/A signal and NAV data.
This class is a storage for the GPS SV ALMANAC data as described in IS-GPS-200M.
Definition gps_almanac.h:36
This class is a storage and orbital model functions for the GPS SV ephemeris data as described in IS-...
This class is a storage for the GPS IONOSPHERIC data as described in IS-GPS-200M.
Definition gps_iono.h:36
bool get_flag_iono_valid() const
Gets flag_iono_valid.
Gps_Navigation_Message(LnavSystem system=LnavSystem::GPS)
void set_channel(int32_t channel_id)
Sets channel ID.
int32_t get_TOW() const
Gets Time of Week, in seconds.
uint32_t get_satellite_PRN() const
Gets satellite PRN number.
bool get_flag_utc_model_valid() const
Gets flag_utc_model_valid.
int32_t get_GPS_week() const
Gets GPS Week Number.
void set_satellite_PRN(uint32_t prn)
Sets satellite PRN number.
double utc_time(double gpstime_corrected) const
Computes the Coordinated Universal Time (UTC) and returns it in [s] (IS-GPS-200M, 20....
Gps_Ephemeris get_ephemeris() const
Obtain a GPS SV Ephemeris class filled with current SV data.
Gps_Iono get_iono()
Obtain a GPS ionospheric correction parameters class filled with current SV data.
int32_t subframe_decoder(const char *subframe)
Decodes the GPS NAV message.
Gps_Almanac get_almanac()
Obtain a GPS almanac class filled with current SV data.
Gps_Utc_Model get_utc_model()
Obtain a GPS Almanac model parameters class filled with current SV data.
This class is a storage for the GPS UTC MODEL data as described in IS-GPS-200M.
Interface of a GPS ALMANAC storage.
Interface of a GPS EPHEMERIS storage.
Interface of a GPS IONOSPHERIC MODEL storage.
Interface of a GPS UTC MODEL storage.