1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-15 04:30:33 +00:00

Merge branch 'next' of https://github.com/gnss-sdr/gnss-sdr into next

This commit is contained in:
Carles Fernandez 2018-06-28 16:31:32 +02:00
commit f6396fe0e6
25 changed files with 980 additions and 250 deletions

View File

@ -60,6 +60,7 @@ GalileoE1PcpsAmbiguousAcquisition::GalileoE1PcpsAmbiguousAcquisition(
acq_parameters.fs_in = fs_in_;
dump_ = configuration_->property(role + ".dump", false);
acq_parameters.dump = dump_;
acq_parameters.dump_channel = configuration_->property(role + ".dump_channel", 0);
blocking_ = configuration_->property(role + ".blocking", true);
acq_parameters.blocking = blocking_;
doppler_max_ = configuration_->property(role + ".doppler_max", 5000);

View File

@ -65,6 +65,7 @@ GalileoE5aPcpsAcquisition::GalileoE5aPcpsAcquisition(ConfigurationInterface* con
}
dump_ = configuration_->property(role + ".dump", false);
acq_parameters.dump = dump_;
acq_parameters.dump_channel = configuration_->property(role + ".dump_channel", 0);
doppler_max_ = configuration_->property(role + ".doppler_max", 5000);
if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max;
acq_parameters.doppler_max = doppler_max_;

View File

@ -61,6 +61,7 @@ GlonassL1CaPcpsAcquisition::GlonassL1CaPcpsAcquisition(
acq_parameters.fs_in = fs_in_;
dump_ = configuration_->property(role + ".dump", false);
acq_parameters.dump = dump_;
acq_parameters.dump_channel = configuration_->property(role + ".dump_channel", 0);
blocking_ = configuration_->property(role + ".blocking", true);
acq_parameters.blocking = blocking_;
doppler_max_ = configuration_->property(role + ".doppler_max", 5000);

View File

@ -60,6 +60,7 @@ GlonassL2CaPcpsAcquisition::GlonassL2CaPcpsAcquisition(
acq_parameters.fs_in = fs_in_;
dump_ = configuration_->property(role + ".dump", false);
acq_parameters.dump = dump_;
acq_parameters.dump_channel = configuration_->property(role + ".dump_channel", 0);
blocking_ = configuration_->property(role + ".blocking", true);
acq_parameters.blocking = blocking_;
doppler_max_ = configuration_->property(role + ".doppler_max", 5000);

View File

@ -62,6 +62,7 @@ GpsL1CaPcpsAcquisition::GpsL1CaPcpsAcquisition(
acq_parameters.fs_in = fs_in_;
dump_ = configuration_->property(role + ".dump", false);
acq_parameters.dump = dump_;
acq_parameters.dump_channel = configuration_->property(role + ".dump_channel", 0);
blocking_ = configuration_->property(role + ".blocking", true);
acq_parameters.blocking = blocking_;
doppler_max_ = configuration_->property(role + ".doppler_max", 5000);

View File

@ -62,6 +62,7 @@ GpsL2MPcpsAcquisition::GpsL2MPcpsAcquisition(
acq_parameters.fs_in = fs_in_;
dump_ = configuration_->property(role + ".dump", false);
acq_parameters.dump = dump_;
acq_parameters.dump_channel = configuration_->property(role + ".dump_channel", 0);
blocking_ = configuration_->property(role + ".blocking", true);
acq_parameters.blocking = blocking_;
doppler_max_ = configuration->property(role + ".doppler_max", 5000);

View File

@ -61,6 +61,7 @@ GpsL5iPcpsAcquisition::GpsL5iPcpsAcquisition(
acq_parameters.fs_in = fs_in_;
dump_ = configuration_->property(role + ".dump", false);
acq_parameters.dump = dump_;
acq_parameters.dump_channel = configuration_->property(role + ".dump_channel", 0);
blocking_ = configuration_->property(role + ".blocking", true);
acq_parameters.blocking = blocking_;
doppler_max_ = configuration->property(role + ".doppler_max", 5000);

View File

@ -123,6 +123,7 @@ pcps_acquisition::pcps_acquisition(const Acq_Conf& conf_) : gr::block("pcps_acqu
grid_ = arma::fmat();
d_step_two = false;
d_dump_number = 0;
d_dump_channel = acq_parameters.dump_channel;
}
@ -314,7 +315,7 @@ void pcps_acquisition::send_positive_acquisition()
<< ", doppler " << d_gnss_synchro->Acq_doppler_hz
<< ", magnitude " << d_mag
<< ", input signal power " << d_input_power;
d_positive_acq = 1;
this->message_port_pub(pmt::mp("events"), pmt::from_long(1));
}
@ -332,7 +333,7 @@ void pcps_acquisition::send_negative_acquisition()
<< ", doppler " << d_gnss_synchro->Acq_doppler_hz
<< ", magnitude " << d_mag
<< ", input signal power " << d_input_power;
d_positive_acq = 0;
this->message_port_pub(pmt::mp("events"), pmt::from_long(2));
}
@ -363,7 +364,7 @@ void pcps_acquisition::dump_results(int effective_fft_size)
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);
matvar_t* matvar = Mat_VarCreate("acq_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);
@ -407,6 +408,10 @@ void pcps_acquisition::dump_results(int effective_fft_size)
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
matvar = Mat_VarCreate("PRN", MAT_C_UINT32, MAT_T_UINT32, 1, dims, &d_gnss_synchro->PRN, 0);
Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE
Mat_VarFree(matvar);
Mat_Close(matfp);
}
}
@ -510,7 +515,7 @@ void pcps_acquisition::acquisition_core(unsigned long int samp_count)
}
}
// Record results to file if required
if (acq_parameters.dump)
if (acq_parameters.dump and d_channel == d_dump_channel)
{
memcpy(grid_.colptr(doppler_index), d_magnitude, sizeof(float) * effective_fft_size);
}
@ -579,7 +584,7 @@ void pcps_acquisition::acquisition_core(unsigned long int samp_count)
}
}
// Record results to file if required
if (acq_parameters.dump)
if (acq_parameters.dump and d_channel == d_dump_channel)
{
memcpy(grid_.colptr(doppler_index), d_magnitude, sizeof(float) * effective_fft_size);
}
@ -598,7 +603,6 @@ void pcps_acquisition::acquisition_core(unsigned long int samp_count)
send_positive_acquisition();
d_step_two = false;
d_state = 0; // Positive acquisition
d_positive_acq = 1;
}
else
{
@ -610,7 +614,6 @@ void pcps_acquisition::acquisition_core(unsigned long int samp_count)
{
send_positive_acquisition();
d_state = 0; // Positive acquisition
d_positive_acq = 1;
}
}
else if (d_well_count == acq_parameters.max_dwells)
@ -633,7 +636,6 @@ void pcps_acquisition::acquisition_core(unsigned long int samp_count)
send_positive_acquisition();
d_step_two = false;
d_state = 0; // Positive acquisition
d_positive_acq = 1;
}
else
{
@ -645,7 +647,6 @@ void pcps_acquisition::acquisition_core(unsigned long int samp_count)
{
send_positive_acquisition();
d_state = 0; // Positive acquisition
d_positive_acq = 1;
}
}
else
@ -657,7 +658,7 @@ void pcps_acquisition::acquisition_core(unsigned long int samp_count)
}
d_worker_active = false;
// Record results to file if required
if (acq_parameters.dump)
if (acq_parameters.dump and d_channel == d_dump_channel)
{
pcps_acquisition::dump_results(effective_fft_size);
}

View File

@ -125,6 +125,7 @@ private:
Gnss_Synchro* d_gnss_synchro;
arma::fmat grid_;
long int d_dump_number;
unsigned int d_dump_channel;
public:
~pcps_acquisition();

View File

@ -48,5 +48,6 @@ Acq_Conf::Acq_Conf()
blocking = false;
make_2_steps = false;
dump_filename = "";
dump_channel = 0;
it_size = sizeof(char);
}

View File

@ -53,6 +53,7 @@ public:
bool blocking;
bool make_2_steps;
std::string dump_filename;
unsigned int dump_channel;
size_t it_size;
Acq_Conf();

View File

@ -117,6 +117,13 @@ void InMemoryConfiguration::set_property(std::string property_name, std::string
}
void InMemoryConfiguration::supersede_property(std::string property_name, std::string value)
{
properties_.erase(property_name);
properties_.insert(std::make_pair(property_name, value));
}
bool InMemoryConfiguration::is_present(std::string property_name)
{
return (properties_.find(property_name) != properties_.end());

View File

@ -63,6 +63,7 @@ public:
float property(std::string property_name, float default_value);
double property(std::string property_name, double default_value);
void set_property(std::string property_name, std::string value);
void supersede_property(std::string property_name, std::string value);
bool is_present(std::string property_name);
private:

View File

@ -0,0 +1,75 @@
/*!
* \file tracking_tests_flags.h
* \brief Helper file for unit testing
* \author Javier Arribas, 2018. jarribas(at)cttc.es
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2010-2018 (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 <https://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_TRACKING_TESTS_FLAGS_H_
#define GNSS_SDR_TRACKING_TESTS_FLAGS_H_
#include <gflags/gflags.h>
#include <limits>
// Input signal configuration
DEFINE_bool(enable_external_signal_file, false, "Use an external signal file capture instead of the software-defined signal generator");
DEFINE_string(signal_file, std::string("gps_l1_capture.dat"), "Path of the external signal capture file");
DEFINE_double(CN0_dBHz_start, std::numeric_limits<double>::infinity(), "Enable noise generator and set the CN0 start sweep value [dB-Hz]");
DEFINE_double(CN0_dBHz_stop, std::numeric_limits<double>::infinity(), "Enable noise generator and set the CN0 stop sweep value [dB-Hz]");
DEFINE_double(CN0_dB_step, 3.0, "Noise generator CN0 sweep step value [dB]");
DEFINE_double(PLL_bw_hz_start, 40.0, "PLL Wide configuration start sweep value [Hz]");
DEFINE_double(PLL_bw_hz_stop, 40.0, "PLL Wide configuration stop sweep value [Hz]");
DEFINE_double(PLL_bw_hz_step, 5.0, "PLL Wide configuration sweep step value [Hz]");
DEFINE_double(DLL_bw_hz_start, 1.5, "DLL Wide configuration start sweep value [Hz]");
DEFINE_double(DLL_bw_hz_stop, 1.5, "DLL Wide configuration stop sweep value [Hz]");
DEFINE_double(DLL_bw_hz_step, 0.25, "DLL Wide configuration sweep step value [Hz]");
DEFINE_double(PLL_narrow_bw_hz, 5.0, "PLL Narrow configuration value [Hz]");
DEFINE_double(DLL_narrow_bw_hz, 0.75, "DLL Narrow configuration value [Hz]");
DEFINE_double(Acq_Doppler_error_hz_start, 500.0, "Acquisition Doppler error start sweep value [Hz]");
DEFINE_double(Acq_Doppler_error_hz_stop, -500.0, "Acquisition Doppler error stop sweep value [Hz]");
DEFINE_double(Acq_Doppler_error_hz_step, -50.0, "Acquisition Doppler error sweep step value [Hz]");
DEFINE_double(Acq_Delay_error_chips_start, 2.0, "Acquisition Code Delay error start sweep value [Hz]");
DEFINE_double(Acq_Delay_error_chips_stop, -2.0, "Acquisition Code Delay error stop sweep value [Hz]");
DEFINE_double(Acq_Delay_error_chips_step, -0.1, "Acquisition Code Delay error sweep step value [Hz]");
DEFINE_int32(plot_detail_level, 0, "Specify the desired plot detail (0,1,2): 0 - Minimum plots (default) 2 - Plot all tracking parameters");
//Emulated acquisition configuration
//Tracking configuration
DEFINE_int32(extend_correlation_symbols, 1, "Set the tracking coherent correlation to N symbols (up to 20 for GPS L1 C/A)");
//Test output configuration
DEFINE_bool(plot_gps_l1_tracking_test, false, "Plots results of GpsL1CADllPllTrackingTest with gnuplot");
#endif

View File

@ -147,6 +147,7 @@ DECLARE_string(log_dir);
#include "unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_test.cc"
#include "unit-tests/signal-processing-blocks/tracking/gps_l2_m_dll_pll_tracking_test.cc"
#include "unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc"
#include "unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_pull-in_test.cc"
#include "unit-tests/signal-processing-blocks/telemetry_decoder/gps_l1_ca_telemetry_decoder_test.cc"
#include "unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc"
#endif

View File

@ -160,6 +160,7 @@ void GpsL1CaPcpsAcquisitionTest::init()
config->set_property("Acquisition_1C.dump", "false");
}
config->set_property("Acquisition_1C.dump_filename", "./tmp-acq-gps1/acquisition");
config->set_property("Acquisition_1C.dump_channel", "1");
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_step", std::to_string(doppler_step));

View File

@ -163,7 +163,8 @@ void GpsL2MPcpsAcquisitionTest::init()
{
config->set_property("Acquisition_2S.dump", "false");
}
config->set_property("Acquisition_2S.dump_filename", "./tmp-acq-gps2/acquisition");
config->set_property("Acquisition_2S.dump_filename", "./tmp-acq-gps2/acquisition_test");
config->set_property("Acquisition_2S.dump_channel", "1");
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_step", std::to_string(doppler_step));
@ -175,11 +176,11 @@ void GpsL2MPcpsAcquisitionTest::init()
void GpsL2MPcpsAcquisitionTest::plot_grid()
{
//load the measured values
std::string basename = "./tmp-acq-gps2/acquisition_G_2S";
std::string basename = "./tmp-acq-gps2/acquisition_test_G_2S";
unsigned int sat = static_cast<unsigned int>(gnss_synchro.PRN);
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, 1);
if (!acq_dump.read_binary_acq()) std::cout << "Error reading files" << std::endl;
std::vector<int> *doppler = &acq_dump.doppler;

View File

@ -43,7 +43,7 @@ bool acquisition_dump_reader::read_binary_acq()
std::cout << "¡¡¡Unreachable Acquisition dump file!!!" << std::endl;
return false;
}
matvar_t* var_ = Mat_VarRead(matfile, "grid");
matvar_t* var_ = Mat_VarRead(matfile, "acq_grid");
if (var_ == NULL)
{
std::cout << "¡¡¡Unreachable grid variable into Acquisition dump file!!!" << std::endl;
@ -109,15 +109,20 @@ bool acquisition_dump_reader::read_binary_acq()
positive_acq = *static_cast<int*>(var2_->data);
Mat_VarFree(var2_);
var2_ = Mat_VarRead(matfile, "PRN");
PRN = *static_cast<int*>(var2_->data);
Mat_VarFree(var2_);
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, 4) * input_power;
for (it1 = mag.begin(); it1 != mag.end(); it1++)
{
for (it2 = it1->begin(); it2 != it1->end(); it2++)
{
*it2 = static_cast<float>(aux[k]) / input_power;
*it2 = static_cast<float>(aux[k]) / normalization_factor;
k++;
}
}
@ -128,6 +133,49 @@ bool acquisition_dump_reader::read_binary_acq()
}
acquisition_dump_reader::acquisition_dump_reader(const std::string& basename,
int channel,
int execution)
{
unsigned int sat_ = 0;
unsigned int doppler_max_ = 0;
unsigned int doppler_step_ = 0;
unsigned int samples_per_code_ = 0;
mat_t* matfile = Mat_Open(d_dump_filename.c_str(), MAT_ACC_RDONLY);
if (matfile != NULL)
{
matvar_t* var_ = Mat_VarRead(matfile, "doppler_max");
doppler_max_ = *static_cast<unsigned int*>(var_->data);
Mat_VarFree(var_);
var_ = Mat_VarRead(matfile, "doppler_step");
doppler_step_ = *static_cast<unsigned int*>(var_->data);
Mat_VarFree(var_);
var_ = Mat_VarRead(matfile, "PRN");
sat_ = *static_cast<int*>(var_->data);
Mat_VarFree(var_);
var_ = Mat_VarRead(matfile, "grid");
samples_per_code_ = var_->dims[0];
Mat_VarFree(var_);
Mat_Close(matfile);
}
else
{
std::cout << "¡¡¡Unreachable Acquisition dump file!!!" << std::endl;
}
acquisition_dump_reader(basename,
sat_,
doppler_max_,
doppler_step_,
samples_per_code_,
channel,
execution);
}
acquisition_dump_reader::acquisition_dump_reader(const std::string& basename,
unsigned int sat,
unsigned int doppler_max,
@ -148,6 +196,7 @@ acquisition_dump_reader::acquisition_dump_reader(const std::string& basename,
threshold = 0.0;
positive_acq = 0;
sample_counter = 0;
PRN = 0;
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));
mag = mag_aux;

View File

@ -45,7 +45,13 @@ public:
unsigned int samples_per_code,
int channel = 0,
int execution = 1);
acquisition_dump_reader(const std::string& basename,
int channel = 0,
int execution = 1);
~acquisition_dump_reader();
bool read_binary_acq();
std::vector<int> doppler;
@ -57,6 +63,7 @@ public:
float input_power;
float threshold;
int positive_acq;
unsigned int PRN;
long unsigned int sample_counter;
private:

View File

@ -97,7 +97,6 @@ bool observables_dump_reader::open_obs_file(std::string out_file)
d_dump_filename = out_file;
d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
d_dump_file.open(d_dump_filename.c_str(), std::ios::in | std::ios::binary);
std::cout << "Observables sum file opened, Log file: " << d_dump_filename.c_str() << std::endl;
return true;
}
catch (const std::ifstream::failure &e)

View File

@ -109,7 +109,6 @@ bool tracking_dump_reader::open_obs_file(std::string out_file)
d_dump_filename = out_file;
d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
d_dump_file.open(d_dump_filename.c_str(), std::ios::in | std::ios::binary);
std::cout << "Tracking dump enabled, Log file: " << d_dump_filename.c_str() << std::endl;
return true;
}
catch (const std::ifstream::failure &e)

View File

@ -93,7 +93,6 @@ bool tracking_true_obs_reader::open_obs_file(std::string out_file)
d_dump_filename = out_file;
d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
d_dump_file.open(d_dump_filename.c_str(), std::ios::in | std::ios::binary);
std::cout << "Tracking Log file: " << d_dump_filename.c_str() << " open ok " << std::endl;
return true;
}
catch (const std::ifstream::failure &e)

View File

@ -0,0 +1,573 @@
/*!
* \file gps_l1_ca_dll_pll_tracking_test.cc
* \brief This class implements a tracking Pull-In test for GPS_L1_CA_DLL_PLL_Tracking
* implementation based on some input parameters.
* \author Javier Arribas, 2018. jarribas(at)cttc.es
*
*
* -------------------------------------------------------------------------
*
* Copyright (C) 2012-2018 (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 <https://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------
*/
#include <chrono>
#include <unistd.h>
#include <vector>
#include <armadillo>
#include <boost/filesystem.hpp>
#include <gnuradio/top_block.h>
#include <gnuradio/blocks/file_source.h>
#include <gnuradio/blocks/interleaved_char_to_complex.h>
#include <gnuradio/blocks/null_sink.h>
#include <gnuradio/blocks/skiphead.h>
#include <gtest/gtest.h>
#include "GPS_L1_CA.h"
#include "gnss_block_factory.h"
#include "tracking_interface.h"
#include "in_memory_configuration.h"
#include "tracking_true_obs_reader.h"
#include "tracking_dump_reader.h"
#include "signal_generator_flags.h"
#include "gnuplot_i.h"
#include "test_flags.h"
#include "tracking_tests_flags.h"
// ######## GNURADIO BLOCK MESSAGE RECEVER #########
class GpsL1CADllPllTrackingPullInTest_msg_rx;
typedef boost::shared_ptr<GpsL1CADllPllTrackingPullInTest_msg_rx> GpsL1CADllPllTrackingPullInTest_msg_rx_sptr;
GpsL1CADllPllTrackingPullInTest_msg_rx_sptr GpsL1CADllPllTrackingPullInTest_msg_rx_make();
class GpsL1CADllPllTrackingPullInTest_msg_rx : public gr::block
{
private:
friend GpsL1CADllPllTrackingPullInTest_msg_rx_sptr GpsL1CADllPllTrackingPullInTest_msg_rx_make();
void msg_handler_events(pmt::pmt_t msg);
GpsL1CADllPllTrackingPullInTest_msg_rx();
public:
int rx_message;
~GpsL1CADllPllTrackingPullInTest_msg_rx(); //!< Default destructor
};
GpsL1CADllPllTrackingPullInTest_msg_rx_sptr GpsL1CADllPllTrackingPullInTest_msg_rx_make()
{
return GpsL1CADllPllTrackingPullInTest_msg_rx_sptr(new GpsL1CADllPllTrackingPullInTest_msg_rx());
}
void GpsL1CADllPllTrackingPullInTest_msg_rx::msg_handler_events(pmt::pmt_t msg)
{
try
{
long int message = pmt::to_long(msg);
rx_message = message; //3 -> loss of lock
//std::cout << "Received trk message: " << rx_message << std::endl;
}
catch (boost::bad_any_cast& e)
{
LOG(WARNING) << "msg_handler_telemetry Bad any cast!";
rx_message = 0;
}
}
GpsL1CADllPllTrackingPullInTest_msg_rx::GpsL1CADllPllTrackingPullInTest_msg_rx() : gr::block("GpsL1CADllPllTrackingPullInTest_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0))
{
this->message_port_register_in(pmt::mp("events"));
this->set_msg_handler(pmt::mp("events"), boost::bind(&GpsL1CADllPllTrackingPullInTest_msg_rx::msg_handler_events, this, _1));
rx_message = 0;
}
GpsL1CADllPllTrackingPullInTest_msg_rx::~GpsL1CADllPllTrackingPullInTest_msg_rx()
{
}
// ###########################################################
class GpsL1CADllPllTrackingPullInTest : public ::testing::Test
{
public:
std::string generator_binary;
std::string p1;
std::string p2;
std::string p3;
std::string p4;
std::string p5;
std::string p6;
std::string implementation = "GPS_L1_CA_DLL_PLL_Tracking"; //"GPS_L1_CA_DLL_PLL_C_Aid_Tracking";
const int baseband_sampling_freq = FLAGS_fs_gen_sps;
std::string filename_rinex_obs = FLAGS_filename_rinex_obs;
std::string filename_raw_data = FLAGS_filename_raw_data;
int configure_generator(double CN0_dBHz, int file_idx);
int generate_signal();
std::vector<double> check_results_doppler(arma::vec& true_time_s,
arma::vec& true_value,
arma::vec& meas_time_s,
arma::vec& meas_value,
double& mean_error,
double& std_dev_error);
std::vector<double> check_results_acc_carrier_phase(arma::vec& true_time_s,
arma::vec& true_value,
arma::vec& meas_time_s,
arma::vec& meas_value,
double& mean_error,
double& std_dev_error);
std::vector<double> check_results_codephase(arma::vec& true_time_s,
arma::vec& true_value,
arma::vec& meas_time_s,
arma::vec& meas_value,
double& mean_error,
double& std_dev_error);
GpsL1CADllPllTrackingPullInTest()
{
factory = std::make_shared<GNSSBlockFactory>();
config = std::make_shared<InMemoryConfiguration>();
item_size = sizeof(gr_complex);
gnss_synchro = Gnss_Synchro();
}
~GpsL1CADllPllTrackingPullInTest()
{
}
void configure_receiver(double PLL_wide_bw_hz,
double DLL_wide_bw_hz,
double PLL_narrow_bw_hz,
double DLL_narrow_bw_hz,
int extend_correlation_symbols);
gr::top_block_sptr top_block;
std::shared_ptr<GNSSBlockFactory> factory;
std::shared_ptr<InMemoryConfiguration> config;
Gnss_Synchro gnss_synchro;
size_t item_size;
};
int GpsL1CADllPllTrackingPullInTest::configure_generator(double CN0_dBHz, int file_idx)
{
// Configure signal generator
generator_binary = FLAGS_generator_binary;
p1 = std::string("-rinex_nav_file=") + FLAGS_rinex_nav_file;
if (FLAGS_dynamic_position.empty())
{
p2 = std::string("-static_position=") + FLAGS_static_position + std::string(",") + std::to_string(FLAGS_duration * 10);
}
else
{
p2 = std::string("-obs_pos_file=") + std::string(FLAGS_dynamic_position);
}
p3 = std::string("-rinex_obs_file=") + FLAGS_filename_rinex_obs; // RINEX 2.10 observation file output
p4 = std::string("-sig_out_file=") + FLAGS_filename_raw_data + std::to_string(file_idx); // Baseband signal output file. Will be stored in int8_t IQ multiplexed samples
p5 = std::string("-sampling_freq=") + std::to_string(baseband_sampling_freq); //Baseband sampling frequency [MSps]
p6 = std::string("-CN0_dBHz=") + std::to_string(CN0_dBHz); // Signal generator CN0
return 0;
}
int GpsL1CADllPllTrackingPullInTest::generate_signal()
{
int child_status;
char* const parmList[] = {&generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0], &p6[0], NULL};
int pid;
if ((pid = fork()) == -1)
perror("fork err");
else if (pid == 0)
{
execv(&generator_binary[0], parmList);
std::cout << "Return not expected. Must be an execv err." << std::endl;
std::terminate();
}
waitpid(pid, &child_status, 0);
std::cout << "Signal and Observables RINEX and RAW files created." << std::endl;
return 0;
}
void GpsL1CADllPllTrackingPullInTest::configure_receiver(
double PLL_wide_bw_hz,
double DLL_wide_bw_hz,
double PLL_narrow_bw_hz,
double DLL_narrow_bw_hz,
int extend_correlation_symbols)
{
gnss_synchro.Channel_ID = 0;
gnss_synchro.System = 'G';
std::string signal = "1C";
signal.copy(gnss_synchro.Signal, 2, 0);
gnss_synchro.PRN = FLAGS_test_satellite_PRN;
config = std::make_shared<InMemoryConfiguration>();
config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(baseband_sampling_freq));
// Set Tracking
config->set_property("Tracking_1C.implementation", implementation);
config->set_property("Tracking_1C.item_type", "gr_complex");
config->set_property("Tracking_1C.pll_bw_hz", std::to_string(PLL_wide_bw_hz));
config->set_property("Tracking_1C.dll_bw_hz", std::to_string(DLL_wide_bw_hz));
config->set_property("Tracking_1C.early_late_space_chips", "0.5");
config->set_property("Tracking_1C.extend_correlation_symbols", std::to_string(extend_correlation_symbols));
config->set_property("Tracking_1C.pll_bw_narrow_hz", std::to_string(PLL_narrow_bw_hz));
config->set_property("Tracking_1C.dll_bw_narrow_hz", std::to_string(DLL_narrow_bw_hz));
config->set_property("Tracking_1C.early_late_space_narrow_chips", "0.5");
config->set_property("Tracking_1C.dump", "true");
config->set_property("Tracking_1C.dump_filename", "./tracking_ch_");
std::cout << "*****************************************\n";
std::cout << "*** Tracking configuration parameters ***\n";
std::cout << "*****************************************\n";
std::cout << "pll_bw_hz: " << config->property("Tracking_1C.pll_bw_hz", 0.0) << " Hz\n";
std::cout << "dll_bw_hz: " << config->property("Tracking_1C.dll_bw_hz", 0.0) << " Hz\n";
std::cout << "pll_bw_narrow_hz: " << config->property("Tracking_1C.pll_bw_narrow_hz", 0.0) << " Hz\n";
std::cout << "dll_bw_narrow_hz: " << config->property("Tracking_1C.dll_bw_narrow_hz", 0.0) << " Hz\n";
std::cout << "extend_correlation_symbols: " << config->property("Tracking_1C.extend_correlation_symbols", 0) << " Symbols\n";
std::cout << "*****************************************\n";
std::cout << "*****************************************\n";
}
TEST_F(GpsL1CADllPllTrackingPullInTest, ValidationOfResults)
{
//*************************************************
//***** STEP 2: Prepare the parameters sweep ******
//*************************************************
std::vector<double> acq_doppler_error_hz_values;
std::vector<std::vector<double>> acq_delay_error_chips_values; //vector of vector
for (double doppler_hz = FLAGS_Acq_Doppler_error_hz_start; doppler_hz >= FLAGS_Acq_Doppler_error_hz_stop; doppler_hz = doppler_hz + FLAGS_Acq_Doppler_error_hz_step)
{
acq_doppler_error_hz_values.push_back(doppler_hz);
std::vector<double> tmp_vector;
//Code Delay Sweep
for (double code_delay_chips = FLAGS_Acq_Delay_error_chips_start; code_delay_chips >= FLAGS_Acq_Delay_error_chips_stop; code_delay_chips = code_delay_chips + FLAGS_Acq_Delay_error_chips_step)
{
tmp_vector.push_back(code_delay_chips);
}
acq_delay_error_chips_values.push_back(tmp_vector);
}
//*********************************************
//***** STEP 3: Generate the input signal *****
//*********************************************
std::vector<double> generator_CN0_values;
if (FLAGS_CN0_dBHz_start == FLAGS_CN0_dBHz_stop)
{
generator_CN0_values.push_back(FLAGS_CN0_dBHz_start);
}
else
{
for (double cn0 = FLAGS_CN0_dBHz_start; cn0 > FLAGS_CN0_dBHz_stop; cn0 = cn0 - FLAGS_CN0_dB_step)
{
generator_CN0_values.push_back(cn0);
}
}
// use generator or use an external capture file
if (FLAGS_enable_external_signal_file)
{
//todo: create and configure an acquisition block and perform an acquisition to obtain the synchronization parameters
}
else
{
for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++)
{
// Configure the signal generator
configure_generator(generator_CN0_values.at(current_cn0_idx), current_cn0_idx);
// Generate signal raw signal samples and observations RINEX file
if (FLAGS_disable_generator == false)
{
generate_signal();
}
}
}
configure_receiver(FLAGS_PLL_bw_hz_start,
FLAGS_DLL_bw_hz_start,
FLAGS_PLL_narrow_bw_hz,
FLAGS_DLL_narrow_bw_hz,
FLAGS_extend_correlation_symbols);
//******************************************************************************************
//***** Obtain the initial signal sinchronization parameters (emulating an acquisition) ****
//******************************************************************************************
int test_satellite_PRN = 0;
tracking_true_obs_reader true_obs_data;
if (!FLAGS_enable_external_signal_file)
{
test_satellite_PRN = FLAGS_test_satellite_PRN;
std::string true_obs_file = std::string("./gps_l1_ca_obs_prn");
true_obs_file.append(std::to_string(test_satellite_PRN));
true_obs_file.append(".dat");
true_obs_data.close_obs_file();
ASSERT_EQ(true_obs_data.open_obs_file(true_obs_file), true) << "Failure opening true observables file";
// load acquisition data based on the first epoch of the true observations
ASSERT_EQ(true_obs_data.read_binary_obs(), true)
<< "Failure reading true tracking dump file." << std::endl
<< "Maybe sat PRN #" + std::to_string(FLAGS_test_satellite_PRN) +
" is not available?";
std::cout << "Testing satellite PRN=" << test_satellite_PRN << std::endl;
std::cout << "True Initial Doppler [Hz]=" << true_obs_data.doppler_l1_hz << " rue Initial code delay [Chips]=" << true_obs_data.prn_delay_chips << std::endl;
}
else
{
//todo: Simulate a perfect acquisition for the external capture file
}
//CN0 LOOP
std::vector<std::vector<double>> pull_in_results_v_v;
for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++)
{
std::vector<double> pull_in_results_v;
for (unsigned int current_acq_doppler_error_idx = 0; current_acq_doppler_error_idx < acq_doppler_error_hz_values.size(); current_acq_doppler_error_idx++)
{
for (unsigned int current_acq_code_error_idx = 0; current_acq_code_error_idx < acq_delay_error_chips_values.at(current_acq_doppler_error_idx).size(); current_acq_code_error_idx++)
{
//simulate a Doppler error in acquisition
double acq_doppler_hz = true_obs_data.doppler_l1_hz + acq_doppler_error_hz_values.at(current_acq_doppler_error_idx);
//simulate Code Delay error in acquisition
double acq_delay_samples;
acq_delay_samples = (GPS_L1_CA_CODE_LENGTH_CHIPS - true_obs_data.prn_delay_chips / GPS_L1_CA_CODE_LENGTH_CHIPS) * static_cast<double>(baseband_sampling_freq) * GPS_L1_CA_CODE_PERIOD;
acq_delay_samples += (acq_delay_error_chips_values.at(current_acq_doppler_error_idx).at(current_acq_code_error_idx) / GPS_L1_CA_CODE_RATE_HZ) * static_cast<double>(baseband_sampling_freq);
//create flowgraph
top_block = gr::make_top_block("Tracking test");
std::shared_ptr<GNSSBlockInterface> trk_ = factory->GetBlock(config, "Tracking_1C", implementation, 1, 1);
std::shared_ptr<TrackingInterface> tracking = std::dynamic_pointer_cast<TrackingInterface>(trk_);
boost::shared_ptr<GpsL1CADllPllTrackingPullInTest_msg_rx> msg_rx = GpsL1CADllPllTrackingPullInTest_msg_rx_make();
gnss_synchro.Acq_delay_samples = acq_delay_samples;
gnss_synchro.Acq_doppler_hz = acq_doppler_hz;
gnss_synchro.Acq_samplestamp_samples = 0;
ASSERT_NO_THROW({
tracking->set_channel(gnss_synchro.Channel_ID);
}) << "Failure setting channel.";
ASSERT_NO_THROW({
tracking->set_gnss_synchro(&gnss_synchro);
}) << "Failure setting gnss_synchro.";
ASSERT_NO_THROW({
tracking->connect(top_block);
}) << "Failure connecting tracking to the top_block.";
ASSERT_NO_THROW({
std::string file = "./" + filename_raw_data + std::to_string(current_cn0_idx);
const char* file_name = file.c_str();
gr::blocks::file_source::sptr file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false);
gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make();
gr::blocks::null_sink::sptr sink = gr::blocks::null_sink::make(sizeof(Gnss_Synchro));
top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0);
top_block->connect(gr_interleaved_char_to_complex, 0, tracking->get_left_block(), 0);
top_block->connect(tracking->get_right_block(), 0, sink, 0);
top_block->msg_connect(tracking->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events"));
}) << "Failure connecting the blocks of tracking test.";
//********************************************************************
//***** STEP 5: Perform the signal tracking and read the results *****
//********************************************************************
std::cout << "------------ START TRACKING -------------" << std::endl;
tracking->start_tracking();
std::chrono::time_point<std::chrono::system_clock> start, end;
EXPECT_NO_THROW({
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
end = std::chrono::system_clock::now();
}) << "Failure running the top_block.";
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "Signal tracking completed in " << elapsed_seconds.count() << " seconds" << std::endl;
pull_in_results_v.push_back(msg_rx->rx_message != 3); //save last asynchronous tracking message in order to detect a loss of lock
//********************************
//***** STEP 7: Plot results *****
//********************************
if (FLAGS_plot_gps_l1_tracking_test == true)
{
//load the measured values
tracking_dump_reader trk_dump;
ASSERT_EQ(trk_dump.open_obs_file(std::string("./tracking_ch_0.dat")), true)
<< "Failure opening tracking dump file";
long int n_measured_epochs = trk_dump.num_epochs();
//todo: use vectors instead
arma::vec trk_timestamp_s = arma::zeros(n_measured_epochs, 1);
arma::vec trk_acc_carrier_phase_cycles = arma::zeros(n_measured_epochs, 1);
arma::vec trk_Doppler_Hz = arma::zeros(n_measured_epochs, 1);
arma::vec trk_prn_delay_chips = arma::zeros(n_measured_epochs, 1);
std::vector<double> timestamp_s;
std::vector<double> prompt;
std::vector<double> early;
std::vector<double> late;
std::vector<double> promptI;
std::vector<double> promptQ;
std::vector<double> CN0_dBHz;
long int epoch_counter = 0;
while (trk_dump.read_binary_obs())
{
trk_timestamp_s(epoch_counter) = static_cast<double>(trk_dump.PRN_start_sample_count) / static_cast<double>(baseband_sampling_freq);
trk_acc_carrier_phase_cycles(epoch_counter) = trk_dump.acc_carrier_phase_rad / GPS_TWO_PI;
trk_Doppler_Hz(epoch_counter) = trk_dump.carrier_doppler_hz;
double delay_chips = GPS_L1_CA_CODE_LENGTH_CHIPS - GPS_L1_CA_CODE_LENGTH_CHIPS * (fmod((static_cast<double>(trk_dump.PRN_start_sample_count) + trk_dump.aux1) / static_cast<double>(baseband_sampling_freq), 1.0e-3) / 1.0e-3);
trk_prn_delay_chips(epoch_counter) = delay_chips;
timestamp_s.push_back(trk_timestamp_s(epoch_counter));
prompt.push_back(trk_dump.abs_P);
early.push_back(trk_dump.abs_E);
late.push_back(trk_dump.abs_L);
promptI.push_back(trk_dump.prompt_I);
promptQ.push_back(trk_dump.prompt_Q);
CN0_dBHz.push_back(trk_dump.CN0_SNV_dB_Hz);
epoch_counter++;
}
const std::string gnuplot_executable(FLAGS_gnuplot_executable);
if (gnuplot_executable.empty())
{
std::cout << "WARNING: Although the flag plot_gps_l1_tracking_test has been set to TRUE," << std::endl;
std::cout << "gnuplot has not been found in your system." << std::endl;
std::cout << "Test results will not be plotted." << std::endl;
}
else
{
try
{
boost::filesystem::path p(gnuplot_executable);
boost::filesystem::path dir = p.parent_path();
std::string gnuplot_path = dir.native();
Gnuplot::set_GNUPlotPath(gnuplot_path);
unsigned int decimate = static_cast<unsigned int>(FLAGS_plot_decimate);
if (FLAGS_plot_detail_level >= 2)
{
Gnuplot g1("linespoints");
g1.showonscreen(); // window output
g1.set_title(std::to_string(generator_CN0_values.at(current_cn0_idx)) + " dB-Hz, " + "PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " Hz" + "GPS L1 C/A (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")");
g1.set_grid();
g1.set_xlabel("Time [s]");
g1.set_ylabel("Correlators' output");
//g1.cmd("set key box opaque");
g1.plot_xy(trk_timestamp_s, prompt, "Prompt", decimate);
g1.plot_xy(trk_timestamp_s, early, "Early", decimate);
g1.plot_xy(trk_timestamp_s, late, "Late", decimate);
g1.set_legend();
//g1.savetops("Correlators_outputs" + std::to_string(generator_CN0_values.at(current_cn0_idx)));
//g1.savetopdf("Correlators_outputs" + std::to_string(generator_CN0_values.at(current_cn0_idx)), 18);
Gnuplot g2("points");
g2.showonscreen(); // window output
g2.set_title(std::to_string(generator_CN0_values.at(current_cn0_idx)) + " dB-Hz Constellation " + "PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " Hz" + "GPS L1 C/A (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")");
g2.set_grid();
g2.set_xlabel("Inphase");
g2.set_ylabel("Quadrature");
//g2.cmd("set size ratio -1");
g2.plot_xy(promptI, promptQ);
//g2.savetops("Constellation");
//g2.savetopdf("Constellation", 18);
Gnuplot g3("linespoints");
g3.set_title(std::to_string(generator_CN0_values.at(current_cn0_idx)) + " dB-Hz, GPS L1 C/A tracking CN0 output (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")");
g3.set_grid();
g3.set_xlabel("Time [s]");
g3.set_ylabel("Reported CN0 [dB-Hz]");
g3.cmd("set key box opaque");
g3.plot_xy(trk_timestamp_s, CN0_dBHz,
std::to_string(static_cast<int>(round(generator_CN0_values.at(current_cn0_idx)))) + "[dB-Hz]", decimate);
g3.set_legend();
//g3.savetops("CN0_output");
//g3.savetopdf("CN0_output", 18);
g3.showonscreen(); // window output
}
}
catch (const GnuplotException& ge)
{
std::cout << ge.what() << std::endl;
}
}
} //end plot
} //end acquisition Delay errors loop
} //end acquisition Doppler errors loop
pull_in_results_v_v.push_back(pull_in_results_v);
} //end CN0 LOOP
//build the mesh grid
std::vector<double> doppler_error_mesh;
std::vector<double> code_delay_error_mesh;
for (unsigned int current_acq_doppler_error_idx = 0; current_acq_doppler_error_idx < acq_doppler_error_hz_values.size(); current_acq_doppler_error_idx++)
{
for (unsigned int current_acq_code_error_idx = 0; current_acq_code_error_idx < acq_delay_error_chips_values.at(current_acq_doppler_error_idx).size(); current_acq_code_error_idx++)
{
doppler_error_mesh.push_back(acq_doppler_error_hz_values.at(current_acq_doppler_error_idx));
code_delay_error_mesh.push_back(acq_delay_error_chips_values.at(current_acq_doppler_error_idx).at(current_acq_code_error_idx));
}
}
for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++)
{
std::vector<double> pull_in_result_mesh;
pull_in_result_mesh = pull_in_results_v_v.at(current_cn0_idx);
//plot grid
Gnuplot g4("points palette pointsize 2 pointtype 7");
g4.cmd("set palette defined ( 0 \"black\", 1 \"green\" )");
g4.cmd("set key off");
g4.cmd("set view map");
std::string title("Tracking Pull-in result grid at CN0:" + std::to_string(static_cast<int>(round(generator_CN0_values.at(current_cn0_idx)))) + " dB-Hz, PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " Hz.");
g4.set_title(title);
g4.set_grid();
g4.set_xlabel("Acquisition Doppler error [Hz]");
g4.set_ylabel("Acquisition Code Delay error [Chips]");
g4.plot_xyz(doppler_error_mesh,
code_delay_error_mesh,
pull_in_result_mesh);
g4.set_legend();
g4.savetops("trk_pull_in_grid_" + std::to_string(static_cast<int>(round(generator_CN0_values.at(current_cn0_idx)))));
g4.savetopdf("trk_pull_in_grid_" + std::to_string(static_cast<int>(round(generator_CN0_values.at(current_cn0_idx)))), 12);
g4.showonscreen(); // window output
}
}

View File

@ -1,6 +1,6 @@
/*!
* \file gps_l1_ca_dll_pll_tracking_test.cc
* \brief This class implements a tracking test for Galileo_E5a_DLL_PLL_Tracking
* \brief This class implements a tracking test for GPS_L1_CA_DLL_PLL_Tracking
* implementation based on some input parameters.
* \author Javier Arribas, 2017. jarribas(at)cttc.es
*
@ -52,33 +52,9 @@
#include "signal_generator_flags.h"
#include "gnuplot_i.h"
#include "test_flags.h"
#include "tracking_tests_flags.h"
// Input signal configuration
DEFINE_bool(enable_external_signal_file, false, "Use an external signal file capture instead of the software-defined signal generator");
DEFINE_string(signal_file, std::string("gps_l1_capture.dat"), "Path of the external signal capture file");
DEFINE_double(CN0_dBHz_start, std::numeric_limits<double>::infinity(), "Enable noise generator and set the CN0 start sweep value [dB-Hz]");
DEFINE_double(CN0_dBHz_stop, std::numeric_limits<double>::infinity(), "Enable noise generator and set the CN0 stop sweep value [dB-Hz]");
DEFINE_double(CN0_dB_step, 3.0, "Noise generator CN0 sweep step value [dB]");
DEFINE_double(PLL_bw_hz_start, 40.0, "PLL Wide configuration start sweep value [Hz]");
DEFINE_double(PLL_bw_hz_stop, 40.0, "PLL Wide configuration stop sweep value [Hz]");
DEFINE_double(PLL_bw_hz_step, 5.0, "PLL Wide configuration sweep step value [Hz]");
DEFINE_double(DLL_bw_hz_start, 1.5, "DLL Wide configuration start sweep value [Hz]");
DEFINE_double(DLL_bw_hz_stop, 1.5, "DLL Wide configuration stop sweep value [Hz]");
DEFINE_double(DLL_bw_hz_step, 0.25, "DLL Wide configuration sweep step value [Hz]");
DEFINE_bool(plot_extra, false, "Enable or disable plots of the correlators output and constellation diagrams");
//Emulated acquisition configuration
//Tracking configuration
DEFINE_int32(extend_correlation_symbols, 1, "Set the tracking coherent correlation to N symbols (up to 20 for GPS L1 C/A)");
//Test output configuration
DEFINE_bool(plot_gps_l1_tracking_test, false, "Plots results of GpsL1CADllPllTrackingTest with gnuplot");
// ######## GNURADIO BLOCK MESSAGE RECEVER #########
class GpsL1CADllPllTrackingTest_msg_rx;
@ -110,7 +86,8 @@ void GpsL1CADllPllTrackingTest_msg_rx::msg_handler_events(pmt::pmt_t msg)
try
{
long int message = pmt::to_long(msg);
rx_message = message;
rx_message = message; //3 -> loss of lock
//std::cout << "Received trk message: " << rx_message << std::endl;
}
catch (boost::bad_any_cast& e)
{
@ -451,18 +428,7 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
std::vector<std::vector<double>> std_dev_carrier_phase_error_sweep; //swep config param and cn0 sweep
std::vector<std::vector<double>> trk_valid_timestamp_s_sweep;
if (FLAGS_CN0_dBHz_start == FLAGS_CN0_dBHz_stop)
{
generator_CN0_values.push_back(FLAGS_CN0_dBHz_start);
}
else
{
for (double cn0 = FLAGS_CN0_dBHz_start; cn0 > FLAGS_CN0_dBHz_stop; cn0 = cn0 - FLAGS_CN0_dB_step)
{
generator_CN0_values.push_back(cn0);
}
}
std::vector<std::vector<double>> generator_CN0_values_sweep_copy;
int test_satellite_PRN = 0;
double acq_delay_samples = 0.0;
@ -470,35 +436,15 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
tracking_true_obs_reader true_obs_data;
//*********************************************
//***** STEP 3: Generate the input signal *****
//*********************************************
// use generator or use an external capture file
if (FLAGS_enable_external_signal_file)
{
//todo: create and configure an acquisition block and perform an acquisition to obtain the synchronization parameters
}
else
{
for (int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++)
{
// Configure the signal generator
configure_generator(generator_CN0_values.at(current_cn0_idx), current_cn0_idx);
// Generate signal raw signal samples and observations RINEX file
if (FLAGS_disable_generator == false)
{
generate_signal();
}
// open true observables log file written by the simulator
}
}
// CONFIG PARAM SWEEP LOOP
std::vector<double> PLL_wide_bw_values;
std::vector<double> DLL_wide_bw_values;
//***********************************************************
//***** STEP 2: Tracking configuration parameters sweep *****
//***********************************************************
if (FLAGS_PLL_bw_hz_start == FLAGS_PLL_bw_hz_stop)
{
if (FLAGS_DLL_bw_hz_start == FLAGS_DLL_bw_hz_stop)
@ -510,7 +456,7 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
else
{
//DLL BW Sweep
for (double dll_bw = FLAGS_DLL_bw_hz_start; dll_bw > FLAGS_DLL_bw_hz_stop; dll_bw = dll_bw - FLAGS_DLL_bw_hz_step)
for (double dll_bw = FLAGS_DLL_bw_hz_start; dll_bw >= FLAGS_DLL_bw_hz_stop; dll_bw = dll_bw - FLAGS_DLL_bw_hz_step)
{
PLL_wide_bw_values.push_back(FLAGS_PLL_bw_hz_start);
DLL_wide_bw_values.push_back(dll_bw);
@ -520,14 +466,55 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
else
{
//PLL BW Sweep
for (double pll_bw = FLAGS_PLL_bw_hz_start; pll_bw > FLAGS_PLL_bw_hz_stop; pll_bw = pll_bw - FLAGS_PLL_bw_hz_step)
for (double pll_bw = FLAGS_PLL_bw_hz_start; pll_bw >= FLAGS_PLL_bw_hz_stop; pll_bw = pll_bw - FLAGS_PLL_bw_hz_step)
{
PLL_wide_bw_values.push_back(pll_bw);
DLL_wide_bw_values.push_back(FLAGS_DLL_bw_hz_start);
}
}
for (int config_idx = 0; config_idx < PLL_wide_bw_values.size(); config_idx++)
//*********************************************
//***** STEP 3: Generate the input signal *****
//*********************************************
std::vector<double> cno_vector;
if (FLAGS_CN0_dBHz_start == FLAGS_CN0_dBHz_stop)
{
generator_CN0_values.push_back(FLAGS_CN0_dBHz_start);
}
else
{
for (double cn0 = FLAGS_CN0_dBHz_start; cn0 > FLAGS_CN0_dBHz_stop; cn0 = cn0 - FLAGS_CN0_dB_step)
{
generator_CN0_values.push_back(cn0);
}
}
// use generator or use an external capture file
if (FLAGS_enable_external_signal_file)
{
//todo: create and configure an acquisition block and perform an acquisition to obtain the synchronization parameters
}
else
{
for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++)
{
// Configure the signal generator
configure_generator(generator_CN0_values.at(current_cn0_idx), current_cn0_idx);
// Generate signal raw signal samples and observations RINEX file
if (FLAGS_disable_generator == false)
{
generate_signal();
}
// open true observables log file written by the simulator
}
}
//************************************************************
//***** STEP 4: Configure the signal tracking parameters *****
//************************************************************
for (unsigned int config_idx = 0; config_idx < PLL_wide_bw_values.size(); config_idx++)
{
//CN0 LOOP
// data containers for CN0 sweep
@ -549,13 +536,14 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
std::vector<double> std_dev_code_phase_error;
std::vector<double> mean_carrier_phase_error;
std::vector<double> std_dev_carrier_phase_error;
std::vector<double> valid_CN0_values;
configure_receiver(PLL_wide_bw_values.at(config_idx),
DLL_wide_bw_values.at(config_idx),
2.0,
1.0,
FLAGS_PLL_narrow_bw_hz,
FLAGS_DLL_narrow_bw_hz,
FLAGS_extend_correlation_symbols);
for (int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++)
for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++)
{
//******************************************************************************************
//***** Obtain the initial signal sinchronization parameters (emulating an acquisition) ****
@ -582,8 +570,6 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
}
//***** STEP 4: Configure the signal tracking parameters *****
//************************************************************
std::chrono::time_point<std::chrono::system_clock> start, end;
top_block = gr::make_top_block("Tracking test");
@ -625,6 +611,7 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
//********************************************************************
//***** STEP 5: Perform the signal tracking and read the results *****
//********************************************************************
std::cout << "------------ START TRACKING -------------" << std::endl;
tracking->start_tracking();
EXPECT_NO_THROW({
@ -636,6 +623,8 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "Signal tracking completed in " << elapsed_seconds.count() << " seconds" << std::endl;
int tracking_last_msg = msg_rx->rx_message; //save last aasynchronous tracking message in order to detect a loss of lock
//check results
//load the measured values
tracking_dump_reader trk_dump;
@ -643,7 +632,7 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
<< "Failure opening tracking dump file";
long int n_measured_epochs = trk_dump.num_epochs();
std::cout << "Measured observation epochs=" << n_measured_epochs << std::endl;
//std::cout << "Measured observation epochs=" << n_measured_epochs << std::endl;
arma::vec trk_timestamp_s = arma::zeros(n_measured_epochs, 1);
arma::vec trk_acc_carrier_phase_cycles = arma::zeros(n_measured_epochs, 1);
@ -694,11 +683,12 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
std::vector<double> doppler_error_hz;
std::vector<double> code_phase_error_chips;
std::vector<double> acc_carrier_phase_hz;
try
{
// load the true values
long int n_true_epochs = true_obs_data.num_epochs();
std::cout << "True observation epochs=" << n_true_epochs << std::endl;
//std::cout << "True observation epochs=" << n_true_epochs << std::endl;
arma::vec true_timestamp_s = arma::zeros(n_true_epochs, 1);
arma::vec true_acc_carrier_phase_cycles = arma::zeros(n_true_epochs, 1);
@ -720,45 +710,47 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
double pull_in_offset_s = 1.0;
arma::uvec initial_meas_point = arma::find(trk_timestamp_s >= (true_timestamp_s(0) + pull_in_offset_s), 1, "first");
trk_timestamp_s = trk_timestamp_s.subvec(initial_meas_point(0), trk_timestamp_s.size() - 1);
trk_acc_carrier_phase_cycles = trk_acc_carrier_phase_cycles.subvec(initial_meas_point(0), trk_acc_carrier_phase_cycles.size() - 1);
trk_Doppler_Hz = trk_Doppler_Hz.subvec(initial_meas_point(0), trk_Doppler_Hz.size() - 1);
trk_prn_delay_chips = trk_prn_delay_chips.subvec(initial_meas_point(0), trk_prn_delay_chips.size() - 1);
if (initial_meas_point.size() > 0 and tracking_last_msg != 3)
{
trk_timestamp_s = trk_timestamp_s.subvec(initial_meas_point(0), trk_timestamp_s.size() - 1);
trk_acc_carrier_phase_cycles = trk_acc_carrier_phase_cycles.subvec(initial_meas_point(0), trk_acc_carrier_phase_cycles.size() - 1);
trk_Doppler_Hz = trk_Doppler_Hz.subvec(initial_meas_point(0), trk_Doppler_Hz.size() - 1);
trk_prn_delay_chips = trk_prn_delay_chips.subvec(initial_meas_point(0), trk_prn_delay_chips.size() - 1);
double mean_error;
double std_dev_error;
double mean_error;
double std_dev_error;
doppler_error_hz = check_results_doppler(true_timestamp_s, true_Doppler_Hz, trk_timestamp_s, trk_Doppler_Hz, mean_error, std_dev_error);
mean_doppler_error.push_back(mean_error);
std_dev_doppler_error.push_back(std_dev_error);
valid_CN0_values.push_back(generator_CN0_values.at(current_cn0_idx)); //save the current cn0 value (valid tracking)
code_phase_error_chips = check_results_codephase(true_timestamp_s, true_prn_delay_chips, trk_timestamp_s, trk_prn_delay_chips, mean_error, std_dev_error);
mean_code_phase_error.push_back(mean_error);
std_dev_code_phase_error.push_back(std_dev_error);
doppler_error_hz = check_results_doppler(true_timestamp_s, true_Doppler_Hz, trk_timestamp_s, trk_Doppler_Hz, mean_error, std_dev_error);
mean_doppler_error.push_back(mean_error);
std_dev_doppler_error.push_back(std_dev_error);
acc_carrier_phase_hz = check_results_acc_carrier_phase(true_timestamp_s, true_acc_carrier_phase_cycles, trk_timestamp_s, trk_acc_carrier_phase_cycles, mean_error, std_dev_error);
mean_carrier_phase_error.push_back(mean_error);
std_dev_carrier_phase_error.push_back(std_dev_error);
code_phase_error_chips = check_results_codephase(true_timestamp_s, true_prn_delay_chips, trk_timestamp_s, trk_prn_delay_chips, mean_error, std_dev_error);
mean_code_phase_error.push_back(mean_error);
std_dev_code_phase_error.push_back(std_dev_error);
//save tracking measurement timestamps to std::vector
std::vector<double> vector_trk_timestamp_s(trk_timestamp_s.colptr(0), trk_timestamp_s.colptr(0) + trk_timestamp_s.n_rows);
trk_valid_timestamp_s_sweep.push_back(vector_trk_timestamp_s);
acc_carrier_phase_hz = check_results_acc_carrier_phase(true_timestamp_s, true_acc_carrier_phase_cycles, trk_timestamp_s, trk_acc_carrier_phase_cycles, mean_error, std_dev_error);
mean_carrier_phase_error.push_back(mean_error);
std_dev_carrier_phase_error.push_back(std_dev_error);
doppler_error_sweep.push_back(doppler_error_hz);
code_phase_error_sweep.push_back(code_phase_error_chips);
acc_carrier_phase_error_sweep.push_back(acc_carrier_phase_hz);
//save tracking measurement timestamps to std::vector
std::vector<double> vector_trk_timestamp_s(trk_timestamp_s.colptr(0), trk_timestamp_s.colptr(0) + trk_timestamp_s.n_rows);
trk_valid_timestamp_s_sweep.push_back(vector_trk_timestamp_s);
doppler_error_sweep.push_back(doppler_error_hz);
code_phase_error_sweep.push_back(code_phase_error_chips);
acc_carrier_phase_error_sweep.push_back(acc_carrier_phase_hz);
}
else
{
std::cout << "Tracking output could not be used, possible loss of lock " << std::endl;
}
}
catch (const std::exception& ex)
{
std::cout << "Tracking output could not be used, possible loss of lock " << ex.what() << std::endl;
std::vector<double> vector_trk_timestamp_s;
trk_valid_timestamp_s_sweep.push_back(vector_trk_timestamp_s);
doppler_error_sweep.push_back(doppler_error_hz);
code_phase_error_sweep.push_back(code_phase_error_chips);
acc_carrier_phase_error_sweep.push_back(acc_carrier_phase_hz);
}
}
@ -772,9 +764,10 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
std_dev_code_phase_error_sweep.push_back(std_dev_code_phase_error);
mean_carrier_phase_error_sweep.push_back(mean_carrier_phase_error);
std_dev_carrier_phase_error_sweep.push_back(std_dev_carrier_phase_error);
//make a copy of the CN0 vector for each configuration parameter in order to filter the loss of lock events
generator_CN0_values_sweep_copy.push_back(valid_CN0_values);
}
std::cout << "A\n\n\n";
//********************************
//***** STEP 7: Plot results *****
//********************************
@ -797,9 +790,9 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
Gnuplot::set_GNUPlotPath(gnuplot_path);
unsigned int decimate = static_cast<unsigned int>(FLAGS_plot_decimate);
if (FLAGS_plot_extra)
if (FLAGS_plot_detail_level >= 2)
{
for (int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++)
for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++)
{
Gnuplot g1("linespoints");
g1.showonscreen(); // window output
@ -819,7 +812,7 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
g2.showonscreen(); // window output
g2.set_multiplot(ceil(static_cast<float>(generator_CN0_values.size()) / 2.0),
ceil(static_cast<float>(generator_CN0_values.size()) / 2));
for (int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++)
for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++)
{
g2.reset_plot();
g2.set_title(std::to_string(generator_CN0_values.at(current_cn0_idx)) + " dB-Hz Constellation " + "PLL/DLL BW: " + std::to_string(PLL_wide_bw_values.at(config_idx)) + "," + std::to_string(DLL_wide_bw_values.at(config_idx)) + " Hz" + "GPS L1 C/A (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")");
@ -839,7 +832,7 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
g3.set_xlabel("Time [s]");
g3.set_ylabel("Reported CN0 [dB-Hz]");
g3.cmd("set key box opaque");
for (int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++)
for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++)
{
g3.plot_xy(trk_timestamp_s_sweep.at(current_cn0_idx), CN0_dBHz_sweep.at(current_cn0_idx),
std::to_string(static_cast<int>(round(generator_CN0_values.at(current_cn0_idx)))) + "[dB-Hz]", decimate);
@ -850,63 +843,85 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
g3.showonscreen(); // window output
}
std::cout << "B\n\n\n";
//PLOT ERROR FIGURES (only if it is used the signal generator)
if (!FLAGS_enable_external_signal_file)
{
Gnuplot g4("points");
g4.showonscreen(); // window output
g4.set_multiplot(ceil(static_cast<float>(generator_CN0_values.size()) / 2.0),
ceil(static_cast<float>(generator_CN0_values.size()) / 2));
for (int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++)
if (FLAGS_plot_detail_level >= 1)
{
g4.reset_plot();
g4.set_title(std::to_string(static_cast<int>(round(generator_CN0_values.at(current_cn0_idx)))) + "[dB-Hz] Doppler error " + "PLL/DLL BW: " + std::to_string(PLL_wide_bw_values.at(config_idx)) + "," + std::to_string(DLL_wide_bw_values.at(config_idx)) + " Hz (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")");
g4.set_grid();
//g4.cmd("set key box opaque");
g4.set_xlabel("Time [s]");
g4.set_ylabel("Dopper error [Hz]");
g4.plot_xy(trk_valid_timestamp_s_sweep.at(current_cn0_idx), doppler_error_sweep.at(current_cn0_idx),
std::to_string(static_cast<int>(round(generator_CN0_values.at(current_cn0_idx)))) + "[dB-Hz]", decimate);
//g4.set_legend();
Gnuplot g5("points");
g5.showonscreen(); // window output
g5.set_title("Code delay error, PLL/DLL BW: " + std::to_string(PLL_wide_bw_values.at(config_idx)) + "," + std::to_string(DLL_wide_bw_values.at(config_idx)) + " Hz (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")");
g5.set_grid();
g5.set_xlabel("Time [s]");
g5.set_ylabel("Code delay error [Chips]");
for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values_sweep_copy.at(config_idx).size(); current_cn0_idx++)
{
try
{
g5.plot_xy(trk_valid_timestamp_s_sweep.at(current_cn0_idx), code_phase_error_sweep.at(current_cn0_idx),
std::to_string(static_cast<int>(round(generator_CN0_values_sweep_copy.at(config_idx).at(current_cn0_idx)))) + "[dB-Hz]", decimate);
}
catch (const GnuplotException& ge)
{
}
}
g5.set_legend();
g5.set_legend();
g5.savetops("Code_error_output");
g5.savetopdf("Code_error_output", 18);
Gnuplot g6("points");
g6.showonscreen(); // window output
g6.set_title("Accumulated carrier phase error, PLL/DLL BW: " + std::to_string(PLL_wide_bw_values.at(config_idx)) + "," + std::to_string(DLL_wide_bw_values.at(config_idx)) + " Hz (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")");
g6.set_grid();
g6.set_xlabel("Time [s]");
g6.set_ylabel("Accumulated carrier phase error [Cycles]");
for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values_sweep_copy.at(config_idx).size(); current_cn0_idx++)
{
try
{
g6.plot_xy(trk_valid_timestamp_s_sweep.at(current_cn0_idx), acc_carrier_phase_error_sweep.at(current_cn0_idx),
std::to_string(static_cast<int>(round(generator_CN0_values_sweep_copy.at(config_idx).at(current_cn0_idx)))) + "[dB-Hz]", decimate);
}
catch (const GnuplotException& ge)
{
}
}
g6.set_legend();
g6.set_legend();
g6.savetops("Carrier_phase_error_output");
g6.savetopdf("Carrier_phase_error_output", 18);
Gnuplot g4("points");
g4.showonscreen(); // window output
g4.set_multiplot(ceil(static_cast<float>(generator_CN0_values.size()) / 2.0),
ceil(static_cast<float>(generator_CN0_values.size()) / 2));
for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values_sweep_copy.at(config_idx).size(); current_cn0_idx++)
{
g4.reset_plot();
g4.set_title(std::to_string(static_cast<int>(round(generator_CN0_values_sweep_copy.at(config_idx).at(current_cn0_idx)))) + "[dB-Hz], PLL/DLL BW: " + std::to_string(PLL_wide_bw_values.at(config_idx)) + "," + std::to_string(DLL_wide_bw_values.at(config_idx)) + " Hz (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")");
g4.set_grid();
//g4.cmd("set key box opaque");
g4.set_xlabel("Time [s]");
g4.set_ylabel("Dopper error [Hz]");
try
{
g4.plot_xy(trk_valid_timestamp_s_sweep.at(current_cn0_idx), doppler_error_sweep.at(current_cn0_idx),
std::to_string(static_cast<int>(round(generator_CN0_values_sweep_copy.at(config_idx).at(current_cn0_idx)))) + "[dB-Hz]", decimate);
}
catch (const GnuplotException& ge)
{
}
}
g4.unset_multiplot();
g4.savetops("Doppler_error_output");
g4.savetopdf("Doppler_error_output", 18);
}
g4.unset_multiplot();
g4.savetops("Doppler_error_output");
g4.savetopdf("Doppler_error_output", 18);
Gnuplot g5("points");
g5.set_title("Code delay error, PLL/DLL BW: " + std::to_string(PLL_wide_bw_values.at(config_idx)) + "," + std::to_string(DLL_wide_bw_values.at(config_idx)) + " Hz (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")");
g5.set_grid();
g5.set_xlabel("Time [s]");
g5.set_ylabel("Code delay error [Chips]");
g5.cmd("set key box opaque");
for (int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++)
{
g5.plot_xy(trk_valid_timestamp_s_sweep.at(current_cn0_idx), code_phase_error_sweep.at(current_cn0_idx),
std::to_string(static_cast<int>(round(generator_CN0_values.at(current_cn0_idx)))) + "[dB-Hz]", decimate);
}
g5.set_legend();
g5.savetops("Code_error_output");
g5.savetopdf("Code_error_output", 18);
g5.showonscreen(); // window output
Gnuplot g6("points");
g6.set_title("Accumulated carrier phase error, PLL/DLL BW: " + std::to_string(PLL_wide_bw_values.at(config_idx)) + "," + std::to_string(DLL_wide_bw_values.at(config_idx)) + " Hz (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")");
g6.set_grid();
g6.set_xlabel("Time [s]");
g6.set_ylabel("Accumulated carrier phase error [Cycles]");
g6.cmd("set key box opaque");
for (int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++)
{
g6.plot_xy(trk_valid_timestamp_s_sweep.at(current_cn0_idx), acc_carrier_phase_error_sweep.at(current_cn0_idx),
std::to_string(static_cast<int>(round(generator_CN0_values.at(current_cn0_idx)))) + "[dB-Hz]", decimate);
}
g6.set_legend();
g6.savetops("Carrier_phase_error_output");
g6.savetopdf("Carrier_phase_error_output", 18);
g6.showonscreen(); // window output
}
}
catch (const GnuplotException& ge)
@ -917,86 +932,77 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
}
}
if (FLAGS_plot_gps_l1_tracking_test == true)
{
const std::string gnuplot_executable(FLAGS_gnuplot_executable);
if (gnuplot_executable.empty())
std::cout << "Ploting performance metrics..." << std::endl;
try
{
std::cout << "WARNING: Although the flag plot_gps_l1_tracking_test has been set to TRUE," << std::endl;
std::cout << "gnuplot has not been found in your system." << std::endl;
std::cout << "Test results will not be plotted." << std::endl;
}
else
{
try
if (generator_CN0_values.size() > 1)
{
if (generator_CN0_values.size() > 1)
//plot metrics
Gnuplot g7("linespoints");
g7.showonscreen(); // window output
g7.set_title("Doppler error metrics (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")");
g7.set_grid();
g7.set_xlabel("CN0 [dB-Hz]");
g7.set_ylabel("Doppler error [Hz]");
g7.set_pointsize(2);
g7.cmd("set termoption lw 2");
g7.cmd("set key box opaque");
for (unsigned int config_sweep_idx = 0; config_sweep_idx < mean_doppler_error_sweep.size(); config_sweep_idx++)
{
//plot metrics
Gnuplot g7("linespoints");
g7.set_title("Doppler error metrics (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")");
g7.set_grid();
g7.set_xlabel("CN0 [dB-Hz]");
g7.set_ylabel("Doppler error [Hz]");
g7.set_pointsize(2);
g7.cmd("set termoption lw 2");
g7.cmd("set key box opaque");
for (int config_sweep_idx = 0; config_sweep_idx < mean_doppler_error_sweep.size(); config_sweep_idx++)
{
g7.plot_xy_err(generator_CN0_values,
mean_doppler_error_sweep.at(config_sweep_idx),
std_dev_doppler_error_sweep.at(config_sweep_idx),
"PLL/DLL BW: " + std::to_string(PLL_wide_bw_values.at(config_sweep_idx)) +
+"," + std::to_string(DLL_wide_bw_values.at(config_sweep_idx)) + " Hz");
}
g7.savetops("Doppler_error_metrics");
g7.savetopdf("Doppler_error_metrics", 18);
Gnuplot g8("linespoints");
g8.set_title("Accumulated carrier phase error metrics (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")");
g8.set_grid();
g8.set_xlabel("CN0 [dB-Hz]");
g8.set_ylabel("Accumulated Carrier Phase error [Cycles]");
g8.cmd("set key box opaque");
g8.cmd("set termoption lw 2");
g8.set_pointsize(2);
for (int config_sweep_idx = 0; config_sweep_idx < mean_doppler_error_sweep.size(); config_sweep_idx++)
{
g8.plot_xy_err(generator_CN0_values,
mean_carrier_phase_error_sweep.at(config_sweep_idx),
std_dev_carrier_phase_error_sweep.at(config_sweep_idx),
"PLL/DLL BW: " + std::to_string(PLL_wide_bw_values.at(config_sweep_idx)) +
+"," + std::to_string(DLL_wide_bw_values.at(config_sweep_idx)) + " Hz");
}
g8.savetops("Carrier_error_metrics");
g8.savetopdf("Carrier_error_metrics", 18);
Gnuplot g9("linespoints");
g9.set_title("Code Phase error metrics (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")");
g9.set_grid();
g9.set_xlabel("CN0 [dB-Hz]");
g9.set_ylabel("Code Phase error [Chips]");
g9.cmd("set key box opaque");
g9.cmd("set termoption lw 2");
g9.set_pointsize(2);
for (int config_sweep_idx = 0; config_sweep_idx < mean_doppler_error_sweep.size(); config_sweep_idx++)
{
g9.plot_xy_err(generator_CN0_values,
mean_code_phase_error_sweep.at(config_sweep_idx),
std_dev_code_phase_error_sweep.at(config_sweep_idx),
"PLL/DLL BW: " + std::to_string(PLL_wide_bw_values.at(config_sweep_idx)) +
+"," + std::to_string(DLL_wide_bw_values.at(config_sweep_idx)) + " Hz");
}
g9.savetops("Code_error_metrics");
g9.savetopdf("Code_error_metrics", 18);
g7.plot_xy_err(generator_CN0_values_sweep_copy.at(config_sweep_idx),
mean_doppler_error_sweep.at(config_sweep_idx),
std_dev_doppler_error_sweep.at(config_sweep_idx),
"PLL/DLL BW: " + std::to_string(PLL_wide_bw_values.at(config_sweep_idx)) +
+"," + std::to_string(DLL_wide_bw_values.at(config_sweep_idx)) + " Hz");
}
g7.savetops("Doppler_error_metrics");
g7.savetopdf("Doppler_error_metrics", 18);
Gnuplot g8("linespoints");
g8.set_title("Accumulated carrier phase error metrics (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")");
g8.set_grid();
g8.set_xlabel("CN0 [dB-Hz]");
g8.set_ylabel("Accumulated Carrier Phase error [Cycles]");
g8.cmd("set key box opaque");
g8.cmd("set termoption lw 2");
g8.set_pointsize(2);
for (unsigned int config_sweep_idx = 0; config_sweep_idx < mean_doppler_error_sweep.size(); config_sweep_idx++)
{
g8.plot_xy_err(generator_CN0_values_sweep_copy.at(config_sweep_idx),
mean_carrier_phase_error_sweep.at(config_sweep_idx),
std_dev_carrier_phase_error_sweep.at(config_sweep_idx),
"PLL/DLL BW: " + std::to_string(PLL_wide_bw_values.at(config_sweep_idx)) +
+"," + std::to_string(DLL_wide_bw_values.at(config_sweep_idx)) + " Hz");
}
g8.savetops("Carrier_error_metrics");
g8.savetopdf("Carrier_error_metrics", 18);
Gnuplot g9("linespoints");
g9.set_title("Code Phase error metrics (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")");
g9.set_grid();
g9.set_xlabel("CN0 [dB-Hz]");
g9.set_ylabel("Code Phase error [Chips]");
g9.cmd("set key box opaque");
g9.cmd("set termoption lw 2");
g9.set_pointsize(2);
for (unsigned int config_sweep_idx = 0; config_sweep_idx < mean_doppler_error_sweep.size(); config_sweep_idx++)
{
g9.plot_xy_err(generator_CN0_values_sweep_copy.at(config_sweep_idx),
mean_code_phase_error_sweep.at(config_sweep_idx),
std_dev_code_phase_error_sweep.at(config_sweep_idx),
"PLL/DLL BW: " + std::to_string(PLL_wide_bw_values.at(config_sweep_idx)) +
+"," + std::to_string(DLL_wide_bw_values.at(config_sweep_idx)) + " Hz");
}
g9.savetops("Code_error_metrics");
g9.savetopdf("Code_error_metrics", 18);
}
catch (const GnuplotException& ge)
{
std::cout << ge.what() << std::endl;
}
}
catch (const GnuplotException& ge)
{
std::cout << ge.what() << std::endl;
}
}
}

View File

@ -107,7 +107,8 @@ 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))
normalization = (d_samples_per_code^4) * input_power;
plot(delay, acq_grid(:, f_max)./normalization)
xlim([min(delay) max(delay)])
xlabel('Code delay / chips')
ylabel('Test statistics')