1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-15 12:40:35 +00:00
This commit is contained in:
Carles Fernandez 2019-03-02 11:48:55 +01:00
commit 0072cd02c3
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
4 changed files with 47 additions and 63 deletions

View File

@ -205,12 +205,11 @@ void GNSSFlowgraph::connect()
DLOG(INFO) << "blocks connected internally";
// Signal Source (i) > Signal conditioner (i) >
int RF_Channels = 0;
int signal_conditioner_ID = 0;
#ifndef ENABLE_FPGA
int RF_Channels = 0;
int signal_conditioner_ID = 0;
for (int i = 0; i < sources_count_; i++)
{
try
@ -357,12 +356,13 @@ void GNSSFlowgraph::connect()
#endif
// Signal conditioner (selected_signal_source) >> channels (i) (dependent of their associated SignalSource_ID)
int selected_signal_conditioner_ID = 0;
bool use_acq_resampler = configuration_->property("GNSS-SDR.use_acquisition_resampler", false);
uint32_t fs = configuration_->property("GNSS-SDR.internal_fs_sps", 0);
for (unsigned int i = 0; i < channels_count_; i++)
{
#ifndef ENABLE_FPGA
int selected_signal_conditioner_ID = 0;
bool use_acq_resampler = configuration_->property("GNSS-SDR.use_acquisition_resampler", false);
uint32_t fs = configuration_->property("GNSS-SDR.internal_fs_sps", 0);
if (configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false) == false)
{
try
@ -861,9 +861,11 @@ void GNSSFlowgraph::disconnect()
}
#endif
// Signal conditioner (selected_signal_source) >> channels (i) (dependent of their associated SignalSource_ID)
int selected_signal_conditioner_ID;
for (unsigned int i = 0; i < channels_count_; i++)
{
#ifndef ENABLE_FPGA
int selected_signal_conditioner_ID;
try
{
selected_signal_conditioner_ID = configuration_->property("Channel" + std::to_string(i) + ".RF_channel_ID", 0);
@ -874,7 +876,6 @@ void GNSSFlowgraph::disconnect()
top_block_->disconnect_all();
return;
}
#ifndef ENABLE_FPGA
try
{
top_block_->disconnect(sig_conditioner_.at(selected_signal_conditioner_ID)->get_right_block(), 0,

View File

@ -81,13 +81,15 @@ void thread_acquisition_send_rx_samples(gr::top_block_sptr top_block,
buffer_float = (char *)malloc(FLOAT_SIZE); // allocate space for the temporary buffer
if (!buffer_float)
{
fprintf(stderr, "Memory error!");
std::cerr << "Memory error!" << std::endl;
return;
}
rx_signal_file = fopen(file_name, "rb"); // file containing the received signal
if (!rx_signal_file)
{
printf("Unable to open file!");
std::cerr << "Unable to open file!" << std::endl;
return;
}
// determine the length of the file that contains the received signal
@ -96,7 +98,6 @@ void thread_acquisition_send_rx_samples(gr::top_block_sptr top_block,
fseek(rx_signal_file, 0, SEEK_SET);
// first step: check for the maximum value of the received signal
float max = 0;
float *pointer_float;
pointer_float = (float *)&buffer_float[0];
@ -118,23 +119,21 @@ void thread_acquisition_send_rx_samples(gr::top_block_sptr top_block,
fseek(rx_signal_file, 0, SEEK_SET);
// allocate memory for the samples to be transferred to the DMA
buffer_DMA = (signed char *)malloc(DMA_ACQ_TRANSFER_SIZE);
if (!buffer_DMA)
{
fprintf(stderr, "Memory error!");
std::cerr << "Memory error!" << std::endl;
}
// open the DMA descriptor
dma_descr = open("/dev/loop_tx", O_WRONLY);
if (dma_descr < 0)
{
printf("can't open loop device\n");
exit(1);
std::cerr << "Can't open loop device\n";
return;
}
// cycle through the file containing the received samples
for (int k = 0; k < NTIMES_CYCLE_THROUGH_RX_SAMPLES_FILE; k++)
{
fseek(rx_signal_file, 0, SEEK_SET);
@ -176,7 +175,6 @@ void thread_acquisition_send_rx_samples(gr::top_block_sptr top_block,
close(dma_descr);
// when all the samples are sent stop the top block
top_block->stop();
}

View File

@ -293,7 +293,7 @@ std::vector<double> GpsL1CADllPllTrackingTest::check_results_doppler(arma::vec&
err = meas_value - true_value_interp;
//conversion between arma::vec and std:vector
// conversion between arma::vec and std:vector
std::vector<double> err_std_vector(err.colptr(0), err.colptr(0) + err.n_rows);
arma::vec err2 = arma::square(err);
@ -344,7 +344,7 @@ std::vector<double> GpsL1CADllPllTrackingTest::check_results_acc_carrier_phase(a
//it is required to remove the initial offset in the accumulated carrier phase error
err = (meas_value - meas_value(0)) - (true_value_interp - true_value_interp(0));
arma::vec err2 = arma::square(err);
//conversion between arma::vec and std:vector
// conversion between arma::vec and std:vector
std::vector<double> err_std_vector(err.colptr(0), err.colptr(0) + err.n_rows);
rmse = sqrt(arma::mean(err2));
@ -392,7 +392,7 @@ std::vector<double> GpsL1CADllPllTrackingTest::check_results_codephase(arma::vec
arma::vec err;
err = meas_value - true_value_interp;
//conversion between arma::vec and std:vector
// conversion between arma::vec and std:vector
std::vector<double> err_std_vector(err.colptr(0), err.colptr(0) + err.n_rows);
arma::vec err2 = arma::square(err);
@ -424,10 +424,8 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
//*************************************************
//***** STEP 2: Prepare the parameters sweep ******
//*************************************************
std::vector<double> generator_CN0_values;
//data containers for config param sweep
std::vector<std::vector<double>> mean_doppler_error_sweep; //swep config param and cn0 sweep
std::vector<std::vector<double>> std_dev_doppler_error_sweep; //swep config param and cn0 sweep
@ -449,16 +447,13 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
double acq_doppler_hz = 0.0;
Tracking_True_Obs_Reader true_obs_data;
// 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)
@ -490,8 +485,6 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
//*********************************************
//***** STEP 3: Generate the input signal *****
//*********************************************
std::vector<double> cno_vector;
if (FLAGS_CN0_dBHz_start == FLAGS_CN0_dBHz_stop)
{
@ -587,7 +580,6 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
true_obs_data.restart();
}
std::chrono::time_point<std::chrono::system_clock> start, end;
top_block = gr::make_top_block("Tracking test");
@ -625,7 +617,6 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
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 *****
//********************************************************************
@ -643,8 +634,8 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
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
// check results
// 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";
@ -736,7 +727,6 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
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 rmse;
@ -781,7 +771,6 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
std::cout << "Tracking output could not be used, possible loss of lock " << ex.what() << std::endl;
}
}
} //CN0 LOOP
if (!FLAGS_enable_external_signal_file)
@ -898,7 +887,7 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
}
}
//PLOT ERROR FIGURES (only if it is used the signal generator)
// PLOT ERROR FIGURES (only if it is used the signal generator)
if (!FLAGS_enable_external_signal_file)
{
if (FLAGS_plot_detail_level >= 1)
@ -917,7 +906,6 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
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
@ -952,7 +940,6 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
g5b.set_xlabel("Time [s]");
g5b.set_ylabel("Code delay error [meters]");
for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values_sweep_copy.at(config_idx).size(); current_cn0_idx++)
{
try
@ -973,7 +960,6 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
g5b.savetops("Code_error_meters");
g5b.savetopdf("Code_error_meters", 18);
Gnuplot g6("points");
if (FLAGS_show_plots)
{
@ -988,7 +974,6 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
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
@ -1064,7 +1049,6 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
if (generator_CN0_values.size() > 1)
{
//plot metrics
Gnuplot g7("linespoints");
if (FLAGS_show_plots)
{
@ -1098,7 +1082,6 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
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();
@ -1155,6 +1138,7 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
}
}
bool GpsL1CADllPllTrackingTest::save_mat_xy(std::vector<double>& x, std::vector<double>& y, std::string filename)
{
try

View File

@ -79,14 +79,15 @@ void send_tracking_gps_input_samples(FILE *rx_signal_file,
dma_descr = open("/dev/loop_tx", O_WRONLY);
if (dma_descr < 0)
{
printf("can't open loop device\n");
exit(1);
std::cerr << "Can't open loop device\n";
return;
}
buffer_DMA = (char *)malloc(DMA_TRACK_TRANSFER_SIZE);
if (!buffer_DMA)
{
fprintf(stderr, "Memory error!");
std::cerr << "Memory error!" << std::endl;
return;
}
while (num_remaining_samples > 0)
@ -140,7 +141,8 @@ void sending_thread(gr::top_block_sptr top_block, const char *file_name)
rx_signal_file = fopen(file_name, "rb");
if (!rx_signal_file)
{
printf("Unable to open file!");
std::cerr << "Unable to open file!" << std::endl;
return;
}
fseek(rx_signal_file, 0, SEEK_END);
@ -335,7 +337,7 @@ void GpsL1CADllPllTrackingTestFpga::configure_receiver()
void GpsL1CADllPllTrackingTestFpga::check_results_doppler(arma::vec &true_time_s,
arma::vec &true_value, arma::vec &meas_time_s, arma::vec &meas_value)
{
//1. True value interpolation to match the measurement times
// 1. True value interpolation to match the measurement times
arma::vec true_value_interp;
arma::uvec true_time_s_valid = find(true_time_s > 0);
true_time_s = true_time_s(true_time_s_valid);
@ -345,22 +347,21 @@ void GpsL1CADllPllTrackingTestFpga::check_results_doppler(arma::vec &true_time_s
meas_value = meas_value(meas_time_s_valid);
arma::interp1(true_time_s, true_value, meas_time_s, true_value_interp);
//2. RMSE
// 2. RMSE
arma::vec err;
err = meas_value - true_value_interp;
arma::vec err2 = arma::square(err);
double rmse = sqrt(arma::mean(err2));
//3. Mean err and variance
// 3. Mean err and variance
double error_mean = arma::mean(err);
double error_var = arma::var(err);
// 5. Peaks
// 4. Peaks
double max_error = arma::max(err);
double min_error = arma::min(err);
//5. report
// 5. report
std::streamsize ss = std::cout.precision();
std::cout << std::setprecision(10) << "TRK Doppler RMSE=" << rmse
<< ", mean=" << error_mean << ", stdev=" << sqrt(error_var)
@ -384,14 +385,14 @@ void GpsL1CADllPllTrackingTestFpga::check_results_acc_carrier_phase(
meas_value = meas_value(meas_time_s_valid);
arma::interp1(true_time_s, true_value, meas_time_s, true_value_interp);
//2. RMSE
// 2. RMSE
arma::vec err;
err = meas_value - true_value_interp;
arma::vec err2 = arma::square(err);
double rmse = sqrt(arma::mean(err2));
//3. Mean err and variance
// 3. Mean err and variance
double error_mean = arma::mean(err);
double error_var = arma::var(err);
@ -399,7 +400,7 @@ void GpsL1CADllPllTrackingTestFpga::check_results_acc_carrier_phase(
double max_error = arma::max(err);
double min_error = arma::min(err);
//5. report
// 5. report
std::streamsize ss = std::cout.precision();
std::cout << std::setprecision(10) << "TRK acc carrier phase RMSE=" << rmse
<< ", mean=" << error_mean << ", stdev=" << sqrt(error_var)
@ -413,7 +414,7 @@ void GpsL1CADllPllTrackingTestFpga::check_results_codephase(
arma::vec &true_time_s, arma::vec &true_value, arma::vec &meas_time_s,
arma::vec &meas_value)
{
//1. True value interpolation to match the measurement times
// 1. True value interpolation to match the measurement times
arma::vec true_value_interp;
arma::uvec true_time_s_valid = find(true_time_s > 0);
true_time_s = true_time_s(true_time_s_valid);
@ -423,13 +424,13 @@ void GpsL1CADllPllTrackingTestFpga::check_results_codephase(
meas_value = meas_value(meas_time_s_valid);
arma::interp1(true_time_s, true_value, meas_time_s, true_value_interp);
//2. RMSE
// 2. RMSE
arma::vec err;
err = meas_value - true_value_interp;
arma::vec err2 = arma::square(err);
double rmse = sqrt(arma::mean(err2));
//3. Mean err and variance
// 3. Mean err and variance
double error_mean = arma::mean(err);
double error_var = arma::var(err);
@ -437,7 +438,7 @@ void GpsL1CADllPllTrackingTestFpga::check_results_codephase(
double max_error = arma::max(err);
double min_error = arma::min(err);
//5. report
// 5. report
std::streamsize ss = std::cout.precision();
std::cout << std::setprecision(10) << "TRK code phase RMSE=" << rmse
<< ", mean=" << error_mean << ", stdev=" << sqrt(error_var)
@ -459,7 +460,7 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga)
configure_receiver();
//open true observables log file written by the simulator
// open true observables log file written by the simulator
Tracking_True_Obs_Reader true_obs_data;
int test_satellite_PRN = FLAGS_test_satellite_PRN;
std::cout << "Testing satellite PRN=" << test_satellite_PRN << std::endl;
@ -491,7 +492,7 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga)
})
<< "Failure reading true observables file";
//restart the epoch counter
// restart the epoch counter
true_obs_data.restart();
std::cout << "Initial Doppler [Hz]=" << true_obs_data.doppler_l1_hz
@ -550,8 +551,8 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga)
// wait until child thread terminates
t.join();
//check results
//load the true values
// check results
// load the true values
int64_t nepoch = true_obs_data.num_epochs();
std::cout << "True observation epochs=" << nepoch << std::endl;
@ -572,7 +573,7 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga)
epoch_counter++;
}
//load the measured values
// load the measured values
Tracking_Dump_Reader trk_dump;
ASSERT_NO_THROW(
{
@ -604,7 +605,7 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga)
epoch_counter++;
}
//Align initial measurements and cut the tracking pull-in transitory
// Align initial measurements and cut the tracking pull-in transitory
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");