mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-14 20:20:35 +00:00
Merge branch 'new_acq_grid' of https://github.com/antonioramosdet/gnss-sdr into antonioramosdet-new_acq_grid
This commit is contained in:
commit
e23dd178d6
@ -1112,7 +1112,7 @@ if(NOT MATIO_FOUND)
|
|||||||
if(CMAKE_VERSION VERSION_LESS 3.2)
|
if(CMAKE_VERSION VERSION_LESS 3.2)
|
||||||
ExternalProject_Add(
|
ExternalProject_Add(
|
||||||
matio-${GNSSSDR_MATIO_LOCAL_VERSION}
|
matio-${GNSSSDR_MATIO_LOCAL_VERSION}
|
||||||
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/mati
|
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/matio
|
||||||
GIT_REPOSITORY https://github.com/tbeu/matio
|
GIT_REPOSITORY https://github.com/tbeu/matio
|
||||||
GIT_TAG v${GNSSSDR_MATIO_LOCAL_VERSION}
|
GIT_TAG v${GNSSSDR_MATIO_LOCAL_VERSION}
|
||||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION}
|
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION}
|
||||||
|
@ -48,6 +48,7 @@ include_directories(
|
|||||||
${GFlags_INCLUDE_DIRS}
|
${GFlags_INCLUDE_DIRS}
|
||||||
${GNURADIO_RUNTIME_INCLUDE_DIRS}
|
${GNURADIO_RUNTIME_INCLUDE_DIRS}
|
||||||
${VOLK_GNSSSDR_INCLUDE_DIRS}
|
${VOLK_GNSSSDR_INCLUDE_DIRS}
|
||||||
|
${MATIO_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -69,7 +70,7 @@ source_group(Headers FILES ${ACQ_GR_BLOCKS_HEADERS})
|
|||||||
if(ENABLE_FPGA)
|
if(ENABLE_FPGA)
|
||||||
target_link_libraries(acq_gr_blocks acquisition_lib gnss_sp_libs gnss_system_parameters ${GNURADIO_RUNTIME_LIBRARIES} ${GNURADIO_FFT_LIBRARIES} ${VOLK_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES} ${OPT_LIBRARIES} ${OPT_ACQUISITION_LIBRARIES})
|
target_link_libraries(acq_gr_blocks acquisition_lib gnss_sp_libs gnss_system_parameters ${GNURADIO_RUNTIME_LIBRARIES} ${GNURADIO_FFT_LIBRARIES} ${VOLK_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES} ${OPT_LIBRARIES} ${OPT_ACQUISITION_LIBRARIES})
|
||||||
else(ENABLE_FPGA)
|
else(ENABLE_FPGA)
|
||||||
target_link_libraries(acq_gr_blocks gnss_sp_libs gnss_system_parameters ${GNURADIO_RUNTIME_LIBRARIES} ${GNURADIO_FFT_LIBRARIES} ${VOLK_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES} ${OPT_LIBRARIES} ${OPT_ACQUISITION_LIBRARIES})
|
target_link_libraries(acq_gr_blocks gnss_sp_libs gnss_system_parameters ${GNURADIO_RUNTIME_LIBRARIES} ${GNURADIO_FFT_LIBRARIES} ${VOLK_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES} ${OPT_LIBRARIES} ${OPT_ACQUISITION_LIBRARIES} ${MATIO_LIBRARIES})
|
||||||
endif(ENABLE_FPGA)
|
endif(ENABLE_FPGA)
|
||||||
if(NOT VOLK_GNSSSDR_FOUND)
|
if(NOT VOLK_GNSSSDR_FOUND)
|
||||||
add_dependencies(acq_gr_blocks volk_gnsssdr_module)
|
add_dependencies(acq_gr_blocks volk_gnsssdr_module)
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
#include "control_message_factory.h"
|
#include "control_message_factory.h"
|
||||||
#include "GPS_L1_CA.h" //GPS_TWO_PI
|
#include "GPS_L1_CA.h" //GPS_TWO_PI
|
||||||
#include "GLONASS_L1_CA.h" //GLONASS_TWO_PI
|
#include "GLONASS_L1_CA.h" //GLONASS_TWO_PI
|
||||||
|
#include <matio.h>
|
||||||
|
|
||||||
|
|
||||||
using google::LogMessage;
|
using google::LogMessage;
|
||||||
@ -98,9 +99,6 @@ pcps_acquisition_cc::pcps_acquisition_cc(
|
|||||||
d_code_phase = 0;
|
d_code_phase = 0;
|
||||||
d_test_statistics = 0.0;
|
d_test_statistics = 0.0;
|
||||||
d_channel = 0;
|
d_channel = 0;
|
||||||
d_doppler_freq = 0.0;
|
|
||||||
|
|
||||||
//set_relative_rate( 1.0/d_fft_size );
|
|
||||||
|
|
||||||
// COD:
|
// COD:
|
||||||
// Experimenting with the overlap/save technique for handling bit trannsitions
|
// Experimenting with the overlap/save technique for handling bit trannsitions
|
||||||
@ -135,6 +133,7 @@ pcps_acquisition_cc::pcps_acquisition_cc(
|
|||||||
d_blocking = blocking;
|
d_blocking = blocking;
|
||||||
d_worker_active = false;
|
d_worker_active = false;
|
||||||
d_data_buffer = static_cast<gr_complex*>(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
|
d_data_buffer = static_cast<gr_complex*>(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
|
||||||
|
grid_ = arma::fmat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -148,17 +147,10 @@ pcps_acquisition_cc::~pcps_acquisition_cc()
|
|||||||
}
|
}
|
||||||
delete[] d_grid_doppler_wipeoffs;
|
delete[] d_grid_doppler_wipeoffs;
|
||||||
}
|
}
|
||||||
|
|
||||||
volk_gnsssdr_free(d_fft_codes);
|
volk_gnsssdr_free(d_fft_codes);
|
||||||
volk_gnsssdr_free(d_magnitude);
|
volk_gnsssdr_free(d_magnitude);
|
||||||
|
|
||||||
delete d_ifft;
|
delete d_ifft;
|
||||||
delete d_fft_if;
|
delete d_fft_if;
|
||||||
|
|
||||||
if (d_dump)
|
|
||||||
{
|
|
||||||
d_dump_file.close();
|
|
||||||
}
|
|
||||||
volk_gnsssdr_free(d_data_buffer);
|
volk_gnsssdr_free(d_data_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,6 +235,12 @@ void pcps_acquisition_cc::init()
|
|||||||
update_local_carrier(d_grid_doppler_wipeoffs[doppler_index], d_fft_size, d_freq + doppler);
|
update_local_carrier(d_grid_doppler_wipeoffs[doppler_index], d_fft_size, d_freq + doppler);
|
||||||
}
|
}
|
||||||
d_worker_active = false;
|
d_worker_active = false;
|
||||||
|
|
||||||
|
if(d_dump)
|
||||||
|
{
|
||||||
|
unsigned int effective_fft_size = (d_bit_transition_flag ? (d_fft_size / 2) : d_fft_size);
|
||||||
|
grid_ = arma::fmat(effective_fft_size, d_num_doppler_bins, arma::fill::zeros);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -481,24 +479,44 @@ void pcps_acquisition_cc::acquisition_core( unsigned long int samp_count )
|
|||||||
// Record results to file if required
|
// Record results to file if required
|
||||||
if (d_dump)
|
if (d_dump)
|
||||||
{
|
{
|
||||||
std::stringstream filename;
|
memcpy(grid_.colptr(doppler_index), d_magnitude, sizeof(float) * effective_fft_size);
|
||||||
std::streamsize n = 2 * sizeof(float) * (d_fft_size); // complex file write
|
if(doppler_index == (d_num_doppler_bins - 1))
|
||||||
filename.str("");
|
{
|
||||||
boost::filesystem::path p = d_dump_filename;
|
std::string filename = d_dump_filename;
|
||||||
filename << p.parent_path().string()
|
filename.append("_");
|
||||||
<< boost::filesystem::path::preferred_separator
|
filename.append(1, d_gnss_synchro->System);
|
||||||
<< p.stem().string()
|
filename.append("_");
|
||||||
<< "_" << d_gnss_synchro->System
|
filename.append(1, d_gnss_synchro->Signal[0]);
|
||||||
<<"_" << d_gnss_synchro->Signal << "_sat_"
|
filename.append(1, d_gnss_synchro->Signal[1]);
|
||||||
<< d_gnss_synchro->PRN << "_doppler_"
|
filename.append("_sat_");
|
||||||
<< doppler
|
filename.append(std::to_string(d_gnss_synchro->PRN));
|
||||||
<< p.extension().string();
|
filename.append(".mat");
|
||||||
|
mat_t* matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73);
|
||||||
|
if(matfp == NULL)
|
||||||
|
{
|
||||||
|
std::cout << "Unable to create or open Acquisition dump file" << std::endl;
|
||||||
|
d_dump = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
size_t dims[2] = {static_cast<size_t>(effective_fft_size), static_cast<size_t>(d_num_doppler_bins)};
|
||||||
|
matvar_t* matvar = Mat_VarCreate("grid", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, grid_.memptr(), 0);
|
||||||
|
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||||
|
Mat_VarFree(matvar);
|
||||||
|
|
||||||
DLOG(INFO) << "Writing ACQ out to " << filename.str();
|
dims[0] = static_cast<size_t>(1);
|
||||||
|
dims[1] = static_cast<size_t>(1);
|
||||||
|
matvar = Mat_VarCreate("doppler_max", MAT_C_SINGLE, MAT_T_UINT32, 1, dims, &d_doppler_max, 0);
|
||||||
|
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||||
|
Mat_VarFree(matvar);
|
||||||
|
|
||||||
d_dump_file.open(filename.str().c_str(), std::ios::out | std::ios::binary);
|
matvar = Mat_VarCreate("doppler_step", MAT_C_SINGLE, MAT_T_UINT32, 1, dims, &d_doppler_step, 0);
|
||||||
d_dump_file.write(reinterpret_cast<char*>(d_ifft->get_outbuf()), n); //write directly |abs(x)|^2 in this Doppler bin?
|
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
|
||||||
d_dump_file.close();
|
Mat_VarFree(matvar);
|
||||||
|
|
||||||
|
Mat_Close(matfp);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lk.lock();
|
lk.lock();
|
||||||
|
@ -58,6 +58,8 @@
|
|||||||
#include <gnuradio/gr_complex.h>
|
#include <gnuradio/gr_complex.h>
|
||||||
#include <gnuradio/fft/fft.h>
|
#include <gnuradio/fft/fft.h>
|
||||||
#include "gnss_synchro.h"
|
#include "gnss_synchro.h"
|
||||||
|
#include <glog/logging.h>
|
||||||
|
#include <armadillo>
|
||||||
|
|
||||||
class pcps_acquisition_cc;
|
class pcps_acquisition_cc;
|
||||||
|
|
||||||
@ -80,6 +82,7 @@ pcps_make_acquisition_cc(unsigned int sampled_ms, unsigned int max_dwells,
|
|||||||
class pcps_acquisition_cc: public gr::block
|
class pcps_acquisition_cc: public gr::block
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend pcps_acquisition_cc_sptr
|
friend pcps_acquisition_cc_sptr
|
||||||
pcps_make_acquisition_cc(unsigned int sampled_ms, unsigned int max_dwells,
|
pcps_make_acquisition_cc(unsigned int sampled_ms, unsigned int max_dwells,
|
||||||
unsigned int doppler_max, long freq, long fs_in,
|
unsigned int doppler_max, long freq, long fs_in,
|
||||||
@ -102,49 +105,47 @@ private:
|
|||||||
void acquisition_core( unsigned long int samp_count );
|
void acquisition_core( unsigned long int samp_count );
|
||||||
|
|
||||||
void send_negative_acquisition();
|
void send_negative_acquisition();
|
||||||
|
|
||||||
void send_positive_acquisition();
|
void send_positive_acquisition();
|
||||||
|
|
||||||
|
bool d_bit_transition_flag;
|
||||||
|
bool d_use_CFAR_algorithm_flag;
|
||||||
|
bool d_active;
|
||||||
|
bool d_dump;
|
||||||
|
bool d_worker_active;
|
||||||
|
bool d_blocking;
|
||||||
|
float d_threshold;
|
||||||
|
float d_mag;
|
||||||
|
float d_input_power;
|
||||||
|
float d_test_statistics;
|
||||||
|
float* d_magnitude;
|
||||||
long d_fs_in;
|
long d_fs_in;
|
||||||
long d_freq;
|
long d_freq;
|
||||||
long d_old_freq;
|
long d_old_freq;
|
||||||
int d_samples_per_ms;
|
int d_samples_per_ms;
|
||||||
int d_samples_per_code;
|
int d_samples_per_code;
|
||||||
//unsigned int d_doppler_resolution;
|
int d_state;
|
||||||
float d_threshold;
|
unsigned int d_channel;
|
||||||
unsigned int d_doppler_max;
|
unsigned int d_doppler_max;
|
||||||
unsigned int d_doppler_step;
|
unsigned int d_doppler_step;
|
||||||
unsigned int d_sampled_ms;
|
unsigned int d_sampled_ms;
|
||||||
unsigned int d_max_dwells;
|
unsigned int d_max_dwells;
|
||||||
unsigned int d_well_count;
|
unsigned int d_well_count;
|
||||||
unsigned int d_fft_size;
|
unsigned int d_fft_size;
|
||||||
|
unsigned int d_num_doppler_bins;
|
||||||
|
unsigned int d_code_phase;
|
||||||
unsigned long int d_sample_counter;
|
unsigned long int d_sample_counter;
|
||||||
gr_complex** d_grid_doppler_wipeoffs;
|
gr_complex** d_grid_doppler_wipeoffs;
|
||||||
unsigned int d_num_doppler_bins;
|
|
||||||
gr_complex* d_fft_codes;
|
gr_complex* d_fft_codes;
|
||||||
|
gr_complex* d_data_buffer;
|
||||||
gr::fft::fft_complex* d_fft_if;
|
gr::fft::fft_complex* d_fft_if;
|
||||||
gr::fft::fft_complex* d_ifft;
|
gr::fft::fft_complex* d_ifft;
|
||||||
Gnss_Synchro* d_gnss_synchro;
|
Gnss_Synchro* d_gnss_synchro;
|
||||||
unsigned int d_code_phase;
|
|
||||||
float d_doppler_freq;
|
|
||||||
float d_mag;
|
|
||||||
float* d_magnitude;
|
|
||||||
float d_input_power;
|
|
||||||
float d_test_statistics;
|
|
||||||
bool d_bit_transition_flag;
|
|
||||||
bool d_use_CFAR_algorithm_flag;
|
|
||||||
std::ofstream d_dump_file;
|
|
||||||
bool d_active;
|
|
||||||
int d_state;
|
|
||||||
bool d_dump;
|
|
||||||
unsigned int d_channel;
|
|
||||||
std::string d_dump_filename;
|
std::string d_dump_filename;
|
||||||
bool d_worker_active;
|
arma::fmat grid_;
|
||||||
bool d_blocking;
|
|
||||||
gr_complex *d_data_buffer;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*!
|
|
||||||
* \brief Default destructor.
|
|
||||||
*/
|
|
||||||
~pcps_acquisition_cc();
|
~pcps_acquisition_cc();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -158,7 +158,7 @@ void GalileoE1PcpsAmbiguousAcquisitionTest::init()
|
|||||||
{
|
{
|
||||||
config->set_property("Acquisition_1B.dump", "false");
|
config->set_property("Acquisition_1B.dump", "false");
|
||||||
}
|
}
|
||||||
config->set_property("Acquisition_1B.dump_filename", "./tmp-acq-gal1/acquisition.dat");
|
config->set_property("Acquisition_1B.dump_filename", "./tmp-acq-gal1/acquisition");
|
||||||
config->set_property("Acquisition_1B.threshold", "0.0001");
|
config->set_property("Acquisition_1B.threshold", "0.0001");
|
||||||
config->set_property("Acquisition_1B.doppler_max", std::to_string(doppler_max));
|
config->set_property("Acquisition_1B.doppler_max", std::to_string(doppler_max));
|
||||||
config->set_property("Acquisition_1B.doppler_step", std::to_string(doppler_step));
|
config->set_property("Acquisition_1B.doppler_step", std::to_string(doppler_step));
|
||||||
|
@ -141,7 +141,7 @@ void GlonassL1CaPcpsAcquisitionTest::init()
|
|||||||
config->set_property("Acquisition_1G.if", "9540000");
|
config->set_property("Acquisition_1G.if", "9540000");
|
||||||
config->set_property("Acquisition_1G.coherent_integration_time_ms", "1");
|
config->set_property("Acquisition_1G.coherent_integration_time_ms", "1");
|
||||||
config->set_property("Acquisition_1G.dump", "true");
|
config->set_property("Acquisition_1G.dump", "true");
|
||||||
config->set_property("Acquisition_1G.dump_filename", "./acquisition.dat");
|
config->set_property("Acquisition_1G.dump_filename", "./acquisition");
|
||||||
config->set_property("Acquisition_1G.implementation", "Glonass_L1_CA_PCPS_Acquisition");
|
config->set_property("Acquisition_1G.implementation", "Glonass_L1_CA_PCPS_Acquisition");
|
||||||
config->set_property("Acquisition_1G.threshold", "0.001");
|
config->set_property("Acquisition_1G.threshold", "0.001");
|
||||||
config->set_property("Acquisition_1G.doppler_max", "5000");
|
config->set_property("Acquisition_1G.doppler_max", "5000");
|
||||||
|
@ -157,7 +157,7 @@ void GpsL1CaPcpsAcquisitionTest::init()
|
|||||||
{
|
{
|
||||||
config->set_property("Acquisition_1C.dump", "false");
|
config->set_property("Acquisition_1C.dump", "false");
|
||||||
}
|
}
|
||||||
config->set_property("Acquisition_1C.dump_filename", "./tmp-acq-gps1/acquisition.dat");
|
config->set_property("Acquisition_1C.dump_filename", "./tmp-acq-gps1/acquisition");
|
||||||
config->set_property("Acquisition_1C.threshold", "0.00001");
|
config->set_property("Acquisition_1C.threshold", "0.00001");
|
||||||
config->set_property("Acquisition_1C.doppler_max", std::to_string(doppler_max));
|
config->set_property("Acquisition_1C.doppler_max", std::to_string(doppler_max));
|
||||||
config->set_property("Acquisition_1C.doppler_step", std::to_string(doppler_step));
|
config->set_property("Acquisition_1C.doppler_step", std::to_string(doppler_step));
|
||||||
|
@ -164,7 +164,7 @@ void GpsL2MPcpsAcquisitionTest::init()
|
|||||||
{
|
{
|
||||||
config->set_property("Acquisition_2S.dump", "false");
|
config->set_property("Acquisition_2S.dump", "false");
|
||||||
}
|
}
|
||||||
config->set_property("Acquisition_2S.dump_filename", "./tmp-acq-gps2/acquisition.dat");
|
config->set_property("Acquisition_2S.dump_filename", "./tmp-acq-gps2/acquisition");
|
||||||
config->set_property("Acquisition_2S.threshold", "0.001");
|
config->set_property("Acquisition_2S.threshold", "0.001");
|
||||||
config->set_property("Acquisition_2S.doppler_max", std::to_string(doppler_max));
|
config->set_property("Acquisition_2S.doppler_max", std::to_string(doppler_max));
|
||||||
config->set_property("Acquisition_2S.doppler_step", std::to_string(doppler_step));
|
config->set_property("Acquisition_2S.doppler_step", std::to_string(doppler_step));
|
||||||
@ -178,9 +178,8 @@ void GpsL2MPcpsAcquisitionTest::plot_grid()
|
|||||||
std::string basename = "./tmp-acq-gps2/acquisition_G_2S";
|
std::string basename = "./tmp-acq-gps2/acquisition_G_2S";
|
||||||
unsigned int sat = static_cast<unsigned int>(gnss_synchro.PRN);
|
unsigned int sat = static_cast<unsigned int>(gnss_synchro.PRN);
|
||||||
|
|
||||||
unsigned int samples_per_code = static_cast<unsigned int>(floor(sampling_frequency_hz / (GPS_L2_M_CODE_RATE_HZ / GPS_L2_M_CODE_LENGTH_CHIPS)) - 1000); // !!
|
unsigned int samples_per_code = static_cast<unsigned int>(floor(static_cast<double>(sampling_frequency_hz) / (GPS_L2_M_CODE_RATE_HZ / static_cast<double>(GPS_L2_M_CODE_LENGTH_CHIPS))));
|
||||||
acquisition_dump_reader acq_dump(basename, sat, doppler_max, doppler_step, samples_per_code);
|
acquisition_dump_reader acq_dump(basename, sat, doppler_max, doppler_step, samples_per_code);
|
||||||
|
|
||||||
if(!acq_dump.read_binary_acq()) std::cout << "Error reading files" << std::endl;
|
if(!acq_dump.read_binary_acq()) std::cout << "Error reading files" << std::endl;
|
||||||
|
|
||||||
std::vector<int> *doppler = &acq_dump.doppler;
|
std::vector<int> *doppler = &acq_dump.doppler;
|
||||||
@ -204,7 +203,7 @@ void GpsL2MPcpsAcquisitionTest::plot_grid()
|
|||||||
std::string gnuplot_path = dir.native();
|
std::string gnuplot_path = dir.native();
|
||||||
Gnuplot::set_GNUPlotPath(gnuplot_path);
|
Gnuplot::set_GNUPlotPath(gnuplot_path);
|
||||||
|
|
||||||
Gnuplot g1("lines");
|
Gnuplot g1("impulses");
|
||||||
g1.set_title("GPS L2CM signal acquisition for satellite PRN #" + std::to_string(gnss_synchro.PRN));
|
g1.set_title("GPS L2CM signal acquisition for satellite PRN #" + std::to_string(gnss_synchro.PRN));
|
||||||
g1.set_xlabel("Doppler [Hz]");
|
g1.set_xlabel("Doppler [Hz]");
|
||||||
g1.set_ylabel("Sample");
|
g1.set_ylabel("Sample");
|
||||||
|
@ -30,6 +30,7 @@ include_directories(
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
${GLOG_INCLUDE_DIRS}
|
${GLOG_INCLUDE_DIRS}
|
||||||
${GFlags_INCLUDE_DIRS}
|
${GFlags_INCLUDE_DIRS}
|
||||||
|
${MATIO_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
/*!
|
/*!
|
||||||
* \file acquisition_dump_reader.cc
|
* \file acquisition_dump_reader.cc
|
||||||
* \brief Helper file for unit testing
|
* \brief Helper file for unit testing
|
||||||
* \author Carles Fernandez-Prades, 2017. cfernandez(at)cttc.es
|
* \authors Carles Fernandez-Prades, 2017. cfernandez(at)cttc.es
|
||||||
|
* Antonio Ramos, 2018. antonio.ramos(at)cttc.es
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* -------------------------------------------------------------------------
|
* -------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors)
|
* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors)
|
||||||
*
|
*
|
||||||
* GNSS-SDR is a software defined Global Navigation
|
* GNSS-SDR is a software defined Global Navigation
|
||||||
* Satellite Systems receiver
|
* Satellite Systems receiver
|
||||||
@ -28,44 +30,65 @@
|
|||||||
* -------------------------------------------------------------------------
|
* -------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <complex>
|
#include <iostream>
|
||||||
|
#include <cmath>
|
||||||
|
#include <matio.h>
|
||||||
#include "acquisition_dump_reader.h"
|
#include "acquisition_dump_reader.h"
|
||||||
|
|
||||||
bool acquisition_dump_reader::read_binary_acq()
|
bool acquisition_dump_reader::read_binary_acq()
|
||||||
{
|
{
|
||||||
std::complex<float>* aux = new std::complex<float>[1];
|
mat_t* matfile = Mat_Open(d_dump_filename.c_str(), MAT_ACC_RDONLY);
|
||||||
for(unsigned int i = 0; i < d_num_doppler_bins; i++)
|
if( matfile == NULL)
|
||||||
{
|
{
|
||||||
try
|
std::cout << "¡¡¡Unreachable Acquisition dump file!!!" << std::endl;
|
||||||
{
|
|
||||||
std::ifstream ifs;
|
|
||||||
ifs.exceptions( std::ifstream::failbit | std::ifstream::badbit );
|
|
||||||
ifs.open(d_dump_filenames.at(i).c_str(), std::ios::in | std::ios::binary);
|
|
||||||
d_dump_files.at(i).swap(ifs);
|
|
||||||
if (d_dump_files.at(i).is_open())
|
|
||||||
{
|
|
||||||
for(unsigned int k = 0; k < d_samples_per_code; k++)
|
|
||||||
{
|
|
||||||
d_dump_files.at(i).read(reinterpret_cast<char *>(&aux[0]), sizeof(std::complex<float>));
|
|
||||||
mag.at(i).at(k) = std::abs(*aux) / std::pow(d_samples_per_code, 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cout << "File " << d_dump_filenames.at(i).c_str() << " not found." << std::endl;
|
|
||||||
delete[] aux;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
d_dump_files.at(i).close();
|
matvar_t* var_= Mat_VarRead(matfile, "grid");
|
||||||
}
|
if( var_ == NULL)
|
||||||
catch (const std::ifstream::failure &e)
|
|
||||||
{
|
{
|
||||||
std::cout << e.what() << std::endl;
|
std::cout << "¡¡¡Unreachable grid variable into Acquisition dump file!!!" << std::endl;
|
||||||
delete[] aux;
|
Mat_Close(matfile);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if(var_->rank != 2)
|
||||||
|
{
|
||||||
|
std::cout << "Invalid Acquisition dump file: rank error" << std::endl;
|
||||||
|
Mat_VarFree(var_);
|
||||||
|
Mat_Close(matfile);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
delete[] aux;
|
if((var_->dims[0] != d_samples_per_code) or (var_->dims[1] != d_num_doppler_bins))
|
||||||
|
{
|
||||||
|
std::cout << "Invalid Acquisition dump file: dimension matrix error" << std::endl;
|
||||||
|
if(var_->dims[0] != d_samples_per_code) std::cout << "Expected " << d_samples_per_code << " samples per code. Obtained " << var_->dims[0] << std::endl;
|
||||||
|
if(var_->dims[1] != d_num_doppler_bins) std::cout << "Expected " << d_num_doppler_bins << " Doppler bins. Obtained " << var_->dims[1] << std::endl;
|
||||||
|
Mat_VarFree(var_);
|
||||||
|
Mat_Close(matfile);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(var_->data_type != MAT_T_SINGLE)
|
||||||
|
{
|
||||||
|
std::cout << "Invalid Acquisition dump file: data type error" << std::endl;
|
||||||
|
Mat_VarFree(var_);
|
||||||
|
Mat_Close(matfile);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
std::vector<std::vector<float> >::iterator it1;
|
||||||
|
std::vector<float>::iterator it2;
|
||||||
|
float* aux = static_cast<float*>(var_->data);
|
||||||
|
int k = 0;
|
||||||
|
float normalization_factor = std::pow(d_samples_per_code, 2);
|
||||||
|
for(it1 = mag.begin(); it1 != mag.end(); it1++)
|
||||||
|
{
|
||||||
|
for(it2 = it1->begin(); it2 != it1->end(); it2++)
|
||||||
|
{
|
||||||
|
*it2 = static_cast<float>(std::sqrt(aux[k])) / normalization_factor;
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Mat_VarFree(var_);
|
||||||
|
Mat_Close(matfile);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,12 +103,10 @@ acquisition_dump_reader::acquisition_dump_reader(const std::string & basename, u
|
|||||||
d_num_doppler_bins = static_cast<unsigned int>(ceil( static_cast<double>(static_cast<int>(d_doppler_max) - static_cast<int>(-d_doppler_max)) / static_cast<double>(d_doppler_step)));
|
d_num_doppler_bins = static_cast<unsigned int>(ceil( static_cast<double>(static_cast<int>(d_doppler_max) - static_cast<int>(-d_doppler_max)) / static_cast<double>(d_doppler_step)));
|
||||||
std::vector<std::vector<float> > mag_aux(d_num_doppler_bins, std::vector<float>(d_samples_per_code));
|
std::vector<std::vector<float> > mag_aux(d_num_doppler_bins, std::vector<float>(d_samples_per_code));
|
||||||
mag = mag_aux;
|
mag = mag_aux;
|
||||||
|
d_dump_filename = d_basename + "_sat_" + std::to_string(d_sat) + ".mat";
|
||||||
for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
|
for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
|
||||||
{
|
{
|
||||||
doppler.push_back(-static_cast<int>(d_doppler_max) + d_doppler_step * doppler_index);
|
doppler.push_back(-static_cast<int>(d_doppler_max) + d_doppler_step * doppler_index);
|
||||||
d_dump_filenames.push_back(d_basename + "_sat_" + std::to_string(d_sat) + "_doppler_" + std::to_string(doppler.at(doppler_index)) + ".dat");
|
|
||||||
std::ifstream ifs;
|
|
||||||
d_dump_files.push_back(std::move(ifs));
|
|
||||||
}
|
}
|
||||||
for (unsigned int k = 0; k < d_samples_per_code; k++)
|
for (unsigned int k = 0; k < d_samples_per_code; k++)
|
||||||
{
|
{
|
||||||
@ -95,12 +116,4 @@ acquisition_dump_reader::acquisition_dump_reader(const std::string & basename, u
|
|||||||
|
|
||||||
|
|
||||||
acquisition_dump_reader::~acquisition_dump_reader()
|
acquisition_dump_reader::~acquisition_dump_reader()
|
||||||
{
|
{}
|
||||||
for(unsigned int i = 0; i < d_num_doppler_bins; i++)
|
|
||||||
{
|
|
||||||
if (d_dump_files.at(i).is_open() == true)
|
|
||||||
{
|
|
||||||
d_dump_files.at(i).close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
/*!
|
/*!
|
||||||
* \file acquisition_dump_reader.h
|
* \file acquisition_dump_reader.h
|
||||||
* \brief Helper file for unit testing
|
* \brief Helper file for unit testing
|
||||||
* \author Carles Fernandez-Prades, 2017. cfernandez(at)cttc.es
|
* \authors Carles Fernandez-Prades, 2017. cfernandez(at)cttc.es
|
||||||
|
* Antonio Ramos, 2018. antonio.ramos(at)cttc.es
|
||||||
*
|
*
|
||||||
* -------------------------------------------------------------------------
|
* -------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors)
|
* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors)
|
||||||
*
|
*
|
||||||
* GNSS-SDR is a software defined Global Navigation
|
* GNSS-SDR is a software defined Global Navigation
|
||||||
* Satellite Systems receiver
|
* Satellite Systems receiver
|
||||||
@ -31,8 +32,6 @@
|
|||||||
#ifndef GNSS_SDR_ACQUISITION_DUMP_READER_H
|
#ifndef GNSS_SDR_ACQUISITION_DUMP_READER_H
|
||||||
#define GNSS_SDR_ACQUISITION_DUMP_READER_H
|
#define GNSS_SDR_ACQUISITION_DUMP_READER_H
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -54,8 +53,7 @@ private:
|
|||||||
unsigned int d_doppler_step;
|
unsigned int d_doppler_step;
|
||||||
unsigned int d_samples_per_code;
|
unsigned int d_samples_per_code;
|
||||||
unsigned int d_num_doppler_bins;
|
unsigned int d_num_doppler_bins;
|
||||||
std::vector<std::string> d_dump_filenames;
|
std::string d_dump_filename;
|
||||||
std::vector<std::ifstream> d_dump_files;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GNSS_SDR_ACQUISITION_DUMP_READER_H
|
#endif // GNSS_SDR_ACQUISITION_DUMP_READER_H
|
||||||
|
116
src/utils/matlab/plot_acq_grid.m
Normal file
116
src/utils/matlab/plot_acq_grid.m
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
% /*!
|
||||||
|
% * \file plot_acq_grid.m
|
||||||
|
% * \brief Read GNSS-SDR Acquisition dump .mat file using the provided
|
||||||
|
% function and plot acquisition grid of acquisition statistic of PRN sat
|
||||||
|
%
|
||||||
|
%
|
||||||
|
% * \author Antonio Ramos, 2017. antonio.ramos(at)cttc.es
|
||||||
|
% * -------------------------------------------------------------------------
|
||||||
|
% *
|
||||||
|
% * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors)
|
||||||
|
% *
|
||||||
|
% * GNSS-SDR is a software defined Global Navigation
|
||||||
|
% * Satellite Systems receiver
|
||||||
|
% *
|
||||||
|
% * 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 <http://www.gnu.org/licenses/>.
|
||||||
|
% *
|
||||||
|
% * -------------------------------------------------------------------------
|
||||||
|
% */
|
||||||
|
|
||||||
|
%%%%%%%%% ¡¡¡ CONFIGURE !!! %%%%%%%%%%%%%
|
||||||
|
|
||||||
|
path = '/archive/';
|
||||||
|
file = 'acq';
|
||||||
|
|
||||||
|
sat = 7;
|
||||||
|
|
||||||
|
% Signal:
|
||||||
|
% 1 GPS L1
|
||||||
|
% 2 GPS L2M
|
||||||
|
% 3 GPS L5
|
||||||
|
% 4 Gal. E1B
|
||||||
|
% 5 Gal. E5
|
||||||
|
% 6 Glo. 1G
|
||||||
|
|
||||||
|
signal_type = 1;
|
||||||
|
|
||||||
|
%%% True for light grid representation
|
||||||
|
lite_view = true;
|
||||||
|
|
||||||
|
%%% If lite_view, it sets the number of samples per chip in the graphical representation
|
||||||
|
n_samples_per_chip = 3;
|
||||||
|
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
|
switch(signal_type)
|
||||||
|
case 1
|
||||||
|
n_chips = 1023;
|
||||||
|
system = 'G';
|
||||||
|
signal = '1C';
|
||||||
|
case 2
|
||||||
|
n_chips = 10230;
|
||||||
|
system = 'G';
|
||||||
|
signal = '2S';
|
||||||
|
case 3
|
||||||
|
n_chips = 10230;
|
||||||
|
system = 'G';
|
||||||
|
signal = 'L5';
|
||||||
|
case 4
|
||||||
|
n_chips = 4092;
|
||||||
|
system = 'E';
|
||||||
|
signal = '1B';
|
||||||
|
case 5
|
||||||
|
n_chips = 10230;
|
||||||
|
system = 'E';
|
||||||
|
signal = '5X';
|
||||||
|
case 6
|
||||||
|
n_chips = 511;
|
||||||
|
system = 'R';
|
||||||
|
signal = '1G';
|
||||||
|
end
|
||||||
|
filename = [path file '_' system '_' signal '_sat_' num2str(sat) '.mat'];
|
||||||
|
load(filename);
|
||||||
|
[n_fft n_dop_bins] = size(grid);
|
||||||
|
[d_max f_max] = find(grid == max(max(grid)));
|
||||||
|
freq = (0 : n_dop_bins - 1) * doppler_step - doppler_max;
|
||||||
|
delay = (0 : n_fft - 1) / n_fft * n_chips;
|
||||||
|
figure(1)
|
||||||
|
if(lite_view == false)
|
||||||
|
surf(freq, delay, grid, 'FaceColor', 'interp', 'LineStyle', 'none')
|
||||||
|
ylim([min(delay) max(delay)])
|
||||||
|
else
|
||||||
|
delay_interp = (0 : n_samples_per_chip * n_chips - 1) / n_samples_per_chip;
|
||||||
|
grid_interp = spline(delay, grid', delay_interp)';
|
||||||
|
surf(freq, delay_interp, grid_interp, 'FaceColor', 'interp', 'LineStyle', 'none')
|
||||||
|
ylim([min(delay_interp) max(delay_interp)])
|
||||||
|
end
|
||||||
|
xlabel('Doppler shift / Hz')
|
||||||
|
xlim([min(freq) max(freq)])
|
||||||
|
ylabel('Code delay / chips')
|
||||||
|
zlabel('Test statistics')
|
||||||
|
figure(2)
|
||||||
|
subplot(2,1,1)
|
||||||
|
plot(freq, grid(d_max, :))
|
||||||
|
xlim([min(freq) max(freq)])
|
||||||
|
xlabel('Doppler shift / Hz')
|
||||||
|
ylabel('Test statistics')
|
||||||
|
title(['Fixed code delay to ' num2str((d_max - 1) / n_fft * n_chips) ' chips'])
|
||||||
|
subplot(2,1,2)
|
||||||
|
plot(delay, grid(:, f_max))
|
||||||
|
xlim([min(delay) max(delay)])
|
||||||
|
xlabel('Code delay / chips')
|
||||||
|
ylabel('Test statistics')
|
||||||
|
title(['Doppler wipe-off = ' num2str((f_max - 1) * doppler_step - doppler_max) ' Hz'])
|
Loading…
Reference in New Issue
Block a user