From 35f9f304418a28f26b8f9e0665e73403a3f93f67 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 12 Sep 2014 10:56:04 +0200 Subject: [PATCH] Some fixes and code cleaning --- .../galileo_e5a_dll_pll_tracking_cc.cc | 96 +++++++++---------- .../galileo_e5a_dll_pll_tracking_cc.h | 8 +- .../gps_l1_ca_dll_fll_pll_tracking_cc.h | 2 +- .../gnss_block/galileo_e5a_tracking_test.cc | 7 +- 4 files changed, 55 insertions(+), 58 deletions(-) diff --git a/src/algorithms/tracking/gnuradio_blocks/galileo_e5a_dll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/galileo_e5a_dll_pll_tracking_cc.cc index 7671b7f64..804d1f2d5 100644 --- a/src/algorithms/tracking/gnuradio_blocks/galileo_e5a_dll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/galileo_e5a_dll_pll_tracking_cc.cc @@ -77,7 +77,7 @@ galileo_e5a_dll_pll_make_tracking_cc( float early_late_space_chips) { return galileo_e5a_dll_pll_tracking_cc_sptr(new Galileo_E5a_Dll_Pll_Tracking_cc(if_freq, - fs_in, vector_length, queue, dump, dump_filename, pll_bw_hz, dll_bw_hz,pll_bw_init_hz, dll_bw_init_hz, ti_ms, early_late_space_chips)); + fs_in, vector_length, queue, dump, dump_filename, pll_bw_hz, dll_bw_hz, pll_bw_init_hz, dll_bw_init_hz, ti_ms, early_late_space_chips)); } @@ -130,8 +130,8 @@ Galileo_E5a_Dll_Pll_Tracking_cc::Galileo_E5a_Dll_Pll_Tracking_cc( // Initialization of local code replica // Get space for a vector with the E5a primary code replicas sampled 1x/chip - d_codeQ = (gr_complex*)volk_malloc((Galileo_E5a_CODE_LENGTH_CHIPS + 2)* sizeof(gr_complex), volk_get_alignment()); - d_codeI = (gr_complex*)volk_malloc((Galileo_E5a_CODE_LENGTH_CHIPS + 2)* sizeof(gr_complex), volk_get_alignment()); + d_codeQ = new gr_complex[(int)Galileo_E5a_CODE_LENGTH_CHIPS + 2]; + d_codeI = new gr_complex[(int)Galileo_E5a_CODE_LENGTH_CHIPS + 2]; d_early_code = (gr_complex*)volk_malloc(2 * d_vector_length * sizeof(gr_complex), volk_get_alignment()); d_late_code = (gr_complex*)volk_malloc(2 * d_vector_length * sizeof(gr_complex), volk_get_alignment()); @@ -140,11 +140,14 @@ Galileo_E5a_Dll_Pll_Tracking_cc::Galileo_E5a_Dll_Pll_Tracking_cc( d_carr_sign = (gr_complex*)volk_malloc(2 * d_vector_length * sizeof(gr_complex), volk_get_alignment()); // correlator outputs (complex number) - d_Early = (gr_complex*)volk_malloc(sizeof(gr_complex), volk_get_alignment()); - d_Prompt = (gr_complex*)volk_malloc(sizeof(gr_complex), volk_get_alignment()); - d_Late = (gr_complex*)volk_malloc(sizeof(gr_complex), volk_get_alignment()); - d_Prompt_data = (gr_complex*)volk_malloc(sizeof(gr_complex), volk_get_alignment()); - + //d_Early = (gr_complex*)volk_malloc(sizeof(gr_complex), volk_get_alignment()); + //d_Prompt = (gr_complex*)volk_malloc(sizeof(gr_complex), volk_get_alignment()); + //d_Late = (gr_complex*)volk_malloc(sizeof(gr_complex), volk_get_alignment()); + //d_Prompt_data = (gr_complex*)volk_malloc(sizeof(gr_complex), volk_get_alignment()); + d_Early = gr_complex(0, 0); + d_Prompt = gr_complex(0, 0); + d_Late = gr_complex(0, 0); + d_Prompt_data = gr_complex(0, 0); //--- Perform initializations ------------------------------ // define initial code frequency basis of NCO d_code_freq_chips = Galileo_E5a_CODE_CHIP_RATE_HZ; @@ -187,13 +190,8 @@ Galileo_E5a_Dll_Pll_Tracking_cc::~Galileo_E5a_Dll_Pll_Tracking_cc () volk_free(d_early_code); volk_free(d_carr_sign); volk_free(d_prompt_data_code); - volk_free(d_Prompt_data); - volk_free(d_Early); - volk_free(d_Prompt); - volk_free(d_Late); - volk_free(d_codeQ); - volk_free(d_codeI); - + delete[] d_codeI; + delete[] d_codeQ; delete[] d_Prompt_buffer; } @@ -315,9 +313,9 @@ void Galileo_E5a_Dll_Pll_Tracking_cc::acquire_secondary() // 3. Serial search int out_corr; int current_best_ = 0; - for (unsigned int i=0; i cmf = std::make_shared(); if (d_queue != gr::msg_queue::sptr()) { d_queue->handle(cmf->GetQueueMessage(d_channel, 2)); } - delete cmf; d_carrier_lock_fail_counter = 0; d_state = 0; // TODO: check if disabling tracking is consistent with the channel state machine } @@ -652,12 +649,11 @@ int Galileo_E5a_Dll_Pll_Tracking_cc::general_work (int noutput_items, gr_vector_ { std::cout << "Loss of lock in channel " << d_channel << "!" << std::endl; LOG(INFO) << "Loss of lock in channel " << d_channel << "!"; - ControlMessageFactory* cmf = new ControlMessageFactory(); + std::shared_ptr cmf = std::make_shared(); if (d_queue != gr::msg_queue::sptr()) { d_queue->handle(cmf->GetQueueMessage(d_channel, 2)); } - delete cmf; d_carrier_lock_fail_counter = 0; d_state = 0; } @@ -665,7 +661,7 @@ int Galileo_E5a_Dll_Pll_Tracking_cc::general_work (int noutput_items, gr_vector_ } d_cn0_estimation_counter = 0; } - if (d_secondary_lock && (d_secondary_delay%Galileo_E5a_I_SECONDARY_CODE_LENGTH)==0) + if (d_secondary_lock && (d_secondary_delay % Galileo_E5a_I_SECONDARY_CODE_LENGTH) == 0) { d_first_transition = true; } @@ -673,8 +669,8 @@ int Galileo_E5a_Dll_Pll_Tracking_cc::general_work (int noutput_items, gr_vector_ // The first Prompt output not equal to 0 is synchronized with the transition of a navigation data bit. if (d_secondary_lock && d_first_transition) { - current_synchro_data.Prompt_I = (double)((*d_Prompt_data).real()); - current_synchro_data.Prompt_Q = (double)((*d_Prompt_data).imag()); + current_synchro_data.Prompt_I = (double)((d_Prompt_data).real()); + current_synchro_data.Prompt_Q = (double)((d_Prompt_data).imag()); // Tracking_timestamp_secs is aligned with the PRN start sample current_synchro_data.Tracking_timestamp_secs = ((double)d_sample_counter + (double)d_current_prn_length_samples + (double)d_rem_code_phase_samples)/(double)d_fs_in; // This tracking block aligns the Tracking_timestamp_secs with the start sample of the PRN, thus, Code_phase_secs=0 @@ -688,7 +684,7 @@ int Galileo_E5a_Dll_Pll_Tracking_cc::general_work (int noutput_items, gr_vector_ // make an output to not stop the rest of the processing blocks current_synchro_data.Prompt_I = 0.0; current_synchro_data.Prompt_Q = 0.0; - current_synchro_data.Tracking_timestamp_secs = (double)d_sample_counter/d_fs_in; + current_synchro_data.Tracking_timestamp_secs = (double)d_sample_counter / d_fs_in; current_synchro_data.Carrier_phase_rads = 0.0; current_synchro_data.Code_phase_secs = 0.0; current_synchro_data.CN0_dB_hz = 0.0; @@ -705,13 +701,13 @@ int Galileo_E5a_Dll_Pll_Tracking_cc::general_work (int noutput_items, gr_vector_ float prompt_Q; float tmp_float; double tmp_double; - prompt_I = (*d_Prompt_data).real(); - prompt_Q = (*d_Prompt_data).imag(); + prompt_I = (d_Prompt_data).real(); + prompt_Q = (d_Prompt_data).imag(); if (d_integration_counter == d_current_ti_ms) { - tmp_E = std::abs(*d_Early); - tmp_P = std::abs(*d_Prompt); - tmp_L = std::abs(*d_Late); + tmp_E = std::abs(d_Early); + tmp_P = std::abs(d_Prompt); + tmp_L = std::abs(d_Late); } try { @@ -746,7 +742,7 @@ int Galileo_E5a_Dll_Pll_Tracking_cc::general_work (int noutput_items, gr_vector_ // AUX vars (for debug purposes) tmp_float = d_rem_code_phase_samples; d_dump_file.write((char*)&tmp_float, sizeof(float)); - tmp_double=(double)(d_sample_counter+d_current_prn_length_samples); + tmp_double = (double)(d_sample_counter + d_current_prn_length_samples); d_dump_file.write((char*)&tmp_double, sizeof(double)); } catch (std::ifstream::failure e) @@ -755,7 +751,7 @@ int Galileo_E5a_Dll_Pll_Tracking_cc::general_work (int noutput_items, gr_vector_ } } - d_secondary_delay = (d_secondary_delay + 1)%Galileo_E5a_Q_SECONDARY_CODE_LENGTH; + d_secondary_delay = (d_secondary_delay + 1) % Galileo_E5a_Q_SECONDARY_CODE_LENGTH; d_sample_counter += d_current_prn_length_samples; //count for the processed samples consume_each(d_current_prn_length_samples); // this is necessary in gr::block derivates return 1; //output tracking result ALWAYS even in the case of d_enable_tracking==false diff --git a/src/algorithms/tracking/gnuradio_blocks/galileo_e5a_dll_pll_tracking_cc.h b/src/algorithms/tracking/gnuradio_blocks/galileo_e5a_dll_pll_tracking_cc.h index 5f686e8b2..f60921919 100644 --- a/src/algorithms/tracking/gnuradio_blocks/galileo_e5a_dll_pll_tracking_cc.h +++ b/src/algorithms/tracking/gnuradio_blocks/galileo_e5a_dll_pll_tracking_cc.h @@ -151,10 +151,10 @@ private: gr_complex* d_prompt_data_code; gr_complex* d_carr_sign; - gr_complex *d_Early; - gr_complex *d_Prompt; - gr_complex *d_Late; - gr_complex *d_Prompt_data; + gr_complex d_Early; + gr_complex d_Prompt; + gr_complex d_Late; + gr_complex d_Prompt_data; float tmp_E; float tmp_P; diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_fll_pll_tracking_cc.h b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_fll_pll_tracking_cc.h index 530f98a47..145ab314a 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_fll_pll_tracking_cc.h +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_fll_pll_tracking_cc.h @@ -132,7 +132,7 @@ private: void CN0_estimation_and_lock_detectors(); // class private vars - Gnss_Synchro *d_acquisition_gnss_synchro; + Gnss_Synchro* d_acquisition_gnss_synchro; boost::shared_ptr d_queue; concurrent_queue *d_channel_internal_queue; unsigned int d_vector_length; diff --git a/src/tests/gnss_block/galileo_e5a_tracking_test.cc b/src/tests/gnss_block/galileo_e5a_tracking_test.cc index e0b1660e4..f2e23d857 100644 --- a/src/tests/gnss_block/galileo_e5a_tracking_test.cc +++ b/src/tests/gnss_block/galileo_e5a_tracking_test.cc @@ -85,6 +85,7 @@ void GalileoE5aTrackingTest::init() gnss_synchro.System = 'E'; std::string signal = "5Q"; signal.copy(gnss_synchro.Signal, 2, 0); + gnss_synchro.PRN = 11; config->set_property("GNSS-SDR.internal_fs_hz", "32000000"); config->set_property("Tracking_Galileo.item_type", "gr_complex"); @@ -92,12 +93,12 @@ void GalileoE5aTrackingTest::init() config->set_property("Tracking_Galileo.dump_filename", "../data/e5a_tracking_ch_"); config->set_property("Tracking_Galileo.implementation", "Galileo_E5a_DLL_PLL_Tracking"); config->set_property("Tracking_Galileo.early_late_space_chips", "0.5"); - + config->set_property("Tracking_Galileo.order", "2"); config->set_property("Tracking_Galileo.pll_bw_hz_init","20.0"); - config->set_property("Tracking_Galileo.ti_ms", "1"); - config->set_property("Tracking_Galileo.dll_bw_hz_init","2.0"); config->set_property("Tracking_Galileo.pll_bw_hz", "5"); + config->set_property("Tracking_Galileo.dll_bw_hz_init","2.0"); config->set_property("Tracking_Galileo.dll_bw_hz", "2"); + config->set_property("Tracking_Galileo.ti_ms", "1"); } TEST_F(GalileoE5aTrackingTest, ValidationOfResults)