From f8adffe5c21113b5d8c8c863663a87ceb3365c14 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 5 Feb 2017 20:07:34 +0100 Subject: [PATCH] Fix execution of extra tests in some environments and some code cleaning --- src/tests/CMakeLists.txt | 2 +- .../system-tests/obs_gps_l1_system_test.cc | 8 - .../libs/CMakeLists.txt | 2 +- .../libs/tlm_dump_reader.cc | 8 +- .../libs/tlm_dump_reader.h | 12 +- .../libs/tracking_dump_reader.cc | 10 +- .../libs/tracking_dump_reader.h | 12 +- .../libs/tracking_true_obs_reader.h | 12 +- .../gps_l1_ca_telemetry_decoder_test.cc | 110 ++++----- .../gps_l1_ca_dll_pll_tracking_test.cc | 225 ++++++++---------- 10 files changed, 178 insertions(+), 223 deletions(-) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 3dae17162..e0b3db5ba 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -279,7 +279,7 @@ if(ENABLE_UNIT_TESTING) signal_generator_blocks signal_generator_adapters pvt_gr_blocks - signak_processing_testing_lib + signal_processing_testing_lib ${VOLK_GNSSSDR_LIBRARIES} ${GNSS_SDR_TEST_OPTIONAL_LIBS} ) diff --git a/src/tests/system-tests/obs_gps_l1_system_test.cc b/src/tests/system-tests/obs_gps_l1_system_test.cc index 78951d35e..4eff21d75 100644 --- a/src/tests/system-tests/obs_gps_l1_system_test.cc +++ b/src/tests/system-tests/obs_gps_l1_system_test.cc @@ -53,14 +53,6 @@ #include "signal_generator_flags.h" - DECLARE_string(generator_binary); - DECLARE_string(rinex_nav_file); - DECLARE_int32(duration); - DECLARE_string(static_position); - DECLARE_string(dynamic_position); - DECLARE_string(filename_rinex_obs); - DECLARE_string(filename_raw_data); - // For GPS NAVIGATION (L1) concurrent_queue global_gps_acq_assist_queue; concurrent_map global_gps_acq_assist_map; diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/CMakeLists.txt b/src/tests/unit-tests/signal-processing-blocks/libs/CMakeLists.txt index 3e68bc02d..8b4136e7d 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/CMakeLists.txt +++ b/src/tests/unit-tests/signal-processing-blocks/libs/CMakeLists.txt @@ -32,6 +32,6 @@ include_directories( file(GLOB SIGNAL_PROCESSING_TESTING_LIB_HEADERS "*.h") list(SORT SIGNAL_PROCESSING_TESTING_LIB_HEADERS) -add_library(signak_processing_testing_lib ${SIGNAL_PROCESSING_TESTING_LIB_SOURCES} ${SIGNAL_PROCESSING_TESTING_LIB_HEADERS}) +add_library(signal_processing_testing_lib ${SIGNAL_PROCESSING_TESTING_LIB_SOURCES} ${SIGNAL_PROCESSING_TESTING_LIB_HEADERS}) source_group(Headers FILES ${SIGNAL_PROCESSING_TESTING_LIB_HEADERS}) diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/tlm_dump_reader.cc b/src/tests/unit-tests/signal-processing-blocks/libs/tlm_dump_reader.cc index 3cf8993fa..40e522f20 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/tlm_dump_reader.cc +++ b/src/tests/unit-tests/signal-processing-blocks/libs/tlm_dump_reader.cc @@ -63,12 +63,12 @@ long int tlm_dump_reader::num_epochs() { std::ifstream::pos_type size; int number_of_vars_in_epoch = 3; - int epoch_size_bytes = sizeof(double)*number_of_vars_in_epoch; + int epoch_size_bytes = sizeof(double) * number_of_vars_in_epoch; std::ifstream tmpfile( d_dump_filename.c_str(), std::ios::binary | std::ios::ate); if (tmpfile.is_open()) { size = tmpfile.tellg(); - long int nepoch=size / epoch_size_bytes; + long int nepoch = size / epoch_size_bytes; return nepoch; } else @@ -86,12 +86,12 @@ bool tlm_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 << "TLM dump enabled, Log file: " << d_dump_filename.c_str()<< std::endl; + std::cout << "TLM dump enabled, Log file: " << d_dump_filename.c_str() << std::endl; return true; } catch (const std::ifstream::failure & e) { - std::cout << "Problem opening TLM dump Log file: " << d_dump_filename.c_str()<< std::endl; + std::cout << "Problem opening TLM dump Log file: " << d_dump_filename.c_str() << std::endl; return false; } } diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/tlm_dump_reader.h b/src/tests/unit-tests/signal-processing-blocks/libs/tlm_dump_reader.h index a3afec291..7339b6e2e 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/tlm_dump_reader.h +++ b/src/tests/unit-tests/signal-processing-blocks/libs/tlm_dump_reader.h @@ -28,16 +28,16 @@ * ------------------------------------------------------------------------- */ -#ifndef GNSS_SDR_tlm_dump_reader_H -#define GNSS_SDR_tlm_dump_reader_H +#ifndef GNSS_SDR_TLM_DUMP_READER_H +#define GNSS_SDR_TLM_DUMP_READER_H #include #include #include #include -class tlm_dump_reader { - +class tlm_dump_reader +{ public: ~tlm_dump_reader(); bool read_binary_obs(); @@ -51,10 +51,8 @@ public: double d_TOW_at_Preamble; private: - std::string d_dump_filename; std::ifstream d_dump_file; - }; -#endif //GNSS_SDR_tlm_dump_reader_H +#endif //GNSS_SDR_TLM_DUMP_READER_H diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.cc b/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.cc index ac4120eb4..c410167b2 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.cc +++ b/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.cc @@ -78,8 +78,8 @@ bool tracking_dump_reader::restart() long int tracking_dump_reader::num_epochs() { std::ifstream::pos_type size; - int number_of_double_vars=11; - int number_of_float_vars=5; + int number_of_double_vars = 11; + int number_of_float_vars = 5; int epoch_size_bytes=sizeof(unsigned long int) + sizeof(double) * number_of_double_vars + sizeof(float) * number_of_float_vars; @@ -113,8 +113,10 @@ bool tracking_dump_reader::open_obs_file(std::string out_file) std::cout << "Problem opening Tracking dump Log file: " << d_dump_filename.c_str() << std::endl; return false; } - }else{ - return false; + } + else + { + return false; } } diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.h b/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.h index 9f145ecc8..6ec71ebb2 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.h +++ b/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.h @@ -28,16 +28,16 @@ * ------------------------------------------------------------------------- */ -#ifndef GNSS_SDR_tracking_dump_reader_H -#define GNSS_SDR_tracking_dump_reader_H +#ifndef GNSS_SDR_TRACKING_DUMP_READER_H +#define GNSS_SDR_TRACKING_DUMP_READER_H #include #include #include #include -class tracking_dump_reader { - +class tracking_dump_reader +{ public: ~tracking_dump_reader(); bool read_binary_obs(); @@ -80,10 +80,8 @@ public: double aux2; private: - std::string d_dump_filename; std::ifstream d_dump_file; - }; -#endif //GNSS_SDR_tracking_dump_reader_H +#endif //GNSS_SDR_TRACKING_DUMP_READER_H diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/tracking_true_obs_reader.h b/src/tests/unit-tests/signal-processing-blocks/libs/tracking_true_obs_reader.h index c7f1e646b..08b69f433 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/tracking_true_obs_reader.h +++ b/src/tests/unit-tests/signal-processing-blocks/libs/tracking_true_obs_reader.h @@ -28,16 +28,16 @@ * ------------------------------------------------------------------------- */ -#ifndef GNSS_SDR_tracking_true_obs_reader_H -#define GNSS_SDR_tracking_true_obs_reader_H +#ifndef GNSS_SDR_TRACKING_TRUE_OBS_READER_H +#define GNSS_SDR_TRACKING_TRUE_OBS_READER_H #include #include #include #include -class tracking_true_obs_reader { - +class tracking_true_obs_reader +{ public: ~tracking_true_obs_reader(); bool read_binary_obs(); @@ -53,10 +53,8 @@ public: double tow; private: - std::string d_dump_filename; std::ifstream d_dump_file; - }; -#endif //GNSS_SDR_tracking_true_obs_reader_H +#endif //GNSS_SDR_RACKING_TRUE_OBS_READER_H diff --git a/src/tests/unit-tests/signal-processing-blocks/telemetry_decoder/gps_l1_ca_telemetry_decoder_test.cc b/src/tests/unit-tests/signal-processing-blocks/telemetry_decoder/gps_l1_ca_telemetry_decoder_test.cc index 0f4a816ce..684252824 100644 --- a/src/tests/unit-tests/signal-processing-blocks/telemetry_decoder/gps_l1_ca_telemetry_decoder_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/telemetry_decoder/gps_l1_ca_telemetry_decoder_test.cc @@ -44,7 +44,6 @@ #include #include #include -#include #include #include #include @@ -64,15 +63,6 @@ #include "gps_l1_ca_dll_pll_c_aid_tracking.h" #include "signal_generator_flags.h" -DECLARE_string(generator_binary); -DECLARE_string(rinex_nav_file); -DECLARE_int32(duration); // 20 -DECLARE_int32(fs_gen_hz); -DECLARE_string(static_position); -DECLARE_string(dynamic_position); -DECLARE_string(filename_rinex_obs); -DECLARE_string(filename_raw_data); -DECLARE_int32(test_satellite_PRN); // ######## GNURADIO BLOCK MESSAGE RECEVER FOR TRACKING MESSAGES ######### class GpsL1CADllPllTelemetryDecoderTest_msg_rx; @@ -218,7 +208,6 @@ public: void configure_receiver(); - gr::msg_queue::sptr queue; gr::top_block_sptr top_block; std::shared_ptr factory; std::shared_ptr config; @@ -302,34 +291,33 @@ void GpsL1CATelemetryDecoderTest::check_results(arma::vec true_time_s, //1. True value interpolation to match the measurement times arma::vec true_value_interp; - arma::interp1(true_time_s,true_value,meas_time_s,true_value_interp); + arma::interp1(true_time_s, true_value, meas_time_s, true_value_interp); //2. RMSE arma::vec err; - err=meas_value-true_value_interp; - arma::vec err2=arma::square(err); - double rmse=sqrt(arma::mean(err2)); + err = meas_value - true_value_interp; + arma::vec err2 = arma::square(err); + double rmse = sqrt(arma::mean(err2)); //3. Mean err and variance - double error_mean=arma::mean(err); - double error_var=arma::var(err); + double error_mean = arma::mean(err); + double error_var = arma::var(err); // 4. Peaks - double max_error=arma::max(err); - double min_error=arma::min(err); + double max_error = arma::max(err); + double min_error = arma::min(err); //5. report - std::cout<< std::setprecision(10)<<"TLM TOW RMSE=" - < tracking = std::make_shared(config.get(), "Tracking_1C", 1, 1); //std::shared_ptr tracking = std::make_shared(config.get(), "Tracking_1C", 1, 1); @@ -366,7 +352,7 @@ TEST_F(GpsL1CATelemetryDecoderTest, ValidationOfResults) // load acquisition data based on the first epoch of the true observations ASSERT_NO_THROW({ - if (true_obs_data.read_binary_obs()==false) + if (true_obs_data.read_binary_obs() == false) { throw std::exception(); }; @@ -375,8 +361,8 @@ TEST_F(GpsL1CATelemetryDecoderTest, ValidationOfResults) //restart the epoch counter true_obs_data.restart(); - std::cout<<"Initial Doppler [Hz]="< #include #include -#include #include #include #include #include +#include #include "GPS_L1_CA.h" #include "gnss_block_factory.h" #include "gnss_block_interface.h" @@ -55,15 +55,6 @@ #include "tracking_dump_reader.h" #include "signal_generator_flags.h" -DECLARE_string(generator_binary); -DECLARE_string(rinex_nav_file); -DECLARE_int32(duration); -DECLARE_int32(fs_gen_hz); -DECLARE_string(static_position); -DECLARE_string(dynamic_position); -DECLARE_string(filename_rinex_obs); -DECLARE_string(filename_raw_data); -DECLARE_int32(test_satellite_PRN); // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GpsL1CADllPllTrackingTest_msg_rx; @@ -82,7 +73,6 @@ private: public: int rx_message; ~GpsL1CADllPllTrackingTest_msg_rx(); //!< Default destructor - }; GpsL1CADllPllTrackingTest_msg_rx_sptr GpsL1CADllPllTrackingTest_msg_rx_make() @@ -163,7 +153,6 @@ public: void configure_receiver(); - gr::msg_queue::sptr queue; gr::top_block_sptr top_block; std::shared_ptr factory; std::shared_ptr config; @@ -244,28 +233,28 @@ void GpsL1CADllPllTrackingTest::check_results_doppler(arma::vec true_time_s, //1. True value interpolation to match the measurement times arma::vec true_value_interp; - arma::interp1(true_time_s,true_value,meas_time_s,true_value_interp); + arma::interp1(true_time_s, true_value, meas_time_s, true_value_interp); //2. RMSE arma::vec err; - err=meas_value-true_value_interp; - arma::vec err2=arma::square(err); - double rmse=sqrt(arma::mean(err2)); + err = meas_value - true_value_interp; + arma::vec err2 = arma::square(err); + double rmse = sqrt(arma::mean(err2)); //3. Mean err and variance - double error_mean=arma::mean(err); - double error_var=arma::var(err); + double error_mean = arma::mean(err); + double error_var = arma::var(err); // 5. Peaks - double max_error=arma::max(err); - double min_error=arma::min(err); + double max_error = arma::max(err); + double min_error = arma::min(err); //5. report - std::cout<< std::setprecision(10)<<"TRK Doppler RMSE="< tracking = std::make_shared(config.get(), "Tracking_1C", 1, 1); //std::shared_ptr tracking = std::make_shared(config.get(), "Tracking_1C", 1, 1); @@ -372,17 +360,17 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults) // load acquisition data based on the first epoch of the true observations ASSERT_NO_THROW({ - if (true_obs_data.read_binary_obs()==false) - { - throw std::exception(); - }; - })<< "Failure reading true observables file" << std::endl; + if (true_obs_data.read_binary_obs() == false) + { + throw std::exception(); + }; + }) << "Failure reading true observables file" << std::endl; //restart the epoch counter true_obs_data.restart(); - std::cout<<"Initial Doppler [Hz]="<= (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); - - check_results_doppler(true_timestamp_s,true_Doppler_Hz,trk_timestamp_s,trk_Doppler_Hz); - check_results_codephase(true_timestamp_s,true_prn_delay_chips,trk_timestamp_s,trk_prn_delay_chips); - check_results_acc_carrier_phase(true_timestamp_s,true_acc_carrier_phase_cycles,trk_timestamp_s,trk_acc_carrier_phase_cycles); + check_results_doppler(true_timestamp_s, true_Doppler_Hz, trk_timestamp_s, trk_Doppler_Hz); + check_results_codephase(true_timestamp_s, true_prn_delay_chips, trk_timestamp_s, trk_prn_delay_chips); + check_results_acc_carrier_phase(true_timestamp_s, true_acc_carrier_phase_cycles, trk_timestamp_s, trk_acc_carrier_phase_cycles); std::cout << "Signal tracking completed in " << (end - begin) << " microseconds" << std::endl; }