From 500dc59516a64448fecf0fabea2fd1c7fcfbe8ae Mon Sep 17 00:00:00 2001 From: Javier Arribas Date: Tue, 22 Mar 2016 18:07:12 +0100 Subject: [PATCH] Release candidate of the GPS L1 C/A telemetry decoder supporting variable tracking correlation length --- conf/gnss-sdr_Hybrid_gr_complex.conf | 8 +- conf/gnss-sdr_Hybrid_nsr.conf | 4 +- src/algorithms/channel/adapters/channel.cc | 2 +- .../gps_l1_ca_telemetry_decoder_cc.cc | 148 +++++++----------- .../gps_l1_ca_telemetry_decoder_cc.h | 7 +- .../gps_l1_ca_dll_pll_c_aid_tracking_cc.cc | 14 +- .../gps_l1_ca_dll_pll_c_aid_tracking_cc.h | 3 +- 7 files changed, 69 insertions(+), 117 deletions(-) diff --git a/conf/gnss-sdr_Hybrid_gr_complex.conf b/conf/gnss-sdr_Hybrid_gr_complex.conf index bb5b4031c..213710eaf 100644 --- a/conf/gnss-sdr_Hybrid_gr_complex.conf +++ b/conf/gnss-sdr_Hybrid_gr_complex.conf @@ -244,14 +244,14 @@ Tracking_1C.dump_filename=../data/epl_tracking_ch_ ;# Valid values are: [1,2,4,5,10,20] (integer divisors of the GPS L1 CA bit period (20 ms) ) ;# Longer integration period require more stable front-end LO -Tracking_1C.extend_correlation_ms=5 +Tracking_1C.extend_correlation_ms=10 ;#pll_bw_hz: PLL loop filter bandwidth [Hz] -Tracking_1C.pll_bw_hz=20; -Tracking_1C.pll_bw_narrow_hz=10; +Tracking_1C.pll_bw_hz=40; +Tracking_1C.pll_bw_narrow_hz=25; ;#dll_bw_hz: DLL loop filter bandwidth [Hz] -Tracking_1C.dll_bw_hz=3.0; +Tracking_1C.dll_bw_hz=2.0; Tracking_1C.dll_bw_narrow_hz=2.0; diff --git a/conf/gnss-sdr_Hybrid_nsr.conf b/conf/gnss-sdr_Hybrid_nsr.conf index 6cbe05638..b9dcfebab 100644 --- a/conf/gnss-sdr_Hybrid_nsr.conf +++ b/conf/gnss-sdr_Hybrid_nsr.conf @@ -238,7 +238,7 @@ Tracking_1C.item_type=gr_complex Tracking_1C.if=0 ;#dump: Enable or disable the Tracking internal binary data file logging [true] or [false] -Tracking_1C.dump=true +Tracking_1C.dump=false ;#dump_filename: Log path and filename. Notice that the tracking channel will add "x.dat" where x is the channel number. Tracking_1C.dump_filename=../data/epl_tracking_ch_ @@ -251,7 +251,7 @@ Tracking_1C.extend_correlation_ms=1 ;#pll_bw_hz: PLL loop filter bandwidth [Hz] Tracking_1C.pll_bw_hz=40; -Tracking_1C.pll_bw_narrow_hz=20; +Tracking_1C.pll_bw_narrow_hz=40; ;#dll_bw_hz: DLL loop filter bandwidth [Hz] Tracking_1C.dll_bw_hz=2.0; diff --git a/src/algorithms/channel/adapters/channel.cc b/src/algorithms/channel/adapters/channel.cc index 30d851505..34eb9711d 100644 --- a/src/algorithms/channel/adapters/channel.cc +++ b/src/algorithms/channel/adapters/channel.cc @@ -126,7 +126,7 @@ void Channel::connect(gr::top_block_sptr top_block) top_block->connect(trk_->get_right_block(), 0, nav_->get_left_block(), 0); DLOG(INFO) << "tracking -> telemetry_decoder"; - top_block->msg_connect(nav_->get_left_block(),pmt::mp("preamble_index"),trk_->get_right_block(),pmt::mp("preamble_index")); + top_block->msg_connect(nav_->get_left_block(),pmt::mp("preamble_timestamp_s"),trk_->get_right_block(),pmt::mp("preamble_timestamp_s")); DLOG(INFO) << "MSG FEEDBACK CHANNEL telemetry_decoder -> tracking"; connected_ = true; 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 8fa708d74..e66fe7e1f 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 @@ -29,17 +29,10 @@ * ------------------------------------------------------------------------- */ -/*! - * \todo Clean this code and move the telemetry definitions to GPS_L1_CA system definitions file - */ - - #include "gps_l1_ca_telemetry_decoder_cc.h" #include -#include #include #include -#include #include #include "control_message_factory.h" #include "gnss_synchro.h" @@ -49,15 +42,17 @@ #endif using google::LogMessage; -/*! - * \todo name and move the magic numbers to GPS_L1_CA.h - */ + gps_l1_ca_telemetry_decoder_cc_sptr gps_l1_ca_make_telemetry_decoder_cc(Gnss_Satellite satellite, boost::shared_ptr queue, bool dump) { return gps_l1_ca_telemetry_decoder_cc_sptr(new gps_l1_ca_telemetry_decoder_cc(satellite, queue, dump)); } +void gps_l1_ca_telemetry_decoder_cc::forecast (int noutput_items, gr_vector_int &ninput_items_required) +{ + ninput_items_required[0] = GPS_CA_PREAMBLE_LENGTH_SYMBOLS; //set the required sample history +} gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc( Gnss_Satellite satellite, @@ -66,29 +61,25 @@ gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc( gr::block("gps_navigation_cc", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { - // create asynchronous message ports - this->message_port_register_out(pmt::mp("preamble_index")); - + this->message_port_register_out(pmt::mp("preamble_timestamp_s")); // initialize internal vars d_queue = queue; d_dump = dump; d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - d_samples_per_bit = ( GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS ) / GPS_CA_TELEMETRY_RATE_BITS_SECOND; - //d_preamble_duration_seconds = (1.0 / GPS_CA_TELEMETRY_RATE_BITS_SECOND) * GPS_CA_PREAMBLE_LENGTH_BITS; - //std::cout<<"d_preamble_duration_seconds="<d_preambles_bits, (unsigned short int*)preambles_bits, GPS_CA_PREAMBLE_LENGTH_BITS*sizeof(unsigned short int)); - // preamble bits to sampled symbols (reversed) - d_preambles_symbols = (signed int*)malloc(sizeof(signed int) * GPS_CA_PREAMBLE_LENGTH_BITS * d_samples_per_bit); + // preamble bits to sampled symbols + d_preambles_symbols = (signed int*)malloc(sizeof(signed int) * GPS_CA_PREAMBLE_LENGTH_SYMBOLS); int n = 0; for (int i = 0; i < GPS_CA_PREAMBLE_LENGTH_BITS; i++) { - for (unsigned int j = 0; j < d_samples_per_bit; j++) + for (unsigned int j = 0; j < GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; j++) { - if (d_preambles_bits[GPS_CA_PREAMBLE_LENGTH_BITS-i-1] == 1) + if (d_preambles_bits[i] == 1) { d_preambles_symbols[n] = 1; } @@ -99,10 +90,7 @@ gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc( n++; } } - d_sample_counter = 0; - //d_preamble_code_phase_seconds = 0; d_stat = 0; - d_preamble_index = 0; d_symbol_accumulator = 0; d_symbol_accumulator_counter = 0; d_frame_bit_index = 0; @@ -121,7 +109,6 @@ gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc( d_channel = 0; Prn_timestamp_at_preamble_ms = 0.0; flag_PLL_180_deg_phase_locked = false; - //set_history(d_samples_per_bit*8); // At least a history of 8 bits are needed to correlate with the preamble } @@ -131,8 +118,6 @@ gps_l1_ca_telemetry_decoder_cc::~gps_l1_ca_telemetry_decoder_cc() d_dump_file.close(); } - - bool gps_l1_ca_telemetry_decoder_cc::gps_word_parityCheck(unsigned int gpsword) { unsigned int d1, d2, d3, d4, d5, d6, d7, t, parity; @@ -160,52 +145,29 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_i gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { int corr_value = 0; - int preamble_diff = 0; + int preamble_diff_ms = 0; Gnss_Synchro **out = (Gnss_Synchro **) &output_items[0]; - d_sample_counter++; //count for the processed samples // ########### Output the tracking data to navigation and PVT ########## const Gnss_Synchro **in = (const Gnss_Synchro **) &input_items[0]; //Get the input samples pointer - // record last symbols (clipped to +1,-1) and its correlation length to perform preamble correlation - if (in[0]->Flag_valid_symbol_output==true) - { - d_symbol_history.push_front(in[0]->Prompt_I); - d_correlation_length_ms_history.push_front(in[0]->correlation_length_ms); - if (static_cast(d_symbol_history.size())>GPS_CA_PREAMBLE_LENGTH_SYMBOLS) + //******* preamble correlation ******** + for (unsigned int i = 0; i < GPS_CA_PREAMBLE_LENGTH_SYMBOLS; i++) { - d_symbol_history.pop_back(); - d_correlation_length_ms_history.pop_back(); - } - - if (d_symbol_history.size()==GPS_CA_PREAMBLE_LENGTH_SYMBOLS) - { - - //******* preamble correlation (in reverse order due to the variable correlator length) - int input_symbol_index=0; - int preamble_index=0; - do{ - if (d_symbol_history.at(input_symbol_index) < 0) // symbols clipping + if (in[0][i].Flag_valid_symbol_output==true) + { + if (in[0][i].Prompt_I < 0) // symbols clipping { - //symbol weight expansion using its tracking correlation length - corr_value -= d_preambles_symbols[preamble_index]*d_correlation_length_ms_history.at(input_symbol_index); + corr_value -= d_preambles_symbols[i]*in[0][i].correlation_length_ms; } else { - //symbol weight expansion using its tracking correlation length - corr_value += d_preambles_symbols[preamble_index]*d_correlation_length_ms_history.at(input_symbol_index); + corr_value += d_preambles_symbols[i]*in[0][i].correlation_length_ms; } - preamble_index+=d_correlation_length_ms_history.at(input_symbol_index); - input_symbol_index++; - }while(preamble_index=GPS_CA_PREAMBLE_LENGTH_SYMBOLS) break; + } d_flag_preamble = false; //******* frame sync ****************** @@ -214,30 +176,28 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_i if (d_stat == 0) { d_GPS_FSM.Event_gps_word_preamble(); - d_preamble_index = d_sample_counter;//record the preamble sample stamp - DLOG(INFO) << "Preamble detection for SAT " << this->d_satellite <<" d_sample_counter="<correlation_length_ms; - d_frame_bit_index = 7; + d_preamble_time_seconds = in[0][0].Tracking_timestamp_secs;//record the preamble sample stamp + DLOG(INFO) << "Preamble detection for SAT " << this->d_satellite << "in[0][0].Tracking_timestamp_secs="<d_satellite << "in[0][0].Tracking_timestamp_secs="<correlation_length_ms; - d_frame_bit_index = 7; + d_preamble_time_seconds = in[0][0].Tracking_timestamp_secs;//record the PRN start sample index associated to the preamble if (!d_flag_frame_sync) { //send asynchronous message to tracking to inform of frame sync and extend correlation time - pmt::pmt_t value = pmt::from_long(d_preamble_index-1); - this->message_port_pub(pmt::mp("preamble_index"),value); + pmt::pmt_t value = pmt::from_double(d_preamble_time_seconds-0.001); + this->message_port_pub(pmt::mp("preamble_timestamp_s"),value); d_flag_frame_sync = true; if (corr_value < 0) @@ -252,9 +212,9 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_i DLOG(INFO) << " Frame sync SAT " << this->d_satellite << " with preamble start at " << d_preamble_time_seconds << " [s]"; } }else{ - if (preamble_diff > GPS_SUBFRAME_MS+1) + if (preamble_diff_ms > GPS_SUBFRAME_MS+1) { - DLOG(INFO) << "Lost of frame sync SAT " << this->d_satellite << " preamble_diff= " << preamble_diff<<" d_sample_counter="<d_satellite << " preamble_diff_ms= " << preamble_diff_ms<Flag_valid_symbol_output==true) + + if (in[0][0].Flag_valid_symbol_output==true) { // extended correlation to bit period is enabled in tracking! - d_symbol_accumulator += in[0]->Prompt_I; // accumulate the input value in d_symbol_accumulator - d_symbol_accumulator_counter+=in[0]->correlation_length_ms; + d_symbol_accumulator += in[0][0].Prompt_I; // accumulate the input value in d_symbol_accumulator + d_symbol_accumulator_counter+=in[0][0].correlation_length_ms; } - - if (d_symbol_accumulator_counter >= GPS_CA_TELEMETRY_SYMBOLS_PER_BIT ) + if (d_symbol_accumulator_counter == 20) { - if (d_symbol_accumulator > 0) - { //symbol to bit - d_GPS_frame_4bytes += 1; //insert the telemetry bit in LSB - } - d_symbol_accumulator = 0; - d_symbol_accumulator_counter = 0; + if (d_symbol_accumulator > 0) + { //symbol to bit + d_GPS_frame_4bytes += 1; //insert the telemetry bit in LSB + } + d_symbol_accumulator = 0; + d_symbol_accumulator_counter = 0; //******* bits to words ****** d_frame_bit_index++; - if (d_frame_bit_index == GPS_WORD_BITS) + if (d_frame_bit_index == 30) { - //std::cout<<"word bits = "<(d_GPS_frame_4bytes)< d_prn_start_sample_history; - double d_preamble_time_seconds; double d_TOW_at_Preamble; diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc index 79f675778..a15ec033b 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc @@ -93,7 +93,7 @@ void gps_l1_ca_dll_pll_c_aid_tracking_cc::msg_handler_preamble_index(pmt::pmt_t DLOG(INFO) << "Extended correlation enabled for Tracking CH " << d_channel << ": Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN)<< std::endl; if (d_enable_extended_integration==false) //avoid re-setting preamble indicator { - d_preamble_index=pmt::to_long(msg); + d_preamble_timestamp_s=pmt::to_double(msg); d_enable_extended_integration=true; d_preamble_synchronized=false; } @@ -117,9 +117,9 @@ gps_l1_ca_dll_pll_c_aid_tracking_cc::gps_l1_ca_dll_pll_c_aid_tracking_cc( gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { // create asynchronous message ports - this->message_port_register_in(pmt::mp("preamble_index")); + this->message_port_register_in(pmt::mp("preamble_timestamp_s")); - this->set_msg_handler(pmt::mp("preamble_index"), + this->set_msg_handler(pmt::mp("preamble_timestamp_s"), boost::bind(&gps_l1_ca_dll_pll_c_aid_tracking_cc::msg_handler_preamble_index, this, _1)); @@ -173,8 +173,7 @@ gps_l1_ca_dll_pll_c_aid_tracking_cc::gps_l1_ca_dll_pll_c_aid_tracking_cc( // sample synchronization d_sample_counter = 0; //(from trk to tlm) - // symbol synchronization (from tlm to trk) - d_symbol_counter =0; + //d_sample_counter_seconds = 0; d_acq_sample_stamp = 0; @@ -351,7 +350,6 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work (int noutput_items, gr_vec current_synchro_data.Flag_valid_symbol_output = false; *out[0] = current_synchro_data; consume_each(samples_offset); //shift input to perform alignment with local replica - d_symbol_counter++; return 1; } @@ -379,7 +377,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work (int noutput_items, gr_vec bool enable_dll_pll; if (d_enable_extended_integration==true) { - long int symbol_diff=d_symbol_counter-d_preamble_index; + long int symbol_diff=round(1000.0*((static_cast(d_sample_counter) + d_rem_code_phase_samples) / static_cast(d_fs_in)-d_preamble_timestamp_s)); if (symbol_diff>0 and symbol_diff % d_extend_correlation_ms == 0) { // compute coherent integration and enable tracking loop @@ -638,6 +636,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work (int noutput_items, gr_vec current_synchro_data.System = {'G'}; current_synchro_data.Flag_valid_pseudorange = false; + current_synchro_data.correlation_length_ms=1; *out[0] = current_synchro_data; } @@ -703,7 +702,6 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work (int noutput_items, gr_vec { LOG(WARNING) << "noutput_items = 0"; } - d_symbol_counter++; return 1; //output tracking result ALWAYS even in the case of d_enable_tracking==false } diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.h b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.h index 6183a2f28..c32f94ea7 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.h +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.h @@ -174,8 +174,7 @@ private: std::deque d_E_history; std::deque d_P_history; std::deque d_L_history; - long int d_preamble_index; - long int d_symbol_counter; + double d_preamble_timestamp_s; int d_extend_correlation_ms; bool d_enable_extended_integration; bool d_preamble_synchronized;