INSTINCT Code Coverage Report


Directory: src/
File: Navigation/GNSS/Satellite/Ephemeris/BDSEphemeris.hpp
Date: 2025-02-07 16:54:41
Exec Total Coverage
Lines: 1 1 100.0%
Functions: 1 1 100.0%
Branches: 0 0 -%

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 BDSEphemeris.hpp
10 /// @brief BDS 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 #include <set>
21
22 namespace NAV
23 {
24
25 // /// @brief List of GEO Satellites of BDS
26 // const static std::set<uint16_t> GeoSats{ 1, 2, 3, 4, 5 };
27
28 /// @brief Broadcasted ephemeris message data
29 /// @note See \cite BDS-SIS-ICD-2.1 BDS-SIS-ICD-2.1, ch. 5.2.4, p. 23ff
30 class BDSEphemeris final : public SatNavData
31 {
32 public:
33 // #######################################################################################################
34 // Members
35 // #######################################################################################################
36
37 /// @brief Number of the satellite
38 const uint16_t satNum;
39
40 // ------------------------------------------ Time Parameters --------------------------------------------
41
42 /// @brief Time of Clock
43 const InsTime toc;
44
45 /// @brief Time of Ephemeris
46 const InsTime toe;
47
48 /// @brief Age of Data, Ephemeris
49 ///
50 /// Age of data, ephemeris (AODE) is the extrapolated interval of ephemeris parameters. It indicates the time difference between the
51 /// reference epoch of ephemeris parameters and the last observation epoch for extrapolating ephemeris parameters. AODE is updated at the start of
52 /// each hour in BDT, and it is 5 bits long with definitions as follows:
53 ///
54 /// | AODE | Definition |
55 /// | :-: | --- |
56 /// | < 25 | Age of the satellite ephemeris parameters in hours |
57 /// | 25 | Age of the satellite ephemeris parameters is two days |
58 /// | 26 | Age of the satellite ephemeris parameters is three days |
59 /// | 27 | Age of the satellite ephemeris parameters is four days |
60 /// | 28 | Age of the satellite ephemeris parameters is five days |
61 /// | 29 | Age of the satellite ephemeris parameters is six days |
62 /// | 30 | Age of the satellite ephemeris parameters is seven days |
63 /// | 31 | Age of the satellite ephemeris parameters is over seven days |
64 ///
65 /// @note See \cite BDS-SIS-ICD-2.1 BDS ICD, ch. 5.2.4.11, Table 5-8, p. 31f
66 const size_t AODE;
67
68 /// @brief Age of Data, Clock
69 ///
70 /// Age of data, clock (AODC) is the extrapolated interval of clock correction parameters. It indicates the time difference between the
71 /// reference epoch of clock correction parameters and the last observation epoch for extrapolating clock correction parameters.
72 /// AODC is updated at the start of each hour in BDT, and it is 5 bits long with definitions as
73 ///
74 /// | AODC | Definition |
75 /// | :-: | --- |
76 /// | < 25 | Age of the satellite clock correction parameters in hours |
77 /// | 25 | Age of the satellite clock correction parameters is two days |
78 /// | 26 | Age of the satellite clock correction parameters is three days |
79 /// | 27 | Age of the satellite clock correction parameters is four days |
80 /// | 28 | Age of the satellite clock correction parameters is five days |
81 /// | 29 | Age of the satellite clock correction parameters is six days |
82 /// | 30 | Age of the satellite clock correction parameters is seven days |
83 /// | 31 | Age of the satellite clock correction parameters is over seven days |
84 ///
85 /// @note See \cite BDS-SIS-ICD-2.1 BDS ICD, ch. 5.2.4.9, Table 5-6, p. 28f
86 const size_t AODC;
87
88 /// Polynomial coefficients for clock correction
89 /// - a(0) bias [s]
90 /// - a(1) drift [s/s]
91 /// - a(2) drift rate (aging) [s/s^2]
92 ///
93 /// @note See \cite BDS-SIS-ICD-2.1 BDS ICD, ch. 5.2.4.10, p. 29f
94 const std::array<double, 3> a;
95
96 // --------------------------------------- Keplerian Parameters ------------------------------------------
97
98 const double sqrt_A; ///< Square root of the semi-major axis [m^1/2]
99 const double e; ///< Eccentricity [-]
100 const double i_0; ///< Inclination angle at reference time [rad]
101 const double Omega_0; ///< Longitude of the ascending node at reference time [rad]
102 const double omega; ///< Argument of perigee [rad]
103 const double M_0; ///< Mean anomaly at reference time [rad]
104
105 // -------------------------------------- Pertubation Parameters -----------------------------------------
106
107 const double delta_n; ///< Mean motion difference from computed value [rad/s]
108 const double Omega_dot; ///< Rate of change of right ascension [rad/s]
109 const double i_dot; ///< Rate of change of inclination [rad/s]
110 const double Cus; ///< Amplitude of the sine harmonic correction term to the argument of latitude [rad]
111 const double Cuc; ///< Amplitude of the cosine harmonic correction term to the argument of latitude [rad]
112 const double Cis; ///< Amplitude of the sine harmonic correction term to the angle of inclination [rad]
113 const double Cic; ///< Amplitude of the cosine harmonic correction term to the angle of inclination [rad]
114 const double Crs; ///< Amplitude of the sine harmonic correction term to the orbit radius [m]
115 const double Crc; ///< Amplitude of the cosine harmonic correction term to the orbit radius [m]
116
117 // ----------------------------------------------- Other -------------------------------------------------
118
119 /// @brief SV accuracy [m]
120 ///
121 /// Derived from an URA index (URAI) of the SV for the standard positioning service user.
122 ///
123 /// @note See \cite BDS-SIS-ICD-2.1 BDS ICD, ch. 5.2.4.5, p. 24
124 const double svAccuracy;
125
126 /// @brief Autonomous Satellite Health flag
127 ///
128 /// 0 = broadcasting satellite is good
129 /// 1 = broadcasting satellite is not good
130 ///
131 /// @note See \cite BDS-SIS-ICD-2.1 BDS ICD, ch. 5.2.4.6, p. 25
132 const uint8_t satH1;
133
134 /// @brief Equipment Group Delay Differential. B1/B3 [s]
135 /// @note See \cite BDS-SIS-ICD-2.1 BDS ICD, ch. 5.2.4.8, p. 28
136 const double T_GD1;
137
138 /// @brief Equipment Group Delay Differential. B2/B3 [s]
139 /// @note See \cite BDS-SIS-ICD-2.1 BDS ICD, ch. 5.2.4.8, p. 28
140 const double T_GD2;
141
142 // #######################################################################################################
143 // Functions
144 // #######################################################################################################
145
146 /// @brief Constructor
147 /// @param[in] satNum Number of the satellite
148 /// @param[in] toc Time the Clock information is calculated (Time of Clock)
149 /// @param[in] toe Time the Orbit information is calculated (Time of Ephemeris)
150 /// @param[in] AODE Age of Data, Ephemeris
151 /// @param[in] AODC Age of Data, Clock
152 /// @param[in] a Polynomial coefficients for clock correction (a0 bias [s], a1 drift [s/s], a2 drift rate (aging) [s/s^2])
153 /// @param[in] sqrt_A Square root of the semi-major axis [m^1/2]
154 /// @param[in] e Eccentricity [-]
155 /// @param[in] i_0 Inclination angle at reference time [rad]
156 /// @param[in] Omega_0 Longitude of the ascending node at reference time [rad]
157 /// @param[in] omega Argument of perigee [rad]
158 /// @param[in] M_0 Mean anomaly at reference time [rad]
159 /// @param[in] delta_n Mean motion difference from computed value [rad/s]
160 /// @param[in] Omega_dot Rate of change of right ascension [rad/s]
161 /// @param[in] i_dot Rate of change of inclination [rad/s]
162 /// @param[in] Cus Amplitude of the sine harmonic correction term to the argument of latitude [rad]
163 /// @param[in] Cuc Amplitude of the cosine harmonic correction term to the argument of latitude [rad]
164 /// @param[in] Cis Amplitude of the sine harmonic correction term to the angle of inclination [rad]
165 /// @param[in] Cic Amplitude of the cosine harmonic correction term to the angle of inclination [rad]
166 /// @param[in] Crs Amplitude of the sine harmonic correction term to the orbit radius [m]
167 /// @param[in] Crc Amplitude of the cosine harmonic correction term to the orbit radius [m]
168 /// @param[in] svAccuracy SV accuracy [m]
169 /// @param[in] satH1 Autonomous Satellite Health flag
170 /// @param[in] T_GD1 Equipment Group Delay Differential. B1/B3 [s]
171 /// @param[in] T_GD2 Equipment Group Delay Differential. B2/B3 [s]
172 BDSEphemeris(const uint16_t& satNum, const InsTime& toc, const InsTime& toe,
173 const size_t& AODE, const size_t& AODC,
174 const std::array<double, 3>& a,
175 const double& sqrt_A, const double& e, const double& i_0, const double& Omega_0, const double& omega, const double& M_0,
176 const double& delta_n, const double& Omega_dot, const double& i_dot, const double& Cus, const double& Cuc,
177 const double& Cis, const double& Cic, const double& Crs, const double& Crc,
178 const double& svAccuracy, uint8_t satH1, double T_GD1, double T_GD2);
179
180 #ifdef TESTING
181 /// @brief Constructor for pasting raw data from Nav files
182 /// @param[in] satNum Number of the satellite
183 /// @param[in] year Time of Clock year
184 /// @param[in] month Time of Clock month
185 /// @param[in] day Time of Clock day
186 /// @param[in] hour Time of Clock hour
187 /// @param[in] minute Time of Clock minute
188 /// @param[in] second Time of Clock second
189 /// @param[in] svClockBias Clock correction a(0) bias [s]
190 /// @param[in] svClockDrift Clock correction a(1) drift [s/s]
191 /// @param[in] svClockDriftRate Clock correction a(2) drift rate (aging) [s/s^2]
192 /// @param[in] AODE Age of Data, Ephemeris
193 /// @param[in] Crs Amplitude of the sine harmonic correction term to the orbit radius [m]
194 /// @param[in] delta_n Mean motion difference from computed value [rad/s]
195 /// @param[in] M_0 Mean anomaly at reference time [rad]
196 /// @param[in] Cuc Amplitude of the cosine harmonic correction term to the argument of latitude [rad]
197 /// @param[in] e Eccentricity [-]
198 /// @param[in] Cus Amplitude of the sine harmonic correction term to the argument of latitude [rad]
199 /// @param[in] sqrt_A Square root of the semi-major axis [m^1/2]
200 /// @param[in] Toe Time of Ephemeris
201 /// @param[in] Cic Amplitude of the cosine harmonic correction term to the angle of inclination [rad]
202 /// @param[in] Omega_0 Longitude of the ascending node at reference time [rad]
203 /// @param[in] Cis Amplitude of the sine harmonic correction term to the angle of inclination [rad]
204 /// @param[in] i_0 Inclination angle at reference time [rad]
205 /// @param[in] Crc Amplitude of the cosine harmonic correction term to the orbit radius [m]
206 /// @param[in] omega Argument of perigee [rad]
207 /// @param[in] Omega_dot Rate of change of right ascension [rad/s]
208 /// @param[in] i_dot Rate of change of inclination [rad/s]
209 /// @param[in] spare1 Spare data
210 /// @param[in] BDTWeek BDT Week to go with Toe (not GPS Week)
211 /// @param[in] spare2 Spare data
212 /// @param[in] svAccuracy SV accuracy [m]
213 /// @param[in] satH1 Autonomous Satellite Health flag
214 /// @param[in] T_GD1 Equipment Group Delay Differential. B1/B3 [s]
215 /// @param[in] T_GD2 Equipment Group Delay Differential. B2/B3 [s]
216 /// @param[in] TransmissionTimeOfMessage Transmission time of message
217 /// @param[in] AODC Age of Data, Clock
218 /// @param[in] spare3 Spare data
219 /// @param[in] spare4 Spare data
220 BDSEphemeris(int32_t satNum, int32_t year, int32_t month, int32_t day, int32_t hour, int32_t minute, double second, double svClockBias, double svClockDrift, double svClockDriftRate,
221 double AODE, double Crs, double delta_n, double M_0,
222 double Cuc, double e, double Cus, double sqrt_A,
223 double Toe, double Cic, double Omega_0, double Cis,
224 double i_0, double Crc, double omega, double Omega_dot,
225 double i_dot, double spare1, double BDTWeek, double spare2,
226 double svAccuracy, double satH1, double T_GD1, double T_GD2,
227 double TransmissionTimeOfMessage, double AODC, double spare3 = 0.0, double spare4 = 0.0);
228 #endif
229
230 /// @brief Destructor
231 13780 ~BDSEphemeris() final = default;
232 /// @brief Copy constructor
233 BDSEphemeris(const BDSEphemeris&) = default;
234 /// @brief Move constructor
235 BDSEphemeris(BDSEphemeris&&) = default;
236 /// @brief Copy assignment operator
237 BDSEphemeris& operator=(const BDSEphemeris&) = delete;
238 /// @brief Move assignment operator
239 BDSEphemeris& operator=(BDSEphemeris&&) = delete;
240
241 /// @brief Calculates the Variance of the satellite position in [m^2]
242 [[nodiscard]] double calcSatellitePositionVariance() const final;
243
244 /// @brief Calculates clock bias and drift of the satellite
245 /// @param[in] recvTime Receive time of the signal
246 /// @param[in] dist Distance between receiver and satellite (normally the pseudorange) [m]
247 /// @param[in] freq Signal Frequency
248 /// @note See \cite BDS-SIS-ICD-2.1 BDS ICD, ch. 5.2.4.10, p. 29ff
249 [[nodiscard]] Corrections calcClockCorrections(const InsTime& recvTime, double dist, const Frequency& freq) const final;
250
251 /// @brief Checks whether the signal is healthy
252 [[nodiscard]] bool isHealthy() const final;
253
254 private:
255 /// @brief Calculates position, velocity and acceleration of the satellite at transmission time
256 /// @param[in] transTime Transmit time of the signal
257 /// @param[in] calc Flags which determine what should be calculated and returned
258 /// @note See \cite BDS-SIS-ICD-2.1 BDS ICD, ch. 5.2.4.12, p. 32ff
259 /// @note See \cite IS-GPS-200M IS-GPS-200 ch. 20.3.3.4.3.1 Table 20-IV p.106-109
260 [[nodiscard]] PosVelAccel calcSatelliteData(const InsTime& transTime, Orbit::Calc calc) const final;
261 };
262
263 } // namespace NAV
264