GNSS-SDR  0.0.19
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 Coordinated Universal Time (UTC) and
81  * returns it in [s]
82  */
83  double utc_time(double beidoutime_corrected) const;
84 
85  bool satellite_validation();
86 
87  /*!
88  * \brief Returns true if new Ephemeris has arrived. The flag is set to false when the function is executed
89  */
90  bool have_new_ephemeris();
91 
92  /*!
93  * \brief Returns true if new Iono model has arrived. The flag is set to false when the function is executed
94  */
95  bool have_new_iono() const;
96 
97  /*!
98  * \brief Returns true if new UTC model has arrived. The flag is set to false when the function is executed
99  */
100  bool have_new_utc_model();
101 
102  /*!
103  * \brief Returns true if new UTC model has arrived. The flag is set to false when the function is executed
104  */
105  bool have_new_almanac();
106 
107  /*!
108  * \brief Sets satellite PRN number
109  */
110  inline void set_satellite_PRN(uint32_t prn)
111  {
112  i_satellite_PRN = prn;
113  }
114 
115  inline void set_signal_type(int32_t signal_type)
116  {
117  i_signal_type = signal_type;
118  }
119 
120  inline bool get_flag_CRC_test() const
121  {
122  return flag_crc_test;
123  }
124 
125  inline bool get_flag_new_SOW_available() const
126  {
127  return flag_new_SOW_available;
128  }
129 
130  inline void set_flag_new_SOW_available(bool new_SOW_available)
131  {
132  flag_new_SOW_available = new_SOW_available;
133  }
134 
135  inline double get_SOW() const
136  {
137  return d_SOW;
138  }
139 
140 private:
141  uint64_t read_navigation_unsigned(const std::bitset<BEIDOU_DNAV_SUBFRAME_DATA_BITS>& bits, const std::vector<std::pair<int32_t, int32_t>>& parameter) const;
142  int64_t read_navigation_signed(const std::bitset<BEIDOU_DNAV_SUBFRAME_DATA_BITS>& bits, const std::vector<std::pair<int32_t, int32_t>>& parameter) const;
143  bool read_navigation_bool(const std::bitset<BEIDOU_DNAV_SUBFRAME_DATA_BITS>& bits, const std::vector<std::pair<int32_t, int32_t>>& parameter) const;
144  void print_beidou_word_bytes(uint32_t BEIDOU_word) const;
145 
146  // broadcast orbit 1
147  double d_SOW{}; // Time of BeiDou Week of the ephemeris set (taken from subframes SOW) [s]
148  double d_SOW_SF1{}; // Time of BeiDou Week from HOW word of Subframe 1 [s]
149  double d_SOW_SF2{}; // Time of BeiDou Week from HOW word of Subframe 2 [s]
150  double d_SOW_SF3{}; // Time of BeiDou Week from HOW word of Subframe 3 [s]
151  double d_SOW_SF4{}; // Time of BeiDou Week from HOW word of Subframe 4 [s]
152  double d_SOW_SF5{}; // Time of BeiDou Week from HOW word of Subframe 5 [s]
153 
154  double d_AODE{};
155  double d_Crs{}; // Amplitude of the Sine Harmonic Correction Term to the Orbit Radius [m]
156  double d_Delta_n{}; // Mean Motion Difference From Computed Value [semi-circles/s]
157  double d_M_0{}; // Mean Anomaly at Reference Time [semi-circles]
158 
159  // broadcast orbit 2
160  double d_Cuc{}; // Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad]
161  double d_eccentricity{}; // Eccentricity [dimensionless]
162  double d_Cus{}; // Amplitude of the Sine Harmonic Correction Term to the Argument of Latitude [rad]
163  double d_sqrt_A{}; // Square Root of the Semi-Major Axis [sqrt(m)]
164 
165  // broadcast orbit 3
166  double d_Toe_sf2{}; // Ephemeris data reference time of week in subframe 2, D1 Message
167  double d_Toe_sf3{}; // Ephemeris data reference time of week in subframe 3, D1 Message
168  double d_Toe{}; // Ephemeris data reference time of week in subframe 1, D2 Message
169  double d_Toc{}; // clock data reference time [s]
170  double d_Cic{}; // Amplitude of the Cosine Harmonic Correction Term to the Angle of Inclination [rad]
171  double d_OMEGA0{}; // Longitude of Ascending Node of Orbit Plane at Weekly Epoch [semi-circles]
172  double d_Cis{}; // Amplitude of the Sine Harmonic Correction Term to the Angle of Inclination [rad]
173 
174  // broadcast orbit 4
175  double d_i_0{}; // Inclination Angle at Reference Time [semi-circles]
176  double d_Crc{}; // Amplitude of the Cosine Harmonic Correction Term to the Orbit Radius [m]
177  double d_OMEGA{}; // Argument of Perigee [semi-cicles]
178  double d_OMEGA_DOT{}; // Rate of Right Ascension [semi-circles/s]
179 
180  // broadcast orbit 5
181  double d_IDOT{}; // Rate of Inclination Angle [semi-circles/s]
182  int32_t i_BEIDOU_week{}; // BeiDou week number, aka WN [week]
183 
184  // broadcast orbit 6
185  int32_t i_SV_accuracy{}; // User Range Accuracy (URA) index of the SV
186  int32_t i_SV_health{};
187  double d_TGD1{}; // Estimated Group Delay Differential in B1 [s]
188  double d_TGD2{}; // Estimated Group Delay Differential in B2 [s]
189  double d_AODC{}; // Age of Data, Clock
190 
191  // broadcast orbit 7
192  // 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]
193 
194  // 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.
195  // double d_spare1{};
196  // double d_spare2{};
197 
198  double d_A_f0{}; // Clock correction parameters. Coefficient 0 of code phase offset model [s]
199  double d_A_f1{}; // Clock correction parameters. Coefficient 1 of code phase offset model [s/s]
200  double d_A_f2{}; // Clock correction parameters. Coefficient 2 of code phase offset model [s/s^2]
201 
202  // D2 NAV Message Decoding
203  uint64_t d_A_f1_msb_bits{}; // Clock correction parameters, D2 NAV MSB
204  uint64_t d_A_f1_lsb_bits{}; // Clock correction parameters, D2 NAV LSB
205  uint64_t d_Cuc_msb_bits{}; // Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad]
206  uint64_t d_Cuc_lsb_bits{}; // Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad]
207  uint64_t d_eccentricity_msb{}; // Eccentricity [dimensionless]
208  uint64_t d_eccentricity_lsb{}; // Eccentricity [dimensionless]
209  uint64_t d_Cic_msb_bits{}; // Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad]
210  uint64_t d_Cic_lsb_bits{}; // Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad]
211  uint64_t d_eccentricity_msb_bits{}; // Eccentricity [dimensionless]
212  uint64_t d_eccentricity_lsb_bits{};
213  uint64_t d_i_0_msb_bits{}; // Inclination Angle at Reference Time [semi-circles]
214  uint64_t d_i_0_lsb_bits{}; // Inclination Angle at Reference Time [semi-circles]
215  uint64_t d_OMEGA_msb_bits{}; // Argument of Perigee [semi-cicles]
216  uint64_t d_OMEGA_lsb_bits{}; // Argument of Perigee [semi-cicles]
217  uint64_t d_OMEGA_DOT_msb_bits{}; // Rate of Right Ascension [semi-circles/s]
218  uint64_t d_OMEGA_DOT_lsb_bits{}; // Rate of Right Ascension [semi-circles/s]
219 
220  // Almanac
221  // double d_Toa{}; // Almanac reference time [s]
222  // int32_t i_WN_A{}; // Modulo 256 of the GPS week number to which the almanac reference time (d_Toa) is referenced
223  std::map<int32_t, int32_t> almanacHealth; // Map that stores the health information stored in the almanac
224 
225  std::map<int32_t, std::string> satelliteBlock; // Map that stores to which block the PRN belongs
226 
227  // satellite identification info
228  int32_t i_signal_type{}; // BDS: data source (0:unknown,1:B1I,2:B1Q,3:B2I,4:B2Q,5:B3I,6:B3Q)
229  uint32_t i_satellite_PRN{};
230 
231  // Ionospheric parameters
232  double d_alpha0{}; // Coefficient 0 of a cubic equation representing the amplitude of the vertical delay [s]
233  double d_alpha1{}; // Coefficient 1 of a cubic equation representing the amplitude of the vertical delay [s/semi-circle]
234  double d_alpha2{}; // Coefficient 2 of a cubic equation representing the amplitude of the vertical delay [s(semi-circle)^2]
235  double d_alpha3{}; // Coefficient 3 of a cubic equation representing the amplitude of the vertical delay [s(semi-circle)^3]
236  double d_beta0{}; // Coefficient 0 of a cubic equation representing the period of the model [s]
237  double d_beta1{}; // Coefficient 1 of a cubic equation representing the period of the model [s/semi-circle]
238  double d_beta2{}; // Coefficient 2 of a cubic equation representing the period of the model [s(semi-circle)^2]
239  double d_beta3{}; // Coefficient 3 of a cubic equation representing the period of the model [s(semi-circle)^3]
240 
241  // UTC parameters
242  double d_A1UTC{}; // 1st order term of a model that relates GPS and UTC time [s/s]
243  double d_A0UTC{}; // Constant of a model that relates GPS and UTC time [s]
244  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.
245  int32_t i_WN_LSF{}; // Week number at the end of which the leap second becomes effective [weeks]
246  int32_t i_DN{}; // Day number (DN) at the end of which the leap second becomes effective [days]
247  double d_DeltaT_LSF{}; // Scheduled future or recent past (relative to NAV message upload) value of the delta time due to leap seconds [s]
248  double d_A1GPS{};
249  double d_A0GPS{};
250  double d_A1GAL{};
251  double d_A0GAL{};
252  double d_A1GLO{};
253  double d_A0GLO{};
254 
255  double d_SQRT_A_ALMANAC{};
256  double d_A1_ALMANAC{};
257  double d_A0_ALMANAC{};
258  double d_OMEGA0_ALMANAC{};
259  double d_E_ALMANAC{};
260  double d_DELTA_I{};
261  double d_TOA{};
262  double d_OMEGA_DOT_ALMANAC{};
263  double d_OMEGA_ALMANAC{};
264  double d_M0_ALMANAC{};
265  int32_t almanac_WN{};
266  double d_toa2{};
267 
268  // System flags for data processing
269  bool flag_eph_valid{};
270  bool flag_utc_model_valid{};
271  bool flag_iono_valid{};
272  bool flag_d1_sf1{};
273  bool flag_d1_sf2{};
274  bool flag_d1_sf3{};
275  bool flag_d1_sf4{};
276  bool flag_d1_sf5{};
277  bool flag_new_SOW_available{};
278  bool flag_crc_test{};
279  double d_previous_aode{};
280 
281  // bool flag_d1_sf5_p7{}; // D1 NAV Message, Subframe 5, Page 09 decoded indicator
282  // bool flag_d1_sf5_p8{}; // D1 NAV Message, Subframe 5, Page 09 decoded indicator
283  bool flag_d1_sf5_p9{}; // D1 NAV Message, Subframe 5, Page 09 decoded indicator
284  bool flag_d1_sf5_p10{}; // D1 NAV Message, Subframe 5, Page 10 decoded indicator
285 
286  bool flag_sf1_p1{}; // D2 NAV Message, Subframe 1, Page 1 decoded indicator
287  bool flag_sf1_p2{}; // D2 NAV Message, Subframe 1, Page 2 decoded indicator
288  bool flag_sf1_p3{}; // D2 NAV Message, Subframe 1, Page 3 decoded indicator
289  bool flag_sf1_p4{}; // D2 NAV Message, Subframe 1, Page 4 decoded indicator
290  bool flag_sf1_p5{}; // D2 NAV Message, Subframe 1, Page 5 decoded indicator
291  bool flag_sf1_p6{}; // D2 NAV Message, Subframe 1, Page 6 decoded indicator
292  bool flag_sf1_p7{}; // D2 NAV Message, Subframe 1, Page 7 decoded indicator
293  bool flag_sf1_p8{}; // D2 NAV Message, Subframe 1, Page 8 decoded indicator
294  bool flag_sf1_p9{}; // D2 NAV Message, Subframe 1, Page 9 decoded indicator
295  bool flag_sf1_p10{}; // D2 NAV Message, Subframe 1, Page 10 decoded indicator
296 };
297 
298 
299 /** \} */
300 /** \} */
301 #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.
double utc_time(double beidoutime_corrected) const
Computes the Coordinated Universal Time (UTC) and returns it in [s].
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.
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 is a storage class for the Beidou SV ephemeris data as described in BeiDou Navigation Satellite ...
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 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.
Defines system parameters for BeiDou B3I signal and DNAV data.