GNSS-SDR  0.0.14
An Open Source GNSS Software Defined Receiver
beidou_dnav_navigation_message.h
Go to the documentation of this file.
1 /*!
2  * \file beidou_dnav_navigation_message.h
3  * \brief Interface of a BeiDou DNAV Data message decoder
4  * \author Sergi Segura, 2018. sergi.segura.munoz(at)gmail.com
5  * \author Damian Miralles, 2018. dmiralles2009@gmail.com
6  *
7  * -----------------------------------------------------------------------------
8  *
9  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
10  * This file is part of GNSS-SDR.
11  *
12  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
13  * SPDX-License-Identifier: GPL-3.0-or-later
14  *
15  * -----------------------------------------------------------------------------
16  */
17 
18 
19 #ifndef GNSS_SDR_BEIDOU_DNAV_NAVIGATION_MESSAGE_H
20 #define GNSS_SDR_BEIDOU_DNAV_NAVIGATION_MESSAGE_H
21 
22 
23 #include "Beidou_B1I.h"
24 #include "Beidou_B3I.h"
25 #include "Beidou_DNAV.h"
26 #include "beidou_dnav_almanac.h"
27 #include "beidou_dnav_ephemeris.h"
28 #include "beidou_dnav_iono.h"
29 #include "beidou_dnav_utc_model.h"
30 #include <bitset>
31 #include <cstdint>
32 #include <map>
33 #include <string>
34 #include <utility>
35 #include <vector>
36 
37 /** \addtogroup Core
38  * \{ */
39 /** \addtogroup System_Parameters
40  * \{ */
41 
42 
43 /*!
44  * \brief This class decodes a BeiDou D1 NAV Data message
45  */
47 {
48 public:
49  /*!
50  * Default constructor
51  */
53 
54  /*!
55  * \brief Obtain a BDS SV Ephemeris class filled with current SV data
56  */
58 
59  /*!
60  * \brief Obtain a BDS ionospheric correction parameters class filled with current SV data
61  */
63 
64  /*!
65  * \brief Obtain a BDS UTC model parameters class filled with current SV data
66  */
68 
69  /*!
70  * \brief Decodes the BDS D1 NAV message
71  */
72  int32_t d1_subframe_decoder(std::string const& subframe);
73 
74  /*!
75  * \brief Decodes the BDS D2 NAV message
76  */
77  int32_t d2_subframe_decoder(std::string const& subframe);
78 
79  /*!
80  * \brief Computes the position of the satellite
81  */
82  void satellitePosition(double transmitTime);
83 
84  /*!
85  * \brief Sets (\a d_satClkCorr) according to the User Algorithm for SV Clock Correction
86  * and returns the corrected clock
87  */
88  double sv_clock_correction(double transmitTime);
89 
90  /*!
91  * \brief Computes the Coordinated Universal Time (UTC) and
92  * returns it in [s]
93  */
94  double utc_time(const double beidoutime_corrected) const;
95 
96  bool satellite_validation();
97 
98  /*!
99  * \brief Returns true if new Ephemeris has arrived. The flag is set to false when the function is executed
100  */
101  bool have_new_ephemeris();
102 
103  /*!
104  * \brief Returns true if new Iono model has arrived. The flag is set to false when the function is executed
105  */
106  bool have_new_iono() const;
107 
108  /*!
109  * \brief Returns true if new UTC model has arrived. The flag is set to false when the function is executed
110  */
111  bool have_new_utc_model();
112 
113  /*!
114  * \brief Returns true if new UTC model has arrived. The flag is set to false when the function is executed
115  */
116  bool have_new_almanac();
117 
118  /*!
119  * \brief Sets satellite PRN number
120  */
121  inline void set_satellite_PRN(uint32_t prn)
122  {
123  i_satellite_PRN = prn;
124  }
125 
126  inline void set_signal_type(int32_t signal_type)
127  {
128  i_signal_type = signal_type;
129  }
130 
131  inline bool get_flag_CRC_test() const
132  {
133  return flag_crc_test;
134  }
135 
136  inline bool get_flag_new_SOW_available() const
137  {
138  return flag_new_SOW_available;
139  }
140 
141  inline void set_flag_new_SOW_available(bool new_SOW_available)
142  {
143  flag_new_SOW_available = new_SOW_available;
144  }
145 
146  inline double get_SOW() const
147  {
148  return d_SOW;
149  }
150 
151 private:
152  uint64_t read_navigation_unsigned(std::bitset<BEIDOU_DNAV_SUBFRAME_DATA_BITS> bits, const std::vector<std::pair<int32_t, int32_t>>& parameter) const;
153  int64_t read_navigation_signed(std::bitset<BEIDOU_DNAV_SUBFRAME_DATA_BITS> bits, const std::vector<std::pair<int32_t, int32_t>>& parameter) const;
154  bool read_navigation_bool(std::bitset<BEIDOU_DNAV_SUBFRAME_DATA_BITS> bits, const std::vector<std::pair<int32_t, int32_t>>& parameter) const;
155  void print_beidou_word_bytes(uint32_t BEIDOU_word) const;
156 
157  /*
158  * Accounts for the beginning or end of week crossover
159  *
160  * \param[in] - time in seconds
161  * \param[out] - corrected time, in seconds
162  */
163  double check_t(double time);
164 
165  // broadcast orbit 1
166  double d_SOW{}; // Time of BeiDou Week of the ephemeris set (taken from subframes SOW) [s]
167  double d_SOW_SF1{}; // Time of BeiDou Week from HOW word of Subframe 1 [s]
168  double d_SOW_SF2{}; // Time of BeiDou Week from HOW word of Subframe 2 [s]
169  double d_SOW_SF3{}; // Time of BeiDou Week from HOW word of Subframe 3 [s]
170  double d_SOW_SF4{}; // Time of BeiDou Week from HOW word of Subframe 4 [s]
171  double d_SOW_SF5{}; // Time of BeiDou Week from HOW word of Subframe 5 [s]
172 
173  double d_AODE{};
174  double d_Crs{}; // Amplitude of the Sine Harmonic Correction Term to the Orbit Radius [m]
175  double d_Delta_n{}; // Mean Motion Difference From Computed Value [semi-circles/s]
176  double d_M_0{}; // Mean Anomaly at Reference Time [semi-circles]
177 
178  // broadcast orbit 2
179  double d_Cuc{}; // Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad]
180  double d_eccentricity{}; // Eccentricity [dimensionless]
181  double d_Cus{}; // Amplitude of the Sine Harmonic Correction Term to the Argument of Latitude [rad]
182  double d_sqrt_A{}; // Square Root of the Semi-Major Axis [sqrt(m)]
183 
184  // broadcast orbit 3
185  double d_Toe_sf2{}; // Ephemeris data reference time of week in subframe 2, D1 Message
186  double d_Toe_sf3{}; // Ephemeris data reference time of week in subframe 3, D1 Message
187  double d_Toe{}; // Ephemeris data reference time of week in subframe 1, D2 Message
188  double d_Toc{}; // clock data reference time [s]
189  double d_Cic{}; // Amplitude of the Cosine Harmonic Correction Term to the Angle of Inclination [rad]
190  double d_OMEGA0{}; // Longitude of Ascending Node of Orbit Plane at Weekly Epoch [semi-circles]
191  double d_Cis{}; // Amplitude of the Sine Harmonic Correction Term to the Angle of Inclination [rad]
192 
193  // broadcast orbit 4
194  double d_i_0{}; // Inclination Angle at Reference Time [semi-circles]
195  double d_Crc{}; // Amplitude of the Cosine Harmonic Correction Term to the Orbit Radius [m]
196  double d_OMEGA{}; // Argument of Perigee [semi-cicles]
197  double d_OMEGA_DOT{}; // Rate of Right Ascension [semi-circles/s]
198 
199  // broadcast orbit 5
200  double d_IDOT{}; // Rate of Inclination Angle [semi-circles/s]
201  int32_t i_BEIDOU_week{}; // BeiDou week number, aka WN [week]
202 
203  // broadcast orbit 6
204  int32_t i_SV_accuracy{}; // User Range Accuracy (URA) index of the SV
205  int32_t i_SV_health{};
206  double d_TGD1{}; // Estimated Group Delay Differential in B1 [s]
207  double d_TGD2{}; // Estimated Group Delay Differential in B2 [s]
208  double d_AODC{}; // Age of Data, Clock
209 
210  // broadcast orbit 7
211  // 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]
212 
213  // 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.
214  // double d_spare1{};
215  // double d_spare2{};
216 
217  double d_A_f0{}; // Clock correction parameters. Coefficient 0 of code phase offset model [s]
218  double d_A_f1{}; // Clock correction parameters. Coefficient 1 of code phase offset model [s/s]
219  double d_A_f2{}; // Clock correction parameters. Coefficient 2 of code phase offset model [s/s^2]
220 
221  // D2 NAV Message Decoding
222  uint64_t d_A_f1_msb_bits{}; // Clock correction parameters, D2 NAV MSB
223  uint64_t d_A_f1_lsb_bits{}; // Clock correction parameters, D2 NAV LSB
224  uint64_t d_Cuc_msb_bits{}; // Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad]
225  uint64_t d_Cuc_lsb_bits{}; // Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad]
226  uint64_t d_eccentricity_msb{}; // Eccentricity [dimensionless]
227  uint64_t d_eccentricity_lsb{}; // Eccentricity [dimensionless]
228  uint64_t d_Cic_msb_bits{}; // Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad]
229  uint64_t d_Cic_lsb_bits{}; // Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad]
230  uint64_t d_eccentricity_msb_bits{}; // Eccentricity [dimensionless]
231  uint64_t d_eccentricity_lsb_bits{};
232  uint64_t d_i_0_msb_bits{}; // Inclination Angle at Reference Time [semi-circles]
233  uint64_t d_i_0_lsb_bits{}; // Inclination Angle at Reference Time [semi-circles]
234  uint64_t d_OMEGA_msb_bits{}; // Argument of Perigee [semi-cicles]
235  uint64_t d_OMEGA_lsb_bits{}; // Argument of Perigee [semi-cicles]
236  uint64_t d_OMEGA_DOT_msb_bits{}; // Rate of Right Ascension [semi-circles/s]
237  uint64_t d_OMEGA_DOT_lsb_bits{}; // Rate of Right Ascension [semi-circles/s]
238 
239  // Almanac
240  // double d_Toa{}; // Almanac reference time [s]
241  // int32_t i_WN_A{}; // Modulo 256 of the GPS week number to which the almanac reference time (d_Toa) is referenced
242  std::map<int32_t, int32_t> almanacHealth; // Map that stores the health information stored in the almanac
243 
244  std::map<int32_t, std::string> satelliteBlock; // Map that stores to which block the PRN belongs
245 
246  // clock terms
247  double d_satClkCorr{}; // GPS clock error
248  double d_dtr{}; // relativistic clock correction term
249 
250  // satellite positions
251  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.
252  double d_satpos_Y{}; // Earth-fixed coordinate y of the satellite [m]. Completes a right-handed, Earth-Centered, Earth-Fixed orthogonal coordinate system.
253  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).
254 
255  // satellite identification info
256  int32_t i_signal_type{}; // BDS: data source (0:unknown,1:B1I,2:B1Q,3:B2I,4:B2Q,5:B3I,6:B3Q)
257  uint32_t i_satellite_PRN{};
258 
259  // Ionospheric parameters
260  double d_alpha0{}; // Coefficient 0 of a cubic equation representing the amplitude of the vertical delay [s]
261  double d_alpha1{}; // Coefficient 1 of a cubic equation representing the amplitude of the vertical delay [s/semi-circle]
262  double d_alpha2{}; // Coefficient 2 of a cubic equation representing the amplitude of the vertical delay [s(semi-circle)^2]
263  double d_alpha3{}; // Coefficient 3 of a cubic equation representing the amplitude of the vertical delay [s(semi-circle)^3]
264  double d_beta0{}; // Coefficient 0 of a cubic equation representing the period of the model [s]
265  double d_beta1{}; // Coefficient 1 of a cubic equation representing the period of the model [s/semi-circle]
266  double d_beta2{}; // Coefficient 2 of a cubic equation representing the period of the model [s(semi-circle)^2]
267  double d_beta3{}; // Coefficient 3 of a cubic equation representing the period of the model [s(semi-circle)^3]
268 
269  // UTC parameters
270  double d_A1UTC{}; // 1st order term of a model that relates GPS and UTC time [s/s]
271  double d_A0UTC{}; // Constant of a model that relates GPS and UTC time [s]
272  int32_t i_DeltaT_LS{}; // delta time due to leap seconds [s]. Number of leap seconds since 6-Jan-1980 as transmitted by the GPS almanac.
273  int32_t i_WN_LSF{}; // Week number at the end of which the leap second becomes effective [weeks]
274  int32_t i_DN{}; // Day number (DN) at the end of which the leap second becomes effective [days]
275  double d_DeltaT_LSF{}; // Scheduled future or recent past (relative to NAV message upload) value of the delta time due to leap seconds [s]
276  double d_A1GPS{};
277  double d_A0GPS{};
278  double d_A1GAL{};
279  double d_A0GAL{};
280  double d_A1GLO{};
281  double d_A0GLO{};
282 
283  double d_SQRT_A_ALMANAC{};
284  double d_A1_ALMANAC{};
285  double d_A0_ALMANAC{};
286  double d_OMEGA0_ALMANAC{};
287  double d_E_ALMANAC{};
288  double d_DELTA_I{};
289  double d_TOA{};
290  double d_OMEGA_DOT_ALMANAC{};
291  double d_OMEGA_ALMANAC{};
292  double d_M0_ALMANAC{};
293  int32_t almanac_WN{};
294  double d_toa2{};
295 
296  // Satellite velocity
297  double d_satvel_X{}; // Earth-fixed velocity coordinate x of the satellite [m]
298  double d_satvel_Y{}; // Earth-fixed velocity coordinate y of the satellite [m]
299  double d_satvel_Z{}; // Earth-fixed velocity coordinate z of the satellite [m]
300 
301  // System flags for data processing
302  bool flag_eph_valid{};
303  bool flag_utc_model_valid{};
304  bool flag_iono_valid{};
305  bool flag_d1_sf1{};
306  bool flag_d1_sf2{};
307  bool flag_d1_sf3{};
308  bool flag_d1_sf4{};
309  bool flag_d1_sf5{};
310  bool flag_new_SOW_available{};
311  bool flag_crc_test{};
312  double d_previous_aode{};
313 
314  // bool flag_d1_sf5_p7{}; // D1 NAV Message, Subframe 5, Page 09 decoded indicator
315  // bool flag_d1_sf5_p8{}; // D1 NAV Message, Subframe 5, Page 09 decoded indicator
316  bool flag_d1_sf5_p9{}; // D1 NAV Message, Subframe 5, Page 09 decoded indicator
317  bool flag_d1_sf5_p10{}; // D1 NAV Message, Subframe 5, Page 10 decoded indicator
318 
319  bool flag_sf1_p1{}; // D2 NAV Message, Subframe 1, Page 1 decoded indicator
320  bool flag_sf1_p2{}; // D2 NAV Message, Subframe 1, Page 2 decoded indicator
321  bool flag_sf1_p3{}; // D2 NAV Message, Subframe 1, Page 3 decoded indicator
322  bool flag_sf1_p4{}; // D2 NAV Message, Subframe 1, Page 4 decoded indicator
323  bool flag_sf1_p5{}; // D2 NAV Message, Subframe 1, Page 5 decoded indicator
324  bool flag_sf1_p6{}; // D2 NAV Message, Subframe 1, Page 6 decoded indicator
325  bool flag_sf1_p7{}; // D2 NAV Message, Subframe 1, Page 7 decoded indicator
326  bool flag_sf1_p8{}; // D2 NAV Message, Subframe 1, Page 8 decoded indicator
327  bool flag_sf1_p9{}; // D2 NAV Message, Subframe 1, Page 9 decoded indicator
328  bool flag_sf1_p10{}; // D2 NAV Message, Subframe 1, Page 10 decoded indicator
329 };
330 
331 
332 /** \} */
333 /** \} */
334 #endif // GNSS_SDR_BEIDOU_DNAV_NAVIGATION_MESSAGE_H
Beidou_Dnav_Iono get_iono()
Obtain a BDS ionospheric correction parameters class filled with current SV data. ...
This class is a storage for the BeiDou DNAV UTC Model.
bool have_new_almanac()
Returns true if new UTC model has arrived. The flag is set to false when the function is executed...
Defines system parameters for BeiDou B1I signal and DNAV data.
Defines system parameters for BeiDou DNAV data processing.
double utc_time(const double beidoutime_corrected) const
Computes the Coordinated Universal Time (UTC) and returns it in [s].
Interface of a BeiDou UTC MODEL storage.
Interface of a Beidou DNAV Almanac storage.
Beidou_Dnav_Utc_Model get_utc_model()
Obtain a BDS UTC model parameters class filled with current SV data.
This class is a storage for the BEIDOU IONOSPHERIC data as described in ICD v2.1. ...
bool have_new_ephemeris()
Returns true if new Ephemeris has arrived. The flag is set to false when the function is executed...
int32_t d1_subframe_decoder(std::string const &subframe)
Decodes the BDS D1 NAV message.
Beidou_Dnav_Ephemeris get_ephemeris() const
Obtain a BDS SV Ephemeris class filled with current SV data.
Interface of a BEIDOU EPHEMERIS storage.
bool have_new_utc_model()
Returns true if new UTC model has arrived. The flag is set to false when the function is executed...
This class is a storage and orbital model functions for the GPS SV ephemeris data as described in Bei...
bool have_new_iono() const
Returns true if new Iono model has arrived. The flag is set to false when the function is executed...
int32_t d2_subframe_decoder(std::string const &subframe)
Decodes the BDS D2 NAV message.
void satellitePosition(double transmitTime)
Computes the position of the satellite.
void set_satellite_PRN(uint32_t prn)
Sets satellite PRN number.
This class decodes a BeiDou D1 NAV Data message.
Interface of a BEIDOU IONOSPHERIC MODEL storage.
double sv_clock_correction(double transmitTime)
Sets (d_satClkCorr) according to the User Algorithm for SV Clock Correction and returns the corrected...
Defines system parameters for BeiDou B3I signal and DNAV data.