GNSS-SDR  0.0.19
An Open Source GNSS Software Defined Receiver
galileo_inav_message.h
Go to the documentation of this file.
1 /*!
2  * \file galileo_inav_message.h
3  * \brief Implementation of a Galileo I/NAV Data message
4  * as described in Galileo OS SIS ICD Issue 2.0 (Jan. 2021)
5  * \author Mara Branzanti 2013. mara.branzanti(at)gmail.com
6  * \author Javier Arribas, 2013. jarribas(at)cttc.es
7  *
8  * -----------------------------------------------------------------------------
9  *
10  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
11  * This file is part of GNSS-SDR.
12  *
13  * Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors)
14  * SPDX-License-Identifier: GPL-3.0-or-later
15  *
16  * -----------------------------------------------------------------------------
17  */
18 
19 #ifndef GNSS_SDR_GALILEO_INAV_MESSAGE_H
20 #define GNSS_SDR_GALILEO_INAV_MESSAGE_H
21 
22 #include "Galileo_INAV.h"
23 #include "galileo_almanac_helper.h"
24 #include "galileo_ephemeris.h"
25 #include "galileo_iono.h"
26 #include "galileo_utc_model.h"
27 #include "gnss_sdr_make_unique.h" // for std::unique_ptr in C++11
28 #include <bitset>
29 #include <cstdint>
30 #include <memory>
31 #include <string>
32 #include <utility>
33 #include <vector>
34 
35 class ReedSolomon; // Forward declaration of the ReedSolomon class
36 
37 /** \addtogroup Core
38  * \{ */
39 /** \addtogroup System_Parameters
40  * \{ */
41 
42 
43 /*!
44  * \brief This class handles the Galileo I/NAV Data message, as described in the
45  * Galileo Open Service Signal in Space Interface Control Document (OS SIS ICD), Issue 2.0 (Jan. 2021).
46  * See https://www.gsc-europa.eu/sites/default/files/sites/all/files/Galileo_OS_SIS_ICD_v2.0.pdf
47  */
49 {
50 public:
52 
54 
55  /*
56  * \brief Takes in input a page (Odd or Even) of 120 bit, split it according ICD 4.3.2.3 and join Data_k with Data_j
57  */
58  void split_page(std::string page_string, int32_t flag_even_word);
59 
60  /*
61  * \brief Takes in input Data_jk (128 bit) and split it in ephemeris parameters according ICD 4.3.5
62  *
63  * Takes in input Data_jk (128 bit) and split it in ephemeris parameters according ICD 4.3.5
64  */
65  int32_t page_jk_decoder(const char* data_jk);
66 
67  /*
68  * \brief Returns true if new Ephemeris has arrived. The flag is set to false when the function is executed
69  */
70  bool have_new_ephemeris();
71 
72  /*
73  * \brief Returns true if new Iono model has arrived. The flag is set to false when the function is executed
74  */
75  bool have_new_iono_and_GST();
76 
77  /*
78  * \brief Returns true if new UTC model has arrived. The flag is set to false when the function is executed
79  */
80  bool have_new_utc_model();
81 
82  /*
83  * \brief Returns true if new UTC model has arrived. The flag is set to false when the function is executed
84  */
85  bool have_new_almanac();
86 
87  /*
88  * \brief Returns true if new Reduced CED parameters have arrived. The flag is set to false when the function is executed
89  */
90  bool have_new_reduced_ced();
91 
92  /*
93  * \brief Returns a Galileo_Ephemeris object filled with the latest navigation data received
94  */
95  Galileo_Ephemeris get_ephemeris() const;
96 
97  /*
98  * \brief Returns a Galileo_Iono object filled with the latest navigation data received
99  */
100  Galileo_Iono get_iono() const;
101 
102  /*
103  * \brief Returns a Galileo_Utc_Model object filled with the latest navigation data received
104  */
105  Galileo_Utc_Model get_utc_model() const;
106 
107  /*
108  * \brief Returns a Galileo_Almanac_Helper object filled with the latest navigation data received
109  */
110  Galileo_Almanac_Helper get_almanac() const;
111 
112  /*
113  * \brief Returns a Galileo_Ephemeris object filled with the latest reduced CED received
114  */
115  Galileo_Ephemeris get_reduced_ced() const;
116 
117  inline bool get_flag_CRC_test() const
118  {
119  return flag_CRC_test;
120  }
121 
122  inline bool get_flag_TOW_set() const
123  {
124  return flag_TOW_set;
125  }
126 
127  inline void set_flag_TOW_set(bool flag_tow)
128  {
129  flag_TOW_set = flag_tow;
130  }
131 
132  inline int32_t get_Galileo_week() const
133  {
134  return WN_0;
135  }
136 
137  inline int32_t get_TOW5() const
138  {
139  return TOW_5;
140  }
141 
142  inline int32_t get_TOW6() const
143  {
144  return TOW_6;
145  }
146 
147  inline bool is_TOW5_set() const
148  {
149  return flag_TOW_5;
150  }
151 
152  inline void set_TOW5_flag(bool flag_tow5)
153  {
154  flag_TOW_5 = flag_tow5;
155  }
156 
157  inline bool is_TOW6_set() const
158  {
159  return flag_TOW_6;
160  }
161 
162  inline void set_TOW6_flag(bool flag_tow6)
163  {
164  flag_TOW_6 = flag_tow6;
165  }
166 
167  inline int32_t get_TOW0() const
168  {
169  return TOW_0;
170  }
171 
172  inline bool is_TOW0_set() const
173  {
174  return flag_TOW_0;
175  }
176 
177  inline void set_TOW0_flag(bool flag_tow0)
178  {
179  flag_TOW_0 = flag_tow0;
180  }
181 
182  inline bool get_flag_GGTO() const
183  {
184  return (flag_GGTO_1 == true and flag_GGTO_2 == true and flag_GGTO_3 == true and flag_GGTO_4 == true);
185  }
186 
187  inline double get_A0G() const
188  {
189  return A_0G_10;
190  }
191 
192  inline double get_A1G() const
193  {
194  return A_1G_10;
195  }
196 
197  inline double get_t0G() const
198  {
199  return t_0G_10;
200  }
201 
202  inline double get_WN0G() const
203  {
204  return WN_0G_10;
205  }
206 
207  /*
208  * \brief Initialize PRN field so we do not need to wait for page 4.
209  */
210  inline void init_PRN(uint32_t prn)
211  {
212  SV_ID_PRN_4 = prn;
213  }
214 
215  /*
216  * \brief Enable Reed-Solomon in Galileo E1B
217  */
218  inline void enable_reed_solomon()
219  {
220  enable_rs = true;
221  }
222 
223 private:
224  bool CRC_test(const std::bitset<GALILEO_DATA_FRAME_BITS>& bits, uint32_t checksum) const;
225  bool read_navigation_bool(const std::bitset<GALILEO_DATA_JK_BITS>& bits, const std::vector<std::pair<int32_t, int32_t>>& parameter) const;
226  uint64_t read_navigation_unsigned(const std::bitset<GALILEO_DATA_JK_BITS>& bits, const std::vector<std::pair<int32_t, int32_t>>& parameter) const;
227  uint64_t read_page_type_unsigned(const std::bitset<GALILEO_PAGE_TYPE_BITS>& bits, const std::vector<std::pair<int32_t, int32_t>>& parameter) const;
228  int64_t read_navigation_signed(const std::bitset<GALILEO_DATA_JK_BITS>& bits, const std::vector<std::pair<int32_t, int32_t>>& parameter) const;
229  uint8_t read_octet_unsigned(const std::bitset<GALILEO_DATA_JK_BITS>& bits, const std::vector<std::pair<int32_t, int32_t>>& parameter) const;
230  void read_page_1(const std::bitset<GALILEO_DATA_JK_BITS>& data_bits);
231  void read_page_2(const std::bitset<GALILEO_DATA_JK_BITS>& data_bits);
232  void read_page_3(const std::bitset<GALILEO_DATA_JK_BITS>& data_bits);
233  void read_page_4(const std::bitset<GALILEO_DATA_JK_BITS>& data_bits);
234  std::bitset<GALILEO_DATA_JK_BITS> regenerate_page_1(const std::vector<uint8_t>& decoded) const;
235  std::bitset<GALILEO_DATA_JK_BITS> regenerate_page_2(const std::vector<uint8_t>& decoded) const;
236  std::bitset<GALILEO_DATA_JK_BITS> regenerate_page_3(const std::vector<uint8_t>& decoded) const;
237  std::bitset<GALILEO_DATA_JK_BITS> regenerate_page_4(const std::vector<uint8_t>& decoded) const;
238 
239  std::string page_Even{};
240 
241  std::vector<uint8_t> rs_buffer; // Reed-Solomon buffer
242  std::unique_ptr<ReedSolomon> rs; // The Reed-Solomon decoder
243  std::vector<int> inav_rs_pages; // Pages 1,2,3,4,17,18,19,20. Holds 1 if the page has arrived, 0 otherwise.
244 
245  int32_t Page_type_time_stamp{};
246  int32_t IOD_ephemeris{};
247 
248  // Word type 1: Ephemeris (1/4)
249  int32_t IOD_nav_1{}; // IOD_nav page 1
250  int32_t t0e_1{}; // Ephemeris reference time [s]
251  double M0_1{}; // Mean anomaly at reference time [rad]
252  double e_1{}; // Eccentricity
253  double A_1{}; // Square root of the semi-major axis [meters^1/2]
254 
255  // Word type 2: Ephemeris (2/4)
256  int32_t IOD_nav_2{}; // IOD_nav page 2
257  double OMEGA_0_2{}; // Longitude of ascending node of orbital plane at weekly epoch [rad]
258  double i_0_2{}; // Inclination angle at reference time [rad]
259  double omega_2{}; // Argument of perigee [rad]
260  double iDot_2{}; // Rate of inclination angle [rad/sec]
261 
262  // Word type 3: Ephemeris (3/4) and SISA
263  int32_t IOD_nav_3{};
264  int32_t SISA_3{};
265  double OMEGA_dot_3{}; // Rate of right ascension [rad/sec]
266  double delta_n_3{}; // Mean motion difference from computed value [rad/sec]
267  double C_uc_3{}; // Amplitude of the cosine harmonic correction term to the argument of latitude [radians]
268  double C_us_3{}; // Amplitude of the sine harmonic correction term to the argument of latitude [radians]
269  double C_rc_3{}; // Amplitude of the cosine harmonic correction term to the orbit radius [meters]
270  double C_rs_3{}; // Amplitude of the sine harmonic correction term to the orbit radius [meters]
271 
272  // Word type 4: Ephemeris (4/4) and Clock correction parameters*/
273  int32_t IOD_nav_4{}; //
274  int32_t SV_ID_PRN_4{}; //
275  double C_ic_4{}; // Amplitude of the cosine harmonic correction term to the angle of inclination [radians]
276  double C_is_4{}; // Amplitude of the sine harmonic correction term to the angle of inclination [radians]
277 
278  // Clock correction parameters
279  int32_t t0c_4{}; // Clock correction data reference Time of Week [sec]
280  double af0_4{}; // SV clock bias correction coefficient [s]
281  double af1_4{}; // SV clock drift correction coefficient [s/s]
282  double af2_4{}; // clock drift rate correction coefficient [s/s^2]
283  double spare_4{};
284 
285  // Word type 5: Ionospheric correction, BGD, signal health and data validity status and GST*/
286  // Ionospheric correction
287  double ai0_5{}; // Effective Ionisation Level 1st order parameter [sfu]
288  double ai1_5{}; // Effective Ionisation Level 2st order parameter [sfu/degree]
289  double ai2_5{}; // Effective Ionisation Level 3st order parameter [sfu/degree]
290  double BGD_E1E5a_5{}; // E1-E5a Broadcast Group Delay [s]
291  double BGD_E1E5b_5{}; // E1-E5b Broadcast Group Delay [s]
292  int32_t E5b_HS_5{}; // E5b Signal Health Status
293  int32_t E1B_HS_5{}; // E1B Signal Health Status
294 
295  // Ionospheric disturbance flag
296  bool Region1_flag_5{}; // Ionospheric Disturbance Flag for region 1
297  bool Region2_flag_5{}; // Ionospheric Disturbance Flag for region 2
298  bool Region3_flag_5{}; // Ionospheric Disturbance Flag for region 3
299  bool Region4_flag_5{}; // Ionospheric Disturbance Flag for region 4
300  bool Region5_flag_5{}; // Ionospheric Disturbance Flag for region 5
301  bool E5b_DVS_5{}; // E5b Data Validity Status
302  bool E1B_DVS_5{}; // E1B Data Validity Status
303 
304  // GST
305  int32_t WN_5{};
306  int32_t TOW_5{};
307  double spare_5{};
308 
309  // Word type 6: GST-UTC conversion parameters
310  double A0_6{};
311  double A1_6{};
312  int32_t Delta_tLS_6{};
313  int32_t t0t_6{};
314  int32_t WNot_6{};
315  int32_t WN_LSF_6{};
316  int32_t DN_6{};
317  int32_t Delta_tLSF_6{};
318  int32_t TOW_6{};
319 
320  // Word type 7: Almanac for SVID1 (1/2), almanac reference time and almanac reference week number
321  int32_t IOD_a_7{};
322  int32_t WN_a_7{};
323  int32_t t0a_7{};
324  int32_t SVID1_7{};
325  double DELTA_A_7{};
326  double e_7{};
327  double omega_7{};
328  double delta_i_7{};
329  double Omega0_7{};
330  double Omega_dot_7{};
331  double M0_7{};
332 
333  // Word type 8: Almanac for SVID1 (2/2) and SVID2 (1/2)
334  int32_t IOD_a_8{};
335  int32_t E5b_HS_8{};
336  int32_t E1B_HS_8{};
337  int32_t SVID2_8{};
338  double af0_8{};
339  double af1_8{};
340  double DELTA_A_8{};
341  double e_8{};
342  double omega_8{};
343  double delta_i_8{};
344  double Omega0_8{};
345  double Omega_dot_8{};
346 
347  // Word type 9: Almanac for SVID2 (2/2) and SVID3 (1/2)
348  int32_t IOD_a_9{};
349  int32_t WN_a_9{};
350  int32_t t0a_9{};
351  double M0_9{};
352  double af0_9{};
353  double af1_9{};
354  int32_t E5b_HS_9{};
355  int32_t E1B_HS_9{};
356  int32_t SVID3_9{};
357  double DELTA_A_9{};
358  double e_9{};
359  double omega_9{};
360  double delta_i_9{};
361 
362  // Word type 10: Almanac for SVID3 (2/2) and GST-GPS conversion parameters
363  int32_t IOD_a_10{};
364  double Omega0_10{};
365  double Omega_dot_10{};
366  double M0_10{};
367  double af0_10{};
368  double af1_10{};
369  int32_t E5b_HS_10{};
370  int32_t E1B_HS_10{};
371 
372  // GST-GPS conversion
373  double A_0G_10{}; // Constant term of the offset Delta t systems
374  double A_1G_10{}; // Rate of change of the offset Delta t systems
375  int32_t t_0G_10{}; // Reference time for Galileo/GPS Time Offset (GGTO) data
376  int32_t WN_0G_10{}; // Week Number of Galileo/GPS Time Offset (GGTO) reference
377 
378  // Word type 0: I/NAV Spare Word
379  int32_t Time_0{};
380  int32_t WN_0{};
381  int32_t TOW_0{};
382 
383  // Word type 16: Reduced Clock and Ephemeris Data (CED) parameters
384  double ced_DeltaAred{};
385  double ced_exred{};
386  double ced_eyred{};
387  double ced_Deltai0red{};
388  double ced_Omega0red{};
389  double ced_lambda0red{};
390  double ced_af0red{};
391  double ced_af1red{};
392 
393  double Galileo_satClkDrift{};
394 
395  int32_t current_IODnav{};
396 
397  uint8_t IODnav_LSB17{};
398  uint8_t IODnav_LSB18{};
399  uint8_t IODnav_LSB19{};
400  uint8_t IODnav_LSB20{};
401 
402  bool flag_CRC_test{};
403  bool flag_all_ephemeris{}; // Flag indicating that all words containing ephemeris have been received
404  bool flag_ephemeris_1{}; // Flag indicating that ephemeris 1/4 (word 1) have been received
405  bool flag_ephemeris_2{}; // Flag indicating that ephemeris 2/4 (word 2) have been received
406  bool flag_ephemeris_3{}; // Flag indicating that ephemeris 3/4 (word 3) have been received
407  bool flag_ephemeris_4{}; // Flag indicating that ephemeris 4/4 (word 4) have been received
408 
409  bool flag_iono_and_GST{}; // Flag indicating that ionospheric and GST parameters (word 5) have been received
410  bool flag_TOW_5{};
411  bool flag_TOW_6{};
412  bool flag_TOW_0{};
413  bool flag_TOW_set{}; // it is true when page 5 or page 6 arrives
414  bool flag_utc_model{}; // Flag indicating that utc model parameters (word 6) have been received
415 
416  bool flag_all_almanac{}; // Flag indicating that all Almanac data have been received
417  bool flag_almanac_1{}; // Flag indicating that almanac 1/4 (word 7) have been received
418  bool flag_almanac_2{}; // Flag indicating that almanac 2/4 (word 8) have been received
419  bool flag_almanac_3{}; // Flag indicating that almanac 3/4 (word 9) have been received
420  bool flag_almanac_4{}; // Flag indicating that almanac 4/4 (word 10) have been received
421 
422  bool flag_GGTO_1{};
423  bool flag_GGTO_2{};
424  bool flag_GGTO_3{};
425  bool flag_GGTO_4{};
426 
427  bool flag_CED{};
428  bool enable_rs{};
429 };
430 
431 
432 /** \} */
433 /** \} */
434 #endif // GNSS_SDR_GALILEO_INAV_MESSAGE_H
Class implementing a Reed-Solomon encoder and decoder RS(255,K,d) where k=255-nroots is the informati...
Definition: reed_solomon.h:40
This file implements std::make_unique for C++11.
This class is a storage for the GALILEO ALMANAC data as described in GALILEO ICD. ...
This class handles the Galileo I/NAV Data message, as described in the Galileo Open Service Signal in...
This class is a storage for the GALILEO IONOSPHERIC data as described in Galileo ICD paragraph 5...
Definition: galileo_iono.h:37
Interface of a Galileo UTC MODEL storage.
Interface of a Galileo ALMANAC storage helper.
This class is a storage and orbital model functions for the Galileo SV ephemeris data as described in...
This class is a storage for the GALILEO UTC MODEL data as described in Galileo ICD https://www...
Interface of a Galileo Ionospheric Model storage.
Interface of a Galileo EPHEMERIS storage.
Galileo INAV mesage constants.