mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-31 07:13:03 +00:00 
			
		
		
		
	Improve ISM handling and add PRN applicability check
This commit is contained in:
		| @@ -44,7 +44,7 @@ Galileo_Inav_Message::Galileo_Inav_Message() | ||||
| } | ||||
|  | ||||
|  | ||||
| // here the compiler knows how to destrcut rs | ||||
| // here the compiler knows how to destroy rs | ||||
| Galileo_Inav_Message::~Galileo_Inav_Message() = default; | ||||
|  | ||||
|  | ||||
| @@ -388,6 +388,17 @@ bool Galileo_Inav_Message::have_new_reduced_ced() | ||||
| } | ||||
|  | ||||
|  | ||||
| bool Galileo_Inav_Message::have_new_ism() | ||||
| { | ||||
|     if (have_ISM) | ||||
|         { | ||||
|             have_ISM = false; | ||||
|             return true; | ||||
|         } | ||||
|     return false; | ||||
| } | ||||
|  | ||||
|  | ||||
| Galileo_Ephemeris Galileo_Inav_Message::get_ephemeris() const | ||||
| { | ||||
|     Galileo_Ephemeris ephemeris; | ||||
| @@ -1359,6 +1370,7 @@ int32_t Galileo_Inav_Message::page_jk_decoder(const char* data_jk) | ||||
|                                               << "Tvalidity=" << static_cast<uint32_t>(gal_ism.get_Tvalidity_hours()) << " [h]"; | ||||
|                                 } | ||||
|                         } | ||||
|                     have_ISM = true; | ||||
|                 } | ||||
|             break; | ||||
|  | ||||
|   | ||||
| @@ -90,6 +90,11 @@ public: | ||||
|      */ | ||||
|     bool have_new_reduced_ced(); | ||||
|  | ||||
|     /* | ||||
|      * \brief Returns true if new ISM data have arrived. The flag is set to false when the function is executed | ||||
|      */ | ||||
|     bool have_new_ism(); | ||||
|  | ||||
|     /* | ||||
|      * \brief Returns a Galileo_Ephemeris object filled with the latest navigation data received | ||||
|      */ | ||||
| @@ -115,6 +120,9 @@ public: | ||||
|      */ | ||||
|     Galileo_Ephemeris get_reduced_ced() const; | ||||
|  | ||||
|     /* | ||||
|      * \brief Returns a Galileo_ISM object filled with the latest ISM data received | ||||
|      */ | ||||
|     Galileo_ISM get_galileo_ism() const; | ||||
|  | ||||
|     inline bool get_flag_CRC_test() const | ||||
| @@ -403,7 +411,6 @@ private: | ||||
|     uint8_t IODnav_LSB19{}; | ||||
|     uint8_t IODnav_LSB20{}; | ||||
|  | ||||
|     uint32_t ism_crc{}; | ||||
|     uint8_t ism_constellation_id{}; | ||||
|     uint8_t ism_service_level_id{}; | ||||
|  | ||||
| @@ -434,6 +441,7 @@ private: | ||||
|  | ||||
|     bool flag_CED{}; | ||||
|     bool enable_rs{}; | ||||
|     bool have_ISM{}; | ||||
| }; | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -19,98 +19,92 @@ | ||||
|  | ||||
| void Galileo_ISM::set_ism_constellation_id(uint8_t const_id) | ||||
| { | ||||
|     this->ism_constellation_id = const_id; | ||||
|     this->d_ism_constellation_id = const_id; | ||||
| } | ||||
|  | ||||
|  | ||||
| void Galileo_ISM::set_ism_service_level_id(uint8_t sl_id) | ||||
| { | ||||
|     this->ism_service_level_id = sl_id; | ||||
|     this->d_ism_service_level_id = sl_id; | ||||
| } | ||||
|  | ||||
|  | ||||
| void Galileo_ISM::set_ism_wn(uint16_t wn_ism) | ||||
| { | ||||
|     this->ism_wn = wn_ism; | ||||
|     this->d_ism_wn = wn_ism; | ||||
| } | ||||
|  | ||||
|  | ||||
| void Galileo_ISM::set_ism_t0(uint16_t t0) | ||||
| { | ||||
|     this->ism_t0 = t0; | ||||
|     this->d_ism_t0 = t0; | ||||
| } | ||||
|  | ||||
|  | ||||
| void Galileo_ISM::set_ism_mask_msb(bool mask_msb) | ||||
| { | ||||
|     this->ism_mask_msb = mask_msb; | ||||
|     this->d_ism_mask_msb = mask_msb; | ||||
| } | ||||
|  | ||||
|  | ||||
| void Galileo_ISM::set_ism_mask(uint32_t mask) | ||||
| { | ||||
|     this->ism_mask = mask; | ||||
|     this->d_ism_mask = mask; | ||||
| } | ||||
|  | ||||
|  | ||||
| void Galileo_ISM::set_ism_pconst(uint8_t pconst) | ||||
| { | ||||
|     this->ism_pconst = pconst; | ||||
|     this->d_ism_pconst = pconst; | ||||
| } | ||||
|  | ||||
|  | ||||
| void Galileo_ISM::set_ism_psat(uint8_t psat) | ||||
| { | ||||
|     this->ism_psat = psat; | ||||
|     this->d_ism_psat = psat; | ||||
| } | ||||
|  | ||||
|  | ||||
| void Galileo_ISM::set_ism_ura(uint8_t ura) | ||||
| { | ||||
|     this->ism_ura = ura; | ||||
|     this->d_ism_ura = ura; | ||||
| } | ||||
|  | ||||
|  | ||||
| void Galileo_ISM::set_ism_ure(uint8_t ure) | ||||
| { | ||||
|     this->ism_ure = ure; | ||||
|     this->d_ism_ure = ure; | ||||
| } | ||||
|  | ||||
|  | ||||
| void Galileo_ISM::set_ism_bnom(uint8_t bnom) | ||||
| { | ||||
|     this->ism_bnom = bnom; | ||||
|     this->d_ism_bnom = bnom; | ||||
| } | ||||
|  | ||||
|  | ||||
| void Galileo_ISM::set_ism_Tvalidity(uint8_t tvalidity) | ||||
| { | ||||
|     this->ism_Tvalidity = tvalidity; | ||||
| } | ||||
|  | ||||
|  | ||||
| void Galileo_ISM::set_ism_crc(uint32_t crc) | ||||
| { | ||||
|     this->ism_crc = crc; | ||||
|     this->d_ism_Tvalidity = tvalidity; | ||||
| } | ||||
|  | ||||
|  | ||||
| uint16_t Galileo_ISM::get_WN_ISM() const | ||||
| { | ||||
|     return this->ism_wn; | ||||
|     return this->d_ism_wn; | ||||
| } | ||||
|  | ||||
|  | ||||
| uint16_t Galileo_ISM::get_t0_ISM() const | ||||
| { | ||||
|     return (this->ism_t0 * 1800); | ||||
|     return (this->d_ism_t0 * 1800); | ||||
| } | ||||
|  | ||||
|  | ||||
| double Galileo_ISM::get_pconst_value() const | ||||
| { | ||||
|     auto it = ISM_PCONST_MAP.find(this->ism_pconst); | ||||
|     if (it == ISM_PCONST_MAP.end()) | ||||
|     auto it = d_ISM_PCONST_MAP.find(this->d_ism_pconst); | ||||
|     if (it == d_ISM_PCONST_MAP.end()) | ||||
|         { | ||||
|             return 0.0; | ||||
|         } | ||||
| @@ -120,8 +114,8 @@ double Galileo_ISM::get_pconst_value() const | ||||
|  | ||||
| double Galileo_ISM::get_psat_value() const | ||||
| { | ||||
|     auto it = ISM_PSAT_MAP.find(this->ism_psat); | ||||
|     if (it == ISM_PSAT_MAP.end()) | ||||
|     auto it = d_ISM_PSAT_MAP.find(this->d_ism_psat); | ||||
|     if (it == d_ISM_PSAT_MAP.end()) | ||||
|         { | ||||
|             return 0.0; | ||||
|         } | ||||
| @@ -131,14 +125,14 @@ double Galileo_ISM::get_psat_value() const | ||||
|  | ||||
| bool Galileo_ISM::get_ism_mask_msb() const | ||||
| { | ||||
|     return ism_mask_msb; | ||||
|     return d_ism_mask_msb; | ||||
| } | ||||
|  | ||||
|  | ||||
| float Galileo_ISM::get_ura_m() const | ||||
| { | ||||
|     auto it = ISM_URA_MAP.find(this->ism_ura); | ||||
|     if (it == ISM_URA_MAP.end()) | ||||
|     auto it = d_ISM_URA_MAP.find(this->d_ism_ura); | ||||
|     if (it == d_ISM_URA_MAP.end()) | ||||
|         { | ||||
|             return 0.0; | ||||
|         } | ||||
| @@ -148,8 +142,8 @@ float Galileo_ISM::get_ura_m() const | ||||
|  | ||||
| float Galileo_ISM::get_ure_m() const | ||||
| { | ||||
|     auto it = ISM_URE_MAP.find(this->ism_ure); | ||||
|     if (it == ISM_URE_MAP.end()) | ||||
|     auto it = d_ISM_URE_MAP.find(this->d_ism_ure); | ||||
|     if (it == d_ISM_URE_MAP.end()) | ||||
|         { | ||||
|             return 0.0; | ||||
|         } | ||||
| @@ -159,14 +153,14 @@ float Galileo_ISM::get_ure_m() const | ||||
|  | ||||
| uint32_t Galileo_ISM::get_mask_ISM() const | ||||
| { | ||||
|     return ism_mask; | ||||
|     return d_ism_mask; | ||||
| } | ||||
|  | ||||
|  | ||||
| float Galileo_ISM::get_bnom_m() const | ||||
| { | ||||
|     auto it = ISM_BNOM_MAP.find(this->ism_bnom); | ||||
|     if (it == ISM_BNOM_MAP.end()) | ||||
|     auto it = d_ISM_BNOM_MAP.find(this->d_ism_bnom); | ||||
|     if (it == d_ISM_BNOM_MAP.end()) | ||||
|         { | ||||
|             return 5.0;  // | ||||
|         } | ||||
| @@ -176,8 +170,8 @@ float Galileo_ISM::get_bnom_m() const | ||||
|  | ||||
| uint16_t Galileo_ISM::get_Tvalidity_hours() const | ||||
| { | ||||
|     auto it = ISM_TVALIDITY_MAP.find(this->ism_Tvalidity); | ||||
|     if (it == ISM_TVALIDITY_MAP.end()) | ||||
|     auto it = d_ISM_TVALIDITY_MAP.find(this->d_ism_Tvalidity); | ||||
|     if (it == d_ISM_TVALIDITY_MAP.end()) | ||||
|         { | ||||
|             return 0.0; | ||||
|         } | ||||
| @@ -197,7 +191,7 @@ bool Galileo_ISM::check_ism_crc(const std::bitset<GALILEO_DATA_JK_BITS>& bits) | ||||
|         { | ||||
|             crc_bits[i] = bits[i]; | ||||
|         } | ||||
|     ism_crc = crc_bits.to_ulong(); | ||||
|     this->d_ism_crc = crc_bits.to_ulong(); | ||||
|  | ||||
|     std::vector<uint8_t> data_bytes((data_bits.size() + 7) / 8); | ||||
|     for (size_t i = 0; i < data_bits.size(); i += 8) | ||||
| @@ -213,7 +207,7 @@ bool Galileo_ISM::check_ism_crc(const std::bitset<GALILEO_DATA_JK_BITS>& bits) | ||||
|     std::reverse(data_bytes.begin(), data_bytes.end()); | ||||
|     const uint32_t crc_computed = this->compute_crc(data_bytes); | ||||
|  | ||||
|     if (this->ism_crc == crc_computed) | ||||
|     if (this->d_ism_crc == crc_computed) | ||||
|         { | ||||
|             return true; | ||||
|         } | ||||
| @@ -224,8 +218,36 @@ bool Galileo_ISM::check_ism_crc(const std::bitset<GALILEO_DATA_JK_BITS>& bits) | ||||
|  | ||||
| uint32_t Galileo_ISM::compute_crc(const std::vector<uint8_t>& data) | ||||
| { | ||||
|     crc32_ism.process_bytes(data.data(), data.size()); | ||||
|     const uint32_t crc = crc32_ism.checksum(); | ||||
|     crc32_ism.reset(); | ||||
|     d_crc32_ism.process_bytes(data.data(), data.size()); | ||||
|     const uint32_t crc = d_crc32_ism.checksum(); | ||||
|     d_crc32_ism.reset(); | ||||
|     return crc; | ||||
| } | ||||
|  | ||||
|  | ||||
| bool Galileo_ISM::ism_parameters_apply(uint32_t prn) const | ||||
| { | ||||
|     // ICD 2.1 Table 96 | ||||
|     if (prn == 0 || prn > 63 || d_ism_service_level_id != 2 || d_ism_constellation_id != 1) | ||||
|         { | ||||
|             return false; | ||||
|         } | ||||
|     std::bitset<32> b(d_ism_mask); | ||||
|     if (d_ism_mask_msb == false) | ||||
|         { | ||||
|             // For numbering in the ICD, the most significant bit/byte is numbered as bit/byte 0 | ||||
|             if (prn > 32) | ||||
|                 { | ||||
|                     return false; | ||||
|                 } | ||||
|             return b.test(32 - prn); | ||||
|         } | ||||
|     else | ||||
|         { | ||||
|             if (prn <= 32) | ||||
|                 { | ||||
|                     return false; | ||||
|                 } | ||||
|             return b.test(64 - prn); | ||||
|         } | ||||
| } | ||||
|   | ||||
| @@ -57,7 +57,6 @@ public: | ||||
|     void set_ism_ure(uint8_t ure); | ||||
|     void set_ism_bnom(uint8_t bnom); | ||||
|     void set_ism_Tvalidity(uint8_t tvalidity); | ||||
|     void set_ism_crc(uint32_t crc); | ||||
|  | ||||
|     bool check_ism_crc(const std::bitset<GALILEO_DATA_JK_BITS>& bits); | ||||
|  | ||||
| @@ -71,13 +70,14 @@ public: | ||||
|     uint16_t get_t0_ISM() const; | ||||
|     uint16_t get_Tvalidity_hours() const; | ||||
|     bool get_ism_mask_msb() const; | ||||
|     bool ism_parameters_apply(uint32_t prn) const; | ||||
|  | ||||
| private: | ||||
|     uint32_t compute_crc(const std::vector<uint8_t>& data); | ||||
|     boost::crc_optimal<32, 0x814141AB, 0, 0, false, false> crc32_ism; | ||||
|     boost::crc_optimal<32, 0x814141AB, 0, 0, false, false> d_crc32_ism; | ||||
|  | ||||
|     // ICD 2.1 Table 97 | ||||
|     std::unordered_map<uint8_t, double> ISM_PCONST_MAP = { | ||||
|     std::unordered_map<uint8_t, double> d_ISM_PCONST_MAP = { | ||||
|         {0, 1.0e-8}, | ||||
|         {1, 1.0e-7}, | ||||
|         {2, 1.0e-6}, | ||||
| @@ -96,7 +96,7 @@ private: | ||||
|         {15, 2.0e-4}}; | ||||
|  | ||||
|     // ICD 2.1 Table 98 | ||||
|     std::unordered_map<uint8_t, double> ISM_PSAT_MAP = { | ||||
|     std::unordered_map<uint8_t, double> d_ISM_PSAT_MAP = { | ||||
|         {0, 1.0e-7}, | ||||
|         {1, 3.0e-7}, | ||||
|         {2, 6.0e-7}, | ||||
| @@ -115,7 +115,7 @@ private: | ||||
|         {15, 3.0e-5}}; | ||||
|  | ||||
|     // ICD 2.1 Table 99 | ||||
|     std::unordered_map<uint8_t, float> ISM_URA_MAP = { | ||||
|     std::unordered_map<uint8_t, float> d_ISM_URA_MAP = { | ||||
|         {0, 0.75}, | ||||
|         {1, 1.0}, | ||||
|         {2, 1.5}, | ||||
| @@ -134,7 +134,7 @@ private: | ||||
|         {15, 6.0}}; | ||||
|  | ||||
|     // ICD 2.1 Table 100 | ||||
|     std::unordered_map<uint8_t, float> ISM_URE_MAP = { | ||||
|     std::unordered_map<uint8_t, float> d_ISM_URE_MAP = { | ||||
|         {0, 0.25}, | ||||
|         {1, 0.50}, | ||||
|         {2, 0.75}, | ||||
| @@ -153,7 +153,7 @@ private: | ||||
|         {15, 4.00}}; | ||||
|  | ||||
|     // ICD 2.1 Table 101 | ||||
|     std::unordered_map<uint8_t, float> ISM_BNOM_MAP = { | ||||
|     std::unordered_map<uint8_t, float> d_ISM_BNOM_MAP = { | ||||
|         {0, 0.0}, | ||||
|         {1, 0.10}, | ||||
|         {2, 0.20}, | ||||
| @@ -172,7 +172,7 @@ private: | ||||
|         {15, 2.4}}; | ||||
|  | ||||
|     // ICD 2.1 Table 102 | ||||
|     std::unordered_map<uint8_t, uint16_t> ISM_TVALIDITY_MAP = { | ||||
|     std::unordered_map<uint8_t, uint16_t> d_ISM_TVALIDITY_MAP = { | ||||
|         {0, 1}, | ||||
|         {1, 2}, | ||||
|         {2, 3}, | ||||
| @@ -190,19 +190,19 @@ private: | ||||
|         {14, 720}, | ||||
|         {15, 1440}}; | ||||
|  | ||||
|     uint32_t ism_crc{}; | ||||
|     uint32_t ism_mask{}; | ||||
|     uint16_t ism_wn{}; | ||||
|     uint16_t ism_t0{}; | ||||
|     uint8_t ism_constellation_id{}; | ||||
|     uint8_t ism_service_level_id{}; | ||||
|     uint8_t ism_pconst{}; | ||||
|     uint8_t ism_psat{}; | ||||
|     uint8_t ism_ura{}; | ||||
|     uint8_t ism_ure{}; | ||||
|     uint8_t ism_bnom{}; | ||||
|     uint8_t ism_Tvalidity{}; | ||||
|     bool ism_mask_msb{}; | ||||
|     uint32_t d_ism_crc{}; | ||||
|     uint32_t d_ism_mask{}; | ||||
|     uint16_t d_ism_wn{}; | ||||
|     uint16_t d_ism_t0{}; | ||||
|     uint8_t d_ism_constellation_id{}; | ||||
|     uint8_t d_ism_service_level_id{}; | ||||
|     uint8_t d_ism_pconst{}; | ||||
|     uint8_t d_ism_psat{}; | ||||
|     uint8_t d_ism_ura{}; | ||||
|     uint8_t d_ism_ure{}; | ||||
|     uint8_t d_ism_bnom{}; | ||||
|     uint8_t d_ism_Tvalidity{}; | ||||
|     bool d_ism_mask_msb{}; | ||||
| }; | ||||
|  | ||||
| /** \} */ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Carles Fernandez
					Carles Fernandez