diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc index efb27d868..eb4aa4b18 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc @@ -47,37 +47,37 @@ using google::LogMessage; galileo_e5a_noncoherentIQ_acquisition_caf_cc_sptr galileo_e5a_noncoherentIQ_make_acquisition_caf_cc( - unsigned int sampled_ms, - unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, - int samples_per_ms, int samples_per_code, - bool bit_transition_flag, - gr::msg_queue::sptr queue, bool dump, - std::string dump_filename, - bool both_signal_components_, - int CAF_window_hz_, - int Zero_padding_) + unsigned int sampled_ms, + unsigned int max_dwells, + unsigned int doppler_max, long freq, long fs_in, + int samples_per_ms, int samples_per_code, + bool bit_transition_flag, + gr::msg_queue::sptr queue, bool dump, + std::string dump_filename, + bool both_signal_components_, + int CAF_window_hz_, + int Zero_padding_) { return galileo_e5a_noncoherentIQ_acquisition_caf_cc_sptr( new galileo_e5a_noncoherentIQ_acquisition_caf_cc(sampled_ms, max_dwells, doppler_max, freq, fs_in, samples_per_ms, - samples_per_code, bit_transition_flag, queue, dump, dump_filename, both_signal_components_, CAF_window_hz_, Zero_padding_)); + samples_per_code, bit_transition_flag, queue, dump, dump_filename, both_signal_components_, CAF_window_hz_, Zero_padding_)); } galileo_e5a_noncoherentIQ_acquisition_caf_cc::galileo_e5a_noncoherentIQ_acquisition_caf_cc( - unsigned int sampled_ms, - unsigned int max_dwells, - unsigned int doppler_max, long freq, long fs_in, - int samples_per_ms, int samples_per_code, - bool bit_transition_flag, - gr::msg_queue::sptr queue, bool dump, - std::string dump_filename, - bool both_signal_components_, - int CAF_window_hz_, - int Zero_padding_) : - gr::block("galileo_e5a_noncoherentIQ_acquisition_caf_cc", - gr::io_signature::make(1, 1, sizeof(gr_complex)), - gr::io_signature::make(0, 0, sizeof(gr_complex))) + unsigned int sampled_ms, + unsigned int max_dwells, + unsigned int doppler_max, long freq, long fs_in, + int samples_per_ms, int samples_per_code, + bool bit_transition_flag, + gr::msg_queue::sptr queue, bool dump, + std::string dump_filename, + bool both_signal_components_, + int CAF_window_hz_, + int Zero_padding_) : + gr::block("galileo_e5a_noncoherentIQ_acquisition_caf_cc", + gr::io_signature::make(1, 1, sizeof(gr_complex)), + gr::io_signature::make(0, 0, sizeof(gr_complex))) { d_sample_counter = 0; // SAMPLE COUNTER d_active = false; @@ -91,13 +91,13 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc::galileo_e5a_noncoherentIQ_acquisit d_well_count = 0; d_doppler_max = doppler_max; if (Zero_padding_ > 0) - { - d_sampled_ms = 1; - } + { + d_sampled_ms = 1; + } else - { - d_sampled_ms = sampled_ms; - } + { + d_sampled_ms = sampled_ms; + } d_fft_size = sampled_ms * d_samples_per_ms; d_mag = 0; d_input_power = 0.0; @@ -112,21 +112,21 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc::galileo_e5a_noncoherentIQ_acquisit d_magnitudeIA = static_cast(volk_malloc(d_fft_size * sizeof(float), volk_get_alignment())); if (d_both_signal_components == true) - { - d_fft_code_Q_A = static_cast(volk_malloc(d_fft_size * sizeof(gr_complex), volk_get_alignment())); - d_magnitudeQA = static_cast(volk_malloc(d_fft_size * sizeof(float), volk_get_alignment())); - } + { + d_fft_code_Q_A = static_cast(volk_malloc(d_fft_size * sizeof(gr_complex), volk_get_alignment())); + d_magnitudeQA = static_cast(volk_malloc(d_fft_size * sizeof(float), volk_get_alignment())); + } // IF COHERENT INTEGRATION TIME > 1 if (d_sampled_ms > 1) - { - d_fft_code_I_B = static_cast(volk_malloc(d_fft_size * sizeof(gr_complex), volk_get_alignment())); - d_magnitudeIB = static_cast(volk_malloc(d_fft_size * sizeof(float), volk_get_alignment())); - if (d_both_signal_components == true) - { - d_fft_code_Q_B = static_cast(volk_malloc(d_fft_size * sizeof(gr_complex), volk_get_alignment())); - d_magnitudeQB = static_cast(volk_malloc(d_fft_size * sizeof(float), volk_get_alignment())); - } - } + { + d_fft_code_I_B = static_cast(volk_malloc(d_fft_size * sizeof(gr_complex), volk_get_alignment())); + d_magnitudeIB = static_cast(volk_malloc(d_fft_size * sizeof(float), volk_get_alignment())); + if (d_both_signal_components == true) + { + d_fft_code_Q_B = static_cast(volk_malloc(d_fft_size * sizeof(gr_complex), volk_get_alignment())); + d_magnitudeQB = static_cast(volk_malloc(d_fft_size * sizeof(float), volk_get_alignment())); + } + } // Direct FFT d_fft_if = new gr::fft::fft_complex(d_fft_size, true); @@ -154,21 +154,21 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc::~galileo_e5a_noncoherentIQ_acquisi volk_free(d_fft_code_I_A); volk_free(d_magnitudeIA); if (d_both_signal_components == true) - { - volk_free(d_fft_code_Q_A); - volk_free(d_magnitudeQA); - } + { + volk_free(d_fft_code_Q_A); + volk_free(d_magnitudeQA); + } // IF INTEGRATION TIME > 1 if (d_sampled_ms > 1) - { - volk_free(d_fft_code_I_B); - volk_free(d_magnitudeIB); - if (d_both_signal_components == true) - { - volk_free(d_fft_code_Q_B); - volk_free(d_magnitudeQB); - } - } + { + volk_free(d_fft_code_I_B); + volk_free(d_magnitudeIB); + if (d_both_signal_components == true) + { + volk_free(d_fft_code_Q_B); + volk_free(d_magnitudeQB); + } + } if (d_CAF_window_hz > 0) { volk_free(d_CAF_vector); @@ -250,11 +250,11 @@ void galileo_e5a_noncoherentIQ_acquisition_caf_cc::init() // Count the number of bins d_num_doppler_bins = 0; for (int doppler = static_cast(-d_doppler_max); - doppler <= static_cast(d_doppler_max); - doppler += d_doppler_step) - { - d_num_doppler_bins++; - } + doppler <= static_cast(d_doppler_max); + doppler += d_doppler_step) + { + d_num_doppler_bins++; + } // Create the carrier Doppler wipeoff signals d_grid_doppler_wipeoffs = new gr_complex*[d_num_doppler_bins]; @@ -262,22 +262,21 @@ void galileo_e5a_noncoherentIQ_acquisition_caf_cc::init() { d_grid_doppler_wipeoffs[doppler_index] = static_cast(volk_malloc(d_fft_size * sizeof(gr_complex), volk_get_alignment())); int doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; - complex_exp_gen_conj(d_grid_doppler_wipeoffs[doppler_index], - d_freq + doppler, d_fs_in, d_fft_size); + complex_exp_gen_conj(d_grid_doppler_wipeoffs[doppler_index], d_freq + doppler, d_fs_in, d_fft_size); } /* CAF Filtering to resolve doppler ambiguity. Phase and quadrature must be processed * separately before non-coherent integration */ -// if (d_CAF_filter) + // if (d_CAF_filter) if (d_CAF_window_hz > 0) - { - d_CAF_vector = static_cast(volk_malloc(d_num_doppler_bins * sizeof(float), volk_get_alignment())); - d_CAF_vector_I = static_cast(volk_malloc(d_num_doppler_bins * sizeof(float), volk_get_alignment())); - if (d_both_signal_components == true) - { - d_CAF_vector_Q = static_cast(volk_malloc(d_num_doppler_bins * sizeof(float), volk_get_alignment())); - } - } + { + d_CAF_vector = static_cast(volk_malloc(d_num_doppler_bins * sizeof(float), volk_get_alignment())); + d_CAF_vector_I = static_cast(volk_malloc(d_num_doppler_bins * sizeof(float), volk_get_alignment())); + if (d_both_signal_components == true) + { + d_CAF_vector_Q = static_cast(volk_malloc(d_num_doppler_bins * sizeof(float), volk_get_alignment())); + } + } } @@ -331,446 +330,445 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items */ switch (d_state) { - case 0: - { - if (d_active) - { - //restart acquisition variables - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; - d_well_count = 0; - d_mag = 0.0; - d_input_power = 0.0; - d_test_statistics = 0.0; - d_state = 1; - } - d_sample_counter += ninput_items[0]; // sample counter - consume_each(ninput_items[0]); + case 0: + { + if (d_active) + { + //restart acquisition variables + d_gnss_synchro->Acq_delay_samples = 0.0; + d_gnss_synchro->Acq_doppler_hz = 0.0; + d_gnss_synchro->Acq_samplestamp_samples = 0; + d_well_count = 0; + d_mag = 0.0; + d_input_power = 0.0; + d_test_statistics = 0.0; + d_state = 1; + } + d_sample_counter += ninput_items[0]; // sample counter + consume_each(ninput_items[0]); - break; - } - case 1: - { - const gr_complex *in = (const gr_complex *)input_items[0]; //Get the input samples pointer - unsigned int buff_increment; - if (ninput_items[0] + d_buffer_count <= d_fft_size) - { - buff_increment = ninput_items[0]; - } - else - { - buff_increment = (d_fft_size - d_buffer_count); - } - memcpy(&d_inbuffer[d_buffer_count], in, sizeof(gr_complex) * buff_increment); - // If buffer will be full in next iteration - if (d_buffer_count >= d_fft_size - d_gr_stream_buffer) - { - d_state=2; - } - d_buffer_count += buff_increment; - d_sample_counter += buff_increment; // sample counter - consume_each(buff_increment); - break; - } - case 2: - { - // Fill last part of the buffer and reset counter - const gr_complex *in = (const gr_complex *)input_items[0]; //Get the input samples pointer - if (d_buffer_count < d_fft_size) - { - memcpy(&d_inbuffer[d_buffer_count], in, sizeof(gr_complex)*(d_fft_size-d_buffer_count)); - } - d_sample_counter += d_fft_size-d_buffer_count; // sample counter + break; + } + case 1: + { + const gr_complex *in = (const gr_complex *)input_items[0]; //Get the input samples pointer + unsigned int buff_increment; + if (ninput_items[0] + d_buffer_count <= d_fft_size) + { + buff_increment = ninput_items[0]; + } + else + { + buff_increment = (d_fft_size - d_buffer_count); + } + memcpy(&d_inbuffer[d_buffer_count], in, sizeof(gr_complex) * buff_increment); + // If buffer will be full in next iteration + if (d_buffer_count >= d_fft_size - d_gr_stream_buffer) + { + d_state=2; + } + d_buffer_count += buff_increment; + d_sample_counter += buff_increment; // sample counter + consume_each(buff_increment); + break; + } + case 2: + { + // Fill last part of the buffer and reset counter + const gr_complex *in = (const gr_complex *)input_items[0]; //Get the input samples pointer + if (d_buffer_count < d_fft_size) + { + memcpy(&d_inbuffer[d_buffer_count], in, sizeof(gr_complex)*(d_fft_size-d_buffer_count)); + } + d_sample_counter += d_fft_size-d_buffer_count; // sample counter - // initialize acquisition algorithm - int doppler; - unsigned int indext = 0; - unsigned int indext_IA = 0; - unsigned int indext_IB = 0; - unsigned int indext_QA = 0; - unsigned int indext_QB = 0; - float magt = 0.0; - float magt_IA = 0.0; - float magt_IB = 0.0; - float magt_QA = 0.0; - float magt_QB = 0.0; - float fft_normalization_factor = static_cast(d_fft_size) * static_cast(d_fft_size); - d_input_power = 0.0; - d_mag = 0.0; - d_well_count++; + // initialize acquisition algorithm + int doppler; + unsigned int indext = 0; + unsigned int indext_IA = 0; + unsigned int indext_IB = 0; + unsigned int indext_QA = 0; + unsigned int indext_QB = 0; + float magt = 0.0; + float magt_IA = 0.0; + float magt_IB = 0.0; + float magt_QA = 0.0; + float magt_QB = 0.0; + float fft_normalization_factor = static_cast(d_fft_size) * static_cast(d_fft_size); + d_input_power = 0.0; + d_mag = 0.0; + d_well_count++; - DLOG(INFO) << "Channel: " << d_channel - << " , doing acquisition of satellite: " << d_gnss_synchro->System << " "<< d_gnss_synchro->PRN - << " ,sample stamp: " << d_sample_counter << ", threshold: " - << d_threshold << ", doppler_max: " << d_doppler_max - << ", doppler_step: " << d_doppler_step; + DLOG(INFO) << "Channel: " << d_channel + << " , doing acquisition of satellite: " << d_gnss_synchro->System << " "<< d_gnss_synchro->PRN + << " ,sample stamp: " << d_sample_counter << ", threshold: " + << d_threshold << ", doppler_max: " << d_doppler_max + << ", doppler_step: " << d_doppler_step; - // 1- Compute the input signal power estimation - volk_32fc_magnitude_squared_32f(d_magnitudeIA, d_inbuffer, d_fft_size); - volk_32f_accumulator_s32f(&d_input_power, d_magnitudeIA, d_fft_size); - d_input_power /= static_cast(d_fft_size); + // 1- Compute the input signal power estimation + volk_32fc_magnitude_squared_32f(d_magnitudeIA, d_inbuffer, d_fft_size); + volk_32f_accumulator_s32f(&d_input_power, d_magnitudeIA, d_fft_size); + d_input_power /= static_cast(d_fft_size); - // 2- Doppler frequency search loop - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) - { - // doppler search steps + // 2- Doppler frequency search loop + for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + { + // doppler search steps - doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; - volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), d_inbuffer, - d_grid_doppler_wipeoffs[doppler_index], d_fft_size); + volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), d_inbuffer, + d_grid_doppler_wipeoffs[doppler_index], d_fft_size); - // 3- Perform the FFT-based convolution (parallel time search) - // Compute the FFT of the carrier wiped--off incoming signal - d_fft_if->execute(); + // 3- Perform the FFT-based convolution (parallel time search) + // Compute the FFT of the carrier wiped--off incoming signal + d_fft_if->execute(); - // CODE IA - // Multiply carrier wiped--off, Fourier transformed incoming signal - // with the local FFT'd code reference using SIMD operations with VOLK library - volk_32fc_x2_multiply_32fc(d_ifft->get_inbuf(), - d_fft_if->get_outbuf(), d_fft_code_I_A, d_fft_size); + // CODE IA + // Multiply carrier wiped--off, Fourier transformed incoming signal + // with the local FFT'd code reference using SIMD operations with VOLK library + volk_32fc_x2_multiply_32fc(d_ifft->get_inbuf(), + d_fft_if->get_outbuf(), d_fft_code_I_A, d_fft_size); - // compute the inverse FFT - d_ifft->execute(); + // compute the inverse FFT + d_ifft->execute(); - // Search maximum - volk_32fc_magnitude_squared_32f(d_magnitudeIA, d_ifft->get_outbuf(), d_fft_size); - volk_32f_index_max_16u(&indext_IA, d_magnitudeIA, d_fft_size); - // Normalize the maximum value to correct the scale factor introduced by FFTW - magt_IA = d_magnitudeIA[indext_IA] / (fft_normalization_factor * fft_normalization_factor); + // Search maximum + volk_32fc_magnitude_squared_32f(d_magnitudeIA, d_ifft->get_outbuf(), d_fft_size); + volk_32f_index_max_16u(&indext_IA, d_magnitudeIA, d_fft_size); + // Normalize the maximum value to correct the scale factor introduced by FFTW + magt_IA = d_magnitudeIA[indext_IA] / (fft_normalization_factor * fft_normalization_factor); - if (d_both_signal_components == true) - { - // REPEAT FOR ALL CODES. CODE_QA - volk_32fc_x2_multiply_32fc(d_ifft->get_inbuf(), - d_fft_if->get_outbuf(), d_fft_code_Q_A, d_fft_size); - d_ifft->execute(); - volk_32fc_magnitude_squared_32f(d_magnitudeQA, d_ifft->get_outbuf(), d_fft_size); - volk_32f_index_max_16u(&indext_QA, d_magnitudeQA, d_fft_size); - magt_QA = d_magnitudeQA[indext_QA] / (fft_normalization_factor * fft_normalization_factor); - } - if (d_sampled_ms > 1) // If Integration time > 1 code - { - // REPEAT FOR ALL CODES. CODE_IB - volk_32fc_x2_multiply_32fc(d_ifft->get_inbuf(), - d_fft_if->get_outbuf(), d_fft_code_I_B, d_fft_size); - d_ifft->execute(); - volk_32fc_magnitude_squared_32f(d_magnitudeIB, d_ifft->get_outbuf(), d_fft_size); - volk_32f_index_max_16u(&indext_IB, d_magnitudeIB, d_fft_size); - magt_IB = d_magnitudeIB[indext_IB] / (fft_normalization_factor * fft_normalization_factor); + if (d_both_signal_components == true) + { + // REPEAT FOR ALL CODES. CODE_QA + volk_32fc_x2_multiply_32fc(d_ifft->get_inbuf(), + d_fft_if->get_outbuf(), d_fft_code_Q_A, d_fft_size); + d_ifft->execute(); + volk_32fc_magnitude_squared_32f(d_magnitudeQA, d_ifft->get_outbuf(), d_fft_size); + volk_32f_index_max_16u(&indext_QA, d_magnitudeQA, d_fft_size); + magt_QA = d_magnitudeQA[indext_QA] / (fft_normalization_factor * fft_normalization_factor); + } + if (d_sampled_ms > 1) // If Integration time > 1 code + { + // REPEAT FOR ALL CODES. CODE_IB + volk_32fc_x2_multiply_32fc(d_ifft->get_inbuf(), + d_fft_if->get_outbuf(), d_fft_code_I_B, d_fft_size); + d_ifft->execute(); + volk_32fc_magnitude_squared_32f(d_magnitudeIB, d_ifft->get_outbuf(), d_fft_size); + volk_32f_index_max_16u(&indext_IB, d_magnitudeIB, d_fft_size); + magt_IB = d_magnitudeIB[indext_IB] / (fft_normalization_factor * fft_normalization_factor); - if (d_both_signal_components == true) - { - // REPEAT FOR ALL CODES. CODE_QB - volk_32fc_x2_multiply_32fc(d_ifft->get_inbuf(), - d_fft_if->get_outbuf(), d_fft_code_Q_B, d_fft_size); - d_ifft->execute(); - volk_32fc_magnitude_squared_32f(d_magnitudeQB, d_ifft->get_outbuf(), d_fft_size); - volk_32f_index_max_16u(&indext_QB, d_magnitudeQB, d_fft_size); - magt_QB = d_magnitudeIB[indext_QB] / (fft_normalization_factor * fft_normalization_factor); - } - } + if (d_both_signal_components == true) + { + // REPEAT FOR ALL CODES. CODE_QB + volk_32fc_x2_multiply_32fc(d_ifft->get_inbuf(), + d_fft_if->get_outbuf(), d_fft_code_Q_B, d_fft_size); + d_ifft->execute(); + volk_32fc_magnitude_squared_32f(d_magnitudeQB, d_ifft->get_outbuf(), d_fft_size); + volk_32f_index_max_16u(&indext_QB, d_magnitudeQB, d_fft_size); + magt_QB = d_magnitudeIB[indext_QB] / (fft_normalization_factor * fft_normalization_factor); + } + } - // Integrate noncoherently the two best combinations (I² + Q²) - // and store the result in the I channel. - // If CAF filter to resolve doppler ambiguity is needed, - // peak is stored before non-coherent integration. - if (d_sampled_ms > 1) // T_integration > 1 code - { - if (magt_IA >= magt_IB) - { -// if (d_CAF_filter) {d_CAF_vector_I[doppler_index] = magt_IA;} - if (d_CAF_window_hz > 0) {d_CAF_vector_I[doppler_index] = d_magnitudeIA[indext_IA];} - if (d_both_signal_components) - { - // Integrate non-coherently I+Q - if (magt_QA >= magt_QB) - { -// if (d_CAF_filter) {d_CAF_vector_Q[doppler_index] = magt_QA;} - if (d_CAF_window_hz > 0) {d_CAF_vector_Q[doppler_index] = d_magnitudeQA[indext_QA];} - for (unsigned int i=0; i 0) {d_CAF_vector_Q[doppler_index] = d_magnitudeQB[indext_QB];} - for (unsigned int i=0; i 0) {d_CAF_vector_I[doppler_index] = d_magnitudeIB[indext_IB];} - if (d_both_signal_components) - { - // Integrate non-coherently I+Q - if (magt_QA >= magt_QB) - { - //if (d_CAF_filter) {d_CAF_vector_Q[doppler_index] = magt_QA;} - if (d_CAF_window_hz > 0) {d_CAF_vector_Q[doppler_index] = d_magnitudeQA[indext_QA];} - for (unsigned int i=0; i 0) {d_CAF_vector_Q[doppler_index] = d_magnitudeQB[indext_QB];} - for (unsigned int i=0; i 0) {d_CAF_vector_I[doppler_index] = d_magnitudeIA[indext_IA];} - if (d_both_signal_components) - { -// if (d_CAF_filter) {d_CAF_vector_Q[doppler_index] = magt_QA;} - if (d_CAF_window_hz > 0) {d_CAF_vector_Q[doppler_index] = d_magnitudeQA[indext_QA];} - // NON-Coherent integration of only 1 code - for (unsigned int i=0; i 1) // T_integration > 1 code + { + if (magt_IA >= magt_IB) + { + // if (d_CAF_filter) {d_CAF_vector_I[doppler_index] = magt_IA;} + if (d_CAF_window_hz > 0) {d_CAF_vector_I[doppler_index] = d_magnitudeIA[indext_IA];} + if (d_both_signal_components) + { + // Integrate non-coherently I+Q + if (magt_QA >= magt_QB) + { + // if (d_CAF_filter) {d_CAF_vector_Q[doppler_index] = magt_QA;} + if (d_CAF_window_hz > 0) {d_CAF_vector_Q[doppler_index] = d_magnitudeQA[indext_QA];} + for (unsigned int i=0; i 0) {d_CAF_vector_Q[doppler_index] = d_magnitudeQB[indext_QB];} + for (unsigned int i=0; i 0) {d_CAF_vector_I[doppler_index] = d_magnitudeIB[indext_IB];} + if (d_both_signal_components) + { + // Integrate non-coherently I+Q + if (magt_QA >= magt_QB) + { + //if (d_CAF_filter) {d_CAF_vector_Q[doppler_index] = magt_QA;} + if (d_CAF_window_hz > 0) {d_CAF_vector_Q[doppler_index] = d_magnitudeQA[indext_QA];} + for (unsigned int i=0; i 0) {d_CAF_vector_Q[doppler_index] = d_magnitudeQB[indext_QB];} + for (unsigned int i=0; i 0) {d_CAF_vector_I[doppler_index] = d_magnitudeIA[indext_IA];} + if (d_both_signal_components) + { + // if (d_CAF_filter) {d_CAF_vector_Q[doppler_index] = magt_QA;} + if (d_CAF_window_hz > 0) {d_CAF_vector_Q[doppler_index] = d_magnitudeQA[indext_QA];} + // NON-Coherent integration of only 1 code + for (unsigned int i=0; iAcq_delay_samples = static_cast(indext % d_samples_per_code); - d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); - d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; + // 4- record the maximum peak and the associated synchronization parameters + if (d_mag < magt) + { + d_mag = magt; + // In case that d_bit_transition_flag = true, we compare the potentially + // new maximum test statistics (d_mag/d_input_power) with the value in + // d_test_statistics. When the second dwell is being processed, the value + // of d_mag/d_input_power could be lower than d_test_statistics (i.e, + // the maximum test statistics in the previous dwell is greater than + // current d_mag/d_input_power). Note that d_test_statistics is not + // restarted between consecutive dwells in multidwell operation. + if (d_test_statistics < (d_mag / d_input_power) || !d_bit_transition_flag) + { + d_gnss_synchro->Acq_delay_samples = static_cast(indext % d_samples_per_code); + d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); + d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; - // 5- Compute the test statistics and compare to the threshold - d_test_statistics = d_mag / d_input_power; - } - } + // 5- Compute the test statistics and compare to the threshold + d_test_statistics = d_mag / d_input_power; + } + } - // Record results to file if required - if (d_dump) - { - std::stringstream filename; - std::streamsize n = sizeof(float) * (d_fft_size); // noncomplex file write - filename.str(""); - filename << "../data/test_statistics_E5a_sat_" - << d_gnss_synchro->PRN << "_doppler_" << doppler << ".dat"; - d_dump_file.open(filename.str().c_str(), std::ios::out | std::ios::binary); - if (d_sampled_ms > 1) // If integration time > 1 code - { - if (magt_IA >= magt_IB) - { - d_dump_file.write((char*)d_magnitudeIA, n); - } - else - { - d_dump_file.write((char*)d_magnitudeIB, n); - } - } - else - { - d_dump_file.write((char*)d_magnitudeIA, n); - } - d_dump_file.close(); - } - } -// std::cout << "d_mag " << d_mag << ".d_sample_counter " << d_sample_counter << ". acq delay " << d_gnss_synchro->Acq_delay_samples<< " indext "<< indext << std::endl; - // 6 OPTIONAL: CAF filter to avoid Doppler ambiguity in bit transition. - if (d_CAF_window_hz > 0) - { - int CAF_bins_half; - float* accum = static_cast(volk_malloc(sizeof(float), volk_get_alignment())); - CAF_bins_half = d_CAF_window_hz / (2 * d_doppler_step); - float weighting_factor; - weighting_factor = 0.5 / static_cast(CAF_bins_half); - // weighting_factor = 0; - // std::cout << "weighting_factor " << weighting_factor << std::endl; - // Initialize first iterations - for (int doppler_index=0; doppler_index < CAF_bins_half; doppler_index++) - { - d_CAF_vector[doppler_index] = 0; - // volk_32f_accumulator_s32f_a(&d_CAF_vector[doppler_index], d_CAF_vector_I, CAF_bins_half+doppler_index+1); - for (int i = 0; i < CAF_bins_half + doppler_index + 1; i++) - { - d_CAF_vector[doppler_index] += d_CAF_vector_I[i] * (1 - weighting_factor * static_cast(abs(doppler_index - i))); - } - // d_CAF_vector[doppler_index] /= CAF_bins_half+doppler_index+1; - d_CAF_vector[doppler_index] /= 1 + CAF_bins_half+doppler_index - weighting_factor * CAF_bins_half * (CAF_bins_half + 1) / 2 - weighting_factor*doppler_index*(doppler_index+1)/2; // triangles = [n*(n+1)/2] - if (d_both_signal_components) - { - accum[0] = 0; - // volk_32f_accumulator_s32f_a(&accum[0], d_CAF_vector_Q, CAF_bins_half+doppler_index+1); - for (int i = 0; i < CAF_bins_half+doppler_index+1; i++) - { - accum[0] += d_CAF_vector_Q[i] * (1 - weighting_factor * static_cast(abs(doppler_index - i))); - } - // accum[0] /= CAF_bins_half+doppler_index+1; - accum[0] /= 1+CAF_bins_half+doppler_index - weighting_factor * CAF_bins_half * (CAF_bins_half + 1) / 2 - weighting_factor * doppler_index * (doppler_index + 1) / 2; // triangles = [n*(n+1)/2] - d_CAF_vector[doppler_index] += accum[0]; - } - } - // Body loop - for (unsigned int doppler_index = CAF_bins_half;doppler_index(abs(doppler_index - i))); - } - // d_CAF_vector[doppler_index] /= 2*CAF_bins_half+1; - d_CAF_vector[doppler_index] /= 1 + 2 * CAF_bins_half - 2 *weighting_factor * CAF_bins_half * (CAF_bins_half + 1) / 2; - if (d_both_signal_components) - { - accum[0] = 0; - // volk_32f_accumulator_s32f_a(&accum[0], &d_CAF_vector_Q[doppler_index-CAF_bins_half], 2*CAF_bins_half); - for (int i = doppler_index-CAF_bins_half; i < doppler_index+CAF_bins_half+1; i++) - { - accum[0] += d_CAF_vector_Q[i] * (1 -weighting_factor * static_cast(abs(doppler_index - i))); - } - // accum[0] /= 2*CAF_bins_half+1; - accum[0] /= 1+2*CAF_bins_half - 2*weighting_factor * CAF_bins_half * (CAF_bins_half + 1) / 2; - d_CAF_vector[doppler_index] += accum[0]; - } - } - // Final iterations - for (unsigned int doppler_index = d_num_doppler_bins - CAF_bins_half;doppler_indexPRN << "_doppler_" << doppler << ".dat"; + d_dump_file.open(filename.str().c_str(), std::ios::out | std::ios::binary); + if (d_sampled_ms > 1) // If integration time > 1 code + { + if (magt_IA >= magt_IB) + { + d_dump_file.write((char*)d_magnitudeIA, n); + } + else + { + d_dump_file.write((char*)d_magnitudeIB, n); + } + } + else + { + d_dump_file.write((char*)d_magnitudeIA, n); + } + d_dump_file.close(); + } + } + // std::cout << "d_mag " << d_mag << ".d_sample_counter " << d_sample_counter << ". acq delay " << d_gnss_synchro->Acq_delay_samples<< " indext "<< indext << std::endl; + // 6 OPTIONAL: CAF filter to avoid Doppler ambiguity in bit transition. + if (d_CAF_window_hz > 0) + { + int CAF_bins_half; + float* accum = static_cast(volk_malloc(sizeof(float), volk_get_alignment())); + CAF_bins_half = d_CAF_window_hz / (2 * d_doppler_step); + float weighting_factor; + weighting_factor = 0.5 / static_cast(CAF_bins_half); + // weighting_factor = 0; + // std::cout << "weighting_factor " << weighting_factor << std::endl; + // Initialize first iterations + for (int doppler_index=0; doppler_index < CAF_bins_half; doppler_index++) + { + d_CAF_vector[doppler_index] = 0; + // volk_32f_accumulator_s32f_a(&d_CAF_vector[doppler_index], d_CAF_vector_I, CAF_bins_half+doppler_index+1); + for (int i = 0; i < CAF_bins_half + doppler_index + 1; i++) + { + d_CAF_vector[doppler_index] += d_CAF_vector_I[i] * (1 - weighting_factor * static_cast((doppler_index - i))); + } + // d_CAF_vector[doppler_index] /= CAF_bins_half+doppler_index+1; + d_CAF_vector[doppler_index] /= 1 + CAF_bins_half+doppler_index - weighting_factor * CAF_bins_half * (CAF_bins_half + 1) / 2 - weighting_factor*doppler_index*(doppler_index+1)/2; // triangles = [n*(n+1)/2] + if (d_both_signal_components) + { + accum[0] = 0; + // volk_32f_accumulator_s32f_a(&accum[0], d_CAF_vector_Q, CAF_bins_half+doppler_index+1); + for (int i = 0; i < CAF_bins_half + doppler_index + 1; i++) + { + accum[0] += d_CAF_vector_Q[i] * (1 - weighting_factor * static_cast(abs(doppler_index - i))); + } + // accum[0] /= CAF_bins_half+doppler_index+1; + accum[0] /= 1 + CAF_bins_half + doppler_index - weighting_factor * CAF_bins_half * (CAF_bins_half + 1) / 2 - weighting_factor * doppler_index * (doppler_index + 1) / 2; // triangles = [n*(n+1)/2] + d_CAF_vector[doppler_index] += accum[0]; + } + } + // Body loop + for (unsigned int doppler_index = CAF_bins_half;doppler_index((doppler_index - i))); + } + // d_CAF_vector[doppler_index] /= 2*CAF_bins_half+1; + d_CAF_vector[doppler_index] /= 1 + 2 * CAF_bins_half - 2 * weighting_factor * CAF_bins_half * (CAF_bins_half + 1) / 2; + if (d_both_signal_components) + { + accum[0] = 0; + // volk_32f_accumulator_s32f_a(&accum[0], &d_CAF_vector_Q[doppler_index-CAF_bins_half], 2*CAF_bins_half); + for (int i = doppler_index-CAF_bins_half; i < doppler_index + CAF_bins_half + 1; i++) + { + accum[0] += d_CAF_vector_Q[i] * (1 - weighting_factor * static_cast((doppler_index - i))); + } + // accum[0] /= 2*CAF_bins_half+1; + accum[0] /= 1 + 2 * CAF_bins_half - 2 * weighting_factor * CAF_bins_half * (CAF_bins_half + 1) / 2; + d_CAF_vector[doppler_index] += accum[0]; + } + } + // Final iterations + for (int doppler_index = d_num_doppler_bins - CAF_bins_half; doppler_index < d_num_doppler_bins; doppler_index++) + { + d_CAF_vector[doppler_index] = 0; + // volk_32f_accumulator_s32f_a(&d_CAF_vector[doppler_index], &d_CAF_vector_I[doppler_index-CAF_bins_half], CAF_bins_half + (d_num_doppler_bins-doppler_index)); + for (int i = doppler_index - CAF_bins_half; i < d_num_doppler_bins; i++) + { + d_CAF_vector[doppler_index] += d_CAF_vector_I[i] * (1 - weighting_factor * (abs(doppler_index - i))); + } + // d_CAF_vector[doppler_index] /= CAF_bins_half+(d_num_doppler_bins-doppler_index); + d_CAF_vector[doppler_index] /= 1 + CAF_bins_half + (d_num_doppler_bins - doppler_index - 1) - weighting_factor * CAF_bins_half * (CAF_bins_half + 1) / 2 - weighting_factor * (d_num_doppler_bins - doppler_index - 1) * (d_num_doppler_bins - doppler_index) / 2; + if (d_both_signal_components) + { + accum[0] = 0; + // volk_32f_accumulator_s32f_a(&accum[0], &d_CAF_vector_Q[doppler_index-CAF_bins_half], CAF_bins_half + (d_num_doppler_bins-doppler_index)); + for (int i = doppler_index-CAF_bins_half; i < d_num_doppler_bins; i++) + { + accum[0] += d_CAF_vector_Q[i] * (1 - weighting_factor * (abs(doppler_index - i))); + } + // accum[0] /= CAF_bins_half+(d_num_doppler_bins-doppler_index); + accum[0] /= 1 + CAF_bins_half + (d_num_doppler_bins - doppler_index - 1) - weighting_factor * CAF_bins_half * (CAF_bins_half + 1) / 2 - weighting_factor * (d_num_doppler_bins - doppler_index - 1) * (d_num_doppler_bins - doppler_index) / 2; + d_CAF_vector[doppler_index] += accum[0]; + } + } - // Recompute the maximum doppler peak - volk_32f_index_max_16u(&indext, d_CAF_vector, d_num_doppler_bins); - doppler = -static_cast(d_doppler_max) + d_doppler_step * indext; - d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); - // Dump if required, appended at the end of the file - if (d_dump) - { - std::stringstream filename; - std::streamsize n = sizeof(float) * (d_num_doppler_bins); // noncomplex file write - filename.str(""); - filename << "../data/test_statistics_E5a_sat_" - << d_gnss_synchro->PRN << "_CAF.dat"; - d_dump_file.open(filename.str().c_str(), std::ios::out | std::ios::binary); - d_dump_file.write((char*)d_CAF_vector, n); - d_dump_file.close(); - } - volk_free(accum); - } + // Recompute the maximum doppler peak + volk_32f_index_max_16u(&indext, d_CAF_vector, d_num_doppler_bins); + doppler = -static_cast(d_doppler_max) + d_doppler_step * indext; + d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); + // Dump if required, appended at the end of the file + if (d_dump) + { + std::stringstream filename; + std::streamsize n = sizeof(float) * (d_num_doppler_bins); // noncomplex file write + filename.str(""); + filename << "../data/test_statistics_E5a_sat_" << d_gnss_synchro->PRN << "_CAF.dat"; + d_dump_file.open(filename.str().c_str(), std::ios::out | std::ios::binary); + d_dump_file.write((char*)d_CAF_vector, n); + d_dump_file.close(); + } + volk_free(accum); + } - if (d_well_count == d_max_dwells) - { - if (d_test_statistics > d_threshold) - { - d_state = 3; // Positive acquisition - } - else - { - d_state = 4; // Negative acquisition - } - } - else - { - d_state = 1; - } + if (d_well_count == d_max_dwells) + { + if (d_test_statistics > d_threshold) + { + d_state = 3; // Positive acquisition + } + else + { + d_state = 4; // Negative acquisition + } + } + else + { + d_state = 1; + } - consume_each(d_fft_size - d_buffer_count); - d_buffer_count = 0; - break; - } - case 3: - { - // 7.1- Declare positive acquisition using a message queue - DLOG(INFO) << "positive acquisition"; - DLOG(INFO) << "satellite " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN; - DLOG(INFO) << "sample_stamp " << d_sample_counter; - DLOG(INFO) << "test statistics value " << d_test_statistics; - DLOG(INFO) << "test statistics threshold " << d_threshold; - DLOG(INFO) << "code phase " << d_gnss_synchro->Acq_delay_samples; - DLOG(INFO) << "doppler " << d_gnss_synchro->Acq_doppler_hz; - DLOG(INFO) << "magnitude " << d_mag; - DLOG(INFO) << "input signal power " << d_input_power; + consume_each(d_fft_size - d_buffer_count); + d_buffer_count = 0; + break; + } + case 3: + { + // 7.1- Declare positive acquisition using a message queue + DLOG(INFO) << "positive acquisition"; + DLOG(INFO) << "satellite " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN; + DLOG(INFO) << "sample_stamp " << d_sample_counter; + DLOG(INFO) << "test statistics value " << d_test_statistics; + DLOG(INFO) << "test statistics threshold " << d_threshold; + DLOG(INFO) << "code phase " << d_gnss_synchro->Acq_delay_samples; + DLOG(INFO) << "doppler " << d_gnss_synchro->Acq_doppler_hz; + DLOG(INFO) << "magnitude " << d_mag; + DLOG(INFO) << "input signal power " << d_input_power; - d_active = false; - d_state = 0; + d_active = false; + d_state = 0; - acquisition_message = 1; - d_channel_internal_queue->push(acquisition_message); - d_sample_counter += ninput_items[0]; // sample counter - consume_each(ninput_items[0]); - break; - } - case 4: - { - // 7.2- Declare negative acquisition using a message queue - DLOG(INFO) << "negative acquisition"; - DLOG(INFO) << "satellite " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN; - DLOG(INFO) << "sample_stamp " << d_sample_counter; - DLOG(INFO) << "test statistics value " << d_test_statistics; - DLOG(INFO) << "test statistics threshold " << d_threshold; - DLOG(INFO) << "code phase " << d_gnss_synchro->Acq_delay_samples; - DLOG(INFO) << "doppler " << d_gnss_synchro->Acq_doppler_hz; - DLOG(INFO) << "magnitude " << d_mag; - DLOG(INFO) << "input signal power " << d_input_power; + acquisition_message = 1; + d_channel_internal_queue->push(acquisition_message); + d_sample_counter += ninput_items[0]; // sample counter + consume_each(ninput_items[0]); + break; + } + case 4: + { + // 7.2- Declare negative acquisition using a message queue + DLOG(INFO) << "negative acquisition"; + DLOG(INFO) << "satellite " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN; + DLOG(INFO) << "sample_stamp " << d_sample_counter; + DLOG(INFO) << "test statistics value " << d_test_statistics; + DLOG(INFO) << "test statistics threshold " << d_threshold; + DLOG(INFO) << "code phase " << d_gnss_synchro->Acq_delay_samples; + DLOG(INFO) << "doppler " << d_gnss_synchro->Acq_doppler_hz; + DLOG(INFO) << "magnitude " << d_mag; + DLOG(INFO) << "input signal power " << d_input_power; - d_active = false; - d_state = 0; + d_active = false; + d_state = 0; - d_sample_counter += ninput_items[0]; // sample counter - consume_each(ninput_items[0]); - acquisition_message = 2; - d_channel_internal_queue->push(acquisition_message); - break; - } + d_sample_counter += ninput_items[0]; // sample counter + consume_each(ninput_items[0]); + acquisition_message = 2; + d_channel_internal_queue->push(acquisition_message); + break; + } } return noutput_items; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc index fa5460a5a..4fd148d2e 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc @@ -356,14 +356,14 @@ int pcps_acquisition_fine_doppler_cc::estimate_Doppler(gr_vector_const_void_star } // 5. Update the Doppler estimation in Hz - if (abs(fftFreqBins[tmp_index_freq] - d_gnss_synchro->Acq_doppler_hz) < 1000) + if (std::abs(fftFreqBins[tmp_index_freq] - d_gnss_synchro->Acq_doppler_hz) < 1000) { d_gnss_synchro->Acq_doppler_hz = static_cast(fftFreqBins[tmp_index_freq]); //std::cout<<"FFT maximum present at "<= d_symbols_per_preamble) { //check preamble separation - preamble_diff = abs(d_sample_counter - d_preamble_index); + preamble_diff = d_sample_counter - d_preamble_index; if (abs(preamble_diff - GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS) == 0) { //try to decode frame 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 d800373f0..f5e9864c6 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 @@ -209,7 +209,7 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_i } else if (d_stat == 1) //check 6 seconds of preamble separation { - preamble_diff = abs(d_sample_counter - d_preamble_index); + preamble_diff = d_sample_counter - d_preamble_index; if (abs(preamble_diff - 6000) < 1) { d_GPS_FSM.Event_gps_word_preamble(); diff --git a/src/core/system_parameters/galileo_navigation_message.cc b/src/core/system_parameters/galileo_navigation_message.cc index fcb74e0a3..d4e7dfe23 100644 --- a/src/core/system_parameters/galileo_navigation_message.cc +++ b/src/core/system_parameters/galileo_navigation_message.cc @@ -1,6 +1,6 @@ /*! - * \file Galileo_Navigation_Message.cc - * \brief Implementation of a Galileo I/NAV Data message + * \file galileo_navigation_message.cc + * \brief Implementation of a Galileo I/NAV Data message * as described in Galileo OS SIS ICD Issue 1.1 (Sept. 2010) * \author Mara Branzanti 2013. mara.branzanti(at)gmail.com * \author Javier Arribas, 2013. jarribas(at)cttc.es diff --git a/src/core/system_parameters/galileo_utc_model.cc b/src/core/system_parameters/galileo_utc_model.cc index abf63be98..06d69752b 100644 --- a/src/core/system_parameters/galileo_utc_model.cc +++ b/src/core/system_parameters/galileo_utc_model.cc @@ -29,6 +29,7 @@ */ #include "galileo_utc_model.h" +#include Galileo_Utc_Model::Galileo_Utc_Model() { @@ -57,7 +58,7 @@ double Galileo_Utc_Model::GST_to_UTC_time(double t_e, int WN) { //Detect if the effectivity time and user's time is within six hours = 6 * 60 *60 = 21600 s int secondOfLeapSecondEvent = DN_6 * 24 * 60 * 60; - if (abs(t_e - secondOfLeapSecondEvent) > 21600) + if (std::abs(t_e - secondOfLeapSecondEvent) > 21600) { /* 5.1.7a GST->UTC case a * Whenever the leap second adjusted time indicated by the WN_LSF and the DN values diff --git a/src/core/system_parameters/gps_navigation_message.cc b/src/core/system_parameters/gps_navigation_message.cc index a5b58b050..d75ff3069 100644 --- a/src/core/system_parameters/gps_navigation_message.cc +++ b/src/core/system_parameters/gps_navigation_message.cc @@ -31,6 +31,7 @@ */ #include "gps_navigation_message.h" +#include #include "boost/date_time/posix_time/posix_time.hpp" @@ -697,7 +698,7 @@ double Gps_Navigation_Message::utc_time(const double gpstime_corrected) const } else //we are in the same week than the leap second event { - if (abs(gpstime_corrected - secondOfLeapSecondEvent) > 21600) + if (std::abs(gpstime_corrected - secondOfLeapSecondEvent) > 21600) { /* 20.3.3.5.2.4a * Whenever the effectivity time indicated by the WN_LSF and the DN values diff --git a/src/core/system_parameters/gps_utc_model.cc b/src/core/system_parameters/gps_utc_model.cc index 64a8b0758..2548b5ab9 100644 --- a/src/core/system_parameters/gps_utc_model.cc +++ b/src/core/system_parameters/gps_utc_model.cc @@ -29,6 +29,7 @@ */ #include "gps_utc_model.h" +#include Gps_Utc_Model::Gps_Utc_Model() { @@ -62,7 +63,7 @@ double Gps_Utc_Model::utc_time(double gpstime_corrected, int i_GPS_week) } else //we are in the same week than the leap second event { - if (abs(gpstime_corrected - secondOfLeapSecondEvent) > 21600) + if (std::abs(gpstime_corrected - secondOfLeapSecondEvent) > 21600) { /* 20.3.3.5.2.4a * Whenever the effectivity time indicated by the WN_LSF and the DN values diff --git a/src/core/system_parameters/sbas_telemetry_data.cc b/src/core/system_parameters/sbas_telemetry_data.cc index 22f7f88b5..2e6475a40 100644 --- a/src/core/system_parameters/sbas_telemetry_data.cc +++ b/src/core/system_parameters/sbas_telemetry_data.cc @@ -28,10 +28,11 @@ * ------------------------------------------------------------------------- */ -#include -#include +#include #include #include +#include +#include #include #include "sbas_telemetry_data.h" #include "sbas_ionospheric_correction.h" @@ -722,7 +723,7 @@ int Sbas_Telemetry_Data::decode_sbstype9(const sbsmsg_t *msg, nav_t *nav) seph.af1 = getbits(msg->msg, 218, 8)*P2_39/2.0; i = msg->prn-MINPRNSBS; - if (!nav->seph || fabs(nav->seph[i].t0 - seph.t0) < 1E-3) + if (!nav->seph || std::abs(nav->seph[i].t0 - seph.t0) < 1E-3) { /* not change */ VLOG(FLOW) << "<> no change in ephemeris -> won't parse"; return 0; diff --git a/src/tests/gnss_block/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc b/src/tests/gnss_block/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc index 4c0261b4f..0e67f110c 100644 --- a/src/tests/gnss_block/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc +++ b/src/tests/gnss_block/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc @@ -320,8 +320,8 @@ void GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = abs((double)expected_delay_chips - (double)(gnss_synchro.Acq_delay_samples-5)*1023.0/((double)fs_in*1e-3)); - double doppler_error_hz = abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); + double delay_error_chips = std::abs((double)expected_delay_chips - (double)(gnss_synchro.Acq_delay_samples-5)*1023.0/((double)fs_in*1e-3)); + double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); mse_doppler += std::pow(doppler_error_hz, 2); diff --git a/src/tests/gnss_block/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc b/src/tests/gnss_block/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc index c8cb55cfd..37826556c 100644 --- a/src/tests/gnss_block/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc +++ b/src/tests/gnss_block/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc @@ -323,8 +323,8 @@ void GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = abs((double)expected_delay_chips - (double)(gnss_synchro.Acq_delay_samples-5)*1023.0/((double)fs_in*1e-3)); - double doppler_error_hz = abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); + double delay_error_chips = std::abs((double)expected_delay_chips - (double)(gnss_synchro.Acq_delay_samples-5)*1023.0/((double)fs_in*1e-3)); + double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); mse_doppler += std::pow(doppler_error_hz, 2); diff --git a/src/tests/gnss_block/galileo_e1_pcps_ambiguous_acquisition_test.cc b/src/tests/gnss_block/galileo_e1_pcps_ambiguous_acquisition_test.cc index 7c147a582..88fe3a141 100644 --- a/src/tests/gnss_block/galileo_e1_pcps_ambiguous_acquisition_test.cc +++ b/src/tests/gnss_block/galileo_e1_pcps_ambiguous_acquisition_test.cc @@ -240,9 +240,9 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, ValidationOfResults) std::cout << "Delay: " << gnss_synchro.Acq_delay_samples << std::endl; std::cout << "Doppler: " << gnss_synchro.Acq_doppler_hz << std::endl; - double delay_error_samples = abs(expected_delay_samples - gnss_synchro.Acq_delay_samples); + double delay_error_samples = std::abs(expected_delay_samples - gnss_synchro.Acq_delay_samples); float delay_error_chips = (float)(delay_error_samples * 1023 / 4000000); - double doppler_error_hz = abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); + double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); EXPECT_LE(doppler_error_hz, 166) << "Doppler error exceeds the expected value: 166 Hz = 2/(3*integration period)"; EXPECT_LT(delay_error_chips, 0.175) << "Delay error exceeds the expected value: 0.175 chips"; diff --git a/src/tests/gnss_block/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc b/src/tests/gnss_block/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc index 1154cadfc..807620869 100644 --- a/src/tests/gnss_block/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc +++ b/src/tests/gnss_block/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc @@ -321,8 +321,8 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisitionTest::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = abs((double)expected_delay_chips - (double)(gnss_synchro.Acq_delay_samples-5)*1023.0/((double)fs_in*1e-3)); - double doppler_error_hz = abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); + double delay_error_chips = std::abs((double)expected_delay_chips - (double)(gnss_synchro.Acq_delay_samples-5)*1023.0/((double)fs_in*1e-3)); + double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); mse_doppler += std::pow(doppler_error_hz, 2); diff --git a/src/tests/gnss_block/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc b/src/tests/gnss_block/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc index edb4f1062..b333a1218 100644 --- a/src/tests/gnss_block/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc +++ b/src/tests/gnss_block/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc @@ -436,8 +436,8 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = abs((double)expected_delay_chips - (double)(gnss_synchro.Acq_delay_samples - 5) * 1023.0 / ((double)fs_in * 1e-3)); - double doppler_error_hz = abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); + double delay_error_chips = std::abs((double)expected_delay_chips - (double)(gnss_synchro.Acq_delay_samples - 5) * 1023.0 / ((double)fs_in * 1e-3)); + double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); mse_doppler += std::pow(doppler_error_hz, 2); diff --git a/src/tests/gnss_block/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc b/src/tests/gnss_block/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc index e4eb6b1ec..2fa325624 100644 --- a/src/tests/gnss_block/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc +++ b/src/tests/gnss_block/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc @@ -328,8 +328,8 @@ void GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = abs((double)expected_delay_chips - (double)(gnss_synchro.Acq_delay_samples-5)*1023.0/((double)fs_in*1e-3)); - double doppler_error_hz = abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); + double delay_error_chips = std::abs((double)expected_delay_chips - (double)(gnss_synchro.Acq_delay_samples-5)*1023.0/((double)fs_in*1e-3)); + double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); mse_doppler += std::pow(doppler_error_hz, 2); diff --git a/src/tests/gnss_block/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc b/src/tests/gnss_block/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc index 065bd5542..0da42fed8 100644 --- a/src/tests/gnss_block/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc +++ b/src/tests/gnss_block/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc @@ -446,20 +446,20 @@ void GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::process_message() switch (sat) { case 0: - delay_error_chips = abs((double)expected_delay_chips - (double)(gnss_synchro.Acq_delay_samples-5)*10230.0/((double)fs_in*1e-3)); - doppler_error_hz = abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); + delay_error_chips = std::abs((double)expected_delay_chips - (double)(gnss_synchro.Acq_delay_samples-5)*10230.0/((double)fs_in*1e-3)); + doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); break; case 1: - delay_error_chips = abs((double)expected_delay_chips1 - (double)(gnss_synchro.Acq_delay_samples-5)*10230.0/((double)fs_in*1e-3)); - doppler_error_hz = abs(expected_doppler_hz1 - gnss_synchro.Acq_doppler_hz); + delay_error_chips = std::abs((double)expected_delay_chips1 - (double)(gnss_synchro.Acq_delay_samples-5)*10230.0/((double)fs_in*1e-3)); + doppler_error_hz = std::abs(expected_doppler_hz1 - gnss_synchro.Acq_doppler_hz); break; case 2: - delay_error_chips = abs((double)expected_delay_chips2 - (double)(gnss_synchro.Acq_delay_samples-5)*10230.0/((double)fs_in*1e-3)); - doppler_error_hz = abs(expected_doppler_hz2 - gnss_synchro.Acq_doppler_hz); + delay_error_chips = std::abs((double)expected_delay_chips2 - (double)(gnss_synchro.Acq_delay_samples-5)*10230.0/((double)fs_in*1e-3)); + doppler_error_hz = std::abs(expected_doppler_hz2 - gnss_synchro.Acq_doppler_hz); break; case 3: - delay_error_chips = abs((double)expected_delay_chips3 - (double)(gnss_synchro.Acq_delay_samples-5)*10230.0/((double)fs_in*1e-3)); - doppler_error_hz = abs(expected_doppler_hz3 - gnss_synchro.Acq_doppler_hz); + delay_error_chips = std::abs((double)expected_delay_chips3 - (double)(gnss_synchro.Acq_delay_samples-5)*10230.0/((double)fs_in*1e-3)); + doppler_error_hz = std::abs(expected_doppler_hz3 - gnss_synchro.Acq_doppler_hz); break; default: // case 3 std::cout << "Error: message from unexpected acquisition channel" << std::endl; diff --git a/src/tests/gnss_block/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc b/src/tests/gnss_block/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc index 63c392055..bb7b2170f 100644 --- a/src/tests/gnss_block/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc +++ b/src/tests/gnss_block/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc @@ -318,8 +318,8 @@ void GpsL1CaPcpsAcquisitionGSoC2013Test::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = abs((double)expected_delay_chips - (double)(gnss_synchro.Acq_delay_samples-5)*1023.0/((double)fs_in*1e-3)); - double doppler_error_hz = abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); + double delay_error_chips = std::abs((double)expected_delay_chips - (double)(gnss_synchro.Acq_delay_samples-5)*1023.0/((double)fs_in*1e-3)); + double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); mse_doppler += std::pow(doppler_error_hz, 2); diff --git a/src/tests/gnss_block/gps_l1_ca_pcps_multithread_acquisition_gsoc2013_test.cc b/src/tests/gnss_block/gps_l1_ca_pcps_multithread_acquisition_gsoc2013_test.cc index cca1782b4..b2d60a4fc 100644 --- a/src/tests/gnss_block/gps_l1_ca_pcps_multithread_acquisition_gsoc2013_test.cc +++ b/src/tests/gnss_block/gps_l1_ca_pcps_multithread_acquisition_gsoc2013_test.cc @@ -322,8 +322,8 @@ void GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = abs((double)expected_delay_chips - (double)(gnss_synchro.Acq_delay_samples-5)*1023.0/((double)fs_in*1e-3)); - double doppler_error_hz = abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); + double delay_error_chips = std::abs((double)expected_delay_chips - (double)(gnss_synchro.Acq_delay_samples-5)*1023.0/((double)fs_in*1e-3)); + double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); mse_doppler += std::pow(doppler_error_hz, 2); diff --git a/src/tests/gnss_block/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc b/src/tests/gnss_block/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc index 6fb536372..c8294a86b 100644 --- a/src/tests/gnss_block/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc +++ b/src/tests/gnss_block/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc @@ -317,8 +317,8 @@ void GpsL1CaPcpsOpenClAcquisitionGSoC2013Test::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = abs((double)expected_delay_chips - (double)(gnss_synchro.Acq_delay_samples- 5 )*1023.0/((double)fs_in*1e-3)); - double doppler_error_hz = abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); + double delay_error_chips = std::abs((double)expected_delay_chips - (double)(gnss_synchro.Acq_delay_samples- 5 )*1023.0/((double)fs_in*1e-3)); + double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); mse_doppler += std::pow(doppler_error_hz, 2); diff --git a/src/tests/gnss_block/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc b/src/tests/gnss_block/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc index f1366a13d..859bacf9e 100644 --- a/src/tests/gnss_block/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc +++ b/src/tests/gnss_block/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc @@ -429,8 +429,8 @@ void GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = abs((double)expected_delay_chips - (double)(gnss_synchro.Acq_delay_samples - 5) * 1023.0/ ((double)fs_in * 1e-3)); - double doppler_error_hz = abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); + double delay_error_chips = std::abs((double)expected_delay_chips - (double)(gnss_synchro.Acq_delay_samples - 5) * 1023.0/ ((double)fs_in * 1e-3)); + double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); mse_doppler += std::pow(doppler_error_hz, 2); diff --git a/src/tests/gnss_block/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc b/src/tests/gnss_block/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc index 693aaf648..55ea5a64b 100644 --- a/src/tests/gnss_block/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc +++ b/src/tests/gnss_block/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc @@ -319,8 +319,8 @@ void GpsL1CaPcpsTongAcquisitionGSoC2013Test::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = abs((double)expected_delay_chips - (double)(gnss_synchro.Acq_delay_samples-5)*1023.0/((double)fs_in*1e-3)); - double doppler_error_hz = abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); + double delay_error_chips = std::abs((double)expected_delay_chips - (double)(gnss_synchro.Acq_delay_samples-5)*1023.0/((double)fs_in*1e-3)); + double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); mse_doppler += std::pow(doppler_error_hz, 2); diff --git a/src/tests/single_test_main.cc b/src/tests/single_test_main.cc index ad92eea99..98b7ae570 100644 --- a/src/tests/single_test_main.cc +++ b/src/tests/single_test_main.cc @@ -29,6 +29,7 @@ * ------------------------------------------------------------------------- */ +#include #include #include #include diff --git a/src/tests/test_main.cc b/src/tests/test_main.cc index c6c662206..ffa7e2064 100644 --- a/src/tests/test_main.cc +++ b/src/tests/test_main.cc @@ -29,9 +29,7 @@ * ------------------------------------------------------------------------- */ - - - +#include #include #include #include