[hamradio-commits] [gnss-sdr] 182/236: minor cleaning

Carles Fernandez carles_fernandez-guest at moszumanska.debian.org
Tue Apr 26 16:02:50 UTC 2016


This is an automated email from the git hooks/post-receive script.

carles_fernandez-guest pushed a commit to branch next
in repository gnss-sdr.

commit 4d072833c578de7d67cc3f561ebe9245e7285bd0
Author: Carles Fernandez <carles.fernandez at gmail.com>
Date:   Sun Apr 10 10:29:25 2016 +0200

    minor cleaning
---
 .../gnuradio_blocks/pcps_acquisition_cc.cc         | 127 +++++++++---------
 .../gnuradio_blocks/pcps_acquisition_sc.cc         | 145 +++++++++++----------
 2 files changed, 139 insertions(+), 133 deletions(-)

diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.cc
index 5304177..3992290 100644
--- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.cc
+++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.cc
@@ -87,7 +87,7 @@ pcps_acquisition_cc::pcps_acquisition_cc(
     d_input_power = 0.0;
     d_num_doppler_bins = 0;
     d_bit_transition_flag = bit_transition_flag;
-    d_use_CFAR_algorithm_flag=use_CFAR_algorithm_flag;
+    d_use_CFAR_algorithm_flag = use_CFAR_algorithm_flag;
     d_threshold = 0.0;
     d_doppler_step = 250;
     d_code_phase = 0;
@@ -108,10 +108,10 @@ pcps_acquisition_cc::pcps_acquisition_cc(
     // We can avoid this by doing linear correlation, effectively doubling the
     // size of the input buffer and padding the code with zeros.
     if( d_bit_transition_flag )
-    {
-        d_fft_size *= 2;
-        d_max_dwells = 1;
-    }
+        {
+            d_fft_size *= 2;
+            d_max_dwells = 1;
+        }
 
     d_fft_codes = static_cast<gr_complex*>(volk_malloc(d_fft_size * sizeof(gr_complex), volk_get_alignment()));
     d_magnitude = static_cast<float*>(volk_malloc(d_fft_size * sizeof(float), volk_get_alignment()));
@@ -131,6 +131,7 @@ pcps_acquisition_cc::pcps_acquisition_cc(
     d_grid_doppler_wipeoffs = 0;
 }
 
+
 pcps_acquisition_cc::~pcps_acquisition_cc()
 {
     if (d_num_doppler_bins > 0)
@@ -154,6 +155,7 @@ pcps_acquisition_cc::~pcps_acquisition_cc()
         }
 }
 
+
 void pcps_acquisition_cc::set_local_code(std::complex<float> * code)
 {
     // COD
@@ -162,15 +164,16 @@ void pcps_acquisition_cc::set_local_code(std::complex<float> * code)
     // where c_i is the local code and there are L zeros and L chips
     int offset = 0;
     if( d_bit_transition_flag )
-    {
-        std::fill_n( d_fft_if->get_inbuf(), d_samples_per_code, gr_complex( 0.0, 0.0 ) );
-        offset = d_samples_per_code;
-    }
+        {
+            std::fill_n( d_fft_if->get_inbuf(), d_samples_per_code, gr_complex( 0.0, 0.0 ) );
+            offset = d_samples_per_code;
+        }
     memcpy(d_fft_if->get_inbuf() + offset, code, sizeof(gr_complex) * d_samples_per_code);
     d_fft_if->execute(); // We need the FFT of local code
     volk_32fc_conjugate_32fc(d_fft_codes, d_fft_if->get_outbuf(), d_fft_size);
 }
 
+
 void pcps_acquisition_cc::update_local_carrier(gr_complex* carrier_vector, int correlator_length_samples, float freq)
 {
     float phase_step_rad = GPS_TWO_PI * freq / static_cast<float>(d_fs_in);
@@ -179,6 +182,7 @@ void pcps_acquisition_cc::update_local_carrier(gr_complex* carrier_vector, int c
     volk_gnsssdr_s32f_sincos_32fc(carrier_vector, - phase_step_rad, _phase, correlator_length_samples);
 }
 
+
 void pcps_acquisition_cc::init()
 {
     d_gnss_synchro->Flag_valid_acquisition = false;
@@ -207,27 +211,27 @@ void pcps_acquisition_cc::init()
 }
 
 
-
 void pcps_acquisition_cc::set_state(int state)
-    {
-        d_state = state;
-        if (d_state == 1)
-            {
-                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;
-            }
-        else if (d_state == 0)
-            {}
-        else
-            {
-                LOG(ERROR) << "State can only be set to 0 or 1";
-            }
-    }
+{
+    d_state = state;
+    if (d_state == 1)
+        {
+            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;
+        }
+    else if (d_state == 0)
+        {}
+    else
+        {
+            LOG(ERROR) << "State can only be set to 0 or 1";
+        }
+}
+
 
 int pcps_acquisition_cc::general_work(int noutput_items,
         gr_vector_int &ninput_items, gr_vector_const_void_star &input_items,
@@ -292,27 +296,26 @@ int pcps_acquisition_cc::general_work(int noutput_items,
             d_well_count++;
 
             DLOG(INFO) << "Channel: " << d_channel
-                    << " , doing acquisition of satellite: " << d_gnss_synchro->System << " "<< d_gnss_synchro->PRN
+                    << " , 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;
 
-            if (d_use_CFAR_algorithm_flag==true)
-            {
-                // 1- (optional) Compute the input signal power estimation
-                volk_32fc_magnitude_squared_32f(d_magnitude, in, d_fft_size);
-                volk_32f_accumulator_s32f(&d_input_power, d_magnitude, d_fft_size);
-                d_input_power /= static_cast<float>(d_fft_size);
-            }
+            if (d_use_CFAR_algorithm_flag == true)
+                {
+                    // 1- (optional) Compute the input signal power estimation
+                    volk_32fc_magnitude_squared_32f(d_magnitude, in, d_fft_size);
+                    volk_32f_accumulator_s32f(&d_input_power, d_magnitude, d_fft_size);
+                    d_input_power /= static_cast<float>(d_fft_size);
+                }
             // 2- Doppler frequency search loop
-            for (unsigned int doppler_index=0; doppler_index < d_num_doppler_bins; doppler_index++)
+            for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
                 {
                     // doppler search steps
-
                     doppler = -static_cast<int>(d_doppler_max) + d_doppler_step * doppler_index;
 
                     volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), in,
-                                d_grid_doppler_wipeoffs[doppler_index], d_fft_size);
+                            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
@@ -321,7 +324,7 @@ int pcps_acquisition_cc::general_work(int noutput_items,
                     // 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_codes, d_fft_size);
+                            d_fft_if->get_outbuf(), d_fft_codes, d_fft_size);
 
                     // compute the inverse FFT
                     d_ifft->execute();
@@ -330,24 +333,24 @@ int pcps_acquisition_cc::general_work(int noutput_items,
                     size_t offset = ( d_bit_transition_flag ? effective_fft_size : 0 );
                     volk_32fc_magnitude_squared_32f(d_magnitude, d_ifft->get_outbuf() + offset, effective_fft_size);
                     volk_32f_index_max_16u(&indext, d_magnitude, effective_fft_size);
-                	magt = d_magnitude[indext];
+                    magt = d_magnitude[indext];
 
-                    if (d_use_CFAR_algorithm_flag==true)
-                    {
-                        // Normalize the maximum value to correct the scale factor introduced by FFTW
-                        magt = d_magnitude[indext] / (fft_normalization_factor * fft_normalization_factor);
-                    }
+                    if (d_use_CFAR_algorithm_flag == true)
+                        {
+                            // Normalize the maximum value to correct the scale factor introduced by FFTW
+                            magt = d_magnitude[indext] / (fft_normalization_factor * fft_normalization_factor);
+                        }
                     // 4- record the maximum peak and the associated synchronization parameters
                     if (d_mag < magt)
                         {
                             d_mag = magt;
 
-                            if (d_use_CFAR_algorithm_flag==false)
-                            {
-								// Search grid noise floor approximation for this doppler line
-								volk_32f_accumulator_s32f(&d_input_power, d_magnitude, effective_fft_size);
-								d_input_power=(d_input_power-d_mag)/(effective_fft_size-1);
-                            }
+                            if (d_use_CFAR_algorithm_flag == false)
+                                {
+                                    // Search grid noise floor approximation for this doppler line
+                                    volk_32f_accumulator_s32f(&d_input_power, d_magnitude, effective_fft_size);
+                                    d_input_power = (d_input_power - d_mag) / (effective_fft_size - 1);
+                                }
 
                             // 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
@@ -358,15 +361,15 @@ int pcps_acquisition_cc::general_work(int noutput_items,
                             // 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<double>(indext % d_samples_per_code);
-                                d_gnss_synchro->Acq_doppler_hz = static_cast<double>(doppler);
-                                d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter;
-
-                                // 5- Compute the test statistics and compare to the threshold
-                                //d_test_statistics = 2 * d_fft_size * d_mag / d_input_power;
-                                d_test_statistics = d_mag / d_input_power;
-                            }
+                                {
+                                    d_gnss_synchro->Acq_delay_samples = static_cast<double>(indext % d_samples_per_code);
+                                    d_gnss_synchro->Acq_doppler_hz = static_cast<double>(doppler);
+                                    d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter;
+
+                                    // 5- Compute the test statistics and compare to the threshold
+                                    //d_test_statistics = 2 * d_fft_size * d_mag / d_input_power;
+                                    d_test_statistics = d_mag / d_input_power;
+                                }
                         }
 
                     // Record results to file if required
diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_sc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_sc.cc
index 413049a..1b6bc9e 100644
--- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_sc.cc
+++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_sc.cc
@@ -86,7 +86,7 @@ pcps_acquisition_sc::pcps_acquisition_sc(
     d_input_power = 0.0;
     d_num_doppler_bins = 0;
     d_bit_transition_flag = bit_transition_flag;
-    d_use_CFAR_algorithm_flag=use_CFAR_algorithm_flag;
+    d_use_CFAR_algorithm_flag = use_CFAR_algorithm_flag;
     d_threshold = 0.0;
     d_doppler_step = 250;
     d_code_phase = 0;
@@ -107,10 +107,10 @@ pcps_acquisition_sc::pcps_acquisition_sc(
     // We can avoid this by doing linear correlation, effectively doubling the
     // size of the input buffer and padding the code with zeros.
     if( d_bit_transition_flag )
-    {
-        d_fft_size *= 2;
-        d_max_dwells = 1;
-    }
+        {
+            d_fft_size *= 2;
+            d_max_dwells = 1;
+        }
 
     d_fft_codes = static_cast<gr_complex*>(volk_malloc(d_fft_size * sizeof(gr_complex), volk_get_alignment()));
     d_magnitude = static_cast<float*>(volk_malloc(d_fft_size * sizeof(float), volk_get_alignment()));
@@ -132,6 +132,7 @@ pcps_acquisition_sc::pcps_acquisition_sc(
     d_grid_doppler_wipeoffs = 0;
 }
 
+
 pcps_acquisition_sc::~pcps_acquisition_sc()
 {
     if (d_num_doppler_bins > 0)
@@ -156,6 +157,7 @@ pcps_acquisition_sc::~pcps_acquisition_sc()
         }
 }
 
+
 void pcps_acquisition_sc::set_local_code(std::complex<float> * code)
 {
     // COD
@@ -164,15 +166,16 @@ void pcps_acquisition_sc::set_local_code(std::complex<float> * code)
     // where c_i is the local code and there are L zeros and L chips
     int offset = 0;
     if( d_bit_transition_flag )
-    {
-        std::fill_n( d_fft_if->get_inbuf(), d_samples_per_code, gr_complex( 0.0, 0.0 ) );
-        offset = d_samples_per_code;
-    }
+        {
+            std::fill_n( d_fft_if->get_inbuf(), d_samples_per_code, gr_complex( 0.0, 0.0 ) );
+            offset = d_samples_per_code;
+        }
     memcpy(d_fft_if->get_inbuf() + offset, code, sizeof(gr_complex) * d_samples_per_code);
     d_fft_if->execute(); // We need the FFT of local code
     volk_32fc_conjugate_32fc(d_fft_codes, d_fft_if->get_outbuf(), d_fft_size);
 }
 
+
 void pcps_acquisition_sc::update_local_carrier(gr_complex* carrier_vector, int correlator_length_samples, float freq)
 {
     float phase_step_rad = GPS_TWO_PI * freq / static_cast<float>(d_fs_in);
@@ -181,6 +184,7 @@ void pcps_acquisition_sc::update_local_carrier(gr_complex* carrier_vector, int c
     volk_gnsssdr_s32f_sincos_32fc(carrier_vector, - phase_step_rad, _phase, correlator_length_samples);
 }
 
+
 void pcps_acquisition_sc::init()
 {
     d_gnss_synchro->Flag_valid_acquisition = false;
@@ -211,25 +215,25 @@ void pcps_acquisition_sc::init()
 
 
 void pcps_acquisition_sc::set_state(int state)
-    {
-        d_state = state;
-        if (d_state == 1)
-            {
-                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;
-            }
-        else if (d_state == 0)
-            {}
-        else
-            {
-                LOG(ERROR) << "State can only be set to 0 or 1";
-            }
-    }
+{
+    d_state = state;
+    if (d_state == 1)
+        {
+            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;
+        }
+    else if (d_state == 0)
+        {}
+    else
+        {
+            LOG(ERROR) << "State can only be set to 0 or 1";
+        }
+}
 
 int pcps_acquisition_sc::general_work(int noutput_items,
         gr_vector_int &ninput_items, gr_vector_const_void_star &input_items,
@@ -294,27 +298,27 @@ int pcps_acquisition_sc::general_work(int noutput_items,
             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;
-
-            if (d_use_CFAR_algorithm_flag==true)
-            {
-                // 1- (optional) Compute the input signal power estimation
-            	volk_32fc_magnitude_squared_32f(d_magnitude, d_in_32fc, d_fft_size);
-            	volk_32f_accumulator_s32f(&d_input_power, d_magnitude, d_fft_size);
-                d_input_power /= static_cast<float>(d_fft_size);
-            }
+                       << " , 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;
+
+            if (d_use_CFAR_algorithm_flag == true)
+                {
+                    // 1- (optional) Compute the input signal power estimation
+                    volk_32fc_magnitude_squared_32f(d_magnitude, d_in_32fc, d_fft_size);
+                    volk_32f_accumulator_s32f(&d_input_power, d_magnitude, d_fft_size);
+                    d_input_power /= static_cast<float>(d_fft_size);
+                }
             // 2- Doppler frequency search loop
-            for (unsigned int doppler_index=0; doppler_index < d_num_doppler_bins; doppler_index++)
+            for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
                 {
                     // doppler search steps
 
                     doppler = -static_cast<int>(d_doppler_max) + d_doppler_step * doppler_index;
 
                     volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), d_in_32fc,
-                                d_grid_doppler_wipeoffs[doppler_index], d_fft_size);
+                            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
@@ -323,7 +327,7 @@ int pcps_acquisition_sc::general_work(int noutput_items,
                     // 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_codes, d_fft_size);
+                            d_fft_if->get_outbuf(), d_fft_codes, d_fft_size);
 
                     // compute the inverse FFT
                     d_ifft->execute();
@@ -332,26 +336,25 @@ int pcps_acquisition_sc::general_work(int noutput_items,
                     size_t offset = ( d_bit_transition_flag ? effective_fft_size : 0 );
                     volk_32fc_magnitude_squared_32f(d_magnitude, d_ifft->get_outbuf() + offset, effective_fft_size);
                     volk_32f_index_max_16u(&indext, d_magnitude, effective_fft_size);
-                	magt = d_magnitude[indext];
-
-                    if (d_use_CFAR_algorithm_flag==true)
-                    {
-                        // Normalize the maximum value to correct the scale factor introduced by FFTW
-                        magt = d_magnitude[indext] / (fft_normalization_factor * fft_normalization_factor);
-                    }
+                    magt = d_magnitude[indext];
 
+                    if (d_use_CFAR_algorithm_flag == true)
+                        {
+                            // Normalize the maximum value to correct the scale factor introduced by FFTW
+                            magt = d_magnitude[indext] / (fft_normalization_factor * fft_normalization_factor);
+                        }
 
                     // 4- record the maximum peak and the associated synchronization parameters
                     if (d_mag < magt)
                         {
                             d_mag = magt;
 
-                            if (d_use_CFAR_algorithm_flag==false)
-                            {
-								// Search grid noise floor approximation for this doppler line
-								volk_32f_accumulator_s32f(&d_input_power, d_magnitude, effective_fft_size);
-								d_input_power=(d_input_power-d_mag)/(effective_fft_size-1);
-                            }
+                            if (d_use_CFAR_algorithm_flag == false)
+                                {
+                                    // Search grid noise floor approximation for this doppler line
+                                    volk_32f_accumulator_s32f(&d_input_power, d_magnitude, effective_fft_size);
+                                    d_input_power = (d_input_power - d_mag) / (effective_fft_size - 1);
+                                }
 
                             // 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
@@ -362,16 +365,16 @@ int pcps_acquisition_sc::general_work(int noutput_items,
                             // 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<double>(indext % d_samples_per_code);
-                                d_gnss_synchro->Acq_doppler_hz = static_cast<double>(doppler);
-                                d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter;
+                                {
+                                    d_gnss_synchro->Acq_delay_samples = static_cast<double>(indext % d_samples_per_code);
+                                    d_gnss_synchro->Acq_doppler_hz = static_cast<double>(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;
-                                //std::cout<<"d_input_power="<<d_input_power<<" d_test_statistics="<<d_test_statistics<<" d_gnss_synchro->Acq_doppler_hz ="<<d_gnss_synchro->Acq_doppler_hz <<std::endl;
+                                    // 5- Compute the test statistics and compare to the threshold
+                                    d_test_statistics = d_mag / d_input_power;
+                                    //std::cout<<"d_input_power="<<d_input_power<<" d_test_statistics="<<d_test_statistics<<" d_gnss_synchro->Acq_doppler_hz ="<<d_gnss_synchro->Acq_doppler_hz <<std::endl;
 
-                            }
+                                }
                         }
 
                     // Record results to file if required
@@ -383,13 +386,13 @@ int pcps_acquisition_sc::general_work(int noutput_items,
 
                             boost::filesystem::path p = d_dump_filename;
                             filename << p.parent_path().string()
-                                     << boost::filesystem::path::preferred_separator
-                                     << p.stem().string()
-                                     << "_" << d_gnss_synchro->System
-                                     <<"_" << d_gnss_synchro->Signal << "_sat_"
-                                     << d_gnss_synchro->PRN << "_doppler_"
-                                     <<  doppler
-                                     << p.extension().string();
+                                             << boost::filesystem::path::preferred_separator
+                                             << p.stem().string()
+                                             << "_" << d_gnss_synchro->System
+                                             <<"_" << d_gnss_synchro->Signal << "_sat_"
+                                             << d_gnss_synchro->PRN << "_doppler_"
+                                             <<  doppler
+                                             << p.extension().string();
 
                             DLOG(INFO) << "Writing ACQ out to " << filename.str();
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/gnss-sdr.git



More information about the pkg-hamradio-commits mailing list