1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-14 04:00:34 +00:00
This commit is contained in:
Carles Fernandez 2019-10-30 12:27:31 +01:00
commit 0a111b0d42
52 changed files with 807 additions and 623 deletions

View File

@ -631,7 +631,6 @@ set(FILESYSTEM_FOUND FALSE)
if(NOT (GNURADIO_VERSION VERSION_LESS 3.8) AND LOG4CPP_READY_FOR_CXX17)
# Check if we have std::filesystem
if(NOT (CMAKE_VERSION VERSION_LESS 3.8))
if((NOT ENABLE_UNIT_TESTING_EXTRA) AND (NOT ENABLE_SYSTEM_TESTING_EXTRA) AND (NOT ENABLE_FPGA)) # Workaround for GPSTk
find_package(FILESYSTEM COMPONENTS Final Experimental)
set_package_properties(FILESYSTEM PROPERTIES
URL "https://en.cppreference.com/w/cpp/filesystem"
@ -648,7 +647,6 @@ if(NOT (GNURADIO_VERSION VERSION_LESS 3.8) AND LOG4CPP_READY_FOR_CXX17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
endif()
endif()
endif()

View File

@ -571,7 +571,7 @@ More details can be found in our tutorial about [GNSS-SDR configuration options
<a name="macosx">macOS and Mac OS X</a>
---------
GNSS-SDR can be built on MacOS or Mac OS X, starting from 10.9 (Mavericks) and including 10.14 (Mojave). If you still have not installed [Xcode](https://developer.apple.com/xcode/ "Xcode"), do it now from the App Store (it's free). You will also need the Xcode Command Line Tools. Launch the Terminal, found in /Applications/Utilities/, and type:
GNSS-SDR can be built on MacOS or Mac OS X, starting from 10.9 (Mavericks) and including 10.15 (Catalina). If you still have not installed [Xcode](https://developer.apple.com/xcode/ "Xcode"), do it now from the App Store (it's free). You will also need the Xcode Command Line Tools. Launch the Terminal, found in /Applications/Utilities/, and type:
~~~~~~
$ xcode-select --install

View File

@ -21,8 +21,9 @@
- Fixed PVT solution in receivers processing L1 plus L2C and/or L5 signals.
- Added RINEX files generation for triple-band configurations (L1 + L2C + L5 and L1 + E1 + L2C + L5 + E5a).
- Fixed a bug in the decoding of BeiDou navigation messages.
- Fixed bugs in the decoding of BeiDou navigation messages.
- Improved management of devices with the AD9361 RF transceiver.
- Fixed bugs in FPGA off-loading.
### Improvements in Maintainability:
@ -45,11 +46,17 @@
- Decoding of navigation messages no longer rely on implementation defined behavior for shifting left a signed integer.
- Removed usage of functions with insecure API (e.g., strcpy, sprintf).
- New type alias volk_gnsssdr::vector allows both aligned memory allocation and automatic deallocation.
- Added clang-tidy checks clang-analyzer-security.*, clang-analyzer-optin.portability.UnixAPI clang-tidy checks. Fixed raised warnings.
- Fixed cpplint.py runtime/printf and runtime/explicit errors.
- All constructors callable with one argument are marked with the keyword explicit. See MISRA C++:2008, 12-1-3 - All constructors that are callable with a single argument of fundamental type shall be declared explicit.
### Improvements in Testability:
- Add receiver runtime to position_test report.
### Improvements in Usability:
- A new parameter allows to process raw sample files containing GPS L1 C/A signals dated before July 14, 2009.

View File

@ -38,7 +38,7 @@
#include <gnuradio/fft/fft.h> // for fft_complex
#include <gnuradio/gr_complex.h> // for gr_complex
#include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <algorithm> // for copy_n
#include <cmath> // for abs, pow, floor
#include <complex> // for complex
@ -99,8 +99,8 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga(
// compute all the GALILEO E1 PRN Codes (this is done only once in the class constructor in order to avoid re-computing the PRN codes every time
// a channel is assigned)
auto fft_if = std::unique_ptr<gr::fft::fft_complex>(new gr::fft::fft_complex(nsamples_total, true)); // Direct FFT
std::vector<std::complex<float>> code(nsamples_total); // buffer for the local code
auto* fft_codes_padded = static_cast<gr_complex*>(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
volk_gnsssdr::vector<std::complex<float>> code(nsamples_total); // buffer for the local code
volk_gnsssdr::vector<gr_complex> fft_codes_padded(nsamples_total);
d_all_fft_codes_ = std::vector<uint32_t>(nsamples_total * GALILEO_E1_NUMBER_OF_CODES); // memory containing all the possible fft codes for PRN 0 to 32
float max; // temporary maxima search
@ -140,7 +140,7 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga(
std::copy_n(code.data(), nsamples_total, fft_if->get_inbuf()); // copy to FFT buffer
fft_if->execute(); // Run the FFT of local code
volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values
volk_32fc_conjugate_32fc(fft_codes_padded.data(), fft_if->get_outbuf(), nsamples_total); // conjugate values
// normalize the code
max = 0; // initialize maximum value
@ -182,9 +182,6 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga(
doppler_step_ = 0;
gnss_synchro_ = nullptr;
// temporary buffers that we can release
volk_gnsssdr_free(fft_codes_padded);
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";

View File

@ -38,7 +38,7 @@
#include <gnuradio/fft/fft.h> // for fft_complex
#include <gnuradio/gr_complex.h> // for gr_complex
#include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <algorithm> // for copy_n
#include <cmath> // for abs, pow, floor
#include <complex> // for complex
@ -100,8 +100,8 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf
// compute all the GALILEO E5 PRN Codes (this is done only once in the class constructor in order to avoid re-computing the PRN codes every time
// a channel is assigned)
auto fft_if = std::unique_ptr<gr::fft::fft_complex>(new gr::fft::fft_complex(nsamples_total, true)); // Direct FFT
std::vector<std::complex<float>> code(nsamples_total); // buffer for the local code
auto* fft_codes_padded = static_cast<gr_complex*>(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
volk_gnsssdr::vector<std::complex<float>> code(nsamples_total);
volk_gnsssdr::vector<std::complex<float>> fft_codes_padded(nsamples_total);
d_all_fft_codes_ = std::vector<uint32_t>(nsamples_total * GALILEO_E5A_NUMBER_OF_CODES); // memory containing all the possible fft codes for PRN 0 to 32
float max; // temporary maxima search
@ -144,7 +144,7 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf
std::copy_n(code.data(), nsamples_total, fft_if->get_inbuf()); // copy to FFT buffer
fft_if->execute(); // Run the FFT of local code
volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values
volk_32fc_conjugate_32fc(fft_codes_padded.data(), fft_if->get_outbuf(), nsamples_total); // conjugate values
max = 0; // initialize maximum value
for (uint32_t i = 0; i < nsamples_total; i++) // search for maxima
@ -185,9 +185,6 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf
doppler_step_ = 0;
gnss_synchro_ = nullptr;
// temporary buffers that we can release
volk_gnsssdr_free(fft_codes_padded);
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";

View File

@ -41,7 +41,7 @@
#include <gnuradio/fft/fft.h>
#include <gnuradio/gr_complex.h> // for gr_complex
#include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <algorithm> // for copy_n
#include <cmath> // for abs, pow, floor
#include <complex> // for complex
@ -93,8 +93,8 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga(
// a channel is assigned)
auto fft_if = std::unique_ptr<gr::fft::fft_complex>(new gr::fft::fft_complex(nsamples_total, true));
// allocate memory to compute all the PRNs and compute all the possible codes
std::vector<std::complex<float>> code(nsamples_total); // buffer for the local code
auto* fft_codes_padded = static_cast<gr_complex*>(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
volk_gnsssdr::vector<std::complex<float>> code(nsamples_total);
volk_gnsssdr::vector<std::complex<float>> fft_codes_padded(nsamples_total);
d_all_fft_codes_ = std::vector<uint32_t>(nsamples_total * NUM_PRNs); // memory containing all the possible fft codes for PRN 0 to 32
float max;
int32_t tmp;
@ -119,7 +119,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga(
std::copy_n(code.data(), nsamples_total, fft_if->get_inbuf()); // copy to FFT buffer
fft_if->execute(); // Run the FFT of local code
volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values
volk_32fc_conjugate_32fc(fft_codes_padded.data(), fft_if->get_outbuf(), nsamples_total); // conjugate values
max = 0; // initialize maximum value
for (uint32_t i = 0; i < nsamples_total; i++) // search for maxima
@ -161,9 +161,6 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga(
doppler_step_ = 0;
gnss_synchro_ = nullptr;
// temporary buffers that we can release
volk_gnsssdr_free(fft_codes_padded);
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";

View File

@ -41,7 +41,7 @@
#include <gnuradio/fft/fft.h> // for fft_complex
#include <gnuradio/gr_complex.h> // for gr_complex
#include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <algorithm> // for copy_n
#include <cmath> // for abs, pow, floor
#include <complex> // for complex
@ -94,8 +94,8 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga(
// a channel is assigned)
auto fft_if = std::unique_ptr<gr::fft::fft_complex>(new gr::fft::fft_complex(nsamples_total, true)); // Direct FFT
// allocate memory to compute all the PRNs and compute all the possible codes
std::vector<std::complex<float>> code(nsamples_total); // buffer for the local code
auto* fft_codes_padded = static_cast<gr_complex*>(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
volk_gnsssdr::vector<std::complex<float>> code(nsamples_total);
volk_gnsssdr::vector<std::complex<float>> fft_codes_padded(nsamples_total);
d_all_fft_codes_ = std::vector<uint32_t>(nsamples_total * NUM_PRNs); // memory containing all the possible fft codes for PRN 0 to 32
float max; // temporary maxima search
@ -114,7 +114,7 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga(
}
std::copy_n(code.data(), nsamples_total, fft_if->get_inbuf()); // copy to FFT buffer
fft_if->execute(); // Run the FFT of local code
volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values
volk_32fc_conjugate_32fc(fft_codes_padded.data(), fft_if->get_outbuf(), nsamples_total); // conjugate values
max = 0; // initialize maximum value
for (unsigned int i = 0; i < nsamples_total; i++) // search for maxima
{
@ -152,9 +152,6 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga(
threshold_ = 0.0;
// temporary buffers that we can release
volk_gnsssdr_free(fft_codes_padded);
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";

View File

@ -41,7 +41,7 @@
#include <gnuradio/fft/fft.h> // for fft_complex
#include <gnuradio/gr_complex.h> // for gr_complex
#include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <algorithm> // for copy_n
#include <cmath> // for abs, pow, floor
#include <complex> // for complex
@ -97,8 +97,8 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga(
// compute all the GPS L5 PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time
// a channel is assigned)
auto fft_if = std::unique_ptr<gr::fft::fft_complex>(new gr::fft::fft_complex(nsamples_total, true)); // Direct FFT
std::vector<std::complex<float>> code(nsamples_total);
auto* fft_codes_padded = static_cast<gr_complex*>(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
volk_gnsssdr::vector<std::complex<float>> code(nsamples_total);
volk_gnsssdr::vector<std::complex<float>> fft_codes_padded(nsamples_total);
d_all_fft_codes_ = std::vector<uint32_t>(nsamples_total * NUM_PRNs); // memory containing all the possible fft codes for PRN 0 to 32
float max; // temporary maxima search
@ -123,7 +123,7 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga(
}
std::copy_n(code.data(), nsamples_total, fft_if->get_inbuf()); // copy to FFT buffer
fft_if->execute(); // Run the FFT of local code
volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values
volk_32fc_conjugate_32fc(fft_codes_padded.data(), fft_if->get_outbuf(), nsamples_total); // conjugate values
max = 0; // initialize maximum value
for (uint32_t i = 0; i < nsamples_total; i++) // search for maxima
@ -164,9 +164,6 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga(
doppler_step_ = 0;
gnss_synchro_ = nullptr;
// temporary buffers that we can release
volk_gnsssdr_free(fft_codes_padded);
if (in_streams_ > 1)
{
LOG(ERROR) << "This implementation only supports one input stream";

View File

@ -76,12 +76,11 @@ target_link_libraries(acquisition_gr_blocks
Gnuradio::runtime
Gnuradio::fft
Volk::volk
Volkgnsssdr::volkgnsssdr
PRIVATE
Gflags::gflags
Glog::glog
Matio::matio
Volkgnsssdr::volkgnsssdr
)
target_include_directories(acquisition_gr_blocks

View File

@ -135,9 +135,9 @@ pcps_acquisition::pcps_acquisition(const Acq_Conf& conf_) : gr::block("pcps_acqu
acq_parameters.max_dwells = 1; // Activation of acq_parameters.bit_transition_flag invalidates the value of acq_parameters.max_dwells
}
d_tmp_buffer = std::vector<float>(d_fft_size);
d_fft_codes = std::vector<std::complex<float>>(d_fft_size);
d_input_signal = std::vector<std::complex<float>>(d_fft_size);
d_tmp_buffer = volk_gnsssdr::vector<float>(d_fft_size);
d_fft_codes = volk_gnsssdr::vector<std::complex<float>>(d_fft_size);
d_input_signal = volk_gnsssdr::vector<std::complex<float>>(d_fft_size);
// Direct FFT
d_fft_if = std::make_shared<gr::fft::fft_complex>(d_fft_size, true);
@ -147,10 +147,10 @@ pcps_acquisition::pcps_acquisition(const Acq_Conf& conf_) : gr::block("pcps_acqu
d_gnss_synchro = nullptr;
d_worker_active = false;
d_data_buffer = std::vector<std::complex<float>>(d_consumed_samples);
d_data_buffer = volk_gnsssdr::vector<std::complex<float>>(d_consumed_samples);
if (d_cshort)
{
d_data_buffer_sc = std::vector<lv_16sc_t>(d_consumed_samples);
d_data_buffer_sc = volk_gnsssdr::vector<lv_16sc_t>(d_consumed_samples);
}
grid_ = arma::fmat();
narrow_grid_ = arma::fmat();
@ -304,16 +304,16 @@ void pcps_acquisition::init()
// Create the carrier Doppler wipeoff signals
if (d_grid_doppler_wipeoffs.empty())
{
d_grid_doppler_wipeoffs = std::vector<std::vector<std::complex<float>>>(d_num_doppler_bins, std::vector<std::complex<float>>(d_fft_size));
d_grid_doppler_wipeoffs = volk_gnsssdr::vector<volk_gnsssdr::vector<std::complex<float>>>(d_num_doppler_bins, volk_gnsssdr::vector<std::complex<float>>(d_fft_size));
}
if (acq_parameters.make_2_steps && (d_grid_doppler_wipeoffs_step_two.empty()))
{
d_grid_doppler_wipeoffs_step_two = std::vector<std::vector<std::complex<float>>>(d_num_doppler_bins_step2, std::vector<std::complex<float>>(d_fft_size));
d_grid_doppler_wipeoffs_step_two = volk_gnsssdr::vector<volk_gnsssdr::vector<std::complex<float>>>(d_num_doppler_bins_step2, volk_gnsssdr::vector<std::complex<float>>(d_fft_size));
}
if (d_magnitude_grid.empty())
{
d_magnitude_grid = std::vector<std::vector<float>>(d_num_doppler_bins, std::vector<float>(d_fft_size));
d_magnitude_grid = volk_gnsssdr::vector<volk_gnsssdr::vector<float>>(d_num_doppler_bins, volk_gnsssdr::vector<float>(d_fft_size));
}
for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)

View File

@ -67,12 +67,12 @@
#include <gnuradio/types.h> // for gr_vector_const_void_star
#include <gsl/gsl> // for Guidelines Support Library
#include <volk/volk_complex.h> // for lv_16sc_t
#include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
#include <complex>
#include <cstdint>
#include <memory>
#include <string>
#include <utility>
#include <vector>
class Gnss_Synchro;
class pcps_acquisition;
@ -243,14 +243,14 @@ private:
float d_test_statistics;
float d_doppler_center_step_two;
std::string d_dump_filename;
std::vector<std::vector<float>> d_magnitude_grid;
std::vector<float> d_tmp_buffer;
std::vector<std::complex<float>> d_input_signal;
std::vector<std::vector<std::complex<float>>> d_grid_doppler_wipeoffs;
std::vector<std::vector<std::complex<float>>> d_grid_doppler_wipeoffs_step_two;
std::vector<std::complex<float>> d_fft_codes;
std::vector<std::complex<float>> d_data_buffer;
std::vector<lv_16sc_t> d_data_buffer_sc;
volk_gnsssdr::vector<volk_gnsssdr::vector<float>> d_magnitude_grid;
volk_gnsssdr::vector<float> d_tmp_buffer;
volk_gnsssdr::vector<std::complex<float>> d_input_signal;
volk_gnsssdr::vector<volk_gnsssdr::vector<std::complex<float>>> d_grid_doppler_wipeoffs;
volk_gnsssdr::vector<volk_gnsssdr::vector<std::complex<float>>> d_grid_doppler_wipeoffs_step_two;
volk_gnsssdr::vector<std::complex<float>> d_fft_codes;
volk_gnsssdr::vector<std::complex<float>> d_data_buffer;
volk_gnsssdr::vector<lv_16sc_t> d_data_buffer_sc;
std::shared_ptr<gr::fft::fft_complex> d_fft_if;
std::shared_ptr<gr::fft::fft_complex> d_ifft;
std::weak_ptr<ChannelFsm> d_channel_fsm;

View File

@ -47,10 +47,10 @@
#include <gnuradio/io_signature.h>
#include <matio.h>
#include <volk/volk.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <algorithm> // std::rotate, std::fill_n
#include <array>
#include <sstream>
#include <vector>
#if HAS_STD_FILESYSTEM
#if HAS_STD_FILESYSTEM_EXPERIMENTAL
@ -87,12 +87,9 @@ pcps_acquisition_fine_doppler_cc::pcps_acquisition_fine_doppler_cc(const Acq_Con
d_max_dwells = conf_.max_dwells;
d_gnuradio_forecast_samples = d_fft_size;
d_state = 0;
d_carrier = static_cast<gr_complex *>(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_fft_codes = static_cast<gr_complex *>(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_magnitude = static_cast<float *>(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment()));
d_10_ms_buffer = static_cast<gr_complex *>(volk_gnsssdr_malloc(50 * d_samples_per_ms * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_fft_codes.reserve(d_fft_size);
d_magnitude.reserve(d_fft_size);
d_10_ms_buffer.reserve(50 * d_samples_per_ms);
// Direct FFT
d_fft_if = std::make_shared<gr::fft::fft_complex>(d_fft_size, true);
@ -175,7 +172,7 @@ void pcps_acquisition_fine_doppler_cc::set_doppler_step(unsigned int doppler_ste
d_num_doppler_points = floor(std::abs(2 * d_config_doppler_max) / d_doppler_step);
d_grid_data = std::vector<std::vector<float>>(d_num_doppler_points, std::vector<float>(d_fft_size));
d_grid_data = volk_gnsssdr::vector<volk_gnsssdr::vector<float>>(d_num_doppler_points, volk_gnsssdr::vector<float>(d_fft_size));
if (d_dump)
{
@ -186,21 +183,12 @@ void pcps_acquisition_fine_doppler_cc::set_doppler_step(unsigned int doppler_ste
}
pcps_acquisition_fine_doppler_cc::~pcps_acquisition_fine_doppler_cc()
{
volk_gnsssdr_free(d_carrier);
volk_gnsssdr_free(d_fft_codes);
volk_gnsssdr_free(d_magnitude);
volk_gnsssdr_free(d_10_ms_buffer);
}
void pcps_acquisition_fine_doppler_cc::set_local_code(std::complex<float> *code)
{
memcpy(d_fft_if->get_inbuf(), code, sizeof(gr_complex) * d_fft_size);
d_fft_if->execute(); // We need the FFT of local code
// Conjugate the local code
volk_32fc_conjugate_32fc(d_fft_codes, d_fft_if->get_outbuf(), d_fft_size);
volk_32fc_conjugate_32fc(d_fft_codes.data(), d_fft_if->get_outbuf(), d_fft_size);
}
@ -247,7 +235,7 @@ void pcps_acquisition_fine_doppler_cc::update_carrier_wipeoff()
// create the carrier Doppler wipeoff signals
int doppler_hz;
float phase_step_rad;
d_grid_doppler_wipeoffs = std::vector<std::vector<std::complex<float>>>(d_num_doppler_points, std::vector<std::complex<float>>(d_fft_size));
d_grid_doppler_wipeoffs = volk_gnsssdr::vector<volk_gnsssdr::vector<std::complex<float>>>(d_num_doppler_points, volk_gnsssdr::vector<std::complex<float>>(d_fft_size));
for (int doppler_index = 0; doppler_index < d_num_doppler_points; doppler_index++)
{
doppler_hz = d_doppler_step * doppler_index - d_config_doppler_max;
@ -338,8 +326,8 @@ float pcps_acquisition_fine_doppler_cc::estimate_input_power(gr_vector_const_voi
const auto *in = reinterpret_cast<const gr_complex *>(input_items[0]); // Get the input samples pointer
// Compute the input signal power estimation
float power = 0;
volk_32fc_magnitude_squared_32f(d_magnitude, in, d_fft_size);
volk_32f_accumulator_s32f(&power, d_magnitude, d_fft_size);
volk_32fc_magnitude_squared_32f(d_magnitude.data(), in, d_fft_size);
volk_32f_accumulator_s32f(&power, d_magnitude.data(), d_fft_size);
power /= static_cast<float>(d_fft_size);
return power;
}
@ -357,7 +345,7 @@ int pcps_acquisition_fine_doppler_cc::compute_and_accumulate_grid(gr_vector_cons
<< ", doppler_step: " << d_doppler_step;
// 2- Doppler frequency search loop
auto *p_tmp_vector = static_cast<float *>(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment()));
volk_gnsssdr::vector<float> p_tmp_vector(d_fft_size);
for (int doppler_index = 0; doppler_index < d_num_doppler_points; doppler_index++)
{
@ -371,18 +359,17 @@ int pcps_acquisition_fine_doppler_cc::compute_and_accumulate_grid(gr_vector_cons
// 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);
volk_32fc_x2_multiply_32fc(d_ifft->get_inbuf(), d_fft_if->get_outbuf(), d_fft_codes.data(), d_fft_size);
// compute the inverse FFT
d_ifft->execute();
// save the grid matrix delay file
volk_32fc_magnitude_squared_32f(p_tmp_vector, d_ifft->get_outbuf(), d_fft_size);
volk_32fc_magnitude_squared_32f(p_tmp_vector.data(), d_ifft->get_outbuf(), d_fft_size);
// accumulate grid values
volk_32f_x2_add_32f(d_grid_data[doppler_index].data(), d_grid_data[doppler_index].data(), p_tmp_vector, d_fft_size);
volk_32f_x2_add_32f(d_grid_data[doppler_index].data(), d_grid_data[doppler_index].data(), p_tmp_vector.data(), d_fft_size);
}
volk_gnsssdr_free(p_tmp_vector);
return d_fft_size;
// debug
// std::cout << "iff=[";
@ -408,39 +395,38 @@ int pcps_acquisition_fine_doppler_cc::estimate_Doppler()
std::fill_n(fft_operator->get_inbuf(), fft_size_extended, gr_complex(0.0, 0.0));
// 1. generate local code aligned with the acquisition code phase estimation
auto *code_replica = static_cast<gr_complex *>(volk_gnsssdr_malloc(signal_samples * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
volk_gnsssdr::vector<gr_complex> code_replica(signal_samples);
gps_l1_ca_code_gen_complex_sampled(gsl::span<gr_complex>(code_replica, signal_samples * sizeof(gr_complex)), d_gnss_synchro->PRN, d_fs_in, 0);
gps_l1_ca_code_gen_complex_sampled(code_replica, d_gnss_synchro->PRN, d_fs_in, 0);
int shift_index = static_cast<int>(d_gnss_synchro->Acq_delay_samples);
// Rotate to align the local code replica using acquisition time delay estimation
if (shift_index != 0)
{
std::rotate(code_replica, code_replica + (d_fft_size - shift_index), code_replica + d_fft_size - 1);
std::rotate(code_replica.data(), code_replica.data() + (d_fft_size - shift_index), code_replica.data() + d_fft_size - 1);
}
for (int n = 0; n < prn_replicas - 1; n++)
{
memcpy(&code_replica[(n + 1) * d_fft_size], code_replica, d_fft_size * sizeof(gr_complex));
memcpy(&code_replica[(n + 1) * d_fft_size], code_replica.data(), d_fft_size * sizeof(gr_complex));
}
// 2. Perform code wipe-off
volk_32fc_x2_multiply_32fc(fft_operator->get_inbuf(), d_10_ms_buffer, code_replica, signal_samples);
volk_32fc_x2_multiply_32fc(fft_operator->get_inbuf(), d_10_ms_buffer.data(), code_replica.data(), signal_samples);
// 3. Perform the FFT (zero padded!)
fft_operator->execute();
// 4. Compute the magnitude and find the maximum
auto *p_tmp_vector = static_cast<float *>(volk_gnsssdr_malloc(fft_size_extended * sizeof(float), volk_gnsssdr_get_alignment()));
volk_32fc_magnitude_squared_32f(p_tmp_vector, fft_operator->get_outbuf(), fft_size_extended);
volk_gnsssdr::vector<float> p_tmp_vector(fft_size_extended);
volk_32fc_magnitude_squared_32f(p_tmp_vector.data(), fft_operator->get_outbuf(), fft_size_extended);
uint32_t tmp_index_freq = 0;
volk_gnsssdr_32f_index_max_32u(&tmp_index_freq, p_tmp_vector, fft_size_extended);
volk_gnsssdr_32f_index_max_32u(&tmp_index_freq, p_tmp_vector.data(), fft_size_extended);
// case even
int counter = 0;
auto fftFreqBins = std::vector<float>(fft_size_extended);
volk_gnsssdr::vector<float> fftFreqBins(fft_size_extended);
for (int k = 0; k < (fft_size_extended / 2); k++)
{
@ -466,9 +452,6 @@ int pcps_acquisition_fine_doppler_cc::estimate_Doppler()
DLOG(INFO) << "Error estimating fine frequency Doppler";
}
// free memory!!
volk_gnsssdr_free(code_replica);
volk_gnsssdr_free(p_tmp_vector);
return d_fft_size;
}

View File

@ -60,12 +60,12 @@
#include <gnuradio/block.h>
#include <gnuradio/fft/fft.h>
#include <gnuradio/gr_complex.h>
#include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
#include <cstdint>
#include <fstream>
#include <memory>
#include <string>
#include <utility>
#include <vector>
class pcps_acquisition_fine_doppler_cc;
@ -83,7 +83,7 @@ public:
/*!
* \brief Default destructor.
*/
~pcps_acquisition_fine_doppler_cc();
~pcps_acquisition_fine_doppler_cc() = default;
/*!
* \brief Set acquisition/tracking common Gnss_Synchro object pointer
@ -192,8 +192,7 @@ public:
gr_vector_void_star& output_items);
private:
friend pcps_acquisition_fine_doppler_cc_sptr
pcps_make_acquisition_fine_doppler_cc(const Acq_Conf& conf_);
friend pcps_acquisition_fine_doppler_cc_sptr pcps_make_acquisition_fine_doppler_cc(const Acq_Conf& conf_);
explicit pcps_acquisition_fine_doppler_cc(const Acq_Conf& conf_);
int compute_and_accumulate_grid(gr_vector_const_void_star& input_items);
@ -215,12 +214,11 @@ private:
int d_doppler_step;
unsigned int d_fft_size;
uint64_t d_sample_counter;
gr_complex* d_carrier;
gr_complex* d_fft_codes;
gr_complex* d_10_ms_buffer;
float* d_magnitude;
std::vector<std::vector<float>> d_grid_data;
std::vector<std::vector<std::complex<float>>> d_grid_doppler_wipeoffs;
volk_gnsssdr::vector<gr_complex> d_fft_codes;
volk_gnsssdr::vector<gr_complex> d_10_ms_buffer;
volk_gnsssdr::vector<float> d_magnitude;
volk_gnsssdr::vector<volk_gnsssdr::vector<float>> d_grid_data;
volk_gnsssdr::vector<volk_gnsssdr::vector<std::complex<float>>> d_grid_doppler_wipeoffs;
std::shared_ptr<gr::fft::fft_complex> d_fft_if;
std::shared_ptr<gr::fft::fft_complex> d_ifft;
Gnss_Synchro* d_gnss_synchro;

View File

@ -195,7 +195,6 @@ void pcps_acquisition_fpga::acquisition_core(uint32_t num_doppler_bins, uint32_t
if (total_block_exp > d_total_block_exp)
{
// if the attenuation factor of the FPGA FFT-IFFT is smaller than the reference attenuation factor then we need to update the reference attenuation factor
std::cout << "changing blk exp..... d_total_block_exp = " << d_total_block_exp << " total_block_exp = " << total_block_exp << " chan = " << d_channel << std::endl;
d_total_block_exp = total_block_exp;
d_test_statistics = 0;
}

View File

@ -325,6 +325,7 @@ install(
)
install(FILES
${PROJECT_SOURCE_DIR}/include/volk_gnsssdr/volk_gnsssdr_alloc.h
${PROJECT_SOURCE_DIR}/include/volk_gnsssdr/volk_gnsssdr_prefs.h
${PROJECT_SOURCE_DIR}/include/volk_gnsssdr/volk_gnsssdr_complex.h
${PROJECT_SOURCE_DIR}/include/volk_gnsssdr/volk_gnsssdr_common.h

View File

@ -0,0 +1,84 @@
/*!
* \file volk_gnsssdr_alloc.h
* \author Carles Fernandez, 2019. cfernandez(at)cttc.es
* \brief C++11 allocator using volk_gnsssdr_malloc and volk_gnsssdr_free.
* Based on https://github.com/gnuradio/volk/pull/284/ by @hcab14
*
* Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors)
*
* This file is part of GNSS-SDR.
*
* GNSS-SDR is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GNSS-SDR is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef INCLUDED_VOLK_GNSSSDR_ALLOC_H
#define INCLUDED_VOLK_GNSSSDR_ALLOC_H
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <cstdlib>
#include <limits>
#include <new>
#include <vector>
namespace volk_gnsssdr
{
/*!
* \brief C++11 allocator using volk_gnsssdr_malloc and volk_gnsssdr_free
*
* \details
* adapted from https://en.cppreference.com/w/cpp/named_req/Alloc
*/
template <class T>
struct alloc
{
typedef T value_type;
alloc() = default;
template <class U>
constexpr alloc(alloc<U> const&) noexcept {}
T* allocate(std::size_t n)
{
if (n > std::numeric_limits<std::size_t>::max() / sizeof(T)) throw std::bad_alloc();
if (auto p = static_cast<T*>(volk_gnsssdr_malloc(n * sizeof(T), volk_gnsssdr_get_alignment())))
return p;
throw std::bad_alloc();
}
void deallocate(T* p, std::size_t) noexcept { volk_gnsssdr_free(p); }
};
template <class T, class U>
bool operator==(alloc<T> const&, alloc<U> const&) { return true; }
template <class T, class U>
bool operator!=(alloc<T> const&, alloc<U> const&) { return false; }
/*!
* \brief type alias for std::vector using volk_gnsssdr::alloc
*
* \details
* example code:
* volk_gnsssdr::vector<float> v(100); // vector using volk_gnsssdr_malloc, volk_gnsssdr_free
*/
template <class T>
using vector = std::vector<T, alloc<T> >;
} // namespace volk_gnsssdr
#endif // INCLUDED_VOLK_GNSSSDR_ALLOC_H

View File

@ -39,20 +39,21 @@
#include <glog/logging.h>
#include <iio.h>
#include <algorithm> // for max
#include <chrono> // for std::this_thread
#include <cmath> // for abs
#include <exception> // for exceptions
#include <fcntl.h> // for open, O_WRONLY
#include <fstream> // for std::ifstream
#include <iostream> // for cout, endl
#include <string> // for string manipulation
#include <thread> // for std::chrono
#include <unistd.h> // for write
#include <utility>
#include <vector>
void run_DMA_process(const std::string &FreqBand, const std::string &Filename1, const std::string &Filename2, const bool &enable_DMA)
{
const int MAX_INPUT_SAMPLES_TOTAL = 8192;
const int MAX_INPUT_SAMPLES_TOTAL = 16384;
int max_value = 0;
int tx_fd; // DMA descriptor
std::ifstream infile1;
@ -256,6 +257,9 @@ void run_DMA_process(const std::string &FreqBand, const std::string &Filename1,
{
std::cerr << "Error: DMA could not send all the required samples " << std::endl;
}
// Throttle the DMA
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
if (nread_elements != MAX_INPUT_SAMPLES_TOTAL * 2)

View File

@ -42,7 +42,7 @@
#include "galileo_e1_signal_processing.h"
#include "gnss_sdr_flags.h"
#include <glog/logging.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <array>
GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga(
@ -193,19 +193,18 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga(
//################# PRE-COMPUTE ALL THE CODES #################
uint32_t code_samples_per_chip = 2;
d_ca_codes = static_cast<int32_t*>(volk_gnsssdr_malloc(static_cast<int32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS) * code_samples_per_chip * GALILEO_E1_NUMBER_OF_CODES * sizeof(int32_t), volk_gnsssdr_get_alignment()));
float* ca_codes_f;
float* data_codes_f = nullptr;
volk_gnsssdr::vector<float> ca_codes_f(static_cast<uint32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS) * code_samples_per_chip);
volk_gnsssdr::vector<float> data_codes_f;
d_data_codes = nullptr;
if (d_track_pilot)
{
d_data_codes = static_cast<int32_t*>(volk_gnsssdr_malloc((static_cast<uint32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS)) * code_samples_per_chip * GALILEO_E1_NUMBER_OF_CODES * sizeof(int32_t), volk_gnsssdr_get_alignment()));
}
ca_codes_f = static_cast<float*>(volk_gnsssdr_malloc(static_cast<int32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS) * code_samples_per_chip * sizeof(float), volk_gnsssdr_get_alignment()));
if (d_track_pilot)
{
data_codes_f = static_cast<float*>(volk_gnsssdr_malloc((static_cast<uint32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS)) * code_samples_per_chip * sizeof(float), volk_gnsssdr_get_alignment()));
data_codes_f.resize(static_cast<uint32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS) * code_samples_per_chip, 0.0);
}
for (uint32_t PRN = 1; PRN <= GALILEO_E1_NUMBER_OF_CODES; PRN++)
@ -214,8 +213,8 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga(
if (d_track_pilot)
{
std::array<char, 3> pilot_signal = {'1', 'C', '\0'};
galileo_e1_code_gen_sinboc11_float(gsl::span<float>(ca_codes_f, static_cast<int32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS) * code_samples_per_chip), pilot_signal, PRN);
galileo_e1_code_gen_sinboc11_float(gsl::span<float>(data_codes_f, static_cast<uint32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS) * code_samples_per_chip), data_signal, PRN);
galileo_e1_code_gen_sinboc11_float(ca_codes_f, pilot_signal, PRN);
galileo_e1_code_gen_sinboc11_float(data_codes_f, data_signal, PRN);
// The code is generated as a series of 1s and -1s. In order to store the values using only one bit, a -1 is stored as a 0 in the FPGA
for (uint32_t s = 0; s < 2 * GALILEO_E1_B_CODE_LENGTH_CHIPS; s++)
@ -238,7 +237,7 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga(
}
else
{
galileo_e1_code_gen_sinboc11_float(gsl::span<float>(ca_codes_f, static_cast<int32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS) * code_samples_per_chip), data_signal, PRN);
galileo_e1_code_gen_sinboc11_float(ca_codes_f, data_signal, PRN);
// The code is generated as a series of 1s and -1s. In order to store the values using only one bit, a -1 is stored as a 0 in the FPGA
for (uint32_t s = 0; s < 2 * GALILEO_E1_B_CODE_LENGTH_CHIPS; s++)
@ -254,11 +253,6 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga(
}
}
volk_gnsssdr_free(ca_codes_f);
if (d_track_pilot)
{
volk_gnsssdr_free(data_codes_f);
}
trk_param_fpga.ca_codes = d_ca_codes;
trk_param_fpga.data_codes = d_data_codes;
trk_param_fpga.code_length_chips = GALILEO_E1_B_CODE_LENGTH_CHIPS;

View File

@ -37,7 +37,7 @@
#include "galileo_e5_signal_processing.h"
#include "gnss_sdr_flags.h"
#include <glog/logging.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <array>
GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga(
@ -181,16 +181,19 @@ GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga(
trk_param_fpga.dev_file_num = configuration->property(role + ".dev_file_num", 27);
// compute the number of tracking channels that have already been instantiated. The order in which
// GNSS-SDR instantiates the tracking channels i L1, L2, L5, E1, E5a
// However E5a can use the same tracking HW accelerators as L5 (but not simultaneously).
// Therefore for the proper assignment of the FPGA tracking device file numbers to the E5a tracking channels,
// the number of channels that have already been assigned to L5 must not be substracted to this channel number,
// so they are not counted here.
trk_param_fpga.num_prev_assigned_ch = configuration->property("Channels_1C.count", 0) +
configuration->property("Channels_2S.count", 0) +
configuration->property("Channels_L5.count", 0) +
configuration->property("Channels_1B.count", 0);
// ################# PRE-COMPUTE ALL THE CODES #################
uint32_t code_samples_per_chip = 1;
auto code_length_chips = static_cast<uint32_t>(GALILEO_E5A_CODE_LENGTH_CHIPS);
auto *aux_code = static_cast<gr_complex *>(volk_gnsssdr_malloc(sizeof(gr_complex) * code_length_chips * code_samples_per_chip, volk_gnsssdr_get_alignment()));
volk_gnsssdr::vector<gr_complex> aux_code(code_length_chips * code_samples_per_chip, gr_complex(0.0, 0.0));
d_ca_codes = static_cast<int32_t *>(volk_gnsssdr_malloc(static_cast<int32_t>(code_length_chips) * code_samples_per_chip * GALILEO_E5A_NUMBER_OF_CODES * sizeof(int32_t), volk_gnsssdr_get_alignment()));
@ -202,7 +205,7 @@ GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga(
for (uint32_t PRN = 1; PRN <= GALILEO_E5A_NUMBER_OF_CODES; PRN++)
{
std::array<char, 3> sig_a = {'5', 'X', '\0'};
galileo_e5_a_code_gen_complex_primary(gsl::span<gr_complex>(aux_code, code_length_chips * code_samples_per_chip), PRN, sig_a);
galileo_e5_a_code_gen_complex_primary(aux_code, PRN, sig_a);
if (trk_param_fpga.track_pilot)
{
@ -242,7 +245,6 @@ GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga(
}
}
volk_gnsssdr_free(aux_code);
trk_param_fpga.ca_codes = d_ca_codes;
trk_param_fpga.data_codes = d_data_codes;
trk_param_fpga.code_length_chips = code_length_chips;

View File

@ -44,7 +44,7 @@
#include "gnss_synchro.h"
#include "gps_l2c_signal.h"
#include <glog/logging.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <array>
#include <cmath> // for round
#include <cstring> // for memcpy
@ -123,22 +123,18 @@ GpsL2MDllPllTrackingFpga::GpsL2MDllPllTrackingFpga(
// GNSS-SDR instantiates the tracking channels i L1, L2, L5, E1, E5a
trk_param_fpga.num_prev_assigned_ch = configuration->property("Channels_1C.count", 0);
auto* ca_codes_f = static_cast<float*>(volk_gnsssdr_malloc(static_cast<unsigned int>(GPS_L2_M_CODE_LENGTH_CHIPS) * sizeof(float), volk_gnsssdr_get_alignment()));
volk_gnsssdr::vector<float> ca_codes_f(static_cast<unsigned int>(GPS_L2_M_CODE_LENGTH_CHIPS), 0.0);
// ################# PRE-COMPUTE ALL THE CODES #################
d_ca_codes = static_cast<int*>(volk_gnsssdr_malloc(static_cast<int>(GPS_L2_M_CODE_LENGTH_CHIPS * NUM_PRNs) * sizeof(int), volk_gnsssdr_get_alignment()));
for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++)
{
gps_l2c_m_code_gen_float(gsl::span<float>(ca_codes_f, static_cast<unsigned int>(GPS_L2_M_CODE_LENGTH_CHIPS)), PRN);
gps_l2c_m_code_gen_float(ca_codes_f, PRN);
for (unsigned int s = 0; s < 2 * static_cast<unsigned int>(GPS_L2_M_CODE_LENGTH_CHIPS); s++)
{
d_ca_codes[static_cast<int>(GPS_L2_M_CODE_LENGTH_CHIPS) * (PRN - 1) + s] = static_cast<int>(ca_codes_f[s]);
}
}
volk_gnsssdr_free(ca_codes_f);
trk_param_fpga.ca_codes = d_ca_codes;
trk_param_fpga.code_length_chips = GPS_L2_M_CODE_LENGTH_CHIPS;
trk_param_fpga.code_samples_per_chip = 1; // 1 sample per chip

View File

@ -44,7 +44,7 @@
#include "gnss_sdr_flags.h"
#include "gps_l5_signal.h"
#include <glog/logging.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <array>
GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga(
@ -193,18 +193,12 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga(
uint32_t code_samples_per_chip = 1;
auto code_length_chips = static_cast<uint32_t>(GPS_L5I_CODE_LENGTH_CHIPS);
float *tracking_code;
float *data_code = nullptr;
tracking_code = static_cast<float *>(volk_gnsssdr_malloc(code_length_chips * sizeof(float), volk_gnsssdr_get_alignment()));
volk_gnsssdr::vector<float> data_code;
volk_gnsssdr::vector<float> tracking_code(code_length_chips, 0.0);
if (track_pilot)
{
data_code = static_cast<float *>(volk_gnsssdr_malloc(code_length_chips * sizeof(float), volk_gnsssdr_get_alignment()));
for (uint32_t i = 0; i < code_length_chips; i++)
{
data_code[i] = 0.0;
}
data_code.resize(code_length_chips, 0.0);
}
d_ca_codes = static_cast<int32_t *>(volk_gnsssdr_malloc(static_cast<int32_t>(code_length_chips * NUM_PRNs) * sizeof(int32_t), volk_gnsssdr_get_alignment()));
@ -219,8 +213,8 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga(
{
if (track_pilot)
{
gps_l5q_code_gen_float(gsl::span<float>(tracking_code, code_length_chips), PRN);
gps_l5i_code_gen_float(gsl::span<float>(data_code, code_length_chips), PRN);
gps_l5q_code_gen_float(tracking_code, PRN);
gps_l5i_code_gen_float(data_code, PRN);
// The code is generated as a series of 1s and -1s. In order to store the values using only one bit, a -1 is stored as a 0 in the FPGA
for (uint32_t s = 0; s < code_length_chips; s++)
@ -244,7 +238,7 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga(
}
else
{
gps_l5i_code_gen_float(gsl::span<float>(tracking_code, code_length_chips), PRN);
gps_l5i_code_gen_float(tracking_code, PRN);
// The code is generated as a series of 1s and -1s. In order to store the values using only one bit, a -1 is stored as a 0 in the FPGA
for (uint32_t s = 0; s < code_length_chips; s++)
@ -260,11 +254,6 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga(
}
}
volk_gnsssdr_free(tracking_code);
if (track_pilot)
{
volk_gnsssdr_free(data_code);
}
trk_param_fpga.ca_codes = d_ca_codes;
trk_param_fpga.data_codes = d_data_codes;
trk_param_fpga.code_length_chips = code_length_chips;

View File

@ -68,6 +68,7 @@
#include <iostream> // for cout, cerr
#include <map>
#include <numeric>
#include <vector>
#if HAS_STD_FILESYSTEM
#if HAS_STD_FILESYSTEM_EXPERIMENTAL
@ -352,7 +353,7 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(const Dll_Pll_Conf &conf_) : gr::bl
// Initialization of local code replica
// Get space for a vector with the sinboc(1,1) replica sampled 2x/chip
d_tracking_code = static_cast<float *>(volk_gnsssdr_malloc(2 * d_code_length_chips * sizeof(float), volk_gnsssdr_get_alignment()));
d_tracking_code.resize(2 * d_code_length_chips, 0.0);
// correlator outputs (scalar)
if (d_veml)
{
@ -365,9 +366,8 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(const Dll_Pll_Conf &conf_) : gr::bl
d_n_correlator_taps = 3;
}
d_correlator_outs = static_cast<gr_complex *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_local_code_shift_chips = static_cast<float *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(float), volk_gnsssdr_get_alignment()));
d_correlator_outs.reserve(d_n_correlator_taps);
d_local_code_shift_chips.reserve(d_n_correlator_taps);
// map memory pointers of correlator outputs
if (d_veml)
{
@ -414,11 +414,7 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(const Dll_Pll_Conf &conf_) : gr::bl
// Extra correlator for the data component
correlator_data_cpu.init(2 * trk_parameters.vector_length, 1);
correlator_data_cpu.set_high_dynamics_resampler(trk_parameters.high_dyn);
d_data_code = static_cast<float *>(volk_gnsssdr_malloc(2 * d_code_length_chips * sizeof(float), volk_gnsssdr_get_alignment()));
}
else
{
d_data_code = nullptr;
d_data_code.resize(2 * d_code_length_chips, 0.0);
}
// --- Initializations ---
@ -440,13 +436,13 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(const Dll_Pll_Conf &conf_) : gr::bl
// CN0 estimation and lock detector buffers
d_cn0_estimation_counter = 0;
d_Prompt_buffer = std::vector<gr_complex>(trk_parameters.cn0_samples);
d_Prompt_buffer.reserve(trk_parameters.cn0_samples);
d_carrier_lock_test = 1.0;
d_CN0_SNV_dB_Hz = 0.0;
d_carrier_lock_fail_counter = 0;
d_code_lock_fail_counter = 0;
d_carrier_lock_threshold = trk_parameters.carrier_lock_th;
d_Prompt_Data = static_cast<gr_complex *>(volk_gnsssdr_malloc(sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_Prompt_Data.reserve(1);
d_cn0_smoother = Exponential_Smoother();
d_cn0_smoother.set_alpha(trk_parameters.cn0_smoother_alpha);
@ -580,24 +576,24 @@ void dll_pll_veml_tracking::start_tracking()
if (systemName == "GPS" and signal_type == "1C")
{
gps_l1_ca_code_gen_float(gsl::span<float>(d_tracking_code, 2 * d_code_length_chips), d_acquisition_gnss_synchro->PRN, 0);
gps_l1_ca_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN, 0);
}
else if (systemName == "GPS" and signal_type == "2S")
{
gps_l2c_m_code_gen_float(gsl::span<float>(d_tracking_code, 2 * d_code_length_chips), d_acquisition_gnss_synchro->PRN);
gps_l2c_m_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN);
}
else if (systemName == "GPS" and signal_type == "L5")
{
if (trk_parameters.track_pilot)
{
gps_l5q_code_gen_float(gsl::span<float>(d_tracking_code, 2 * d_code_length_chips), d_acquisition_gnss_synchro->PRN);
gps_l5i_code_gen_float(gsl::span<float>(d_data_code, 2 * d_code_length_chips), d_acquisition_gnss_synchro->PRN);
gps_l5q_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN);
gps_l5i_code_gen_float(d_data_code, d_acquisition_gnss_synchro->PRN);
d_Prompt_Data[0] = gr_complex(0.0, 0.0);
correlator_data_cpu.set_local_code_and_taps(d_code_length_chips, d_data_code, d_prompt_data_shift);
correlator_data_cpu.set_local_code_and_taps(d_code_length_chips, d_data_code.data(), d_prompt_data_shift);
}
else
{
gps_l5i_code_gen_float(gsl::span<float>(d_tracking_code, 2 * d_code_length_chips), d_acquisition_gnss_synchro->PRN);
gps_l5i_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN);
}
}
else if (systemName == "Galileo" and signal_type == "1B")
@ -605,21 +601,21 @@ void dll_pll_veml_tracking::start_tracking()
if (trk_parameters.track_pilot)
{
std::array<char, 3> pilot_signal = {{'1', 'C', '\0'}};
galileo_e1_code_gen_sinboc11_float(gsl::span<float>(d_tracking_code, 2 * d_code_length_chips), pilot_signal, d_acquisition_gnss_synchro->PRN);
galileo_e1_code_gen_sinboc11_float(gsl::span<float>(d_data_code, 2 * d_code_length_chips), Signal_, d_acquisition_gnss_synchro->PRN);
galileo_e1_code_gen_sinboc11_float(d_tracking_code, pilot_signal, d_acquisition_gnss_synchro->PRN);
galileo_e1_code_gen_sinboc11_float(d_data_code, Signal_, d_acquisition_gnss_synchro->PRN);
d_Prompt_Data[0] = gr_complex(0.0, 0.0);
correlator_data_cpu.set_local_code_and_taps(d_code_samples_per_chip * d_code_length_chips, d_data_code, d_prompt_data_shift);
correlator_data_cpu.set_local_code_and_taps(d_code_samples_per_chip * d_code_length_chips, d_data_code.data(), d_prompt_data_shift);
}
else
{
galileo_e1_code_gen_sinboc11_float(gsl::span<float>(d_tracking_code, 2 * d_code_length_chips), Signal_, d_acquisition_gnss_synchro->PRN);
galileo_e1_code_gen_sinboc11_float(d_tracking_code, Signal_, d_acquisition_gnss_synchro->PRN);
}
}
else if (systemName == "Galileo" and signal_type == "5X")
{
auto *aux_code = static_cast<gr_complex *>(volk_gnsssdr_malloc(sizeof(gr_complex) * d_code_length_chips, volk_gnsssdr_get_alignment()));
volk_gnsssdr::vector<gr_complex> aux_code(d_code_length_chips);
std::array<char, 3> signal_type_ = {{'5', 'X', '\0'}};
galileo_e5_a_code_gen_complex_primary(gsl::span<gr_complex>(aux_code, d_code_length_chips), d_acquisition_gnss_synchro->PRN, signal_type_);
galileo_e5_a_code_gen_complex_primary(aux_code, d_acquisition_gnss_synchro->PRN, signal_type_);
if (trk_parameters.track_pilot)
{
d_secondary_code_string = const_cast<std::string *>(&GALILEO_E5A_Q_SECONDARY_CODE[d_acquisition_gnss_synchro->PRN - 1]);
@ -629,7 +625,7 @@ void dll_pll_veml_tracking::start_tracking()
d_data_code[i] = aux_code[i].real(); // the same because it is generated the full signal (E5aI + E5aQ)
}
d_Prompt_Data[0] = gr_complex(0.0, 0.0);
correlator_data_cpu.set_local_code_and_taps(d_code_length_chips, d_data_code, d_prompt_data_shift);
correlator_data_cpu.set_local_code_and_taps(d_code_length_chips, d_data_code.data(), d_prompt_data_shift);
}
else
{
@ -638,11 +634,10 @@ void dll_pll_veml_tracking::start_tracking()
d_tracking_code[i] = aux_code[i].real();
}
}
volk_gnsssdr_free(aux_code);
}
else if (systemName == "Beidou" and signal_type == "B1")
{
beidou_b1i_code_gen_float(gsl::span<float>(d_tracking_code, 2 * d_code_length_chips), d_acquisition_gnss_synchro->PRN, 0);
beidou_b1i_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN, 0);
// GEO Satellites use different secondary code
if (d_acquisition_gnss_synchro->PRN > 0 and d_acquisition_gnss_synchro->PRN < 6)
{
@ -675,7 +670,7 @@ void dll_pll_veml_tracking::start_tracking()
else if (systemName == "Beidou" and signal_type == "B3")
{
beidou_b3i_code_gen_float(gsl::span<float>(d_tracking_code, 2 * d_code_length_chips), d_acquisition_gnss_synchro->PRN, 0);
beidou_b3i_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN, 0);
// Update secondary code settings for geo satellites
if (d_acquisition_gnss_synchro->PRN > 0 and d_acquisition_gnss_synchro->PRN < 6)
{
@ -706,8 +701,8 @@ void dll_pll_veml_tracking::start_tracking()
}
}
multicorrelator_cpu.set_local_code_and_taps(d_code_samples_per_chip * d_code_length_chips, d_tracking_code, d_local_code_shift_chips);
std::fill_n(d_correlator_outs, d_n_correlator_taps, gr_complex(0.0, 0.0));
multicorrelator_cpu.set_local_code_and_taps(d_code_samples_per_chip * d_code_length_chips, d_tracking_code.data(), d_local_code_shift_chips.data());
std::fill_n(d_correlator_outs.begin(), d_n_correlator_taps, gr_complex(0.0, 0.0));
d_carrier_lock_fail_counter = 0;
d_code_lock_fail_counter = 0;
@ -765,7 +760,7 @@ dll_pll_veml_tracking::~dll_pll_veml_tracking()
}
catch (const std::exception &ex)
{
LOG(WARNING) << "Exception in destructor " << ex.what();
LOG(WARNING) << "Exception in Tracking block destructor: " << ex.what();
}
}
if (d_dump_mat)
@ -781,20 +776,15 @@ dll_pll_veml_tracking::~dll_pll_veml_tracking()
}
try
{
volk_gnsssdr_free(d_local_code_shift_chips);
volk_gnsssdr_free(d_correlator_outs);
volk_gnsssdr_free(d_tracking_code);
volk_gnsssdr_free(d_Prompt_Data);
if (trk_parameters.track_pilot)
{
volk_gnsssdr_free(d_data_code);
correlator_data_cpu.free();
}
multicorrelator_cpu.free();
}
catch (const std::exception &ex)
{
LOG(WARNING) << "Exception in destructor " << ex.what();
LOG(WARNING) << "Exception in Tracking block destructor: " << ex.what();
}
}
@ -907,7 +897,7 @@ void dll_pll_veml_tracking::do_correlation_step(const gr_complex *input_samples)
{
// ################# CARRIER WIPEOFF AND CORRELATORS ##############################
// perform carrier wipe-off and compute Early, Prompt and Late correlation
multicorrelator_cpu.set_input_output_vectors(d_correlator_outs, input_samples);
multicorrelator_cpu.set_input_output_vectors(d_correlator_outs.data(), input_samples);
multicorrelator_cpu.Carrier_wipeoff_multicorrelator_resampler(
d_rem_carr_phase_rad,
d_carrier_phase_step_rad, d_carrier_phase_rate_step_rad,
@ -919,7 +909,7 @@ void dll_pll_veml_tracking::do_correlation_step(const gr_complex *input_samples)
// DATA CORRELATOR (if tracking tracks the pilot signal)
if (trk_parameters.track_pilot)
{
correlator_data_cpu.set_input_output_vectors(d_Prompt_Data, input_samples);
correlator_data_cpu.set_input_output_vectors(d_Prompt_Data.data(), input_samples);
correlator_data_cpu.Carrier_wipeoff_multicorrelator_resampler(
d_rem_carr_phase_rad,
d_carrier_phase_step_rad, d_carrier_phase_rate_step_rad,
@ -1019,7 +1009,7 @@ void dll_pll_veml_tracking::run_dll_pll()
void dll_pll_veml_tracking::clear_tracking_vars()
{
std::fill_n(d_correlator_outs, d_n_correlator_taps, gr_complex(0.0, 0.0));
std::fill_n(d_correlator_outs.begin(), d_n_correlator_taps, gr_complex(0.0, 0.0));
if (trk_parameters.track_pilot)
{
d_Prompt_Data[0] = gr_complex(0.0, 0.0);
@ -1166,11 +1156,11 @@ void dll_pll_veml_tracking::save_correlation_results()
{
if (d_data_secondary_code_string->at(d_current_data_symbol) == '0')
{
d_P_data_accu += *d_Prompt_Data;
d_P_data_accu += d_Prompt_Data[0];
}
else
{
d_P_data_accu -= *d_Prompt_Data;
d_P_data_accu -= d_Prompt_Data[0];
}
}
else
@ -1193,7 +1183,7 @@ void dll_pll_veml_tracking::save_correlation_results()
{
if (trk_parameters.track_pilot)
{
d_P_data_accu += *d_Prompt_Data;
d_P_data_accu += d_Prompt_Data[0];
}
else
{
@ -1208,7 +1198,7 @@ void dll_pll_veml_tracking::save_correlation_results()
{
if (trk_parameters.track_pilot)
{
d_P_data_accu = *d_Prompt_Data;
d_P_data_accu = d_Prompt_Data[0];
}
else
{
@ -1245,8 +1235,8 @@ void dll_pll_veml_tracking::log_data()
uint64_t tmp_long_int;
if (trk_parameters.track_pilot)
{
prompt_I = d_Prompt_Data->real();
prompt_Q = d_Prompt_Data->imag();
prompt_I = d_Prompt_Data.data()->real();
prompt_Q = d_Prompt_Data.data()->imag();
}
else
{

View File

@ -43,11 +43,11 @@
#include <gnuradio/gr_complex.h> // for gr_complex
#include <gnuradio/types.h> // for gr_vector_int, gr_vector...
#include <pmt/pmt.h> // for pmt_t
#include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
#include <cstdint> // for int32_t
#include <fstream> // for string, ofstream
#include <string>
#include <utility> // for pair
#include <vector>
class Gnss_Synchro;
class dll_pll_veml_tracking;
@ -123,9 +123,9 @@ private:
int32_t d_correlation_length_ms;
int32_t d_n_correlator_taps;
float *d_tracking_code;
float *d_data_code;
float *d_local_code_shift_chips;
volk_gnsssdr::vector<float> d_tracking_code;
volk_gnsssdr::vector<float> d_data_code;
volk_gnsssdr::vector<float> d_local_code_shift_chips;
float *d_prompt_data_shift;
Cpu_Multicorrelator_Real_Codes multicorrelator_cpu;
Cpu_Multicorrelator_Real_Codes correlator_data_cpu; // for data channel
@ -135,7 +135,7 @@ private:
Implement this functionality inside multicorrelator class
as an enhancement to increase the performance
*/
gr_complex *d_correlator_outs;
volk_gnsssdr::vector<gr_complex> d_correlator_outs;
gr_complex *d_Very_Early;
gr_complex *d_Early;
gr_complex *d_Prompt;
@ -155,7 +155,7 @@ private:
gr_complex d_VL_accu;
gr_complex d_P_data_accu;
gr_complex *d_Prompt_Data;
volk_gnsssdr::vector<gr_complex> d_Prompt_Data;
double d_code_phase_step_chips;
double d_code_phase_rate_step_chips;
@ -207,7 +207,7 @@ private:
double d_CN0_SNV_dB_Hz;
double d_carrier_lock_threshold;
boost::circular_buffer<gr_complex> d_Prompt_circular_buffer;
std::vector<gr_complex> d_Prompt_buffer;
volk_gnsssdr::vector<gr_complex> d_Prompt_buffer;
Exponential_Smoother d_cn0_smoother;
Exponential_Smoother d_carrier_lock_test_smoother;
// file dump

View File

@ -309,9 +309,8 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga &
d_n_correlator_taps = 3;
}
d_correlator_outs = static_cast<gr_complex *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_local_code_shift_chips = static_cast<float *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(float), volk_gnsssdr_get_alignment()));
d_correlator_outs.reserve(d_n_correlator_taps);
d_local_code_shift_chips.reserve(d_n_correlator_taps);
// map memory pointers of correlator outputs
if (d_veml)
{
@ -370,13 +369,13 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga &
// CN0 estimation and lock detector buffers
d_cn0_estimation_counter = 0;
d_Prompt_buffer = std::vector<gr_complex>(trk_parameters.cn0_samples);
d_Prompt_buffer.reserve(trk_parameters.cn0_samples);
d_carrier_lock_test = 1.0;
d_CN0_SNV_dB_Hz = 0.0;
d_carrier_lock_fail_counter = 0;
d_code_lock_fail_counter = 0;
d_carrier_lock_threshold = trk_parameters.carrier_lock_th;
d_Prompt_Data = static_cast<gr_complex *>(volk_gnsssdr_malloc(sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_Prompt_Data.reserve(1);
d_cn0_smoother = Exponential_Smoother();
d_cn0_smoother.set_alpha(trk_parameters.cn0_smoother_alpha);
if (d_code_period > 0.0)
@ -458,7 +457,7 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga &
int32_t *ca_codes = trk_parameters.ca_codes;
int32_t *data_codes = trk_parameters.data_codes;
multicorrelator_fpga = std::make_shared<Fpga_Multicorrelator_8sc>(d_n_correlator_taps, device_name, dev_file_num, num_prev_assigned_ch, ca_codes, data_codes, d_code_length_chips, trk_parameters.track_pilot, d_code_samples_per_chip);
multicorrelator_fpga->set_output_vectors(d_correlator_outs, d_Prompt_Data);
multicorrelator_fpga->set_output_vectors(d_correlator_outs.data(), d_Prompt_Data.data());
d_sample_counter_next = 0ULL;
d_corrected_doppler = false;
@ -531,7 +530,7 @@ dll_pll_veml_tracking_fpga::~dll_pll_veml_tracking_fpga()
}
catch (const std::exception &ex)
{
LOG(WARNING) << "Exception in destructor " << ex.what();
LOG(WARNING) << "Exception in Tracking block destructor: " << ex.what();
}
}
if (d_dump_mat)
@ -547,14 +546,11 @@ dll_pll_veml_tracking_fpga::~dll_pll_veml_tracking_fpga()
}
try
{
volk_gnsssdr_free(d_local_code_shift_chips);
volk_gnsssdr_free(d_correlator_outs);
volk_gnsssdr_free(d_Prompt_Data);
multicorrelator_fpga->free();
}
catch (const std::exception &ex)
{
LOG(WARNING) << "Exception in destructor " << ex.what();
LOG(WARNING) << "Exception in Tracking block destructor: " << ex.what();
}
}
@ -766,7 +762,7 @@ void dll_pll_veml_tracking_fpga::run_dll_pll()
void dll_pll_veml_tracking_fpga::clear_tracking_vars()
{
std::fill_n(d_correlator_outs, d_n_correlator_taps, gr_complex(0.0, 0.0));
std::fill_n(d_correlator_outs.begin(), d_n_correlator_taps, gr_complex(0.0, 0.0));
if (trk_parameters.track_pilot)
{
d_Prompt_Data[0] = gr_complex(0.0, 0.0);
@ -917,16 +913,16 @@ void dll_pll_veml_tracking_fpga::save_correlation_results()
{
if (d_data_secondary_code_string->at(d_current_data_symbol) == '0')
{
d_P_data_accu += *d_Prompt_Data;
d_P_data_accu += d_Prompt_Data[0];
}
else
{
d_P_data_accu -= *d_Prompt_Data;
d_P_data_accu -= d_Prompt_Data[0];
}
}
else
{
d_P_data_accu += *d_Prompt_Data;
d_P_data_accu += d_Prompt_Data[0];
}
}
else
@ -955,7 +951,7 @@ void dll_pll_veml_tracking_fpga::save_correlation_results()
{
if (trk_parameters.track_pilot)
{
d_P_data_accu += *d_Prompt_Data;
d_P_data_accu += d_Prompt_Data[0];
}
else
{
@ -970,7 +966,7 @@ void dll_pll_veml_tracking_fpga::save_correlation_results()
{
if (trk_parameters.track_pilot)
{
d_P_data_accu = *d_Prompt_Data;
d_P_data_accu = d_Prompt_Data[0];
}
else
{
@ -1007,8 +1003,8 @@ void dll_pll_veml_tracking_fpga::log_data()
uint64_t tmp_long_int;
if (trk_parameters.track_pilot)
{
prompt_I = d_Prompt_Data->real();
prompt_Q = d_Prompt_Data->imag();
prompt_I = d_Prompt_Data.data()->real();
prompt_Q = d_Prompt_Data.data()->imag();
}
else
{
@ -1406,7 +1402,7 @@ void dll_pll_veml_tracking_fpga::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro)
}
}
std::fill_n(d_correlator_outs, d_n_correlator_taps, gr_complex(0.0, 0.0));
std::fill_n(d_correlator_outs.begin(), d_n_correlator_taps, gr_complex(0.0, 0.0));
d_carrier_lock_fail_counter = 0;
d_code_lock_fail_counter = 0;
@ -1441,7 +1437,7 @@ void dll_pll_veml_tracking_fpga::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro)
d_code_loop_filter.set_update_interval(d_code_period);
d_code_loop_filter.initialize(); // initialize the code filter
multicorrelator_fpga->set_local_code_and_taps(d_local_code_shift_chips, d_prompt_data_shift, d_acquisition_gnss_synchro->PRN);
multicorrelator_fpga->set_local_code_and_taps(d_local_code_shift_chips.data(), d_prompt_data_shift, d_acquisition_gnss_synchro->PRN);
d_pull_in_transitory = true;

View File

@ -42,12 +42,12 @@
#include <gnuradio/gr_complex.h> // for gr_complex
#include <gnuradio/types.h> // for gr_vector_int, gr_vector...
#include <pmt/pmt.h> // for pmt_t
#include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
#include <cstdint> // for int32_t
#include <fstream> // for string, ofstream
#include <memory>
#include <string>
#include <utility> // for pair
#include <vector>
class Fpga_Multicorrelator_8sc;
class Gnss_Synchro;
@ -152,10 +152,10 @@ private:
int32_t d_correlation_length_ms;
int32_t d_n_correlator_taps;
float *d_local_code_shift_chips;
volk_gnsssdr::vector<float> d_local_code_shift_chips;
float *d_prompt_data_shift;
std::shared_ptr<Fpga_Multicorrelator_8sc> multicorrelator_fpga;
gr_complex *d_correlator_outs;
volk_gnsssdr::vector<gr_complex> d_correlator_outs;
gr_complex *d_Very_Early;
gr_complex *d_Early;
gr_complex *d_Prompt;
@ -175,7 +175,7 @@ private:
gr_complex d_VL_accu;
gr_complex d_P_data_accu;
gr_complex *d_Prompt_Data;
volk_gnsssdr::vector<gr_complex> d_Prompt_Data;
double d_code_phase_step_chips;
double d_code_phase_rate_step_chips;
@ -228,7 +228,7 @@ private:
double d_CN0_SNV_dB_Hz;
double d_carrier_lock_threshold;
boost::circular_buffer<gr_complex> d_Prompt_circular_buffer;
std::vector<gr_complex> d_Prompt_buffer;
volk_gnsssdr::vector<gr_complex> d_Prompt_buffer;
Exponential_Smoother d_cn0_smoother;
Exponential_Smoother d_carrier_lock_test_smoother;
// file dump

View File

@ -48,6 +48,7 @@
#include <glog/logging.h>
#include <gnuradio/io_signature.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <algorithm> // for fill_n
#include <cmath>
#include <iostream>
#include <memory>
@ -116,15 +117,11 @@ Galileo_E1_Tcp_Connector_Tracking_cc::Galileo_E1_Tcp_Connector_Tracking_cc(
// Initialization of local code replica
// Get space for a vector with the sinboc(1,1) replica sampled 2x/chip
d_ca_code = static_cast<gr_complex *>(volk_gnsssdr_malloc((2 * GALILEO_E1_B_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_ca_code.resize(2 * GALILEO_E1_B_CODE_LENGTH_CHIPS, gr_complex(0.0, 0.0));
// correlator outputs (scalar)
d_n_correlator_taps = 5; // Very-Early, Early, Prompt, Late, Very-Late
d_correlator_outs = static_cast<gr_complex *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
for (int32_t n = 0; n < d_n_correlator_taps; n++)
{
d_correlator_outs[n] = gr_complex(0, 0);
}
d_correlator_outs.resize(d_n_correlator_taps, gr_complex(0.0, 0.0));
// map memory pointers of correlator outputs
d_Very_Early = &d_correlator_outs[0];
d_Early = &d_correlator_outs[1];
@ -132,7 +129,7 @@ Galileo_E1_Tcp_Connector_Tracking_cc::Galileo_E1_Tcp_Connector_Tracking_cc(
d_Late = &d_correlator_outs[3];
d_Very_Late = &d_correlator_outs[4];
d_local_code_shift_chips = static_cast<float *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(float), volk_gnsssdr_get_alignment()));
d_local_code_shift_chips.reserve(d_n_correlator_taps);
// Set TAPs delay values [chips]
d_local_code_shift_chips[0] = -d_very_early_late_spc_chips;
d_local_code_shift_chips[1] = -d_early_late_spc_chips;
@ -163,7 +160,7 @@ Galileo_E1_Tcp_Connector_Tracking_cc::Galileo_E1_Tcp_Connector_Tracking_cc(
// CN0 estimation and lock detector buffers
d_cn0_estimation_counter = 0;
d_Prompt_buffer = std::vector<gr_complex>(FLAGS_cn0_samples);
d_Prompt_buffer.reserve(FLAGS_cn0_samples);
d_carrier_lock_test = 1;
d_CN0_SNV_dB_Hz = 0;
d_carrier_lock_fail_counter = 0;
@ -192,18 +189,15 @@ void Galileo_E1_Tcp_Connector_Tracking_cc::start_tracking()
std::memcpy(Signal_.data(), d_acquisition_gnss_synchro->Signal, 3);
// generate local reference ALWAYS starting at chip 1 (2 samples per chip)
galileo_e1_code_gen_complex_sampled(gsl::span<gr_complex>(d_ca_code, (2 * GALILEO_E1_B_CODE_LENGTH_CHIPS)),
galileo_e1_code_gen_complex_sampled(d_ca_code,
Signal_,
false,
d_acquisition_gnss_synchro->PRN,
2 * GALILEO_E1_CODE_CHIP_RATE_CPS,
0);
multicorrelator_cpu.set_local_code_and_taps(static_cast<int32_t>(2 * GALILEO_E1_B_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips);
for (int32_t n = 0; n < d_n_correlator_taps; n++)
{
d_correlator_outs[n] = gr_complex(0, 0);
}
multicorrelator_cpu.set_local_code_and_taps(static_cast<int32_t>(2 * GALILEO_E1_B_CODE_LENGTH_CHIPS), d_ca_code.data(), d_local_code_shift_chips.data());
std::fill_n(d_correlator_outs.begin(), d_n_correlator_taps, gr_complex(0.0, 0.0));
d_carrier_lock_fail_counter = 0;
d_rem_code_phase_samples = 0.0;
@ -239,20 +233,17 @@ Galileo_E1_Tcp_Connector_Tracking_cc::~Galileo_E1_Tcp_Connector_Tracking_cc()
}
catch (const std::exception &ex)
{
LOG(WARNING) << "Exception in destructor " << ex.what();
LOG(WARNING) << "Exception in Tracking block destructor: " << ex.what();
}
}
try
{
volk_gnsssdr_free(d_local_code_shift_chips);
volk_gnsssdr_free(d_correlator_outs);
volk_gnsssdr_free(d_ca_code);
d_tcp_com.close_tcp_connection(d_port);
multicorrelator_cpu.free();
}
catch (const std::exception &ex)
{
LOG(WARNING) << "Exception in destructor " << ex.what();
LOG(WARNING) << "Exception in Tracking block destructor: " << ex.what();
}
}
@ -335,7 +326,7 @@ int Galileo_E1_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attri
// ################# CARRIER WIPEOFF AND CORRELATORS ##############################
// perform carrier wipe-off and compute Early, Prompt and Late correlation
multicorrelator_cpu.set_input_output_vectors(d_correlator_outs, in);
multicorrelator_cpu.set_input_output_vectors(d_correlator_outs.data(), in);
double carr_phase_step_rad = GALILEO_TWO_PI * d_carrier_doppler_hz / static_cast<double>(d_fs_in);
double code_phase_step_half_chips = (2.0 * d_code_freq_chips) / (static_cast<double>(d_fs_in));
@ -457,9 +448,9 @@ int Galileo_E1_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attri
}
else
{
*d_Early = gr_complex(0, 0);
*d_Prompt = gr_complex(0, 0);
*d_Late = gr_complex(0, 0);
*d_Early = gr_complex(0.0, 0.0);
*d_Prompt = gr_complex(0.0, 0.0);
*d_Late = gr_complex(0.0, 0.0);
current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast<uint64_t>(d_current_prn_length_samples);
// When tracking is disabled an array of 1's is sent to maintain the TCP connection
boost::array<float, NUM_TX_VARIABLES_GALILEO_E1> tx_variables_array = {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}};

View File

@ -43,11 +43,10 @@
#include "gnss_synchro.h"
#include "tcp_communication.h"
#include <gnuradio/block.h>
#include <volk/volk.h>
#include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
#include <fstream>
#include <map>
#include <string>
#include <vector>
class Galileo_E1_Tcp_Connector_Tracking_cc;
@ -123,7 +122,7 @@ private:
float d_early_late_spc_chips;
float d_very_early_late_spc_chips;
gr_complex *d_ca_code;
volk_gnsssdr::vector<gr_complex> d_ca_code;
gr_complex *d_Very_Early;
gr_complex *d_Early;
@ -141,8 +140,8 @@ private:
float d_acq_carrier_doppler_hz;
// correlator
float *d_local_code_shift_chips;
gr_complex *d_correlator_outs;
volk_gnsssdr::vector<float> d_local_code_shift_chips;
volk_gnsssdr::vector<gr_complex> d_correlator_outs;
Cpu_Multicorrelator multicorrelator_cpu;
// tracking vars
@ -167,7 +166,7 @@ private:
// CN0 estimation and lock detector
int32_t d_cn0_estimation_counter;
std::vector<gr_complex> d_Prompt_buffer;
volk_gnsssdr::vector<gr_complex> d_Prompt_buffer;
float d_carrier_lock_test;
float d_CN0_SNV_dB_Hz;
float d_carrier_lock_threshold;

View File

@ -48,6 +48,7 @@
#include <matio.h>
#include <pmt/pmt.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <algorithm>
#include <array>
#include <cmath>
#include <exception>
@ -55,13 +56,13 @@
#include <memory>
#include <sstream>
#include <utility>
#include <vector>
#define CN0_ESTIMATION_SAMPLES 10
glonass_l1_ca_dll_pll_c_aid_tracking_cc_sptr
glonass_l1_ca_dll_pll_c_aid_make_tracking_cc(
glonass_l1_ca_dll_pll_c_aid_tracking_cc_sptr glonass_l1_ca_dll_pll_c_aid_make_tracking_cc(
int64_t fs_in,
uint32_t vector_length,
bool dump,
@ -143,16 +144,13 @@ glonass_l1_ca_dll_pll_c_aid_tracking_cc::glonass_l1_ca_dll_pll_c_aid_tracking_cc
// Initialization of local code replica
// Get space for a vector with the C/A code replica sampled 1x/chip
d_ca_code = static_cast<gr_complex *>(volk_gnsssdr_malloc(static_cast<int32_t>(GLONASS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_ca_code.resize(static_cast<int32_t>(GLONASS_L1_CA_CODE_LENGTH_CHIPS), gr_complex(0.0, 0.0));
// correlator outputs (scalar)
d_n_correlator_taps = 3; // Early, Prompt, and Late
d_correlator_outs = static_cast<gr_complex *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
for (int32_t n = 0; n < d_n_correlator_taps; n++)
{
d_correlator_outs[n] = gr_complex(0, 0);
}
d_local_code_shift_chips = static_cast<float *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(float), volk_gnsssdr_get_alignment()));
d_correlator_outs.resize(d_n_correlator_taps, gr_complex(0.0, 0.0));
d_local_code_shift_chips.reserve(d_n_correlator_taps);
// Set TAPs delay values [chips]
d_local_code_shift_chips[0] = -d_early_late_spc_chips;
d_local_code_shift_chips[1] = 0.0;
@ -176,7 +174,7 @@ glonass_l1_ca_dll_pll_c_aid_tracking_cc::glonass_l1_ca_dll_pll_c_aid_tracking_cc
// CN0 estimation and lock detector buffers
d_cn0_estimation_counter = 0;
d_Prompt_buffer = std::vector<gr_complex>(FLAGS_cn0_samples);
d_Prompt_buffer.reserve(FLAGS_cn0_samples);
d_carrier_lock_test = 1;
d_CN0_SNV_dB_Hz = 0;
d_carrier_lock_fail_counter = 0;
@ -274,13 +272,10 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_cc::start_tracking()
d_code_loop_filter.initialize(); // initialize the code filter
// generate local reference ALWAYS starting at chip 1 (1 sample per chip)
glonass_l1_ca_code_gen_complex(gsl::span<gr_complex>(d_ca_code, GLONASS_L1_CA_CODE_LENGTH_CHIPS), 0);
glonass_l1_ca_code_gen_complex(gsl::span<gr_complex>(d_ca_code.data(), GLONASS_L1_CA_CODE_LENGTH_CHIPS), 0);
multicorrelator_cpu.set_local_code_and_taps(static_cast<int32_t>(GLONASS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips);
for (int32_t n = 0; n < d_n_correlator_taps; n++)
{
d_correlator_outs[n] = gr_complex(0, 0);
}
multicorrelator_cpu.set_local_code_and_taps(static_cast<int32_t>(GLONASS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code.data(), d_local_code_shift_chips.data());
std::fill_n(d_correlator_outs.begin(), d_n_correlator_taps, gr_complex(0.0, 0.0));
d_carrier_lock_fail_counter = 0;
d_rem_code_phase_samples = 0.0;
@ -318,7 +313,7 @@ glonass_l1_ca_dll_pll_c_aid_tracking_cc::~glonass_l1_ca_dll_pll_c_aid_tracking_c
}
catch (const std::exception &ex)
{
LOG(WARNING) << "Exception in destructor " << ex.what();
LOG(WARNING) << "Exception in Tracking block destructor: " << ex.what();
}
}
@ -344,14 +339,11 @@ glonass_l1_ca_dll_pll_c_aid_tracking_cc::~glonass_l1_ca_dll_pll_c_aid_tracking_c
try
{
volk_gnsssdr_free(d_local_code_shift_chips);
volk_gnsssdr_free(d_correlator_outs);
volk_gnsssdr_free(d_ca_code);
multicorrelator_cpu.free();
}
catch (const std::exception &ex)
{
LOG(WARNING) << "Exception in destructor " << ex.what();
LOG(WARNING) << "Exception in Tracking block destructor: " << ex.what();
}
}
@ -601,7 +593,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at
// ################# CARRIER WIPEOFF AND CORRELATORS ##############################
// perform carrier wipe-off and compute Early, Prompt and Late correlation
multicorrelator_cpu.set_input_output_vectors(d_correlator_outs, in);
multicorrelator_cpu.set_input_output_vectors(d_correlator_outs.data(), in);
multicorrelator_cpu.Carrier_wipeoff_multicorrelator_resampler(d_rem_carrier_phase_rad,
d_carrier_phase_step_rad,
d_rem_code_phase_chips,
@ -819,7 +811,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at
{
for (int32_t n = 0; n < d_n_correlator_taps; n++)
{
d_correlator_outs[n] = gr_complex(0, 0);
d_correlator_outs[n] = gr_complex(0.0, 0.0);
}
current_synchro_data.System = {'R'};

View File

@ -46,11 +46,12 @@
#include "cpu_multicorrelator.h"
#include <gnuradio/block.h>
#include <pmt/pmt.h>
#include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
#include <deque>
#include <fstream>
#include <map>
#include <string>
#include <vector>
class glonass_l1_ca_dll_pll_c_aid_tracking_cc;
@ -123,9 +124,9 @@ private:
double d_early_late_spc_chips;
int32_t d_n_correlator_taps;
gr_complex* d_ca_code;
float* d_local_code_shift_chips;
gr_complex* d_correlator_outs;
volk_gnsssdr::vector<gr_complex> d_ca_code;
volk_gnsssdr::vector<float> d_local_code_shift_chips;
volk_gnsssdr::vector<gr_complex> d_correlator_outs;
Cpu_Multicorrelator multicorrelator_cpu;
// remaining code phase and carrier phase between tracking loops
@ -181,7 +182,7 @@ private:
// CN0 estimation and lock detector
int32_t d_cn0_estimation_counter;
std::vector<gr_complex> d_Prompt_buffer;
volk_gnsssdr::vector<gr_complex> d_Prompt_buffer;
double d_carrier_lock_test;
double d_CN0_SNV_dB_Hz;
double d_carrier_lock_threshold;

View File

@ -54,12 +54,12 @@
#include <memory>
#include <sstream>
#include <utility>
#include <vector>
#define CN0_ESTIMATION_SAMPLES 10
glonass_l1_ca_dll_pll_c_aid_tracking_sc_sptr
glonass_l1_ca_dll_pll_c_aid_make_tracking_sc(
glonass_l1_ca_dll_pll_c_aid_tracking_sc_sptr glonass_l1_ca_dll_pll_c_aid_make_tracking_sc(
int64_t fs_in,
uint32_t vector_length,
bool dump,
@ -139,19 +139,15 @@ glonass_l1_ca_dll_pll_c_aid_tracking_sc::glonass_l1_ca_dll_pll_c_aid_tracking_sc
// Initialization of local code replica
// Get space for a vector with the C/A code replica sampled 1x/chip
d_ca_code = static_cast<gr_complex *>(volk_gnsssdr_malloc(static_cast<int32_t>(GLONASS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_ca_code_16sc = static_cast<lv_16sc_t *>(volk_gnsssdr_malloc(static_cast<int32_t>(GLONASS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(lv_16sc_t), volk_gnsssdr_get_alignment()));
d_ca_code.resize(static_cast<int32_t>(GLONASS_L1_CA_CODE_LENGTH_CHIPS), gr_complex(0.0, 0.0));
d_ca_code_16sc.reserve(static_cast<int32_t>(GLONASS_L1_CA_CODE_LENGTH_CHIPS));
// correlator outputs (scalar)
d_n_correlator_taps = 3; // Early, Prompt, and Late
d_correlator_outs_16sc = static_cast<lv_16sc_t *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(lv_16sc_t), volk_gnsssdr_get_alignment()));
for (int32_t n = 0; n < d_n_correlator_taps; n++)
{
d_correlator_outs_16sc[n] = lv_cmake(0, 0);
}
d_correlator_outs_16sc.resize(d_n_correlator_taps, lv_cmake(0, 0));
d_local_code_shift_chips = static_cast<float *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(float), volk_gnsssdr_get_alignment()));
d_local_code_shift_chips.reserve(d_n_correlator_taps);
// Set TAPs delay values [chips]
d_local_code_shift_chips[0] = -d_early_late_spc_chips;
d_local_code_shift_chips[1] = 0.0;
@ -175,7 +171,7 @@ glonass_l1_ca_dll_pll_c_aid_tracking_sc::glonass_l1_ca_dll_pll_c_aid_tracking_sc
// CN0 estimation and lock detector buffers
d_cn0_estimation_counter = 0;
d_Prompt_buffer = std::vector<gr_complex>(FLAGS_cn0_samples);
d_Prompt_buffer.reserve(FLAGS_cn0_samples);
d_carrier_lock_test = 1;
d_CN0_SNV_dB_Hz = 0;
d_carrier_lock_fail_counter = 0;
@ -269,10 +265,10 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_sc::start_tracking()
d_code_loop_filter.initialize(); // initialize the code filter
// generate local reference ALWAYS starting at chip 1 (1 sample per chip)
glonass_l1_ca_code_gen_complex(gsl::span<gr_complex>(d_ca_code, GLONASS_L1_CA_CODE_LENGTH_CHIPS), 0);
volk_gnsssdr_32fc_convert_16ic(d_ca_code_16sc, d_ca_code, static_cast<int32_t>(GLONASS_L1_CA_CODE_LENGTH_CHIPS));
glonass_l1_ca_code_gen_complex(d_ca_code, 0);
volk_gnsssdr_32fc_convert_16ic(d_ca_code_16sc.data(), d_ca_code.data(), static_cast<int32_t>(GLONASS_L1_CA_CODE_LENGTH_CHIPS));
multicorrelator_cpu_16sc.set_local_code_and_taps(static_cast<int32_t>(GLONASS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code_16sc, d_local_code_shift_chips);
multicorrelator_cpu_16sc.set_local_code_and_taps(static_cast<int32_t>(GLONASS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code_16sc.data(), d_local_code_shift_chips.data());
for (int32_t n = 0; n < d_n_correlator_taps; n++)
{
d_correlator_outs_16sc[n] = lv_16sc_t(0, 0);
@ -486,7 +482,7 @@ glonass_l1_ca_dll_pll_c_aid_tracking_sc::~glonass_l1_ca_dll_pll_c_aid_tracking_s
}
catch (const std::exception &ex)
{
LOG(WARNING) << "Exception in destructor " << ex.what();
LOG(WARNING) << "Exception in Tracking block destructor: " << ex.what();
}
}
@ -511,12 +507,14 @@ glonass_l1_ca_dll_pll_c_aid_tracking_sc::~glonass_l1_ca_dll_pll_c_aid_tracking_s
}
}
volk_gnsssdr_free(d_local_code_shift_chips);
volk_gnsssdr_free(d_ca_code);
volk_gnsssdr_free(d_ca_code_16sc);
volk_gnsssdr_free(d_correlator_outs_16sc);
try
{
multicorrelator_cpu_16sc.free();
}
catch (const std::exception &ex)
{
LOG(WARNING) << "Exception in Tracking block destructor: " << ex.what();
}
}
@ -594,7 +592,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at
// ################# CARRIER WIPEOFF AND CORRELATORS ##############################
// perform carrier wipe-off and compute Early, Prompt and Late correlation
multicorrelator_cpu_16sc.set_input_output_vectors(d_correlator_outs_16sc, in);
multicorrelator_cpu_16sc.set_input_output_vectors(d_correlator_outs_16sc.data(), in);
multicorrelator_cpu_16sc.Carrier_wipeoff_multicorrelator_resampler(d_rem_carrier_phase_rad,
d_carrier_phase_step_rad,
d_rem_code_phase_chips,

View File

@ -46,11 +46,11 @@
#include "tracking_FLL_PLL_filter.h"
#include <gnuradio/block.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
#include <deque>
#include <fstream>
#include <map>
#include <string>
#include <vector>
class glonass_l1_ca_dll_pll_c_aid_tracking_sc;
@ -123,12 +123,10 @@ private:
double d_early_late_spc_chips;
int32_t d_n_correlator_taps;
gr_complex* d_ca_code;
lv_16sc_t* d_ca_code_16sc;
float* d_local_code_shift_chips;
// gr_complex* d_correlator_outs;
lv_16sc_t* d_correlator_outs_16sc;
// cpu_multicorrelator multicorrelator_cpu;
volk_gnsssdr::vector<gr_complex> d_ca_code;
volk_gnsssdr::vector<lv_16sc_t> d_ca_code_16sc;
volk_gnsssdr::vector<float> d_local_code_shift_chips;
volk_gnsssdr::vector<lv_16sc_t> d_correlator_outs_16sc;
Cpu_Multicorrelator_16sc multicorrelator_cpu_16sc;
// remaining code phase and carrier phase between tracking loops
@ -183,7 +181,7 @@ private:
// CN0 estimation and lock detector
int32_t d_cn0_estimation_counter;
std::vector<gr_complex> d_Prompt_buffer;
volk_gnsssdr::vector<gr_complex> d_Prompt_buffer;
double d_carrier_lock_test;
double d_CN0_SNV_dB_Hz;
double d_carrier_lock_threshold;

View File

@ -45,7 +45,7 @@
#include <glog/logging.h>
#include <gnuradio/io_signature.h>
#include <matio.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <algorithm>
#include <array>
#include <cmath>
#include <exception>
@ -53,12 +53,11 @@
#include <memory>
#include <sstream>
#include <utility>
#include <vector>
#define CN0_ESTIMATION_SAMPLES 10
glonass_l1_ca_dll_pll_tracking_cc_sptr
glonass_l1_ca_dll_pll_make_tracking_cc(
glonass_l1_ca_dll_pll_tracking_cc_sptr glonass_l1_ca_dll_pll_make_tracking_cc(
int64_t fs_in,
uint32_t vector_length,
bool dump,
@ -111,16 +110,13 @@ Glonass_L1_Ca_Dll_Pll_Tracking_cc::Glonass_L1_Ca_Dll_Pll_Tracking_cc(
// Initialization of local code replica
// Get space for a vector with the C/A code replica sampled 1x/chip
d_ca_code = static_cast<gr_complex *>(volk_gnsssdr_malloc(static_cast<int32_t>(GLONASS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_ca_code.resize(static_cast<int32_t>(GLONASS_L1_CA_CODE_LENGTH_CHIPS), gr_complex(0.0, 0.0));
// correlator outputs (scalar)
d_n_correlator_taps = 3; // Early, Prompt, and Late
d_correlator_outs = static_cast<gr_complex *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
for (int32_t n = 0; n < d_n_correlator_taps; n++)
{
d_correlator_outs[n] = gr_complex(0, 0);
}
d_local_code_shift_chips = static_cast<float *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(float), volk_gnsssdr_get_alignment()));
d_correlator_outs.resize(d_n_correlator_taps, gr_complex(0.0, 0.0));
d_local_code_shift_chips.reserve(d_n_correlator_taps);
// Set TAPs delay values [chips]
d_local_code_shift_chips[0] = -d_early_late_spc_chips;
d_local_code_shift_chips[1] = 0.0;
@ -146,7 +142,7 @@ Glonass_L1_Ca_Dll_Pll_Tracking_cc::Glonass_L1_Ca_Dll_Pll_Tracking_cc(
// CN0 estimation and lock detector buffers
d_cn0_estimation_counter = 0;
d_Prompt_buffer = std::vector<gr_complex>(FLAGS_cn0_samples);
d_Prompt_buffer.reserve(FLAGS_cn0_samples);
d_carrier_lock_test = 1;
d_CN0_SNV_dB_Hz = 0;
d_carrier_lock_fail_counter = 0;
@ -228,13 +224,11 @@ void Glonass_L1_Ca_Dll_Pll_Tracking_cc::start_tracking()
d_code_loop_filter.initialize(); // initialize the code filter
// generate local reference ALWAYS starting at chip 1 (1 sample per chip)
glonass_l1_ca_code_gen_complex(gsl::span<gr_complex>(d_ca_code, GLONASS_L1_CA_CODE_LENGTH_CHIPS), 0);
//glonass_l1_ca_code_gen_complex(gsl::span<gr_complex>(d_ca_code.data(), GLONASS_L1_CA_CODE_LENGTH_CHIPS), 0);
glonass_l1_ca_code_gen_complex(d_ca_code, 0);
multicorrelator_cpu.set_local_code_and_taps(static_cast<int32_t>(GLONASS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips);
for (int32_t n = 0; n < d_n_correlator_taps; n++)
{
d_correlator_outs[n] = gr_complex(0, 0);
}
multicorrelator_cpu.set_local_code_and_taps(static_cast<int32_t>(GLONASS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code.data(), d_local_code_shift_chips.data());
std::fill_n(d_correlator_outs.begin(), d_n_correlator_taps, gr_complex(0.0, 0.0));
d_carrier_lock_fail_counter = 0;
d_rem_code_phase_samples = 0;
@ -271,7 +265,7 @@ Glonass_L1_Ca_Dll_Pll_Tracking_cc::~Glonass_L1_Ca_Dll_Pll_Tracking_cc()
}
catch (const std::exception &ex)
{
LOG(WARNING) << "Exception in destructor " << ex.what();
LOG(WARNING) << "Exception in Tracking block destructor: " << ex.what();
}
}
if (d_dump)
@ -296,14 +290,11 @@ Glonass_L1_Ca_Dll_Pll_Tracking_cc::~Glonass_L1_Ca_Dll_Pll_Tracking_cc()
}
try
{
volk_gnsssdr_free(d_local_code_shift_chips);
volk_gnsssdr_free(d_correlator_outs);
volk_gnsssdr_free(d_ca_code);
multicorrelator_cpu.free();
}
catch (const std::exception &ex)
{
LOG(WARNING) << "Exception in destructor " << ex.what();
LOG(WARNING) << "Exception in Tracking block destructor: " << ex.what();
}
}
@ -556,7 +547,7 @@ int Glonass_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut
// ################# CARRIER WIPEOFF AND CORRELATORS ##############################
// perform carrier wipe-off and compute Early, Prompt and Late correlation
multicorrelator_cpu.set_input_output_vectors(d_correlator_outs, in);
multicorrelator_cpu.set_input_output_vectors(d_correlator_outs.data(), in);
multicorrelator_cpu.Carrier_wipeoff_multicorrelator_resampler(d_rem_carr_phase_rad,
d_carrier_phase_step_rad,
d_rem_code_phase_chips,
@ -658,11 +649,7 @@ int Glonass_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut
}
else
{
for (int32_t n = 0; n < d_n_correlator_taps; n++)
{
d_correlator_outs[n] = gr_complex(0, 0);
}
std::fill_n(d_correlator_outs.begin(), d_n_correlator_taps, gr_complex(0.0, 0.0));
current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast<uint64_t>(d_current_prn_length_samples);
current_synchro_data.System = {'R'};
current_synchro_data.correlation_length_ms = 1;

View File

@ -44,10 +44,10 @@
#include "tracking_2nd_DLL_filter.h"
#include "tracking_2nd_PLL_filter.h"
#include <gnuradio/block.h>
#include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
#include <fstream>
#include <map>
#include <string>
#include <vector>
class Glonass_L1_Ca_Dll_Pll_Tracking_cc;
@ -124,9 +124,9 @@ private:
double d_acq_carrier_doppler_hz;
// correlator
int32_t d_n_correlator_taps;
gr_complex* d_ca_code;
float* d_local_code_shift_chips;
gr_complex* d_correlator_outs;
volk_gnsssdr::vector<gr_complex> d_ca_code;
volk_gnsssdr::vector<float> d_local_code_shift_chips;
volk_gnsssdr::vector<gr_complex> d_correlator_outs;
Cpu_Multicorrelator multicorrelator_cpu;
// tracking vars
@ -148,7 +148,7 @@ private:
// CN0 estimation and lock detector
int32_t d_cn0_estimation_counter;
std::vector<gr_complex> d_Prompt_buffer;
volk_gnsssdr::vector<gr_complex> d_Prompt_buffer;
double d_carrier_lock_test;
double d_CN0_SNV_dB_Hz;
double d_carrier_lock_threshold;

View File

@ -45,7 +45,7 @@
#include <gnuradio/io_signature.h>
#include <matio.h>
#include <pmt/pmt.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <algorithm>
#include <array>
#include <cmath>
#include <exception>
@ -53,12 +53,12 @@
#include <memory>
#include <sstream>
#include <utility>
#include <vector>
#define CN0_ESTIMATION_SAMPLES 10
glonass_l2_ca_dll_pll_c_aid_tracking_cc_sptr
glonass_l2_ca_dll_pll_c_aid_make_tracking_cc(
glonass_l2_ca_dll_pll_c_aid_tracking_cc_sptr glonass_l2_ca_dll_pll_c_aid_make_tracking_cc(
int64_t fs_in,
uint32_t vector_length,
bool dump,
@ -140,16 +140,13 @@ glonass_l2_ca_dll_pll_c_aid_tracking_cc::glonass_l2_ca_dll_pll_c_aid_tracking_cc
// Initialization of local code replica
// Get space for a vector with the C/A code replica sampled 1x/chip
d_ca_code = static_cast<gr_complex *>(volk_gnsssdr_malloc(static_cast<int32_t>(GLONASS_L2_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_ca_code.resize(static_cast<int32_t>(GLONASS_L2_CA_CODE_LENGTH_CHIPS), gr_complex(0.0, 0.0));
// correlator outputs (scalar)
d_n_correlator_taps = 3; // Early, Prompt, and Late
d_correlator_outs = static_cast<gr_complex *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
for (int32_t n = 0; n < d_n_correlator_taps; n++)
{
d_correlator_outs[n] = gr_complex(0, 0);
}
d_local_code_shift_chips = static_cast<float *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(float), volk_gnsssdr_get_alignment()));
d_correlator_outs.resize(d_n_correlator_taps, gr_complex(0.0, 0.0));
d_local_code_shift_chips.reserve(d_n_correlator_taps);
// Set TAPs delay values [chips]
d_local_code_shift_chips[0] = -d_early_late_spc_chips;
d_local_code_shift_chips[1] = 0.0;
@ -173,7 +170,7 @@ glonass_l2_ca_dll_pll_c_aid_tracking_cc::glonass_l2_ca_dll_pll_c_aid_tracking_cc
// CN0 estimation and lock detector buffers
d_cn0_estimation_counter = 0;
d_Prompt_buffer = std::vector<gr_complex>(FLAGS_cn0_samples);
d_Prompt_buffer.reserve(FLAGS_cn0_samples);
d_carrier_lock_test = 1;
d_CN0_SNV_dB_Hz = 0;
d_carrier_lock_fail_counter = 0;
@ -265,19 +262,15 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_cc::start_tracking()
d_carrier_doppler_hz = d_acq_carrier_doppler_hz;
d_carrier_phase_step_rad = GLONASS_TWO_PI * d_carrier_frequency_hz / static_cast<double>(d_fs_in);
// DLL/PLL filter initialization
d_carrier_loop_filter.initialize(d_carrier_frequency_hz); // The carrier loop filter implements the Doppler accumulator
d_code_loop_filter.initialize(); // initialize the code filter
// generate local reference ALWAYS starting at chip 1 (1 sample per chip)
glonass_l2_ca_code_gen_complex(gsl::span<gr_complex>(d_ca_code, static_cast<int32_t>(GLONASS_L2_CA_CODE_LENGTH_CHIPS)), 0);
glonass_l2_ca_code_gen_complex(d_ca_code, 0);
multicorrelator_cpu.set_local_code_and_taps(static_cast<int32_t>(GLONASS_L2_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips);
for (int32_t n = 0; n < d_n_correlator_taps; n++)
{
d_correlator_outs[n] = gr_complex(0, 0);
}
multicorrelator_cpu.set_local_code_and_taps(static_cast<int32_t>(GLONASS_L2_CA_CODE_LENGTH_CHIPS), d_ca_code.data(), d_local_code_shift_chips.data());
std::fill_n(d_correlator_outs.begin(), d_n_correlator_taps, gr_complex(0.0, 0.0));
d_carrier_lock_fail_counter = 0;
d_rem_code_phase_samples = 0.0;
@ -315,7 +308,7 @@ glonass_l2_ca_dll_pll_c_aid_tracking_cc::~glonass_l2_ca_dll_pll_c_aid_tracking_c
}
catch (const std::exception &ex)
{
LOG(WARNING) << "Exception in destructor " << ex.what();
LOG(WARNING) << "Exception in Tracking block destructor: " << ex.what();
}
}
@ -342,14 +335,11 @@ glonass_l2_ca_dll_pll_c_aid_tracking_cc::~glonass_l2_ca_dll_pll_c_aid_tracking_c
try
{
volk_gnsssdr_free(d_local_code_shift_chips);
volk_gnsssdr_free(d_correlator_outs);
volk_gnsssdr_free(d_ca_code);
multicorrelator_cpu.free();
}
catch (const std::exception &ex)
{
LOG(WARNING) << "Exception in destructor " << ex.what();
LOG(WARNING) << "Exception in Tracking block destructor: " << ex.what();
}
}
@ -599,7 +589,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at
// ################# CARRIER WIPEOFF AND CORRELATORS ##############################
// perform carrier wipe-off and compute Early, Prompt and Late correlation
multicorrelator_cpu.set_input_output_vectors(d_correlator_outs, in);
multicorrelator_cpu.set_input_output_vectors(d_correlator_outs.data(), in);
multicorrelator_cpu.Carrier_wipeoff_multicorrelator_resampler(d_rem_carrier_phase_rad,
d_carrier_phase_step_rad,
d_rem_code_phase_chips,
@ -815,11 +805,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at
}
else
{
for (int32_t n = 0; n < d_n_correlator_taps; n++)
{
d_correlator_outs[n] = gr_complex(0, 0);
}
std::fill_n(d_correlator_outs.begin(), d_n_correlator_taps, gr_complex(0.0, 0.0));
current_synchro_data.System = {'R'};
current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast<uint64_t>(d_correlation_length_samples);
}

View File

@ -40,15 +40,14 @@
#include "gnss_synchro.h"
#include "tracking_2nd_DLL_filter.h"
#include "tracking_FLL_PLL_filter.h"
// #include "tracking_loop_filter.h"
#include "cpu_multicorrelator.h"
#include <gnuradio/block.h>
#include <pmt/pmt.h>
#include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
#include <deque>
#include <fstream>
#include <map>
#include <string>
#include <vector>
class glonass_l2_ca_dll_pll_c_aid_tracking_cc;
@ -121,9 +120,9 @@ private:
double d_early_late_spc_chips;
int32_t d_n_correlator_taps;
gr_complex* d_ca_code;
float* d_local_code_shift_chips;
gr_complex* d_correlator_outs;
volk_gnsssdr::vector<gr_complex> d_ca_code;
volk_gnsssdr::vector<float> d_local_code_shift_chips;
volk_gnsssdr::vector<gr_complex> d_correlator_outs;
Cpu_Multicorrelator multicorrelator_cpu;
// remaining code phase and carrier phase between tracking loops
@ -179,7 +178,7 @@ private:
// CN0 estimation and lock detector
int32_t d_cn0_estimation_counter;
std::vector<gr_complex> d_Prompt_buffer;
volk_gnsssdr::vector<gr_complex> d_Prompt_buffer;
double d_carrier_lock_test;
double d_CN0_SNV_dB_Hz;
double d_carrier_lock_threshold;

View File

@ -52,12 +52,12 @@
#include <memory>
#include <sstream>
#include <utility>
#include <vector>
#define CN0_ESTIMATION_SAMPLES 10
glonass_l2_ca_dll_pll_c_aid_tracking_sc_sptr
glonass_l2_ca_dll_pll_c_aid_make_tracking_sc(
glonass_l2_ca_dll_pll_c_aid_tracking_sc_sptr glonass_l2_ca_dll_pll_c_aid_make_tracking_sc(
int64_t fs_in,
uint32_t vector_length,
bool dump,
@ -137,19 +137,15 @@ glonass_l2_ca_dll_pll_c_aid_tracking_sc::glonass_l2_ca_dll_pll_c_aid_tracking_sc
// Initialization of local code replica
// Get space for a vector with the C/A code replica sampled 1x/chip
d_ca_code = static_cast<gr_complex *>(volk_gnsssdr_malloc(static_cast<int32_t>(GLONASS_L2_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_ca_code_16sc = static_cast<lv_16sc_t *>(volk_gnsssdr_malloc(static_cast<int32_t>(GLONASS_L2_CA_CODE_LENGTH_CHIPS) * sizeof(lv_16sc_t), volk_gnsssdr_get_alignment()));
d_ca_code.resize(static_cast<int32_t>(GLONASS_L2_CA_CODE_LENGTH_CHIPS), gr_complex(0.0, 0.0));
d_ca_code_16sc.reserve(static_cast<int32_t>(GLONASS_L2_CA_CODE_LENGTH_CHIPS));
// correlator outputs (scalar)
d_n_correlator_taps = 3; // Early, Prompt, and Late
d_correlator_outs_16sc = static_cast<lv_16sc_t *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(lv_16sc_t), volk_gnsssdr_get_alignment()));
for (int32_t n = 0; n < d_n_correlator_taps; n++)
{
d_correlator_outs_16sc[n] = lv_cmake(0, 0);
}
d_correlator_outs_16sc.resize(d_n_correlator_taps, lv_cmake(0, 0));
d_local_code_shift_chips = static_cast<float *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(float), volk_gnsssdr_get_alignment()));
d_local_code_shift_chips.reserve(d_n_correlator_taps);
// Set TAPs delay values [chips]
d_local_code_shift_chips[0] = -d_early_late_spc_chips;
d_local_code_shift_chips[1] = 0.0;
@ -173,7 +169,7 @@ glonass_l2_ca_dll_pll_c_aid_tracking_sc::glonass_l2_ca_dll_pll_c_aid_tracking_sc
// CN0 estimation and lock detector buffers
d_cn0_estimation_counter = 0;
d_Prompt_buffer = std::vector<gr_complex>(FLAGS_cn0_samples);
d_Prompt_buffer.reserve(FLAGS_cn0_samples);
d_carrier_lock_test = 1;
d_CN0_SNV_dB_Hz = 0;
d_carrier_lock_fail_counter = 0;
@ -267,10 +263,10 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_sc::start_tracking()
d_code_loop_filter.initialize(); // initialize the code filter
// generate local reference ALWAYS starting at chip 1 (1 sample per chip)
glonass_l2_ca_code_gen_complex(gsl::span<gr_complex>(d_ca_code, static_cast<int32_t>(GLONASS_L2_CA_CODE_LENGTH_CHIPS)), 0);
volk_gnsssdr_32fc_convert_16ic(d_ca_code_16sc, d_ca_code, static_cast<int32_t>(GLONASS_L2_CA_CODE_LENGTH_CHIPS));
glonass_l2_ca_code_gen_complex(d_ca_code, 0);
volk_gnsssdr_32fc_convert_16ic(d_ca_code_16sc.data(), d_ca_code.data(), static_cast<int32_t>(GLONASS_L2_CA_CODE_LENGTH_CHIPS));
multicorrelator_cpu_16sc.set_local_code_and_taps(static_cast<int32_t>(GLONASS_L2_CA_CODE_LENGTH_CHIPS), d_ca_code_16sc, d_local_code_shift_chips);
multicorrelator_cpu_16sc.set_local_code_and_taps(static_cast<int32_t>(GLONASS_L2_CA_CODE_LENGTH_CHIPS), d_ca_code_16sc.data(), d_local_code_shift_chips.data());
for (int32_t n = 0; n < d_n_correlator_taps; n++)
{
d_correlator_outs_16sc[n] = lv_16sc_t(0, 0);
@ -484,7 +480,7 @@ glonass_l2_ca_dll_pll_c_aid_tracking_sc::~glonass_l2_ca_dll_pll_c_aid_tracking_s
}
catch (const std::exception &ex)
{
LOG(WARNING) << "Exception in destructor " << ex.what();
LOG(WARNING) << "Exception in Tracking block destructor: " << ex.what();
}
}
@ -509,12 +505,14 @@ glonass_l2_ca_dll_pll_c_aid_tracking_sc::~glonass_l2_ca_dll_pll_c_aid_tracking_s
}
}
volk_gnsssdr_free(d_local_code_shift_chips);
volk_gnsssdr_free(d_ca_code);
volk_gnsssdr_free(d_ca_code_16sc);
volk_gnsssdr_free(d_correlator_outs_16sc);
try
{
multicorrelator_cpu_16sc.free();
}
catch (const std::exception &ex)
{
LOG(WARNING) << "Exception in Tracking block destructor: " << ex.what();
}
}
@ -592,7 +590,7 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at
// ################# CARRIER WIPEOFF AND CORRELATORS ##############################
// perform carrier wipe-off and compute Early, Prompt and Late correlation
multicorrelator_cpu_16sc.set_input_output_vectors(d_correlator_outs_16sc, in);
multicorrelator_cpu_16sc.set_input_output_vectors(d_correlator_outs_16sc.data(), in);
multicorrelator_cpu_16sc.Carrier_wipeoff_multicorrelator_resampler(d_rem_carrier_phase_rad,
d_carrier_phase_step_rad,
d_rem_code_phase_chips,

View File

@ -43,12 +43,11 @@
#include "tracking_2nd_DLL_filter.h"
#include "tracking_FLL_PLL_filter.h"
#include <gnuradio/block.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
#include <deque>
#include <fstream>
#include <map>
#include <string>
#include <vector>
class glonass_l2_ca_dll_pll_c_aid_tracking_sc;
@ -121,12 +120,10 @@ private:
double d_early_late_spc_chips;
int32_t d_n_correlator_taps;
gr_complex* d_ca_code;
lv_16sc_t* d_ca_code_16sc;
float* d_local_code_shift_chips;
// gr_complex* d_correlator_outs;
lv_16sc_t* d_correlator_outs_16sc;
// cpu_multicorrelator multicorrelator_cpu;
volk_gnsssdr::vector<gr_complex> d_ca_code;
volk_gnsssdr::vector<lv_16sc_t> d_ca_code_16sc;
volk_gnsssdr::vector<float> d_local_code_shift_chips;
volk_gnsssdr::vector<lv_16sc_t> d_correlator_outs_16sc;
Cpu_Multicorrelator_16sc multicorrelator_cpu_16sc;
// remaining code phase and carrier phase between tracking loops
@ -181,7 +178,7 @@ private:
// CN0 estimation and lock detector
int32_t d_cn0_estimation_counter;
std::vector<gr_complex> d_Prompt_buffer;
volk_gnsssdr::vector<gr_complex> d_Prompt_buffer;
double d_carrier_lock_test;
double d_CN0_SNV_dB_Hz;
double d_carrier_lock_threshold;

View File

@ -45,7 +45,7 @@
#include <glog/logging.h>
#include <gnuradio/io_signature.h>
#include <matio.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <algorithm>
#include <array>
#include <cmath>
#include <exception>
@ -53,12 +53,12 @@
#include <memory>
#include <sstream>
#include <utility>
#include <vector>
#define CN0_ESTIMATION_SAMPLES 10
glonass_l2_ca_dll_pll_tracking_cc_sptr
glonass_l2_ca_dll_pll_make_tracking_cc(
glonass_l2_ca_dll_pll_tracking_cc_sptr glonass_l2_ca_dll_pll_make_tracking_cc(
int64_t fs_in,
uint32_t vector_length,
bool dump,
@ -111,16 +111,13 @@ Glonass_L2_Ca_Dll_Pll_Tracking_cc::Glonass_L2_Ca_Dll_Pll_Tracking_cc(
// Initialization of local code replica
// Get space for a vector with the C/A code replica sampled 1x/chip
d_ca_code = static_cast<gr_complex *>(volk_gnsssdr_malloc(static_cast<int32_t>(GLONASS_L2_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_ca_code.resize(static_cast<int32_t>(GLONASS_L2_CA_CODE_LENGTH_CHIPS), gr_complex(0.0, 0.0));
// correlator outputs (scalar)
d_n_correlator_taps = 3; // Early, Prompt, and Late
d_correlator_outs = static_cast<gr_complex *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
for (int32_t n = 0; n < d_n_correlator_taps; n++)
{
d_correlator_outs[n] = gr_complex(0, 0);
}
d_local_code_shift_chips = static_cast<float *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(float), volk_gnsssdr_get_alignment()));
d_correlator_outs.resize(d_n_correlator_taps, gr_complex(0.0, 0.0));
d_local_code_shift_chips.reserve(d_n_correlator_taps);
// Set TAPs delay values [chips]
d_local_code_shift_chips[0] = -d_early_late_spc_chips;
d_local_code_shift_chips[1] = 0.0;
@ -146,7 +143,7 @@ Glonass_L2_Ca_Dll_Pll_Tracking_cc::Glonass_L2_Ca_Dll_Pll_Tracking_cc(
// CN0 estimation and lock detector buffers
d_cn0_estimation_counter = 0;
d_Prompt_buffer = std::vector<gr_complex>(FLAGS_cn0_samples);
d_Prompt_buffer.reserve(FLAGS_cn0_samples);
d_carrier_lock_test = 1;
d_CN0_SNV_dB_Hz = 0;
d_carrier_lock_fail_counter = 0;
@ -228,13 +225,10 @@ void Glonass_L2_Ca_Dll_Pll_Tracking_cc::start_tracking()
d_code_loop_filter.initialize(); // initialize the code filter
// generate local reference ALWAYS starting at chip 1 (1 sample per chip)
glonass_l2_ca_code_gen_complex(gsl::span<gr_complex>(d_ca_code, static_cast<int32_t>(GLONASS_L2_CA_CODE_LENGTH_CHIPS)), 0);
glonass_l2_ca_code_gen_complex(gsl::span<gr_complex>(d_ca_code.data(), GLONASS_L2_CA_CODE_LENGTH_CHIPS), 0);
multicorrelator_cpu.set_local_code_and_taps(static_cast<int32_t>(GLONASS_L2_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips);
for (int32_t n = 0; n < d_n_correlator_taps; n++)
{
d_correlator_outs[n] = gr_complex(0, 0);
}
multicorrelator_cpu.set_local_code_and_taps(static_cast<int32_t>(GLONASS_L2_CA_CODE_LENGTH_CHIPS), d_ca_code.data(), d_local_code_shift_chips.data());
std::fill_n(d_correlator_outs.begin(), d_n_correlator_taps, gr_complex(0.0, 0.0));
d_carrier_lock_fail_counter = 0;
d_rem_code_phase_samples = 0;
@ -271,7 +265,7 @@ Glonass_L2_Ca_Dll_Pll_Tracking_cc::~Glonass_L2_Ca_Dll_Pll_Tracking_cc()
}
catch (const std::exception &ex)
{
LOG(WARNING) << "Exception in destructor " << ex.what();
LOG(WARNING) << "Exception in Tracking block destructor: " << ex.what();
}
}
if (d_dump)
@ -296,14 +290,11 @@ Glonass_L2_Ca_Dll_Pll_Tracking_cc::~Glonass_L2_Ca_Dll_Pll_Tracking_cc()
}
try
{
volk_gnsssdr_free(d_local_code_shift_chips);
volk_gnsssdr_free(d_correlator_outs);
volk_gnsssdr_free(d_ca_code);
multicorrelator_cpu.free();
}
catch (const std::exception &ex)
{
LOG(WARNING) << "Exception in destructor " << ex.what();
LOG(WARNING) << "Exception in Tracking block destructor: " << ex.what();
}
}
@ -556,7 +547,7 @@ int Glonass_L2_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut
// ################# CARRIER WIPEOFF AND CORRELATORS ##############################
// perform carrier wipe-off and compute Early, Prompt and Late correlation
multicorrelator_cpu.set_input_output_vectors(d_correlator_outs, in);
multicorrelator_cpu.set_input_output_vectors(d_correlator_outs.data(), in);
multicorrelator_cpu.Carrier_wipeoff_multicorrelator_resampler(d_rem_carr_phase_rad,
d_carrier_phase_step_rad,
d_rem_code_phase_chips,
@ -658,11 +649,7 @@ int Glonass_L2_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut
}
else
{
for (int32_t n = 0; n < d_n_correlator_taps; n++)
{
d_correlator_outs[n] = gr_complex(0, 0);
}
std::fill_n(d_correlator_outs.begin(), d_n_correlator_taps, gr_complex(0.0, 0.0));
current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast<uint64_t>(d_current_prn_length_samples);
current_synchro_data.System = {'R'};
current_synchro_data.correlation_length_ms = 1;

View File

@ -42,10 +42,10 @@
#include "tracking_2nd_DLL_filter.h"
#include "tracking_2nd_PLL_filter.h"
#include <gnuradio/block.h>
#include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
#include <fstream>
#include <map>
#include <string>
#include <vector>
class Glonass_L2_Ca_Dll_Pll_Tracking_cc;
@ -122,9 +122,10 @@ private:
double d_acq_carrier_doppler_hz;
// correlator
int32_t d_n_correlator_taps;
gr_complex* d_ca_code;
float* d_local_code_shift_chips;
gr_complex* d_correlator_outs;
volk_gnsssdr::vector<gr_complex> d_ca_code;
volk_gnsssdr::vector<float> d_local_code_shift_chips;
volk_gnsssdr::vector<gr_complex> d_correlator_outs;
Cpu_Multicorrelator multicorrelator_cpu;
// tracking vars
@ -146,7 +147,7 @@ private:
// CN0 estimation and lock detector
int32_t d_cn0_estimation_counter;
std::vector<gr_complex> d_Prompt_buffer;
volk_gnsssdr::vector<gr_complex> d_Prompt_buffer;
double d_carrier_lock_test;
double d_CN0_SNV_dB_Hz;
double d_carrier_lock_threshold;

View File

@ -48,6 +48,7 @@
#include <gsl/gsl>
#include <matio.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <algorithm>
#include <array>
#include <cmath>
#include <exception>
@ -55,10 +56,10 @@
#include <memory>
#include <sstream>
#include <utility>
#include <vector>
gps_l1_ca_kf_tracking_cc_sptr
gps_l1_ca_kf_make_tracking_cc(
gps_l1_ca_kf_tracking_cc_sptr gps_l1_ca_kf_make_tracking_cc(
uint32_t order,
int64_t if_freq,
int64_t fs_in,
@ -127,16 +128,13 @@ Gps_L1_Ca_Kf_Tracking_cc::Gps_L1_Ca_Kf_Tracking_cc(
// Initialization of local code replica
// Get space for a vector with the C/A code replica sampled 1x/chip
d_ca_code = static_cast<float *>(volk_gnsssdr_malloc(static_cast<int>(GPS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(float), volk_gnsssdr_get_alignment()));
d_ca_code.resize(static_cast<int>(GPS_L1_CA_CODE_LENGTH_CHIPS));
// correlator outputs (scalar)
d_n_correlator_taps = 3; // Early, Prompt, and Late
d_correlator_outs = static_cast<gr_complex *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
for (int32_t n = 0; n < d_n_correlator_taps; n++)
{
d_correlator_outs[n] = gr_complex(0, 0);
}
d_local_code_shift_chips = static_cast<float *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(float), volk_gnsssdr_get_alignment()));
d_correlator_outs.resize(d_n_correlator_taps, gr_complex(0.0, 0.0));
d_local_code_shift_chips.reserve(d_n_correlator_taps);
// Set TAPs delay values [chips]
d_local_code_shift_chips[0] = -d_early_late_spc_chips;
d_local_code_shift_chips[1] = 0.0;
@ -163,7 +161,7 @@ Gps_L1_Ca_Kf_Tracking_cc::Gps_L1_Ca_Kf_Tracking_cc(
// CN0 estimation and lock detector buffers
d_cn0_estimation_counter = 0;
d_Prompt_buffer = std::vector<gr_complex>(FLAGS_cn0_samples);
d_Prompt_buffer.reserve(FLAGS_cn0_samples);
d_carrier_lock_test = 1;
d_CN0_SNV_dB_Hz = 0;
d_carrier_lock_fail_counter = 0;
@ -324,13 +322,10 @@ void Gps_L1_Ca_Kf_Tracking_cc::start_tracking()
d_code_loop_filter.initialize(); // initialize the code filter
// generate local reference ALWAYS starting at chip 1 (1 sample per chip)
gps_l1_ca_code_gen_float(gsl::span<float>(d_ca_code, static_cast<int>(GPS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(float)), d_acquisition_gnss_synchro->PRN, 0);
gps_l1_ca_code_gen_float(d_ca_code, d_acquisition_gnss_synchro->PRN, 0);
multicorrelator_cpu.set_local_code_and_taps(static_cast<int>(GPS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips);
for (int32_t n = 0; n < d_n_correlator_taps; n++)
{
d_correlator_outs[n] = gr_complex(0, 0);
}
multicorrelator_cpu.set_local_code_and_taps(static_cast<int>(GPS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code.data(), d_local_code_shift_chips.data());
std::fill_n(d_correlator_outs.begin(), d_n_correlator_taps, gr_complex(0.0, 0.0));
d_carrier_lock_fail_counter = 0;
d_rem_code_phase_samples = 0;
@ -368,7 +363,7 @@ Gps_L1_Ca_Kf_Tracking_cc::~Gps_L1_Ca_Kf_Tracking_cc()
}
catch (const std::exception &ex)
{
LOG(WARNING) << "Exception in destructor " << ex.what();
LOG(WARNING) << "Exception in Tracking block destructor: " << ex.what();
}
}
if (d_dump)
@ -393,14 +388,11 @@ Gps_L1_Ca_Kf_Tracking_cc::~Gps_L1_Ca_Kf_Tracking_cc()
}
try
{
volk_gnsssdr_free(d_local_code_shift_chips);
volk_gnsssdr_free(d_correlator_outs);
volk_gnsssdr_free(d_ca_code);
multicorrelator_cpu.free();
}
catch (const std::exception &ex)
{
LOG(WARNING) << "Exception in destructor " << ex.what();
LOG(WARNING) << "Exception in Tracking block destructor: " << ex.what();
}
}
@ -693,7 +685,7 @@ int Gps_L1_Ca_Kf_Tracking_cc::general_work(int noutput_items __attribute__((unus
// ################# CARRIER WIPEOFF AND CORRELATORS ##############################
// Perform carrier wipe-off and compute Early, Prompt and Late correlation
multicorrelator_cpu.set_input_output_vectors(d_correlator_outs, in);
multicorrelator_cpu.set_input_output_vectors(d_correlator_outs.data(), in);
multicorrelator_cpu.Carrier_wipeoff_multicorrelator_resampler(d_rem_carr_phase_rad,
d_carrier_phase_step_rad,
d_rem_code_phase_chips,

View File

@ -49,12 +49,12 @@
#include "gnss_synchro.h"
#include "tracking_2nd_DLL_filter.h"
#include "tracking_2nd_PLL_filter.h"
#include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
#include <armadillo>
#include <gnuradio/block.h>
#include <fstream>
#include <map>
#include <string>
#include <vector>
class Gps_L1_Ca_Kf_Tracking_cc;
@ -175,9 +175,9 @@ private:
double d_acq_carrier_doppler_hz;
// correlator
int32_t d_n_correlator_taps;
float* d_ca_code;
float* d_local_code_shift_chips;
gr_complex* d_correlator_outs;
volk_gnsssdr::vector<float> d_ca_code;
volk_gnsssdr::vector<float> d_local_code_shift_chips;
volk_gnsssdr::vector<gr_complex> d_correlator_outs;
Cpu_Multicorrelator_Real_Codes multicorrelator_cpu;
// tracking vars
@ -203,7 +203,7 @@ private:
// CN0 estimation and lock detector
int32_t d_cn0_estimation_counter;
std::vector<gr_complex> d_Prompt_buffer;
volk_gnsssdr::vector<gr_complex> d_Prompt_buffer;
double d_carrier_lock_test;
double d_CN0_SNV_dB_Hz;
double d_carrier_lock_threshold;

View File

@ -45,7 +45,7 @@
#include "tracking_discriminators.h"
#include <glog/logging.h>
#include <gnuradio/io_signature.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <algorithm>
#include <cmath>
#include <exception>
#include <iostream>
@ -53,8 +53,7 @@
#include <utility>
gps_l1_ca_tcp_connector_tracking_cc_sptr
gps_l1_ca_tcp_connector_make_tracking_cc(
gps_l1_ca_tcp_connector_tracking_cc_sptr gps_l1_ca_tcp_connector_make_tracking_cc(
int64_t fs_in,
uint32_t vector_length,
bool dump,
@ -105,21 +104,19 @@ Gps_L1_Ca_Tcp_Connector_Tracking_cc::Gps_L1_Ca_Tcp_Connector_Tracking_cc(
// Initialization of local code replica
// Get space for a vector with the C/A code replica sampled 1x/chip
d_ca_code = static_cast<gr_complex *>(volk_gnsssdr_malloc((GPS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_ca_code.resize(GPS_L1_CA_CODE_LENGTH_CHIPS);
// correlator outputs (scalar)
d_n_correlator_taps = 3; // Very-Early, Early, Prompt, Late, Very-Late
d_correlator_outs = static_cast<gr_complex *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
for (int32_t n = 0; n < d_n_correlator_taps; n++)
{
d_correlator_outs[n] = gr_complex(0, 0);
}
d_correlator_outs.resize(d_n_correlator_taps);
std::fill_n(d_correlator_outs.begin(), d_n_correlator_taps, gr_complex(0.0, 0.0));
// map memory pointers of correlator outputs
d_Early = &d_correlator_outs[0];
d_Prompt = &d_correlator_outs[1];
d_Late = &d_correlator_outs[2];
d_local_code_shift_chips = static_cast<float *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(float), volk_gnsssdr_get_alignment()));
d_local_code_shift_chips.reserve(d_n_correlator_taps);
// Set TAPs delay values [chips]
d_local_code_shift_chips[0] = -d_early_late_spc_chips;
d_local_code_shift_chips[1] = 0.0;
@ -149,7 +146,7 @@ Gps_L1_Ca_Tcp_Connector_Tracking_cc::Gps_L1_Ca_Tcp_Connector_Tracking_cc(
// CN0 estimation and lock detector buffers
d_cn0_estimation_counter = 0;
d_Prompt_buffer = std::vector<gr_complex>(FLAGS_cn0_samples);
d_Prompt_buffer.reserve(FLAGS_cn0_samples);
d_carrier_lock_test = 1;
d_CN0_SNV_dB_Hz = 0;
d_carrier_lock_fail_counter = 0;
@ -224,13 +221,10 @@ void Gps_L1_Ca_Tcp_Connector_Tracking_cc::start_tracking()
d_carrier_doppler_hz = d_acq_carrier_doppler_hz;
// generate local reference ALWAYS starting at chip 1 (1 sample per chip)
gps_l1_ca_code_gen_complex(gsl::span<gr_complex>(d_ca_code, (GPS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex)), d_acquisition_gnss_synchro->PRN, 0);
gps_l1_ca_code_gen_complex(d_ca_code, d_acquisition_gnss_synchro->PRN, 0);
multicorrelator_cpu.set_local_code_and_taps(static_cast<int32_t>(GPS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips);
for (int32_t n = 0; n < d_n_correlator_taps; n++)
{
d_correlator_outs[n] = gr_complex(0, 0);
}
multicorrelator_cpu.set_local_code_and_taps(static_cast<int32_t>(GPS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code.data(), d_local_code_shift_chips.data());
std::fill_n(d_correlator_outs.begin(), d_n_correlator_taps, gr_complex(0.0, 0.0));
d_carrier_lock_fail_counter = 0;
d_rem_code_phase_samples = 0;
@ -268,20 +262,17 @@ Gps_L1_Ca_Tcp_Connector_Tracking_cc::~Gps_L1_Ca_Tcp_Connector_Tracking_cc()
}
catch (const std::exception &ex)
{
LOG(WARNING) << "Exception in destructor " << ex.what();
LOG(WARNING) << "Exception in Tracking block destructor: " << ex.what();
}
}
try
{
volk_gnsssdr_free(d_local_code_shift_chips);
volk_gnsssdr_free(d_correlator_outs);
volk_gnsssdr_free(d_ca_code);
d_tcp_com.close_tcp_connection(d_port);
multicorrelator_cpu.free();
}
catch (const std::exception &ex)
{
LOG(WARNING) << "Exception in destructor " << ex.what();
LOG(WARNING) << "Exception in Tracking block destructor: " << ex.what();
}
}
@ -375,7 +366,7 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attrib
// ################# CARRIER WIPEOFF AND CORRELATORS ##############################
// perform carrier wipe-off and compute Early, Prompt and Late correlation
multicorrelator_cpu.set_input_output_vectors(d_correlator_outs, in);
multicorrelator_cpu.set_input_output_vectors(d_correlator_outs.data(), in);
double carr_phase_step_rad = GPS_TWO_PI * d_carrier_doppler_hz / static_cast<double>(d_fs_in);
double rem_code_phase_chips = d_rem_code_phase_samples * (d_code_freq_hz / d_fs_in);
@ -491,9 +482,9 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attrib
}
else
{
*d_Early = gr_complex(0, 0);
*d_Prompt = gr_complex(0, 0);
*d_Late = gr_complex(0, 0);
*d_Early = gr_complex(0.0, 0.0);
*d_Prompt = gr_complex(0.0, 0.0);
*d_Late = gr_complex(0.0, 0.0);
// GNSS_SYNCHRO OBJECT to interchange data between tracking->telemetry_decoder
current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast<uint64_t>(d_correlation_length_samples);
// When tracking is disabled an array of 1's is sent to maintain the TCP connection

View File

@ -41,10 +41,10 @@
#include "gnss_synchro.h"
#include "tcp_communication.h"
#include <gnuradio/block.h>
#include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
#include <fstream>
#include <map>
#include <string>
#include <vector>
class Gps_L1_Ca_Tcp_Connector_Tracking_cc;
@ -112,7 +112,7 @@ private:
double d_code_phase_step_chips;
gr_complex *d_ca_code;
volk_gnsssdr::vector<gr_complex> d_ca_code;
gr_complex *d_Early;
gr_complex *d_Prompt;
@ -127,8 +127,8 @@ private:
float d_acq_code_phase_samples;
float d_acq_carrier_doppler_hz;
// correlator
float *d_local_code_shift_chips;
gr_complex *d_correlator_outs;
volk_gnsssdr::vector<float> d_local_code_shift_chips;
volk_gnsssdr::vector<gr_complex> d_correlator_outs;
Cpu_Multicorrelator multicorrelator_cpu;
// tracking vars
@ -153,7 +153,7 @@ private:
// CN0 estimation and lock detector
int32_t d_cn0_estimation_counter;
std::vector<gr_complex> d_Prompt_buffer;
volk_gnsssdr::vector<gr_complex> d_Prompt_buffer;
float d_carrier_lock_test;
float d_CN0_SNV_dB_Hz;
float d_carrier_lock_threshold;

View File

@ -61,9 +61,14 @@ const float PHASE_CARR_MAX_DIV_PI = 683565275.5764316; // 2^(31)/pi
const float TWO_PI = 6.283185307179586;
Fpga_Multicorrelator_8sc::Fpga_Multicorrelator_8sc(int32_t n_correlators,
const std::string &device_name, uint32_t dev_file_num, uint32_t num_prev_assigned_ch, int32_t *ca_codes, int32_t *data_codes, uint32_t code_length_chips, bool track_pilot,
const std::string &device_name,
uint32_t dev_file_num,
uint32_t num_prev_assigned_ch,
int32_t *ca_codes,
int32_t *data_codes,
uint32_t code_length_chips,
bool track_pilot,
uint32_t code_samples_per_chip)
{
d_n_correlators = n_correlators;
d_device_name = device_name;
@ -77,17 +82,13 @@ Fpga_Multicorrelator_8sc::Fpga_Multicorrelator_8sc(int32_t n_correlators,
// instantiate variable length vectors
if (d_track_pilot)
{
d_initial_index = static_cast<uint32_t *>(volk_gnsssdr_malloc(
(n_correlators + 1) * sizeof(uint32_t), volk_gnsssdr_get_alignment()));
d_initial_interp_counter = static_cast<uint32_t *>(volk_gnsssdr_malloc(
(n_correlators + 1) * sizeof(uint32_t), volk_gnsssdr_get_alignment()));
d_initial_index.reserve(n_correlators + 1);
d_initial_interp_counter.reserve(n_correlators + 1);
}
else
{
d_initial_index = static_cast<uint32_t *>(volk_gnsssdr_malloc(
n_correlators * sizeof(uint32_t), volk_gnsssdr_get_alignment()));
d_initial_interp_counter = static_cast<uint32_t *>(volk_gnsssdr_malloc(
n_correlators * sizeof(uint32_t), volk_gnsssdr_get_alignment()));
d_initial_index.reserve(n_correlators);
d_initial_interp_counter.reserve(n_correlators);
}
d_shifts_chips = nullptr;
d_prompt_data_shift = nullptr;
@ -109,8 +110,6 @@ Fpga_Multicorrelator_8sc::Fpga_Multicorrelator_8sc(int32_t n_correlators,
d_data_codes = data_codes;
d_code_samples_per_chip = code_samples_per_chip;
d_code_length_samples = d_code_length_chips * d_code_samples_per_chip;
d_secondary_code_enabled = false;
DLOG(INFO) << "TRACKING FPGA CLASS CREATED";
@ -120,14 +119,6 @@ Fpga_Multicorrelator_8sc::Fpga_Multicorrelator_8sc(int32_t n_correlators,
Fpga_Multicorrelator_8sc::~Fpga_Multicorrelator_8sc()
{
close_device();
if (d_initial_index != nullptr)
{
volk_gnsssdr_free(d_initial_index);
}
if (d_initial_interp_counter != nullptr)
{
volk_gnsssdr_free(d_initial_interp_counter);
}
}
@ -219,20 +210,6 @@ bool Fpga_Multicorrelator_8sc::free()
{
// unlock the channel
Fpga_Multicorrelator_8sc::unlock_channel();
// free the FPGA dynamically created variables
if (d_initial_index != nullptr)
{
volk_gnsssdr_free(d_initial_index);
d_initial_index = nullptr;
}
if (d_initial_interp_counter != nullptr)
{
volk_gnsssdr_free(d_initial_interp_counter);
d_initial_interp_counter = nullptr;
}
return true;
}
@ -289,8 +266,7 @@ void Fpga_Multicorrelator_8sc::set_channel(uint32_t channel)
}
uint32_t Fpga_Multicorrelator_8sc::fpga_acquisition_test_register(
uint32_t writeval)
uint32_t Fpga_Multicorrelator_8sc::fpga_acquisition_test_register(uint32_t writeval)
{
uint32_t readval = 0;
// write value to test register
@ -305,7 +281,6 @@ uint32_t Fpga_Multicorrelator_8sc::fpga_acquisition_test_register(
void Fpga_Multicorrelator_8sc::fpga_configure_tracking_gps_local_code(int32_t PRN)
{
uint32_t k;
d_map_base[prog_mems_addr] = local_code_fpga_clear_address_counter;
for (k = 0; k < d_code_length_samples; k++)
{
@ -320,7 +295,7 @@ void Fpga_Multicorrelator_8sc::fpga_configure_tracking_gps_local_code(int32_t PR
}
}
d_map_base[code_length_minus_1_reg_addr] = (d_code_length_samples)-1; // number of samples - 1
d_map_base[code_length_minus_1_reg_addr] = d_code_length_samples - 1; // number of samples - 1
}
@ -339,7 +314,6 @@ void Fpga_Multicorrelator_8sc::fpga_compute_code_shift_parameters()
}
d_initial_index[i] = dec_part;
frac_part = fmod(d_shifts_chips[i] - d_rem_code_phase_chips, 1.0);
if (frac_part < 0)
{
@ -387,8 +361,8 @@ void Fpga_Multicorrelator_8sc::fpga_compute_signal_parameters_in_fpga()
{
float d_rem_carrier_phase_in_rad_temp;
d_code_phase_step_chips_num = static_cast<uint32_t>(roundf(max_code_resampler_counter * d_code_phase_step_chips));
d_code_phase_rate_step_chips_num = static_cast<uint32_t>(roundf(max_code_resampler_counter * d_code_phase_rate_step_chips));
d_code_phase_step_chips_num = static_cast<uint32_t>(std::roundf(max_code_resampler_counter * d_code_phase_step_chips));
d_code_phase_rate_step_chips_num = static_cast<uint32_t>(std::roundf(max_code_resampler_counter * d_code_phase_rate_step_chips));
if (d_rem_carrier_phase_in_rad > M_PI)
{
@ -403,9 +377,9 @@ void Fpga_Multicorrelator_8sc::fpga_compute_signal_parameters_in_fpga()
d_rem_carrier_phase_in_rad_temp = d_rem_carrier_phase_in_rad;
}
d_rem_carr_phase_rad_int = static_cast<int32_t>(roundf((d_rem_carrier_phase_in_rad_temp)*PHASE_CARR_MAX_DIV_PI));
d_phase_step_rad_int = static_cast<int32_t>(roundf((d_phase_step_rad)*PHASE_CARR_MAX_DIV_PI)); // the FPGA accepts a range for the phase step between -pi and +pi
d_carrier_phase_rate_step_rad_int = static_cast<int32_t>(roundf((d_carrier_phase_rate_step_rad)*PHASE_CARR_MAX_DIV_PI));
d_rem_carr_phase_rad_int = static_cast<int32_t>(std::roundf(d_rem_carrier_phase_in_rad_temp * PHASE_CARR_MAX_DIV_PI));
d_phase_step_rad_int = static_cast<int32_t>(std::roundf(d_phase_step_rad * PHASE_CARR_MAX_DIV_PI)); // the FPGA accepts a range for the phase step between -pi and +pi
d_carrier_phase_rate_step_rad_int = static_cast<int32_t>(std::roundf(d_carrier_phase_rate_step_rad * PHASE_CARR_MAX_DIV_PI));
}
@ -464,7 +438,6 @@ void Fpga_Multicorrelator_8sc::unlock_channel()
// unlock the channel to let the next samples go through
d_map_base[drop_samples_reg_addr] = drop_samples; // unlock the channel and disable secondary codes
d_map_base[stop_tracking_reg_addr] = 1; // set the tracking module back to idle
d_secondary_code_enabled = false;
}
@ -498,12 +471,14 @@ void Fpga_Multicorrelator_8sc::set_secondary_code_lengths(uint32_t secondary_cod
d_map_base[secondary_code_lengths_reg_addr] = secondary_code_length_1_minus_1 * 256 + secondary_code_length_0_minus_1;
}
void Fpga_Multicorrelator_8sc::update_prn_code_length(uint32_t first_prn_length, uint32_t next_prn_length)
{
d_map_base[first_prn_length_minus_1_reg_addr] = first_prn_length - 1;
d_map_base[next_prn_length_minus_1_reg_addr] = next_prn_length - 1;
}
void Fpga_Multicorrelator_8sc::initialize_secondary_code(uint32_t secondary_code, std::string *secondary_code_string)
{
uint32_t secondary_code_length;
@ -543,7 +518,7 @@ void Fpga_Multicorrelator_8sc::write_secondary_code(uint32_t secondary_code_leng
pow_k = 1;
for (unsigned int k = 0; k < secondary_code_word_size; k++)
{
std::string string_tmp(1, secondary_code_string->at(mem_addr * secondary_code_word_size + k));
std::string string_tmp(1, (*secondary_code_string)[mem_addr * secondary_code_word_size + k]);
write_val = write_val | std::stoi(string_tmp) * pow_k;
pow_k = pow_k * 2;
}
@ -557,7 +532,7 @@ void Fpga_Multicorrelator_8sc::write_secondary_code(uint32_t secondary_code_leng
for (unsigned int k = 0; k < last_word_size; k++)
{
std::string string_tmp(1, secondary_code_string->at(mem_addr * secondary_code_word_size + k));
std::string string_tmp(1, (*secondary_code_string)[mem_addr * secondary_code_word_size + k]);
write_val = write_val | std::stoi(string_tmp) * pow_k;
pow_k = pow_k * 2;
}
@ -566,12 +541,14 @@ void Fpga_Multicorrelator_8sc::write_secondary_code(uint32_t secondary_code_leng
d_map_base[reg_addr] = write_val;
}
void Fpga_Multicorrelator_8sc::enable_secondary_codes()
{
d_map_base[drop_samples_reg_addr] = init_secondary_code_addresses | enable_secondary_code; // enable secondary codes and clear secondary code indices
d_secondary_code_enabled = true;
}
void Fpga_Multicorrelator_8sc::disable_secondary_codes()
{
// this function is to be called before starting the tracking process in order to disable the secondary codes by default

View File

@ -38,6 +38,7 @@
#define GNSS_SDR_FPGA_MULTICORRELATOR_H_
#include <gnuradio/block.h>
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <cstdint>
#include <string>
@ -86,9 +87,11 @@ public:
* \brief Perform a multicorrelation
*/
void Carrier_wipeoff_multicorrelator_resampler(
float rem_carrier_phase_in_rad, float phase_step_rad,
float rem_carrier_phase_in_rad,
float phase_step_rad,
float carrier_phase_rate_step_rad,
float rem_code_phase_chips, float code_phase_step_chips,
float rem_code_phase_chips,
float code_phase_step_chips,
float code_phase_rate_step_chips,
int32_t signal_length_samples);
@ -226,8 +229,8 @@ private:
bool d_track_pilot;
// configuration data computed in the format that the FPGA expects
uint32_t *d_initial_index;
uint32_t *d_initial_interp_counter;
volk_gnsssdr::vector<uint32_t> d_initial_index;
volk_gnsssdr::vector<uint32_t> d_initial_interp_counter;
uint32_t d_code_phase_step_chips_num;
uint32_t d_code_phase_rate_step_chips_num;
int32_t d_rem_carr_phase_rad_int;

View File

@ -101,6 +101,9 @@ private:
std::shared_ptr<InMemoryConfiguration> config;
std::shared_ptr<FileConfiguration> config_f;
std::string generated_kml_file;
std::chrono::time_point<std::chrono::system_clock> start;
std::chrono::time_point<std::chrono::system_clock> end;
};
@ -353,6 +356,7 @@ int PositionSystemTest::run_receiver()
control_thread = std::make_shared<ControlThread>(config_f);
}
start = std::chrono::system_clock::now();
// start receiver
try
{
@ -366,7 +370,7 @@ int PositionSystemTest::run_receiver()
{
std::cout << "STD exception: " << ex.what();
}
end = std::chrono::system_clock::now();
// Get the name of the KML file generated by the receiver
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
FILE* fp;
@ -561,6 +565,8 @@ void PositionSystemTest::check_results()
double static_2D_error_m = sqrt(pow(arma::mean(error_east_m), 2.0) + pow(arma::mean(error_north_m), 2.0));
double static_3D_error_m = sqrt(pow(arma::mean(error_east_m), 2.0) + pow(arma::mean(error_north_m), 2.0) + pow(arma::mean(error_up_m), 2.0));
std::chrono::duration<double> elapsed_seconds = end - start;
std::stringstream stm;
std::ofstream position_test_file;
if (!FLAGS_config_file_ptest.empty())
@ -588,6 +594,9 @@ void PositionSystemTest::check_results()
stm << "90% SAS = " << 0.833 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl;
stm << "MRSE = " << sqrt(sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl;
stm << "SEP = " << 0.51 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl;
stm << std::endl;
stm << "Receiver runtime: " << elapsed_seconds.count() << " [seconds]" << std::endl;
std::cout << stm.rdbuf();
std::string output_filename = "position_test_output_" + PositionSystemTest::generated_kml_file.erase(PositionSystemTest::generated_kml_file.length() - 3, 3) + "txt";

View File

@ -32,6 +32,7 @@
#include <armadillo>
#include <volk/volk.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <algorithm>
#include <chrono>
#include <complex>
@ -132,3 +133,22 @@ TEST(ConjugateTest, VolkComplexImplementation)
volk_gnsssdr_free(input);
volk_gnsssdr_free(output);
}
TEST(ConjugateTest, VolkComplexImplementationAlloc)
{
volk_gnsssdr::vector<std::complex<float>> input(FLAGS_size_conjugate_test, std::complex<float>(0.0, 0.0));
volk_gnsssdr::vector<std::complex<float>> output(FLAGS_size_conjugate_test);
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
volk_32fc_conjugate_32fc(output.data(), input.data(), FLAGS_size_conjugate_test);
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "Conjugate of a " << FLAGS_size_conjugate_test
<< "-length complex float vector using VOLK ALLOC finished in " << elapsed_seconds.count() * 1e6
<< " microseconds" << std::endl;
ASSERT_LE(0, elapsed_seconds.count() * 1e6);
}

View File

@ -33,6 +33,7 @@
#include <armadillo>
#include <volk/volk.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <algorithm>
#include <chrono>
#include <complex>
@ -45,6 +46,10 @@ TEST(MagnitudeSquaredTest, StandardCComplexImplementation)
auto* input = new std::complex<float>[FLAGS_size_magnitude_test];
auto* output = new float[FLAGS_size_magnitude_test];
unsigned int number = 0;
for (number = 0; number < static_cast<unsigned int>(FLAGS_size_magnitude_test); number++)
{
input[number] = std::complex<float>(0.0, 0.0);
}
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
@ -56,7 +61,7 @@ TEST(MagnitudeSquaredTest, StandardCComplexImplementation)
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "The squared magnitude of a " << FLAGS_size_magnitude_test
<< "-length vector in standard C computed in " << elapsed_seconds.count() * 1e6
<< "-length complex vector in standard C computed in " << elapsed_seconds.count() * 1e6
<< " microseconds" << std::endl;
delete[] input;
delete[] output;
@ -132,4 +137,24 @@ TEST(MagnitudeSquaredTest, VolkComplexImplementation)
ASSERT_LE(0, elapsed_seconds.count() * 1e6);
}
TEST(MagnitudeSquaredTest, VolkComplexImplementationAlloc)
{
volk_gnsssdr::vector<std::complex<float>> input(FLAGS_size_magnitude_test); // or: input(FLAGS_size_magnitude_test, std::complex<float>(0.0, 0.0));
std::fill_n(input.begin(), FLAGS_size_magnitude_test, std::complex<float>(0.0, 0.0));
volk_gnsssdr::vector<float> output(FLAGS_size_magnitude_test);
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
volk_32fc_magnitude_squared_32f(output.data(), input.data(), static_cast<unsigned int>(FLAGS_size_magnitude_test));
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "The squared magnitude of a " << FLAGS_size_magnitude_test
<< "-length vector using VOLK ALLOC computed in " << elapsed_seconds.count() * 1e6
<< " microseconds" << std::endl;
ASSERT_LE(0, elapsed_seconds.count() * 1e6);
}
// volk_32f_accumulator_s32f(&d_input_power, d_magnitude, d_fft_size);

View File

@ -60,8 +60,8 @@ TEST(MultiplyTest, StandardCDoubleImplementation)
<< " doubles in standard C finished in " << elapsed_seconds.count() * 1e6
<< " microseconds" << std::endl;
double acc = 0;
double expected = 0;
double acc = 0.0;
double expected = 0.0;
for (int i = 0; i < FLAGS_size_multiply_test; i++)
{
acc += output[i];
@ -112,8 +112,8 @@ TEST(MultiplyTest, StandardCComplexImplementation)
<< " complex<float> in standard C finished in " << elapsed_seconds.count() * 1e6
<< " microseconds" << std::endl;
std::complex<float> expected(0, 0);
std::complex<float> result(0, 0);
std::complex<float> expected(0.0, 0.0);
std::complex<float> result(0.0, 0.0);
for (int i = 0; i < FLAGS_size_multiply_test; i++)
{
result += output[i];
@ -146,7 +146,7 @@ TEST(MultiplyTest, C11ComplexImplementation)
<< " microseconds" << std::endl;
ASSERT_LE(0, elapsed_seconds.count() * 1e6);
std::complex<float> expected(0, 0);
std::complex<float> expected(0.0, 0.0);
auto result = std::inner_product(output.begin(), output.end(), output.begin(), expected);
ASSERT_EQ(expected, result);
}
@ -193,14 +193,43 @@ TEST(MultiplyTest, VolkComplexImplementation)
auto* mag = static_cast<float*>(volk_gnsssdr_malloc(FLAGS_size_multiply_test * sizeof(float), volk_gnsssdr_get_alignment()));
volk_32fc_magnitude_32f(mag, output, FLAGS_size_multiply_test);
auto* result = new float(0);
auto* result = new float(0.0);
volk_32f_accumulator_s32f(result, mag, FLAGS_size_multiply_test);
// Comparing floating-point numbers is tricky.
// Due to round-off errors, it is very unlikely that two floating-points will match exactly.
// See http://code.google.com/p/googletest/wiki/AdvancedGuide#Floating-Point_Comparison
float expected = 0;
float expected = 0.0;
ASSERT_FLOAT_EQ(expected, result[0]);
volk_gnsssdr_free(input);
volk_gnsssdr_free(output);
volk_gnsssdr_free(mag);
}
TEST(MultiplyTest, VolkComplexImplementationAlloc)
{
volk_gnsssdr::vector<std::complex<float>> input(FLAGS_size_multiply_test, std::complex<float>(0.0, 0.0));
volk_gnsssdr::vector<std::complex<float>> output(FLAGS_size_multiply_test);
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
volk_32fc_x2_multiply_32fc(output.data(), input.data(), input.data(), FLAGS_size_multiply_test);
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "Element-wise multiplication of " << FLAGS_size_multiply_test
<< "-length complex float vector using VOLK ALLOC finished in " << elapsed_seconds.count() * 1e6
<< " microseconds" << std::endl;
ASSERT_LE(0, elapsed_seconds.count() * 1e6);
volk_gnsssdr::vector<float> mag(FLAGS_size_multiply_test);
volk_32fc_magnitude_32f(mag.data(), output.data(), FLAGS_size_multiply_test);
auto* result = new float(0.0);
volk_32f_accumulator_s32f(result, mag.data(), FLAGS_size_multiply_test);
// Comparing floating-point numbers is tricky.
// Due to round-off errors, it is very unlikely that two floating-points will match exactly.
// See http://code.google.com/p/googletest/wiki/AdvancedGuide#Floating-Point_Comparison
float expected = 0.0;
ASSERT_FLOAT_EQ(expected, result[0]);
}

View File

@ -35,7 +35,7 @@
#include <gflags/gflags.h>
#include <gnuradio/gr_complex.h>
#include <gtest/gtest.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <chrono>
#include <complex>
#include <random>
@ -173,3 +173,96 @@ TEST(CpuMulticorrelatorRealCodesTest, MeasureExecutionTime)
correlator_pool[n]->free();
}
}
TEST(CpuMulticorrelatorRealCodesTest, MeasureExecutionTimeAlloc)
{
std::chrono::time_point<std::chrono::system_clock> start;
std::chrono::time_point<std::chrono::system_clock> end;
std::chrono::duration<double> elapsed_seconds(0);
int max_threads = FLAGS_cpu_multicorrelator_real_codes_max_threads_test;
std::vector<std::thread> thread_pool;
std::vector<Cpu_Multicorrelator_Real_Codes*> correlator_pool(max_threads);
unsigned int correlation_sizes[3] = {2048, 4096, 8192};
double execution_times[3];
volk_gnsssdr::vector<float> d_ca_code(static_cast<int>(GPS_L1_CA_CODE_LENGTH_CHIPS));
int d_n_correlator_taps = 3;
int d_vector_length = correlation_sizes[2]; // max correlation size to allocate all the necessary memory
volk_gnsssdr::vector<gr_complex> in_cpu(2 * d_vector_length);
// correlator outputs (scalar)
d_n_correlator_taps = 3; // Early, Prompt, and Late
volk_gnsssdr::vector<gr_complex> d_correlator_outs(d_n_correlator_taps, gr_complex(0.0, 0.0));
volk_gnsssdr::vector<float> d_local_code_shift_chips(d_n_correlator_taps);
// Set TAPs delay values [chips]
float d_early_late_spc_chips = 0.5;
d_local_code_shift_chips[0] = -d_early_late_spc_chips;
d_local_code_shift_chips[1] = 0.0;
d_local_code_shift_chips[2] = d_early_late_spc_chips;
// --- Perform initializations ------------------------------
// local code resampler on GPU
// generate local reference (1 sample per chip)
gps_l1_ca_code_gen_float(d_ca_code, 1, 0);
// generate inut signal
std::random_device r;
std::default_random_engine e1(r());
std::uniform_real_distribution<float> uniform_dist(0, 1);
for (int n = 0; n < 2 * d_vector_length; n++)
{
in_cpu[n] = std::complex<float>(uniform_dist(e1), uniform_dist(e1));
}
for (int n = 0; n < max_threads; n++)
{
correlator_pool[n] = new Cpu_Multicorrelator_Real_Codes();
correlator_pool[n]->init(d_vector_length, d_n_correlator_taps);
correlator_pool[n]->set_input_output_vectors(d_correlator_outs.data(), in_cpu.data());
correlator_pool[n]->set_local_code_and_taps(static_cast<int>(GPS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code.data(), d_local_code_shift_chips.data());
}
float d_rem_carrier_phase_rad = 0.0;
float d_carrier_phase_step_rad = 0.1;
float d_code_phase_step_chips = 0.3;
float d_code_phase_rate_step_chips = 0.00001;
float d_rem_code_phase_chips = 0.4;
EXPECT_NO_THROW(
for (int correlation_sizes_idx = 0; correlation_sizes_idx < 3; correlation_sizes_idx++) {
for (int current_max_threads = 1; current_max_threads < (max_threads + 1); current_max_threads++)
{
std::cout << "Running " << current_max_threads << " concurrent correlators" << std::endl;
start = std::chrono::system_clock::now();
// create the concurrent correlator threads
for (int current_thread = 0; current_thread < current_max_threads; current_thread++)
{
thread_pool.emplace_back(std::thread(run_correlator_cpu_real_codes,
correlator_pool[current_thread],
d_rem_carrier_phase_rad,
d_carrier_phase_step_rad,
d_code_phase_step_chips,
d_code_phase_rate_step_chips,
d_rem_code_phase_chips,
correlation_sizes[correlation_sizes_idx]));
}
// wait the threads to finish they work and destroy the thread objects
for (auto& t : thread_pool)
{
t.join();
}
thread_pool.clear();
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
execution_times[correlation_sizes_idx] = elapsed_seconds.count() / static_cast<double>(FLAGS_cpu_multicorrelator_real_codes_iterations_test);
std::cout << "CPU Multicorrelator (real codes) execution time for length=" << correlation_sizes[correlation_sizes_idx]
<< " : " << execution_times[correlation_sizes_idx] << " [s]" << std::endl;
}
});
for (int n = 0; n < max_threads; n++)
{
correlator_pool[n]->free();
}
}

View File

@ -35,7 +35,7 @@
#include <gflags/gflags.h>
#include <gnuradio/gr_complex.h>
#include <gtest/gtest.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <volk_gnsssdr/volk_gnsssdr_alloc.h>
#include <chrono>
#include <complex>
#include <random>
@ -168,3 +168,96 @@ TEST(CpuMulticorrelatorTest, MeasureExecutionTime)
correlator_pool[n]->free();
}
}
TEST(CpuMulticorrelatorTest, MeasureExecutionTimeAlloc)
{
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds(0);
int max_threads = FLAGS_cpu_multicorrelator_max_threads_test;
std::vector<std::thread> thread_pool;
std::vector<Cpu_Multicorrelator*> correlator_pool(max_threads);
unsigned int correlation_sizes[3] = {2048, 4096, 8192};
double execution_times[3];
int d_n_correlator_taps = 3;
int d_vector_length = correlation_sizes[2]; // max correlation size to allocate all the necessary memory
// allocate host memory
// Get space for a vector with the C/A code replica sampled 1x/chip
volk_gnsssdr::vector<gr_complex> d_ca_code(static_cast<int>(GPS_L1_CA_CODE_LENGTH_CHIPS));
volk_gnsssdr::vector<gr_complex> in_cpu(2 * d_vector_length);
// correlator outputs (scalar)
d_n_correlator_taps = 3; // Early, Prompt, and Late
volk_gnsssdr::vector<gr_complex> d_correlator_outs(d_n_correlator_taps, gr_complex(0.0, 0.0));
volk_gnsssdr::vector<float> d_local_code_shift_chips(d_n_correlator_taps);
// Set TAPs delay values [chips]
float d_early_late_spc_chips = 0.5;
d_local_code_shift_chips[0] = -d_early_late_spc_chips;
d_local_code_shift_chips[1] = 0.0;
d_local_code_shift_chips[2] = d_early_late_spc_chips;
// -- Perform initializations ------------------------------
// local code resampler on GPU
// generate local reference (1 sample per chip)
gps_l1_ca_code_gen_complex(d_ca_code, 1, 0);
// generate inut signal
std::random_device r;
std::default_random_engine e1(r());
std::uniform_real_distribution<float> uniform_dist(0, 1);
for (int n = 0; n < 2 * d_vector_length; n++)
{
in_cpu[n] = std::complex<float>(uniform_dist(e1), uniform_dist(e1));
}
for (int n = 0; n < max_threads; n++)
{
correlator_pool[n] = new Cpu_Multicorrelator();
correlator_pool[n]->init(d_vector_length, d_n_correlator_taps);
correlator_pool[n]->set_input_output_vectors(d_correlator_outs.data(), in_cpu.data());
correlator_pool[n]->set_local_code_and_taps(static_cast<int>(GPS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code.data(), d_local_code_shift_chips.data());
}
float d_rem_carrier_phase_rad = 0.0;
float d_carrier_phase_step_rad = 0.1;
float d_code_phase_step_chips = 0.3;
float d_rem_code_phase_chips = 0.4;
EXPECT_NO_THROW(
for (int correlation_sizes_idx = 0; correlation_sizes_idx < 3; correlation_sizes_idx++) {
for (int current_max_threads = 1; current_max_threads < (max_threads + 1); current_max_threads++)
{
std::cout << "Running " << current_max_threads << " concurrent correlators" << std::endl;
start = std::chrono::system_clock::now();
// create the concurrent correlator threads
for (int current_thread = 0; current_thread < current_max_threads; current_thread++)
{
thread_pool.push_back(std::thread(run_correlator_cpu,
correlator_pool[current_thread],
d_rem_carrier_phase_rad,
d_carrier_phase_step_rad,
d_code_phase_step_chips,
d_rem_code_phase_chips,
correlation_sizes[correlation_sizes_idx]));
}
// wait the threads to finish they work and destroy the thread objects
for (auto& t : thread_pool)
{
t.join();
}
thread_pool.clear();
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
execution_times[correlation_sizes_idx] = elapsed_seconds.count() / static_cast<double>(FLAGS_cpu_multicorrelator_iterations_test);
std::cout << "CPU Multicorrelator execution time for length=" << correlation_sizes[correlation_sizes_idx]
<< " : " << execution_times[correlation_sizes_idx] << " [s]" << std::endl;
}
});
for (int n = 0; n < max_threads; n++)
{
correlator_pool[n]->free();
}
}

View File

@ -39,7 +39,6 @@
#include "gnss_synchro.h"
#include "in_memory_configuration.h"
#include "tracking_interface.h"
#include <gnuradio/analog/sig_source_waveform.h>
#include <gnuradio/blocks/file_source.h>
#include <gnuradio/blocks/null_sink.h>
#include <gnuradio/blocks/skiphead.h>
@ -47,11 +46,6 @@
#include <gtest/gtest.h>
#include <chrono>
#include <utility>
#ifdef GR_GREATER_38
#include <gnuradio/analog/sig_source.h>
#else
#include <gnuradio/analog/sig_source_c.h>
#endif
// ######## GNURADIO BLOCK MESSAGE RECEVER #########
class GlonassL1CaDllPllCAidTrackingTest_msg_rx;
@ -179,7 +173,6 @@ TEST_F(GlonassL1CaDllPllCAidTrackingTest, ValidationOfResults)
}) << "Failure connecting tracking to the top_block.";
ASSERT_NO_THROW({
gr::analog::sig_source_c::sptr sin_source = gr::analog::sig_source_c::make(fs_in, gr::analog::GR_SIN_WAVE, 1000, 1, gr_complex(0));
std::string path = std::string(TEST_PATH);
std::string file = path + "signal_samples/NT1065_GLONASS_L1_20160831_fs6625e6_if0e3_4ms.bin";
const char* file_name = file.c_str();