From 566611fd5e5147f54a5c39c2b1afbca27e0dad6e Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 28 Jun 2018 16:30:36 +0200 Subject: [PATCH] Add work on acq performance --- .../gps_l1_acq_performance_test.cc | 93 ++++++++++++++++++- 1 file changed, 88 insertions(+), 5 deletions(-) diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_acq_performance_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_acq_performance_test.cc index 572fd5d92..e6d0e0626 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_acq_performance_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_acq_performance_test.cc @@ -34,8 +34,8 @@ #include "tracking_true_obs_reader.h" #include "true_observables_reader.h" #include "display.h" -#include // for create_directories, exists -#include // for filesystem +#include "gnuplot_i.h" +#include #include #include #include @@ -49,6 +49,7 @@ DEFINE_int32(acq_test_fake_PRN, 33, "Fake PRN number"); DEFINE_int32(acq_test_signal_duration_s, 2, "Generated signal duration"); DEFINE_bool(acq_test_bit_transition_flag, false, "Bit transition flag"); DEFINE_int32(acq_test_iterations, 2, "Number of iterations"); +DEFINE_bool(plot_acq_test, false, "Plots results of AcquisitionPerformanceTest with gnuplot"); // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class AcqPerfTest_msg_rx; @@ -133,8 +134,8 @@ protected: { } - std::vector cn0_ = {35.0}; - std::vector pfa_local = {0.0001, 0.001, 0.01, 0.1, 1}; //{FLAGS_acq_test_pfa}; //{0.001, 0.01, 0.1, 1}; + std::vector cn0_ = {35.0, 38.0}; + std::vector pfa_local = {0.001, 0.01, 1}; //{0.0001, 0.001, 0.01, 0.1, 1}; //{FLAGS_acq_test_pfa}; //{0.001, 0.01, 0.1, 1}; int N_iterations = FLAGS_acq_test_iterations; void init(); //void plot_grid(); @@ -149,6 +150,7 @@ protected: int run_receiver(); int count_executions(const std::string& basename, unsigned int sat); void check_results(); + void plot_results(); concurrent_queue channel_internal_queue; @@ -438,7 +440,86 @@ int AcquisitionPerformanceTest::count_executions(const std::string& basename, un } -TEST_F(AcquisitionPerformanceTest, PdvsCn0) +void AcquisitionPerformanceTest::plot_results() +{ + if (FLAGS_plot_acq_test == true) + { + 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); + + Gnuplot g1("linespoints"); + g1.set_title("Receiver Operating Characteristic for GPS L1 C/A acquisition"); + g1.cmd("set logscale x"); + g1.cmd("set yrange [0:1]"); + g1.cmd("set grid xtics 0.001 0.01 0.1 1"); + g1.cmd("set grid ytics"); + g1.set_grid(); + g1.set_xlabel("Pfa"); + g1.set_ylabel("Pd"); + for (int i = 0; i < static_cast(cn0_.size()); i++) + { + std::vector Pd_i; + std::vector Pfa_i; + for (int k = 0; k < num_thresholds; k++) + { + Pd_i.push_back(Pd[i][k]); + Pfa_i.push_back(Pd[i][k]); + } + g1.plot_xy(Pfa_i, Pd_i, "CN0 = " + std::to_string(static_cast(cn0_[i])) + " dBHz"); + } + g1.set_legend(); + g1.savetops("ROC"); + g1.savetopdf("ROC", 18); + g1.showonscreen(); // window output + + if (Pd_correct[0].size() > 0) + { + Gnuplot g2("linespoints"); + g2.set_title("Receiver Operating Characteristic for GPS L1 C/A correct acquisition"); + g2.cmd("set logscale x"); + g2.set_xlabel("Pfa"); + g2.set_xlabel("Pd"); + g2.set_grid(); + for (int i = 0; i < static_cast(cn0_.size()); i++) + { + std::vector Pd_i_correct; + std::vector Pfa_i; + for (int k = 0; k < num_thresholds; k++) + { + Pd_i_correct.push_back(Pd_correct[i][k]); + Pfa_i.push_back(Pd[i][k]); + } + g2.plot_xy(Pfa_i, Pd_i_correct, "CN0 = " + std::to_string(static_cast(cn0_[i])) + " dBHz"); + } + g2.set_legend(); + g2.savetops("ROC-correct"); + g2.savetopdf("ROC-correct", 18); + g2.showonscreen(); // window output + } + } + catch (const GnuplotException& ge) + { + std::cout << ge.what() << std::endl; + } + } + } +} + + +TEST_F(AcquisitionPerformanceTest, ROC) { tracking_true_obs_reader true_trk_data; @@ -726,4 +807,6 @@ TEST_F(AcquisitionPerformanceTest, PdvsCn0) aux_index++; } + + plot_results(); }