GNSS-SDR  0.0.13
An Open Source GNSS Software Defined Receiver
gps_ephemeris.h
Go to the documentation of this file.
1 /*!
2  * \file gps_ephemeris.h
3  * \brief Interface of a GPS EPHEMERIS storage
4  * \author Javier Arribas, 2013. jarribas(at)cttc.es
5  *
6  * -----------------------------------------------------------------------------
7  *
8  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
9  *
10  * GNSS-SDR is a software defined Global Navigation
11  * Satellite Systems receiver
12  *
13  * This file is part of GNSS-SDR.
14  *
15  * SPDX-License-Identifier: GPL-3.0-or-later
16  *
17  * -----------------------------------------------------------------------------
18  */
19 
20 
21 #ifndef GNSS_SDR_GPS_EPHEMERIS_H
22 #define GNSS_SDR_GPS_EPHEMERIS_H
23 
24 
25 #include <boost/serialization/nvp.hpp>
26 #include <cstdint>
27 #include <map>
28 #include <string>
29 
30 
31 /*!
32  * \brief This class is a storage and orbital model functions for the GPS SV ephemeris data as described in IS-GPS-200K
33  *
34  * See https://www.gps.gov/technical/icwg/IS-GPS-200K.pdf Appendix II
35  */
37 {
38 public:
39  /*!
40  * Default constructor
41  */
42  Gps_Ephemeris();
43 
44  /*!
45  * \brief Compute the ECEF SV coordinates and ECEF velocity
46  * Implementation of Table 20-IV (IS-GPS-200K)
47  * and compute the clock bias term including relativistic effect (return value)
48  */
49  double satellitePosition(double transmitTime);
50 
51  /*!
52  * \brief Sets (\a d_satClkDrift)and returns the clock drift in seconds according to the User Algorithm for SV Clock Correction
53  * (IS-GPS-200K, 20.3.3.3.3.1)
54  */
55  double sv_clock_drift(double transmitTime);
56 
57  /*!
58  * \brief Sets (\a d_dtr) and returns the clock relativistic correction term in seconds according to the User Algorithm for SV Clock Correction
59  * (IS-GPS-200K, 20.3.3.3.3.1)
60  */
61  double sv_clock_relativistic_term(double transmitTime);
62 
63  uint32_t i_satellite_PRN{}; // SV PRN NUMBER
64  int32_t d_TOW{}; //!< Time of GPS Week of the ephemeris set (taken from subframes TOW) [s]
65  double d_Crs{}; //!< Amplitude of the Sine Harmonic Correction Term to the Orbit Radius [m]
66  double d_Delta_n{}; //!< Mean Motion Difference From Computed Value [semi-circles/s]
67  double d_M_0{}; //!< Mean Anomaly at Reference Time [semi-circles]
68  double d_Cuc{}; //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad]
69  double d_e_eccentricity{}; //!< Eccentricity [dimensionless]
70  double d_Cus{}; //!< Amplitude of the Sine Harmonic Correction Term to the Argument of Latitude [rad]
71  double d_sqrt_A{}; //!< Square Root of the Semi-Major Axis [sqrt(m)]
72  int32_t d_Toe{}; //!< Ephemeris data reference time of week (Ref. 20.3.3.4.3 IS-GPS-200K) [s]
73  int32_t d_Toc{}; //!< clock data reference time (Ref. 20.3.3.3.3.1 IS-GPS-200K) [s]
74  double d_Cic{}; //!< Amplitude of the Cosine Harmonic Correction Term to the Angle of Inclination [rad]
75  double d_OMEGA0{}; //!< Longitude of Ascending Node of Orbit Plane at Weekly Epoch [semi-circles]
76  double d_Cis{}; //!< Amplitude of the Sine Harmonic Correction Term to the Angle of Inclination [rad]
77  double d_i_0{}; //!< Inclination Angle at Reference Time [semi-circles]
78  double d_Crc{}; //!< Amplitude of the Cosine Harmonic Correction Term to the Orbit Radius [m]
79  double d_OMEGA{}; //!< Argument of Perigee [semi-cicles]
80  double d_OMEGA_DOT{}; //!< Rate of Right Ascension [semi-circles/s]
81  double d_IDOT{}; //!< Rate of Inclination Angle [semi-circles/s]
82  int32_t i_code_on_L2{}; //!< If 1, P code ON in L2; if 2, C/A code ON in L2;
83  int32_t i_GPS_week{}; //!< GPS week number, aka WN [week]
84  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
85  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)
86  int32_t i_SV_health{};
87  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]
88  int32_t d_IODC{}; //!< Issue of Data, Clock
89  int32_t d_IODE_SF2{}; //!< Issue of Data, Ephemeris (IODE), subframe 2
90  int32_t d_IODE_SF3{}; //!< Issue of Data, Ephemeris(IODE), subframe 3
91  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]
92 
93  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.
94  double d_spare1{};
95  double d_spare2{};
96 
97  double d_A_f0{}; //!< Coefficient 0 of code phase offset model [s]
98  double d_A_f1{}; //!< Coefficient 1 of code phase offset model [s/s]
99  double d_A_f2{}; //!< Coefficient 2 of code phase offset model [s/s^2]
100 
101  // Flags
102 
103  /*! \brief If true, enhanced level of integrity assurance.
104  *
105  * If false, indicates that the conveying signal is provided with the legacy level of integrity assurance.
106  * That is, the probability that the instantaneous URE of the conveying signal exceeds 4.42 times the upper bound
107  * value of the current broadcast URA index, for more than 5.2 seconds, without an accompanying alert, is less
108  * than 1E-5 per hour. If true, indicates that the conveying signal is provided with an enhanced level of
109  * integrity assurance. That is, the probability that the instantaneous URE of the conveying signal exceeds 5.73
110  * times the upper bound value of the current broadcast URA index, for more than 5.2 seconds, without an
111  * accompanying alert, is less than 1E-8 per hour.
112  */
114  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.
115  bool b_antispoofing_flag{}; //!< If true, the AntiSpoofing mode is ON in that SV
116 
117  // clock terms derived from ephemeris data
118  double d_satClkDrift{}; //!< GPS clock error
119  double d_dtr{}; //!< relativistic clock correction term
120 
121  // satellite positions
122  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.
123  double d_satpos_Y{}; //!< Earth-fixed coordinate y of the satellite [m]. Completes a right-handed, Earth-Centered, Earth-Fixed orthogonal coordinate system.
124  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).
125 
126  // Satellite velocity
127  double d_satvel_X{}; //!< Earth-fixed velocity coordinate x of the satellite [m]
128  double d_satvel_Y{}; //!< Earth-fixed velocity coordinate y of the satellite [m]
129  double d_satvel_Z{}; //!< Earth-fixed velocity coordinate z of the satellite [m]
130 
131  std::map<int, std::string> satelliteBlock; //!< Map that stores to which block the PRN belongs https://www.navcen.uscg.gov/?Do=constellationStatus
132 
133  template <class Archive>
134 
135  /*!
136  * \brief Serialize is a boost standard method to be called by the boost XML serialization. Here is used to save the ephemeris data on disk file.
137  */
138  inline void serialize(Archive& archive, const uint32_t version)
139  {
140  using boost::serialization::make_nvp;
141  if (version)
142  {
143  };
144 
145  archive& make_nvp("i_satellite_PRN", i_satellite_PRN); // SV PRN NUMBER
146  archive& make_nvp("d_TOW", d_TOW); //!< Time of GPS Week of the ephemeris set (taken from subframes TOW) [s]
147  archive& make_nvp("d_IODE_SF2", d_IODE_SF2);
148  archive& make_nvp("d_IODE_SF3", d_IODE_SF3);
149  archive& make_nvp("d_Crs", d_Crs); //!< Amplitude of the Sine Harmonic Correction Term to the Orbit Radius [m]
150  archive& make_nvp("d_Delta_n", d_Delta_n); //!< Mean Motion Difference From Computed Value [semi-circles/s]
151  archive& make_nvp("d_M_0", d_M_0); //!< Mean Anomaly at Reference Time [semi-circles]
152  archive& make_nvp("d_Cuc", d_Cuc); //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad]
153  archive& make_nvp("d_e_eccentricity", d_e_eccentricity); //!< Eccentricity [dimensionless]
154  archive& make_nvp("d_Cus", d_Cus); //!< Amplitude of the Sine Harmonic Correction Term to the Argument of Latitude [rad]
155  archive& make_nvp("d_sqrt_A", d_sqrt_A); //!< Square Root of the Semi-Major Axis [sqrt(m)]
156  archive& make_nvp("d_Toe", d_Toe); //!< Ephemeris data reference time of week (Ref. 20.3.3.4.3 IS-GPS-200K) [s]
157  archive& make_nvp("d_Toc", d_Toc); //!< clock data reference time (Ref. 20.3.3.3.3.1 IS-GPS-200K) [s]
158  archive& make_nvp("d_Cic", d_Cic); //!< Amplitude of the Cosine Harmonic Correction Term to the Angle of Inclination [rad]
159  archive& make_nvp("d_OMEGA0", d_OMEGA0); //!< Longitude of Ascending Node of Orbit Plane at Weekly Epoch [semi-circles]
160  archive& make_nvp("d_Cis", d_Cis); //!< Amplitude of the Sine Harmonic Correction Term to the Angle of Inclination [rad]
161  archive& make_nvp("d_i_0", d_i_0); //!< Inclination Angle at Reference Time [semi-circles]
162  archive& make_nvp("d_Crc", d_Crc); //!< Amplitude of the Cosine Harmonic Correction Term to the Orbit Radius [m]
163  archive& make_nvp("d_OMEGA", d_OMEGA); //!< Argument of Perigee [semi-cicles]
164  archive& make_nvp("d_OMEGA_DOT", d_OMEGA_DOT); //!< Rate of Right Ascension [semi-circles/s]
165  archive& make_nvp("d_IDOT", d_IDOT); //!< Rate of Inclination Angle [semi-circles/s]
166  archive& make_nvp("i_code_on_L2", i_code_on_L2); //!< If 1, P code ON in L2; if 2, C/A code ON in L2;
167  archive& make_nvp("i_GPS_week", i_GPS_week); //!< GPS week number, aka WN [week]
168  archive& make_nvp("b_L2_P_data_flag", b_L2_P_data_flag); //!< When true, indicates that the NAV data stream was commanded OFF on the P-code of the L2 channel
169  archive& make_nvp("i_SV_accuracy", 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)
170  archive& make_nvp("i_SV_health", i_SV_health);
171  archive& make_nvp("d_TGD", 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]
172  archive& make_nvp("d_IODC", d_IODC); //!< Issue of Data, Clock
173  archive& make_nvp("i_AODO", 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]
174 
175  archive& make_nvp("b_fit_interval_flag", 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.
176  archive& make_nvp("d_spare1", d_spare1);
177  archive& make_nvp("d_spare2", d_spare2);
178 
179  archive& make_nvp("d_A_f0", d_A_f0); //!< Coefficient 0 of code phase offset model [s]
180  archive& make_nvp("d_A_f1", d_A_f1); //!< Coefficient 1 of code phase offset model [s/s]
181  archive& make_nvp("d_A_f2", d_A_f2); //!< Coefficient 2 of code phase offset model [s/s^2]
182 
183  archive& make_nvp("b_integrity_status_flag", b_integrity_status_flag);
184  archive& make_nvp("b_alert_flag", 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.
185  archive& make_nvp("b_antispoofing_flag", b_antispoofing_flag); //!< If true, the AntiSpoofing mode is ON in that SV
186  }
187 
188 private:
189  /*
190  * Accounts for the beginning or end of week crossover
191  *
192  * See paragraph 20.3.3.3.3.1 (IS-GPS-200K)
193  * \param[in] - time in seconds
194  * \param[out] - corrected time, in seconds
195  */
196  double check_t(double time);
197 };
198 
199 #endif
void serialize(Archive &archive, const uint32_t version)
Serialize is a boost standard method to be called by the boost XML serialization. Here is used to sav...
int32_t d_IODC
Issue of Data, Clock.
Definition: gps_ephemeris.h:88
int32_t i_AODO
Age of Data Offset (AODO) term for the navigation message correction table (NMCT) contained in subfra...
Definition: gps_ephemeris.h:91
double d_OMEGA_DOT
Rate of Right Ascension [semi-circles/s].
Definition: gps_ephemeris.h:80
This class is a storage and orbital model functions for the GPS SV ephemeris data as described in IS-...
Definition: gps_ephemeris.h:36
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 d...
Definition: gps_ephemeris.h:93
int32_t d_IODE_SF2
Issue of Data, Ephemeris (IODE), subframe 2.
Definition: gps_ephemeris.h:89
int32_t d_IODE_SF3
Issue of Data, Ephemeris(IODE), subframe 3.
Definition: gps_ephemeris.h:90
double d_Cuc
Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad].
Definition: gps_ephemeris.h:68
double d_Cis
Amplitude of the Sine Harmonic Correction Term to the Angle of Inclination [rad]. ...
Definition: gps_ephemeris.h:76
double d_OMEGA0
Longitude of Ascending Node of Orbit Plane at Weekly Epoch [semi-circles].
Definition: gps_ephemeris.h:75
double d_satClkDrift
GPS clock error.
double sv_clock_drift(double transmitTime)
Sets (d_satClkDrift)and returns the clock drift in seconds according to the User Algorithm for SV Clo...
double d_A_f1
Coefficient 1 of code phase offset model [s/s].
Definition: gps_ephemeris.h:98
double d_Cic
Amplitude of the Cosine Harmonic Correction Term to the Angle of Inclination [rad].
Definition: gps_ephemeris.h:74
bool b_integrity_status_flag
If true, enhanced level of integrity assurance.
std::map< int, std::string > satelliteBlock
Map that stores to which block the PRN belongs https://www.navcen.uscg.gov/?Do=constellationStatus.
int32_t d_TOW
Time of GPS Week of the ephemeris set (taken from subframes TOW) [s].
Definition: gps_ephemeris.h:64
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...
Definition: gps_ephemeris.h:84
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 o...
double d_Cus
Amplitude of the Sine Harmonic Correction Term to the Argument of Latitude [rad]. ...
Definition: gps_ephemeris.h:70
double d_sqrt_A
Square Root of the Semi-Major Axis [sqrt(m)].
Definition: gps_ephemeris.h:71
bool b_antispoofing_flag
If true, the AntiSpoofing mode is ON in that SV.
double d_Crs
Amplitude of the Sine Harmonic Correction Term to the Orbit Radius [m].
Definition: gps_ephemeris.h:65
double d_satvel_Y
Earth-fixed velocity coordinate y of the satellite [m].
double d_satvel_Z
Earth-fixed velocity coordinate z of the satellite [m].
double d_i_0
Inclination Angle at Reference Time [semi-circles].
Definition: gps_ephemeris.h:77
double d_A_f0
Coefficient 0 of code phase offset model [s].
Definition: gps_ephemeris.h:97
double d_satpos_Y
Earth-fixed coordinate y of the satellite [m]. Completes a right-handed, Earth-Centered, Earth-Fixed orthogonal coordinate system.
double d_M_0
Mean Anomaly at Reference Time [semi-circles].
Definition: gps_ephemeris.h:67
int32_t i_GPS_week
GPS week number, aka WN [week].
Definition: gps_ephemeris.h:83
double d_A_f2
Coefficient 2 of code phase offset model [s/s^2].
Definition: gps_ephemeris.h:99
double d_satvel_X
Earth-fixed velocity coordinate x of the satellite [m].
double d_Delta_n
Mean Motion Difference From Computed Value [semi-circles/s].
Definition: gps_ephemeris.h:66
double d_dtr
relativistic clock correction term
int32_t d_Toc
clock data reference time (Ref. 20.3.3.3.3.1 IS-GPS-200K) [s]
Definition: gps_ephemeris.h:73
double d_TGD
Estimated Group Delay Differential: L1-L2 correction term only for the benefit of "L1 P(Y)" or "L2 P(...
Definition: gps_ephemeris.h:87
double d_Crc
Amplitude of the Cosine Harmonic Correction Term to the Orbit Radius [m].
Definition: gps_ephemeris.h:78
double d_satpos_Z
Earth-fixed coordinate z of the satellite [m]. The direction of the IERS (International Earth Rotatio...
double d_satpos_X
Earth-fixed coordinate x of the satellite [m]. Intersection of the IERS Reference Meridian (IRM) and ...
int32_t i_code_on_L2
If 1, P code ON in L2; if 2, C/A code ON in L2;.
Definition: gps_ephemeris.h:82
double d_IDOT
Rate of Inclination Angle [semi-circles/s].
Definition: gps_ephemeris.h:81
double satellitePosition(double transmitTime)
Compute the ECEF SV coordinates and ECEF velocity Implementation of Table 20-IV (IS-GPS-200K) and com...
double sv_clock_relativistic_term(double transmitTime)
Sets (d_dtr) and returns the clock relativistic correction term in seconds according to the User Algo...
int32_t i_SV_accuracy
User Range Accuracy (URA) index of the SV (reference paragraph 6.2.1) for the standard positioning se...
Definition: gps_ephemeris.h:85
double d_e_eccentricity
Eccentricity [dimensionless].
Definition: gps_ephemeris.h:69
double d_OMEGA
Argument of Perigee [semi-cicles].
Definition: gps_ephemeris.h:79
int32_t d_Toe
Ephemeris data reference time of week (Ref. 20.3.3.4.3 IS-GPS-200K) [s].
Definition: gps_ephemeris.h:72