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