| Line | Branch | Exec | Source |
|---|---|---|---|
| 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 GPSEphemeris.hpp | ||
| 10 | /// @brief GPS Ephemeris information | ||
| 11 | /// @author T. Topp (topp@ins.uni-stuttgart.de) | ||
| 12 | /// @date 2022-12-02 | ||
| 13 | |||
| 14 | #pragma once | ||
| 15 | |||
| 16 | #include "Navigation/GNSS/Satellite/internal/SatNavData.hpp" | ||
| 17 | |||
| 18 | #include "Navigation/Time/InsTime.hpp" | ||
| 19 | |||
| 20 | namespace NAV | ||
| 21 | { | ||
| 22 | |||
| 23 | /// @brief Broadcasted ephemeris message data | ||
| 24 | /// @note See \cite IS-GPS-200M IS-GPS-200M, Table 20-III, p. 105 | ||
| 25 | /// | ||
| 26 | /// \image html GPS-satellite-orbits.png "Description of the GPS satellite orbits" | ||
| 27 | class GPSEphemeris final : public SatNavData | ||
| 28 | { | ||
| 29 | public: | ||
| 30 | // ####################################################################################################### | ||
| 31 | // Members | ||
| 32 | // ####################################################################################################### | ||
| 33 | |||
| 34 | // ------------------------------------------ Time Parameters -------------------------------------------- | ||
| 35 | |||
| 36 | /// @brief Time of Clock | ||
| 37 | InsTime toc; | ||
| 38 | |||
| 39 | /// @brief Time of Ephemeris | ||
| 40 | InsTime toe; | ||
| 41 | |||
| 42 | /// @brief Issue of Data, Ephemeris | ||
| 43 | /// | ||
| 44 | /// Provides the user with a convenient means for detecting any change in the ephemeris representation parameters | ||
| 45 | /// | ||
| 46 | /// @note See \cite IS-GPS-200M GPS ICD, ch. 20.3.3.4.1, p.102 | ||
| 47 | size_t IODE{}; | ||
| 48 | |||
| 49 | /// @brief Issue of Data, Clock | ||
| 50 | /// | ||
| 51 | /// Indicates the issue number of the data set and thereby provides the user with a convenient means of detecting any change in the | ||
| 52 | /// subframe 1 core CEI data. Constraints on the IODC as well as the relationship between the IODC and the IODE (issue of data, ephemeris) terms | ||
| 53 | /// are defined in \cite IS-GPS-200M GPS ICD, ch. 20.3.4.4. | ||
| 54 | /// | ||
| 55 | /// @note See \cite IS-GPS-200M GPS ICD, ch. 20.3.3.3.1.5, p.95 | ||
| 56 | size_t IODC{}; | ||
| 57 | |||
| 58 | /// Polynomial coefficients for clock correction | ||
| 59 | /// - a(0) bias [s] | ||
| 60 | /// - a(1) drift [s/s] | ||
| 61 | /// - a(2) drift rate (aging) [s/s^2] | ||
| 62 | /// | ||
| 63 | /// @note See \cite IS-GPS-200M GPS ICD, ch. 20.3.3.3.1.8, p.95 | ||
| 64 | std::array<double, 3> a{}; | ||
| 65 | |||
| 66 | // --------------------------------------- Keplerian Parameters ------------------------------------------ | ||
| 67 | |||
| 68 | double sqrt_A{}; ///< Square root of the semi-major axis [m^1/2] | ||
| 69 | double e{}; ///< Eccentricity [-] | ||
| 70 | double i_0{}; ///< Inclination angle at reference time [rad] | ||
| 71 | double Omega_0{}; ///< Longitude of the ascending node at reference time [rad] | ||
| 72 | double omega{}; ///< Argument of perigee [rad] | ||
| 73 | double M_0{}; ///< Mean anomaly at reference time [rad] | ||
| 74 | |||
| 75 | // -------------------------------------- Pertubation Parameters ----------------------------------------- | ||
| 76 | |||
| 77 | double delta_n{}; ///< Mean motion difference from computed value [rad/s] | ||
| 78 | double Omega_dot{}; ///< Rate of change of right ascension [rad/s] | ||
| 79 | double i_dot{}; ///< Rate of change of inclination [rad/s] | ||
| 80 | double Cus{}; ///< Amplitude of the sine harmonic correction term to the argument of latitude [rad] | ||
| 81 | double Cuc{}; ///< Amplitude of the cosine harmonic correction term to the argument of latitude [rad] | ||
| 82 | double Cis{}; ///< Amplitude of the sine harmonic correction term to the angle of inclination [rad] | ||
| 83 | double Cic{}; ///< Amplitude of the cosine harmonic correction term to the angle of inclination [rad] | ||
| 84 | double Crs{}; ///< Amplitude of the sine harmonic correction term to the orbit radius [m] | ||
| 85 | double Crc{}; ///< Amplitude of the cosine harmonic correction term to the orbit radius [m] | ||
| 86 | |||
| 87 | // ----------------------------------------------- Other ------------------------------------------------- | ||
| 88 | |||
| 89 | /// @brief SV accuracy [m] | ||
| 90 | /// | ||
| 91 | /// Derived from an URA index of the SV for the standard positioning service user. | ||
| 92 | /// | ||
| 93 | /// @note See \cite IS-GPS-200M GPS ICD, ch. 20.3.3.3.1.3, p.92ff | ||
| 94 | double svAccuracy{}; | ||
| 95 | |||
| 96 | /// @brief SV health | ||
| 97 | /// | ||
| 98 | /// 0 = all LNAV data are OK | ||
| 99 | /// 1 = some or all LNAV data are bad | ||
| 100 | /// | ||
| 101 | /// @note See \cite IS-GPS-200M GPS ICD, ch. 20.3.3.3.1.4, p. 94 | ||
| 102 | /// @note See \cite IS-GPS-200M GPS ICD, ch. 20.3.3.5.1.3, p. 117ff | ||
| 103 | uint8_t svHealth{}; | ||
| 104 | |||
| 105 | /// @brief Indicate which code(s) is (are) commanded ON for the in-phase component of the L2 channel. | ||
| 106 | /// | ||
| 107 | /// 00 = Invalid, | ||
| 108 | /// 01 = P-code ON, | ||
| 109 | /// 10 = C/A-code ON, | ||
| 110 | /// 11 = Invalid. | ||
| 111 | /// | ||
| 112 | /// These bits provide no indication of which code(s), if any, may be commanded ON for the quadrature component of the L2 channel. | ||
| 113 | /// | ||
| 114 | /// @note See \cite IS-GPS-200M GPS ICD, ch. 20.3.3.3.1.2, p. 92 | ||
| 115 | uint8_t L2ChannelCodes{}; | ||
| 116 | |||
| 117 | /// @brief Data Flag for L2 P-Code | ||
| 118 | /// | ||
| 119 | /// 1 indicates that the LNAV data stream was commanded OFF on the P-code of the in-phase component of the L2 channel. | ||
| 120 | /// This bit provides no indication of whether LNAV data is or is not present on any code modulated on the quadrature component of the L2 channel. | ||
| 121 | /// | ||
| 122 | /// @note See \cite IS-GPS-200M GPS ICD, ch. 20.3.3.3.1.6, p. 95 | ||
| 123 | bool L2DataFlagPCode{}; | ||
| 124 | |||
| 125 | /// @brief Estimated Group Delay Differential. L1 and L2 correction term [s] | ||
| 126 | /// @note See \cite IS-GPS-200M GPS ICD, ch. 20.3.3.3.1.7, p. 95 | ||
| 127 | double T_GD{}; | ||
| 128 | |||
| 129 | /// @brief Fit Interval of ephemerides [h] | ||
| 130 | /// @note See \cite IS-GPS-200M GPS ICD, ch. 20.3.3.4.1, p.102 | ||
| 131 | double fitInterval{}; | ||
| 132 | |||
| 133 | // ####################################################################################################### | ||
| 134 | // Functions | ||
| 135 | // ####################################################################################################### | ||
| 136 | |||
| 137 | /// @brief Default Constructor | ||
| 138 | /// @param[in] toc Time the Clock information is calculated (Time of Clock) | ||
| 139 | explicit GPSEphemeris(const InsTime& toc); | ||
| 140 | |||
| 141 | /// @brief Constructor | ||
| 142 | /// @param[in] toc Time the Clock information is calculated (Time of Clock) | ||
| 143 | /// @param[in] toe Time the Orbit information is calculated (Time of Ephemeris) | ||
| 144 | /// @param[in] IODE Issue of Data, Ephemeris | ||
| 145 | /// @param[in] IODC Issue of Data, Clock | ||
| 146 | /// @param[in] a Polynomial coefficients for clock correction (a0 bias [s], a1 drift [s/s], a2 drift rate (aging) [s/s^2]) | ||
| 147 | /// @param[in] sqrt_A Square root of the semi-major axis [m^1/2] | ||
| 148 | /// @param[in] e Eccentricity [-] | ||
| 149 | /// @param[in] i_0 Inclination angle at reference time [rad] | ||
| 150 | /// @param[in] Omega_0 Longitude of the ascending node at reference time [rad] | ||
| 151 | /// @param[in] omega Argument of perigee [rad] | ||
| 152 | /// @param[in] M_0 Mean anomaly at reference time [rad] | ||
| 153 | /// @param[in] delta_n Mean motion difference from computed value [rad/s] | ||
| 154 | /// @param[in] Omega_dot Rate of change of right ascension [rad/s] | ||
| 155 | /// @param[in] i_dot Rate of change of inclination [rad/s] | ||
| 156 | /// @param[in] Cus Amplitude of the sine harmonic correction term to the argument of latitude [rad] | ||
| 157 | /// @param[in] Cuc Amplitude of the cosine harmonic correction term to the argument of latitude [rad] | ||
| 158 | /// @param[in] Cis Amplitude of the sine harmonic correction term to the angle of inclination [rad] | ||
| 159 | /// @param[in] Cic Amplitude of the cosine harmonic correction term to the angle of inclination [rad] | ||
| 160 | /// @param[in] Crs Amplitude of the sine harmonic correction term to the orbit radius [m] | ||
| 161 | /// @param[in] Crc Amplitude of the cosine harmonic correction term to the orbit radius [m] | ||
| 162 | /// @param[in] svAccuracy SV accuracy [m] | ||
| 163 | /// @param[in] svHealth Signal Health | ||
| 164 | /// @param[in] L2ChannelCodes Indicate which code(s) is (are) commanded ON for the in-phase component of the L2 channel | ||
| 165 | /// @param[in] L2DataFlagPCode Data Flag for L2 P-Code | ||
| 166 | /// @param[in] T_GD Estimated Group Delay Differential. L1 and L2 correction term [s] | ||
| 167 | /// @param[in] fitInterval Fit Interval of ephemerides [h] | ||
| 168 | GPSEphemeris(const InsTime& toc, const InsTime& toe, | ||
| 169 | const size_t& IODE, const size_t& IODC, | ||
| 170 | const std::array<double, 3>& a, | ||
| 171 | const double& sqrt_A, const double& e, const double& i_0, const double& Omega_0, const double& omega, const double& M_0, | ||
| 172 | const double& delta_n, const double& Omega_dot, const double& i_dot, const double& Cus, const double& Cuc, | ||
| 173 | const double& Cis, const double& Cic, const double& Crs, const double& Crc, | ||
| 174 | const double& svAccuracy, uint8_t svHealth, | ||
| 175 | uint8_t L2ChannelCodes, bool L2DataFlagPCode, | ||
| 176 | const double& T_GD, | ||
| 177 | const double& fitInterval); | ||
| 178 | |||
| 179 | #ifdef TESTING | ||
| 180 | /// @brief Constructor for pasting raw data from Nav files | ||
| 181 | /// @param[in] year Time of Clock year | ||
| 182 | /// @param[in] month Time of Clock month | ||
| 183 | /// @param[in] day Time of Clock day | ||
| 184 | /// @param[in] hour Time of Clock hour | ||
| 185 | /// @param[in] minute Time of Clock minute | ||
| 186 | /// @param[in] second Time of Clock second | ||
| 187 | /// @param[in] svClockBias Clock correction a(0) bias [s] | ||
| 188 | /// @param[in] svClockDrift Clock correction a(1) drift [s/s] | ||
| 189 | /// @param[in] svClockDriftRate Clock correction a(2) drift rate (aging) [s/s^2] | ||
| 190 | /// @param[in] IODE Issue of Data, Ephemeris | ||
| 191 | /// @param[in] Crs Amplitude of the sine harmonic correction term to the orbit radius [m] | ||
| 192 | /// @param[in] delta_n Mean motion difference from computed value [rad/s] | ||
| 193 | /// @param[in] M_0 Mean anomaly at reference time [rad] | ||
| 194 | /// @param[in] Cuc Amplitude of the cosine harmonic correction term to the argument of latitude [rad] | ||
| 195 | /// @param[in] e Eccentricity [-] | ||
| 196 | /// @param[in] Cus Amplitude of the sine harmonic correction term to the argument of latitude [rad] | ||
| 197 | /// @param[in] sqrt_A Square root of the semi-major axis [m^1/2] | ||
| 198 | /// @param[in] Toe Time of Ephemeris | ||
| 199 | /// @param[in] Cic Amplitude of the cosine harmonic correction term to the angle of inclination [rad] | ||
| 200 | /// @param[in] Omega_0 Longitude of the ascending node at reference time [rad] | ||
| 201 | /// @param[in] Cis Amplitude of the sine harmonic correction term to the angle of inclination [rad] | ||
| 202 | /// @param[in] i_0 Inclination angle at reference time [rad] | ||
| 203 | /// @param[in] Crc Amplitude of the cosine harmonic correction term to the orbit radius [m] | ||
| 204 | /// @param[in] omega Argument of perigee [rad] | ||
| 205 | /// @param[in] Omega_dot Rate of change of right ascension [rad/s] | ||
| 206 | /// @param[in] i_dot Rate of change of inclination [rad/s] | ||
| 207 | /// @param[in] L2ChannelCodes Indicate which code(s) is (are) commanded ON for the in-phase component of the L2 channel. | ||
| 208 | /// @param[in] GPSWeek GPS Week to go with Toe | ||
| 209 | /// @param[in] L2DataFlagPCode Data Flag for L2 P-Code | ||
| 210 | /// @param[in] svAccuracy SV accuracy [m] | ||
| 211 | /// @param[in] svHealth SV health | ||
| 212 | /// @param[in] T_GD Estimated Group Delay Differential. L1 and L2 correction term [s] | ||
| 213 | /// @param[in] IODC Issue of Data, Clock | ||
| 214 | /// @param[in] TransmissionTimeOfMessage Transmission time of message | ||
| 215 | /// @param[in] fitInterval Fit Interval of ephemerides [h] | ||
| 216 | /// @param[in] spare1 Spare data | ||
| 217 | /// @param[in] spare2 Spare data | ||
| 218 | GPSEphemeris(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t minute, double second, double svClockBias, double svClockDrift, double svClockDriftRate, | ||
| 219 | double IODE, double Crs, double delta_n, double M_0, | ||
| 220 | double Cuc, double e, double Cus, double sqrt_A, | ||
| 221 | double Toe, double Cic, double Omega_0, double Cis, | ||
| 222 | double i_0, double Crc, double omega, double Omega_dot, | ||
| 223 | double i_dot, double L2ChannelCodes, double GPSWeek, double L2DataFlagPCode, | ||
| 224 | double svAccuracy, double svHealth, double T_GD, double IODC, | ||
| 225 | double TransmissionTimeOfMessage, double fitInterval, double spare1 = 0.0, double spare2 = 0.0); | ||
| 226 | #endif | ||
| 227 | |||
| 228 | /// @brief Destructor | ||
| 229 | 20328 | ~GPSEphemeris() final = default; | |
| 230 | /// @brief Copy constructor | ||
| 231 | GPSEphemeris(const GPSEphemeris&) = default; | ||
| 232 | /// @brief Move constructor | ||
| 233 | GPSEphemeris(GPSEphemeris&&) = default; | ||
| 234 | /// @brief Copy assignment operator | ||
| 235 | GPSEphemeris& operator=(const GPSEphemeris&) = delete; | ||
| 236 | /// @brief Move assignment operator | ||
| 237 | GPSEphemeris& operator=(GPSEphemeris&&) = delete; | ||
| 238 | |||
| 239 | /// @brief Calculates the Variance of the satellite position in [m^2] | ||
| 240 | [[nodiscard]] double calcSatellitePositionVariance() const final; | ||
| 241 | |||
| 242 | /// @brief Calculates clock bias and drift of the satellite | ||
| 243 | /// @param[in] recvTime Receive time of the signal | ||
| 244 | /// @param[in] dist Distance between receiver and satellite (normally the pseudorange) [m] | ||
| 245 | /// @param[in] freq Signal Frequency | ||
| 246 | [[nodiscard]] Corrections calcClockCorrections(const InsTime& recvTime, double dist, const Frequency& freq) const final; | ||
| 247 | |||
| 248 | /// @brief Checks whether the signal is healthy | ||
| 249 | [[nodiscard]] bool isHealthy() const final; | ||
| 250 | |||
| 251 | private: | ||
| 252 | /// @brief Calculates position, velocity and acceleration of the satellite at transmission time | ||
| 253 | /// @param[in] transTime Transmit time of the signal | ||
| 254 | /// @param[in] calc Flags which determine what should be calculated and returned | ||
| 255 | /// @note See \cite IS-GPS-200M IS-GPS-200 ch. 20.3.3.4.3.1 Table 20-IV p.106-109 | ||
| 256 | [[nodiscard]] PosVelAccel calcSatelliteData(const InsTime& transTime, Orbit::Calc calc) const final; | ||
| 257 | }; | ||
| 258 | |||
| 259 | } // namespace NAV | ||
| 260 |