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