From d8f697401e3e59371dbe9e8df9535ea0e97ac886 Mon Sep 17 00:00:00 2001 From: Damian Miralles Date: Wed, 20 Sep 2017 08:42:01 -0600 Subject: [PATCH] bugfix: Fixes bugs with units in GNAV Almanac decoding Forces conversion of semicircles to radians units in some GNAV Almanac parameters. In addition, adds safeguards in code to avoid invalid slot number identification. --- conf/gnss-sdr_GLONASS_L1_CA_ibyte.conf | 15 +- .../glonass_l1_ca_telemetry_decoder_cc.cc | 3 + .../glonass_gnav_navigation_message.cc | 149 ++++++++++-------- 3 files changed, 89 insertions(+), 78 deletions(-) diff --git a/conf/gnss-sdr_GLONASS_L1_CA_ibyte.conf b/conf/gnss-sdr_GLONASS_L1_CA_ibyte.conf index af8929c2d..a5bb1572f 100644 --- a/conf/gnss-sdr_GLONASS_L1_CA_ibyte.conf +++ b/conf/gnss-sdr_GLONASS_L1_CA_ibyte.conf @@ -25,20 +25,15 @@ Resampler.sample_freq_out=6625000 Resampler.item_type=gr_complex ;######### CHANNELS GLOBAL CONFIG ############ +Channel.signal=1G +Channels.in_acquisition=1 Channels_1G.count=5 -Channels.in_acquisition=5 -Channel0.signal=1G -Channel1.signal=1G -Channel2.signal=1G -Channel3.signal=1G -Channel4.signal=1G Channel0.satellite=11 Channel1.satellite=2 Channel2.satellite=18 Channel3.satellite=12 Channel4.satellite=21 -; Possible list includes 2, 12, 21, 22 ;######### ACQUISITION GLOBAL CONFIG ############ Acquisition_1G.implementation=GLONASS_L1_CA_PCPS_Acquisition @@ -53,9 +48,9 @@ Acquisition_1G.dump_filename=/archive/glo_acquisition.dat ;Acquisition_1G.coherent_integration_time_ms=10 ;######### TRACKING GLOBAL CONFIG ############ -Tracking_1G.implementation=GLONASS_L1_CA_DLL_PLL_C_Aid_Tracking +Tracking_1G.implementation=GLONASS_L1_CA_DLL_PLL_Tracking Tracking_1G.item_type=gr_complex -Tracking_1G.if=1 +Tracking_1G.if=0 Tracking_1G.early_late_space_chips=0.5 Tracking_1G.pll_bw_hz=25.0; Tracking_1G.dll_bw_hz=3.0; @@ -63,7 +58,7 @@ Tracking_1G.dump=true; Tracking_1G.dump_filename=/archive/glo_tracking_ch_ ;######### TELEMETRY DECODER GPS CONFIG ############ -TelemetryDecoder_1G.implementation=GPS_L1_CA_Telemetry_Decoder +TelemetryDecoder_1G.implementation=GLONASS_L1_CA_Telemetry_Decoder ;######### OBSERVABLES CONFIG ############ Observables.implementation=Hybrid_Observables diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc index a6dee4c8f..e12e83b7e 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc @@ -200,6 +200,7 @@ void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols,int // get object for this SV (mandatory) std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + LOG(INFO) << "GLONASS GNAV Ephemeris have been received on channel" << d_channel << " from satellite " << d_satellite; } if (d_nav.have_new_utc_model() == true) @@ -207,12 +208,14 @@ void glonass_l1_ca_telemetry_decoder_cc::decode_string(double *frame_symbols,int // get object for this SV (mandatory) std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + LOG(INFO) << "GLONASS GNAV UTC Model have been received on channel" << d_channel << " from satellite " << d_satellite; } if (d_nav.have_new_almanac() == true) { unsigned int slot_nbr = d_nav.i_alm_satellite_slot_number; std::shared_ptr tmp_obj= std::make_shared(d_nav.get_almanac(slot_nbr)); this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + LOG(INFO) << "GLONASS GNAV Almanac have been received on channel" << d_channel << " in slot number " << slot_nbr; } // 5. Update satellite information on system if(d_nav.flag_update_slot_number == true) diff --git a/src/core/system_parameters/glonass_gnav_navigation_message.cc b/src/core/system_parameters/glonass_gnav_navigation_message.cc index d37f5e796..ca5b4a9d0 100644 --- a/src/core/system_parameters/glonass_gnav_navigation_message.cc +++ b/src/core/system_parameters/glonass_gnav_navigation_message.cc @@ -385,86 +385,97 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) case 3: // --- It is string 3 ---------------------------------------------- - gnav_ephemeris.d_P_3 = static_cast(read_navigation_bool(string_bits, P3)); - gnav_ephemeris.d_gamma_n = static_cast(read_navigation_signed(string_bits, GAMMA_N)) * TWO_N40; - gnav_ephemeris.d_P = static_cast(read_navigation_unsigned(string_bits, P)); - gnav_ephemeris.d_l3rd_n = static_cast(read_navigation_bool(string_bits, EPH_L_N)); - gnav_ephemeris.d_VZn = static_cast(read_navigation_signed(string_bits, Z_N_DOT)) * TWO_N20; - gnav_ephemeris.d_AZn = static_cast(read_navigation_signed(string_bits, Z_N_DOT_DOT)) * TWO_N30; - gnav_ephemeris.d_Zn = static_cast(read_navigation_signed(string_bits, Z_N)) * TWO_N11; + if (flag_ephemeris_str_2 == true) + { + gnav_ephemeris.d_P_3 = static_cast(read_navigation_bool(string_bits, P3)); + gnav_ephemeris.d_gamma_n = static_cast(read_navigation_signed(string_bits, GAMMA_N)) * TWO_N40; + gnav_ephemeris.d_P = static_cast(read_navigation_unsigned(string_bits, P)); + gnav_ephemeris.d_l3rd_n = static_cast(read_navigation_bool(string_bits, EPH_L_N)); + gnav_ephemeris.d_VZn = static_cast(read_navigation_signed(string_bits, Z_N_DOT)) * TWO_N20; + gnav_ephemeris.d_AZn = static_cast(read_navigation_signed(string_bits, Z_N_DOT_DOT)) * TWO_N30; + gnav_ephemeris.d_Zn = static_cast(read_navigation_signed(string_bits, Z_N)) * TWO_N11; - flag_ephemeris_str_3 = true; + flag_ephemeris_str_3 = true; + } break; case 4: // --- It is string 4 ---------------------------------------------- - gnav_ephemeris.d_tau_n = static_cast(read_navigation_signed(string_bits, TAU_N)) * TWO_N30; - gnav_ephemeris.d_Delta_tau_n = static_cast(read_navigation_signed(string_bits, DELTA_TAU_N)) * TWO_N30; - gnav_ephemeris.d_E_n = static_cast(read_navigation_unsigned(string_bits, E_N)); - gnav_ephemeris.d_P_4 = static_cast(read_navigation_bool(string_bits, P4)); - gnav_ephemeris.d_F_T = static_cast(read_navigation_unsigned(string_bits, F_T)); - gnav_ephemeris.d_N_T = static_cast(read_navigation_unsigned(string_bits, N_T)); - gnav_ephemeris.d_n = static_cast(read_navigation_unsigned(string_bits, N)); - gnav_ephemeris.d_M = static_cast(read_navigation_unsigned(string_bits, M)); + if (flag_ephemeris_str_3 == true) + { + gnav_ephemeris.d_tau_n = static_cast(read_navigation_signed(string_bits, TAU_N)) * TWO_N30; + gnav_ephemeris.d_Delta_tau_n = static_cast(read_navigation_signed(string_bits, DELTA_TAU_N)) * TWO_N30; + gnav_ephemeris.d_E_n = static_cast(read_navigation_unsigned(string_bits, E_N)); + gnav_ephemeris.d_P_4 = static_cast(read_navigation_bool(string_bits, P4)); + gnav_ephemeris.d_F_T = static_cast(read_navigation_unsigned(string_bits, F_T)); + gnav_ephemeris.d_N_T = static_cast(read_navigation_unsigned(string_bits, N_T)); + gnav_ephemeris.d_n = static_cast(read_navigation_unsigned(string_bits, N)); + gnav_ephemeris.d_M = static_cast(read_navigation_unsigned(string_bits, M)); - // Fill in ephemeris deliverables in the code - flag_update_slot_number = true; - gnav_ephemeris.i_satellite_slot_number = static_cast(gnav_ephemeris.d_n); - gnav_ephemeris.i_satellite_PRN = static_cast(gnav_ephemeris.d_n); + // Fill in ephemeris deliverables in the code + flag_update_slot_number = true; + gnav_ephemeris.i_satellite_slot_number = static_cast(gnav_ephemeris.d_n); + gnav_ephemeris.i_satellite_PRN = static_cast(gnav_ephemeris.d_n); - flag_ephemeris_str_4 = true; + flag_ephemeris_str_4 = true; + } break; case 5: // --- It is string 5 ---------------------------------------------- - gnav_utc_model.d_N_A = static_cast(read_navigation_unsigned(string_bits, N_A)); - gnav_utc_model.d_tau_c = static_cast(read_navigation_signed(string_bits, TAU_C)) * TWO_N31; - gnav_utc_model.d_N_4 = static_cast(read_navigation_unsigned(string_bits, N_4)); - gnav_utc_model.d_tau_gps = static_cast(read_navigation_signed(string_bits, TAU_GPS)) * TWO_N30; - gnav_ephemeris.d_l5th_n = static_cast(read_navigation_bool(string_bits, ALM_L_N)); - - flag_utc_model_str_5 = true; - // Compute Year and DoY based on Algorithm A3.11 of GLONASS ICD if (flag_ephemeris_str_4 == true) { - //Current year number J in the four-year interval is calculated: + gnav_utc_model.d_N_A = static_cast(read_navigation_unsigned(string_bits, N_A)); + gnav_utc_model.d_tau_c = static_cast(read_navigation_signed(string_bits, TAU_C)) * TWO_N31; + gnav_utc_model.d_N_4 = static_cast(read_navigation_unsigned(string_bits, N_4)); + gnav_utc_model.d_tau_gps = static_cast(read_navigation_signed(string_bits, TAU_GPS)) * TWO_N30; + gnav_ephemeris.d_l5th_n = static_cast(read_navigation_bool(string_bits, ALM_L_N)); + + flag_utc_model_str_5 = true; + + // Compute Year and DoY based on Algorithm A3.11 of GLONASS ICD + // 1). Current year number J in the four-year interval is calculated if (gnav_ephemeris.d_N_T >= 1 && gnav_ephemeris.d_N_T <= 366) - { - J = 1; - } + { + J = 1; + } else if (gnav_ephemeris.d_N_T >= 367 && gnav_ephemeris.d_N_T <= 731) - { - J = 2; - } + { + J = 2; + } else if (gnav_ephemeris.d_N_T >= 732 && gnav_ephemeris.d_N_T <= 1096) - { - J = 3; - } + { + J = 3; + } else if (gnav_ephemeris.d_N_T >= 1097 && gnav_ephemeris.d_N_T <= 1461) - { - J = 4; - } + { + J = 4; + } // 2). Current year in common form is calculated by the following formula: gnav_ephemeris.d_yr = 1996 + 4.0 * (gnav_utc_model.d_N_4 - 1.0) + (J - 1.0); gnav_ephemeris.d_tau_c = gnav_utc_model.d_tau_c; // 3). Set TOW once the year has been defined, it helps with leap second determination if (flag_ephemeris_str_1 == true) - { - d_TOW = get_TOW(); - flag_TOW_set = true; - - } + { + d_TOW = get_TOW(); + flag_TOW_set = true; + } } + + break; case 6: // --- It is string 6 ---------------------------------------------- i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, n_A)); d_frame_ID = get_frame_number(i_alm_satellite_slot_number); + // Make sure a valid frame_ID or satellite slot number is returned + if(d_frame_ID == 0) + return 0; gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = static_cast(read_navigation_bool(string_bits, C_N)); gnav_almanac[i_alm_satellite_slot_number - 1].d_M_n_A = static_cast(read_navigation_unsigned(string_bits, M_N_A)); @@ -510,6 +521,9 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) // --- It is string 8 ---------------------------------------------- i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, n_A)); d_frame_ID = get_frame_number(i_alm_satellite_slot_number); + // Make sure a valid frame_ID or satellite slot number is returned + if(d_frame_ID == 0) + return 0; gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = static_cast(read_navigation_bool(string_bits, C_N)); gnav_almanac[i_alm_satellite_slot_number - 1].d_M_n_A = static_cast(read_navigation_unsigned(string_bits, M_N_A)); @@ -548,6 +562,9 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) // --- It is string 10 --------------------------------------------- i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, n_A)); d_frame_ID = get_frame_number(i_alm_satellite_slot_number); + // Make sure a valid frame_ID or satellite slot number is returned + if(d_frame_ID == 0) + return 0; gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = static_cast(read_navigation_bool(string_bits, C_N)); gnav_almanac[i_alm_satellite_slot_number - 1].d_M_n_A = static_cast(read_navigation_unsigned(string_bits, M_N_A)); @@ -587,7 +604,9 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) // --- It is string 12 --------------------------------------------- i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, n_A)); d_frame_ID = get_frame_number(i_alm_satellite_slot_number); - + // Make sure a valid frame_ID or satellite slot number is returned + if(d_frame_ID == 0) + return 0; gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = static_cast(read_navigation_bool(string_bits, C_N)); gnav_almanac[i_alm_satellite_slot_number - 1].d_M_n_A = static_cast(read_navigation_unsigned(string_bits, M_N_A)); gnav_almanac[i_alm_satellite_slot_number - 1].d_n_A = static_cast(read_navigation_unsigned(string_bits, n_A)); @@ -633,7 +652,9 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) { i_alm_satellite_slot_number = static_cast(read_navigation_unsigned(string_bits, n_A)); d_frame_ID = get_frame_number(i_alm_satellite_slot_number); - + // Make sure a valid frame_ID or satellite slot number is returned + if(d_frame_ID == 0) + return 0; gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = static_cast(read_navigation_bool(string_bits, C_N)); gnav_almanac[i_alm_satellite_slot_number - 1].d_M_n_A = static_cast(read_navigation_unsigned(string_bits, M_N_A)); gnav_almanac[i_alm_satellite_slot_number - 1].d_n_A = static_cast(read_navigation_unsigned(string_bits, n_A)); @@ -644,12 +665,10 @@ int Glonass_Gnav_Navigation_Message::string_decoder(std::string frame_string) flag_almanac_str_14 = true; } - - break; case 15: - // --- It is string 9 ---------------------------------------------- + // --- It is string 15 ---------------------------------------------- if (d_frame_ID != 5 and flag_almanac_str_14 == true) { gnav_almanac[i_alm_satellite_slot_number - 1].d_omega_n_A = static_cast(read_navigation_signed(string_bits, OMEGA_N_A)) * TWO_N15 * GLONASS_PI; gnav_almanac[i_alm_satellite_slot_number - 1].d_t_lambda_n_A = static_cast(read_navigation_unsigned(string_bits, T_LAMBDA_N_A)) * TWO_N5; @@ -711,23 +730,17 @@ Glonass_Gnav_Almanac Glonass_Gnav_Navigation_Message::get_almanac(unsigned int s bool Glonass_Gnav_Navigation_Message::have_new_ephemeris() //Check if we have a new ephemeris stored in the galileo navigation class { - if ((flag_ephemeris_str_1 == true) and (flag_ephemeris_str_2 == true) and (flag_ephemeris_str_3 == true) and (flag_ephemeris_str_4 == true)) + // We need to make sure we have received the ephemeris info plus the time info + if ((flag_ephemeris_str_1 == true) and (flag_ephemeris_str_2 == true) and + (flag_ephemeris_str_3 == true) and (flag_ephemeris_str_4 == true) and + (flag_utc_model_str_5 == true)) { - if (gnav_ephemeris.d_P_4 == 1) - { - flag_ephemeris_str_1 = false;// clear the flag - flag_ephemeris_str_2 = false;// clear the flag - flag_ephemeris_str_3 = false;// clear the flag - flag_ephemeris_str_4 = false;// clear the flag - flag_all_ephemeris = true; - DLOG(INFO) << "Ephemeris (1, 2, 3, 4) have been received and belong to the same batch" << std::endl; - - return true; - } - else - { - return false; - } + flag_ephemeris_str_1 = false;// clear the flag + flag_ephemeris_str_2 = false;// clear the flag + flag_ephemeris_str_3 = false;// clear the flag + flag_ephemeris_str_4 = false;// clear the flag + flag_all_ephemeris = true; + DLOG(INFO) << "GLONASS GNAV Ephemeris (1, 2, 3, 4) have been received and belong to the same batch" << std::endl; } else return false;