GNSS-SDR  0.0.13
An Open Source GNSS Software Defined Receiver
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  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
10  *
11  * GNSS-SDR is a software defined Global Navigation
12  * Satellite Systems receiver
13  *
14  * This file is part of GNSS-SDR.
15  *
16  * SPDX-License-Identifier: GPL-3.0-or-later
17  *
18  * -----------------------------------------------------------------------------
19  */
20 
21 
22 #ifndef GNSS_SDR_GPS_NAVIGATION_MESSAGE_H
23 #define GNSS_SDR_GPS_NAVIGATION_MESSAGE_H
24 
25 
26 #include "GPS_L1_CA.h"
27 #include "gps_ephemeris.h"
28 #include "gps_iono.h"
29 #include "gps_utc_model.h"
30 #include <bitset>
31 #include <cstdint>
32 #include <map>
33 #include <string>
34 #include <utility> // for pair
35 #include <vector>
36 
37 
38 /*!
39  * \brief This class decodes a GPS NAV Data message as described in IS-GPS-200K
40  *
41  * See https://www.gps.gov/technical/icwg/IS-GPS-200K.pdf Appendix II
42  */
44 {
45 public:
46  /*!
47  * Default constructor
48  */
50 
51  /*!
52  * \brief Obtain a GPS SV Ephemeris class filled with current SV data
53  */
55 
56  /*!
57  * \brief Obtain a GPS ionospheric correction parameters class filled with current SV data
58  */
60 
61  /*!
62  * \brief Obtain a GPS UTC model parameters class filled with current SV data
63  */
65 
66  /*!
67  * \brief Decodes the GPS NAV message
68  */
69  int32_t subframe_decoder(char* subframe);
70 
71  /*!
72  * \brief Computes the Coordinated Universal Time (UTC) and
73  * returns it in [s] (IS-GPS-200K, 20.3.3.5.2.4)
74  */
75  double utc_time(const double gpstime_corrected) const;
76 
77  /*!
78  * \brief Gets Time of Week, in seconds
79  */
80  inline int32_t get_TOW() const
81  {
82  return d_TOW;
83  }
84 
85  /*!
86  * \brief Sets Time of Week, in seconds
87  */
88  inline int32_t get_GPS_week() const
89  {
90  return i_GPS_week;
91  }
92 
93  /*!
94  * \brief Sets satellite PRN number
95  */
96  inline void set_satellite_PRN(uint32_t prn)
97  {
98  i_satellite_PRN = prn;
99  }
100 
101  /*!
102  * \brief Gets satellite PRN number
103  */
104  inline uint32_t get_satellite_PRN() const
105  {
106  return i_satellite_PRN;
107  }
108 
109  /*!
110  * \brief Sets channel ID
111  */
112  inline void set_channel(int32_t channel_id)
113  {
114  i_channel_ID = channel_id;
115  }
116 
117  /*!
118  * \brief Gets flag_iono_valid
119  */
120  inline bool get_flag_iono_valid() const
121  {
122  return flag_iono_valid;
123  }
124 
125  /*!
126  * \brief Gets flag_utc_model_valid
127  */
128  inline bool get_flag_utc_model_valid() const
129  {
130  return flag_utc_model_valid;
131  }
132 
133  bool satellite_validation();
134 
135 private:
136  uint64_t read_navigation_unsigned(std::bitset<GPS_SUBFRAME_BITS> bits, const std::vector<std::pair<int32_t, int32_t>>& parameter) const;
137  int64_t read_navigation_signed(std::bitset<GPS_SUBFRAME_BITS> bits, const std::vector<std::pair<int32_t, int32_t>>& parameter) const;
138  bool read_navigation_bool(std::bitset<GPS_SUBFRAME_BITS> bits, const std::vector<std::pair<int32_t, int32_t>>& parameter) const;
139  void print_gps_word_bytes(uint32_t GPS_word) const;
140 
141  std::map<int32_t, int32_t> almanacHealth; //!< Map that stores the health information stored in the almanac
142 
143  std::map<int32_t, std::string> satelliteBlock; //!< Map that stores to which block the PRN belongs https://www.navcen.uscg.gov/?Do=constellationStatus
144 
145  // broadcast orbit 1
146  int32_t d_TOW{}; // Time of GPS Week of the ephemeris set (taken from subframes TOW) [s]
147  int32_t d_TOW_SF1{}; // Time of GPS Week from HOW word of Subframe 1 [s]
148  int32_t d_TOW_SF2{}; // Time of GPS Week from HOW word of Subframe 2 [s]
149  int32_t d_TOW_SF3{}; // Time of GPS Week from HOW word of Subframe 3 [s]
150  int32_t d_TOW_SF4{}; // Time of GPS Week from HOW word of Subframe 4 [s]
151  int32_t d_TOW_SF5{}; // Time of GPS Week from HOW word of Subframe 5 [s]
152  int32_t d_IODE_SF2{};
153  int32_t d_IODE_SF3{};
154  double d_Crs{}; // Amplitude of the Sine Harmonic Correction Term to the Orbit Radius [m]
155  double d_Delta_n{}; // Mean Motion Difference From Computed Value [semi-circles/s]
156  double d_M_0{}; // Mean Anomaly at Reference Time [semi-circles]
157  // broadcast orbit 2
158  double d_Cuc{}; // Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad]
159  double d_e_eccentricity{}; // Eccentricity [dimensionless]
160  double d_Cus{}; // Amplitude of the Sine Harmonic Correction Term to the Argument of Latitude [rad]
161  double d_sqrt_A{}; // Square Root of the Semi-Major Axis [sqrt(m)]
162  // broadcast orbit 3
163  int32_t d_Toe{}; // Ephemeris data reference time of week (Ref. 20.3.3.4.3 IS-GPS-200K) [s]
164  int32_t d_Toc{}; // clock data reference time (Ref. 20.3.3.3.3.1 IS-GPS-200K) [s]
165  double d_Cic{}; // Amplitude of the Cosine Harmonic Correction Term to the Angle of Inclination [rad]
166  double d_OMEGA0{}; // Longitude of Ascending Node of Orbit Plane at Weekly Epoch [semi-circles]
167  double d_Cis{}; // Amplitude of the Sine Harmonic Correction Term to the Angle of Inclination [rad]
168  // broadcast orbit 4
169  double d_i_0{}; // Inclination Angle at Reference Time [semi-circles]
170  double d_Crc{}; // Amplitude of the Cosine Harmonic Correction Term to the Orbit Radius [m]
171  double d_OMEGA{}; // Argument of Perigee [semi-cicles]
172  double d_OMEGA_DOT{}; // Rate of Right Ascension [semi-circles/s]
173  // broadcast orbit 5
174  double d_IDOT{}; // Rate of Inclination Angle [semi-circles/s]
175  int32_t i_code_on_L2{}; // If 1, P code ON in L2; if 2, C/A code ON in L2;
176  int32_t i_GPS_week{}; // GPS week number, aka WN [week]
177  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
178  // broadcast orbit 6
179  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-200K)
180  int32_t i_SV_health{};
181  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]
182  int32_t d_IODC{}; // Issue of Data, Clock
183  // broadcast orbit 7
184  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]
185  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.
186  double d_spare1{};
187  double d_spare2{};
188  double d_A_f0{}; // Coefficient 0 of code phase offset model [s]
189  double d_A_f1{}; // Coefficient 1 of code phase offset model [s/s]
190  double d_A_f2{}; // Coefficient 2 of code phase offset model [s/s^2]
191 
192  // Almanac
193  int32_t i_Toa{}; // Almanac reference time [s]
194  int32_t i_WN_A{}; // Modulo 256 of the GPS week number to which the almanac reference time (i_Toa) is referenced
195 
196  // clock terms
197  // double d_master_clock{}; // GPS transmission time
198 
199  double d_dtr{}; // relativistic clock correction term
200  double d_satClkDrift{};
201 
202  // satellite positions
203  double d_satpos_X{}; // Earth-fixed coordinate x of the satellite [m]. Intersection of the IERS Reference Meridian (IRM) and the plane passing through the origin and normal to the Z-axis.
204  double d_satpos_Y{}; // Earth-fixed coordinate y of the satellite [m]. Completes a right-handed, Earth-Centered, Earth-Fixed orthogonal coordinate system.
205  double d_satpos_Z{}; // Earth-fixed coordinate z of the satellite [m]. The direction of the IERS (International Earth Rotation and Reference Systems Service) Reference Pole (IRP).
206 
207  // Satellite velocity
208  double d_satvel_X{}; // Earth-fixed velocity coordinate x of the satellite [m]
209  double d_satvel_Y{}; // Earth-fixed velocity coordinate y of the satellite [m]
210  double d_satvel_Z{}; // Earth-fixed velocity coordinate z of the satellite [m]
211 
212  // satellite identification info
213  int32_t i_channel_ID{};
214  uint32_t i_satellite_PRN{};
215 
216  // Ionospheric parameters
217  double d_alpha0{}; // Coefficient 0 of a cubic equation representing the amplitude of the vertical delay [s]
218  double d_alpha1{}; // Coefficient 1 of a cubic equation representing the amplitude of the vertical delay [s/semi-circle]
219  double d_alpha2{}; // Coefficient 2 of a cubic equation representing the amplitude of the vertical delay [s(semi-circle)^2]
220  double d_alpha3{}; // Coefficient 3 of a cubic equation representing the amplitude of the vertical delay [s(semi-circle)^3]
221  double d_beta0{}; // Coefficient 0 of a cubic equation representing the period of the model [s]
222  double d_beta1{}; // Coefficient 1 of a cubic equation representing the period of the model [s/semi-circle]
223  double d_beta2{}; // Coefficient 2 of a cubic equation representing the period of the model [s(semi-circle)^2]
224  double d_beta3{}; // Coefficient 3 of a cubic equation representing the period of the model [s(semi-circle)^3]
225 
226  // UTC parameters
227  double d_A0{}; // Constant of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200K) [s]
228  double d_A1{}; // 1st order term of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200K) [s/s]
229 
230  int32_t d_t_OT{}; // Reference time for UTC data (reference 20.3.4.5 and 20.3.3.5.2.4 IS-GPS-200K) [s]
231  int32_t i_WN_T{}; // UTC reference week number [weeks]
232  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.
233  int32_t i_WN_LSF{}; // Week number at the end of which the leap second becomes effective [weeks]
234  int32_t i_DN{}; // Day number (DN) at the end of which the leap second becomes effective [days]
235  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]
236 
237  // Flags
238  bool b_valid_ephemeris_set_flag{}; // flag indicating that this ephemeris set have passed the validation check
239  bool flag_iono_valid{}; // If set, it indicates that the ionospheric parameters are filled (page 18 has arrived and decoded)
240  bool flag_utc_model_valid{}; // If set, it indicates that the UTC model parameters are filled
241 
242  /* If true, enhanced level of integrity assurance.
243  *
244  * If false, indicates that the conveying signal is provided with the legacy level of integrity assurance.
245  * That is, the probability that the instantaneous URE of the conveying signal exceeds 4.42 times the upper bound
246  * value of the current broadcast URA index, for more than 5.2 seconds, without an accompanying alert, is less
247  * than 1E-5 per hour. If true, indicates that the conveying signal is provided with an enhanced level of
248  * integrity assurance. That is, the probability that the instantaneous URE of the conveying signal exceeds 5.73
249  * times the upper bound value of the current broadcast URA index, for more than 5.2 seconds, without an
250  * accompanying alert, is less than 1E-8 per hour.
251  */
252  bool b_integrity_status_flag{};
253  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.
254  bool b_antispoofing_flag{}; // If true, the AntiSpoofing mode is ON in that SV
255 };
256 
257 #endif
This class is a storage for the GPS IONOSPHERIC data as described in IS-GPS-200K. ...
Definition: gps_iono.h:33
Gps_Ephemeris get_ephemeris() const
Obtain a GPS SV Ephemeris class filled with current SV data.
Gps_Utc_Model get_utc_model()
Obtain a GPS UTC model parameters class filled with current SV data.
double utc_time(const double gpstime_corrected) const
Computes the Coordinated Universal Time (UTC) and returns it in s
int32_t subframe_decoder(char *subframe)
Decodes the GPS NAV message.
This class is a storage and orbital model functions for the GPS SV ephemeris data as described in IS-...
Definition: gps_ephemeris.h:36
Defines system parameters for GPS L1 C/A signal and NAV data.
Interface of a GPS UTC MODEL storage.
Gps_Iono get_iono()
Obtain a GPS ionospheric correction parameters class filled with current SV data. ...
void set_channel(int32_t channel_id)
Sets channel ID.
bool get_flag_utc_model_valid() const
Gets flag_utc_model_valid.
bool get_flag_iono_valid() const
Gets flag_iono_valid.
This class decodes a GPS NAV Data message as described in IS-GPS-200K.
Interface of a GPS EPHEMERIS storage.
This class is a storage for the GPS UTC MODEL data as described in IS-GPS-200K.
Definition: gps_utc_model.h:32
uint32_t get_satellite_PRN() const
Gets satellite PRN number.
void set_satellite_PRN(uint32_t prn)
Sets satellite PRN number.
int32_t get_GPS_week() const
Sets Time of Week, in seconds.
int32_t get_TOW() const
Gets Time of Week, in seconds.
Interface of a GPS IONOSPHERIC MODEL storage.