From 5c24826d701235ec25b5206dff4daa00c69ebe08 Mon Sep 17 00:00:00 2001 From: Javier Arribas Date: Tue, 7 Aug 2018 19:39:56 +0200 Subject: [PATCH] Telemetry decoders improvements --- .../galileo_e1b_telemetry_decoder_cc.cc | 103 ++++++++++-------- .../galileo_e1b_telemetry_decoder_cc.h | 3 +- .../galileo_e5a_telemetry_decoder_cc.cc | 86 ++++++++------- .../galileo_e5a_telemetry_decoder_cc.h | 3 +- .../gps_l1_ca_telemetry_decoder_cc.cc | 77 +++++++------ .../gps_l5_telemetry_decoder_cc.cc | 67 +++++++----- .../gps_l5_telemetry_decoder_cc.h | 7 +- src/core/system_parameters/GPS_L1_CA.h | 2 +- src/core/system_parameters/GPS_L5.h | 2 + src/core/system_parameters/Galileo_E1.h | 2 + 10 files changed, 193 insertions(+), 159 deletions(-) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.cc index 9e1dc3394..2e4256b42 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.cc @@ -117,7 +117,8 @@ galileo_e1b_telemetry_decoder_cc::galileo_e1b_telemetry_decoder_cc( d_flag_frame_sync = false; d_flag_parity = false; - d_TOW_at_current_symbol = 0; + d_TOW_at_current_symbol_ms = 0; + d_TOW_at_Preamble_ms = 0; delta_t = 0; d_CRC_error_counter = 0; flag_even_word_arrived = 0; @@ -251,9 +252,9 @@ void galileo_e1b_telemetry_decoder_cc::decode_word(double *page_part_symbols, in DLOG(INFO) << "T0G=" << tmp_obj->t_0G_10; DLOG(INFO) << "WN_0G_10=" << tmp_obj->WN_0G_10; DLOG(INFO) << "Current parameters:"; - DLOG(INFO) << "d_TOW_at_current_symbol=" << d_TOW_at_current_symbol; + DLOG(INFO) << "d_TOW_at_current_symbol_ms=" << d_TOW_at_current_symbol_ms; DLOG(INFO) << "d_nav.WN_0=" << d_nav.WN_0; - delta_t = tmp_obj->A_0G_10 + tmp_obj->A_1G_10 * (d_TOW_at_current_symbol - tmp_obj->t_0G_10 + 604800 * (fmod((d_nav.WN_0 - tmp_obj->WN_0G_10), 64))); + delta_t = tmp_obj->A_0G_10 + tmp_obj->A_1G_10 * (static_cast(d_TOW_at_current_symbol_ms) / 1000.0 - tmp_obj->t_0G_10 + 604800 * (fmod((d_nav.WN_0 - tmp_obj->WN_0G_10), 64))); DLOG(INFO) << "delta_t=" << delta_t << "[s]"; } } @@ -406,6 +407,9 @@ int galileo_e1b_telemetry_decoder_cc::general_work(int noutput_items __attribute LOG(INFO) << "Lost of frame sync SAT " << this->d_satellite; d_flag_frame_sync = false; d_stat = 0; + d_TOW_at_current_symbol_ms = 0; + d_TOW_at_Preamble_ms = 0; + d_nav.flag_TOW_set = false; } } } @@ -419,73 +423,76 @@ int galileo_e1b_telemetry_decoder_cc::general_work(int noutput_items __attribute if (d_nav.flag_TOW_5 == true) // page 5 arrived and decoded, so we are in the odd page (since Tow refers to the even page, we have to add 1 sec) { // TOW_5 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later plus the decoding delay - d_TOW_at_current_symbol = d_nav.TOW_5 + static_cast(GALILEO_INAV_PAGE_PART_SECONDS) + static_cast(required_symbols + 1) * GALILEO_E1_CODE_PERIOD; + d_TOW_at_Preamble_ms = static_cast(d_nav.TOW_5 * 1000.0); + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + GALILEO_INAV_PAGE_PART_MS + (required_symbols + 1) * GALILEO_E1_CODE_PERIOD_MS; d_nav.flag_TOW_5 = false; } else if (d_nav.flag_TOW_6 == true) // page 6 arrived and decoded, so we are in the odd page (since Tow refers to the even page, we have to add 1 sec) { // TOW_6 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later plus the decoding delay - d_TOW_at_current_symbol = d_nav.TOW_6 + static_cast(GALILEO_INAV_PAGE_PART_SECONDS) + static_cast(required_symbols + 1) * GALILEO_E1_CODE_PERIOD; + d_TOW_at_Preamble_ms = static_cast(d_nav.TOW_6 * 1000.0); + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + GALILEO_INAV_PAGE_PART_MS + (required_symbols + 1) * GALILEO_E1_CODE_PERIOD_MS; d_nav.flag_TOW_6 = false; } else { // this page has no timing information - d_TOW_at_current_symbol += GALILEO_E1_CODE_PERIOD; // + GALILEO_INAV_PAGE_PART_SYMBOLS*GALILEO_E1_CODE_PERIOD; + d_TOW_at_current_symbol_ms += GALILEO_E1_CODE_PERIOD_MS; // + GALILEO_INAV_PAGE_PART_SYMBOLS*GALILEO_E1_CODE_PERIOD; } } else // if there is not a new preamble, we define the TOW of the current symbol { - d_TOW_at_current_symbol += GALILEO_E1_CODE_PERIOD; - } - - // if (d_flag_frame_sync == true and d_nav.flag_TOW_set==true and d_nav.flag_CRC_test == true) - - if (d_nav.flag_GGTO_1 == true and d_nav.flag_GGTO_2 == true and d_nav.flag_GGTO_3 == true and d_nav.flag_GGTO_4 == true) // all GGTO parameters arrived - { - delta_t = d_nav.A_0G_10 + d_nav.A_1G_10 * (d_TOW_at_current_symbol - d_nav.t_0G_10 + 604800.0 * (fmod((d_nav.WN_0 - d_nav.WN_0G_10), 64.0))); - } - - if (d_flag_frame_sync == true and d_nav.flag_TOW_set == true) - { - current_symbol.Flag_valid_word = true; - } - else - { - current_symbol.Flag_valid_word = false; - } - - current_symbol.TOW_at_current_symbol_ms = round(d_TOW_at_current_symbol * 1000.0); - // todo: Galileo to GPS time conversion should be moved to observable block. - // current_symbol.TOW_at_current_symbol_ms -= delta_t; //Galileo to GPS TOW - - if (d_dump == true) - { - // MULTIPLEXED FILE RECORDING - Record results to file - try + if (d_nav.flag_TOW_set == true) { - double tmp_double; - unsigned long int tmp_ulong_int; - tmp_double = d_TOW_at_current_symbol; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_ulong_int = current_symbol.Tracking_sample_counter; - d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(unsigned long int)); - tmp_double = 0; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "Exception writing observables dump file " << e.what(); + d_TOW_at_current_symbol_ms += GALILEO_E1_CODE_PERIOD_MS; } } // remove used symbols from history + // todo: Use circular buffer here if (d_symbol_history.size() > required_symbols) { d_symbol_history.pop_front(); } - // 3. Make the output (copy the object contents to the GNURadio reserved memory) - *out[0] = current_symbol; - return 1; + + if (d_nav.flag_TOW_set) + { + if (d_nav.flag_GGTO_1 == true and d_nav.flag_GGTO_2 == true and d_nav.flag_GGTO_3 == true and d_nav.flag_GGTO_4 == true) // all GGTO parameters arrived + { + delta_t = d_nav.A_0G_10 + d_nav.A_1G_10 * (static_cast(d_TOW_at_current_symbol_ms) / 1000.0 - d_nav.t_0G_10 + 604800.0 * (fmod((d_nav.WN_0 - d_nav.WN_0G_10), 64.0))); + } + + current_symbol.Flag_valid_word = d_nav.flag_TOW_set; + current_symbol.TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms; + // todo: Galileo to GPS time conversion should be moved to observable block. + // current_symbol.TOW_at_current_symbol_ms -= delta_t; //Galileo to GPS TOW + + if (d_dump == true) + { + // MULTIPLEXED FILE RECORDING - Record results to file + try + { + double tmp_double; + unsigned long int tmp_ulong_int; + tmp_double = static_cast(d_TOW_at_current_symbol_ms) / 1000.0; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_ulong_int = current_symbol.Tracking_sample_counter; + d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(unsigned long int)); + tmp_double = static_cast(d_TOW_at_Preamble_ms) / 1000.0; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "Exception writing observables dump file " << e.what(); + } + } + // 3. Make the output (copy the object contents to the GNURadio reserved memory) + *out[0] = current_symbol; + return 1; + } + else + { + return 0; + } } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.h index 8f434f0d5..36803eccf 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.h @@ -105,7 +105,8 @@ private: Gnss_Satellite d_satellite; int d_channel; - double d_TOW_at_current_symbol; + unsigned int d_TOW_at_Preamble_ms; + unsigned int d_TOW_at_current_symbol_ms; bool flag_TOW_set; double delta_t; //GPS-GALILEO time offset diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc index 96431880b..a4ef0da6e 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc @@ -154,7 +154,6 @@ galileo_e5a_telemetry_decoder_cc::galileo_e5a_telemetry_decoder_cc( // initialize internal vars d_dump = dump; d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - LOG(INFO) << "GALILEO E5A TELEMETRY PROCESSING: satellite " << d_satellite; // set the preamble for (int i = 0; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++) @@ -182,7 +181,8 @@ galileo_e5a_telemetry_decoder_cc::galileo_e5a_telemetry_decoder_cc( d_flag_preamble = false; d_preamble_index = 0; d_flag_frame_sync = false; - d_TOW_at_current_symbol = 0.0; + d_TOW_at_current_symbol_ms = 0; + d_TOW_at_Preamble_ms = 0; flag_TOW_set = false; d_CRC_error_counter = 0; d_channel = 0; @@ -345,7 +345,7 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute // ****************** Frame sync ****************** if ((d_stat == 0) && new_symbol) // no preamble information { - if (abs(corr_value) >= GALILEO_FNAV_PREAMBLE_LENGTH_BITS) + if (abs(corr_value) == GALILEO_FNAV_PREAMBLE_LENGTH_BITS) { d_preamble_index = d_sample_counter; // record the preamble sample stamp LOG(INFO) << "Preamble detection for Galileo E5a satellite " << d_satellite; @@ -354,7 +354,7 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute } else if ((d_stat == 1) && new_symbol) // possible preamble lock { - if (abs(corr_value) >= GALILEO_FNAV_PREAMBLE_LENGTH_BITS) + if (abs(corr_value) == GALILEO_FNAV_PREAMBLE_LENGTH_BITS) { // check preamble separation preamble_diff = d_sample_counter - d_preamble_index; @@ -418,6 +418,9 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute d_flag_frame_sync = false; d_stat = 0; flag_bit_start = false; + d_nav.flag_TOW_set = false; + d_TOW_at_current_symbol_ms = 0; + d_TOW_at_Preamble_ms = 0; } } } @@ -432,73 +435,72 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute { if (d_nav.flag_TOW_1 == true) { - d_TOW_at_current_symbol = d_nav.FNAV_TOW_1 + (static_cast(GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD); + d_TOW_at_Preamble_ms = static_cast(d_nav.FNAV_TOW_1 * 1000.0); + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + (GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD_MS; d_nav.flag_TOW_1 = false; } else if (d_nav.flag_TOW_2 == true) { - d_TOW_at_current_symbol = d_nav.FNAV_TOW_2 + (static_cast(GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD); + d_TOW_at_Preamble_ms = static_cast(d_nav.FNAV_TOW_2 * 1000.0); + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + (GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD_MS; d_nav.flag_TOW_2 = false; } else if (d_nav.flag_TOW_3 == true) { - d_TOW_at_current_symbol = d_nav.FNAV_TOW_3 + (static_cast(GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD); + d_TOW_at_Preamble_ms = static_cast(d_nav.FNAV_TOW_3 * 1000.0); + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + (GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD_MS; d_nav.flag_TOW_3 = false; } else if (d_nav.flag_TOW_4 == true) { - d_TOW_at_current_symbol = d_nav.FNAV_TOW_4 + (static_cast(GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD); + d_TOW_at_Preamble_ms = static_cast(d_nav.FNAV_TOW_4 * 1000.0); + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + (GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD_MS; d_nav.flag_TOW_4 = false; } else { - d_TOW_at_current_symbol += GALILEO_E5a_CODE_PERIOD; + d_TOW_at_current_symbol_ms += GALILEO_E5a_CODE_PERIOD_MS; } } else // if there is not a new preamble, we define the TOW of the current symbol { - d_TOW_at_current_symbol += GALILEO_E5a_CODE_PERIOD; - } - - //if (d_flag_frame_sync == true and d_nav.flag_TOW_set==true and d_nav.flag_CRC_test == true) - if (d_flag_frame_sync and d_nav.flag_TOW_set) - { - current_sample.Flag_valid_word = true; - } - else - { - current_sample.Flag_valid_word = false; - } - - current_sample.TOW_at_current_symbol_ms = round(d_TOW_at_current_symbol * 1000.0); - - if (d_dump) - { - // MULTIPLEXED FILE RECORDING - Record results to file - try + if (d_nav.flag_TOW_set == true) { - double tmp_double; - unsigned long int tmp_ulong_int; - tmp_double = d_TOW_at_current_symbol; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_ulong_int = current_sample.Tracking_sample_counter; - d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(unsigned long int)); - tmp_double = 0.0; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "Exception writing Galileo E5a Telemetry Decoder dump file " << e.what(); + d_TOW_at_current_symbol_ms += GALILEO_E5a_CODE_PERIOD_MS; } } + // remove used symbols from history + // todo: Use circular buffer here while (d_symbol_history.size() > required_symbols) { d_symbol_history.pop_front(); } - // 3. Make the output - if (current_sample.Flag_valid_word) + + if (d_nav.flag_TOW_set) { + current_sample.Flag_valid_word = true; + current_sample.TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms; + if (d_dump) + { + // MULTIPLEXED FILE RECORDING - Record results to file + try + { + double tmp_double; + unsigned long int tmp_ulong_int; + tmp_double = static_cast(d_TOW_at_current_symbol_ms) / 1000.0; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_ulong_int = current_sample.Tracking_sample_counter; + d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(unsigned long int)); + tmp_double = static_cast(d_TOW_at_Preamble_ms) / 1000.0; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "Exception writing Galileo E5a Telemetry Decoder dump file " << e.what(); + } + } + // 3. Make the output out[0] = current_sample; return 1; } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.h index 32400ca01..5416af8f5 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.h @@ -104,7 +104,8 @@ private: bool new_symbol; double d_prompt_acum; double page_symbols[GALILEO_FNAV_SYMBOLS_PER_PAGE - GALILEO_FNAV_PREAMBLE_LENGTH_BITS]; - double d_TOW_at_current_symbol; + unsigned int d_TOW_at_Preamble_ms; + unsigned int d_TOW_at_current_symbol_ms; double delta_t; //GPS-GALILEO time offset std::string d_dump_filename; std::ofstream d_dump_file; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc index 899913024..b07b467f6 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc @@ -419,6 +419,7 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__ flag_TOW_set = false; d_current_subframe_symbol = 0; d_crc_error_synchronization_counter = 0; + d_TOW_at_current_symbol_ms = 0; } } } @@ -426,47 +427,57 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__ //2. Add the telemetry decoder information if (this->d_flag_preamble == true and d_flag_new_tow_available == true) { - d_TOW_at_current_symbol_ms = static_cast(d_nav.d_TOW) * 1000 + GPS_CA_PREAMBLE_DURATION_MS; - d_TOW_at_Preamble_ms = d_TOW_at_current_symbol_ms; + d_TOW_at_current_symbol_ms = static_cast(d_nav.d_TOW * 1000.0) + GPS_CA_PREAMBLE_DURATION_MS; + d_TOW_at_Preamble_ms = static_cast(d_nav.d_TOW * 1000.0); flag_TOW_set = true; d_flag_new_tow_available = false; } else { - d_TOW_at_current_symbol_ms += GPS_L1_CA_CODE_PERIOD_MS; - } - - current_symbol.TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms; - current_symbol.Flag_valid_word = flag_TOW_set; - - if (flag_PLL_180_deg_phase_locked == true) - { - //correct the accumulated phase for the Costas loop phase shift, if required - current_symbol.Carrier_phase_rads += GPS_PI; - } - - if (d_dump == true) - { - // MULTIPLEXED FILE RECORDING - Record results to file - try + if (flag_TOW_set == true) { - double tmp_double; - unsigned long int tmp_ulong_int; - tmp_double = static_cast(d_TOW_at_current_symbol_ms) / 1000.0; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_ulong_int = current_symbol.Tracking_sample_counter; - d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(unsigned long int)); - tmp_double = static_cast(d_TOW_at_Preamble_ms) * 1000.0; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "Exception writing observables dump file " << e.what(); + d_TOW_at_current_symbol_ms += GPS_L1_CA_CODE_PERIOD_MS; } } - //3. Make the output (copy the object contents to the GNURadio reserved memory) - *out[0] = current_symbol; + if (flag_TOW_set == true) + { + current_symbol.TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms; + current_symbol.Flag_valid_word = flag_TOW_set; - return 1; + if (flag_PLL_180_deg_phase_locked == true) + { + //correct the accumulated phase for the Costas loop phase shift, if required + current_symbol.Carrier_phase_rads += GPS_PI; + } + + if (d_dump == true) + { + // MULTIPLEXED FILE RECORDING - Record results to file + try + { + double tmp_double; + unsigned long int tmp_ulong_int; + tmp_double = static_cast(d_TOW_at_current_symbol_ms) / 1000.0; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_ulong_int = current_symbol.Tracking_sample_counter; + d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(unsigned long int)); + tmp_double = static_cast(d_TOW_at_Preamble_ms) / 1000.0; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "Exception writing observables dump file " << e.what(); + } + } + + //3. Make the output (copy the object contents to the GNURadio reserved memory) + *out[0] = current_symbol; + + return 1; + } + else + { + return 0; + } } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc index 87412096e..ca050a575 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc @@ -64,8 +64,8 @@ gps_l5_telemetry_decoder_cc::gps_l5_telemetry_decoder_cc( DLOG(INFO) << "GPS L5 TELEMETRY PROCESSING: satellite " << d_satellite; d_channel = 0; d_flag_valid_word = false; - d_TOW_at_current_symbol = 0.0; - d_TOW_at_Preamble = 0.0; + d_TOW_at_current_symbol_ms = 0; + d_TOW_at_Preamble_ms = 0; //initialize the CNAV frame decoder (libswiftcnav) cnav_msg_decoder_init(&d_cnav_decoder); for (int aux = 0; aux < GPS_L5i_NH_CODE_LENGTH; aux++) @@ -236,47 +236,56 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u } //update TOW at the preamble instant - d_TOW_at_Preamble = static_cast(msg.tow) * 6.0; + d_TOW_at_Preamble_ms = msg.tow * 6000; //* The time of the last input symbol can be computed from the message ToW and //* delay by the formulae: //* \code //* symbolTime_ms = msg->tow * 6000 + *pdelay * 10 + (12 * 10); 12 symbols of the encoder's transitory - d_TOW_at_current_symbol = (static_cast(msg.tow) * 6.0) + (static_cast(delay) + 12.0) * GPS_L5i_SYMBOL_PERIOD; - d_TOW_at_current_symbol = floor(d_TOW_at_current_symbol * 1000.0) / 1000.0; + //d_TOW_at_current_symbol_ms = msg.tow * 6000 + (delay + 12) * GPS_L5i_SYMBOL_PERIOD_MS; + + d_TOW_at_current_symbol_ms = msg.tow * 6000 + (delay + 12) * GPS_L5i_SYMBOL_PERIOD_MS; d_flag_valid_word = true; } else { - d_TOW_at_current_symbol += GPS_L5i_PERIOD; + d_TOW_at_current_symbol_ms += GPS_L5i_PERIOD_MS; if (current_synchro_data.Flag_valid_symbol_output == false) { d_flag_valid_word = false; } } - current_synchro_data.TOW_at_current_symbol_ms = round(d_TOW_at_current_symbol * 1000.0); - current_synchro_data.Flag_valid_word = d_flag_valid_word; - if (d_dump == true) + if (d_flag_valid_word == true) { - // MULTIPLEXED FILE RECORDING - Record results to file - try - { - double tmp_double; - unsigned long int tmp_ulong_int; - tmp_double = d_TOW_at_current_symbol; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_ulong_int = current_synchro_data.Tracking_sample_counter; - d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(unsigned long int)); - tmp_double = d_TOW_at_Preamble; - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "Exception writing Telemetry GPS L5 dump file " << e.what(); - } - } + current_synchro_data.TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms; + current_synchro_data.Flag_valid_word = d_flag_valid_word; - //3. Make the output (copy the object contents to the GNURadio reserved memory) - out[0] = current_synchro_data; - return 1; + if (d_dump == true) + { + // MULTIPLEXED FILE RECORDING - Record results to file + try + { + double tmp_double; + unsigned long int tmp_ulong_int; + tmp_double = static_cast(d_TOW_at_current_symbol_ms) / 1000.0; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_ulong_int = current_synchro_data.Tracking_sample_counter; + d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(unsigned long int)); + tmp_double = static_cast(d_TOW_at_Preamble_ms) / 1000.0; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "Exception writing Telemetry GPS L5 dump file " << e.what(); + } + } + + //3. Make the output (copy the object contents to the GNURadio reserved memory) + out[0] = current_synchro_data; + return 1; + } + else + { + return 0; + } } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.h index c5e838382..2970fe7c9 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.h @@ -41,8 +41,7 @@ #include #include -extern "C" -{ +extern "C" { #include "cnav_msg.h" #include "edc.h" #include "bits.h" @@ -85,8 +84,8 @@ private: cnav_msg_decoder_t d_cnav_decoder; - double d_TOW_at_current_symbol; - double d_TOW_at_Preamble; + unsigned int d_TOW_at_current_symbol_ms; + unsigned int d_TOW_at_Preamble_ms; bool d_flag_valid_word; Gps_CNAV_Navigation_Message d_CNAV_Message; diff --git a/src/core/system_parameters/GPS_L1_CA.h b/src/core/system_parameters/GPS_L1_CA.h index be6192795..d0b377cc0 100644 --- a/src/core/system_parameters/GPS_L1_CA.h +++ b/src/core/system_parameters/GPS_L1_CA.h @@ -68,7 +68,7 @@ const double MAX_TOA_DELAY_MS = 20; //#define NAVIGATION_SOLUTION_RATE_MS 1000 // this cannot go here //const double GPS_STARTOFFSET_ms = 68.802; //[ms] Initial sign. travel time (this cannot go here) -const double GPS_STARTOFFSET_ms = 69.0; +const double GPS_STARTOFFSET_ms = 60.0; // OBSERVABLE HISTORY DEEP FOR INTERPOLATION const int GPS_L1_CA_HISTORY_DEEP = 100; diff --git a/src/core/system_parameters/GPS_L5.h b/src/core/system_parameters/GPS_L5.h index 5a919820d..31d36e89d 100644 --- a/src/core/system_parameters/GPS_L5.h +++ b/src/core/system_parameters/GPS_L5.h @@ -55,7 +55,9 @@ const double GPS_L5_FREQ_HZ = FREQ5; //!< L5 [Hz] const double GPS_L5i_CODE_RATE_HZ = 10.23e6; //!< GPS L5i code rate [chips/s] const int GPS_L5i_CODE_LENGTH_CHIPS = 10230; //!< GPS L5i code length [chips] const double GPS_L5i_PERIOD = 0.001; //!< GPS L5 code period [seconds] +const int GPS_L5i_PERIOD_MS = 1; //!< GPS L5 code period [ms] const double GPS_L5i_SYMBOL_PERIOD = 0.01; //!< GPS L5 symbol period [seconds] +const int GPS_L5i_SYMBOL_PERIOD_MS = 10; //!< GPS L5 symbol period [ms] const double GPS_L5q_CODE_RATE_HZ = 10.23e6; //!< GPS L5i code rate [chips/s] const int GPS_L5q_CODE_LENGTH_CHIPS = 10230; //!< GPS L5i code length [chips] diff --git a/src/core/system_parameters/Galileo_E1.h b/src/core/system_parameters/Galileo_E1.h index 951612e02..da005c877 100644 --- a/src/core/system_parameters/Galileo_E1.h +++ b/src/core/system_parameters/Galileo_E1.h @@ -80,6 +80,7 @@ const int GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS = 250; const int GALILEO_INAV_PAGE_PART_SYMBOLS = 250; //!< Each Galileo INAV pages are composed of two parts (even and odd) each of 250 symbols, including preamble. See Galileo ICD 4.3.2 const int GALILEO_INAV_PAGE_SYMBOLS = 500; //!< The complete Galileo INAV page length const int GALILEO_INAV_PAGE_PART_SECONDS = 1; // a page part last 1 sec +const int GALILEO_INAV_PAGE_PART_MS = 1000; // a page part last 1 sec const int GALILEO_INAV_PAGE_SECONDS = 2; // a full page last 2 sec const int GALILEO_INAV_INTERLEAVER_ROWS = 8; const int GALILEO_INAV_INTERLEAVER_COLS = 30; @@ -89,6 +90,7 @@ const int GALILEO_DATA_JK_BITS = 128; const int GALILEO_DATA_FRAME_BITS = 196; const int GALILEO_DATA_FRAME_BYTES = 25; const double GALILEO_E1_CODE_PERIOD = 0.004; +const int GALILEO_E1_CODE_PERIOD_MS = 4; const std::vector> type({{1, 6}}); const std::vector> PAGE_TYPE_bit({{1, 6}});