1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-15 19:55:47 +00:00

Multiple changes pcps acquisition: including linear corr.

Reduced zero_padding_factor in pcps acquisition

This was 16, I'm processing data at about 16MHz, this oversampling
factor caused memory allocation issues

Previously dump file name was not being read from the configuration

Added fix for non-zero IF in pcps_acquisition_cc

Added linear correlation to pcps acquisition.
This commit is contained in:
Cillian O'Driscoll 2015-08-06 09:34:25 +01:00
parent 0948e90c61
commit 5b9683baad
3 changed files with 79 additions and 10 deletions

View File

@ -97,6 +97,10 @@ GalileoE1PcpsAmbiguousAcquisition::GalileoE1PcpsAmbiguousAcquisition(
vector_length_ = sampled_ms_ * samples_per_ms;
if( bit_transition_flag_ ){
vector_length_ *= 2;
}
code_ = new gr_complex[vector_length_];
if (item_type_.compare("gr_complex") == 0)

View File

@ -40,6 +40,7 @@
#include <volk/volk.h>
#include "gnss_signal_processing.h"
#include "control_message_factory.h"
#include <boost/filesystem.hpp>
using google::LogMessage;
@ -65,8 +66,8 @@ pcps_acquisition_cc::pcps_acquisition_cc(
gr::msg_queue::sptr queue, bool dump,
std::string dump_filename) :
gr::block("pcps_acquisition_cc",
gr::io_signature::make(1, 1, sizeof(gr_complex) * sampled_ms * samples_per_ms),
gr::io_signature::make(0, 0, sizeof(gr_complex) * sampled_ms * samples_per_ms))
gr::io_signature::make(1, 1, sizeof(gr_complex) * sampled_ms * samples_per_ms * ( bit_transition_flag ? 2 : 1 )),
gr::io_signature::make(0, 0, sizeof(gr_complex) * sampled_ms * samples_per_ms * ( bit_transition_flag ? 2 : 1 )) )
{
d_sample_counter = 0; // SAMPLE COUNTER
d_active = false;
@ -92,6 +93,24 @@ pcps_acquisition_cc::pcps_acquisition_cc(
d_channel = 0;
d_doppler_freq = 0.0;
//set_relative_rate( 1.0/d_fft_size );
// COD:
// Experimenting with the overlap/save technique for handling bit trannsitions
// The problem: Circular correlation is asynchronous with the received code.
// In effect the first code phase used in the correlation is the current
// estimate of the code phase at the start of the input buffer. If this is 1/2
// of the code period a bit transition would move all the signal energy into
// adjacent frequency bands at +/- 1/T where T is the integration time.
//
// 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_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()));
@ -135,7 +154,17 @@ pcps_acquisition_cc::~pcps_acquisition_cc()
void pcps_acquisition_cc::set_local_code(std::complex<float> * code)
{
memcpy(d_fft_if->get_inbuf(), code, sizeof(gr_complex) * d_fft_size);
// COD
// Here we want to create a buffer that looks like this:
// [ 0 0 0 ... 0 c_0 c_1 ... c_L]
// 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;
}
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);
}
@ -157,7 +186,7 @@ void pcps_acquisition_cc::init()
{
d_grid_doppler_wipeoffs[doppler_index] = static_cast<gr_complex*>(volk_malloc(d_fft_size * sizeof(gr_complex), volk_get_alignment()));
int doppler = -static_cast<int>(d_doppler_max) + d_doppler_step * doppler_index;
complex_exp_gen(d_grid_doppler_wipeoffs[doppler_index], d_freq - doppler, d_fs_in, d_fft_size);
complex_exp_gen(d_grid_doppler_wipeoffs[doppler_index], -d_freq - doppler, d_fs_in, d_fft_size);
}
}
@ -222,6 +251,8 @@ int pcps_acquisition_cc::general_work(int noutput_items,
d_sample_counter += d_fft_size * ninput_items[0]; // sample counter
consume_each(ninput_items[0]);
//DLOG(INFO) << "Consumed " << ninput_items[0] << " items";
break;
}
@ -232,7 +263,13 @@ int pcps_acquisition_cc::general_work(int noutput_items,
unsigned int indext = 0;
float magt = 0.0;
const gr_complex *in = (const gr_complex *)input_items[0]; //Get the input samples pointer
float fft_normalization_factor = static_cast<float>(d_fft_size) * static_cast<float>(d_fft_size);
int effective_fft_size = ( d_bit_transition_flag ? d_fft_size/2 : d_fft_size );
size_t offset = ( d_bit_transition_flag ? effective_fft_size : 0 );
float fft_normalization_factor = static_cast<float>(d_fft_size)
* static_cast<float>(d_fft_size);
d_input_power = 0.0;
d_mag = 0.0;
@ -273,8 +310,9 @@ int pcps_acquisition_cc::general_work(int noutput_items,
d_ifft->execute();
// Search maximum
volk_32fc_magnitude_squared_32f(d_magnitude, d_ifft->get_outbuf(), d_fft_size);
volk_32f_index_max_16u(&indext, d_magnitude, d_fft_size);
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);
// Normalize the maximum value to correct the scale factor introduced by FFTW
magt = d_magnitude[indext] / (fft_normalization_factor * fft_normalization_factor);
@ -309,9 +347,19 @@ int pcps_acquisition_cc::general_work(int noutput_items,
std::stringstream filename;
std::streamsize n = 2 * sizeof(float) * (d_fft_size); // complex file write
filename.str("");
filename << "../data/test_statistics_" << d_gnss_synchro->System
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 << ".dat";
<< d_gnss_synchro->PRN << "_doppler_"
<< doppler
<< p.extension().string();
DLOG(INFO) << "Writing ACQ out to " << filename.str();
d_dump_file.open(filename.str().c_str(), std::ios::out | std::ios::binary);
d_dump_file.write((char*)d_ifft->get_outbuf(), n); //write directly |abs(x)|^2 in this Doppler bin?
d_dump_file.close();
@ -346,6 +394,8 @@ int pcps_acquisition_cc::general_work(int noutput_items,
consume_each(1);
DLOG(INFO) << "Done. Consumed 1 item.";
break;
}
@ -402,3 +452,18 @@ int pcps_acquisition_cc::general_work(int noutput_items,
return noutput_items;
}
//void pcps_acquisition_cc::forecast (int noutput_items, gr_vector_int &ninput_items_required)
//{
//// COD:
//// For zero-padded case we need one extra code period
//if( d_bit_transition_flag )
//{
//ninput_items_required[0] = noutput_items*(d_samples_per_code * d_max_dwells + d_samples_per_code);
//}
//else
//{
//ninput_items_required[0] = noutput_items*d_fft_size*d_max_dwells;
//}
//}

View File

@ -316,7 +316,7 @@ int pcps_acquisition_fine_doppler_cc::estimate_Doppler(gr_vector_const_void_star
{
// Direct FFT
int zero_padding_factor = 16;
int zero_padding_factor = 2;
int fft_size_extended = d_fft_size * zero_padding_factor;
gr::fft::fft_complex *fft_operator = new gr::fft::fft_complex(fft_size_extended, true);