From e7143f932a5950346924fdb754b499b99f4cb9cc Mon Sep 17 00:00:00 2001 From: Javier Arribas Date: Tue, 31 Oct 2017 12:36:35 +0100 Subject: [PATCH 01/60] Add includes for gnuradio-iio in block factory --- src/core/receiver/CMakeLists.txt | 102 ++++++++++++++++--------------- 1 file changed, 52 insertions(+), 50 deletions(-) diff --git a/src/core/receiver/CMakeLists.txt b/src/core/receiver/CMakeLists.txt index ae6908495..623a0dc39 100644 --- a/src/core/receiver/CMakeLists.txt +++ b/src/core/receiver/CMakeLists.txt @@ -41,6 +41,58 @@ if(ENABLE_FPGA) endif(ENABLE_FPGA) +if(Boost_VERSION LESS 105000) + add_definitions(-DOLD_BOOST=1) +endif(Boost_VERSION LESS 105000) + +if(OPENSSL_FOUND) + add_definitions( -DUSE_OPENSSL_FALLBACK=1 ) +endif(OPENSSL_FOUND) + +if(ENABLE_GN3S) + add_definitions(-DGN3S_DRIVER=1) +endif(ENABLE_GN3S) + +if(ENABLE_ARRAY) + add_definitions(-DRAW_ARRAY_DRIVER=1) +endif(ENABLE_ARRAY) + +if(ENABLE_FLEXIBAND) + add_definitions(-DFLEXIBAND_DRIVER=1) +endif(ENABLE_FLEXIBAND) + +if(ENABLE_OSMOSDR) + if(GROSMOSDR_FOUND) + add_definitions(-DOSMOSDR_DRIVER=1) + endif(GROSMOSDR_FOUND) +endif(ENABLE_OSMOSDR) + +if(ENABLE_UHD AND GNURADIO_UHD_LIBRARIES_gnuradio-uhd) + add_definitions(-DUHD_DRIVER=1) +endif(ENABLE_UHD AND GNURADIO_UHD_LIBRARIES_gnuradio-uhd) + +#Enable OpenCL if found in the system +if(OPENCL_FOUND) + message(STATUS "Adding processing blocks implemented using OpenCL" ) + add_definitions(-DOPENCL_BLOCKS=1) +else(OPENCL_FOUND) + add_definitions(-DOPENCL_BLOCKS=0) +endif(OPENCL_FOUND) + +#enable SDR Hardware based on fmcomms2 +if(ENABLE_PLUTOSDR) + add_definitions(-DPLUTOSDR_DRIVER=1) + set(OPT_RECEIVER_INCLUDE_DIRS ${OPT_RECEIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS}) +endif(ENABLE_PLUTOSDR) + +if(ENABLE_FMCOMMS2) + add_definitions(-DFMCOMMS2_DRIVER=1) + set(OPT_RECEIVER_INCLUDE_DIRS ${OPT_RECEIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS}) +endif(ENABLE_FMCOMMS2) + +add_definitions(-DGNSSSDR_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}") + + include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src/core/system_parameters @@ -86,56 +138,6 @@ include_directories( ${VOLK_GNSSSDR_INCLUDE_DIRS} ) -if(Boost_VERSION LESS 105000) - add_definitions(-DOLD_BOOST=1) -endif(Boost_VERSION LESS 105000) - -if(OPENSSL_FOUND) - add_definitions( -DUSE_OPENSSL_FALLBACK=1 ) -endif(OPENSSL_FOUND) - -if(ENABLE_GN3S) - add_definitions(-DGN3S_DRIVER=1) -endif(ENABLE_GN3S) - -if(ENABLE_ARRAY) - add_definitions(-DRAW_ARRAY_DRIVER=1) -endif(ENABLE_ARRAY) - -if(ENABLE_FLEXIBAND) - add_definitions(-DFLEXIBAND_DRIVER=1) -endif(ENABLE_FLEXIBAND) - -if(ENABLE_OSMOSDR) - if(GROSMOSDR_FOUND) - add_definitions(-DOSMOSDR_DRIVER=1) - endif(GROSMOSDR_FOUND) -endif(ENABLE_OSMOSDR) - -if(ENABLE_UHD AND GNURADIO_UHD_LIBRARIES_gnuradio-uhd) - add_definitions(-DUHD_DRIVER=1) -endif(ENABLE_UHD AND GNURADIO_UHD_LIBRARIES_gnuradio-uhd) - -#Enable OpenCL if found in the system -if(OPENCL_FOUND) - message(STATUS "Adding processing blocks implemented using OpenCL" ) - add_definitions(-DOPENCL_BLOCKS=1) -else(OPENCL_FOUND) - add_definitions(-DOPENCL_BLOCKS=0) -endif(OPENCL_FOUND) - -#enable SDR Hardware based on fmcomms2 -if(ENABLE_PLUTOSDR) - add_definitions(-DPLUTOSDR_DRIVER=1) -endif(ENABLE_PLUTOSDR) - -if(ENABLE_FMCOMMS2) - add_definitions(-DFMCOMMS2_DRIVER=1) - add_definitions(-DPLUTOSDR_DRIVER=1) -endif(ENABLE_FMCOMMS2) - -add_definitions(-DGNSSSDR_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}") - file(GLOB GNSS_RECEIVER_HEADERS "*.h") list(SORT GNSS_RECEIVER_HEADERS) file(GLOB GNSS_RECEIVER_INTERFACE_HEADERS "../interfaces/*.h") From 0054f1c5f8e9c7dde703bb5e2ce828d960adf464 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 31 Oct 2017 12:45:09 +0100 Subject: [PATCH 02/60] Fix compilation --- cmake/Modules/Findiio.cmake | 32 +++++++++++++++++++ .../signal_source/adapters/CMakeLists.txt | 2 +- .../adapters/plutosdr_signal_source.cc | 2 +- 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 cmake/Modules/Findiio.cmake diff --git a/cmake/Modules/Findiio.cmake b/cmake/Modules/Findiio.cmake new file mode 100644 index 000000000..1daf4d12e --- /dev/null +++ b/cmake/Modules/Findiio.cmake @@ -0,0 +1,32 @@ +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PC_IIO gnuradio-iio) + +FIND_PATH( + IIO_INCLUDE_DIRS + NAMES iio/api.h + HINTS $ENV{IIO_DIR}/include + ${PC_IIO_INCLUDEDIR} + PATHS ${CMAKE_INSTALL_PREFIX}/include + /usr/local/include + /usr/include + ${CMAKE_INSTALL_PREFIX}/include/gnuradio + /usr/local/include/gnuradio + /usr/include/gnuradio +) + +FIND_LIBRARY( + IIO_LIBRARIES + NAMES gnuradio-iio + HINTS $ENV{IIO_DIR}/lib + ${PC_IIO_LIBDIR} + PATHS ${CMAKE_INSTALL_PREFIX}/lib + ${CMAKE_INSTALL_PREFIX}/lib64 + /usr/local/lib + /usr/local/lib64 + /usr/lib + /usr/lib64 +) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(IIO DEFAULT_MSG IIO_LIBRARIES IIO_INCLUDE_DIRS) +MARK_AS_ADVANCED(IIO_LIBRARIES IIO_INCLUDE_DIRS) diff --git a/src/algorithms/signal_source/adapters/CMakeLists.txt b/src/algorithms/signal_source/adapters/CMakeLists.txt index 009f56433..822b483d4 100644 --- a/src/algorithms/signal_source/adapters/CMakeLists.txt +++ b/src/algorithms/signal_source/adapters/CMakeLists.txt @@ -47,7 +47,7 @@ if(ENABLE_FMCOMMS2) else(NOT IIO_FOUND) set(OPT_LIBRARIES ${OPT_LIBRARIES} ${IIO_LIBRARIES}) set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS}) - set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} fmcomms2_signal_source.cc plutosdr_signal_source.cc) + set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} fmcomms2_signal_source.cc) endif(NOT IIO_FOUND) endif(ENABLE_FMCOMMS2) diff --git a/src/algorithms/signal_source/adapters/plutosdr_signal_source.cc b/src/algorithms/signal_source/adapters/plutosdr_signal_source.cc index 64d59a113..d0926dc56 100644 --- a/src/algorithms/signal_source/adapters/plutosdr_signal_source.cc +++ b/src/algorithms/signal_source/adapters/plutosdr_signal_source.cc @@ -51,7 +51,7 @@ PlutosdrSignalSource::PlutosdrSignalSource(ConfigurationInterface* configuration std::string default_dump_file = "./data/signal_source.dat"; uri_ = configuration->property(role + ".device_address", std::string("192.168.2.1")); freq_ = configuration->property(role + ".freq", GPS_L1_FREQ_HZ); - sample_rate_ configuration->property(role + ".sampling_frequency", 3000000); + sample_rate_ = configuration->property(role + ".sampling_frequency", 3000000); bandwidth_ = configuration->property(role + ".bandwidth", 2000000); buffer_size_ = configuration->property(role + ".buffer_size", 0xA0000); decimation_ = configuration->property(role + ".decimation", 1); From 462de44be4c6b5cedb7138527f1d994e1d3eb958 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 31 Oct 2017 13:05:15 +0100 Subject: [PATCH 03/60] Fix compilation --- cmake/Modules/Findiio.cmake | 5 +---- .../signal_source/adapters/fmcomms2_signal_source.h | 4 ++-- .../signal_source/adapters/plutosdr_signal_source.h | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/cmake/Modules/Findiio.cmake b/cmake/Modules/Findiio.cmake index 1daf4d12e..817e9f9f7 100644 --- a/cmake/Modules/Findiio.cmake +++ b/cmake/Modules/Findiio.cmake @@ -3,15 +3,12 @@ PKG_CHECK_MODULES(PC_IIO gnuradio-iio) FIND_PATH( IIO_INCLUDE_DIRS - NAMES iio/api.h + NAMES gnuradio/iio/api.h HINTS $ENV{IIO_DIR}/include ${PC_IIO_INCLUDEDIR} PATHS ${CMAKE_INSTALL_PREFIX}/include /usr/local/include /usr/include - ${CMAKE_INSTALL_PREFIX}/include/gnuradio - /usr/local/include/gnuradio - /usr/include/gnuradio ) FIND_LIBRARY( diff --git a/src/algorithms/signal_source/adapters/fmcomms2_signal_source.h b/src/algorithms/signal_source/adapters/fmcomms2_signal_source.h index 0672770f5..35c1e2541 100644 --- a/src/algorithms/signal_source/adapters/fmcomms2_signal_source.h +++ b/src/algorithms/signal_source/adapters/fmcomms2_signal_source.h @@ -1,6 +1,6 @@ /*! * \file fmcomms2_signal_source.h - * \brief Interface to use SDR hardware based in FMCOMMS2 driver from analog + * \brief Interface to use SDR hardware based in FMCOMMS2 driver from analog * devices, for example FMCOMMS4 and ADALM-PLUTO (PlutoSdr) * \author Rodrigo Muñoz, 2017. rmunozl(at)inacap.cl * @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include "gnss_block_interface.h" class ConfigurationInterface; diff --git a/src/algorithms/signal_source/adapters/plutosdr_signal_source.h b/src/algorithms/signal_source/adapters/plutosdr_signal_source.h index 79a310089..9bbdb4511 100644 --- a/src/algorithms/signal_source/adapters/plutosdr_signal_source.h +++ b/src/algorithms/signal_source/adapters/plutosdr_signal_source.h @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include "gnss_block_interface.h" class ConfigurationInterface; From c70f7b504add41674b8566828cd96f33a3cf5f6a Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 31 Oct 2017 15:40:14 +0100 Subject: [PATCH 04/60] Fix RINEX version --- CMakeLists.txt | 2 +- src/algorithms/PVT/libs/rinex_printer.cc | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 30d4f6eaf..042f386db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,7 @@ option(ENABLE_FLEXIBAND "Enable the use of the signal source adater for the Tele option(ENABLE_ARRAY "Enable the use of CTTC's antenna array front-end as signal source (experimental)" OFF) option(ENABLE_GN3S "Enable the use of the GN3S dongle as signal source (experimental)" OFF) option(ENABLE_PLUTOSDR "Enable the use of ADALM-PLUTO Evaluation Boards (Analog Devices Inc.), requires gr-iio" OFF) -option(ENABLE_FMCOMMS2 "Enable the use of FMCOMMS4-EBZ + ZedBoard hardware" OFF) +option(ENABLE_FMCOMMS2 "Enable the use of FMCOMMS4-EBZ + ZedBoard hardware, requires gr-iio" OFF) # Performance analysis tools option(ENABLE_GPERFTOOLS "Enable linking to Gperftools libraries (tcmalloc and profiler)" OFF) diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index 4631270d2..7de3391c9 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -182,8 +182,15 @@ Rinex_Printer::Rinex_Printer(int conf_version) if(conf_version != 0) { if(conf_version == 2) - version = 2; - stringVersion = "2.11"; + { + version = 2; + stringVersion = "2.11"; + } + if(conf_version == 3) + { + version = 3; + stringVersion = "3.02"; + } } numberTypesObservations = 4; // Number of available types of observable in the system From 0531c0a0ed19580baa510881dd61e4e430102e0b Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 30 Oct 2017 17:47:55 +0100 Subject: [PATCH 05/60] Observables system test GNSS-SDR space Added a new observables system test --- src/tests/CMakeLists.txt | 14 + .../obs_gps_l1_space_system_test.cc | 573 ++++++++++++++++++ 2 files changed, 587 insertions(+) create mode 100644 src/tests/system-tests/obs_gps_l1_space_system_test.cc diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 651713998..5d988c58d 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -483,10 +483,13 @@ if(ENABLE_SYSTEM_TESTING) if(GPSTK_FOUND OR OWN_GPSTK) add_executable(obs_gps_l1_system_test ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/obs_gps_l1_system_test.cc) + add_executable(obs_gps_l1_space_system_test ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/obs_gps_l1_space_system_test.cc) if(NOT ${GTEST_DIR_LOCAL}) add_dependencies(obs_gps_l1_system_test gtest-${gtest_RELEASE} ) + add_dependencies(obs_gps_l1_space_system_test gtest-${gtest_RELEASE} ) else(NOT ${GTEST_DIR_LOCAL}) add_dependencies(obs_gps_l1_system_test gtest) + add_dependencies(obs_gps_l1_space_system_test gtest) endif(NOT ${GTEST_DIR_LOCAL}) include_directories(${GPSTK_INCLUDE_DIRS}) target_link_libraries(obs_gps_l1_system_test ${GFlags_LIBS} @@ -495,6 +498,13 @@ if(ENABLE_SYSTEM_TESTING) gnss_sp_libs gnss_rx ${gpstk_libs}) + + target_link_libraries(obs_gps_l1_space_system_test ${GFlags_LIBS} + ${GLOG_LIBRARIES} + ${GTEST_LIBRARIES} + gnss_sp_libs + gnss_rx + ${gpstk_libs}) if(ENABLE_INSTALL_TESTS) if(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) @@ -505,6 +515,10 @@ if(ENABLE_SYSTEM_TESTING) add_custom_command(TARGET obs_gps_l1_system_test POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_SOURCE_DIR}/install/$ ) + add_custom_command(TARGET obs_gps_l1_space_system_test POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ + ${CMAKE_SOURCE_DIR}/install/$ ) + endif(ENABLE_INSTALL_TESTS) endif(GPSTK_FOUND OR OWN_GPSTK) endif(ENABLE_SYSTEM_TESTING_EXTRA) diff --git a/src/tests/system-tests/obs_gps_l1_space_system_test.cc b/src/tests/system-tests/obs_gps_l1_space_system_test.cc new file mode 100644 index 000000000..69c21a5a3 --- /dev/null +++ b/src/tests/system-tests/obs_gps_l1_space_system_test.cc @@ -0,0 +1,573 @@ +/*! + * \file obs_gps_l1_space_system_test.cc + * \brief This class implements a test for the validation of generated observables. + * \author Carles Fernandez-Prades, 2016. cfernandez(at)cttc.es + * Antonio Ramos, 2017. antonio.ramos(at)cttc.es + * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "RinexUtilities.hpp" +#include "Rinex3ObsBase.hpp" +#include "Rinex3ObsData.hpp" +#include "Rinex3ObsHeader.hpp" +#include "Rinex3ObsStream.hpp" +#include "concurrent_map.h" +#include "concurrent_queue.h" +#include "control_thread.h" +#include "file_configuration.h" +#include "signal_generator_flags.h" + + +// For GPS NAVIGATION (L1) +concurrent_queue global_gps_acq_assist_queue; +concurrent_map global_gps_acq_assist_map; + +DEFINE_string(configuration_file_space, "./default_configuration.conf", "Path of configuration file"); + +class ObsGpsL1SpaceSystemTest: public ::testing::Test +{ +public: + //std::string generator_binary; + //std::string p1; + //std::string p2; + //std::string p3; + //std::string p4; + //std::string p5; + + //const double baseband_sampling_freq = 2.6e6; + + std::string filename_rinex_obs = FLAGS_filename_rinex_obs; + //std::string filename_raw_data = FLAGS_filename_raw_data; + std::string generated_rinex_obs; + std::string configuration_file_ = FLAGS_configuration_file_space; + //int configure_generator(); + //int generate_signal(); + int configure_receiver(); + int run_receiver(); + void check_results(); + bool check_valid_rinex_nav(std::string filename); // return true if the file is a valid Rinex navigation file. + bool check_valid_rinex_obs(std::string filename); // return true if the file is a valid Rinex observation file. + double compute_stdev(const std::vector & vec); + + std::shared_ptr config; +}; + + +bool ObsGpsL1SpaceSystemTest::check_valid_rinex_nav(std::string filename) +{ + bool res = false; + res = gpstk::isRinexNavFile(filename); + return res; +} + + +double ObsGpsL1SpaceSystemTest::compute_stdev(const std::vector & vec) +{ + double sum__ = std::accumulate(vec.begin(), vec.end(), 0.0); + double mean__ = sum__ / vec.size(); + double accum__ = 0.0; + std::for_each (std::begin(vec), std::end(vec), [&](const double d) { + accum__ += (d - mean__) * (d - mean__); + }); + double stdev__ = std::sqrt(accum__ / (vec.size() - 1)); + return stdev__; +} + + +bool ObsGpsL1SpaceSystemTest::check_valid_rinex_obs(std::string filename) +{ + bool res = false; + res = gpstk::isRinex3ObsFile(filename); + return res; +} + +/* +int ObsGpsL1SpaceSystemTest::configure_generator() +{ + // 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(std::min(FLAGS_duration * 10, 3000)); + if(FLAGS_duration > 300) std::cout << "WARNING: Duration has been set to its maximum value of 300 s" << std::endl; + } + 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; // 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] + return 0; +} +*/ +/* +int ObsGpsL1SpaceSystemTest::generate_signal() +{ + pid_t wait_result; + int child_status; + + char *const parmList[] = { &generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0], NULL }; + + int pid; + if ((pid = fork()) == -1) + perror("fork error"); + else if (pid == 0) + { + execv(&generator_binary[0], parmList); + std::cout << "Return not expected. Must be an execv error." << std::endl; + std::terminate(); + } + + wait_result = waitpid(pid, &child_status, 0); + if (wait_result == -1) perror("waitpid error"); + EXPECT_EQ(true, check_valid_rinex_obs(filename_rinex_obs)); + std::cout << "Signal and Observables RINEX files created." << std::endl; + return 0; +} +*/ + +int ObsGpsL1SpaceSystemTest::configure_receiver() +{ + config = std::make_shared(configuration_file_); + return 0; +} + + +int ObsGpsL1SpaceSystemTest::run_receiver() +{ + std::shared_ptr control_thread; + control_thread = std::make_shared(config); + // start receiver + try + { + control_thread->run(); + } + catch(const boost::exception & e) + { + std::cout << "Boost exception: " << boost::diagnostic_information(e); + } + catch(const std::exception & ex) + { + std::cout << "STD exception: " << ex.what(); + } + // Get the name of the RINEX obs file generated by the receiver + std::this_thread::sleep_for(std::chrono::milliseconds(2000)); + FILE *fp; + std::string argum2 = std::string("/bin/ls *O | grep GSDR | tail -1"); + char buffer[1035]; + fp = popen(&argum2[0], "r"); + if (fp == NULL) + { + std::cout << "Failed to run command: " << argum2 << std::endl; + return -1; + } + while (fgets(buffer, sizeof(buffer), fp) != NULL) + { + std::string aux = std::string(buffer); + ObsGpsL1SpaceSystemTest::generated_rinex_obs = aux.erase(aux.length() - 1, 1); + } + pclose(fp); + return 0; +} + + +void ObsGpsL1SpaceSystemTest::check_results() +{ + std::vector> > pseudorange_ref(33); + std::vector> > carrierphase_ref(33); + std::vector> > doppler_ref(33); + + std::vector> > pseudorange_meas(33); + std::vector> > carrierphase_meas(33); + std::vector> > doppler_meas(33); + + // Open and read reference RINEX observables file + try + { + gpstk::Rinex3ObsStream r_ref(FLAGS_filename_rinex_obs); + r_ref.exceptions(std::ios::failbit); + gpstk::Rinex3ObsData r_ref_data; + gpstk::Rinex3ObsHeader r_ref_header; + + gpstk::RinexDatum dataobj; + + r_ref >> r_ref_header; + + while (r_ref >> r_ref_data) + { + for (int myprn = 1; myprn < 33; myprn++) + { + gpstk::SatID prn( myprn, gpstk::SatID::systemGPS ); + gpstk::CommonTime time = r_ref_data.time; + double sow(static_cast(time).sow); + + gpstk::Rinex3ObsData::DataMap::iterator pointer = r_ref_data.obs.find(prn); + if( pointer == r_ref_data.obs.end() ) + { + // PRN not present; do nothing + } + else + { + dataobj = r_ref_data.getObs(prn, "C1C", r_ref_header); + double P1 = dataobj.data; + std::pair pseudo(sow,P1); + pseudorange_ref.at(myprn).push_back(pseudo); + + dataobj = r_ref_data.getObs(prn, "L1C", r_ref_header); + double L1 = dataobj.data; + std::pair carrier(sow, L1); + carrierphase_ref.at(myprn).push_back(carrier); + + dataobj = r_ref_data.getObs(prn, "D1C", r_ref_header); + double D1 = dataobj.data; + std::pair doppler(sow, D1); + doppler_ref.at(myprn).push_back(doppler); + } // End of 'if( pointer == roe.obs.end() )' + } // end for + } // end while + } // End of 'try' block + catch(const gpstk::FFStreamError& e) + { + std::cout << e; + exit(1); + } + catch(const gpstk::Exception& e) + { + std::cout << e; + exit(1); + } + catch (...) + { + std::cout << "unknown error. I don't feel so well..." << std::endl; + exit(1); + } + + try + { + std::string arg2_gen = std::string("./") + ObsGpsL1SpaceSystemTest::generated_rinex_obs; + gpstk::Rinex3ObsStream r_meas(arg2_gen); + r_meas.exceptions(std::ios::failbit); + gpstk::Rinex3ObsData r_meas_data; + gpstk::Rinex3ObsHeader r_meas_header; + gpstk::RinexDatum dataobj; + + r_meas >> r_meas_header; + + while (r_meas >> r_meas_data) + { + for (int myprn = 1; myprn < 33; myprn++) + { + gpstk::SatID prn( myprn, gpstk::SatID::systemGPS ); + gpstk::CommonTime time = r_meas_data.time; + double sow(static_cast(time).sow); + + gpstk::Rinex3ObsData::DataMap::iterator pointer = r_meas_data.obs.find(prn); + if( pointer == r_meas_data.obs.end() ) + { + // PRN not present; do nothing + } + else + { + dataobj = r_meas_data.getObs(prn, "C1C", r_meas_header); + double P1 = dataobj.data; + std::pair pseudo(sow, P1); + pseudorange_meas.at(myprn).push_back(pseudo); + + dataobj = r_meas_data.getObs(prn, "L1C", r_meas_header); + double L1 = dataobj.data; + std::pair carrier(sow, L1); + carrierphase_meas.at(myprn).push_back(carrier); + + dataobj = r_meas_data.getObs(prn, "D1C", r_meas_header); + double D1 = dataobj.data; + std::pair doppler(sow, D1); + doppler_meas.at(myprn).push_back(doppler); + } // End of 'if( pointer == roe.obs.end() )' + } // end for + } // end while + } // End of 'try' block + catch(const gpstk::FFStreamError& e) + { + std::cout << e; + exit(1); + } + catch(const gpstk::Exception& e) + { + std::cout << e; + exit(1); + } + catch (...) + { + std::cout << "unknown error. I don't feel so well..." << std::endl; + exit(1); + } + + // Time alignment + std::vector> > pseudorange_ref_aligned(33); + std::vector> > carrierphase_ref_aligned(33); + std::vector> > doppler_ref_aligned(33); + + std::vector> >::iterator iter; + std::vector>::iterator it; + std::vector>::iterator it2; + + std::vector> pr_diff(33); + std::vector> cp_diff(33); + std::vector> doppler_diff(33); + + std::vector>::iterator iter_diff; + std::vector::iterator iter_v; + + int prn_id = 0; + for(iter = pseudorange_ref.begin(); iter != pseudorange_ref.end(); iter++) + { + for(it = iter->begin(); it != iter->end(); it++) + { + // If a measure exists for this sow, store it + for(it2 = pseudorange_meas.at(prn_id).begin(); it2 != pseudorange_meas.at(prn_id).end(); it2++) + { + if(std::abs(it->first - it2->first) < 0.01) // store measures closer than 10 ms. + { + pseudorange_ref_aligned.at(prn_id).push_back(*it); + pr_diff.at(prn_id).push_back(it->second - it2->second ); + //std::cout << "Sat " << prn_id << ": " << "PR_ref=" << it->second << " PR_meas=" << it2->second << " Diff:" << it->second - it2->second << std::endl; + } + } + } + prn_id++; + } + + prn_id = 0; + for(iter = carrierphase_ref.begin(); iter != carrierphase_ref.end(); iter++) + { + for(it = iter->begin(); it != iter->end(); it++) + { + // If a measure exists for this sow, store it + for(it2 = carrierphase_meas.at(prn_id).begin(); it2 != carrierphase_meas.at(prn_id).end(); it2++) + { + if(std::abs(it->first - it2->first) < 0.01) // store measures closer than 10 ms. + { + carrierphase_ref_aligned.at(prn_id).push_back(*it); + cp_diff.at(prn_id).push_back(it->second - it2->second ); + // std::cout << "Sat " << prn_id << ": " << "Carrier_ref=" << it->second << " Carrier_meas=" << it2->second << " Diff:" << it->second - it2->second << std::endl; + } + } + } + prn_id++; + } + prn_id = 0; + for(iter = doppler_ref.begin(); iter != doppler_ref.end(); iter++) + { + for(it = iter->begin(); it != iter->end(); it++) + { + // If a measure exists for this sow, store it + for(it2 = doppler_meas.at(prn_id).begin(); it2 != doppler_meas.at(prn_id).end(); it2++) + { + if(std::abs(it->first - it2->first) < 0.01) // store measures closer than 10 ms. + { + doppler_ref_aligned.at(prn_id).push_back(*it); + doppler_diff.at(prn_id).push_back(it->second - it2->second ); + } + } + } + prn_id++; + } + + // Compute pseudorange error + prn_id = 0; + std::vector mean_pr_diff_v; + for(iter_diff = pr_diff.begin(); iter_diff != pr_diff.end(); iter_diff++) + { + // For each satellite with reference and measurements aligned in time + int number_obs = 0; + double mean_diff = 0.0; + for(iter_v = iter_diff->begin(); iter_v != iter_diff->end(); iter_v++) + { + mean_diff = mean_diff + *iter_v; + number_obs = number_obs + 1; + } + if(number_obs > 0) + { + mean_diff = mean_diff / number_obs; + mean_pr_diff_v.push_back(mean_diff); + std::cout << "-- Mean pseudorange difference for sat " << prn_id << ": " << mean_diff; + double stdev_ = compute_stdev(*iter_diff); + std::cout << " +/- " << stdev_ ; + std::cout << " [m]" << std::endl; + } + else + { + mean_diff = 0.0; + } + + prn_id++; + } + double stdev_pr = compute_stdev(mean_pr_diff_v); + std::cout << "Pseudorange diff error stdev = " << stdev_pr << " [m]" << std::endl; + ASSERT_LT(stdev_pr, 10.0); + + // Compute carrier phase error + prn_id = 0; + std::vector mean_cp_diff_v; + for(iter_diff = cp_diff.begin(); iter_diff != cp_diff.end(); iter_diff++) + { + // For each satellite with reference and measurements aligned in time + int number_obs = 0; + double mean_diff = 0.0; + for(iter_v = iter_diff->begin(); iter_v != iter_diff->end(); iter_v++) + { + mean_diff = mean_diff + *iter_v; + number_obs = number_obs + 1; + } + if(number_obs > 0) + { + mean_diff = mean_diff / number_obs; + mean_cp_diff_v.push_back(mean_diff); + std::cout << "-- Mean carrier phase difference for sat " << prn_id << ": " << mean_diff; + double stdev_pr_ = compute_stdev(*iter_diff); + std::cout << " +/- " << stdev_pr_ << " whole cycles (19 cm)" << std::endl; + } + else + { + mean_diff = 0.0; + } + + prn_id++; + } + + // Compute Doppler error + prn_id = 0; + std::vector mean_doppler_v; + for(iter_diff = doppler_diff.begin(); iter_diff != doppler_diff.end(); iter_diff++) + { + // For each satellite with reference and measurements aligned in time + int number_obs = 0; + double mean_diff = 0.0; + for(iter_v = iter_diff->begin(); iter_v != iter_diff->end(); iter_v++) + { + //std::cout << *iter_v << std::endl; + mean_diff = mean_diff + *iter_v; + number_obs = number_obs + 1; + } + if(number_obs > 0) + { + mean_diff = mean_diff / number_obs; + mean_doppler_v.push_back(mean_diff); + std::cout << "-- Mean Doppler difference for sat " << prn_id << ": " << mean_diff << " [Hz]" << std::endl; + } + else + { + mean_diff = 0.0; + } + + prn_id++; + } + + double stdev_dp = compute_stdev(mean_doppler_v); + std::cout << "Doppler error stdev = " << stdev_dp << " [Hz]" << std::endl; + ASSERT_LT(stdev_dp, 10.0); +} + + +TEST_F(ObsGpsL1SpaceSystemTest, Observables_system_test) +{ + std::cout << "Validating input RINEX obs (TRUE) file: " << filename_rinex_obs << " ..." << std::endl; + bool is_rinex_obs_valid = check_valid_rinex_obs(filename_rinex_obs); + ASSERT_EQ(true, is_rinex_obs_valid) << "The RINEX observation file " << filename_rinex_obs << " is not well formed."; + std::cout << "The file is valid." << std::endl; + + // Configure the signal generator + //configure_generator(); + + // Generate signal raw signal samples and observations RINEX file + /* + if(!FLAGS_disable_generator) + { + generate_signal(); + } + + std::cout << "Validating generated reference RINEX obs file: " << FLAGS_filename_rinex_obs << " ..." << std::endl; + bool is_gen_rinex_obs_valid = check_valid_rinex_obs( "./" + FLAGS_filename_rinex_obs); + EXPECT_EQ(true, is_gen_rinex_obs_valid) << "The RINEX observation file " << FLAGS_filename_rinex_obs << ", generated by gnss-sim, is not well formed."; + std::cout << "The file is valid." << std::endl; + */ + // Configure receiver + configure_receiver(); + + // Run the receiver + ASSERT_EQ( run_receiver(), 0) << "Problem executing the software-defined signal generator"; + + std::cout << "Validating RINEX obs file obtained by GNSS-SDR: " << ObsGpsL1SpaceSystemTest::generated_rinex_obs << " ..." << std::endl; + bool is_gen_rinex_obs_valid = check_valid_rinex_obs( "./" + ObsGpsL1SpaceSystemTest::generated_rinex_obs); + ASSERT_EQ(true, is_gen_rinex_obs_valid) << "The RINEX observation file " << ObsGpsL1SpaceSystemTest::generated_rinex_obs << ", generated by GNSS-SDR, is not well formed."; + std::cout << "The file is valid." << std::endl; + + // Check results + check_results(); +} + + +int main(int argc, char **argv) +{ + std::cout << "Running GNSS-SDR in Space Observables validation test..." << std::endl; + int res = 0; + try + { + testing::InitGoogleTest(&argc, argv); + } + catch(...) {} // catch the "testing::internal::::ClassUniqueToAlwaysTrue" from gtest + + google::ParseCommandLineFlags(&argc, &argv, true); + google::InitGoogleLogging(argv[0]); + + // Run the Tests + try + { + res = RUN_ALL_TESTS(); + } + catch(...) + { + LOG(WARNING) << "Unexpected catch"; + } + google::ShutDownCommandLineFlags(); + return res; +} From 647a27a1924c39ef59518589ac2843c7703d9c9a Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 31 Oct 2017 16:02:18 +0100 Subject: [PATCH 06/60] Avoid possible duplication of linked libraries Add installation pointers for gnuradio-iio --- .../signal_source/adapters/CMakeLists.txt | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/algorithms/signal_source/adapters/CMakeLists.txt b/src/algorithms/signal_source/adapters/CMakeLists.txt index 822b483d4..870d6537b 100644 --- a/src/algorithms/signal_source/adapters/CMakeLists.txt +++ b/src/algorithms/signal_source/adapters/CMakeLists.txt @@ -21,34 +21,40 @@ list(SORT SIGNAL_SOURCE_ADAPTER_HEADERS) # Optional drivers +if(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2) + find_package(iio REQUIRED) + if(NOT IIO_FOUND) + message(STATUS "gnuradio-iio not found, its installation is required.") + message(STATUS "Please build and install the following projects:") + message(STATUS " * libiio from https://github.com/analogdevicesinc/libiio") + message(STATUS " * libad9361-iio from https://github.com/analogdevicesinc/libad9361-iio") + message(STATUS " * gnuradio-iio from https://github.com/analogdevicesinc/gr-iio") + message(FATAL_ERROR "gnuradio-iio required for building gnss-sdr with this option enabled") + endif(NOT IIO_FOUND) + set(OPT_LIBRARIES ${OPT_LIBRARIES} ${IIO_LIBRARIES}) + set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS}) +endif(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2) + if(ENABLE_PLUTOSDR) ############################################## # ADALM-PLUTO (Analog Devices Inc.) ############################################## - find_package(iio REQUIRED) - if(NOT IIO_FOUND) - message("gnuradio-iio not found, installation is required") - message(FATAL_ERROR "gnuradio-iio required for building gnss-sdr with this option enabled") - else(NOT IIO_FOUND) - set(OPT_LIBRARIES ${OPT_LIBRARIES} ${IIO_LIBRARIES}) - set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS}) + if(IIO_FOUND) + #set(OPT_LIBRARIES ${OPT_LIBRARIES} ${IIO_LIBRARIES}) + #set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS}) set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} plutosdr_signal_source.cc) - endif(NOT IIO_FOUND) + endif(IIO_FOUND) endif(ENABLE_PLUTOSDR) if(ENABLE_FMCOMMS2) ############################################### # FMCOMMS2 based SDR Hardware ############################################### - find_package(iio REQUIRED) - if(NOT IIO_FOUND) - message("gnuradio-iio not found, installation is required") - message(FATAL_ERROR "gnuradio-iio required for building gnss-sdr with this option enabled") - else(NOT IIO_FOUND) - set(OPT_LIBRARIES ${OPT_LIBRARIES} ${IIO_LIBRARIES}) - set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS}) + if(IIO_FOUND) + #set(OPT_LIBRARIES ${OPT_LIBRARIES} ${IIO_LIBRARIES}) + #set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS}) set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} fmcomms2_signal_source.cc) - endif(NOT IIO_FOUND) + endif(IIO_FOUND) endif(ENABLE_FMCOMMS2) if(ENABLE_GN3S) @@ -134,7 +140,7 @@ set(SIGNAL_SOURCE_ADAPTER_SOURCES file_signal_source.cc gen_signal_source.cc nsr_file_signal_source.cc spir_file_signal_source.cc - rtl_tcp_signal_source.cc + rtl_tcp_signal_source.cc ${OPT_DRIVER_SOURCES} ) From afb3aa14f62050bfcd215fc145d3a094198c85dd Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 31 Oct 2017 16:03:41 +0100 Subject: [PATCH 07/60] Remove commented lines --- src/algorithms/signal_source/adapters/CMakeLists.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/algorithms/signal_source/adapters/CMakeLists.txt b/src/algorithms/signal_source/adapters/CMakeLists.txt index 870d6537b..bac9aee3d 100644 --- a/src/algorithms/signal_source/adapters/CMakeLists.txt +++ b/src/algorithms/signal_source/adapters/CMakeLists.txt @@ -35,28 +35,27 @@ if(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2) set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS}) endif(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2) + if(ENABLE_PLUTOSDR) ############################################## # ADALM-PLUTO (Analog Devices Inc.) ############################################## if(IIO_FOUND) - #set(OPT_LIBRARIES ${OPT_LIBRARIES} ${IIO_LIBRARIES}) - #set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS}) set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} plutosdr_signal_source.cc) endif(IIO_FOUND) endif(ENABLE_PLUTOSDR) + if(ENABLE_FMCOMMS2) ############################################### # FMCOMMS2 based SDR Hardware ############################################### if(IIO_FOUND) - #set(OPT_LIBRARIES ${OPT_LIBRARIES} ${IIO_LIBRARIES}) - #set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS}) set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} fmcomms2_signal_source.cc) endif(IIO_FOUND) endif(ENABLE_FMCOMMS2) + if(ENABLE_GN3S) ############################################## # GN3S (USB dongle) From dcedbf25d76e53bebc2d59a4ad3868e511139530 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 31 Oct 2017 17:01:56 +0100 Subject: [PATCH 08/60] Improving gps_l1_obs_space_system_test Improved checking algorithm --- .../obs_gps_l1_space_system_test.cc | 109 +++--------------- 1 file changed, 19 insertions(+), 90 deletions(-) diff --git a/src/tests/system-tests/obs_gps_l1_space_system_test.cc b/src/tests/system-tests/obs_gps_l1_space_system_test.cc index 69c21a5a3..db1785136 100644 --- a/src/tests/system-tests/obs_gps_l1_space_system_test.cc +++ b/src/tests/system-tests/obs_gps_l1_space_system_test.cc @@ -63,40 +63,19 @@ DEFINE_string(configuration_file_space, "./default_configuration.conf", "Path of class ObsGpsL1SpaceSystemTest: public ::testing::Test { public: - //std::string generator_binary; - //std::string p1; - //std::string p2; - //std::string p3; - //std::string p4; - //std::string p5; - - //const double baseband_sampling_freq = 2.6e6; - std::string filename_rinex_obs = FLAGS_filename_rinex_obs; - //std::string filename_raw_data = FLAGS_filename_raw_data; std::string generated_rinex_obs; std::string configuration_file_ = FLAGS_configuration_file_space; - //int configure_generator(); - //int generate_signal(); int configure_receiver(); int run_receiver(); void check_results(); - bool check_valid_rinex_nav(std::string filename); // return true if the file is a valid Rinex navigation file. - bool check_valid_rinex_obs(std::string filename); // return true if the file is a valid Rinex observation file. + bool check_valid_rinex_obs(std::string filename, int rinex_ver); // return true if the file is a valid Rinex observation file. double compute_stdev(const std::vector & vec); std::shared_ptr config; }; -bool ObsGpsL1SpaceSystemTest::check_valid_rinex_nav(std::string filename) -{ - bool res = false; - res = gpstk::isRinexNavFile(filename); - return res; -} - - double ObsGpsL1SpaceSystemTest::compute_stdev(const std::vector & vec) { double sum__ = std::accumulate(vec.begin(), vec.end(), 0.0); @@ -110,64 +89,29 @@ double ObsGpsL1SpaceSystemTest::compute_stdev(const std::vector & vec) } -bool ObsGpsL1SpaceSystemTest::check_valid_rinex_obs(std::string filename) +bool ObsGpsL1SpaceSystemTest::check_valid_rinex_obs(std::string filename, int rinex_ver) { bool res = false; - res = gpstk::isRinex3ObsFile(filename); + if(rinex_ver == 2) + { + res = gpstk::isRinexObsFile(filename); + } + if(rinex_ver == 3) + { + res = gpstk::isRinex3ObsFile(filename); + } return res; } -/* -int ObsGpsL1SpaceSystemTest::configure_generator() -{ - // 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(std::min(FLAGS_duration * 10, 3000)); - if(FLAGS_duration > 300) std::cout << "WARNING: Duration has been set to its maximum value of 300 s" << std::endl; - } - 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; // 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] - return 0; -} -*/ -/* -int ObsGpsL1SpaceSystemTest::generate_signal() -{ - pid_t wait_result; - int child_status; - - char *const parmList[] = { &generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0], NULL }; - - int pid; - if ((pid = fork()) == -1) - perror("fork error"); - else if (pid == 0) - { - execv(&generator_binary[0], parmList); - std::cout << "Return not expected. Must be an execv error." << std::endl; - std::terminate(); - } - - wait_result = waitpid(pid, &child_status, 0); - if (wait_result == -1) perror("waitpid error"); - EXPECT_EQ(true, check_valid_rinex_obs(filename_rinex_obs)); - std::cout << "Signal and Observables RINEX files created." << std::endl; - return 0; -} -*/ - int ObsGpsL1SpaceSystemTest::configure_receiver() { config = std::make_shared(configuration_file_); + int d_rinex_ver = config->property("PVT.rinex_version", 0); + if(d_rinex_ver != 2) + { + std::cout << "Invalid RINEX version. Set PVT.rinex_ver=2 in configuration file." << std::endl; + std::cout << "GPSTk does not work with RINEX v. 3.02." << std::endl; + } return 0; } @@ -511,25 +455,10 @@ void ObsGpsL1SpaceSystemTest::check_results() TEST_F(ObsGpsL1SpaceSystemTest, Observables_system_test) { std::cout << "Validating input RINEX obs (TRUE) file: " << filename_rinex_obs << " ..." << std::endl; - bool is_rinex_obs_valid = check_valid_rinex_obs(filename_rinex_obs); - ASSERT_EQ(true, is_rinex_obs_valid) << "The RINEX observation file " << filename_rinex_obs << " is not well formed."; + bool is_rinex_obs_valid = check_valid_rinex_obs(filename_rinex_obs, 3); + ASSERT_EQ(true, is_rinex_obs_valid) << "The RINEX observation file " << filename_rinex_obs << " is not well formed. Only RINEX v. 3.00 files are allowed"; std::cout << "The file is valid." << std::endl; - // Configure the signal generator - //configure_generator(); - - // Generate signal raw signal samples and observations RINEX file - /* - if(!FLAGS_disable_generator) - { - generate_signal(); - } - - std::cout << "Validating generated reference RINEX obs file: " << FLAGS_filename_rinex_obs << " ..." << std::endl; - bool is_gen_rinex_obs_valid = check_valid_rinex_obs( "./" + FLAGS_filename_rinex_obs); - EXPECT_EQ(true, is_gen_rinex_obs_valid) << "The RINEX observation file " << FLAGS_filename_rinex_obs << ", generated by gnss-sim, is not well formed."; - std::cout << "The file is valid." << std::endl; - */ // Configure receiver configure_receiver(); @@ -537,7 +466,7 @@ TEST_F(ObsGpsL1SpaceSystemTest, Observables_system_test) ASSERT_EQ( run_receiver(), 0) << "Problem executing the software-defined signal generator"; std::cout << "Validating RINEX obs file obtained by GNSS-SDR: " << ObsGpsL1SpaceSystemTest::generated_rinex_obs << " ..." << std::endl; - bool is_gen_rinex_obs_valid = check_valid_rinex_obs( "./" + ObsGpsL1SpaceSystemTest::generated_rinex_obs); + bool is_gen_rinex_obs_valid = check_valid_rinex_obs( "./" + ObsGpsL1SpaceSystemTest::generated_rinex_obs, 2); ASSERT_EQ(true, is_gen_rinex_obs_valid) << "The RINEX observation file " << ObsGpsL1SpaceSystemTest::generated_rinex_obs << ", generated by GNSS-SDR, is not well formed."; std::cout << "The file is valid." << std::endl; From dceb15acdc4d8783434cbb26daea9251318c0d5d Mon Sep 17 00:00:00 2001 From: Antonio Ramos Date: Tue, 31 Oct 2017 20:28:34 +0100 Subject: [PATCH 09/60] Baseband downconverting PulseBlanking Added an IF to baseband downconverting stage previous to the pulse blanking filter --- .../adapters/pulse_blanking_filter.cc | 26 +++++++++++++++++-- .../adapters/pulse_blanking_filter.h | 2 ++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc b/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc index e6bcc2632..454434baa 100644 --- a/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc +++ b/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc @@ -32,6 +32,7 @@ #include #include #include "configuration_interface.h" +#include using google::LogMessage; @@ -71,7 +72,13 @@ PulseBlankingFilter::PulseBlankingFilter(ConfigurationInterface* configuration, item_size = sizeof(gr_complex); //avoids uninitialization input_size_ = sizeof(gr_complex); //avoids uninitialization } - + float default_if = 0.0; + float if_ = config_->property(role_ + ".if", default_if); + if (if_ > 0.0) + { + const std::vector taps = { 1.0 }; //All-pass filter + freq_xlating_ = gr::filter::freq_xlating_fir_filter_ccf::make(1, taps, if_, config_->property("SignalSource.sampling_frequency", 2000000)); + } if (dump_) { DLOG(INFO) << "Dumping output into file " << dump_filename_; @@ -95,6 +102,10 @@ void PulseBlankingFilter::connect(gr::top_block_sptr top_block) { top_block->connect(pulse_blanking_cc_, 0, file_sink_, 0); } + if (config_->property(role_ + ".if", 0.0) > 0.0) + { + top_block->connect(freq_xlating_, 0, pulse_blanking_cc_, 0); + } } else @@ -113,6 +124,10 @@ void PulseBlankingFilter::disconnect(gr::top_block_sptr top_block) { top_block->disconnect(pulse_blanking_cc_, 0, file_sink_, 0); } + if (config_->property(role_ + ".if", 0.0) > 0.0) + { + top_block->disconnect(freq_xlating_, 0, pulse_blanking_cc_, 0); + } } else { @@ -125,7 +140,14 @@ gr::basic_block_sptr PulseBlankingFilter::get_left_block() { if (input_item_type_.compare("gr_complex") == 0) { - return pulse_blanking_cc_; + if (config_->property(role_ + ".if", 0.0) > 0.0) + { + return freq_xlating_; + } + else + { + return pulse_blanking_cc_; + } } else { diff --git a/src/algorithms/input_filter/adapters/pulse_blanking_filter.h b/src/algorithms/input_filter/adapters/pulse_blanking_filter.h index 18b040bcc..238636f28 100644 --- a/src/algorithms/input_filter/adapters/pulse_blanking_filter.h +++ b/src/algorithms/input_filter/adapters/pulse_blanking_filter.h @@ -35,6 +35,7 @@ #include #include #include +#include #include "gnss_block_interface.h" #include "pulse_blanking_cc.h" @@ -82,6 +83,7 @@ private: unsigned int out_streams_; gr::blocks::file_sink::sptr file_sink_; pulse_blanking_cc_sptr pulse_blanking_cc_; + gr::filter::freq_xlating_fir_filter_ccf::sptr freq_xlating_; }; #endif // GNSS_SDR_PULSE_BLANKING_FILTER_H_ From 5958d11fd115355a22b2a86ee53e2dcee2af7a1d Mon Sep 17 00:00:00 2001 From: Antonio Ramos Date: Tue, 31 Oct 2017 20:28:34 +0100 Subject: [PATCH 10/60] Baseband downconverting PulseBlanking Added an IF to baseband downconverting stage previous to the pulse blanking filter --- .../adapters/pulse_blanking_filter.cc | 31 +++++++++++++++++-- .../adapters/pulse_blanking_filter.h | 2 ++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc b/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc index e6bcc2632..cc0b02bed 100644 --- a/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc +++ b/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc @@ -30,7 +30,9 @@ #include "pulse_blanking_filter.h" #include +#include #include +#include #include "configuration_interface.h" using google::LogMessage; @@ -71,7 +73,17 @@ PulseBlankingFilter::PulseBlankingFilter(ConfigurationInterface* configuration, item_size = sizeof(gr_complex); //avoids uninitialization input_size_ = sizeof(gr_complex); //avoids uninitialization } - + float default_if = 0.0; + float if_ = config_->property(role_ + ".if", default_if); + if (if_ > 0.0) + { + double default_bw = 2000000.0; + double bw_ = config_->property(role_ + ".bw", default_bw); + double default_tw = bw_ / 15.0; + double tw_ = config_->property(role_ + ".tw", default_tw); + const std::vector taps = gr::filter::firdes::low_pass(1.0, config_->property("SignalSource.sampling_frequency", 2000000.0), bw_ / 2.0, tw_); + freq_xlating_ = gr::filter::freq_xlating_fir_filter_ccf::make(1, taps, if_, config_->property("SignalSource.sampling_frequency", 2000000.0)); + } if (dump_) { DLOG(INFO) << "Dumping output into file " << dump_filename_; @@ -95,6 +107,10 @@ void PulseBlankingFilter::connect(gr::top_block_sptr top_block) { top_block->connect(pulse_blanking_cc_, 0, file_sink_, 0); } + if (config_->property(role_ + ".if", 0.0) > 0.0) + { + top_block->connect(freq_xlating_, 0, pulse_blanking_cc_, 0); + } } else @@ -113,6 +129,10 @@ void PulseBlankingFilter::disconnect(gr::top_block_sptr top_block) { top_block->disconnect(pulse_blanking_cc_, 0, file_sink_, 0); } + if (config_->property(role_ + ".if", 0.0) > 0.0) + { + top_block->disconnect(freq_xlating_, 0, pulse_blanking_cc_, 0); + } } else { @@ -125,7 +145,14 @@ gr::basic_block_sptr PulseBlankingFilter::get_left_block() { if (input_item_type_.compare("gr_complex") == 0) { - return pulse_blanking_cc_; + if (config_->property(role_ + ".if", 0.0) > 0.0) + { + return freq_xlating_; + } + else + { + return pulse_blanking_cc_; + } } else { diff --git a/src/algorithms/input_filter/adapters/pulse_blanking_filter.h b/src/algorithms/input_filter/adapters/pulse_blanking_filter.h index 18b040bcc..238636f28 100644 --- a/src/algorithms/input_filter/adapters/pulse_blanking_filter.h +++ b/src/algorithms/input_filter/adapters/pulse_blanking_filter.h @@ -35,6 +35,7 @@ #include #include #include +#include #include "gnss_block_interface.h" #include "pulse_blanking_cc.h" @@ -82,6 +83,7 @@ private: unsigned int out_streams_; gr::blocks::file_sink::sptr file_sink_; pulse_blanking_cc_sptr pulse_blanking_cc_; + gr::filter::freq_xlating_fir_filter_ccf::sptr freq_xlating_; }; #endif // GNSS_SDR_PULSE_BLANKING_FILTER_H_ From a9be24420e619f79d4bd96abcfd53b44acc77fd3 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 1 Nov 2017 20:49:10 +0100 Subject: [PATCH 11/60] Fix typo --- .../signal_source/adapters/fmcomms2_signal_source.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc b/src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc index 26640d840..ce2c14a89 100644 --- a/src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc +++ b/src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc @@ -78,7 +78,7 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration std::cout << "LO frequency : " << freq_ << "Hz" << std::endl; std::cout << "sample rate: " << sample_rate_ << "Hz" << std::endl; - if(item_type_.compare("gr_complex")==0) + if(item_type_.compare("gr_complex") == 0) { fmcomms2_source_f32c_ = gr::iio::fmcomms2_source_f32c::make( uri_.c_str(), freq_, sample_rate_, @@ -92,7 +92,7 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration } else { - LOG(FATAL) << "Exception: item type " << item_type_ << " not suported!"; + LOG(FATAL) << "Exception: item type " << item_type_ << " not supported!"; } if (samples_ != 0) From 36200183d204edb2b8481b4a34cdbc012279a98a Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 1 Nov 2017 20:50:20 +0100 Subject: [PATCH 12/60] Simplify installation instructions for gr-iio --- README.md | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 6935a4067..ca3ae78e3 100644 --- a/README.md +++ b/README.md @@ -373,51 +373,38 @@ $ sudo make install Install the [libiio](https://github.com/analogdevicesinc/libiio.git) (>=v0.11), [libad9361](https://github.com/analogdevicesinc/libad9361-iio.git) (>=v0.1-1) libraries and [gr-iio](https://github.com/analogdevicesinc/gr-iio.git) (>=v0.2) gnuradio block. For example in Ubuntu 16.04 follow these instructions (based on https://github.com/blurbdust/blurbdust.github.io): ~~~~~~ +$ sudo apt-get install libxml2-dev bison flex $ git clone https://github.com/analogdevicesinc/libiio.git $ cd libiio $ mkdir build $ cd build $ cmake .. -$ make -$ sudo make install -$ sudo ldconfig +$ make && sudo make install && sudo ldconfig +$ cd ../.. $ git clone https://github.com/analogdevicesinc/libad9361-iio.git $ cd libad9361-iio $ mkdir build $ cd build $ cmake .. -$ make -$ sudo make install -$ sudo ldconfig +$ make && sudo make install && sudo ldconfig +$ cd ../.. $ git clone https://github.com/analogdevicesinc/gr-iio.git $ cd gr-iio -$ mv include/gnuradio/iio include/iio -$ rm -r include/gnuradio -$ sed -i 's/gnuradio\/iio/iio/g' CMakeLists.txt -$ sed -i 's/gnuradio\/iio/iio/g' swig/* -$ sed -i 's/gnuradio\/iio/iio/g' include/iio/* -$ sed -i 's/gnuradio\/iio/iio/g' lib/* -$ sed -i 's/gnuradio\/iio/iio/g' python/iio/* -$ sed -i 's/from\ gnuradio\ import\ iio/import\ iio/g' grc/iio_pluto_sink.xml -$ sed -i 's/from\ gnuradio\ import\ iio/import\ iio/g' grc/iio_pluto_source.xml -$ sed -i 's/from\ gnuradio\ import\ iio/import\ iio/g' grc/iio_fmcomms2_sink.xml -$ sed -i 's/from\ gnuradio\ import\ iio/import\ iio/g' grc/iio_fmcomms2_source.xml $ mkdir build $ cd build -$ cmake .. -$ make -$ sudo make install -$ sudo ldconfig +$ cmake -DCMAKE_INSTALL_PREFIX=/usr .. +$ make && sudo make install && sudo ldconfig +$ cd ../.. ~~~~~~ -Then configure the gnss-sdr to build the `Fmcomms2_Signal_Source` and `Plutosdr_Signal_Source`: +Then configure the gnss-sdr to build the `Fmcomms2_Signal_Source` implementation: ~~~~~~ $ cmake -DENABLE_FMCOMMS2=ON ../ $ make $ sudo make install ~~~~~~ -or configure only `Plutosdr_Signal_Source`: +or configure it to build `Plutosdr_Signal_Source`: ~~~~~~ $ cmake -DENABLE_PLUTOSDR=ON ../ $ make From f436cc8a5c2dbe54f16e3c413bde14c834d27389 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 4 Nov 2017 10:59:03 +0100 Subject: [PATCH 13/60] Allow 'large' files in 32 bit builds (Lintian requirement) --- .../volk_gnsssdr_module/volk_gnsssdr/apps/CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/CMakeLists.txt index 4ba808db5..27c97c8ec 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/CMakeLists.txt @@ -50,6 +50,15 @@ elseif(ORC_FOUND) endif(ORC_FOUND) +# allow 'large' files in 32 bit builds +if(UNIX) + add_definitions( -D_LARGEFILE_SOURCE + -D_FILE_OFFSET_BITS=64 + -D_LARGE_FILES + ) +endif(UNIX) + + # MAKE volk_gnsssdr_profile add_executable(volk_gnsssdr_profile ${CMAKE_CURRENT_SOURCE_DIR}/volk_gnsssdr_profile.cc From 4992449b51d61b94ba4f46b5b4324daef2dad152 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 4 Nov 2017 10:59:51 +0100 Subject: [PATCH 14/60] Remove unused includes --- .../signal_source/adapters/fmcomms2_signal_source.cc | 11 ++++------- .../signal_source/adapters/fmcomms2_signal_source.h | 2 +- .../signal_source/adapters/plutosdr_signal_source.cc | 10 ++++------ 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc b/src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc index ce2c14a89..5c354e500 100644 --- a/src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc +++ b/src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc @@ -30,11 +30,8 @@ */ #include "fmcomms2_signal_source.h" -#include #include -#include #include -#include #include "configuration_interface.h" #include "gnss_sdr_valve.h" #include "GPS_L1_CA.h" @@ -75,8 +72,8 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration item_size_ = sizeof(gr_complex); std::cout << "device address: " << uri_ << std::endl; - std::cout << "LO frequency : " << freq_ << "Hz" << std::endl; - std::cout << "sample rate: " << sample_rate_ << "Hz" << std::endl; + std::cout << "LO frequency : " << freq_ << " Hz" << std::endl; + std::cout << "sample rate: " << sample_rate_ << " Hz" << std::endl; if(item_type_.compare("gr_complex") == 0) { @@ -92,7 +89,7 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration } else { - LOG(FATAL) << "Exception: item type " << item_type_ << " not supported!"; + LOG(FATAL) << "Configuration error: item type " << item_type_ << " not supported!"; } if (samples_ != 0) @@ -153,7 +150,7 @@ void Fmcomms2SignalSource::disconnect(gr::top_block_sptr top_block) { if (dump_) { - top_block->disconnect(fmcomms2_source_f32c_, 0, file_sink_, 0); + top_block->disconnect(fmcomms2_source_f32c_, 0, file_sink_, 0); } } } diff --git a/src/algorithms/signal_source/adapters/fmcomms2_signal_source.h b/src/algorithms/signal_source/adapters/fmcomms2_signal_source.h index 35c1e2541..fb62a12cb 100644 --- a/src/algorithms/signal_source/adapters/fmcomms2_signal_source.h +++ b/src/algorithms/signal_source/adapters/fmcomms2_signal_source.h @@ -57,7 +57,7 @@ public: } /*! - * \brief Returns "fmcomms2_Signal_Source" + * \brief Returns "Fmcomms2_Signal_Source" */ inline std::string implementation() override { diff --git a/src/algorithms/signal_source/adapters/plutosdr_signal_source.cc b/src/algorithms/signal_source/adapters/plutosdr_signal_source.cc index d0926dc56..34526f6a5 100644 --- a/src/algorithms/signal_source/adapters/plutosdr_signal_source.cc +++ b/src/algorithms/signal_source/adapters/plutosdr_signal_source.cc @@ -30,9 +30,7 @@ #include "plutosdr_signal_source.h" #include -#include #include -#include #include "configuration_interface.h" #include "gnss_sdr_valve.h" #include "GPS_L1_CA.h" @@ -70,15 +68,15 @@ PlutosdrSignalSource::PlutosdrSignalSource(ConfigurationInterface* configuration if(item_type_.compare("gr_complex") != 0) { - std::cout << "bad item_type!!" << std::endl; - LOG(FATAL) << "Exception: item type must be gr_complex!"; + std::cout << "Configuration error: item_type must be gr_complex" << std::endl; + LOG(FATAL) << "Configuration error: item_type must be gr_complex!"; } item_size_ = sizeof(gr_complex); std::cout << "device address: " << uri_ << std::endl; - std::cout << "frequency : " << freq_ << "Hz" << std::endl; - std::cout << "sample rate: " << sample_rate_ << "Hz" << std::endl; + std::cout << "frequency : " << freq_ << " Hz" << std::endl; + std::cout << "sample rate: " << sample_rate_ << " Hz" << std::endl; std::cout << "gain mode: " << gain_mode_ << std::endl; std::cout << "item type: " << item_type_ << std::endl; From 532d69ef4783c0891a007e0a97e837a24db418cb Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 4 Nov 2017 12:01:24 +0100 Subject: [PATCH 15/60] Avoid double writing of the results --- .../volk_gnsssdr/apps/volk_gnsssdr_profile.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc index d55999d16..2aad67d09 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc @@ -213,7 +213,6 @@ int main(int argc, char *argv[]) { } if(!dry_run) { - write_results(&results, false); if(vm.count("path")) write_results(&results, false, config_file); else write_results(&results, false); } From a148fe44256ed99eecc26837e0a05e5663bf3755 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 4 Nov 2017 12:09:56 +0100 Subject: [PATCH 16/60] Fix CMake warnings about RPATH in macOS --- .../libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt index 1699ea5e9..30b7c02d9 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt @@ -31,6 +31,13 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") add_definitions(-D_GLIBCXX_USE_CXX11_ABI=1) +if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.0") + cmake_policy(SET CMP0042 NEW) + if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.9") + cmake_policy(SET CMP0068 NEW) + endif(CMAKE_VERSION VERSION_GREATER_EQUAL "3.9") +endif(CMAKE_VERSION VERSION_GREATER_EQUAL "3.0") + option(ENABLE_STRIP "Create a stripped volk_gnsssdr_profile binary (without shared libraries)" OFF) set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) #allows this to be a sub-project @@ -84,6 +91,7 @@ if(UNIX) ) endif(UNIX) + ######################################################################## # Dependencies setup ######################################################################## From 401889da3556eab4503c88a11d47688de769d84c Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 4 Nov 2017 19:22:40 +0100 Subject: [PATCH 17/60] Update GPSTk to 2.10 Add more control of installed versions --- CMakeLists.txt | 113 ++++++++++-------- src/tests/CMakeLists.txt | 86 +++++++------ .../system-tests/obs_gps_l1_system_test.cc | 14 +-- 3 files changed, 110 insertions(+), 103 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 042f386db..04377cc46 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -317,6 +317,18 @@ set(GNSSSDR_ARMADILLO_MIN_VERSION "4.200.0") +################################################################################ +# Versions to download and build (but not installed) if not found +################################################################################ +set(GNSSSDR_GFLAGS_LOCAL_VERSION "2.2.1") +set(GNSSSDR_GLOG_LOCAL_VERSION "0.3.5") +set(GNSSSDR_ARMADILLO_LOCAL_VERSION "unstable") +set(GNSSSDR_GTEST_LOCAL_VERSION "1.8.0") +set(GNSSSDR_GNSS_SIM_LOCAL_VERSION "master") +set(GNSSSDR_GPSTK_LOCAL_VERSION "2.10") + + + ################################################################################ # Check cmake version ################################################################################ @@ -668,7 +680,6 @@ endif(NOT VOLK_GNSSSDR_FOUND) # gflags - https://github.com/gflags/gflags ################################################################################ set(LOCAL_GFLAGS false) -set(gflags_RELEASE 2.2.1) find_package(GFlags) if (NOT GFlags_FOUND) message (STATUS " gflags library has not been found.") @@ -677,12 +688,12 @@ if (NOT GFlags_FOUND) if(CMAKE_VERSION VERSION_LESS 3.2) ExternalProject_Add( - gflags-${gflags_RELEASE} - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE} + gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} GIT_REPOSITORY git://github.com/gflags/gflags.git - GIT_TAG v${gflags_RELEASE} - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags/gflags-${gflags_RELEASE} - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE} + GIT_TAG v${GNSSSDR_GFLAGS_LOCAL_VERSION} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} CMAKE_ARGS -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_gflags_nothreads_LIB=OFF -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} UPDATE_COMMAND "" @@ -691,15 +702,15 @@ if (NOT GFlags_FOUND) ) else(CMAKE_VERSION VERSION_LESS 3.2) ExternalProject_Add( - gflags-${gflags_RELEASE} - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE} + gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} GIT_REPOSITORY git://github.com/gflags/gflags.git - GIT_TAG v${gflags_RELEASE} - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags/gflags-${gflags_RELEASE} - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE} + GIT_TAG v${GNSSSDR_GFLAGS_LOCAL_VERSION} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} CMAKE_ARGS -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_gflags_nothreads_LIB=OFF -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} - BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_STATIC_LIBRARY_SUFFIX} + BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_STATIC_LIBRARY_SUFFIX} UPDATE_COMMAND "" PATCH_COMMAND "" INSTALL_COMMAND "" @@ -707,16 +718,16 @@ if (NOT GFlags_FOUND) endif(CMAKE_VERSION VERSION_LESS 3.2) set(GFlags_INCLUDE_DIRS - ${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}/include CACHE PATH "Local Gflags headers" + ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/include CACHE PATH "Local Gflags headers" ) add_library(gflags UNKNOWN IMPORTED) - set_property(TARGET gflags PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_STATIC_LIBRARY_SUFFIX}) - add_dependencies(gflags gflags-${gflags_RELEASE}) + set_property(TARGET gflags PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_STATIC_LIBRARY_SUFFIX}) + add_dependencies(gflags gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}) set(GFlags_LIBS gflags) - file(GLOB GFlags_SHARED_LIBS "${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_SHARED_LIBRARY_SUFFIX}*") - set(GFlags_LIBRARY gflags-${gflags_RELEASE}) - set(GFlags_LIBRARY_PATH ${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}/lib ) + file(GLOB GFlags_SHARED_LIBS "${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_SHARED_LIBRARY_SUFFIX}*") + set(GFlags_LIBRARY gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}) + set(GFlags_LIBRARY_PATH ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib ) link_directories(${GFlags_LIBRARY_PATH}) set(GFlags_lib ${GFlags_LIBS} CACHE FILEPATH "Local Gflags library") set(GFlags_LIBRARY_PATH ${GFlags_LIBS}) @@ -734,7 +745,7 @@ if(NOT ${ENABLE_OWN_GLOG}) set(GLOG_FOUND ON) endif(GLOG_INCLUDE_DIRS) endif(NOT ${ENABLE_OWN_GLOG}) -set(glog_RELEASE 0.3.5) +set(glog_RELEASE ${GNSSSDR_GLOG_LOCAL_VERSION}) if (NOT GLOG_FOUND OR ${LOCAL_GFLAGS}) message (STATUS " glog library has not been found") if(NOT GFlags_FOUND) @@ -743,20 +754,20 @@ if (NOT GLOG_FOUND OR ${LOCAL_GFLAGS}) message (STATUS " glog will be downloaded and built automatically ") message (STATUS " when doing 'make'. ") if(NOT ${LOCAL_GFLAGS}) - add_library(gflags-${gflags_RELEASE} UNKNOWN IMPORTED) - set_property(TARGET gflags-${gflags_RELEASE} PROPERTY IMPORTED_LOCATION "${GFlags_LIBS}") + add_library(gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} UNKNOWN IMPORTED) + set_property(TARGET gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} PROPERTY IMPORTED_LOCATION "${GFlags_LIBS}") endif(NOT ${LOCAL_GFLAGS}) - set(TARGET_GFLAGS gflags-${gflags_RELEASE}) + set(TARGET_GFLAGS gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}) if(${LOCAL_GFLAGS}) set(GFLAGS_LIBRARIES_TO_LINK ${GFlags_SHARED_LIBS}) - set(GFLAGS_LIBRARY_DIR_TO_LINK ${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}/lib) + set(GFLAGS_LIBRARY_DIR_TO_LINK ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib) else(${LOCAL_GFLAGS}) set(GFLAGS_LIBRARIES_TO_LINK ${GFlags_LIBS}) set(GFLAGS_LIBRARY_DIR_TO_LINK ${GFlags_LIBRARY_DIRS}) endif(${LOCAL_GFLAGS}) if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/tmp/configure_with_gflags + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/tmp/configure_with_gflags "#!/bin/sh export CPPFLAGS=-I${GFlags_INCLUDE_DIRS} export LDFLAGS=-L${GFLAGS_LIBRARY_DIR_TO_LINK} @@ -764,34 +775,34 @@ export LIBS=\"${GFLAGS_LIBRARIES_TO_LINK} -lc++\" export CXXFLAGS=\"-stdlib=libc++\" export CC=clang export CXX=clang++ -cd ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}/ +cd ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/ aclocal automake --add-missing autoreconf -vfi -cd ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE} -${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}/configure") +cd ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} +${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/configure") else("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/tmp/configure_with_gflags + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/tmp/configure_with_gflags "#!/bin/sh export CPPFLAGS=-I${GFlags_INCLUDE_DIRS} export LDFLAGS=-L${GFLAGS_LIBRARY_DIR_TO_LINK} export LIBS=${GFLAGS_LIBRARIES_TO_LINK} -cd ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}/ +cd ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/ aclocal automake --add-missing autoreconf -vfi -cd ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE} -${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}/configure") +cd ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} +${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/configure") endif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - file(COPY ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/tmp/configure_with_gflags - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE} + file(COPY ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/tmp/configure_with_gflags + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) - set(GLOG_CONFIGURE ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/configure_with_gflags) + set(GLOG_CONFIGURE ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/configure_with_gflags) # Ensure that aclocal and libtool are present if(OS_IS_LINUX) @@ -826,13 +837,13 @@ ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}/configure") if(CMAKE_VERSION VERSION_LESS 3.2) ExternalProject_Add( - glog-${glog_RELEASE} + glog-${GNSSSDR_GLOG_LOCAL_VERSION} DEPENDS ${TARGET_GFLAGS} - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE} + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} GIT_REPOSITORY https://github.com/google/glog/ - GIT_TAG v${glog_RELEASE} - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE} - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE} + GIT_TAG v${GNSSSDR_GLOG_LOCAL_VERSION} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION} + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} CONFIGURE_COMMAND ${GLOG_CONFIGURE} --prefix= BUILD_COMMAND "${CMAKE_MAKE_PROGRAM}" UPDATE_COMMAND "" @@ -841,16 +852,16 @@ ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}/configure") ) else(CMAKE_VERSION VERSION_LESS 3.2) ExternalProject_Add( - glog-${glog_RELEASE} + glog-${GNSSSDR_GLOG_LOCAL_VERSION} DEPENDS ${TARGET_GFLAGS} - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE} + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} GIT_REPOSITORY https://github.com/google/glog/ - GIT_TAG v${glog_RELEASE} - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE} - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE} + GIT_TAG v${GNSSSDR_GLOG_LOCAL_VERSION} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION} + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} CONFIGURE_COMMAND ${GLOG_CONFIGURE} --prefix= BUILD_COMMAND "${CMAKE_MAKE_PROGRAM}" - BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/.libs/${CMAKE_FIND_LIBRARY_PREFIXES}glog${CMAKE_STATIC_LIBRARY_SUFFIX} + BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/.libs/${CMAKE_FIND_LIBRARY_PREFIXES}glog${CMAKE_STATIC_LIBRARY_SUFFIX} UPDATE_COMMAND "" PATCH_COMMAND "" INSTALL_COMMAND "" @@ -859,16 +870,16 @@ ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}/configure") # Set up variables set(GLOG_INCLUDE_DIRS - ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}/src/ - ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/src + ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/src/ + ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/src ) set(GLOG_LIBRARIES - ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/.libs/${CMAKE_FIND_LIBRARY_PREFIXES}glog${CMAKE_STATIC_LIBRARY_SUFFIX} + ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/.libs/${CMAKE_FIND_LIBRARY_PREFIXES}glog${CMAKE_STATIC_LIBRARY_SUFFIX} ) set(LOCAL_GLOG true CACHE STRING "Glog downloaded and built automatically" FORCE) else(NOT GLOG_FOUND OR ${LOCAL_GFLAGS}) - add_library(glog-${glog_RELEASE} UNKNOWN IMPORTED) - set_property(TARGET glog-${glog_RELEASE} PROPERTY IMPORTED_LOCATION "${GLOG_LIBRARIES}") + add_library(glog-${GNSSSDR_GLOG_LOCAL_VERSION} UNKNOWN IMPORTED) + set_property(TARGET glog-${GNSSSDR_GLOG_LOCAL_VERSION} PROPERTY IMPORTED_LOCATION "${GLOG_LIBRARIES}") endif(NOT GLOG_FOUND OR ${LOCAL_GFLAGS}) if(NOT ENABLE_LOG) @@ -1051,7 +1062,7 @@ if(NOT ARMADILLO_FOUND OR ENABLE_OWN_ARMADILLO) message(STATUS " Armadillo has not been found.") message(STATUS " Armadillo will be downloaded and built automatically") message(STATUS " when doing '${CMAKE_MAKE_PROGRAM_PRETTY_NAME}'. ") - set(armadillo_BRANCH unstable) + set(armadillo_BRANCH ${GNSSSDR_ARMADILLO_LOCAL_VERSION}) set(armadillo_RELEASE ${armadillo_BRANCH}) if(CMAKE_VERSION VERSION_LESS 3.2) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 651713998..8464e5199 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -47,15 +47,13 @@ endif(EXISTS $ENV{OECORE_TARGET_SYSROOT}) if(NOT ${GTEST_DIR_LOCAL}) # if GTEST_DIR is not defined, we download and build it - set(gtest_RELEASE 1.8.0) - if(CMAKE_VERSION VERSION_LESS 3.2) ExternalProject_Add( - gtest-${gtest_RELEASE} + gtest-${GNSSSDR_GTEST_LOCAL_VERSION} GIT_REPOSITORY https://github.com/google/googletest - GIT_TAG release-${gtest_RELEASE} - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${gtest_RELEASE} - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${gtest_RELEASE} + GIT_TAG release-${GNSSSDR_GTEST_LOCAL_VERSION} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${GNSSSDR_GTEST_LOCAL_VERSION} + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${GNSSSDR_GTEST_LOCAL_VERSION} CMAKE_ARGS ${GTEST_COMPILER} -DBUILD_GTEST=ON -DBUILD_GMOCK=OFF ${TOOLCHAIN_ARG} UPDATE_COMMAND "" PATCH_COMMAND "" @@ -63,41 +61,41 @@ if(NOT ${GTEST_DIR_LOCAL}) ) else(CMAKE_VERSION VERSION_LESS 3.2) ExternalProject_Add( - gtest-${gtest_RELEASE} + gtest-${GNSSSDR_GTEST_LOCAL_VERSION} GIT_REPOSITORY https://github.com/google/googletest - GIT_TAG release-${gtest_RELEASE} - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${gtest_RELEASE} - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${gtest_RELEASE} + GIT_TAG release-${GNSSSDR_GTEST_LOCAL_VERSION} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${GNSSSDR_GTEST_LOCAL_VERSION} + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${GNSSSDR_GTEST_LOCAL_VERSION} CMAKE_ARGS ${GTEST_COMPILER} -DBUILD_GTEST=ON -DBUILD_GMOCK=OFF ${TOOLCHAIN_ARG} UPDATE_COMMAND "" PATCH_COMMAND "" - BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${gtest_RELEASE}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} - ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${gtest_RELEASE}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX} + BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} + ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX} INSTALL_COMMAND "" ) endif(CMAKE_VERSION VERSION_LESS 3.2) # Set up variables # Set recently downloaded and build Googletest root folder - set(GTEST_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${gtest_RELEASE}/googletest") + set(GTEST_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/googletest") # Source code - ExternalProject_Get_Property(gtest-${gtest_RELEASE} source_dir) + ExternalProject_Get_Property(gtest-${GNSSSDR_GTEST_LOCAL_VERSION} source_dir) set(GTEST_INCLUDE_DIR ${source_dir}/googletest/include) set(GTEST_INCLUDE_DIRECTORIES ${GTEST_DIR}/include ${GTEST_DIR} ${GTEST_DIR}/src) # Library - ExternalProject_Get_Property(gtest-${gtest_RELEASE} binary_dir) + ExternalProject_Get_Property(gtest-${GNSSSDR_GTEST_LOCAL_VERSION} binary_dir) if(OS_IS_MACOSX) if(CMAKE_GENERATOR STREQUAL Xcode) set(binary_dir "${binary_dir}/Debug") endif(CMAKE_GENERATOR STREQUAL Xcode) endif(OS_IS_MACOSX) set(GTEST_LIBRARY_PATH "${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${CMAKE_STATIC_LIBRARY_SUFFIX};${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX}") - set(GTEST_LIBRARY gtest-${gtest_RELEASE}) + set(GTEST_LIBRARY gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) set(GTEST_LIBRARIES ${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} ${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX} ) - set(GTEST_LIB_DIR "${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${gtest_RELEASE}/googletest") + set(GTEST_LIB_DIR "${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/googletest") else(NOT ${GTEST_DIR_LOCAL}) if(GTEST_INCLUDE_DIRS) set(GTEST_INCLUDE_DIRECTORIES ${GTEST_INCLUDE_DIRS} ${LIBGTEST_DEV_DIR}) @@ -178,7 +176,7 @@ if(ENABLE_UNIT_TESTING_EXTRA OR ENABLE_SYSTEM_TESTING_EXTRA OR ENABLE_FPGA) ExternalProject_Add( gnss-sim GIT_REPOSITORY https://bitbucket.org/jarribas/gnss-simulator - GIT_TAG master + GIT_TAG ${GNSSSDR_GNSS_SIM_LOCAL_VERSION} SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gnss-sim BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gnss-sim CMAKE_ARGS ${GTEST_COMPILER} ${TOOLCHAIN_ARG} ${CROSS_INSTALL_DIR} @@ -207,38 +205,36 @@ if(ENABLE_UNIT_TESTING_EXTRA OR ENABLE_SYSTEM_TESTING_EXTRA OR ENABLE_FPGA) find_package(GPSTK) if(NOT GPSTK_FOUND OR ENABLE_OWN_GPSTK) if(NOT ENABLE_FPGA) - set(gpstk_RELEASE "2.9") - if(CMAKE_VERSION VERSION_LESS 3.2) ExternalProject_Add( - gpstk-${gpstk_RELEASE} + gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION} GIT_REPOSITORY https://github.com/SGL-UT/GPSTk - GIT_TAG v${gpstk_RELEASE} - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${gpstk_RELEASE} - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gpstk-${gpstk_RELEASE} - CMAKE_ARGS ${GTEST_COMPILER} ${TOOLCHAIN_ARG} -DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}/thirdparty/gpstk-${gpstk_RELEASE}/install -DBUILD_EXT=OFF -DBUILD_PYTHON=OFF + GIT_TAG v${GNSSSDR_GPSTK_LOCAL_VERSION} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION} + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION} + CMAKE_ARGS ${GTEST_COMPILER} ${TOOLCHAIN_ARG} -DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}/thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install -DBUILD_EXT=OFF -DBUILD_PYTHON=OFF UPDATE_COMMAND "" PATCH_COMMAND "" ) else(CMAKE_VERSION VERSION_LESS 3.2) ExternalProject_Add( - gpstk-${gpstk_RELEASE} + gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION} GIT_REPOSITORY https://github.com/SGL-UT/GPSTk - GIT_TAG v${gpstk_RELEASE} - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${gpstk_RELEASE} - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gpstk-${gpstk_RELEASE} - CMAKE_ARGS ${GTEST_COMPILER} ${TOOLCHAIN_ARG} -DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}/thirdparty/gpstk-${gpstk_RELEASE}/install -DBUILD_EXT=OFF -DBUILD_PYTHON=OFF - BUILD_BYPRODUCTS ${CMAKE_SOURCE_DIR}/thirdparty/gpstk-${gpstk_RELEASE}/install/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_SHARED_LIBRARY_SUFFIX} + GIT_TAG v${GNSSSDR_GPSTK_LOCAL_VERSION} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION} + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION} + CMAKE_ARGS ${GTEST_COMPILER} ${TOOLCHAIN_ARG} -DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}/thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install -DBUILD_EXT=OFF -DBUILD_PYTHON=OFF + BUILD_BYPRODUCTS ${CMAKE_SOURCE_DIR}/thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_SHARED_LIBRARY_SUFFIX} UPDATE_COMMAND "" PATCH_COMMAND "" ) endif(CMAKE_VERSION VERSION_LESS 3.2) - set(GPSTK_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${gpstk_RELEASE}/install/include CACHE PATH "Local GPSTK headers") + set(GPSTK_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/include CACHE PATH "Local GPSTK headers") add_library(gpstk UNKNOWN IMPORTED) - set_property(TARGET gpstk PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${gpstk_RELEASE}/install/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_SHARED_LIBRARY_SUFFIX}) - add_dependencies(gpstk gpstk-${gpstk_RELEASE}) - set(GPSTK_BINDIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${gpstk_RELEASE}/install/bin/ ) + set_property(TARGET gpstk PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_SHARED_LIBRARY_SUFFIX}) + add_dependencies(gpstk gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}) + set(GPSTK_BINDIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/bin/ ) add_definitions(-DGPSTK_BINDIR="${GPSTK_BINDIR}") set(gpstk_libs gpstk) set(OWN_GPSTK True) @@ -360,7 +356,7 @@ if(ENABLE_UNIT_TESTING) ${GNSS_SDR_TEST_OPTIONAL_LIBS} ) if(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(run_tests gtest-${gtest_RELEASE}) + add_dependencies(run_tests gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) endif(NOT ${GTEST_DIR_LOCAL}) if(ENABLE_INSTALL_TESTS) @@ -417,7 +413,7 @@ if(ENABLE_SYSTEM_TESTING) add_executable(ttff ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/ttff_gps_l1.cc ) if(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(ttff gtest-${gtest_RELEASE}) + add_dependencies(ttff gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) else(NOT ${GTEST_DIR_LOCAL}) add_dependencies(ttff gtest) endif(NOT ${GTEST_DIR_LOCAL}) @@ -451,7 +447,7 @@ if(ENABLE_SYSTEM_TESTING) add_executable(position_test ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/position_test.cc ) if(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(position_test gtest-${gtest_RELEASE}) + add_dependencies(position_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) else(NOT ${GTEST_DIR_LOCAL}) add_dependencies(position_test gtest) endif(NOT ${GTEST_DIR_LOCAL}) @@ -484,11 +480,11 @@ if(ENABLE_SYSTEM_TESTING) if(GPSTK_FOUND OR OWN_GPSTK) add_executable(obs_gps_l1_system_test ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/obs_gps_l1_system_test.cc) if(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(obs_gps_l1_system_test gtest-${gtest_RELEASE} ) + add_dependencies(obs_gps_l1_system_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION} ) else(NOT ${GTEST_DIR_LOCAL}) add_dependencies(obs_gps_l1_system_test gtest) endif(NOT ${GTEST_DIR_LOCAL}) - include_directories(${GPSTK_INCLUDE_DIRS}) + include_directories(${GPSTK_INCLUDE_DIRS} ${GPSTK_INCLUDE_DIRS}/gpstk) target_link_libraries(obs_gps_l1_system_test ${GFlags_LIBS} ${GLOG_LIBRARIES} ${GTEST_LIBRARIES} @@ -534,7 +530,7 @@ if(NOT ${ENABLE_PACKAGING}) ) add_test(control_thread_test control_thread_test) if(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(control_thread_test gtest-${gtest_RELEASE}) + add_dependencies(control_thread_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) else(NOT ${GTEST_DIR_LOCAL}) add_dependencies(control_thread_test gtest) endif(NOT ${GTEST_DIR_LOCAL}) @@ -556,7 +552,7 @@ if(NOT ${ENABLE_PACKAGING}) ${VOLK_GNSSSDR_LIBRARIES} ) add_test(flowgraph_test flowgraph_test) if(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(flowgraph_test gtest-${gtest_RELEASE}) + add_dependencies(flowgraph_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) else(NOT ${GTEST_DIR_LOCAL}) add_dependencies(flowgraph_test gtest) endif(NOT ${GTEST_DIR_LOCAL}) @@ -591,7 +587,7 @@ if(NOT ${ENABLE_PACKAGING}) ) add_test(gnss_block_test gnss_block_test) if(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(gnss_block_test gtest-${gtest_RELEASE}) + add_dependencies(gnss_block_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) else(NOT ${GTEST_DIR_LOCAL}) add_dependencies(gnss_block_test gtest) endif(NOT ${GTEST_DIR_LOCAL}) @@ -616,7 +612,7 @@ target_link_libraries(gnuradio_block_test ${Boost_LIBRARIES} ) add_test(gnuradio_block_test gnuradio_block_test) if(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(gnuradio_block_test gtest-${gtest_RELEASE}) + add_dependencies(gnuradio_block_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) else(NOT ${GTEST_DIR_LOCAL}) add_dependencies(gnuradio_block_test gtest) endif(NOT ${GTEST_DIR_LOCAL}) @@ -662,7 +658,7 @@ target_link_libraries(trk_test ${Boost_LIBRARIES} ) add_test(trk_test trk_test) if(NOT ${GTEST_DIR_LOCAL}) - add_dependencies(trk_test gtest-${gtest_RELEASE}) + add_dependencies(trk_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) else(NOT ${GTEST_DIR_LOCAL}) add_dependencies(trk_test gtest) endif(NOT ${GTEST_DIR_LOCAL}) 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 03e1ceabb..353c494ae 100644 --- a/src/tests/system-tests/obs_gps_l1_system_test.cc +++ b/src/tests/system-tests/obs_gps_l1_system_test.cc @@ -41,11 +41,11 @@ #include #include #include -#include "RinexUtilities.hpp" -#include "Rinex3ObsBase.hpp" -#include "Rinex3ObsData.hpp" -#include "Rinex3ObsHeader.hpp" -#include "Rinex3ObsStream.hpp" +#include +#include +#include +#include +#include #include "concurrent_map.h" #include "concurrent_queue.h" #include "control_thread.h" @@ -513,7 +513,7 @@ void ObsGpsL1SystemTest::check_results() // If a measure exists for this sow, store it for(it2 = pseudorange_meas.at(prn_id).begin(); it2 != pseudorange_meas.at(prn_id).end(); it2++) { - if(std::abs(it->first - it2->first) < 0.01) // store measures closer than 10 ms. + if(std::abs(it->first - it2->first) < 0.1) // store measures closer than 10 ms. { pseudorange_ref_aligned.at(prn_id).push_back(*it); pr_diff.at(prn_id).push_back(it->second - it2->second ); @@ -532,7 +532,7 @@ void ObsGpsL1SystemTest::check_results() // If a measure exists for this sow, store it for(it2 = carrierphase_meas.at(prn_id).begin(); it2 != carrierphase_meas.at(prn_id).end(); it2++) { - if(std::abs(it->first - it2->first) < 0.01) // store measures closer than 10 ms. + if(std::abs(it->first - it2->first) < 0.1) // store measures closer than 10 ms. { carrierphase_ref_aligned.at(prn_id).push_back(*it); cp_diff.at(prn_id).push_back(it->second - it2->second ); From ff2e7ecbb3a0a93330edc1b5aac92facb7006b37 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 4 Nov 2017 20:14:13 +0100 Subject: [PATCH 18/60] Fix building for CMake 3.6 and older VERSION_GREATER_EQUAL was introduced in CMake 3.7 --- .../libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt index 30b7c02d9..738bce42d 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt @@ -31,12 +31,12 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") add_definitions(-D_GLIBCXX_USE_CXX11_ABI=1) -if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.0") +if(CMAKE_VERSION VERSION_GREATER "3.0") cmake_policy(SET CMP0042 NEW) - if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.9") + if(CMAKE_VERSION VERSION_GREATER "3.9") cmake_policy(SET CMP0068 NEW) - endif(CMAKE_VERSION VERSION_GREATER_EQUAL "3.9") -endif(CMAKE_VERSION VERSION_GREATER_EQUAL "3.0") + endif(CMAKE_VERSION VERSION_GREATER "3.9") +endif(CMAKE_VERSION VERSION_GREATER "3.0") option(ENABLE_STRIP "Create a stripped volk_gnsssdr_profile binary (without shared libraries)" OFF) From 60c2e0d4863017973cf696c29f8003c0cb6ee4ef Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 5 Nov 2017 00:30:13 +0100 Subject: [PATCH 19/60] Update PyBOMBS instructions --- README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ca3ae78e3..e06525aef 100644 --- a/README.md +++ b/README.md @@ -84,11 +84,16 @@ Download, build and install PyBOMBS: $ sudo pip install git+https://github.com/gnuradio/pybombs.git ~~~~~~ -Add some software recipes (i.e., instructions on how to install software dependencies): +Apply a configuration: ~~~~~~ -$ pybombs recipes add gr-recipes git+https://github.com/gnuradio/gr-recipes.git -$ pybombs recipes add gr-etcetera git+https://github.com/gnuradio/gr-etcetera.git +$ pybombs auto-config +~~~~~~ + +Add list of default recipes: + +~~~~~~ +$ pybombs recipes add-defaults ~~~~~~ Download, build and install GNU Radio, related drivers and some other extra modules into the directory ```/path/to/prefix``` (replace this path by your preferred one, for instance ```$HOME/sdr```): From 03f7cf0b07054a0e429a7542ac62cd53f81e1366 Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 6 Nov 2017 10:32:11 +0100 Subject: [PATCH 20/60] Add lowpass filtering Lowpass filtering implementation in freq_xlating --- .../adapters/freq_xlating_fir_filter.cc | 89 ++++++++++--------- .../adapters/pulse_blanking_filter.cc | 18 ++-- .../adapters/pulse_blanking_filter.h | 1 - 3 files changed, 58 insertions(+), 50 deletions(-) diff --git a/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc b/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc index d5690f07e..8af287d6f 100644 --- a/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc +++ b/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include "configuration_interface.h" @@ -343,8 +344,8 @@ void FreqXlatingFirFilter::init() std::string default_output_item_type = "gr_complex"; std::string default_taps_item_type = "float"; std::string default_dump_filename = "../data/input_filter.dat"; - double default_intermediate_freq = 0; - double default_sampling_freq = 4000000; + double default_intermediate_freq = 0.0; + double default_sampling_freq = 4000000.0; int default_number_of_taps = 6; unsigned int default_number_of_bands = 2; std::vector default_bands = { 0.0, 0.4, 0.6, 1.0 }; @@ -364,46 +365,54 @@ void FreqXlatingFirFilter::init() sampling_freq_ = config_->property(role_ + ".sampling_frequency", default_sampling_freq); int number_of_taps = config_->property(role_ + ".number_of_taps", default_number_of_taps); unsigned int number_of_bands = config_->property(role_ + ".number_of_bands", default_number_of_bands); - - std::vector bands; - std::vector ampl; - std::vector error_w; - std::string option; - double option_value; - - for (unsigned int i = 0; i < number_of_bands; i++) - { - option = ".band" + boost::lexical_cast(i + 1) + "_begin"; - option_value = config_->property(role_ + option, default_bands[i]); - bands.push_back(option_value); - - option = ".band" + boost::lexical_cast(i + 1) + "_end"; - option_value = config_->property(role_ + option, default_bands[i]); - bands.push_back(option_value); - - option = ".ampl" + boost::lexical_cast(i + 1) + "_begin"; - option_value = config_->property(role_ + option, default_bands[i]); - ampl.push_back(option_value); - - option = ".ampl" + boost::lexical_cast(i + 1) + "_end"; - option_value = config_->property(role_ + option, default_bands[i]); - ampl.push_back(option_value); - - option = ".band" + boost::lexical_cast(i + 1) + "_error"; - option_value = config_->property(role_ + option, default_bands[i]); - error_w.push_back(option_value); - } - std::string filter_type = config_->property(role_ + ".filter_type", default_filter_type); - int grid_density = config_->property(role_ + ".grid_density", default_grid_density); - std::vector taps_d = gr::filter::pm_remez(number_of_taps - 1, bands, ampl, - error_w, filter_type, grid_density); - - taps_.reserve(taps_d.size()); - for (std::vector::iterator it = taps_d.begin(); it != taps_d.end(); it++) + if(filter_type.compare("lowpass") != 0) { - taps_.push_back(float(*it)); - //std::cout<<"TAP="< taps_d; + std::vector bands; + std::vector ampl; + std::vector error_w; + std::string option; + double option_value; + + for (unsigned int i = 0; i < number_of_bands; i++) + { + option = ".band" + boost::lexical_cast(i + 1) + "_begin"; + option_value = config_->property(role_ + option, default_bands[i]); + bands.push_back(option_value); + + option = ".band" + boost::lexical_cast(i + 1) + "_end"; + option_value = config_->property(role_ + option, default_bands[i]); + bands.push_back(option_value); + + option = ".ampl" + boost::lexical_cast(i + 1) + "_begin"; + option_value = config_->property(role_ + option, default_bands[i]); + ampl.push_back(option_value); + + option = ".ampl" + boost::lexical_cast(i + 1) + "_end"; + option_value = config_->property(role_ + option, default_bands[i]); + ampl.push_back(option_value); + + option = ".band" + boost::lexical_cast(i + 1) + "_error"; + option_value = config_->property(role_ + option, default_bands[i]); + error_w.push_back(option_value); + } + + int grid_density = config_->property(role_ + ".grid_density", default_grid_density); + taps_d = gr::filter::pm_remez(number_of_taps - 1, bands, ampl, error_w, filter_type, grid_density); + taps_.reserve(taps_d.size()); + for (std::vector::iterator it = taps_d.begin(); it != taps_d.end(); it++) + { + taps_.push_back(static_cast(*it)); + } } + else + { + double default_bw = 2000000.0; + double bw_ = config_->property(role_ + ".bw", default_bw); + double default_tw = bw_ / 20.0; + double tw_ = config_->property(role_ + ".tw", default_tw); + taps_ = gr::filter::firdes::low_pass(1.0, sampling_freq_, bw_ / 2.0, tw_); + } } diff --git a/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc b/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc index 89a2ff0ac..ea16bd231 100644 --- a/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc +++ b/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc @@ -28,13 +28,13 @@ * ------------------------------------------------------------------------- */ -#include "pulse_blanking_filter.h" #include #include +#include #include #include #include "configuration_interface.h" -#include +#include "pulse_blanking_filter.h" using google::LogMessage; @@ -74,13 +74,13 @@ PulseBlankingFilter::PulseBlankingFilter(ConfigurationInterface* configuration, item_size = sizeof(gr_complex); //avoids uninitialization input_size_ = sizeof(gr_complex); //avoids uninitialization } - float default_if = 0.0; - float if_ = config_->property(role_ + ".if", default_if); - if (if_ > 0.0) + double default_if = 0.0; + double if_ = config_->property(role_ + ".if", default_if); + if (std::abs(if_) > 1.0) { double default_bw = 2000000.0; double bw_ = config_->property(role_ + ".bw", default_bw); - double default_tw = bw_ / 15.0; + double default_tw = bw_ / 20.0; double tw_ = config_->property(role_ + ".tw", default_tw); const std::vector taps = gr::filter::firdes::low_pass(1.0, config_->property("SignalSource.sampling_frequency", 2000000.0), bw_ / 2.0, tw_); freq_xlating_ = gr::filter::freq_xlating_fir_filter_ccf::make(1, taps, if_, config_->property("SignalSource.sampling_frequency", 2000000.0)); @@ -108,7 +108,7 @@ void PulseBlankingFilter::connect(gr::top_block_sptr top_block) { top_block->connect(pulse_blanking_cc_, 0, file_sink_, 0); } - if (config_->property(role_ + ".if", 0.0) > 0.0) + if (std::abs(config_->property(role_ + ".if", 0.0)) > 1.0) { top_block->connect(freq_xlating_, 0, pulse_blanking_cc_, 0); } @@ -130,7 +130,7 @@ void PulseBlankingFilter::disconnect(gr::top_block_sptr top_block) { top_block->disconnect(pulse_blanking_cc_, 0, file_sink_, 0); } - if (config_->property(role_ + ".if", 0.0) > 0.0) + if (std::abs(config_->property(role_ + ".if", 0.0)) > 1.0) { top_block->disconnect(freq_xlating_, 0, pulse_blanking_cc_, 0); } @@ -146,7 +146,7 @@ gr::basic_block_sptr PulseBlankingFilter::get_left_block() { if (input_item_type_.compare("gr_complex") == 0) { - if (config_->property(role_ + ".if", 0.0) > 0.0) + if (std::abs(config_->property(role_ + ".if", 0.0)) > 1.0) { return freq_xlating_; } diff --git a/src/algorithms/input_filter/adapters/pulse_blanking_filter.h b/src/algorithms/input_filter/adapters/pulse_blanking_filter.h index 238636f28..e0748a9d2 100644 --- a/src/algorithms/input_filter/adapters/pulse_blanking_filter.h +++ b/src/algorithms/input_filter/adapters/pulse_blanking_filter.h @@ -33,7 +33,6 @@ #define GNSS_SDR_PULSE_BLANKING_FILTER_H_ #include -#include #include #include #include "gnss_block_interface.h" From a8ff283bacd0d26691691c7474436cb299feba2b Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 6 Nov 2017 19:03:01 +0100 Subject: [PATCH 21/60] Call the Intermediate Frequency parameter "IF" for consistency with the freq_xlating_fir_filter block --- src/algorithms/input_filter/adapters/pulse_blanking_filter.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc b/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc index 8d3111dc9..e262e3abf 100644 --- a/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc +++ b/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc @@ -75,7 +75,8 @@ PulseBlankingFilter::PulseBlankingFilter(ConfigurationInterface* configuration, input_size_ = sizeof(gr_complex); //avoids uninitialization } double default_if = 0.0; - double if_ = config_->property(role_ + ".if", default_if); + double if_aux = config_->property(role_ + ".if", default_if); + double if_ = config_->property(role_ + ".IF", if_aux); if (std::abs(if_) > 1.0) { double default_sampling_freq = 4000000.0; From 8fa965c75cda21c3e676f1c9011b79e62dc67dd8 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 6 Nov 2017 19:27:41 +0100 Subject: [PATCH 22/60] Change parameter bw to be the cut-off frequency --- src/algorithms/input_filter/adapters/pulse_blanking_filter.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc b/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc index e262e3abf..9c1c18b82 100644 --- a/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc +++ b/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc @@ -83,9 +83,9 @@ PulseBlankingFilter::PulseBlankingFilter(ConfigurationInterface* configuration, double sampling_freq_ = config_->property(role_ + ".sampling_frequency", default_sampling_freq); double default_bw = 2000000.0; double bw_ = config_->property(role_ + ".bw", default_bw); - double default_tw = bw_ / 20.0; + double default_tw = bw_ / 10.0; double tw_ = config_->property(role_ + ".tw", default_tw); - const std::vector taps = gr::filter::firdes::low_pass(1.0, sampling_freq_, bw_ / 2.0, tw_); + const std::vector taps = gr::filter::firdes::low_pass(1.0, sampling_freq_, bw_ , tw_); freq_xlating_ = gr::filter::freq_xlating_fir_filter_ccf::make(1, taps, if_, sampling_freq_); } if (dump_) From 09e9220764feca3c0653fd9d314e5863f11271d7 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 6 Nov 2017 23:53:05 +0100 Subject: [PATCH 23/60] Add pull request template --- docs/PULL_REQUEST_TEMPLATE.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 docs/PULL_REQUEST_TEMPLATE.md diff --git a/docs/PULL_REQUEST_TEMPLATE.md b/docs/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..b4e04e2c1 --- /dev/null +++ b/docs/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,11 @@ +:+1::tada: Hello, and thanks for contributing to [GNSS-SDR](http://gnss-sdr.org)! :tada::+1: + +Before submitting your pull request, please make sure the following is done: + 1. You undertake the [Contributor Covenant Code of Conduct](https://github.com/gnss-sdr/gnss-sdr/blob/master/CODE_OF_CONDUCT.md). + 2. If you are a first-time contributor, after your pull request you will be asked to sign an Individual Contributor License Agreement ([CLA](https://en.wikipedia.org/wiki/Contributor_License_Agreement)) before your code gets accepted into `master`. This license is for your protection as a Contributor as well as for the protection of [CTTC](http://www.cttc.es/); it does not change your rights to use your own contributions for any other purpose. Except for the license granted therein to CTTC and recipients of software distributed by CTTC, you reserve all right, title, and interest in and to your contributions. The information you provide in that CLA will be maintained in accordance with [CTTC's privacy policy](http://www.cttc.es/privacy/). + 3. You have read the [Contributing Guidelines](https://github.com/gnss-sdr/gnss-sdr/blob/master/CONTRIBUTING.md). + 4. You have read the [coding style guide](http://gnss-sdr.org/coding-style/). + 5. You have forked the [gnss-sdr upstream repository](https://github.com/gnss-sdr/gnss-sdr) and have created your branch from `next` (or any other currently living branch in the upstream repository). + 6. Please include a description of your changes here. + +**Please feel free to delete this line and the above text once you have read it and in case you want to go on with your pull request.** \ No newline at end of file From 10bbe2a267c7a5eb92036b88d80a3dd1d1ddffab Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 7 Nov 2017 09:20:06 +0100 Subject: [PATCH 24/60] Avoid IF parameter ambiguity Added a new boolean for proper instantiation and connection of the internal blocks --- .../input_filter/adapters/pulse_blanking_filter.cc | 8 +++++--- .../input_filter/adapters/pulse_blanking_filter.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc b/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc index 9c1c18b82..07c543a92 100644 --- a/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc +++ b/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc @@ -44,6 +44,7 @@ PulseBlankingFilter::PulseBlankingFilter(ConfigurationInterface* configuration, out_streams_(out_streams) { size_t item_size; + xlat_ = false; std::string default_input_item_type = "gr_complex"; std::string default_output_item_type = "gr_complex"; std::string default_dump_filename = "../data/input_filter.dat"; @@ -79,6 +80,7 @@ PulseBlankingFilter::PulseBlankingFilter(ConfigurationInterface* configuration, double if_ = config_->property(role_ + ".IF", if_aux); if (std::abs(if_) > 1.0) { + xlat_ = true; double default_sampling_freq = 4000000.0; double sampling_freq_ = config_->property(role_ + ".sampling_frequency", default_sampling_freq); double default_bw = 2000000.0; @@ -111,7 +113,7 @@ void PulseBlankingFilter::connect(gr::top_block_sptr top_block) { top_block->connect(pulse_blanking_cc_, 0, file_sink_, 0); } - if (std::abs(config_->property(role_ + ".if", 0.0)) > 1.0) + if (xlat_) { top_block->connect(freq_xlating_, 0, pulse_blanking_cc_, 0); } @@ -133,7 +135,7 @@ void PulseBlankingFilter::disconnect(gr::top_block_sptr top_block) { top_block->disconnect(pulse_blanking_cc_, 0, file_sink_, 0); } - if (std::abs(config_->property(role_ + ".if", 0.0)) > 1.0) + if (xlat_) { top_block->disconnect(freq_xlating_, 0, pulse_blanking_cc_, 0); } @@ -149,7 +151,7 @@ gr::basic_block_sptr PulseBlankingFilter::get_left_block() { if (input_item_type_.compare("gr_complex") == 0) { - if (std::abs(config_->property(role_ + ".if", 0.0)) > 1.0) + if (xlat_) { return freq_xlating_; } diff --git a/src/algorithms/input_filter/adapters/pulse_blanking_filter.h b/src/algorithms/input_filter/adapters/pulse_blanking_filter.h index e0748a9d2..8c5211c64 100644 --- a/src/algorithms/input_filter/adapters/pulse_blanking_filter.h +++ b/src/algorithms/input_filter/adapters/pulse_blanking_filter.h @@ -73,6 +73,7 @@ public: private: ConfigurationInterface* config_; bool dump_; + bool xlat_; std::string dump_filename_; std::string input_item_type_; size_t input_size_; From 829071369dfed3d4045ee8fc1eaa56796c6cf309 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 7 Nov 2017 10:34:49 +0100 Subject: [PATCH 25/60] Changes in cut-off frequency and transition width parameters --- .../input_filter/adapters/freq_xlating_fir_filter.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc b/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc index d52b4ad51..a62d179f1 100644 --- a/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc +++ b/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc @@ -412,8 +412,8 @@ void FreqXlatingFirFilter::init() { double default_bw = 2000000.0; double bw_ = config_->property(role_ + ".bw", default_bw); - double default_tw = bw_ / 20.0; + double default_tw = bw_ / 10.0; double tw_ = config_->property(role_ + ".tw", default_tw); - taps_ = gr::filter::firdes::low_pass(1.0, sampling_freq_, bw_ / 2.0, tw_); + taps_ = gr::filter::firdes::low_pass(1.0, sampling_freq_, bw_, tw_); } } From 6798f45df6172b0cc7b40018f34dca55e4403402 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 8 Nov 2017 11:41:15 +0100 Subject: [PATCH 26/60] Added L1, E1, L5, E5 obs system test --- src/tests/CMakeLists.txt | 14 +- .../obs_gps_l1_space_system_test.cc | 502 ------------- .../system-tests/obs_space_system_test.cc | 681 ++++++++++++++++++ 3 files changed, 688 insertions(+), 509 deletions(-) delete mode 100644 src/tests/system-tests/obs_gps_l1_space_system_test.cc create mode 100644 src/tests/system-tests/obs_space_system_test.cc diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 2f2ee15a9..fd5aed1fa 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -479,13 +479,13 @@ if(ENABLE_SYSTEM_TESTING) if(GPSTK_FOUND OR OWN_GPSTK) add_executable(obs_gps_l1_system_test ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/obs_gps_l1_system_test.cc) - add_executable(obs_gps_l1_space_system_test ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/obs_gps_l1_space_system_test.cc) + add_executable(obs_space_system_test ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/obs_space_system_test.cc) if(NOT ${GTEST_DIR_LOCAL}) add_dependencies(obs_gps_l1_system_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION} ) - add_dependencies(obs_gps_l1_space_system_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION} ) + add_dependencies(obs_space_system_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION} ) else(NOT ${GTEST_DIR_LOCAL}) add_dependencies(obs_gps_l1_system_test gtest) - add_dependencies(obs_gps_l1_space_system_test gtest) + add_dependencies(obs_space_system_test gtest) endif(NOT ${GTEST_DIR_LOCAL}) include_directories(${GPSTK_INCLUDE_DIRS} ${GPSTK_INCLUDE_DIRS}/gpstk) target_link_libraries(obs_gps_l1_system_test ${GFlags_LIBS} @@ -495,7 +495,7 @@ if(ENABLE_SYSTEM_TESTING) gnss_rx ${gpstk_libs}) - target_link_libraries(obs_gps_l1_space_system_test ${GFlags_LIBS} + target_link_libraries(obs_space_system_test ${GFlags_LIBS} ${GLOG_LIBRARIES} ${GTEST_LIBRARIES} gnss_sp_libs @@ -511,9 +511,9 @@ if(ENABLE_SYSTEM_TESTING) add_custom_command(TARGET obs_gps_l1_system_test POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_SOURCE_DIR}/install/$ ) - add_custom_command(TARGET obs_gps_l1_space_system_test POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ - ${CMAKE_SOURCE_DIR}/install/$ ) + add_custom_command(TARGET obs_space_system_test POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ + ${CMAKE_SOURCE_DIR}/install/$ ) endif(ENABLE_INSTALL_TESTS) endif(GPSTK_FOUND OR OWN_GPSTK) diff --git a/src/tests/system-tests/obs_gps_l1_space_system_test.cc b/src/tests/system-tests/obs_gps_l1_space_system_test.cc deleted file mode 100644 index 6a17e0ba6..000000000 --- a/src/tests/system-tests/obs_gps_l1_space_system_test.cc +++ /dev/null @@ -1,502 +0,0 @@ -/*! - * \file obs_gps_l1_space_system_test.cc - * \brief This class implements a test for the validation of generated observables. - * \author Carles Fernandez-Prades, 2016. cfernandez(at)cttc.es - * Antonio Ramos, 2017. antonio.ramos(at)cttc.es - * - * - * ------------------------------------------------------------------------- - * - * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) - * - * GNSS-SDR is a software defined Global Navigation - * Satellite Systems receiver - * - * This file is part of GNSS-SDR. - * - * GNSS-SDR is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GNSS-SDR is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNSS-SDR. If not, see . - * - * ------------------------------------------------------------------------- - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "concurrent_map.h" -#include "concurrent_queue.h" -#include "control_thread.h" -#include "file_configuration.h" -#include "signal_generator_flags.h" - - -// For GPS NAVIGATION (L1) -concurrent_queue global_gps_acq_assist_queue; -concurrent_map global_gps_acq_assist_map; - -DEFINE_string(configuration_file_space, "./default_configuration.conf", "Path of configuration file"); - -class ObsGpsL1SpaceSystemTest: public ::testing::Test -{ -public: - std::string filename_rinex_obs = FLAGS_filename_rinex_obs; - std::string generated_rinex_obs; - std::string configuration_file_ = FLAGS_configuration_file_space; - int configure_receiver(); - int run_receiver(); - void check_results(); - bool check_valid_rinex_obs(std::string filename, int rinex_ver); // return true if the file is a valid Rinex observation file. - double compute_stdev(const std::vector & vec); - - std::shared_ptr config; -}; - - -double ObsGpsL1SpaceSystemTest::compute_stdev(const std::vector & vec) -{ - double sum__ = std::accumulate(vec.begin(), vec.end(), 0.0); - double mean__ = sum__ / vec.size(); - double accum__ = 0.0; - std::for_each (std::begin(vec), std::end(vec), [&](const double d) { - accum__ += (d - mean__) * (d - mean__); - }); - double stdev__ = std::sqrt(accum__ / (vec.size() - 1)); - return stdev__; -} - - -bool ObsGpsL1SpaceSystemTest::check_valid_rinex_obs(std::string filename, int rinex_ver) -{ - bool res = false; - if(rinex_ver == 2) - { - res = gpstk::isRinexObsFile(filename); - } - if(rinex_ver == 3) - { - res = gpstk::isRinex3ObsFile(filename); - } - return res; -} - -int ObsGpsL1SpaceSystemTest::configure_receiver() -{ - config = std::make_shared(configuration_file_); - int d_rinex_ver = config->property("PVT.rinex_version", 0); - if(d_rinex_ver != 2) - { - std::cout << "Invalid RINEX version. Set PVT.rinex_ver=2 in configuration file." << std::endl; - std::cout << "GPSTk does not work with RINEX v. 3.02." << std::endl; - } - return 0; -} - - -int ObsGpsL1SpaceSystemTest::run_receiver() -{ - std::shared_ptr control_thread; - control_thread = std::make_shared(config); - // start receiver - try - { - control_thread->run(); - } - catch(const boost::exception & e) - { - std::cout << "Boost exception: " << boost::diagnostic_information(e); - } - catch(const std::exception & ex) - { - std::cout << "STD exception: " << ex.what(); - } - // Get the name of the RINEX obs file generated by the receiver - std::this_thread::sleep_for(std::chrono::milliseconds(2000)); - FILE *fp; - std::string argum2 = std::string("/bin/ls *O | grep GSDR | tail -1"); - char buffer[1035]; - fp = popen(&argum2[0], "r"); - if (fp == NULL) - { - std::cout << "Failed to run command: " << argum2 << std::endl; - return -1; - } - while (fgets(buffer, sizeof(buffer), fp) != NULL) - { - std::string aux = std::string(buffer); - ObsGpsL1SpaceSystemTest::generated_rinex_obs = aux.erase(aux.length() - 1, 1); - } - pclose(fp); - return 0; -} - - -void ObsGpsL1SpaceSystemTest::check_results() -{ - std::vector> > pseudorange_ref(33); - std::vector> > carrierphase_ref(33); - std::vector> > doppler_ref(33); - - std::vector> > pseudorange_meas(33); - std::vector> > carrierphase_meas(33); - std::vector> > doppler_meas(33); - - // Open and read reference RINEX observables file - try - { - gpstk::Rinex3ObsStream r_ref(FLAGS_filename_rinex_obs); - r_ref.exceptions(std::ios::failbit); - gpstk::Rinex3ObsData r_ref_data; - gpstk::Rinex3ObsHeader r_ref_header; - - gpstk::RinexDatum dataobj; - - r_ref >> r_ref_header; - - while (r_ref >> r_ref_data) - { - for (int myprn = 1; myprn < 33; myprn++) - { - gpstk::SatID prn( myprn, gpstk::SatID::systemGPS ); - gpstk::CommonTime time = r_ref_data.time; - double sow(static_cast(time).sow); - - gpstk::Rinex3ObsData::DataMap::iterator pointer = r_ref_data.obs.find(prn); - if( pointer == r_ref_data.obs.end() ) - { - // PRN not present; do nothing - } - else - { - dataobj = r_ref_data.getObs(prn, "C1C", r_ref_header); - double P1 = dataobj.data; - std::pair pseudo(sow,P1); - pseudorange_ref.at(myprn).push_back(pseudo); - - dataobj = r_ref_data.getObs(prn, "L1C", r_ref_header); - double L1 = dataobj.data; - std::pair carrier(sow, L1); - carrierphase_ref.at(myprn).push_back(carrier); - - dataobj = r_ref_data.getObs(prn, "D1C", r_ref_header); - double D1 = dataobj.data; - std::pair doppler(sow, D1); - doppler_ref.at(myprn).push_back(doppler); - } // End of 'if( pointer == roe.obs.end() )' - } // end for - } // end while - } // End of 'try' block - catch(const gpstk::FFStreamError& e) - { - std::cout << e; - exit(1); - } - catch(const gpstk::Exception& e) - { - std::cout << e; - exit(1); - } - catch (...) - { - std::cout << "unknown error. I don't feel so well..." << std::endl; - exit(1); - } - - try - { - std::string arg2_gen = std::string("./") + ObsGpsL1SpaceSystemTest::generated_rinex_obs; - gpstk::Rinex3ObsStream r_meas(arg2_gen); - r_meas.exceptions(std::ios::failbit); - gpstk::Rinex3ObsData r_meas_data; - gpstk::Rinex3ObsHeader r_meas_header; - gpstk::RinexDatum dataobj; - - r_meas >> r_meas_header; - - while (r_meas >> r_meas_data) - { - for (int myprn = 1; myprn < 33; myprn++) - { - gpstk::SatID prn( myprn, gpstk::SatID::systemGPS ); - gpstk::CommonTime time = r_meas_data.time; - double sow(static_cast(time).sow); - - gpstk::Rinex3ObsData::DataMap::iterator pointer = r_meas_data.obs.find(prn); - if( pointer == r_meas_data.obs.end() ) - { - // PRN not present; do nothing - } - else - { - dataobj = r_meas_data.getObs(prn, "C1C", r_meas_header); - double P1 = dataobj.data; - std::pair pseudo(sow, P1); - pseudorange_meas.at(myprn).push_back(pseudo); - - dataobj = r_meas_data.getObs(prn, "L1C", r_meas_header); - double L1 = dataobj.data; - std::pair carrier(sow, L1); - carrierphase_meas.at(myprn).push_back(carrier); - - dataobj = r_meas_data.getObs(prn, "D1C", r_meas_header); - double D1 = dataobj.data; - std::pair doppler(sow, D1); - doppler_meas.at(myprn).push_back(doppler); - } // End of 'if( pointer == roe.obs.end() )' - } // end for - } // end while - } // End of 'try' block - catch(const gpstk::FFStreamError& e) - { - std::cout << e; - exit(1); - } - catch(const gpstk::Exception& e) - { - std::cout << e; - exit(1); - } - catch (...) - { - std::cout << "unknown error. I don't feel so well..." << std::endl; - exit(1); - } - - // Time alignment - std::vector> > pseudorange_ref_aligned(33); - std::vector> > carrierphase_ref_aligned(33); - std::vector> > doppler_ref_aligned(33); - - std::vector> >::iterator iter; - std::vector>::iterator it; - std::vector>::iterator it2; - - std::vector> pr_diff(33); - std::vector> cp_diff(33); - std::vector> doppler_diff(33); - - std::vector>::iterator iter_diff; - std::vector::iterator iter_v; - - int prn_id = 0; - for(iter = pseudorange_ref.begin(); iter != pseudorange_ref.end(); iter++) - { - for(it = iter->begin(); it != iter->end(); it++) - { - // If a measure exists for this sow, store it - for(it2 = pseudorange_meas.at(prn_id).begin(); it2 != pseudorange_meas.at(prn_id).end(); it2++) - { - if(std::abs(it->first - it2->first) < 0.01) // store measures closer than 10 ms. - { - pseudorange_ref_aligned.at(prn_id).push_back(*it); - pr_diff.at(prn_id).push_back(it->second - it2->second ); - //std::cout << "Sat " << prn_id << ": " << "PR_ref=" << it->second << " PR_meas=" << it2->second << " Diff:" << it->second - it2->second << std::endl; - } - } - } - prn_id++; - } - - prn_id = 0; - for(iter = carrierphase_ref.begin(); iter != carrierphase_ref.end(); iter++) - { - for(it = iter->begin(); it != iter->end(); it++) - { - // If a measure exists for this sow, store it - for(it2 = carrierphase_meas.at(prn_id).begin(); it2 != carrierphase_meas.at(prn_id).end(); it2++) - { - if(std::abs(it->first - it2->first) < 0.01) // store measures closer than 10 ms. - { - carrierphase_ref_aligned.at(prn_id).push_back(*it); - cp_diff.at(prn_id).push_back(it->second - it2->second ); - // std::cout << "Sat " << prn_id << ": " << "Carrier_ref=" << it->second << " Carrier_meas=" << it2->second << " Diff:" << it->second - it2->second << std::endl; - } - } - } - prn_id++; - } - prn_id = 0; - for(iter = doppler_ref.begin(); iter != doppler_ref.end(); iter++) - { - for(it = iter->begin(); it != iter->end(); it++) - { - // If a measure exists for this sow, store it - for(it2 = doppler_meas.at(prn_id).begin(); it2 != doppler_meas.at(prn_id).end(); it2++) - { - if(std::abs(it->first - it2->first) < 0.01) // store measures closer than 10 ms. - { - doppler_ref_aligned.at(prn_id).push_back(*it); - doppler_diff.at(prn_id).push_back(it->second - it2->second ); - } - } - } - prn_id++; - } - - // Compute pseudorange error - prn_id = 0; - std::vector mean_pr_diff_v; - for(iter_diff = pr_diff.begin(); iter_diff != pr_diff.end(); iter_diff++) - { - // For each satellite with reference and measurements aligned in time - int number_obs = 0; - double mean_diff = 0.0; - for(iter_v = iter_diff->begin(); iter_v != iter_diff->end(); iter_v++) - { - mean_diff = mean_diff + *iter_v; - number_obs = number_obs + 1; - } - if(number_obs > 0) - { - mean_diff = mean_diff / number_obs; - mean_pr_diff_v.push_back(mean_diff); - std::cout << "-- Mean pseudorange difference for sat " << prn_id << ": " << mean_diff; - double stdev_ = compute_stdev(*iter_diff); - std::cout << " +/- " << stdev_ ; - std::cout << " [m]" << std::endl; - } - else - { - mean_diff = 0.0; - } - - prn_id++; - } - double stdev_pr = compute_stdev(mean_pr_diff_v); - std::cout << "Pseudorange diff error stdev = " << stdev_pr << " [m]" << std::endl; - ASSERT_LT(stdev_pr, 10.0); - - // Compute carrier phase error - prn_id = 0; - std::vector mean_cp_diff_v; - for(iter_diff = cp_diff.begin(); iter_diff != cp_diff.end(); iter_diff++) - { - // For each satellite with reference and measurements aligned in time - int number_obs = 0; - double mean_diff = 0.0; - for(iter_v = iter_diff->begin(); iter_v != iter_diff->end(); iter_v++) - { - mean_diff = mean_diff + *iter_v; - number_obs = number_obs + 1; - } - if(number_obs > 0) - { - mean_diff = mean_diff / number_obs; - mean_cp_diff_v.push_back(mean_diff); - std::cout << "-- Mean carrier phase difference for sat " << prn_id << ": " << mean_diff; - double stdev_pr_ = compute_stdev(*iter_diff); - std::cout << " +/- " << stdev_pr_ << " whole cycles (19 cm)" << std::endl; - } - else - { - mean_diff = 0.0; - } - - prn_id++; - } - - // Compute Doppler error - prn_id = 0; - std::vector mean_doppler_v; - for(iter_diff = doppler_diff.begin(); iter_diff != doppler_diff.end(); iter_diff++) - { - // For each satellite with reference and measurements aligned in time - int number_obs = 0; - double mean_diff = 0.0; - for(iter_v = iter_diff->begin(); iter_v != iter_diff->end(); iter_v++) - { - //std::cout << *iter_v << std::endl; - mean_diff = mean_diff + *iter_v; - number_obs = number_obs + 1; - } - if(number_obs > 0) - { - mean_diff = mean_diff / number_obs; - mean_doppler_v.push_back(mean_diff); - std::cout << "-- Mean Doppler difference for sat " << prn_id << ": " << mean_diff << " [Hz]" << std::endl; - } - else - { - mean_diff = 0.0; - } - - prn_id++; - } - - double stdev_dp = compute_stdev(mean_doppler_v); - std::cout << "Doppler error stdev = " << stdev_dp << " [Hz]" << std::endl; - ASSERT_LT(stdev_dp, 10.0); -} - - -TEST_F(ObsGpsL1SpaceSystemTest, Observables_system_test) -{ - std::cout << "Validating input RINEX obs (TRUE) file: " << filename_rinex_obs << " ..." << std::endl; - bool is_rinex_obs_valid = check_valid_rinex_obs(filename_rinex_obs, 3); - ASSERT_EQ(true, is_rinex_obs_valid) << "The RINEX observation file " << filename_rinex_obs << " is not well formed. Only RINEX v. 3.00 files are allowed"; - std::cout << "The file is valid." << std::endl; - - // Configure receiver - configure_receiver(); - - // Run the receiver - ASSERT_EQ( run_receiver(), 0) << "Problem executing the software-defined signal generator"; - - std::cout << "Validating RINEX obs file obtained by GNSS-SDR: " << ObsGpsL1SpaceSystemTest::generated_rinex_obs << " ..." << std::endl; - bool is_gen_rinex_obs_valid = check_valid_rinex_obs( "./" + ObsGpsL1SpaceSystemTest::generated_rinex_obs, 2); - ASSERT_EQ(true, is_gen_rinex_obs_valid) << "The RINEX observation file " << ObsGpsL1SpaceSystemTest::generated_rinex_obs << ", generated by GNSS-SDR, is not well formed."; - std::cout << "The file is valid." << std::endl; - - // Check results - check_results(); -} - - -int main(int argc, char **argv) -{ - std::cout << "Running GNSS-SDR in Space Observables validation test..." << std::endl; - int res = 0; - try - { - testing::InitGoogleTest(&argc, argv); - } - catch(...) {} // catch the "testing::internal::::ClassUniqueToAlwaysTrue" from gtest - - google::ParseCommandLineFlags(&argc, &argv, true); - google::InitGoogleLogging(argv[0]); - - // Run the Tests - try - { - res = RUN_ALL_TESTS(); - } - catch(...) - { - LOG(WARNING) << "Unexpected catch"; - } - google::ShutDownCommandLineFlags(); - return res; -} diff --git a/src/tests/system-tests/obs_space_system_test.cc b/src/tests/system-tests/obs_space_system_test.cc new file mode 100644 index 000000000..a227733f1 --- /dev/null +++ b/src/tests/system-tests/obs_space_system_test.cc @@ -0,0 +1,681 @@ +/*! + * \file obs_space_system_test.cc + * \brief This class implements a test for the validation of generated observables. + * \author Carles Fernandez-Prades, 2016. cfernandez(at)cttc.es + * Antonio Ramos, 2017. antonio.ramos(at)cttc.es + * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "concurrent_map.h" +#include "concurrent_queue.h" +#include "control_thread.h" +#include "file_configuration.h" + +// For GPS NAVIGATION (L1) +concurrent_queue global_gps_acq_assist_queue; +concurrent_map global_gps_acq_assist_map; + +DEFINE_string(configuration_file, "./default_configuration.conf", "Path of configuration file"); +DEFINE_string(filename_rinex_true, "./default_rinex.txt", "Path of RINEX true observations"); +DEFINE_string(filename_rinex_obs, "default_string", "Path of RINEX true observations"); +DEFINE_double(pr_error_mean_max, 50.0, "Maximum mean error in pseudorange"); +DEFINE_double(pr_error_std_max, 50.0, "Maximum standard deviation in pseudorange"); +DEFINE_double(cp_error_mean_max, 50.0, "Maximum mean error in carrier phase"); +DEFINE_double(cp_error_std_max, 50.0, "Maximum standard deviation in carrier phase"); +DEFINE_double(dp_error_mean_max, 5.0, "Maximum mean error in Doppler frequency"); +DEFINE_double(dp_error_std_max, 10.0, "Maximum standard deviation in Doppler frequency"); + +class ObsSpaceSystemTest: public ::testing::Test +{ +public: + int configure_receiver(); + int run_receiver(); + void check_results(); + bool check_valid_rinex_obs(std::string filename, int rinex_ver); // return true if the file is a valid Rinex observation file. + void read_rinex_files( + std::vector& pseudorange_ref, + std::vector& carrierphase_ref, + std::vector& doppler_ref, + std::vector& pseudorange_meas, + std::vector& carrierphase_meas, + std::vector& doppler_meas, + int signal_type); + void time_alignment_diff( + std::vector& ref, + std::vector& meas, + std::vector& diff); + void compute_pseudorange_error(std::vector& diff, + double error_th_mean, double error_th_std); + void compute_carrierphase_error( + std::vector& diff, + double error_th_mean, double error_th_std); + void compute_doppler_error( + std::vector& diff, + double error_th_mean, double error_th_std); + std::string filename_rinex_obs = FLAGS_filename_rinex_true; + std::string generated_rinex_obs = FLAGS_filename_rinex_obs; + std::string configuration_file_ = FLAGS_configuration_file; + std::shared_ptr config; + bool gps_1C = false; + bool gps_L5 = false; + bool gal_1B = false; + bool gal_E5a = false; + bool internal_rinex_generation = false; + + /****************/ + const int num_prn_gps = 33; + const int num_prn_gal = 31; + + double pseudorange_error_th_mean = FLAGS_pr_error_mean_max; + double pseudorange_error_th_std= FLAGS_pr_error_std_max; + double carrierphase_error_th_mean = FLAGS_cp_error_mean_max; + double carrierphase_error_th_std = FLAGS_cp_error_std_max; + double doppler_error_th_mean = FLAGS_dp_error_mean_max; + double doppler_error_th_std = FLAGS_dp_error_std_max; + +}; + + +bool ObsSpaceSystemTest::check_valid_rinex_obs(std::string filename, int rinex_ver) +{ + bool res = false; + if(rinex_ver == 2) + { + res = gpstk::isRinexObsFile(filename); + } + if(rinex_ver == 3) + { + res = gpstk::isRinex3ObsFile(filename); + } + return res; +} + +void ObsSpaceSystemTest::read_rinex_files( + std::vector& pseudorange_ref, + std::vector& carrierphase_ref, + std::vector& doppler_ref, + std::vector& pseudorange_meas, + std::vector& carrierphase_meas, + std::vector& doppler_meas, + int signal_type) +{ + bool ref_exist = false; + bool meas_exist = false; + gpstk::SatID::SatelliteSystem sat_type = gpstk::SatID::systemUnknown; + int max_prn = 0; + std::string pr_string; + std::string cp_string; + std::string dp_string; + std::string signal_type_string; + + switch(signal_type) + { + case 0: //GPS L1 + + sat_type = gpstk::SatID::systemGPS; + max_prn = num_prn_gps; + pr_string = "C1C"; + cp_string = "L1C"; + dp_string = "D1C"; + signal_type_string = "GPS L1 C/A"; + break; + + case 1: //Galileo E1B + + sat_type = gpstk::SatID::systemGalileo; + max_prn = num_prn_gal; + pr_string = "C1B"; + cp_string = "L1B"; + dp_string = "D1B"; + signal_type_string = "Galileo E1B"; + break; + + case 2: //GPS L5 + + sat_type = gpstk::SatID::systemGPS; + max_prn = num_prn_gps; + pr_string = "C5X"; + cp_string = "L5X"; + dp_string = "D5X"; + signal_type_string = "GPS L5"; + break; + + case 3: //Galileo E5a + + sat_type = gpstk::SatID::systemGalileo; + max_prn = num_prn_gal; + pr_string = "C5X"; + cp_string = "L5X"; + dp_string = "D5X"; + signal_type_string = "Galileo E5a"; + break; + } + + // Open and read reference RINEX observables file + std::cout << "Read: RINEX " << signal_type_string << " True" << std::endl; + try + { + gpstk::Rinex3ObsStream r_ref(filename_rinex_obs); + r_ref.exceptions(std::ios::failbit); + gpstk::Rinex3ObsData r_ref_data; + gpstk::Rinex3ObsHeader r_ref_header; + gpstk::RinexDatum dataobj; + r_ref >> r_ref_header; + + while (r_ref >> r_ref_data) + { + for (int myprn = 1; myprn < max_prn; myprn++) + { + gpstk::SatID prn( myprn, sat_type); + gpstk::CommonTime time = r_ref_data.time; + double sow(static_cast(time).sow); + gpstk::Rinex3ObsData::DataMap::iterator pointer = r_ref_data.obs.find(prn); + if( pointer == r_ref_data.obs.end() ) + { + // PRN not present; do nothing + } + else + { + dataobj = r_ref_data.getObs(prn, pr_string, r_ref_header); + double P1 = dataobj.data; + pseudorange_ref.at(myprn).insert_rows(pseudorange_ref.at(myprn).n_rows, arma::rowvec({sow, P1})); + + dataobj = r_ref_data.getObs(prn, cp_string, r_ref_header); + double L1 = dataobj.data; + carrierphase_ref.at(myprn).insert_rows(carrierphase_ref.at(myprn).n_rows, arma::rowvec({sow, L1})); + + dataobj = r_ref_data.getObs(prn, dp_string, r_ref_header); + double D1 = dataobj.data; + doppler_ref.at(myprn).insert_rows(doppler_ref.at(myprn).n_rows, arma::rowvec({sow, D1})); + + ref_exist = true; + } // End of 'if( pointer == roe.obs.end() )' + } // end for + } // end while + } // End of 'try' block + catch(const gpstk::FFStreamError& e) + { + std::cout << e; + exit(1); + } + catch(const gpstk::Exception& e) + { + std::cout << e; + exit(1); + } + catch (...) + { + std::cout << "unknown error. I don't feel so well..." << std::endl; + exit(1); + } + + // Open and read measured RINEX observables file + std::cout << "Read: RINEX "<< signal_type_string << " measures" << std::endl; + try + { + std::string arg2_gen; + if(internal_rinex_generation) + { + arg2_gen = std::string("./") + generated_rinex_obs; + } + else + { + arg2_gen = generated_rinex_obs; + } + gpstk::Rinex3ObsStream r_meas(arg2_gen); + r_meas.exceptions(std::ios::failbit); + gpstk::Rinex3ObsData r_meas_data; + gpstk::Rinex3ObsHeader r_meas_header; + gpstk::RinexDatum dataobj; + r_meas >> r_meas_header; + + while (r_meas >> r_meas_data) + { + for (int myprn = 1; myprn < max_prn; myprn++) + { + gpstk::SatID prn( myprn, sat_type); + gpstk::CommonTime time = r_meas_data.time; + double sow(static_cast(time).sow); + gpstk::Rinex3ObsData::DataMap::iterator pointer = r_meas_data.obs.find(prn); + if( pointer == r_meas_data.obs.end() ) + { + // PRN not present; do nothing + } + else + { + dataobj = r_meas_data.getObs(prn, pr_string, r_meas_header); + double P1 = dataobj.data; + pseudorange_meas.at(myprn).insert_rows(pseudorange_meas.at(myprn).n_rows, arma::rowvec({sow, P1})); + + dataobj = r_meas_data.getObs(prn, cp_string, r_meas_header); + double L1 = dataobj.data; + carrierphase_meas.at(myprn).insert_rows(carrierphase_meas.at(myprn).n_rows, arma::rowvec({sow, L1})); + + dataobj = r_meas_data.getObs(prn, dp_string, r_meas_header); + double D1 = dataobj.data; + doppler_meas.at(myprn).insert_rows(doppler_meas.at(myprn).n_rows, arma::rowvec({sow, D1})); + + meas_exist = true; + } // End of 'if( pointer == roe.obs.end() )' + } // end for + } // end while + } // End of 'try' block + catch(const gpstk::FFStreamError& e) + { + std::cout << e; + exit(1); + } + catch(const gpstk::Exception& e) + { + std::cout << e; + exit(1); + } + catch (...) + { + std::cout << "unknown error. I don't feel so well..." << std::endl; + exit(1); + } + EXPECT_TRUE(ref_exist) << "RINEX reference file does not contain " << signal_type_string << " information"; + EXPECT_TRUE(meas_exist) << "RINEX generated file does not contain " << signal_type_string << " information"; +} + +void ObsSpaceSystemTest::time_alignment_diff( + std::vector& ref, + std::vector& meas, + std::vector& diff) +{ + std::vector::iterator iter_ref; + std::vector::iterator iter_meas; + std::vector::iterator iter_diff; + arma::mat mat_aux; + + iter_ref = ref.begin(); + iter_diff = diff.begin(); + for(iter_meas = meas.begin(); iter_meas != meas.end(); iter_meas++) + { + if( !iter_meas->is_empty() && !iter_ref->is_empty() ) + { + arma::uvec index_ = arma::find(iter_meas->col(0) > iter_ref->at(0, 0)); + arma::uword index_min = arma::min(index_); + index_ = arma::find(iter_meas->col(0) < iter_ref->at(iter_ref->n_rows - 1, 0)); + arma::uword index_max = arma::max(index_); + mat_aux = iter_meas->rows(index_min, index_max); + arma::vec ref_aligned; + arma::interp1(iter_ref->col(0), iter_ref->col(1), mat_aux.col(0), ref_aligned); + *iter_diff = ref_aligned - mat_aux.col(1); + } + iter_ref++; + iter_diff++; + } +} + +int ObsSpaceSystemTest::configure_receiver() +{ + config = std::make_shared(configuration_file_); + int d_rinex_ver = config->property("PVT.rinex_version", 0); + if(d_rinex_ver != 2) + { + std::cout << "Invalid RINEX version. Set PVT.rinex_version=2 in configuration file." << std::endl; + std::cout << "GPSTk does not work with RINEX v. 3.02." << std::endl; + } + if( config->property("Channels_1C.count", 0) > 0 ) + {gps_1C = true;} + if( config->property("Channels_1B.count", 0) > 0 ) + {gal_1B = true;} + if( config->property("Channels_5X.count", 0) > 0 ) + {gal_E5a = true;} + if( config->property("Channels_7X.count", 0) > 0 ) //NOT DEFINITIVE!!!!! + {gps_L5 = true;} + + return 0; +} + +int ObsSpaceSystemTest::run_receiver() +{ + std::shared_ptr control_thread; + control_thread = std::make_shared(config); + // start receiver + try + { + control_thread->run(); + } + catch(const boost::exception & e) + { + std::cout << "Boost exception: " << boost::diagnostic_information(e); + } + catch(const std::exception & ex) + { + std::cout << "STD exception: " << ex.what(); + } + // Get the name of the RINEX obs file generated by the receiver + std::this_thread::sleep_for(std::chrono::milliseconds(2000)); + FILE *fp; + std::string argum2 = std::string("/bin/ls *O | grep GSDR | tail -1"); + char buffer[1035]; + fp = popen(&argum2[0], "r"); + if (fp == NULL) + { + std::cout << "Failed to run command: " << argum2 << std::endl; + return -1; + } + while (fgets(buffer, sizeof(buffer), fp) != NULL) + { + std::string aux = std::string(buffer); + generated_rinex_obs = aux.erase(aux.length() - 1, 1); + internal_rinex_generation = true; + } + pclose(fp); + return 0; +} + +void ObsSpaceSystemTest::compute_pseudorange_error( + std::vector& diff, + double error_th_mean, double error_th_std) +{ + int prn_id = 0; + std::vector::iterator iter_diff; + for(iter_diff = diff.begin(); iter_diff != diff.end(); iter_diff++) + { + if(!iter_diff->is_empty()) + { + double d_mean = arma::mean(*iter_diff); + double d_stddev = arma::stddev(*iter_diff); + std::cout << "-- Mean pseudorange difference for sat " << prn_id << ": " << d_mean; + std::cout << " +/- " << d_stddev; + std::cout << " [m]" << std::endl; + EXPECT_LT(d_mean, error_th_mean); + EXPECT_LT(d_stddev, error_th_std); + } + prn_id++; + } +} + +void ObsSpaceSystemTest::compute_carrierphase_error( + std::vector& diff, + double error_th_mean, double error_th_std) +{ + int prn_id = 0; + std::vector::iterator iter_diff; + for(iter_diff = diff.begin(); iter_diff != diff.end(); iter_diff++) + { + if(!iter_diff->is_empty()) + { + double d_mean = arma::mean(*iter_diff); + double d_stddev = arma::stddev(*iter_diff); + std::cout << "-- Mean carrier phase difference for sat " << prn_id << ": " << d_mean; + std::cout << " +/- " << d_stddev; + std::cout << " whole cycles" << std::endl; + EXPECT_LT(d_mean, error_th_mean); + EXPECT_LT(d_stddev, error_th_std); + } + prn_id++; + } +} + +void ObsSpaceSystemTest::compute_doppler_error( + std::vector& diff, + double error_th_mean, double error_th_std) +{ + int prn_id = 0; + std::vector::iterator iter_diff; + for(iter_diff = diff.begin(); iter_diff != diff.end(); iter_diff++) + { + if(!iter_diff->is_empty()) + { + double d_mean = arma::mean(*iter_diff); + double d_stddev = arma::stddev(*iter_diff); + std::cout << "-- Mean Doppler difference for sat " << prn_id << ": " << d_mean; + std::cout << " +/- " << d_stddev; + std::cout << " [Hz]" << std::endl; + EXPECT_LT(d_mean, error_th_mean); + EXPECT_LT(d_stddev, error_th_std); + } + prn_id++; + } +} +void ObsSpaceSystemTest::check_results() +{ + if(gps_1C) + { + std::vector pseudorange_ref(num_prn_gps); + std::vector carrierphase_ref(num_prn_gps); + std::vector doppler_ref(num_prn_gps); + + std::vector pseudorange_meas(num_prn_gps); + std::vector carrierphase_meas(num_prn_gps); + std::vector doppler_meas(num_prn_gps); + + read_rinex_files(pseudorange_ref, carrierphase_ref, doppler_ref, pseudorange_meas, carrierphase_meas, doppler_meas, 0); + + // Time alignment and difference computation + + std::vector pr_diff(num_prn_gps); + std::vector cp_diff(num_prn_gps); + std::vector dp_diff(num_prn_gps); + time_alignment_diff(pseudorange_ref, pseudorange_meas, pr_diff); + time_alignment_diff(carrierphase_ref, carrierphase_meas, cp_diff); + time_alignment_diff(doppler_ref, doppler_meas, dp_diff); + + // Results + std::cout << "GPS L1 C/A obs. results" << std::endl; + + // Compute pseudorange error + + compute_pseudorange_error(pr_diff, pseudorange_error_th_mean, pseudorange_error_th_std); + + // Compute carrier phase error + + compute_carrierphase_error(cp_diff, carrierphase_error_th_mean, carrierphase_error_th_std); + + // Compute Doppler error + + compute_doppler_error(dp_diff, doppler_error_th_mean, doppler_error_th_std); + } + if(gps_L5) + { + std::vector pseudorange_ref(num_prn_gps); + std::vector carrierphase_ref(num_prn_gps); + std::vector doppler_ref(num_prn_gps); + + std::vector pseudorange_meas(num_prn_gps); + std::vector carrierphase_meas(num_prn_gps); + std::vector doppler_meas(num_prn_gps); + + read_rinex_files(pseudorange_ref, carrierphase_ref, doppler_ref, pseudorange_meas, carrierphase_meas, doppler_meas, 2); + + // Time alignment and difference computation + + std::vector pr_diff(num_prn_gps); + std::vector cp_diff(num_prn_gps); + std::vector dp_diff(num_prn_gps); + time_alignment_diff(pseudorange_ref, pseudorange_meas, pr_diff); + time_alignment_diff(carrierphase_ref, carrierphase_meas, cp_diff); + time_alignment_diff(doppler_ref, doppler_meas, dp_diff); + + // Results + std::cout << "GPS L5 obs. results" << std::endl; + + // Compute pseudorange error + + compute_pseudorange_error(pr_diff, pseudorange_error_th_mean, pseudorange_error_th_std); + + // Compute carrier phase error + + compute_carrierphase_error(cp_diff, carrierphase_error_th_mean, carrierphase_error_th_std); + + // Compute Doppler error + + compute_doppler_error(dp_diff, doppler_error_th_mean, doppler_error_th_std); + } + if(gal_1B) + { + std::vector pseudorange_ref(num_prn_gal); + std::vector carrierphase_ref(num_prn_gal); + std::vector doppler_ref(num_prn_gal); + + std::vector pseudorange_meas(num_prn_gal); + std::vector carrierphase_meas(num_prn_gal); + std::vector doppler_meas(num_prn_gal); + + read_rinex_files(pseudorange_ref, carrierphase_ref, doppler_ref, pseudorange_meas, carrierphase_meas, doppler_meas, 1); + + // Time alignment and difference computation + + std::vector pr_diff(num_prn_gal); + std::vector cp_diff(num_prn_gal); + std::vector dp_diff(num_prn_gal); + time_alignment_diff(pseudorange_ref, pseudorange_meas, pr_diff); + time_alignment_diff(carrierphase_ref, carrierphase_meas, cp_diff); + time_alignment_diff(doppler_ref, doppler_meas, dp_diff); + + // Results + std::cout << "Galileo E1B obs. results" << std::endl; + + // Compute pseudorange error + + compute_pseudorange_error(pr_diff, pseudorange_error_th_mean, pseudorange_error_th_std); + + // Compute carrier phase error + + compute_carrierphase_error(cp_diff, carrierphase_error_th_mean, carrierphase_error_th_std); + + // Compute Doppler error + + compute_doppler_error(dp_diff, doppler_error_th_mean, doppler_error_th_std); + } + if(gal_E5a) + { + std::vector pseudorange_ref(num_prn_gal); + std::vector carrierphase_ref(num_prn_gal); + std::vector doppler_ref(num_prn_gal); + + std::vector pseudorange_meas(num_prn_gal); + std::vector carrierphase_meas(num_prn_gal); + std::vector doppler_meas(num_prn_gal); + + read_rinex_files(pseudorange_ref, carrierphase_ref, doppler_ref, pseudorange_meas, carrierphase_meas, doppler_meas, 3); + + // Time alignment and difference computation + + std::vector pr_diff(num_prn_gal); + std::vector cp_diff(num_prn_gal); + std::vector dp_diff(num_prn_gal); + time_alignment_diff(pseudorange_ref, pseudorange_meas, pr_diff); + time_alignment_diff(carrierphase_ref, carrierphase_meas, cp_diff); + time_alignment_diff(doppler_ref, doppler_meas, dp_diff); + + // Results + std::cout << "Galileo E5a obs. results" << std::endl; + + // Compute pseudorange error + + compute_pseudorange_error(pr_diff, pseudorange_error_th_mean, pseudorange_error_th_std); + + // Compute carrier phase error + + compute_carrierphase_error(cp_diff, carrierphase_error_th_mean, carrierphase_error_th_std); + + // Compute Doppler error + + compute_doppler_error(dp_diff, doppler_error_th_mean, doppler_error_th_std); + } +} + + +TEST_F(ObsSpaceSystemTest, Observables_system_test) +{ + std::cout << "Validating input RINEX obs (TRUE) file: " << filename_rinex_obs << " ..." << std::endl; + bool is_rinex_obs_valid = check_valid_rinex_obs(filename_rinex_obs, 3); + ASSERT_EQ(true, is_rinex_obs_valid) << "The RINEX observation file " << filename_rinex_obs << " is not well formed. Only RINEX v. 3.00 files are allowed"; + std::cout << "The file is valid." << std::endl; + // Configure receiver + configure_receiver(); + if(generated_rinex_obs.compare("default_string") == 0) + { + // Run the receiver + ASSERT_EQ( run_receiver(), 0) << "Problem executing the software-defined signal generator"; + } + std::cout << "Validating RINEX obs file obtained by GNSS-SDR: " << generated_rinex_obs << " ..." << std::endl; + bool is_gen_rinex_obs_valid = false; + if(internal_rinex_generation) + { + is_gen_rinex_obs_valid = check_valid_rinex_obs( "./" + generated_rinex_obs, 2); + } + else + { + is_gen_rinex_obs_valid = check_valid_rinex_obs(generated_rinex_obs, 2); + } + ASSERT_EQ(true, is_gen_rinex_obs_valid) << "The RINEX observation file " << generated_rinex_obs << ", generated by GNSS-SDR, is not well formed."; + std::cout << "The file is valid." << std::endl; + // Check results + check_results(); +} + + +int main(int argc, char **argv) +{ + std::cout << "Running GNSS-SDR in Space Observables validation test..." << std::endl; + int res = 0; + try + { + testing::InitGoogleTest(&argc, argv); + } + catch(...) {} // catch the "testing::internal::::ClassUniqueToAlwaysTrue" from gtest + + google::ParseCommandLineFlags(&argc, &argv, true); + google::InitGoogleLogging(argv[0]); + + // Run the Tests + try + { + res = RUN_ALL_TESTS(); + } + catch(...) + { + LOG(WARNING) << "Unexpected catch"; + } + google::ShutDownCommandLineFlags(); + return res; +} From 994233b9f7f6a6092dd4668c2f717f8d4ab66026 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 10 Nov 2017 09:25:18 +0100 Subject: [PATCH 27/60] Change test name --- src/tests/CMakeLists.txt | 14 +++++------ ...pace_system_test.cc => obs_system_test.cc} | 24 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) rename src/tests/system-tests/{obs_space_system_test.cc => obs_system_test.cc} (97%) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index fd5aed1fa..0783209c8 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -479,13 +479,13 @@ if(ENABLE_SYSTEM_TESTING) if(GPSTK_FOUND OR OWN_GPSTK) add_executable(obs_gps_l1_system_test ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/obs_gps_l1_system_test.cc) - add_executable(obs_space_system_test ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/obs_space_system_test.cc) + add_executable(obs_system_test ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/obs_system_test.cc) if(NOT ${GTEST_DIR_LOCAL}) add_dependencies(obs_gps_l1_system_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION} ) - add_dependencies(obs_space_system_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION} ) + add_dependencies(obs_system_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION} ) else(NOT ${GTEST_DIR_LOCAL}) add_dependencies(obs_gps_l1_system_test gtest) - add_dependencies(obs_space_system_test gtest) + add_dependencies(obs_system_test gtest) endif(NOT ${GTEST_DIR_LOCAL}) include_directories(${GPSTK_INCLUDE_DIRS} ${GPSTK_INCLUDE_DIRS}/gpstk) target_link_libraries(obs_gps_l1_system_test ${GFlags_LIBS} @@ -495,7 +495,7 @@ if(ENABLE_SYSTEM_TESTING) gnss_rx ${gpstk_libs}) - target_link_libraries(obs_space_system_test ${GFlags_LIBS} + target_link_libraries(obs_system_test ${GFlags_LIBS} ${GLOG_LIBRARIES} ${GTEST_LIBRARIES} gnss_sp_libs @@ -511,9 +511,9 @@ if(ENABLE_SYSTEM_TESTING) add_custom_command(TARGET obs_gps_l1_system_test POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_SOURCE_DIR}/install/$ ) - add_custom_command(TARGET obs_space_system_test POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ - ${CMAKE_SOURCE_DIR}/install/$ ) + add_custom_command(TARGET obs_system_test POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ + ${CMAKE_SOURCE_DIR}/install/$ ) endif(ENABLE_INSTALL_TESTS) endif(GPSTK_FOUND OR OWN_GPSTK) diff --git a/src/tests/system-tests/obs_space_system_test.cc b/src/tests/system-tests/obs_system_test.cc similarity index 97% rename from src/tests/system-tests/obs_space_system_test.cc rename to src/tests/system-tests/obs_system_test.cc index a227733f1..cb82f302c 100644 --- a/src/tests/system-tests/obs_space_system_test.cc +++ b/src/tests/system-tests/obs_system_test.cc @@ -1,5 +1,5 @@ /*! - * \file obs_space_system_test.cc + * \file obs_system_test.cc * \brief This class implements a test for the validation of generated observables. * \author Carles Fernandez-Prades, 2016. cfernandez(at)cttc.es * Antonio Ramos, 2017. antonio.ramos(at)cttc.es @@ -67,7 +67,7 @@ DEFINE_double(cp_error_std_max, 50.0, "Maximum standard deviation in carrier pha DEFINE_double(dp_error_mean_max, 5.0, "Maximum mean error in Doppler frequency"); DEFINE_double(dp_error_std_max, 10.0, "Maximum standard deviation in Doppler frequency"); -class ObsSpaceSystemTest: public ::testing::Test +class ObsSystemTest: public ::testing::Test { public: int configure_receiver(); @@ -118,7 +118,7 @@ public: }; -bool ObsSpaceSystemTest::check_valid_rinex_obs(std::string filename, int rinex_ver) +bool ObsSystemTest::check_valid_rinex_obs(std::string filename, int rinex_ver) { bool res = false; if(rinex_ver == 2) @@ -132,7 +132,7 @@ bool ObsSpaceSystemTest::check_valid_rinex_obs(std::string filename, int rinex_v return res; } -void ObsSpaceSystemTest::read_rinex_files( +void ObsSystemTest::read_rinex_files( std::vector& pseudorange_ref, std::vector& carrierphase_ref, std::vector& doppler_ref, @@ -321,7 +321,7 @@ void ObsSpaceSystemTest::read_rinex_files( EXPECT_TRUE(meas_exist) << "RINEX generated file does not contain " << signal_type_string << " information"; } -void ObsSpaceSystemTest::time_alignment_diff( +void ObsSystemTest::time_alignment_diff( std::vector& ref, std::vector& meas, std::vector& diff) @@ -351,7 +351,7 @@ void ObsSpaceSystemTest::time_alignment_diff( } } -int ObsSpaceSystemTest::configure_receiver() +int ObsSystemTest::configure_receiver() { config = std::make_shared(configuration_file_); int d_rinex_ver = config->property("PVT.rinex_version", 0); @@ -372,7 +372,7 @@ int ObsSpaceSystemTest::configure_receiver() return 0; } -int ObsSpaceSystemTest::run_receiver() +int ObsSystemTest::run_receiver() { std::shared_ptr control_thread; control_thread = std::make_shared(config); @@ -410,7 +410,7 @@ int ObsSpaceSystemTest::run_receiver() return 0; } -void ObsSpaceSystemTest::compute_pseudorange_error( +void ObsSystemTest::compute_pseudorange_error( std::vector& diff, double error_th_mean, double error_th_std) { @@ -432,7 +432,7 @@ void ObsSpaceSystemTest::compute_pseudorange_error( } } -void ObsSpaceSystemTest::compute_carrierphase_error( +void ObsSystemTest::compute_carrierphase_error( std::vector& diff, double error_th_mean, double error_th_std) { @@ -454,7 +454,7 @@ void ObsSpaceSystemTest::compute_carrierphase_error( } } -void ObsSpaceSystemTest::compute_doppler_error( +void ObsSystemTest::compute_doppler_error( std::vector& diff, double error_th_mean, double error_th_std) { @@ -475,7 +475,7 @@ void ObsSpaceSystemTest::compute_doppler_error( prn_id++; } } -void ObsSpaceSystemTest::check_results() +void ObsSystemTest::check_results() { if(gps_1C) { @@ -624,7 +624,7 @@ void ObsSpaceSystemTest::check_results() } -TEST_F(ObsSpaceSystemTest, Observables_system_test) +TEST_F(ObsSystemTest, Observables_system_test) { std::cout << "Validating input RINEX obs (TRUE) file: " << filename_rinex_obs << " ..." << std::endl; bool is_rinex_obs_valid = check_valid_rinex_obs(filename_rinex_obs, 3); From f55f3d34a686d0a4021482101bb061a979343580 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 10 Nov 2017 10:46:53 +0100 Subject: [PATCH 28/60] Print test results in file in a more elegant way --- src/tests/system-tests/position_test.cc | 70 ++++++++++-------- src/tests/system-tests/ttff_gps_l1.cc | 96 ++++++++----------------- 2 files changed, 70 insertions(+), 96 deletions(-) diff --git a/src/tests/system-tests/position_test.cc b/src/tests/system-tests/position_test.cc index c139216e5..0b3cd098d 100644 --- a/src/tests/system-tests/position_test.cc +++ b/src/tests/system-tests/position_test.cc @@ -60,6 +60,13 @@ concurrent_map global_gps_acq_assist_map; class StaticPositionSystemTest: public ::testing::Test { public: + int configure_generator(); + int generate_signal(); + int configure_receiver(); + int run_receiver(); + void check_results(); + +private: std::string generator_binary; std::string p1; std::string p2; @@ -72,12 +79,6 @@ public: std::string filename_rinex_obs = FLAGS_filename_rinex_obs; std::string filename_raw_data = FLAGS_filename_raw_data; - int configure_generator(); - int generate_signal(); - - int configure_receiver(); - int run_receiver(); - void check_results(); void print_results(const std::vector & east, const std::vector & north, const std::vector & up); @@ -88,13 +89,12 @@ public: void geodetic2Enu(const double latitude, const double longitude, const double altitude, double* east, double* north, double* up); + void geodetic2Ecef(const double latitude, const double longitude, const double altitude, + double* x, double* y, double* z); + std::shared_ptr config; std::shared_ptr config_f; std::string generated_kml_file; - -private: - void geodetic2Ecef(const double latitude, const double longitude, const double altitude, - double* x, double* y, double* z); }; @@ -521,29 +521,41 @@ void StaticPositionSystemTest::check_results() double sum__u = std::accumulate(pos_u.begin(), pos_u.end(), 0.0); double mean__u = sum__u / pos_u.size(); + std::stringstream stm; + std::ofstream position_test_file; + if(FLAGS_config_file_ptest.empty()) { - std::cout << "---- ACCURACY ----" << std::endl; - std::cout << "2DRMS = " << 2 * sqrt(sigma_E_2_accuracy + sigma_N_2_accuracy) << " [m]" << std::endl; - std::cout << "DRMS = " << sqrt(sigma_E_2_accuracy + sigma_N_2_accuracy) << " [m]" << std::endl; - std::cout << "CEP = " << 0.62 * compute_stdev_accuracy(pos_n, 0.0) + 0.56 * compute_stdev_accuracy(pos_e, 0.0) << " [m]" << std::endl; - std::cout << "99% SAS = " << 1.122 * (sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl; - std::cout << "90% SAS = " << 0.833 * (sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl; - std::cout << "MRSE = " << sqrt(sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl; - std::cout << "SEP = " << 0.51 * (sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl; - std::cout << "Bias 2D = " << sqrt(std::pow(mean__e, 2.0) + std::pow(mean__n, 2.0)) << " [m]" << std::endl; - std::cout << "Bias 3D = " << sqrt(std::pow(mean__e, 2.0) + std::pow(mean__n, 2.0) + std::pow(mean__u, 2.0)) << " [m]" << std::endl; - std::cout << std::endl; + stm << "---- ACCURACY ----" << std::endl; + stm << "2DRMS = " << 2 * sqrt(sigma_E_2_accuracy + sigma_N_2_accuracy) << " [m]" << std::endl; + stm << "DRMS = " << sqrt(sigma_E_2_accuracy + sigma_N_2_accuracy) << " [m]" << std::endl; + stm << "CEP = " << 0.62 * compute_stdev_accuracy(pos_n, 0.0) + 0.56 * compute_stdev_accuracy(pos_e, 0.0) << " [m]" << std::endl; + stm << "99% SAS = " << 1.122 * (sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl; + stm << "90% SAS = " << 0.833 * (sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl; + stm << "MRSE = " << sqrt(sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl; + stm << "SEP = " << 0.51 * (sigma_E_2_accuracy + sigma_N_2_accuracy + sigma_U_2_accuracy) << " [m]" << std::endl; + stm << "Bias 2D = " << sqrt(std::pow(mean__e, 2.0) + std::pow(mean__n, 2.0)) << " [m]" << std::endl; + stm << "Bias 3D = " << sqrt(std::pow(mean__e, 2.0) + std::pow(mean__n, 2.0) + std::pow(mean__u, 2.0)) << " [m]" << std::endl; + stm << std::endl; } - std::cout << "---- PRECISION ----" << std::endl; - std::cout << "2DRMS = " << 2 * sqrt(sigma_E_2_precision + sigma_N_2_precision) << " [m]" << std::endl; - std::cout << "DRMS = " << sqrt(sigma_E_2_precision + sigma_N_2_precision) << " [m]" << std::endl; - std::cout << "CEP = " << 0.62 * compute_stdev_precision(pos_n) + 0.56 * compute_stdev_precision(pos_e) << " [m]" << std::endl; - std::cout << "99% SAS = " << 1.122 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl; - std::cout << "90% SAS = " << 0.833 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl; - std::cout << "MRSE = " << sqrt(sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl; - std::cout << "SEP = " << 0.51 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl; + stm << "---- PRECISION ----" << std::endl; + stm << "2DRMS = " << 2 * sqrt(sigma_E_2_precision + sigma_N_2_precision) << " [m]" << std::endl; + stm << "DRMS = " << sqrt(sigma_E_2_precision + sigma_N_2_precision) << " [m]" << std::endl; + stm << "CEP = " << 0.62 * compute_stdev_precision(pos_n) + 0.56 * compute_stdev_precision(pos_e) << " [m]" << std::endl; + stm << "99% SAS = " << 1.122 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl; + stm << "90% SAS = " << 0.833 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl; + stm << "MRSE = " << sqrt(sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl; + stm << "SEP = " << 0.51 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision) << " [m]" << std::endl; + + std::cout << stm.rdbuf(); + std::string output_filename = "position_test_output_" + StaticPositionSystemTest::generated_kml_file.erase(StaticPositionSystemTest::generated_kml_file.length() - 3,3) + "txt"; + position_test_file.open(output_filename.c_str()); + if(position_test_file.is_open()) + { + position_test_file << stm.str(); + position_test_file.close(); + } // Sanity Check double precision_SEP = 0.51 * (sigma_E_2_precision + sigma_N_2_precision + sigma_U_2_precision); diff --git a/src/tests/system-tests/ttff_gps_l1.cc b/src/tests/system-tests/ttff_gps_l1.cc index 0a1047005..fb6eabcf1 100644 --- a/src/tests/system-tests/ttff_gps_l1.cc +++ b/src/tests/system-tests/ttff_gps_l1.cc @@ -359,96 +359,58 @@ void TfttGpsL1CATest::print_TTFF_report(const std::vector & ttff_v, std: std::string default_str = "default"; source = config_->property("SignalSource.implementation", default_str); - if (ttff_report_file.is_open()) - { - ttff_report_file << "---------------------------" << std::endl; - ttff_report_file << " Time-To-First-Fix Report" << std::endl; - ttff_report_file << "---------------------------" << std::endl; - ttff_report_file << "Initial receiver status: "; - if (read_ephemeris) - { - ttff_report_file << "Hot start." << std::endl; - } - else - { - ttff_report_file << "Cold start." << std::endl; - } - ttff_report_file << "A-GNSS: "; - if (agnss && read_ephemeris) - { - ttff_report_file << "Enabled." << std::endl; - } - else - { - ttff_report_file << "Disabled." << std::endl; - } - ttff_report_file << "Valid measurements (" << ttff.size() << "/" << FLAGS_num_measurements << "): "; - for(double ttff_ : ttff) ttff_report_file << ttff_ << " "; - ttff_report_file << std::endl; - ttff_report_file << "TTFF mean: " << mean << " [s]" << std::endl; - if (ttff.size() > 0) - { - ttff_report_file << "TTFF max: " << *max_ttff << " [s]" << std::endl; - ttff_report_file << "TTFF min: " << *min_ttff << " [s]" << std::endl; - } - ttff_report_file << "TTFF stdev: " << stdev << " [s]" << std::endl; - ttff_report_file << "Operating System: " << std::string(HOST_SYSTEM) << std::endl; - ttff_report_file << "Navigation mode: " << "3D" << std::endl; + std::stringstream stm; - if(source.compare("UHD_Signal_Source")) - { - ttff_report_file << "Source: File" << std::endl; - } - else - { - ttff_report_file << "Source: Live" << std::endl; - } - ttff_report_file << "---------------------------" << std::endl; - } - ttff_report_file.close(); - std::cout << "---------------------------" << std::endl; - std::cout << " Time-To-First-Fix Report" << std::endl; - std::cout << "---------------------------" << std::endl; - std::cout << "Initial receiver status: "; + stm << "---------------------------" << std::endl; + stm << " Time-To-First-Fix Report" << std::endl; + stm << "---------------------------" << std::endl; + stm << "Initial receiver status: "; if (read_ephemeris) { - std::cout << "Hot start." << std::endl; + stm << "Hot start." << std::endl; } else { - std::cout << "Cold start." << std::endl; + stm << "Cold start." << std::endl; } - std::cout << "A-GNSS: "; + stm << "A-GNSS: "; if (agnss && read_ephemeris) { - std::cout << "Enabled." << std::endl; + stm << "Enabled." << std::endl; } else { - std::cout << "Disabled." << std::endl; + stm << "Disabled." << std::endl; } - std::cout << "Valid measurements (" << ttff.size() << "/" << FLAGS_num_measurements << "): "; - for(double ttff_ : ttff) std::cout << ttff_ << " "; - std::cout << std::endl; - std::cout << "TTFF mean: " << mean << " [s]" << std::endl; + stm << "Valid measurements (" << ttff.size() << "/" << FLAGS_num_measurements << "): "; + for(double ttff_ : ttff) stm << ttff_ << " "; + stm << std::endl; + stm << "TTFF mean: " << mean << " [s]" << std::endl; if (ttff.size() > 0) { - std::cout << "TTFF max: " << *max_ttff << " [s]" << std::endl; - std::cout << "TTFF min: " << *min_ttff << " [s]" << std::endl; + stm << "TTFF max: " << *max_ttff << " [s]" << std::endl; + stm << "TTFF min: " << *min_ttff << " [s]" << std::endl; } - std::cout << "TTFF stdev: " << stdev << " [s]" << std::endl; - std::cout << "Operating System: " << std::string(HOST_SYSTEM) << std::endl; - std::cout << "Navigation mode: " << "3D" << std::endl; + stm << "TTFF stdev: " << stdev << " [s]" << std::endl; + stm << "Operating System: " << std::string(HOST_SYSTEM) << std::endl; + stm << "Navigation mode: " << "3D" << std::endl; if(source.compare("UHD_Signal_Source")) { - std::cout << "Source: File" << std::endl; + stm << "Source: File" << std::endl; } else { - std::cout << "Source: Live" << std::endl; + stm << "Source: Live" << std::endl; + } + stm << "---------------------------" << std::endl; + + std::cout << stm.rdbuf(); + if (ttff_report_file.is_open()) + { + ttff_report_file << stm.str(); + ttff_report_file.close(); } - std::cout << "---------------------------" << std::endl; } From b838d5d34c3288d689643949eadcebeaa26fb201 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 10 Nov 2017 12:04:21 +0100 Subject: [PATCH 29/60] Improved pseudorange error computation --- src/tests/system-tests/obs_system_test.cc | 153 +++++++++++++++++++--- 1 file changed, 133 insertions(+), 20 deletions(-) diff --git a/src/tests/system-tests/obs_system_test.cc b/src/tests/system-tests/obs_system_test.cc index cb82f302c..b5e291e90 100644 --- a/src/tests/system-tests/obs_system_test.cc +++ b/src/tests/system-tests/obs_system_test.cc @@ -60,12 +60,12 @@ concurrent_map global_gps_acq_assist_map; DEFINE_string(configuration_file, "./default_configuration.conf", "Path of configuration file"); DEFINE_string(filename_rinex_true, "./default_rinex.txt", "Path of RINEX true observations"); DEFINE_string(filename_rinex_obs, "default_string", "Path of RINEX true observations"); -DEFINE_double(pr_error_mean_max, 50.0, "Maximum mean error in pseudorange"); -DEFINE_double(pr_error_std_max, 50.0, "Maximum standard deviation in pseudorange"); -DEFINE_double(cp_error_mean_max, 50.0, "Maximum mean error in carrier phase"); -DEFINE_double(cp_error_std_max, 50.0, "Maximum standard deviation in carrier phase"); -DEFINE_double(dp_error_mean_max, 5.0, "Maximum mean error in Doppler frequency"); -DEFINE_double(dp_error_std_max, 10.0, "Maximum standard deviation in Doppler frequency"); +DEFINE_double(pr_error_mean_max, 25.0, "Maximum mean error in pseudorange"); +DEFINE_double(pr_error_std_max, 5.0, "Maximum standard deviation in pseudorange"); +DEFINE_double(cp_error_mean_max, 5.0, "Maximum mean error in carrier phase"); +DEFINE_double(cp_error_std_max, 2.5, "Maximum standard deviation in carrier phase"); +DEFINE_double(dp_error_mean_max, 50.0, "Maximum mean error in Doppler frequency"); +DEFINE_double(dp_error_std_max, 15.0, "Maximum standard deviation in Doppler frequency"); class ObsSystemTest: public ::testing::Test { @@ -81,11 +81,21 @@ public: std::vector& pseudorange_meas, std::vector& carrierphase_meas, std::vector& doppler_meas, + arma::mat& sow_prn_ref, int signal_type); void time_alignment_diff( std::vector& ref, std::vector& meas, std::vector& diff); + void time_alignment_diff_cp( + std::vector& ref, + std::vector& meas, + std::vector& diff); + void time_alignment_diff_pr( + std::vector& ref, + std::vector& meas, + std::vector& diff, + arma::mat& sow_prn_ref); void compute_pseudorange_error(std::vector& diff, double error_th_mean, double error_th_std); void compute_carrierphase_error( @@ -139,6 +149,7 @@ void ObsSystemTest::read_rinex_files( std::vector& pseudorange_meas, std::vector& carrierphase_meas, std::vector& doppler_meas, + arma::mat& sow_prn_ref, int signal_type) { bool ref_exist = false; @@ -149,6 +160,7 @@ void ObsSystemTest::read_rinex_files( std::string cp_string; std::string dp_string; std::string signal_type_string; + sow_prn_ref.reset(); switch(signal_type) { @@ -273,7 +285,11 @@ void ObsSystemTest::read_rinex_files( while (r_meas >> r_meas_data) { - for (int myprn = 1; myprn < max_prn; myprn++) + double pr_min = 0.0; + double sow_insert = 0.0; + double prn_min = 0.0; + bool set_pr_min = true; + for (int myprn = 1; myprn < max_prn; myprn++) { gpstk::SatID prn( myprn, sat_type); gpstk::CommonTime time = r_meas_data.time; @@ -288,6 +304,13 @@ void ObsSystemTest::read_rinex_files( dataobj = r_meas_data.getObs(prn, pr_string, r_meas_header); double P1 = dataobj.data; pseudorange_meas.at(myprn).insert_rows(pseudorange_meas.at(myprn).n_rows, arma::rowvec({sow, P1})); + if(set_pr_min || (P1 < pr_min)) + { + set_pr_min = false; + pr_min = P1; + sow_insert = sow; + prn_min = static_cast(myprn); + } dataobj = r_meas_data.getObs(prn, cp_string, r_meas_header); double L1 = dataobj.data; @@ -300,6 +323,7 @@ void ObsSystemTest::read_rinex_files( meas_exist = true; } // End of 'if( pointer == roe.obs.end() )' } // end for + sow_prn_ref.insert_rows(sow_prn_ref.n_rows, arma::rowvec({sow_insert, pr_min, prn_min})); } // end while } // End of 'try' block catch(const gpstk::FFStreamError& e) @@ -351,6 +375,94 @@ void ObsSystemTest::time_alignment_diff( } } +void ObsSystemTest::time_alignment_diff_cp( + std::vector& ref, + std::vector& meas, + std::vector& diff) +{ + std::vector::iterator iter_ref; + std::vector::iterator iter_meas; + std::vector::iterator iter_diff; + arma::mat mat_aux; + + iter_ref = ref.begin(); + iter_diff = diff.begin(); + for(iter_meas = meas.begin(); iter_meas != meas.end(); iter_meas++) + { + if( !iter_meas->is_empty() && !iter_ref->is_empty() ) + { + arma::uvec index_ = arma::find(iter_meas->col(0) > iter_ref->at(0, 0)); + arma::uword index_min = arma::min(index_); + index_ = arma::find(iter_meas->col(0) < iter_ref->at(iter_ref->n_rows - 1, 0)); + arma::uword index_max = arma::max(index_); + mat_aux = iter_meas->rows(index_min, index_max); + mat_aux.col(1) -= arma::min(mat_aux.col(1)); + arma::vec ref_aligned; + arma::interp1(iter_ref->col(0), iter_ref->col(1), mat_aux.col(0), ref_aligned); + ref_aligned -= arma::min(ref_aligned); + *iter_diff = ref_aligned - mat_aux.col(1); + } + iter_ref++; + iter_diff++; + } +} + + +void ObsSystemTest::time_alignment_diff_pr( + std::vector& ref, + std::vector& meas, + std::vector& diff, + arma::mat& sow_prn_ref) +{ + std::vector::iterator iter_ref; + std::vector::iterator iter_meas; + std::vector::iterator iter_diff; + arma::mat mat_aux; + arma::vec subtraction_meas; + arma::vec subtraction_ref; + + arma::mat subtraction_pr_ref = sow_prn_ref; + arma::vec::iterator iter_vec0 = subtraction_pr_ref.begin_col(0); + arma::vec::iterator iter_vec1 = subtraction_pr_ref.begin_col(1); + arma::vec::iterator iter_vec2 = subtraction_pr_ref.begin_col(2); + + for(iter_vec1 = subtraction_pr_ref.begin_col(1); iter_vec1 != subtraction_pr_ref.end_col(1); iter_vec1++) + { + arma::vec aux_pr; //vector with only 1 element + arma::vec aux_sow = {*iter_vec0}; //vector with only 1 element + arma::interp1(ref.at(static_cast(*iter_vec2)).col(0), + ref.at(static_cast(*iter_vec2)).col(1), + aux_sow, + aux_pr); + *iter_vec1 = aux_pr(0); + iter_vec0++; + iter_vec2++; + } + + iter_ref = ref.begin(); + iter_diff = diff.begin(); + for(iter_meas = meas.begin(); iter_meas != meas.end(); iter_meas++) + { + if( !iter_meas->is_empty() && !iter_ref->is_empty() ) + { + arma::uvec index_ = arma::find(iter_meas->col(0) > iter_ref->at(0, 0)); + arma::uword index_min = arma::min(index_); + index_ = arma::find(iter_meas->col(0) < iter_ref->at(iter_ref->n_rows - 1, 0)); + arma::uword index_max = arma::max(index_); + mat_aux = iter_meas->rows(index_min, index_max); + arma::interp1(sow_prn_ref.col(0), sow_prn_ref.col(1), mat_aux.col(0), subtraction_meas); + mat_aux.col(1) -= subtraction_meas; + arma::vec ref_aligned; + arma::interp1(iter_ref->col(0), iter_ref->col(1), mat_aux.col(0), ref_aligned); + arma::interp1(subtraction_pr_ref.col(0), subtraction_pr_ref.col(1), mat_aux.col(0), subtraction_ref); + ref_aligned -= subtraction_ref; + *iter_diff = ref_aligned - mat_aux.col(1); + } + iter_ref++; + iter_diff++; + } +} + int ObsSystemTest::configure_receiver() { config = std::make_shared(configuration_file_); @@ -477,7 +589,8 @@ void ObsSystemTest::compute_doppler_error( } void ObsSystemTest::check_results() { - if(gps_1C) + arma::mat sow_prn_ref; + if(gps_1C) { std::vector pseudorange_ref(num_prn_gps); std::vector carrierphase_ref(num_prn_gps); @@ -487,15 +600,15 @@ void ObsSystemTest::check_results() std::vector carrierphase_meas(num_prn_gps); std::vector doppler_meas(num_prn_gps); - read_rinex_files(pseudorange_ref, carrierphase_ref, doppler_ref, pseudorange_meas, carrierphase_meas, doppler_meas, 0); + read_rinex_files(pseudorange_ref, carrierphase_ref, doppler_ref, pseudorange_meas, carrierphase_meas, doppler_meas, sow_prn_ref, 0); // Time alignment and difference computation std::vector pr_diff(num_prn_gps); std::vector cp_diff(num_prn_gps); std::vector dp_diff(num_prn_gps); - time_alignment_diff(pseudorange_ref, pseudorange_meas, pr_diff); - time_alignment_diff(carrierphase_ref, carrierphase_meas, cp_diff); + time_alignment_diff_pr(pseudorange_ref, pseudorange_meas, pr_diff, sow_prn_ref); + time_alignment_diff_cp(carrierphase_ref, carrierphase_meas, cp_diff); time_alignment_diff(doppler_ref, doppler_meas, dp_diff); // Results @@ -523,15 +636,15 @@ void ObsSystemTest::check_results() std::vector carrierphase_meas(num_prn_gps); std::vector doppler_meas(num_prn_gps); - read_rinex_files(pseudorange_ref, carrierphase_ref, doppler_ref, pseudorange_meas, carrierphase_meas, doppler_meas, 2); + read_rinex_files(pseudorange_ref, carrierphase_ref, doppler_ref, pseudorange_meas, carrierphase_meas, doppler_meas, sow_prn_ref, 2); // Time alignment and difference computation std::vector pr_diff(num_prn_gps); std::vector cp_diff(num_prn_gps); std::vector dp_diff(num_prn_gps); - time_alignment_diff(pseudorange_ref, pseudorange_meas, pr_diff); - time_alignment_diff(carrierphase_ref, carrierphase_meas, cp_diff); + time_alignment_diff_pr(pseudorange_ref, pseudorange_meas, pr_diff, sow_prn_ref); + time_alignment_diff_cp(carrierphase_ref, carrierphase_meas, cp_diff); time_alignment_diff(doppler_ref, doppler_meas, dp_diff); // Results @@ -559,15 +672,15 @@ void ObsSystemTest::check_results() std::vector carrierphase_meas(num_prn_gal); std::vector doppler_meas(num_prn_gal); - read_rinex_files(pseudorange_ref, carrierphase_ref, doppler_ref, pseudorange_meas, carrierphase_meas, doppler_meas, 1); + read_rinex_files(pseudorange_ref, carrierphase_ref, doppler_ref, pseudorange_meas, carrierphase_meas, doppler_meas, sow_prn_ref, 1); // Time alignment and difference computation std::vector pr_diff(num_prn_gal); std::vector cp_diff(num_prn_gal); std::vector dp_diff(num_prn_gal); - time_alignment_diff(pseudorange_ref, pseudorange_meas, pr_diff); - time_alignment_diff(carrierphase_ref, carrierphase_meas, cp_diff); + time_alignment_diff_pr(pseudorange_ref, pseudorange_meas, pr_diff, sow_prn_ref); + time_alignment_diff_cp(carrierphase_ref, carrierphase_meas, cp_diff); time_alignment_diff(doppler_ref, doppler_meas, dp_diff); // Results @@ -595,15 +708,15 @@ void ObsSystemTest::check_results() std::vector carrierphase_meas(num_prn_gal); std::vector doppler_meas(num_prn_gal); - read_rinex_files(pseudorange_ref, carrierphase_ref, doppler_ref, pseudorange_meas, carrierphase_meas, doppler_meas, 3); + read_rinex_files(pseudorange_ref, carrierphase_ref, doppler_ref, pseudorange_meas, carrierphase_meas, doppler_meas, sow_prn_ref, 3); // Time alignment and difference computation std::vector pr_diff(num_prn_gal); std::vector cp_diff(num_prn_gal); std::vector dp_diff(num_prn_gal); - time_alignment_diff(pseudorange_ref, pseudorange_meas, pr_diff); - time_alignment_diff(carrierphase_ref, carrierphase_meas, cp_diff); + time_alignment_diff_pr(pseudorange_ref, pseudorange_meas, pr_diff, sow_prn_ref); + time_alignment_diff_cp(carrierphase_ref, carrierphase_meas, cp_diff); time_alignment_diff(doppler_ref, doppler_meas, dp_diff); // Results From 6e878920d51c93555b2756c95678bdbc37b990e0 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 10 Nov 2017 12:34:20 +0100 Subject: [PATCH 30/60] Avoid working with optional testing executables from old builds If the testing flags are switched ON and then OFF, optional executables are deleted from the install folder. If the flag is switched to ON again, executables are rebuild and copied to the install folder. --- src/tests/CMakeLists.txt | 46 ++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 8464e5199..54ff6e386 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -410,13 +410,20 @@ if(ENABLE_SYSTEM_TESTING) set(HOST_SYSTEM "MacOS") endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") add_definitions(-DHOST_SYSTEM="${HOST_SYSTEM}") - add_executable(ttff - ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/ttff_gps_l1.cc ) + set(TTFF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/ttff_gps_l1.cc) + + # Ensure that ttff is rebuild if was previously built and then removed + if(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/ttff) + execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${TTFF_SOURCES}) + endif(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/ttff) + + add_executable(ttff ${TTFF_SOURCES} ) if(NOT ${GTEST_DIR_LOCAL}) add_dependencies(ttff gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) else(NOT ${GTEST_DIR_LOCAL}) add_dependencies(ttff gtest) endif(NOT ${GTEST_DIR_LOCAL}) + target_link_libraries(ttff ${Boost_LIBRARIES} ${GFlags_LIBS} @@ -444,8 +451,12 @@ if(ENABLE_SYSTEM_TESTING) endif(ENABLE_INSTALL_TESTS) if(ENABLE_SYSTEM_TESTING_EXTRA) - add_executable(position_test - ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/position_test.cc ) + set(POSITION_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/position_test.cc) + # Ensure that position_test is rebuild if was previously built and then removed + if(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/position_test) + execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${POSITION_TEST_SOURCES}) + endif(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/position_test) + add_executable(position_test ${POSITION_TEST_SOURCES}) if(NOT ${GTEST_DIR_LOCAL}) add_dependencies(position_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) else(NOT ${GTEST_DIR_LOCAL}) @@ -478,7 +489,12 @@ if(ENABLE_SYSTEM_TESTING) endif(ENABLE_INSTALL_TESTS) if(GPSTK_FOUND OR OWN_GPSTK) - add_executable(obs_gps_l1_system_test ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/obs_gps_l1_system_test.cc) + set(OBS_GPS_L1_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/obs_gps_l1_system_test.cc) + # Ensure that obs_gps_l1_system_test is rebuild if was previously built and then removed + if(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) + execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${OBS_GPS_L1_TEST_SOURCES}) + endif(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) + add_executable(obs_gps_l1_system_test ${OBS_GPS_L1_TEST_SOURCES}) if(NOT ${GTEST_DIR_LOCAL}) add_dependencies(obs_gps_l1_system_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION} ) else(NOT ${GTEST_DIR_LOCAL}) @@ -503,8 +519,26 @@ if(ENABLE_SYSTEM_TESTING) ${CMAKE_SOURCE_DIR}/install/$ ) endif(ENABLE_INSTALL_TESTS) endif(GPSTK_FOUND OR OWN_GPSTK) + else(ENABLE_SYSTEM_TESTING_EXTRA) + # Avoid working with old executables if they were switched ON and then OFF + if(EXISTS ${CMAKE_SOURCE_DIR}/install/position_test) + file(REMOVE ${CMAKE_SOURCE_DIR}/install/position_test) + endif(EXISTS ${CMAKE_SOURCE_DIR}/install/position_test) + if(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) + file(REMOVE ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) + endif(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) endif(ENABLE_SYSTEM_TESTING_EXTRA) - +else(ENABLE_SYSTEM_TESTING) + # Avoid working with old executables if they were switched ON and then OFF + if(EXISTS ${CMAKE_SOURCE_DIR}/install/ttff) + file(REMOVE ${CMAKE_SOURCE_DIR}/install/ttff) + endif(EXISTS ${CMAKE_SOURCE_DIR}/install/ttff) + if(EXISTS ${CMAKE_SOURCE_DIR}/install/position_test) + file(REMOVE ${CMAKE_SOURCE_DIR}/install/position_test) + endif(EXISTS ${CMAKE_SOURCE_DIR}/install/position_test) + if(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) + file(REMOVE ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) + endif(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) endif(ENABLE_SYSTEM_TESTING) From baf2afdd3eeee4d1c4fe6cc9f51ceb486cac7419 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 10 Nov 2017 14:12:25 +0100 Subject: [PATCH 31/60] Added GnuPlot to observables system test --- src/tests/system-tests/obs_system_test.cc | 188 +++++++++++++++++++--- 1 file changed, 162 insertions(+), 26 deletions(-) diff --git a/src/tests/system-tests/obs_system_test.cc b/src/tests/system-tests/obs_system_test.cc index b5e291e90..47a46e7dd 100644 --- a/src/tests/system-tests/obs_system_test.cc +++ b/src/tests/system-tests/obs_system_test.cc @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -48,6 +49,8 @@ #include #include #include +#include "gnuplot_i.h" +#include "test_flags.h" #include "concurrent_map.h" #include "concurrent_queue.h" #include "control_thread.h" @@ -66,6 +69,7 @@ DEFINE_double(cp_error_mean_max, 5.0, "Maximum mean error in carrier phase"); DEFINE_double(cp_error_std_max, 2.5, "Maximum standard deviation in carrier phase"); DEFINE_double(dp_error_mean_max, 50.0, "Maximum mean error in Doppler frequency"); DEFINE_double(dp_error_std_max, 15.0, "Maximum standard deviation in Doppler frequency"); +DEFINE_bool(plot_obs_sys_test, false, "Plots results of ObsSystemTest with gnuplot"); class ObsSystemTest: public ::testing::Test { @@ -97,13 +101,16 @@ public: std::vector& diff, arma::mat& sow_prn_ref); void compute_pseudorange_error(std::vector& diff, - double error_th_mean, double error_th_std); + double error_th_mean, double error_th_std, + std::string signal_name); void compute_carrierphase_error( std::vector& diff, - double error_th_mean, double error_th_std); + double error_th_mean, double error_th_std, + std::string signal_name); void compute_doppler_error( std::vector& diff, - double error_th_mean, double error_th_std); + double error_th_mean, double error_th_std, + std::string signal_name); std::string filename_rinex_obs = FLAGS_filename_rinex_true; std::string generated_rinex_obs = FLAGS_filename_rinex_obs; std::string configuration_file_ = FLAGS_configuration_file; @@ -466,12 +473,7 @@ void ObsSystemTest::time_alignment_diff_pr( int ObsSystemTest::configure_receiver() { config = std::make_shared(configuration_file_); - int d_rinex_ver = config->property("PVT.rinex_version", 0); - if(d_rinex_ver != 2) - { - std::cout << "Invalid RINEX version. Set PVT.rinex_version=2 in configuration file." << std::endl; - std::cout << "GPSTk does not work with RINEX v. 3.02." << std::endl; - } + if( config->property("Channels_1C.count", 0) > 0 ) {gps_1C = true;} if( config->property("Channels_1B.count", 0) > 0 ) @@ -524,16 +526,23 @@ int ObsSystemTest::run_receiver() void ObsSystemTest::compute_pseudorange_error( std::vector& diff, - double error_th_mean, double error_th_std) + double error_th_mean, double error_th_std, + std::string signal_name) { int prn_id = 0; std::vector::iterator iter_diff; + std::vector means; + std::vector stddevs; + std::vector prns; for(iter_diff = diff.begin(); iter_diff != diff.end(); iter_diff++) { if(!iter_diff->is_empty()) { double d_mean = arma::mean(*iter_diff); + means.push_back(d_mean); double d_stddev = arma::stddev(*iter_diff); + stddevs.push_back(d_stddev); + prns.push_back(static_cast(prn_id)); std::cout << "-- Mean pseudorange difference for sat " << prn_id << ": " << d_mean; std::cout << " +/- " << d_stddev; std::cout << " [m]" << std::endl; @@ -542,20 +551,62 @@ void ObsSystemTest::compute_pseudorange_error( } prn_id++; } + if(FLAGS_plot_obs_sys_test == true) + { + const std::string gnuplot_executable(FLAGS_gnuplot_executable); + if(gnuplot_executable.empty()) + { + std::cout << "WARNING: Although the flag plot_obs_sys_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(signal_name + " Pseudorange error"); + g1.set_grid(); + g1.set_xlabel("PRN"); + g1.set_ylabel("Pseudorange error [m]"); + g1.plot_xy(prns, means, "Mean"); + g1.plot_xy(prns, stddevs, "Standard deviation"); + //g1.savetops("FFT_execution_times_extended"); + //g1.savetopdf("FFT_execution_times_extended", 18); + g1.showonscreen(); // window output + } + catch (const GnuplotException & ge) + { + std::cout << ge.what() << std::endl; + } + } + } } void ObsSystemTest::compute_carrierphase_error( std::vector& diff, - double error_th_mean, double error_th_std) + double error_th_mean, double error_th_std, + std::string signal_name) { int prn_id = 0; + std::vector means; + std::vector stddevs; + std::vector prns; std::vector::iterator iter_diff; for(iter_diff = diff.begin(); iter_diff != diff.end(); iter_diff++) { if(!iter_diff->is_empty()) { double d_mean = arma::mean(*iter_diff); + means.push_back(d_mean); double d_stddev = arma::stddev(*iter_diff); + stddevs.push_back(d_stddev); + prns.push_back(static_cast(prn_id)); std::cout << "-- Mean carrier phase difference for sat " << prn_id << ": " << d_mean; std::cout << " +/- " << d_stddev; std::cout << " whole cycles" << std::endl; @@ -564,20 +615,62 @@ void ObsSystemTest::compute_carrierphase_error( } prn_id++; } + if(FLAGS_plot_obs_sys_test == true) + { + const std::string gnuplot_executable(FLAGS_gnuplot_executable); + if(gnuplot_executable.empty()) + { + std::cout << "WARNING: Although the flag plot_obs_sys_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(signal_name + " Carrier phase error"); + g1.set_grid(); + g1.set_xlabel("PRN"); + g1.set_ylabel("Carrier phase error [whole cycles]"); + g1.plot_xy(prns, means, "Mean"); + g1.plot_xy(prns, stddevs, "Standard deviation"); + //g1.savetops("FFT_execution_times_extended"); + //g1.savetopdf("FFT_execution_times_extended", 18); + g1.showonscreen(); // window output + } + catch (const GnuplotException & ge) + { + std::cout << ge.what() << std::endl; + } + } + } } void ObsSystemTest::compute_doppler_error( std::vector& diff, - double error_th_mean, double error_th_std) + double error_th_mean, double error_th_std, + std::string signal_name) { int prn_id = 0; + std::vector means; + std::vector stddevs; + std::vector prns; std::vector::iterator iter_diff; for(iter_diff = diff.begin(); iter_diff != diff.end(); iter_diff++) { if(!iter_diff->is_empty()) { double d_mean = arma::mean(*iter_diff); + means.push_back(d_mean); double d_stddev = arma::stddev(*iter_diff); + stddevs.push_back(d_stddev); + prns.push_back(static_cast(prn_id)); std::cout << "-- Mean Doppler difference for sat " << prn_id << ": " << d_mean; std::cout << " +/- " << d_stddev; std::cout << " [Hz]" << std::endl; @@ -586,6 +679,41 @@ void ObsSystemTest::compute_doppler_error( } prn_id++; } + if(FLAGS_plot_obs_sys_test == true) + { + const std::string gnuplot_executable(FLAGS_gnuplot_executable); + if(gnuplot_executable.empty()) + { + std::cout << "WARNING: Although the flag plot_obs_sys_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(signal_name + " Doppler error"); + g1.set_grid(); + g1.set_xlabel("PRN"); + g1.set_ylabel("Doppler error [Hz]"); + g1.plot_xy(prns, means, "Mean"); + g1.plot_xy(prns, stddevs, "Standard deviation"); + //g1.savetops("FFT_execution_times_extended"); + //g1.savetopdf("FFT_execution_times_extended", 18); + g1.showonscreen(); // window output + } + catch (const GnuplotException & ge) + { + std::cout << ge.what() << std::endl; + } + } + } } void ObsSystemTest::check_results() { @@ -612,19 +740,21 @@ void ObsSystemTest::check_results() time_alignment_diff(doppler_ref, doppler_meas, dp_diff); // Results + std::cout << std::endl; + std::cout << std::endl; std::cout << "GPS L1 C/A obs. results" << std::endl; // Compute pseudorange error - compute_pseudorange_error(pr_diff, pseudorange_error_th_mean, pseudorange_error_th_std); + compute_pseudorange_error(pr_diff, pseudorange_error_th_mean, pseudorange_error_th_std, "GPS L1 C/A"); // Compute carrier phase error - compute_carrierphase_error(cp_diff, carrierphase_error_th_mean, carrierphase_error_th_std); + compute_carrierphase_error(cp_diff, carrierphase_error_th_mean, carrierphase_error_th_std, "GPS L1 C/A"); // Compute Doppler error - compute_doppler_error(dp_diff, doppler_error_th_mean, doppler_error_th_std); + compute_doppler_error(dp_diff, doppler_error_th_mean, doppler_error_th_std, "GPS L1 C/A"); } if(gps_L5) { @@ -648,19 +778,21 @@ void ObsSystemTest::check_results() time_alignment_diff(doppler_ref, doppler_meas, dp_diff); // Results + std::cout << std::endl; + std::cout << std::endl; std::cout << "GPS L5 obs. results" << std::endl; // Compute pseudorange error - compute_pseudorange_error(pr_diff, pseudorange_error_th_mean, pseudorange_error_th_std); + compute_pseudorange_error(pr_diff, pseudorange_error_th_mean, pseudorange_error_th_std, "GPS L5"); // Compute carrier phase error - compute_carrierphase_error(cp_diff, carrierphase_error_th_mean, carrierphase_error_th_std); + compute_carrierphase_error(cp_diff, carrierphase_error_th_mean, carrierphase_error_th_std, "GPS L5"); // Compute Doppler error - compute_doppler_error(dp_diff, doppler_error_th_mean, doppler_error_th_std); + compute_doppler_error(dp_diff, doppler_error_th_mean, doppler_error_th_std, "GPS L5"); } if(gal_1B) { @@ -684,19 +816,21 @@ void ObsSystemTest::check_results() time_alignment_diff(doppler_ref, doppler_meas, dp_diff); // Results + std::cout << std::endl; + std::cout << std::endl; std::cout << "Galileo E1B obs. results" << std::endl; // Compute pseudorange error - compute_pseudorange_error(pr_diff, pseudorange_error_th_mean, pseudorange_error_th_std); + compute_pseudorange_error(pr_diff, pseudorange_error_th_mean, pseudorange_error_th_std, "Galileo E1B"); // Compute carrier phase error - compute_carrierphase_error(cp_diff, carrierphase_error_th_mean, carrierphase_error_th_std); + compute_carrierphase_error(cp_diff, carrierphase_error_th_mean, carrierphase_error_th_std, "Galileo E1B"); // Compute Doppler error - compute_doppler_error(dp_diff, doppler_error_th_mean, doppler_error_th_std); + compute_doppler_error(dp_diff, doppler_error_th_mean, doppler_error_th_std, "Galileo E1B"); } if(gal_E5a) { @@ -720,19 +854,21 @@ void ObsSystemTest::check_results() time_alignment_diff(doppler_ref, doppler_meas, dp_diff); // Results + std::cout << std::endl; + std::cout << std::endl; std::cout << "Galileo E5a obs. results" << std::endl; // Compute pseudorange error - compute_pseudorange_error(pr_diff, pseudorange_error_th_mean, pseudorange_error_th_std); + compute_pseudorange_error(pr_diff, pseudorange_error_th_mean, pseudorange_error_th_std, "Galileo E5a"); // Compute carrier phase error - compute_carrierphase_error(cp_diff, carrierphase_error_th_mean, carrierphase_error_th_std); + compute_carrierphase_error(cp_diff, carrierphase_error_th_mean, carrierphase_error_th_std, "Galileo E5a"); // Compute Doppler error - compute_doppler_error(dp_diff, doppler_error_th_mean, doppler_error_th_std); + compute_doppler_error(dp_diff, doppler_error_th_mean, doppler_error_th_std, "Galileo E5a"); } } @@ -754,11 +890,11 @@ TEST_F(ObsSystemTest, Observables_system_test) bool is_gen_rinex_obs_valid = false; if(internal_rinex_generation) { - is_gen_rinex_obs_valid = check_valid_rinex_obs( "./" + generated_rinex_obs, 2); + is_gen_rinex_obs_valid = check_valid_rinex_obs( "./" + generated_rinex_obs, config->property("PVT.rinex_version", 3)); } else { - is_gen_rinex_obs_valid = check_valid_rinex_obs(generated_rinex_obs, 2); + is_gen_rinex_obs_valid = check_valid_rinex_obs(generated_rinex_obs, config->property("PVT.rinex_version", 3)); } ASSERT_EQ(true, is_gen_rinex_obs_valid) << "The RINEX observation file " << generated_rinex_obs << ", generated by GNSS-SDR, is not well formed."; std::cout << "The file is valid." << std::endl; From 218844cce5f083f818f9eaac361405b9ac8971a2 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 10 Nov 2017 14:38:16 +0100 Subject: [PATCH 32/60] Minor changes in RINEX printer version setting --- src/algorithms/PVT/libs/rinex_printer.cc | 16 ++++++++-------- src/tests/system-tests/obs_system_test.cc | 22 +++++++++++----------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index 7de3391c9..6c993fecc 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -409,8 +409,8 @@ std::string Rinex_Printer::getLocalTime() void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& iono, const Galileo_Utc_Model& utc_model, const Galileo_Almanac& galileo_almanac) { std::string line; - stringVersion = "3.02"; - version = 3; + //stringVersion = "3.02"; + //version = 3; // -------- Line 1 line = std::string(5, ' '); @@ -815,8 +815,8 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& iono, co void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono, const Gps_Utc_Model& gps_utc_model, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model, const Galileo_Almanac& galileo_almanac) { std::string line; - stringVersion = "3.02"; - version = 3; + //stringVersion = "3.02"; + //version = 3; // -------- Line 1 line = std::string(5, ' '); @@ -2909,11 +2909,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream & out, const Gps_Ephemeris & e void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& eph, const double d_TOW_first_observation, const std::string bands) { std::string line; - version = 3; + //version = 3; // -------- Line 1 line = std::string(5, ' '); - line += "3.02"; + line += stringVersion; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); line += satelliteSystem["Galileo"]; @@ -3171,11 +3171,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps { if(galileo_eph.e_1){} // avoid warning, not needed std::string line; - version = 3; + //version = 3; // -------- Line 1 line = std::string(5, ' '); - line += "3.02"; + line += stringVersion; line += std::string(11, ' '); line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); line += satelliteSystem["Mixed"]; diff --git a/src/tests/system-tests/obs_system_test.cc b/src/tests/system-tests/obs_system_test.cc index 47a46e7dd..1a9d990fb 100644 --- a/src/tests/system-tests/obs_system_test.cc +++ b/src/tests/system-tests/obs_system_test.cc @@ -67,8 +67,8 @@ DEFINE_double(pr_error_mean_max, 25.0, "Maximum mean error in pseudorange"); DEFINE_double(pr_error_std_max, 5.0, "Maximum standard deviation in pseudorange"); DEFINE_double(cp_error_mean_max, 5.0, "Maximum mean error in carrier phase"); DEFINE_double(cp_error_std_max, 2.5, "Maximum standard deviation in carrier phase"); -DEFINE_double(dp_error_mean_max, 50.0, "Maximum mean error in Doppler frequency"); -DEFINE_double(dp_error_std_max, 15.0, "Maximum standard deviation in Doppler frequency"); +DEFINE_double(dp_error_mean_max, 75.0, "Maximum mean error in Doppler frequency"); +DEFINE_double(dp_error_std_max, 25.0, "Maximum standard deviation in Doppler frequency"); DEFINE_bool(plot_obs_sys_test, false, "Plots results of ObsSystemTest with gnuplot"); class ObsSystemTest: public ::testing::Test @@ -538,12 +538,12 @@ void ObsSystemTest::compute_pseudorange_error( { if(!iter_diff->is_empty()) { - double d_mean = arma::mean(*iter_diff); + double d_mean = std::sqrt(arma::mean(arma::square(*iter_diff))); means.push_back(d_mean); double d_stddev = arma::stddev(*iter_diff); stddevs.push_back(d_stddev); prns.push_back(static_cast(prn_id)); - std::cout << "-- Mean pseudorange difference for sat " << prn_id << ": " << d_mean; + std::cout << "-- RMS pseudorange difference for sat " << prn_id << ": " << d_mean; std::cout << " +/- " << d_stddev; std::cout << " [m]" << std::endl; EXPECT_LT(d_mean, error_th_mean); @@ -574,7 +574,7 @@ void ObsSystemTest::compute_pseudorange_error( g1.set_grid(); g1.set_xlabel("PRN"); g1.set_ylabel("Pseudorange error [m]"); - g1.plot_xy(prns, means, "Mean"); + g1.plot_xy(prns, means, "RMS error"); g1.plot_xy(prns, stddevs, "Standard deviation"); //g1.savetops("FFT_execution_times_extended"); //g1.savetopdf("FFT_execution_times_extended", 18); @@ -602,12 +602,12 @@ void ObsSystemTest::compute_carrierphase_error( { if(!iter_diff->is_empty()) { - double d_mean = arma::mean(*iter_diff); + double d_mean = std::sqrt(arma::mean(arma::square(*iter_diff))); means.push_back(d_mean); double d_stddev = arma::stddev(*iter_diff); stddevs.push_back(d_stddev); prns.push_back(static_cast(prn_id)); - std::cout << "-- Mean carrier phase difference for sat " << prn_id << ": " << d_mean; + std::cout << "-- RMS carrier phase difference for sat " << prn_id << ": " << d_mean; std::cout << " +/- " << d_stddev; std::cout << " whole cycles" << std::endl; EXPECT_LT(d_mean, error_th_mean); @@ -638,7 +638,7 @@ void ObsSystemTest::compute_carrierphase_error( g1.set_grid(); g1.set_xlabel("PRN"); g1.set_ylabel("Carrier phase error [whole cycles]"); - g1.plot_xy(prns, means, "Mean"); + g1.plot_xy(prns, means, "RMS error"); g1.plot_xy(prns, stddevs, "Standard deviation"); //g1.savetops("FFT_execution_times_extended"); //g1.savetopdf("FFT_execution_times_extended", 18); @@ -666,12 +666,12 @@ void ObsSystemTest::compute_doppler_error( { if(!iter_diff->is_empty()) { - double d_mean = arma::mean(*iter_diff); + double d_mean = std::sqrt(arma::mean(arma::square(*iter_diff))); means.push_back(d_mean); double d_stddev = arma::stddev(*iter_diff); stddevs.push_back(d_stddev); prns.push_back(static_cast(prn_id)); - std::cout << "-- Mean Doppler difference for sat " << prn_id << ": " << d_mean; + std::cout << "-- RMS Doppler difference for sat " << prn_id << ": " << d_mean; std::cout << " +/- " << d_stddev; std::cout << " [Hz]" << std::endl; EXPECT_LT(d_mean, error_th_mean); @@ -702,7 +702,7 @@ void ObsSystemTest::compute_doppler_error( g1.set_grid(); g1.set_xlabel("PRN"); g1.set_ylabel("Doppler error [Hz]"); - g1.plot_xy(prns, means, "Mean"); + g1.plot_xy(prns, means, "RMS error"); g1.plot_xy(prns, stddevs, "Standard deviation"); //g1.savetops("FFT_execution_times_extended"); //g1.savetopdf("FFT_execution_times_extended", 18); From 05247ea4be9c46abbedf49d1430b15630ac77de3 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 11 Nov 2017 10:27:02 +0100 Subject: [PATCH 33/60] Remove repeated line --- src/tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index a7ce8ed34..2bafedc98 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -530,10 +530,10 @@ if(ENABLE_SYSTEM_TESTING) file(REMOVE ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) endif(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) install(TARGETS obs_gps_l1_system_test RUNTIME DESTINATION bin COMPONENT "obs_gps_l1_system_test") + if(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test) file(REMOVE ${CMAKE_SOURCE_DIR}/install/obs_system_test) endif(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test) - install(TARGETS obs_gps_l1_system_test RUNTIME DESTINATION bin COMPONENT "obs_gps_l1_system_test") install(TARGETS obs_system_test RUNTIME DESTINATION bin COMPONENT "obs_system_test") else(ENABLE_INSTALL_TESTS) add_custom_command(TARGET obs_gps_l1_system_test POST_BUILD From 1630ec2af707f6b00cc38ac6aa1a4cc51c5c28c7 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 11 Nov 2017 14:04:57 +0100 Subject: [PATCH 34/60] Help find GPSTk if installed --- cmake/Modules/FindGPSTK.cmake | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/FindGPSTK.cmake b/cmake/Modules/FindGPSTK.cmake index fffe17877..37ea1dbf0 100644 --- a/cmake/Modules/FindGPSTK.cmake +++ b/cmake/Modules/FindGPSTK.cmake @@ -7,10 +7,16 @@ # also defined, but not for general use are # GPSTK_LIBRARY, where to find the GPSTK library. -FIND_PATH(GPSTK_INCLUDE_DIR Rinex3ObsBase.hpp) +FIND_PATH(GPSTK_INCLUDE_DIR Rinex3ObsBase.hpp + HINTS /usr/include/gpstk + /usr/local/include/gpstk + /opt/local/include/gpstk ) SET(GPSTK_NAMES ${GPSTK_NAMES} gpstk libgpstk) -FIND_LIBRARY(GPSTK_LIBRARY NAMES ${GPSTK_NAMES} ) +FIND_LIBRARY(GPSTK_LIBRARY NAMES ${GPSTK_NAMES} + HINTS /usr/lib + /usr/local/lib + /opt/local/lib ) # handle the QUIETLY and REQUIRED arguments and set GPSTK_FOUND to TRUE if # all listed variables are TRUE From e95f1b62f5c0f1f2186af044832a2f572d882696 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 13 Nov 2017 22:13:58 +0100 Subject: [PATCH 35/60] Improve usage of gtest macros --- .../filter/fir_filter_test.cc | 20 +++++++++---------- .../filter/notch_filter_lite_test.cc | 8 ++++---- .../filter/notch_filter_test.cc | 8 ++++---- .../filter/pulse_blanking_filter_test.cc | 8 ++++---- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc b/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc index baa3feea0..3d5b4a1af 100644 --- a/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc @@ -192,14 +192,14 @@ TEST_F(FirFilterTest, ConnectAndRun) top_block->connect(source, 0, valve, 0); top_block->connect(valve, 0, filter->get_left_block(), 0); top_block->connect(filter->get_right_block(), 0, null_sink, 0); - }) << "Failure connecting the top_block."<< std::endl; + }) << "Failure connecting the top_block."; EXPECT_NO_THROW( { start = std::chrono::system_clock::now(); top_block->run(); // Start threads and wait end = std::chrono::system_clock::now(); elapsed_seconds = end - start; - }) << "Failure running the top_block." << std::endl; + }) << "Failure running the top_block."; std::cout << "Filtered " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl; } @@ -234,14 +234,14 @@ TEST_F(FirFilterTest, ConnectAndRunGrcomplex) top_block->connect(source->get_right_block(), 0, filter->get_left_block(), 0); top_block->connect(filter->get_right_block(), 0, null_sink, 0); - }) << "Failure connecting the top_block."<< std::endl; + }) << "Failure connecting the top_block."; EXPECT_NO_THROW( { start = std::chrono::system_clock::now(); top_block->run(); // Start threads and wait end = std::chrono::system_clock::now(); elapsed_seconds = end - start; - }) << "Failure running the top_block." << std::endl; + }) << "Failure running the top_block."; std::cout << "Filtered " << nsamples << " gr_complex samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl; } @@ -277,14 +277,14 @@ TEST_F(FirFilterTest, ConnectAndRunCshorts) top_block->connect(source->get_right_block(), 0, ishort_to_cshort_, 0); top_block->connect(ishort_to_cshort_, 0, filter->get_left_block(), 0); top_block->connect(filter->get_right_block(), 0, null_sink, 0); - }) << "Failure connecting the top_block."<< std::endl; + }) << "Failure connecting the top_block."; EXPECT_NO_THROW( { start = std::chrono::system_clock::now(); top_block->run(); // Start threads and wait end = std::chrono::system_clock::now(); elapsed_seconds = end - start; - }) << "Failure running the top_block." << std::endl; + }) << "Failure running the top_block."; std::cout << "Filtered " << nsamples << " std::complex samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl; } @@ -322,14 +322,14 @@ TEST_F(FirFilterTest, ConnectAndRunCbytes) top_block->connect(source->get_right_block(), 0, ibyte_to_cbyte_, 0); top_block->connect(ibyte_to_cbyte_, 0, filter->get_left_block(), 0); top_block->connect(filter->get_right_block(), 0, null_sink, 0); - }) << "Failure connecting the top_block."<< std::endl; + }) << "Failure connecting the top_block."; EXPECT_NO_THROW( { start = std::chrono::system_clock::now(); top_block->run(); // Start threads and wait end = std::chrono::system_clock::now(); elapsed_seconds = end - start; - }) << "Failure running the top_block." << std::endl; + }) << "Failure running the top_block."; std::cout << "Filtered " << nsamples << " std::complex samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl; } @@ -366,13 +366,13 @@ TEST_F(FirFilterTest, ConnectAndRunCbyteGrcomplex) top_block->connect(source->get_right_block(), 0, ibyte_to_cbyte_, 0); top_block->connect(ibyte_to_cbyte_, 0, filter->get_left_block(), 0); top_block->connect(filter->get_right_block(), 0, null_sink, 0); - }) << "Failure connecting the top_block."<< std::endl; + }) << "Failure connecting the top_block."; EXPECT_NO_THROW( { start = std::chrono::system_clock::now(); top_block->run(); // Start threads and wait end = std::chrono::system_clock::now(); elapsed_seconds = end - start; - }) << "Failure running the top_block." << std::endl; + }) << "Failure running the top_block."; std::cout << "Filtered " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl; } diff --git a/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc b/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc index 363ff89ce..13896442c 100644 --- a/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc @@ -116,14 +116,14 @@ TEST_F(NotchFilterLiteTest, ConnectAndRun) top_block->connect(source, 0, valve, 0); top_block->connect(valve, 0, filter->get_left_block(), 0); top_block->connect(filter->get_right_block(), 0, null_sink, 0); - }) << "Failure connecting the top_block."<< std::endl; + }) << "Failure connecting the top_block."; EXPECT_NO_THROW( { start = std::chrono::system_clock::now(); top_block->run(); // Start threads and wait end = std::chrono::system_clock::now(); elapsed_seconds = end - start; - }) << "Failure running the top_block." << std::endl; + }) << "Failure running the top_block."; std::cout << "Filtered " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl; } @@ -157,13 +157,13 @@ TEST_F(NotchFilterLiteTest, ConnectAndRunGrcomplex) top_block->connect(source->get_right_block(), 0, filter->get_left_block(), 0); top_block->connect(filter->get_right_block(), 0, null_sink, 0); - }) << "Failure connecting the top_block."<< std::endl; + }) << "Failure connecting the top_block."; EXPECT_NO_THROW( { start = std::chrono::system_clock::now(); top_block->run(); // Start threads and wait end = std::chrono::system_clock::now(); elapsed_seconds = end - start; - }) << "Failure running the top_block." << std::endl; + }) << "Failure running the top_block."; std::cout << "Filtered " << nsamples << " gr_complex samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl; } diff --git a/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_test.cc b/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_test.cc index f3997ecc2..a6a13dc42 100644 --- a/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_test.cc @@ -116,14 +116,14 @@ TEST_F(NotchFilterTest, ConnectAndRun) top_block->connect(source, 0, valve, 0); top_block->connect(valve, 0, filter->get_left_block(), 0); top_block->connect(filter->get_right_block(), 0, null_sink, 0); - }) << "Failure connecting the top_block."<< std::endl; + }) << "Failure connecting the top_block."; EXPECT_NO_THROW( { start = std::chrono::system_clock::now(); top_block->run(); // Start threads and wait end = std::chrono::system_clock::now(); elapsed_seconds = end - start; - }) << "Failure running the top_block." << std::endl; + }) << "Failure running the top_block."; std::cout << "Filtered " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl; } @@ -157,13 +157,13 @@ TEST_F(NotchFilterTest, ConnectAndRunGrcomplex) top_block->connect(source->get_right_block(), 0, filter->get_left_block(), 0); top_block->connect(filter->get_right_block(), 0, null_sink, 0); - }) << "Failure connecting the top_block."<< std::endl; + }) << "Failure connecting the top_block."; EXPECT_NO_THROW( { start = std::chrono::system_clock::now(); top_block->run(); // Start threads and wait end = std::chrono::system_clock::now(); elapsed_seconds = end - start; - }) << "Failure running the top_block." << std::endl; + }) << "Failure running the top_block."; std::cout << "Filtered " << nsamples << " gr_complex samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl; } diff --git a/src/tests/unit-tests/signal-processing-blocks/filter/pulse_blanking_filter_test.cc b/src/tests/unit-tests/signal-processing-blocks/filter/pulse_blanking_filter_test.cc index f157bf3a6..1b09b7367 100644 --- a/src/tests/unit-tests/signal-processing-blocks/filter/pulse_blanking_filter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/filter/pulse_blanking_filter_test.cc @@ -115,14 +115,14 @@ TEST_F(PulseBlankingFilterTest, ConnectAndRun) top_block->connect(source, 0, valve, 0); top_block->connect(valve, 0, filter->get_left_block(), 0); top_block->connect(filter->get_right_block(), 0, null_sink, 0); - }) << "Failure connecting the top_block."<< std::endl; + }) << "Failure connecting the top_block."; EXPECT_NO_THROW( { start = std::chrono::system_clock::now(); top_block->run(); // Start threads and wait end = std::chrono::system_clock::now(); elapsed_seconds = end - start; - }) << "Failure running the top_block." << std::endl; + }) << "Failure running the top_block."; std::cout << "Filtered " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl; } @@ -156,13 +156,13 @@ TEST_F(PulseBlankingFilterTest, ConnectAndRunGrcomplex) top_block->connect(source->get_right_block(), 0, filter->get_left_block(), 0); top_block->connect(filter->get_right_block(), 0, null_sink, 0); - }) << "Failure connecting the top_block."<< std::endl; + }) << "Failure connecting the top_block."; EXPECT_NO_THROW( { start = std::chrono::system_clock::now(); top_block->run(); // Start threads and wait end = std::chrono::system_clock::now(); elapsed_seconds = end - start; - }) << "Failure running the top_block." << std::endl; + }) << "Failure running the top_block."; std::cout << "Filtered " << nsamples << " gr_complex samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl; } From fe4702068547bb312c6b57ee116545d4d84b1c6e Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 13 Nov 2017 22:21:47 +0100 Subject: [PATCH 36/60] Add GPL v3 badge --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e06525aef..b37d53c6b 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ -![](./docs/doxygen/images/gnss-sdr_logo.png) +[![](./docs/doxygen/images/gnss-sdr_logo.png)](http://gnss-sdr.org "GNSS-SDR website") + +[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) **Welcome to GNSS-SDR!** -Visit [gnss-sdr.org](http://gnss-sdr.org "GNSS-SDR's Homepage") for more information about this open source GNSS software defined receiver. +Visit [http://gnss-sdr.org](http://gnss-sdr.org "GNSS-SDR website") for more information about this open source GNSS software defined receiver. If you have questions about GNSS-SDR, please [subscribe to the gnss-sdr-developers mailing list](http://lists.sourceforge.net/lists/listinfo/gnss-sdr-developers "Subscribe to the gnss-sdr-developers mailing list" ) and post your questions there. From 23df265d5dee3efeea908f87d890b8346b2e975f Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 13 Nov 2017 23:38:04 +0100 Subject: [PATCH 37/60] Update Homebrew instructions --- README.md | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b37d53c6b..538742a14 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,6 @@ Visit [http://gnss-sdr.org](http://gnss-sdr.org "GNSS-SDR website") for more information about this open source GNSS software defined receiver. -If you have questions about GNSS-SDR, please [subscribe to the gnss-sdr-developers mailing list](http://lists.sourceforge.net/lists/listinfo/gnss-sdr-developers "Subscribe to the gnss-sdr-developers mailing list" ) and post your questions there. - # How to build GNSS-SDR @@ -511,15 +509,30 @@ $ sudo port select --set python python27 #### Homebrew -Instructions for installing GNU Radio using [homebrew](http://www.brew.sh) can be found [here](http://github.com/odrisci/homebrew-gnuradio) - please ensure to install all dependencies as required. +First, install [Homebrew](https://brew.sh/). Paste this in a terminal prompt: -Install Armadillo and dependencies: +~~~~~~ +$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" +~~~~~~ + +The script explains what it will do and then pauses before it does it. There are more installation options [here](https://docs.brew.sh/Installation.html). + +Install pip: + +~~~~~~ +$ sudo easy_install pip +~~~~~~ + +Install the required dependencies: ~~~~~~ $ brew tap homebrew/science $ brew install cmake hdf5 arpack superlu $ brew install armadillo $ brew install glog gflags gnutls +$ brew install gnuradio +$ pip install mako +$ pip install six ~~~~~~ #### Build GNSS-SDR From 42deb7b58341830f0e4ffa6b3756b24cf8bd379e Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 13 Nov 2017 23:46:43 +0100 Subject: [PATCH 38/60] Fix wording --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 538742a14..fbe4503d8 100644 --- a/README.md +++ b/README.md @@ -375,7 +375,7 @@ $ sudo make install ###### Build FMCOMMS2 based SDR Hardware support (OPTIONAL): -Install the [libiio](https://github.com/analogdevicesinc/libiio.git) (>=v0.11), [libad9361](https://github.com/analogdevicesinc/libad9361-iio.git) (>=v0.1-1) libraries and [gr-iio](https://github.com/analogdevicesinc/gr-iio.git) (>=v0.2) gnuradio block. For example in Ubuntu 16.04 follow these instructions (based on https://github.com/blurbdust/blurbdust.github.io): +Install the [libiio](https://github.com/analogdevicesinc/libiio.git) (>=v0.11), [libad9361](https://github.com/analogdevicesinc/libad9361-iio.git) (>=v0.1-1) libraries and [gr-iio](https://github.com/analogdevicesinc/gr-iio.git) (>v0.2) gnuradio block: ~~~~~~ $ sudo apt-get install libxml2-dev bison flex @@ -402,8 +402,10 @@ $ make && sudo make install && sudo ldconfig $ cd ../.. ~~~~~~ -Then configure the gnss-sdr to build the `Fmcomms2_Signal_Source` implementation: +Then configure GNSS-SDR to build the `Fmcomms2_Signal_Source` implementation: + ~~~~~~ +$ cd gnss-sdr/build $ cmake -DENABLE_FMCOMMS2=ON ../ $ make $ sudo make install @@ -416,7 +418,7 @@ $ make $ sudo make install ~~~~~~ -With `Fmcomms2_Signal_Source` you can use any SDR hardware based on fmcomms2, including the ADALM-PLUTO (PlutoSdr) by configuring correctly the .conf file. The `Plutosdr_Signal_Source` offers a simplier manner to use the ADALM-PLUTO because implements only a subset of fmcomms2's parameters valid for those devices. +With `Fmcomms2_Signal_Source` you can use any SDR hardware based on [FMCOMMS2](https://wiki.analog.com/resources/eval/user-guides/ad-fmcomms2-ebz), including the ADALM-PLUTO (PlutoSdr) by configuring correctly the .conf file. The `Plutosdr_Signal_Source` offers a simpler manner to use the ADALM-PLUTO because implements only a subset of FMCOMMS2's parameters valid for those devices. ###### Build OpenCL support (OPTIONAL): From 9c6d79e945503a4c8d5096008ab09dd85f304623 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 15 Nov 2017 01:23:05 +0100 Subject: [PATCH 39/60] Fix building with Python 3.6 --- .../volk_gnsssdr/gen/volk_gnsssdr_arch_defs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_arch_defs.py b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_arch_defs.py index d1e656d70..cfce6d5b2 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_arch_defs.py +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/gen/volk_gnsssdr_arch_defs.py @@ -82,7 +82,7 @@ for arch_xml in archs_xml: flags = dict() for flag_xml in arch_xml.getElementsByTagName("flag"): name = flag_xml.attributes["compiler"].value - if not flags.has_key(name): flags[name] = list() + if name not in flags: flags[name] = list() flags[name].append(flag_xml.firstChild.data) #force kwargs keys to be of type str, not unicode for py25 kwargs = dict((str(k), v) for k, v in six.iteritems(kwargs)) From 80c79125b4213dea1f823536949fd8335c12cb7d Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 15 Nov 2017 01:32:40 +0100 Subject: [PATCH 40/60] Update Armadillo, glog and gflags versions --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index fbe4503d8..a72c79577 100644 --- a/README.md +++ b/README.md @@ -134,9 +134,9 @@ or manually as explained below, and then please follow instructions on how to [d $ sudo apt-get install libopenblas-dev liblapack-dev # For Debian/Ubuntu/LinuxMint $ sudo yum install lapack-devel blas-devel # For Fedora/CentOS/RHEL $ sudo zypper install lapack-devel blas-devel # For OpenSUSE -$ wget http://sourceforge.net/projects/arma/files/armadillo-7.800.2.tar.xz -$ tar xvfz armadillo-7.800.2.tar.xz -$ cd armadillo-7.800.2 +$ wget http://sourceforge.net/projects/arma/files/armadillo-8.200.2.tar.xz +$ tar xvfz armadillo-8.200.2.tar.xz +$ cd armadillo-8.200.2 $ cmake . $ make $ sudo make install @@ -149,9 +149,9 @@ The full stop separated from ```cmake``` by a space is important. [CMake](http:/ #### Install [Gflags](https://github.com/gflags/gflags "Gflags' Homepage"), a commandline flags processing module for C++: ~~~~~~ -$ wget https://github.com/gflags/gflags/archive/v2.2.0.tar.gz -$ tar xvfz v2.2.0.tar.gz -$ cd gflags-2.2.0 +$ wget https://github.com/gflags/gflags/archive/v2.2.1.tar.gz +$ tar xvfz v2.2.1.tar.gz +$ cd gflags-2.2.1 $ cmake -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF -DBUILD_gflags_nothreads_LIB=OFF . $ make $ sudo make install @@ -163,9 +163,9 @@ $ sudo ldconfig #### Install [Glog](https://github.com/google/glog "Glog's Homepage"), a library that implements application-level logging: ~~~~~~ -$ wget https://github.com/google/glog/archive/v0.3.4.tar.gz -$ tar xvfz v0.3.4.tar.gz -$ cd glog-0.3.4 +$ wget https://github.com/google/glog/archive/v0.3.5.tar.gz +$ tar xvfz v0.3.5.tar.gz +$ cd glog-0.3.5 $ ./configure $ make $ sudo make install From 27eece55da1c972b25b5aa789cf6636d1cdff405 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 15 Nov 2017 02:10:25 +0100 Subject: [PATCH 41/60] Add aligned kernel for AVX --- ...nsssdr_32fc_32f_rotator_dot_prod_32fc_xn.h | 344 +++++++++++++----- ...dr_32fc_32f_rotator_dotprodxnpuppet_32fc.h | 30 ++ 2 files changed, 285 insertions(+), 89 deletions(-) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn.h index 544a83990..0a8674893 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn.h @@ -176,9 +176,10 @@ static inline void volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_u_avx(lv_32fc_ const float* aPtr = (float*)in_common; const float* bPtr[ num_a_vectors]; - for( vec_ind = 0; vec_ind < num_a_vectors; ++vec_ind ){ - bPtr[vec_ind] = in_a[vec_ind]; - } + for( vec_ind = 0; vec_ind < num_a_vectors; ++vec_ind ) + { + bPtr[vec_ind] = in_a[vec_ind]; + } lv_32fc_t _phase = (*phase); lv_32fc_t wo; @@ -193,20 +194,22 @@ static inline void volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_u_avx(lv_32fc_ __m256 dotProdVal2[num_a_vectors]; __m256 dotProdVal3[num_a_vectors]; - for( vec_ind = 0; vec_ind < num_a_vectors; vec_ind++ ){ - dotProdVal0[vec_ind] = _mm256_setzero_ps(); - dotProdVal1[vec_ind] = _mm256_setzero_ps(); - dotProdVal2[vec_ind] = _mm256_setzero_ps(); - dotProdVal3[vec_ind] = _mm256_setzero_ps(); - } + for( vec_ind = 0; vec_ind < num_a_vectors; vec_ind++ ) + { + dotProdVal0[vec_ind] = _mm256_setzero_ps(); + dotProdVal1[vec_ind] = _mm256_setzero_ps(); + dotProdVal2[vec_ind] = _mm256_setzero_ps(); + dotProdVal3[vec_ind] = _mm256_setzero_ps(); + } // Set up the complex rotator __m256 z0, z1, z2, z3; - __attribute__((aligned(32))) lv_32fc_t phase_vec[16]; - for( vec_ind = 0; vec_ind < 16; ++vec_ind ){ - phase_vec[vec_ind] = _phase; - _phase *= phase_inc; - } + __VOLK_ATTR_ALIGNED(32) lv_32fc_t phase_vec[16]; + for( vec_ind = 0; vec_ind < 16; ++vec_ind ) + { + phase_vec[vec_ind] = _phase; + _phase *= phase_inc; + } z0 = _mm256_load_ps( (float *)phase_vec ); z1 = _mm256_load_ps( (float *)(phase_vec + 4) ); @@ -215,104 +218,267 @@ static inline void volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_u_avx(lv_32fc_ lv_32fc_t dz = phase_inc; dz *= dz; dz *= dz; dz *= dz; dz *= dz; // dz = phase_inc^16; - for( vec_ind = 0; vec_ind < 4; ++vec_ind ){ - phase_vec[vec_ind] = dz; - } + for( vec_ind = 0; vec_ind < 4; ++vec_ind ) + { + phase_vec[vec_ind] = dz; + } __m256 dz_reg = _mm256_load_ps( (float *)phase_vec ); dz_reg = _mm256_complexnormalise_ps( dz_reg ); - for(;number < sixteenthPoints; number++){ - - a0Val = _mm256_loadu_ps(aPtr); - a1Val = _mm256_loadu_ps(aPtr+8); - a2Val = _mm256_loadu_ps(aPtr+16); - a3Val = _mm256_loadu_ps(aPtr+24); - - a0Val = _mm256_complexmul_ps( a0Val, z0 ); - a1Val = _mm256_complexmul_ps( a1Val, z1 ); - a2Val = _mm256_complexmul_ps( a2Val, z2 ); - a3Val = _mm256_complexmul_ps( a3Val, z3 ); - - z0 = _mm256_complexmul_ps( z0, dz_reg ); - z1 = _mm256_complexmul_ps( z1, dz_reg ); - z2 = _mm256_complexmul_ps( z2, dz_reg ); - z3 = _mm256_complexmul_ps( z3, dz_reg ); - - - for( vec_ind = 0; vec_ind < num_a_vectors; ++vec_ind ){ - x0Val[vec_ind] = _mm256_loadu_ps(bPtr[vec_ind]); // t0|t1|t2|t3|t4|t5|t6|t7 - x1Val[vec_ind] = _mm256_loadu_ps(bPtr[vec_ind]+8); - x0loVal[vec_ind] = _mm256_unpacklo_ps(x0Val[vec_ind], x0Val[vec_ind]); // t0|t0|t1|t1|t4|t4|t5|t5 - x0hiVal[vec_ind] = _mm256_unpackhi_ps(x0Val[vec_ind], x0Val[vec_ind]); // t2|t2|t3|t3|t6|t6|t7|t7 - x1loVal[vec_ind] = _mm256_unpacklo_ps(x1Val[vec_ind], x1Val[vec_ind]); - x1hiVal[vec_ind] = _mm256_unpackhi_ps(x1Val[vec_ind], x1Val[vec_ind]); - - // TODO: it may be possible to rearrange swizzling to better pipeline data - b0Val[vec_ind] = _mm256_permute2f128_ps(x0loVal[vec_ind], x0hiVal[vec_ind], 0x20); // t0|t0|t1|t1|t2|t2|t3|t3 - b1Val[vec_ind] = _mm256_permute2f128_ps(x0loVal[vec_ind], x0hiVal[vec_ind], 0x31); // t4|t4|t5|t5|t6|t6|t7|t7 - b2Val[vec_ind] = _mm256_permute2f128_ps(x1loVal[vec_ind], x1hiVal[vec_ind], 0x20); - b3Val[vec_ind] = _mm256_permute2f128_ps(x1loVal[vec_ind], x1hiVal[vec_ind], 0x31); - - c0Val[vec_ind] = _mm256_mul_ps(a0Val, b0Val[vec_ind]); - c1Val[vec_ind] = _mm256_mul_ps(a1Val, b1Val[vec_ind]); - c2Val[vec_ind] = _mm256_mul_ps(a2Val, b2Val[vec_ind]); - c3Val[vec_ind] = _mm256_mul_ps(a3Val, b3Val[vec_ind]); - - dotProdVal0[vec_ind] = _mm256_add_ps(c0Val[vec_ind], dotProdVal0[vec_ind]); - dotProdVal1[vec_ind] = _mm256_add_ps(c1Val[vec_ind], dotProdVal1[vec_ind]); - dotProdVal2[vec_ind] = _mm256_add_ps(c2Val[vec_ind], dotProdVal2[vec_ind]); - dotProdVal3[vec_ind] = _mm256_add_ps(c3Val[vec_ind], dotProdVal3[vec_ind]); - - bPtr[vec_ind] += 16; - } - - // Force the rotators back onto the unit circle - if ((number % 64) == 0) + for(;number < sixteenthPoints; number++) { - z0 = _mm256_complexnormalise_ps( z0 ); - z1 = _mm256_complexnormalise_ps( z1 ); - z2 = _mm256_complexnormalise_ps( z2 ); - z3 = _mm256_complexnormalise_ps( z3 ); - } + a0Val = _mm256_loadu_ps(aPtr); + a1Val = _mm256_loadu_ps(aPtr+8); + a2Val = _mm256_loadu_ps(aPtr+16); + a3Val = _mm256_loadu_ps(aPtr+24); - aPtr += 32; - } + a0Val = _mm256_complexmul_ps( a0Val, z0 ); + a1Val = _mm256_complexmul_ps( a1Val, z1 ); + a2Val = _mm256_complexmul_ps( a2Val, z2 ); + a3Val = _mm256_complexmul_ps( a3Val, z3 ); + + z0 = _mm256_complexmul_ps( z0, dz_reg ); + z1 = _mm256_complexmul_ps( z1, dz_reg ); + z2 = _mm256_complexmul_ps( z2, dz_reg ); + z3 = _mm256_complexmul_ps( z3, dz_reg ); + + for( vec_ind = 0; vec_ind < num_a_vectors; ++vec_ind ) + { + x0Val[vec_ind] = _mm256_loadu_ps(bPtr[vec_ind]); // t0|t1|t2|t3|t4|t5|t6|t7 + x1Val[vec_ind] = _mm256_loadu_ps(bPtr[vec_ind]+8); + x0loVal[vec_ind] = _mm256_unpacklo_ps(x0Val[vec_ind], x0Val[vec_ind]); // t0|t0|t1|t1|t4|t4|t5|t5 + x0hiVal[vec_ind] = _mm256_unpackhi_ps(x0Val[vec_ind], x0Val[vec_ind]); // t2|t2|t3|t3|t6|t6|t7|t7 + x1loVal[vec_ind] = _mm256_unpacklo_ps(x1Val[vec_ind], x1Val[vec_ind]); + x1hiVal[vec_ind] = _mm256_unpackhi_ps(x1Val[vec_ind], x1Val[vec_ind]); + + // TODO: it may be possible to rearrange swizzling to better pipeline data + b0Val[vec_ind] = _mm256_permute2f128_ps(x0loVal[vec_ind], x0hiVal[vec_ind], 0x20); // t0|t0|t1|t1|t2|t2|t3|t3 + b1Val[vec_ind] = _mm256_permute2f128_ps(x0loVal[vec_ind], x0hiVal[vec_ind], 0x31); // t4|t4|t5|t5|t6|t6|t7|t7 + b2Val[vec_ind] = _mm256_permute2f128_ps(x1loVal[vec_ind], x1hiVal[vec_ind], 0x20); + b3Val[vec_ind] = _mm256_permute2f128_ps(x1loVal[vec_ind], x1hiVal[vec_ind], 0x31); + + c0Val[vec_ind] = _mm256_mul_ps(a0Val, b0Val[vec_ind]); + c1Val[vec_ind] = _mm256_mul_ps(a1Val, b1Val[vec_ind]); + c2Val[vec_ind] = _mm256_mul_ps(a2Val, b2Val[vec_ind]); + c3Val[vec_ind] = _mm256_mul_ps(a3Val, b3Val[vec_ind]); + + dotProdVal0[vec_ind] = _mm256_add_ps(c0Val[vec_ind], dotProdVal0[vec_ind]); + dotProdVal1[vec_ind] = _mm256_add_ps(c1Val[vec_ind], dotProdVal1[vec_ind]); + dotProdVal2[vec_ind] = _mm256_add_ps(c2Val[vec_ind], dotProdVal2[vec_ind]); + dotProdVal3[vec_ind] = _mm256_add_ps(c3Val[vec_ind], dotProdVal3[vec_ind]); + + bPtr[vec_ind] += 16; + } + + // Force the rotators back onto the unit circle + if ((number % 64) == 0) + { + z0 = _mm256_complexnormalise_ps( z0 ); + z1 = _mm256_complexnormalise_ps( z1 ); + z2 = _mm256_complexnormalise_ps( z2 ); + z3 = _mm256_complexnormalise_ps( z3 ); + } + + aPtr += 32; + } __VOLK_ATTR_ALIGNED(32) lv_32fc_t dotProductVector[4]; - for( vec_ind = 0; vec_ind < num_a_vectors; ++vec_ind ){ - dotProdVal0[vec_ind] = _mm256_add_ps(dotProdVal0[vec_ind], dotProdVal1[vec_ind]); - dotProdVal0[vec_ind] = _mm256_add_ps(dotProdVal0[vec_ind], dotProdVal2[vec_ind]); - dotProdVal0[vec_ind] = _mm256_add_ps(dotProdVal0[vec_ind], dotProdVal3[vec_ind]); + for( vec_ind = 0; vec_ind < num_a_vectors; ++vec_ind ) + { + dotProdVal0[vec_ind] = _mm256_add_ps(dotProdVal0[vec_ind], dotProdVal1[vec_ind]); + dotProdVal0[vec_ind] = _mm256_add_ps(dotProdVal0[vec_ind], dotProdVal2[vec_ind]); + dotProdVal0[vec_ind] = _mm256_add_ps(dotProdVal0[vec_ind], dotProdVal3[vec_ind]); - _mm256_store_ps((float *)dotProductVector,dotProdVal0[vec_ind]); // Store the results back into the dot product vector + _mm256_store_ps((float *)dotProductVector, dotProdVal0[vec_ind]); // Store the results back into the dot product vector - result[ vec_ind ] = lv_cmake( 0, 0 ); - for( i = 0; i < 4; ++i ){ - result[vec_ind] += dotProductVector[i]; + result[ vec_ind ] = lv_cmake( 0, 0 ); + for( i = 0; i < 4; ++i ) + { + result[vec_ind] += dotProductVector[i]; + } } - } z0 = _mm256_complexnormalise_ps( z0 ); _mm256_store_ps((float*)phase_vec, z0); - _phase = phase_vec[0]; + _phase = phase_vec[0]; _mm256_zeroupper(); - number = sixteenthPoints*16; - for(;number < num_points; number++){ - wo = (*aPtr++)*_phase; - _phase *= phase_inc; + for(;number < num_points; number++) + { + wo = (*aPtr++)*_phase; + _phase *= phase_inc; - for( vec_ind = 0; vec_ind < num_a_vectors; ++vec_ind ){ - result[vec_ind] += wo * in_a[vec_ind][number]; + for( vec_ind = 0; vec_ind < num_a_vectors; ++vec_ind ) + { + result[vec_ind] += wo * in_a[vec_ind][number]; + } } - } *phase = _phase; - } +#endif /* LV_HAVE_AVX */ + + +#ifdef LV_HAVE_AVX +#include +#include +static inline void volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_a_avx(lv_32fc_t* result, const lv_32fc_t* in_common, const lv_32fc_t phase_inc, lv_32fc_t* phase, const float** in_a, int num_a_vectors, unsigned int num_points) +{ + unsigned int number = 0; + unsigned int vec_ind = 0; + unsigned int i = 0; + const unsigned int sixteenthPoints = num_points / 16; + + const float* aPtr = (float*)in_common; + const float* bPtr[ num_a_vectors]; + for( vec_ind = 0; vec_ind < num_a_vectors; ++vec_ind ) + { + bPtr[vec_ind] = in_a[vec_ind]; + } + + lv_32fc_t _phase = (*phase); + lv_32fc_t wo; + + __m256 a0Val, a1Val, a2Val, a3Val; + __m256 b0Val[num_a_vectors], b1Val[num_a_vectors], b2Val[num_a_vectors], b3Val[num_a_vectors]; + __m256 x0Val[num_a_vectors], x1Val[num_a_vectors], x0loVal[num_a_vectors], x0hiVal[num_a_vectors], x1loVal[num_a_vectors], x1hiVal[num_a_vectors]; + __m256 c0Val[num_a_vectors], c1Val[num_a_vectors], c2Val[num_a_vectors], c3Val[num_a_vectors]; + + __m256 dotProdVal0[num_a_vectors]; + __m256 dotProdVal1[num_a_vectors]; + __m256 dotProdVal2[num_a_vectors]; + __m256 dotProdVal3[num_a_vectors]; + + for( vec_ind = 0; vec_ind < num_a_vectors; vec_ind++ ) + { + dotProdVal0[vec_ind] = _mm256_setzero_ps(); + dotProdVal1[vec_ind] = _mm256_setzero_ps(); + dotProdVal2[vec_ind] = _mm256_setzero_ps(); + dotProdVal3[vec_ind] = _mm256_setzero_ps(); + } + + // Set up the complex rotator + __m256 z0, z1, z2, z3; + __VOLK_ATTR_ALIGNED(32) lv_32fc_t phase_vec[16]; + for( vec_ind = 0; vec_ind < 16; ++vec_ind ) + { + phase_vec[vec_ind] = _phase; + _phase *= phase_inc; + } + + z0 = _mm256_load_ps( (float *)phase_vec ); + z1 = _mm256_load_ps( (float *)(phase_vec + 4) ); + z2 = _mm256_load_ps( (float *)(phase_vec + 8) ); + z3 = _mm256_load_ps( (float *)(phase_vec + 12) ); + + lv_32fc_t dz = phase_inc; dz *= dz; dz *= dz; dz *= dz; dz *= dz; // dz = phase_inc^16; + + for( vec_ind = 0; vec_ind < 4; ++vec_ind ) + { + phase_vec[vec_ind] = dz; + } + + __m256 dz_reg = _mm256_load_ps( (float *)phase_vec ); + dz_reg = _mm256_complexnormalise_ps( dz_reg ); + + for(;number < sixteenthPoints; number++) + { + + a0Val = _mm256_load_ps(aPtr); + a1Val = _mm256_load_ps(aPtr+8); + a2Val = _mm256_load_ps(aPtr+16); + a3Val = _mm256_load_ps(aPtr+24); + + a0Val = _mm256_complexmul_ps( a0Val, z0 ); + a1Val = _mm256_complexmul_ps( a1Val, z1 ); + a2Val = _mm256_complexmul_ps( a2Val, z2 ); + a3Val = _mm256_complexmul_ps( a3Val, z3 ); + + z0 = _mm256_complexmul_ps( z0, dz_reg ); + z1 = _mm256_complexmul_ps( z1, dz_reg ); + z2 = _mm256_complexmul_ps( z2, dz_reg ); + z3 = _mm256_complexmul_ps( z3, dz_reg ); + + for( vec_ind = 0; vec_ind < num_a_vectors; ++vec_ind ) + { + x0Val[vec_ind] = _mm256_loadu_ps(bPtr[vec_ind]); // t0|t1|t2|t3|t4|t5|t6|t7 + x1Val[vec_ind] = _mm256_loadu_ps(bPtr[vec_ind]+8); + x0loVal[vec_ind] = _mm256_unpacklo_ps(x0Val[vec_ind], x0Val[vec_ind]); // t0|t0|t1|t1|t4|t4|t5|t5 + x0hiVal[vec_ind] = _mm256_unpackhi_ps(x0Val[vec_ind], x0Val[vec_ind]); // t2|t2|t3|t3|t6|t6|t7|t7 + x1loVal[vec_ind] = _mm256_unpacklo_ps(x1Val[vec_ind], x1Val[vec_ind]); + x1hiVal[vec_ind] = _mm256_unpackhi_ps(x1Val[vec_ind], x1Val[vec_ind]); + + // TODO: it may be possible to rearrange swizzling to better pipeline data + b0Val[vec_ind] = _mm256_permute2f128_ps(x0loVal[vec_ind], x0hiVal[vec_ind], 0x20); // t0|t0|t1|t1|t2|t2|t3|t3 + b1Val[vec_ind] = _mm256_permute2f128_ps(x0loVal[vec_ind], x0hiVal[vec_ind], 0x31); // t4|t4|t5|t5|t6|t6|t7|t7 + b2Val[vec_ind] = _mm256_permute2f128_ps(x1loVal[vec_ind], x1hiVal[vec_ind], 0x20); + b3Val[vec_ind] = _mm256_permute2f128_ps(x1loVal[vec_ind], x1hiVal[vec_ind], 0x31); + + c0Val[vec_ind] = _mm256_mul_ps(a0Val, b0Val[vec_ind]); + c1Val[vec_ind] = _mm256_mul_ps(a1Val, b1Val[vec_ind]); + c2Val[vec_ind] = _mm256_mul_ps(a2Val, b2Val[vec_ind]); + c3Val[vec_ind] = _mm256_mul_ps(a3Val, b3Val[vec_ind]); + + dotProdVal0[vec_ind] = _mm256_add_ps(c0Val[vec_ind], dotProdVal0[vec_ind]); + dotProdVal1[vec_ind] = _mm256_add_ps(c1Val[vec_ind], dotProdVal1[vec_ind]); + dotProdVal2[vec_ind] = _mm256_add_ps(c2Val[vec_ind], dotProdVal2[vec_ind]); + dotProdVal3[vec_ind] = _mm256_add_ps(c3Val[vec_ind], dotProdVal3[vec_ind]); + + bPtr[vec_ind] += 16; + } + + // Force the rotators back onto the unit circle + if ((number % 64) == 0) + { + z0 = _mm256_complexnormalise_ps( z0 ); + z1 = _mm256_complexnormalise_ps( z1 ); + z2 = _mm256_complexnormalise_ps( z2 ); + z3 = _mm256_complexnormalise_ps( z3 ); + } + + aPtr += 32; + } + __VOLK_ATTR_ALIGNED(32) lv_32fc_t dotProductVector[4]; + + for( vec_ind = 0; vec_ind < num_a_vectors; ++vec_ind ) + { + dotProdVal0[vec_ind] = _mm256_add_ps(dotProdVal0[vec_ind], dotProdVal1[vec_ind]); + dotProdVal0[vec_ind] = _mm256_add_ps(dotProdVal0[vec_ind], dotProdVal2[vec_ind]); + dotProdVal0[vec_ind] = _mm256_add_ps(dotProdVal0[vec_ind], dotProdVal3[vec_ind]); + + _mm256_store_ps((float *)dotProductVector, dotProdVal0[vec_ind]); // Store the results back into the dot product vector + + result[ vec_ind ] = lv_cmake( 0, 0 ); + for( i = 0; i < 4; ++i ) + { + result[vec_ind] += dotProductVector[i]; + } + } + + z0 = _mm256_complexnormalise_ps( z0 ); + _mm256_store_ps((float*)phase_vec, z0); + _phase = phase_vec[0]; + _mm256_zeroupper(); + + number = sixteenthPoints*16; + for(;number < num_points; number++) + { + wo = (*aPtr++)*_phase; + _phase *= phase_inc; + + for( vec_ind = 0; vec_ind < num_a_vectors; ++vec_ind ) + { + result[vec_ind] += wo * in_a[vec_ind][number]; + } + } + + *phase = _phase; +} + + #endif /* LV_HAVE_AVX */ #endif /* INCLUDED_volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_H */ diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc.h index a0284f65d..ca684e30b 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc.h @@ -128,5 +128,35 @@ static inline void volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc_u_avx(lv_3 #endif // AVX + +#ifdef LV_HAVE_AVX +static inline void volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc_a_avx(lv_32fc_t* result, const lv_32fc_t* local_code, const float* in, unsigned int num_points) +{ + // phases must be normalized. Phase rotator expects a complex exponential input! + float rem_carrier_phase_in_rad = 0.25; + float phase_step_rad = 0.1; + lv_32fc_t phase[1]; + phase[0] = lv_cmake(cos(rem_carrier_phase_in_rad), sin(rem_carrier_phase_in_rad)); + lv_32fc_t phase_inc[1]; + phase_inc[0] = lv_cmake(cos(phase_step_rad), sin(phase_step_rad)); + unsigned int n; + int num_a_vectors = 3; + float ** in_a = (float **)volk_gnsssdr_malloc(sizeof(float *) * num_a_vectors, volk_gnsssdr_get_alignment()); + for(n = 0; n < num_a_vectors; n++) + { + in_a[n] = (float *)volk_gnsssdr_malloc(sizeof(float ) * num_points, volk_gnsssdr_get_alignment()); + memcpy((float*)in_a[n], (float*)in, sizeof(float) * num_points); + } + volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn_a_avx(result, local_code, phase_inc[0], phase, (const float**) in_a, num_a_vectors, num_points); + + for(n = 0; n < num_a_vectors; n++) + { + volk_gnsssdr_free(in_a[n]); + } + volk_gnsssdr_free(in_a); +} + +#endif // AVX + #endif // INCLUDED_volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc_H From 9ff4d8d88024de3082e0a2d17b02877f7c508a0f Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 15 Nov 2017 10:22:40 +0100 Subject: [PATCH 42/60] Fix Galileo E5a deadlock --- .../galileo_e5a_noncoherent_iq_acquisition_caf.cc | 2 +- .../galileo_e5a_noncoherent_iq_acquisition_caf.h | 1 - .../galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc | 12 ++++++------ .../galileo_e5a_dll_pll_tracking_cc.cc | 1 + 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.cc b/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.cc index ec9501b12..afc50d17c 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.cc @@ -84,7 +84,7 @@ GalileoE5aNoncoherentIQAcquisitionCaf::GalileoE5aNoncoherentIQAcquisitionCaf( bit_transition_flag_ = configuration_->property(role + ".bit_transition_flag", false); //--- Find number of samples per spreading code (1ms)------------------------- - code_length_ = round(fs_in_ / Galileo_E5a_CODE_CHIP_RATE_HZ * Galileo_E5a_CODE_LENGTH_CHIPS); + code_length_ = round(static_cast(fs_in_) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS)); vector_length_ = code_length_ * sampled_ms_; diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h b/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h index ce23d5441..60fc3c577 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h @@ -135,7 +135,6 @@ public: private: ConfigurationInterface* configuration_; galileo_e5a_noncoherentIQ_acquisition_caf_cc_sptr acquisition_cc_; - gr::blocks::stream_to_vector::sptr stream_to_vector_; size_t item_size_; std::string item_type_; unsigned int vector_length_; diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc index f20d39ff0..858a4117d 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc @@ -344,7 +344,7 @@ void galileo_e5a_noncoherentIQ_acquisition_caf_cc::set_state(int state) -int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items, +int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items __attribute__((unused))) { @@ -392,17 +392,17 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items { const gr_complex *in = reinterpret_cast(input_items[0]); //Get the input samples pointer unsigned int buff_increment; - if (ninput_items[0] + d_buffer_count <= d_fft_size) + if ((ninput_items[0] + d_buffer_count) <= d_fft_size) { buff_increment = ninput_items[0]; } else { - buff_increment = (d_fft_size - d_buffer_count); + buff_increment = d_fft_size - d_buffer_count; } memcpy(&d_inbuffer[d_buffer_count], in, sizeof(gr_complex) * buff_increment); // If buffer will be full in next iteration - if (d_buffer_count >= d_fft_size - d_gr_stream_buffer) + if (d_buffer_count >= (d_fft_size - d_gr_stream_buffer)) { d_state = 2; } @@ -419,7 +419,7 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items { memcpy(&d_inbuffer[d_buffer_count], in, sizeof(gr_complex)*(d_fft_size-d_buffer_count)); } - d_sample_counter += d_fft_size-d_buffer_count; // sample counter + d_sample_counter += (d_fft_size - d_buffer_count); // sample counter // initialize acquisition algorithm int doppler; @@ -810,6 +810,6 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items } } - return noutput_items; + return 0; } diff --git a/src/algorithms/tracking/gnuradio_blocks/galileo_e5a_dll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/galileo_e5a_dll_pll_tracking_cc.cc index 45beca2bf..74446bf96 100644 --- a/src/algorithms/tracking/gnuradio_blocks/galileo_e5a_dll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/galileo_e5a_dll_pll_tracking_cc.cc @@ -430,6 +430,7 @@ int Galileo_E5a_Dll_Pll_Tracking_cc::general_work (int noutput_items __attribute current_synchro_data.Carrier_phase_rads = 0.0; current_synchro_data.CN0_dB_hz = 0.0; current_synchro_data.fs = d_fs_in; + *out[0] = current_synchro_data; consume_each(samples_offset); //shift input to perform alignment with local replica return 1; break; From 7076bebf302c94fe144c62b8b6a8720603022843 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 16 Nov 2017 14:44:28 +0100 Subject: [PATCH 43/60] Remove unused include --- .../adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h b/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h index 60fc3c577..cfe7653d7 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h @@ -39,7 +39,6 @@ #define GALILEO_E5A_NONCOHERENT_IQ_ACQUISITION_CAF_H_ #include -#include #include "gnss_synchro.h" #include "acquisition_interface.h" #include "galileo_e5a_noncoherent_iq_acquisition_caf_cc.h" From 6d216fa5a1ed5a006ce91181d23261a662b170ef Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 16 Nov 2017 19:45:15 +0100 Subject: [PATCH 44/60] Add volk_gnsssdr_16ic_conjugate_16ic kernel --- .../volk_gnsssdr_16ic_conjugate_16ic.h | 377 ++++++++++++++++++ .../volk_gnsssdr/lib/kernel_tests.h | 1 + 2 files changed, 378 insertions(+) create mode 100644 src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_conjugate_16ic.h diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_conjugate_16ic.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_conjugate_16ic.h new file mode 100644 index 000000000..bf7608413 --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_conjugate_16ic.h @@ -0,0 +1,377 @@ +/*! + * \file volk_gnsssdr_16ic_conjugate_16ic.h + * \brief VOLK_GNSSSDR kernel: calculates the conjugate of a 16 bits vector. + * \authors
    + *
  • Andres Cecilia, 2014. a.cecilia.luque(at)gmail.com + *
+ * + * VOLK_GNSSSDR kernel that calculates the conjugate of a + * 16 bits vector (8 bits the real part and 8 bits the imaginary part) + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2015 (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 . + * + * ------------------------------------------------------------------------- + */ + +/*! + * \page volk_gnsssdr_16ic_conjugate_16ic + * + * \b Overview + * + * Takes the conjugate of a complex unsigned char vector. + * + * Dispatcher Prototype + * \code + * void volk_gnsssdr_16ic_conjugate_16ic(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points); + * \endcode + * + * \b Inputs + * \li aVector: Vector of complex items to be conjugated + * \li num_points: The number of complex data points. + * + * \b Outputs + * \li cVector: The vector where the result will be stored + * + */ + +#ifndef INCLUDED_volk_gnsssdr_16ic_conjugate_16ic_H +#define INCLUDED_volk_gnsssdr_16ic_conjugate_16ic_H + +#include + + +//#ifdef LV_HAVE_AVX2 +//#include +// +//static inline void volk_gnsssdr_16ic_conjugate_16ic_u_avx2(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +//{ +// const unsigned int avx2_iters = num_points / 16; +// unsigned int i; +// lv_16sc_t* c = cVector; +// const lv_16sc_t* a = aVector; +// +// __m256i tmp; +// __m256i conjugator = _mm256_setr_epi8(1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1); +// +// for (i = 0; i < avx2_iters; ++i) +// { +// tmp = _mm256_loadu_si256((__m256i*)a); +// tmp = _mm256_sign_epi8(tmp, conjugator); +// _mm256_storeu_si256((__m256i*)c, tmp); +// +// a += 16; +// c += 16; +// } +// +// for (i = avx2_iters * 16; i < num_points; ++i) +// { +// *c++ = lv_conj(*a++); +// } +//} +//#endif /* LV_HAVE_AVX2 */ + + +//#ifdef LV_HAVE_AVX +//#include +//static inline void volk_gnsssdr_16ic_conjugate_16ic_u_avx(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +//{ +// const unsigned int sse_iters = num_points / 8; +// unsigned int i; +// lv_16sc_t* c = cVector; +// const lv_16sc_t* a = aVector; +// +// __m256i tmp; +// //__m128i tmp128lo, tmp128hi; +// //__m256 conjugator1 = _mm256_castsi256_ps(_mm256_setr_epi16(0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF)); +// //__m128i conjugator2 = _mm_setr_epi16(0, -1, 0, -1, 0, -1, 0, -1); +// __m256i conjugator = _mm256_setr_ps(0, -1, 0, -1, 0, -1, 0, -1); +// +// for (i = 0; i < sse_iters; ++i) +// { +// tmp = _mm256_loadu_si256((__m256i*)a); +// tmp = _mm256_xor_si256(tmp, conjugator); +// //tmp128lo = _mm256_castsi256_si128(_mm256_castps_si256(tmp)); +// //tmp128lo = _mm_add_epi16(tmp128lo, conjugator2); +// //tmp128hi = _mm256_extractf128_si256(_mm256_castps_si256(tmp),1); +// //tmp128hi = _mm_add_epi16(tmp128hi, conjugator2); +// //tmp = _mm256_set_m128i(tmp128hi , tmp128lo); //not defined in some versions of immintrin.h +// //tmp = _mm256_castsi256_ps(_mm256_insertf128_si256(_mm256_castsi128_si256(tmp128lo),(tmp128hi),1)); +// _mm256_storeu_si256((__m256i*)c, tmp); +// +// a += 8; +// c += 8; +// } +// +// for (i = sse_iters * 8; i < num_points; ++i) +// { +// *c++ = lv_conj(*a++); +// } +//} +//#endif /* LV_HAVE_AVX */ + + +#ifdef LV_HAVE_SSSE3 +#include + +static inline void volk_gnsssdr_16ic_conjugate_16ic_u_ssse3(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +{ + const unsigned int sse_iters = num_points / 4; + unsigned int i; + lv_16sc_t* c = cVector; + const lv_16sc_t* a = aVector; + __m128i tmp; + + __m128i conjugator = _mm_setr_epi16(1, -1, 1, -1, 1, -1, 1, -1); + + for (i = 0; i < sse_iters; ++i) + { + tmp = _mm_lddqu_si128((__m128i*)a); + tmp = _mm_sign_epi16(tmp, conjugator); + _mm_storeu_si128((__m128i*)c, tmp); + a += 4; + c += 4; + } + + for (i = sse_iters * 4; i < num_points; ++i) + { + *c++ = lv_conj(*a++); + } +} + +#endif /* LV_HAVE_SSSE3 */ +// +// +//#ifdef LV_HAVE_SSE3 +//#include +// +//static inline void volk_gnsssdr_16ic_conjugate_16ic_u_sse3(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +//{ +// const unsigned int sse_iters = num_points / 8; +// unsigned int i; +// lv_16sc_t* c = cVector; +// const lv_16sc_t* a = aVector; +// __m128i tmp; +// +// __m128i conjugator1 = _mm_setr_epi8(0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF); +// __m128i conjugator2 = _mm_setr_epi8(0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1); +// +// for (i = 0; i < sse_iters; ++i) +// { +// tmp = _mm_lddqu_si128((__m128i*)a); +// tmp = _mm_xor_si128(tmp, conjugator1); +// tmp = _mm_add_epi8(tmp, conjugator2); +// _mm_storeu_si128((__m128i*)c, tmp); +// a += 8; +// c += 8; +// } +// +// for (i = sse_iters * 8; i < num_points; ++i) +// { +// *c++ = lv_conj(*a++); +// } +// +//} +//#endif /* LV_HAVE_SSE3 */ + + +#ifdef LV_HAVE_GENERIC + +static inline void volk_gnsssdr_16ic_conjugate_16ic_generic(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +{ + lv_16sc_t* cPtr = cVector; + const lv_16sc_t* aPtr = aVector; + unsigned int number; + + for(number = 0; number < num_points; number++) + { + *cPtr++ = lv_conj(*aPtr++); + } +} +#endif /* LV_HAVE_GENERIC */ + + +//#ifdef LV_HAVE_AVX +//#include +// +//static inline void volk_gnsssdr_16ic_conjugate_16ic_a_avx(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +//{ +// const unsigned int sse_iters = num_points / 16; +// unsigned int i; +// lv_16sc_t* c = cVector; +// const lv_16sc_t* a = aVector; +// +// __m256 tmp; +// __m128i tmp128lo, tmp128hi; +// __m256 conjugator1 = _mm256_castsi256_ps(_mm256_setr_epi8(0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF)); +// __m128i conjugator2 = _mm_setr_epi8(0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1); +// +// for (i = 0; i < sse_iters; ++i) +// { +// tmp = _mm256_load_ps((float*)a); +// tmp = _mm256_xor_ps(tmp, conjugator1); +// tmp128lo = _mm256_castsi256_si128(_mm256_castps_si256(tmp)); +// tmp128lo = _mm_add_epi8(tmp128lo, conjugator2); +// tmp128hi = _mm256_extractf128_si256(_mm256_castps_si256(tmp),1); +// tmp128hi = _mm_add_epi8(tmp128hi, conjugator2); +// //tmp = _mm256_set_m128i(tmp128hi , tmp128lo); //not defined in some versions of immintrin.h +// tmp = _mm256_castsi256_ps(_mm256_insertf128_si256(_mm256_castsi128_si256(tmp128lo),(tmp128hi),1)); +// _mm256_store_ps((float*)c, tmp); +// +// a += 16; +// c += 16; +// } +// +// for (i = sse_iters * 16; i < num_points; ++i) +// { +// *c++ = lv_conj(*a++); +// } +//} +//#endif /* LV_HAVE_AVX */ +// +// +//#ifdef LV_HAVE_AVX2 +//#include +// +//static inline void volk_gnsssdr_16ic_conjugate_16ic_a_avx2(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +//{ +// const unsigned int avx2_iters = num_points / 16; +// unsigned int i; +// lv_16sc_t* c = cVector; +// const lv_16sc_t* a = aVector; +// +// __m256i tmp; +// __m256i conjugator = _mm256_setr_epi8(1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1); +// +// for (i = 0; i < avx2_iters; ++i) +// { +// tmp = _mm256_load_si256((__m256i*)a); +// tmp = _mm256_sign_epi8(tmp, conjugator); +// _mm256_store_si256((__m256i*)c, tmp); +// +// a += 16; +// c += 16; +// } +// +// for (i = avx2_iters * 16; i < num_points; ++i) +// { +// *c++ = lv_conj(*a++); +// } +//} +//#endif /* LV_HAVE_AVX2 */ +// +// +#ifdef LV_HAVE_SSSE3 +#include + +static inline void volk_gnsssdr_16ic_conjugate_16ic_a_ssse3(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +{ + const unsigned int sse_iters = num_points / 4; + unsigned int i; + lv_16sc_t* c = cVector; + const lv_16sc_t* a = aVector; + __m128i tmp; + __m128i conjugator = _mm_setr_epi16(1, -1, 1, -1, 1, -1, 1, -1); + + for (i = 0; i < sse_iters; ++i) + { + tmp = _mm_load_si128((__m128i*)a); + tmp = _mm_sign_epi16(tmp, conjugator); + _mm_store_si128((__m128i*)c, tmp); + a += 4; + c += 4; + } + + for (i = sse_iters * 4; i < num_points; ++i) + { + *c++ = lv_conj(*a++); + } +} + +#endif /* LV_HAVE_SSSE3 */ +// +// +//#ifdef LV_HAVE_SSE3 +//#include +// +//static inline void volk_gnsssdr_16ic_conjugate_16ic_a_sse3(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +//{ +// const unsigned int sse_iters = num_points / 8; +// unsigned int i; +// lv_16sc_t* c = cVector; +// const lv_16sc_t* a = aVector; +// __m128i tmp; +// +// __m128i conjugator1 = _mm_setr_epi8(0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF); +// __m128i conjugator2 = _mm_setr_epi8(0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1); +// +// for (i = 0; i < sse_iters; ++i) +// { +// tmp = _mm_load_si128((__m128i*)a); +// tmp = _mm_xor_si128(tmp, conjugator1); +// tmp = _mm_add_epi8(tmp, conjugator2); +// _mm_store_si128((__m128i*)c, tmp); +// a += 8; +// c += 8; +// } +// +// for (i = sse_iters * 8; i < num_points; ++i) +// { +// *c++ = lv_conj(*a++); +// } +// +//} +//#endif /* LV_HAVE_SSE3 */ +// +// +// +// +//#ifdef LV_HAVE_NEON +//#include +// +//static inline void volk_gnsssdr_16ic_conjugate_16ic_neon(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +//{ +// const unsigned int sse_iters = num_points / 4; +// unsigned int i; +// lv_16sc_t* c = cVector; +// const lv_16sc_t* a = aVector; +// int16x4x2_t a_val; +// +// for (i = 0; i < sse_iters; ++i) +// { +// a_val = vld2_s16((const int16_t*)a); +// __VOLK_GNSSSDR_PREFETCH(a + 16); +// a_val.val[1] = vneg_s16(a_val.val[1]); +// vst2_s16((int16_t*)c, a_val); +// a += 4; +// c += 4; +// } +// +// for (i = sse_iters * 4; i < num_points; ++i) +// { +// *c++ = lv_conj(*a++); +// } +//} +//#endif /* LV_HAVE_NEON */ + +#endif /* INCLUDED_volk_gnsssdr_16ic_conjugate_16ic_H */ + diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/kernel_tests.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/kernel_tests.h index da0b2f0f8..e7fa4e62b 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/kernel_tests.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/kernel_tests.h @@ -84,6 +84,7 @@ std::vector init_test_list(volk_gnsssdr_test_params_t (VOLK_INIT_TEST(volk_gnsssdr_16ic_x2_dot_prod_16ic, test_params)) (VOLK_INIT_TEST(volk_gnsssdr_16ic_x2_multiply_16ic, test_params_more_iters)) (VOLK_INIT_TEST(volk_gnsssdr_16ic_convert_32fc, test_params_more_iters)) + (VOLK_INIT_TEST(volk_gnsssdr_16ic_conjugate_16ic, test_params_more_iters)) (VOLK_INIT_PUPP(volk_gnsssdr_s32f_sincospuppet_32fc, volk_gnsssdr_s32f_sincos_32fc, test_params_inacc2)) (VOLK_INIT_PUPP(volk_gnsssdr_16ic_rotatorpuppet_16ic, volk_gnsssdr_16ic_s32fc_x2_rotator_16ic, test_params_int1)) (VOLK_INIT_PUPP(volk_gnsssdr_16ic_resamplerfastpuppet_16ic, volk_gnsssdr_16ic_resampler_fast_16ic, test_params)) From eecfa6c582c744aaf97e3090e179c8a1916b4bfb Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 16 Nov 2017 19:51:15 +0100 Subject: [PATCH 45/60] Add AVX2 --- .../volk_gnsssdr_16ic_conjugate_16ic.h | 117 +++++++++--------- 1 file changed, 59 insertions(+), 58 deletions(-) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_conjugate_16ic.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_conjugate_16ic.h index bf7608413..8745b40d3 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_conjugate_16ic.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_conjugate_16ic.h @@ -60,35 +60,35 @@ #include -//#ifdef LV_HAVE_AVX2 -//#include -// -//static inline void volk_gnsssdr_16ic_conjugate_16ic_u_avx2(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) -//{ -// const unsigned int avx2_iters = num_points / 16; -// unsigned int i; -// lv_16sc_t* c = cVector; -// const lv_16sc_t* a = aVector; -// -// __m256i tmp; -// __m256i conjugator = _mm256_setr_epi8(1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1); -// -// for (i = 0; i < avx2_iters; ++i) -// { -// tmp = _mm256_loadu_si256((__m256i*)a); -// tmp = _mm256_sign_epi8(tmp, conjugator); -// _mm256_storeu_si256((__m256i*)c, tmp); -// -// a += 16; -// c += 16; -// } -// -// for (i = avx2_iters * 16; i < num_points; ++i) -// { -// *c++ = lv_conj(*a++); -// } -//} -//#endif /* LV_HAVE_AVX2 */ +#ifdef LV_HAVE_AVX2 +#include + +static inline void volk_gnsssdr_16ic_conjugate_16ic_u_avx2(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +{ + const unsigned int avx2_iters = num_points / 8; + unsigned int i; + lv_16sc_t* c = cVector; + const lv_16sc_t* a = aVector; + + __m256i tmp; + __m256i conjugator = _mm256_setr_epi16(1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1); + + for (i = 0; i < avx2_iters; ++i) + { + tmp = _mm256_loadu_si256((__m256i*)a); + tmp = _mm256_sign_epi16(tmp, conjugator); + _mm256_storeu_si256((__m256i*)c, tmp); + + a += 8; + c += 8; + } + + for (i = avx2_iters * 8; i < num_points; ++i) + { + *c++ = lv_conj(*a++); + } +} +#endif /* LV_HAVE_AVX2 */ //#ifdef LV_HAVE_AVX @@ -249,35 +249,36 @@ static inline void volk_gnsssdr_16ic_conjugate_16ic_generic(lv_16sc_t* cVector, //#endif /* LV_HAVE_AVX */ // // -//#ifdef LV_HAVE_AVX2 -//#include -// -//static inline void volk_gnsssdr_16ic_conjugate_16ic_a_avx2(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) -//{ -// const unsigned int avx2_iters = num_points / 16; -// unsigned int i; -// lv_16sc_t* c = cVector; -// const lv_16sc_t* a = aVector; -// -// __m256i tmp; -// __m256i conjugator = _mm256_setr_epi8(1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1); -// -// for (i = 0; i < avx2_iters; ++i) -// { -// tmp = _mm256_load_si256((__m256i*)a); -// tmp = _mm256_sign_epi8(tmp, conjugator); -// _mm256_store_si256((__m256i*)c, tmp); -// -// a += 16; -// c += 16; -// } -// -// for (i = avx2_iters * 16; i < num_points; ++i) -// { -// *c++ = lv_conj(*a++); -// } -//} -//#endif /* LV_HAVE_AVX2 */ +#ifdef LV_HAVE_AVX2 +#include + +static inline void volk_gnsssdr_16ic_conjugate_16ic_a_avx2(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +{ + const unsigned int avx2_iters = num_points / 8; + unsigned int i; + lv_16sc_t* c = cVector; + const lv_16sc_t* a = aVector; + + __m256i tmp; + __m256i conjugator = _mm256_setr_epi16(1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1); + + for (i = 0; i < avx2_iters; ++i) + { + tmp = _mm256_load_si256((__m256i*)a); + tmp = _mm256_sign_epi16(tmp, conjugator); + _mm256_store_si256((__m256i*)c, tmp); + + a += 8; + c += 8; + } + + for (i = avx2_iters * 8; i < num_points; ++i) + { + *c++ = lv_conj(*a++); + } +} + +#endif /* LV_HAVE_AVX2 */ // // #ifdef LV_HAVE_SSSE3 From fe241c8b2d8375ba40771d4b1bba75e9247bab67 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 16 Nov 2017 20:54:04 +0100 Subject: [PATCH 46/60] clean kernel --- .../volk_gnsssdr_16ic_conjugate_16ic.h | 376 ++++++------------ 1 file changed, 116 insertions(+), 260 deletions(-) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_conjugate_16ic.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_conjugate_16ic.h index 8745b40d3..5aae17266 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_conjugate_16ic.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_conjugate_16ic.h @@ -1,16 +1,16 @@ /*! * \file volk_gnsssdr_16ic_conjugate_16ic.h - * \brief VOLK_GNSSSDR kernel: calculates the conjugate of a 16 bits vector. + * \brief VOLK_GNSSSDR kernel: returns the conjugate of a 16 bits complex vector. * \authors
    - *
  • Andres Cecilia, 2014. a.cecilia.luque(at)gmail.com + *
  • Carles Fernandez Prades 2017 cfernandez at cttc dot cat *
* * VOLK_GNSSSDR kernel that calculates the conjugate of a - * 16 bits vector (8 bits the real part and 8 bits the imaginary part) + * 16 bits complex vector (16 bits the real part and 16 bits the imaginary part) * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -38,7 +38,7 @@ * * \b Overview * - * Takes the conjugate of a complex unsigned char vector. + * Takes the conjugate of a complex signed 16-bit integer vector. * * Dispatcher Prototype * \code @@ -60,6 +60,116 @@ #include +#ifdef LV_HAVE_GENERIC + +static inline void volk_gnsssdr_16ic_conjugate_16ic_generic(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +{ + lv_16sc_t* cPtr = cVector; + const lv_16sc_t* aPtr = aVector; + unsigned int number; + + for(number = 0; number < num_points; number++) + { + *cPtr++ = lv_conj(*aPtr++); + } +} + +#endif /* LV_HAVE_GENERIC */ + + +#ifdef LV_HAVE_SSSE3 +#include + +static inline void volk_gnsssdr_16ic_conjugate_16ic_u_ssse3(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +{ + const unsigned int sse_iters = num_points / 4; + unsigned int i; + lv_16sc_t* c = cVector; + const lv_16sc_t* a = aVector; + __m128i tmp; + + __m128i conjugator = _mm_setr_epi16(1, -1, 1, -1, 1, -1, 1, -1); + + for (i = 0; i < sse_iters; ++i) + { + tmp = _mm_lddqu_si128((__m128i*)a); + tmp = _mm_sign_epi16(tmp, conjugator); + _mm_storeu_si128((__m128i*)c, tmp); + a += 4; + c += 4; + } + + for (i = sse_iters * 4; i < num_points; ++i) + { + *c++ = lv_conj(*a++); + } +} + +#endif /* LV_HAVE_SSSE3 */ + + +#ifdef LV_HAVE_SSSE3 +#include + +static inline void volk_gnsssdr_16ic_conjugate_16ic_a_ssse3(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +{ + const unsigned int sse_iters = num_points / 4; + unsigned int i; + lv_16sc_t* c = cVector; + const lv_16sc_t* a = aVector; + __m128i tmp; + __m128i conjugator = _mm_setr_epi16(1, -1, 1, -1, 1, -1, 1, -1); + + for (i = 0; i < sse_iters; ++i) + { + tmp = _mm_load_si128((__m128i*)a); + tmp = _mm_sign_epi16(tmp, conjugator); + _mm_store_si128((__m128i*)c, tmp); + a += 4; + c += 4; + } + + for (i = sse_iters * 4; i < num_points; ++i) + { + *c++ = lv_conj(*a++); + } +} + +#endif /* LV_HAVE_SSSE3 */ + + +#ifdef LV_HAVE_AVX2 +#include + +static inline void volk_gnsssdr_16ic_conjugate_16ic_a_avx2(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) +{ + const unsigned int avx2_iters = num_points / 8; + unsigned int i; + lv_16sc_t* c = cVector; + const lv_16sc_t* a = aVector; + + __m256i tmp; + __m256i conjugator = _mm256_setr_epi16(1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1); + + for (i = 0; i < avx2_iters; ++i) + { + tmp = _mm256_load_si256((__m256i*)a); + tmp = _mm256_sign_epi16(tmp, conjugator); + _mm256_store_si256((__m256i*)c, tmp); + + a += 8; + c += 8; + } + + for (i = avx2_iters * 8; i < num_points; ++i) + { + *c++ = lv_conj(*a++); + } +} + +#endif /* LV_HAVE_AVX2 */ + + #ifdef LV_HAVE_AVX2 #include @@ -90,260 +200,6 @@ static inline void volk_gnsssdr_16ic_conjugate_16ic_u_avx2(lv_16sc_t* cVector, c } #endif /* LV_HAVE_AVX2 */ - -//#ifdef LV_HAVE_AVX -//#include -//static inline void volk_gnsssdr_16ic_conjugate_16ic_u_avx(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) -//{ -// const unsigned int sse_iters = num_points / 8; -// unsigned int i; -// lv_16sc_t* c = cVector; -// const lv_16sc_t* a = aVector; -// -// __m256i tmp; -// //__m128i tmp128lo, tmp128hi; -// //__m256 conjugator1 = _mm256_castsi256_ps(_mm256_setr_epi16(0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF)); -// //__m128i conjugator2 = _mm_setr_epi16(0, -1, 0, -1, 0, -1, 0, -1); -// __m256i conjugator = _mm256_setr_ps(0, -1, 0, -1, 0, -1, 0, -1); -// -// for (i = 0; i < sse_iters; ++i) -// { -// tmp = _mm256_loadu_si256((__m256i*)a); -// tmp = _mm256_xor_si256(tmp, conjugator); -// //tmp128lo = _mm256_castsi256_si128(_mm256_castps_si256(tmp)); -// //tmp128lo = _mm_add_epi16(tmp128lo, conjugator2); -// //tmp128hi = _mm256_extractf128_si256(_mm256_castps_si256(tmp),1); -// //tmp128hi = _mm_add_epi16(tmp128hi, conjugator2); -// //tmp = _mm256_set_m128i(tmp128hi , tmp128lo); //not defined in some versions of immintrin.h -// //tmp = _mm256_castsi256_ps(_mm256_insertf128_si256(_mm256_castsi128_si256(tmp128lo),(tmp128hi),1)); -// _mm256_storeu_si256((__m256i*)c, tmp); -// -// a += 8; -// c += 8; -// } -// -// for (i = sse_iters * 8; i < num_points; ++i) -// { -// *c++ = lv_conj(*a++); -// } -//} -//#endif /* LV_HAVE_AVX */ - - -#ifdef LV_HAVE_SSSE3 -#include - -static inline void volk_gnsssdr_16ic_conjugate_16ic_u_ssse3(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) -{ - const unsigned int sse_iters = num_points / 4; - unsigned int i; - lv_16sc_t* c = cVector; - const lv_16sc_t* a = aVector; - __m128i tmp; - - __m128i conjugator = _mm_setr_epi16(1, -1, 1, -1, 1, -1, 1, -1); - - for (i = 0; i < sse_iters; ++i) - { - tmp = _mm_lddqu_si128((__m128i*)a); - tmp = _mm_sign_epi16(tmp, conjugator); - _mm_storeu_si128((__m128i*)c, tmp); - a += 4; - c += 4; - } - - for (i = sse_iters * 4; i < num_points; ++i) - { - *c++ = lv_conj(*a++); - } -} - -#endif /* LV_HAVE_SSSE3 */ -// -// -//#ifdef LV_HAVE_SSE3 -//#include -// -//static inline void volk_gnsssdr_16ic_conjugate_16ic_u_sse3(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) -//{ -// const unsigned int sse_iters = num_points / 8; -// unsigned int i; -// lv_16sc_t* c = cVector; -// const lv_16sc_t* a = aVector; -// __m128i tmp; -// -// __m128i conjugator1 = _mm_setr_epi8(0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF); -// __m128i conjugator2 = _mm_setr_epi8(0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1); -// -// for (i = 0; i < sse_iters; ++i) -// { -// tmp = _mm_lddqu_si128((__m128i*)a); -// tmp = _mm_xor_si128(tmp, conjugator1); -// tmp = _mm_add_epi8(tmp, conjugator2); -// _mm_storeu_si128((__m128i*)c, tmp); -// a += 8; -// c += 8; -// } -// -// for (i = sse_iters * 8; i < num_points; ++i) -// { -// *c++ = lv_conj(*a++); -// } -// -//} -//#endif /* LV_HAVE_SSE3 */ - - -#ifdef LV_HAVE_GENERIC - -static inline void volk_gnsssdr_16ic_conjugate_16ic_generic(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) -{ - lv_16sc_t* cPtr = cVector; - const lv_16sc_t* aPtr = aVector; - unsigned int number; - - for(number = 0; number < num_points; number++) - { - *cPtr++ = lv_conj(*aPtr++); - } -} -#endif /* LV_HAVE_GENERIC */ - - -//#ifdef LV_HAVE_AVX -//#include -// -//static inline void volk_gnsssdr_16ic_conjugate_16ic_a_avx(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) -//{ -// const unsigned int sse_iters = num_points / 16; -// unsigned int i; -// lv_16sc_t* c = cVector; -// const lv_16sc_t* a = aVector; -// -// __m256 tmp; -// __m128i tmp128lo, tmp128hi; -// __m256 conjugator1 = _mm256_castsi256_ps(_mm256_setr_epi8(0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF)); -// __m128i conjugator2 = _mm_setr_epi8(0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1); -// -// for (i = 0; i < sse_iters; ++i) -// { -// tmp = _mm256_load_ps((float*)a); -// tmp = _mm256_xor_ps(tmp, conjugator1); -// tmp128lo = _mm256_castsi256_si128(_mm256_castps_si256(tmp)); -// tmp128lo = _mm_add_epi8(tmp128lo, conjugator2); -// tmp128hi = _mm256_extractf128_si256(_mm256_castps_si256(tmp),1); -// tmp128hi = _mm_add_epi8(tmp128hi, conjugator2); -// //tmp = _mm256_set_m128i(tmp128hi , tmp128lo); //not defined in some versions of immintrin.h -// tmp = _mm256_castsi256_ps(_mm256_insertf128_si256(_mm256_castsi128_si256(tmp128lo),(tmp128hi),1)); -// _mm256_store_ps((float*)c, tmp); -// -// a += 16; -// c += 16; -// } -// -// for (i = sse_iters * 16; i < num_points; ++i) -// { -// *c++ = lv_conj(*a++); -// } -//} -//#endif /* LV_HAVE_AVX */ -// -// -#ifdef LV_HAVE_AVX2 -#include - -static inline void volk_gnsssdr_16ic_conjugate_16ic_a_avx2(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) -{ - const unsigned int avx2_iters = num_points / 8; - unsigned int i; - lv_16sc_t* c = cVector; - const lv_16sc_t* a = aVector; - - __m256i tmp; - __m256i conjugator = _mm256_setr_epi16(1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1); - - for (i = 0; i < avx2_iters; ++i) - { - tmp = _mm256_load_si256((__m256i*)a); - tmp = _mm256_sign_epi16(tmp, conjugator); - _mm256_store_si256((__m256i*)c, tmp); - - a += 8; - c += 8; - } - - for (i = avx2_iters * 8; i < num_points; ++i) - { - *c++ = lv_conj(*a++); - } -} - -#endif /* LV_HAVE_AVX2 */ -// -// -#ifdef LV_HAVE_SSSE3 -#include - -static inline void volk_gnsssdr_16ic_conjugate_16ic_a_ssse3(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) -{ - const unsigned int sse_iters = num_points / 4; - unsigned int i; - lv_16sc_t* c = cVector; - const lv_16sc_t* a = aVector; - __m128i tmp; - __m128i conjugator = _mm_setr_epi16(1, -1, 1, -1, 1, -1, 1, -1); - - for (i = 0; i < sse_iters; ++i) - { - tmp = _mm_load_si128((__m128i*)a); - tmp = _mm_sign_epi16(tmp, conjugator); - _mm_store_si128((__m128i*)c, tmp); - a += 4; - c += 4; - } - - for (i = sse_iters * 4; i < num_points; ++i) - { - *c++ = lv_conj(*a++); - } -} - -#endif /* LV_HAVE_SSSE3 */ -// -// -//#ifdef LV_HAVE_SSE3 -//#include -// -//static inline void volk_gnsssdr_16ic_conjugate_16ic_a_sse3(lv_16sc_t* cVector, const lv_16sc_t* aVector, unsigned int num_points) -//{ -// const unsigned int sse_iters = num_points / 8; -// unsigned int i; -// lv_16sc_t* c = cVector; -// const lv_16sc_t* a = aVector; -// __m128i tmp; -// -// __m128i conjugator1 = _mm_setr_epi8(0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF); -// __m128i conjugator2 = _mm_setr_epi8(0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1); -// -// for (i = 0; i < sse_iters; ++i) -// { -// tmp = _mm_load_si128((__m128i*)a); -// tmp = _mm_xor_si128(tmp, conjugator1); -// tmp = _mm_add_epi8(tmp, conjugator2); -// _mm_store_si128((__m128i*)c, tmp); -// a += 8; -// c += 8; -// } -// -// for (i = sse_iters * 8; i < num_points; ++i) -// { -// *c++ = lv_conj(*a++); -// } -// -//} -//#endif /* LV_HAVE_SSE3 */ -// -// // // //#ifdef LV_HAVE_NEON @@ -360,7 +216,7 @@ static inline void volk_gnsssdr_16ic_conjugate_16ic_a_ssse3(lv_16sc_t* cVector, // for (i = 0; i < sse_iters; ++i) // { // a_val = vld2_s16((const int16_t*)a); -// __VOLK_GNSSSDR_PREFETCH(a + 16); +// __VOLK_GNSSSDR_PREFETCH(a + 4); // a_val.val[1] = vneg_s16(a_val.val[1]); // vst2_s16((int16_t*)c, a_val); // a += 4; From d20902d6883310a39cd1fe77c7b95b7e40bee4ed Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 17 Nov 2017 09:21:03 +0100 Subject: [PATCH 47/60] Add mechanisms for inverted spectrum --- .../data_type_adapter/adapters/CMakeLists.txt | 1 + .../adapters/ibyte_to_cbyte.cc | 55 +++++++++++++++-- .../adapters/ibyte_to_cbyte.h | 3 + .../adapters/ibyte_to_complex.cc | 56 +++++++++++++++--- .../adapters/ibyte_to_complex.h | 5 +- .../adapters/ibyte_to_cshort.cc | 52 +++++++++++++--- .../adapters/ibyte_to_cshort.h | 3 + .../adapters/ishort_to_complex.cc | 54 ++++++++++++++--- .../adapters/ishort_to_complex.h | 3 + .../adapters/ishort_to_cshort.cc | 54 ++++++++++++++--- .../adapters/ishort_to_cshort.h | 3 + src/algorithms/libs/CMakeLists.txt | 3 + src/algorithms/libs/conjugate_cc.cc | 29 +++++++++ src/algorithms/libs/conjugate_cc.h | 59 +++++++++++++++++++ src/algorithms/libs/conjugate_ic.cc | 29 +++++++++ src/algorithms/libs/conjugate_ic.h | 59 +++++++++++++++++++ src/algorithms/libs/conjugate_sc.cc | 29 +++++++++ src/algorithms/libs/conjugate_sc.h | 59 +++++++++++++++++++ src/algorithms/libs/pass_through.cc | 57 +++++++++++++++++- src/algorithms/libs/pass_through.h | 14 +++-- .../adapter/pass_through_test.cc | 3 - 21 files changed, 583 insertions(+), 47 deletions(-) create mode 100644 src/algorithms/libs/conjugate_cc.cc create mode 100644 src/algorithms/libs/conjugate_cc.h create mode 100644 src/algorithms/libs/conjugate_ic.cc create mode 100644 src/algorithms/libs/conjugate_ic.h create mode 100644 src/algorithms/libs/conjugate_sc.cc create mode 100644 src/algorithms/libs/conjugate_sc.h diff --git a/src/algorithms/data_type_adapter/adapters/CMakeLists.txt b/src/algorithms/data_type_adapter/adapters/CMakeLists.txt index a88ffd3e9..d18c83b04 100644 --- a/src/algorithms/data_type_adapter/adapters/CMakeLists.txt +++ b/src/algorithms/data_type_adapter/adapters/CMakeLists.txt @@ -31,6 +31,7 @@ include_directories( ${CMAKE_SOURCE_DIR}/src/core/system_parameters ${CMAKE_SOURCE_DIR}/src/core/interfaces ${CMAKE_SOURCE_DIR}/src/algorithms/data_type_adapter/gnuradio_blocks + ${CMAKE_SOURCE_DIR}/src/algorithms/libs ${GLOG_INCLUDE_DIRS} ${GFlags_INCLUDE_DIRS} ${GNURADIO_RUNTIME_INCLUDE_DIRS} diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.cc b/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.cc index 8dc47c8ad..e91455a23 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.cc +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.cc @@ -51,6 +51,7 @@ IbyteToCbyte::IbyteToCbyte(ConfigurationInterface* configuration, std::string ro dump_ = config_->property(role_ + ".dump", false); dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename); + inverted_spectrum = configuration->property(role + ".inverted_spectrum", false); size_t item_size = sizeof(lv_8sc_t); @@ -63,6 +64,10 @@ IbyteToCbyte::IbyteToCbyte(ConfigurationInterface* configuration, std::string ro DLOG(INFO) << "Dumping output into file " << dump_filename_; file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str()); } + if(inverted_spectrum) + { + conjugate_ic_ = make_conjugate_ic(); + } } @@ -74,7 +79,26 @@ void IbyteToCbyte::connect(gr::top_block_sptr top_block) { if (dump_) { - top_block->connect(ibyte_to_cbyte_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->connect(ibyte_to_cbyte_, 0, conjugate_ic_, 0); + top_block->connect(conjugate_ic_, 0, file_sink_, 0); + } + else + { + top_block->connect(ibyte_to_cbyte_, 0, file_sink_, 0); + } + } + else + { + if(inverted_spectrum) + { + top_block->connect(ibyte_to_cbyte_, 0, conjugate_ic_, 0); + } + else + { + DLOG(INFO) << "Nothing to connect internally"; + } } } @@ -83,21 +107,40 @@ void IbyteToCbyte::disconnect(gr::top_block_sptr top_block) { if (dump_) { - top_block->disconnect(ibyte_to_cbyte_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->disconnect(ibyte_to_cbyte_, 0, conjugate_ic_, 0); + top_block->disconnect(conjugate_ic_, 0, file_sink_, 0); + } + else + { + top_block->disconnect(ibyte_to_cbyte_, 0, file_sink_, 0); + } + } + else + { + if(inverted_spectrum) + { + top_block->disconnect(ibyte_to_cbyte_, 0, conjugate_ic_, 0); + } } } - gr::basic_block_sptr IbyteToCbyte::get_left_block() { return ibyte_to_cbyte_; } - gr::basic_block_sptr IbyteToCbyte::get_right_block() { - return ibyte_to_cbyte_; + if(inverted_spectrum) + { + return conjugate_ic_; + } + else + { + return ibyte_to_cbyte_; + } } - diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h b/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h index 2aa0d1197..c40d85286 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h @@ -34,6 +34,7 @@ #include #include +#include "conjugate_ic.h" #include "gnss_block_interface.h" #include "interleaved_byte_to_complex_byte.h" @@ -85,6 +86,8 @@ private: unsigned int in_streams_; unsigned int out_streams_; gr::blocks::file_sink::sptr file_sink_; + conjugate_ic_sptr conjugate_ic_; + bool inverted_spectrum; }; #endif diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.cc b/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.cc index 6119ebd9f..83b6fd6c5 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.cc +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.cc @@ -49,6 +49,7 @@ IbyteToComplex::IbyteToComplex(ConfigurationInterface* configuration, std::strin dump_ = config_->property(role_ + ".dump", false); dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename); + inverted_spectrum = configuration->property(role + ".inverted_spectrum", false); size_t item_size = sizeof(gr_complex); @@ -56,6 +57,10 @@ IbyteToComplex::IbyteToComplex(ConfigurationInterface* configuration, std::strin DLOG(INFO) << "data_type_adapter_(" << gr_interleaved_char_to_complex_->unique_id() << ")"; + if (inverted_spectrum) + { + conjugate_cc_ = make_conjugate_cc(); + } if (dump_) { DLOG(INFO) << "Dumping output into file " << dump_filename_; @@ -72,7 +77,26 @@ void IbyteToComplex::connect(gr::top_block_sptr top_block) { if (dump_) { - top_block->connect(gr_interleaved_char_to_complex_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->connect(gr_interleaved_char_to_complex_, 0, conjugate_cc_, 0); + top_block->connect(conjugate_cc_, 0, file_sink_, 0); + } + else + { + top_block->connect(gr_interleaved_char_to_complex_, 0, file_sink_, 0); + } + } + else + { + if(inverted_spectrum) + { + top_block->connect(gr_interleaved_char_to_complex_, 0, conjugate_cc_, 0); + } + else + { + DLOG(INFO) << "Nothing to connect internally"; + } } } @@ -81,22 +105,40 @@ void IbyteToComplex::disconnect(gr::top_block_sptr top_block) { if (dump_) { - top_block->disconnect(gr_interleaved_char_to_complex_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->disconnect(gr_interleaved_char_to_complex_, 0, conjugate_cc_, 0); + top_block->disconnect(conjugate_cc_, 0, file_sink_, 0); + } + else + { + top_block->disconnect(gr_interleaved_char_to_complex_, 0, file_sink_, 0); + } + } + else + { + if(inverted_spectrum) + { + top_block->disconnect(gr_interleaved_char_to_complex_, 0, conjugate_cc_, 0); + } } } - gr::basic_block_sptr IbyteToComplex::get_left_block() { return gr_interleaved_char_to_complex_; } - gr::basic_block_sptr IbyteToComplex::get_right_block() { - return gr_interleaved_char_to_complex_; + if(inverted_spectrum) + { + return conjugate_cc_; + } + else + { + return gr_interleaved_char_to_complex_; + } } - - diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.h b/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.h index 50b38f37e..3c379d7ba 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.h +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_complex.h @@ -34,8 +34,9 @@ #include #include #include -#include "gnss_synchro.h" +#include "conjugate_cc.h" #include "gnss_block_interface.h" +#include "gnss_synchro.h" class ConfigurationInterface; @@ -85,6 +86,8 @@ private: unsigned int in_streams_; unsigned int out_streams_; gr::blocks::file_sink::sptr file_sink_; + conjugate_cc_sptr conjugate_cc_; + bool inverted_spectrum; }; #endif diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.cc b/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.cc index 206f824cc..59ac82042 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.cc +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.cc @@ -51,6 +51,7 @@ IbyteToCshort::IbyteToCshort(ConfigurationInterface* configuration, std::string dump_ = config_->property(role_ + ".dump", false); dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename); + inverted_spectrum = configuration->property(role + ".inverted_spectrum", false); size_t item_size = sizeof(lv_16sc_t); @@ -63,6 +64,10 @@ IbyteToCshort::IbyteToCshort(ConfigurationInterface* configuration, std::string DLOG(INFO) << "Dumping output into file " << dump_filename_; file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str()); } + if(inverted_spectrum) + { + conjugate_sc_ = make_conjugate_sc(); + } } @@ -74,7 +79,22 @@ void IbyteToCshort::connect(gr::top_block_sptr top_block) { if (dump_) { - top_block->connect(interleaved_byte_to_complex_short_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->connect(interleaved_byte_to_complex_short_, 0, conjugate_sc_, 0); + top_block->connect(conjugate_sc_, 0, file_sink_, 0); + } + else + { + top_block->connect(interleaved_byte_to_complex_short_, 0, file_sink_, 0); + } + } + else + { + if(inverted_spectrum) + { + top_block->connect(interleaved_byte_to_complex_short_, 0, conjugate_sc_, 0); + } } } @@ -83,22 +103,40 @@ void IbyteToCshort::disconnect(gr::top_block_sptr top_block) { if (dump_) { - top_block->disconnect(interleaved_byte_to_complex_short_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->disconnect(interleaved_byte_to_complex_short_, 0, conjugate_sc_, 0); + top_block->disconnect(conjugate_sc_, 0, file_sink_, 0); + } + else + { + top_block->disconnect(interleaved_byte_to_complex_short_, 0, file_sink_, 0); + } + } + else + { + if(inverted_spectrum) + { + top_block->disconnect(interleaved_byte_to_complex_short_, 0, conjugate_sc_, 0); + } } } - gr::basic_block_sptr IbyteToCshort::get_left_block() { return interleaved_byte_to_complex_short_; } - gr::basic_block_sptr IbyteToCshort::get_right_block() { - return interleaved_byte_to_complex_short_; + if(inverted_spectrum) + { + return conjugate_sc_; + } + else + { + return interleaved_byte_to_complex_short_; + } } - - diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.h b/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.h index 71829d6a3..2de7089ac 100644 --- a/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.h +++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_cshort.h @@ -34,6 +34,7 @@ #include #include #include "gnss_block_interface.h" +#include "conjugate_sc.h" #include "interleaved_byte_to_complex_short.h" @@ -85,6 +86,8 @@ private: unsigned int in_streams_; unsigned int out_streams_; gr::blocks::file_sink::sptr file_sink_; + conjugate_sc_sptr conjugate_sc_; + bool inverted_spectrum; }; #endif diff --git a/src/algorithms/data_type_adapter/adapters/ishort_to_complex.cc b/src/algorithms/data_type_adapter/adapters/ishort_to_complex.cc index e87dc1f59..cb9d3c6df 100644 --- a/src/algorithms/data_type_adapter/adapters/ishort_to_complex.cc +++ b/src/algorithms/data_type_adapter/adapters/ishort_to_complex.cc @@ -49,6 +49,7 @@ IshortToComplex::IshortToComplex(ConfigurationInterface* configuration, std::str dump_ = config_->property(role_ + ".dump", false); dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename); + inverted_spectrum = configuration->property(role + ".inverted_spectrum", false); size_t item_size = sizeof(gr_complex); @@ -56,6 +57,10 @@ IshortToComplex::IshortToComplex(ConfigurationInterface* configuration, std::str DLOG(INFO) << "data_type_adapter_(" << gr_interleaved_short_to_complex_->unique_id() << ")"; + if (inverted_spectrum) + { + conjugate_cc_ = make_conjugate_cc(); + } if (dump_) { DLOG(INFO) << "Dumping output into file " << dump_filename_; @@ -72,11 +77,26 @@ void IshortToComplex::connect(gr::top_block_sptr top_block) { if (dump_) { - top_block->connect(gr_interleaved_short_to_complex_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->connect(gr_interleaved_short_to_complex_, 0, conjugate_cc_, 0); + top_block->connect(conjugate_cc_, 0, file_sink_, 0); + } + else + { + top_block->connect(gr_interleaved_short_to_complex_, 0, file_sink_, 0); + } } else { - DLOG(INFO) << "Nothing to connect internally"; + if(inverted_spectrum) + { + top_block->connect(gr_interleaved_short_to_complex_, 0, conjugate_cc_, 0); + } + else + { + DLOG(INFO) << "Nothing to connect internally"; + } } } @@ -85,22 +105,40 @@ void IshortToComplex::disconnect(gr::top_block_sptr top_block) { if (dump_) { - top_block->disconnect(gr_interleaved_short_to_complex_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->disconnect(gr_interleaved_short_to_complex_, 0, conjugate_cc_, 0); + top_block->disconnect(conjugate_cc_, 0, file_sink_, 0); + } + else + { + top_block->disconnect(gr_interleaved_short_to_complex_, 0, file_sink_, 0); + } + } + else + { + if(inverted_spectrum) + { + top_block->disconnect(gr_interleaved_short_to_complex_, 0, conjugate_cc_, 0); + } } } - gr::basic_block_sptr IshortToComplex::get_left_block() { return gr_interleaved_short_to_complex_; } - gr::basic_block_sptr IshortToComplex::get_right_block() { - return gr_interleaved_short_to_complex_; + if(inverted_spectrum) + { + return conjugate_cc_; + } + else + { + return gr_interleaved_short_to_complex_; + } } - - diff --git a/src/algorithms/data_type_adapter/adapters/ishort_to_complex.h b/src/algorithms/data_type_adapter/adapters/ishort_to_complex.h index 79a2d7162..57cf7283e 100644 --- a/src/algorithms/data_type_adapter/adapters/ishort_to_complex.h +++ b/src/algorithms/data_type_adapter/adapters/ishort_to_complex.h @@ -34,6 +34,7 @@ #include #include #include +#include "conjugate_cc.h" #include "gnss_block_interface.h" @@ -84,6 +85,8 @@ private: unsigned int in_streams_; unsigned int out_streams_; gr::blocks::file_sink::sptr file_sink_; + conjugate_cc_sptr conjugate_cc_; + bool inverted_spectrum; }; #endif diff --git a/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.cc b/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.cc index 503341d08..96a87abe2 100644 --- a/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.cc +++ b/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.cc @@ -51,6 +51,7 @@ IshortToCshort::IshortToCshort(ConfigurationInterface* configuration, std::strin dump_ = config_->property(role_ + ".dump", false); dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename); + inverted_spectrum = configuration->property(role + ".inverted_spectrum", false); size_t item_size = sizeof(lv_16sc_t); @@ -63,6 +64,10 @@ IshortToCshort::IshortToCshort(ConfigurationInterface* configuration, std::strin DLOG(INFO) << "Dumping output into file " << dump_filename_; file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str()); } + if(inverted_spectrum) + { + conjugate_sc_ = make_conjugate_sc(); + } } @@ -74,11 +79,26 @@ void IshortToCshort::connect(gr::top_block_sptr top_block) { if (dump_) { - top_block->connect(interleaved_short_to_complex_short_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->connect(interleaved_short_to_complex_short_, 0, conjugate_sc_, 0); + top_block->connect(conjugate_sc_, 0, file_sink_, 0); + } + else + { + top_block->connect(interleaved_short_to_complex_short_, 0, file_sink_, 0); + } } else { - DLOG(INFO) << "Nothing to connect internally"; + if(inverted_spectrum) + { + top_block->connect(interleaved_short_to_complex_short_, 0, conjugate_sc_, 0); + } + else + { + DLOG(INFO) << "Nothing to connect internally"; + } } } @@ -87,22 +107,40 @@ void IshortToCshort::disconnect(gr::top_block_sptr top_block) { if (dump_) { - top_block->disconnect(interleaved_short_to_complex_short_, 0, file_sink_, 0); + if(inverted_spectrum) + { + top_block->disconnect(interleaved_short_to_complex_short_, 0, conjugate_sc_, 0); + top_block->disconnect(conjugate_sc_, 0, file_sink_, 0); + } + else + { + top_block->disconnect(interleaved_short_to_complex_short_, 0, file_sink_, 0); + } + } + else + { + if(inverted_spectrum) + { + top_block->disconnect(interleaved_short_to_complex_short_, 0, conjugate_sc_, 0); + } } } - gr::basic_block_sptr IshortToCshort::get_left_block() { return interleaved_short_to_complex_short_; } - gr::basic_block_sptr IshortToCshort::get_right_block() { - return interleaved_short_to_complex_short_; + if(inverted_spectrum) + { + return conjugate_sc_; + } + else + { + return interleaved_short_to_complex_short_; + } } - - diff --git a/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.h b/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.h index cb8080e40..685373a6a 100644 --- a/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.h +++ b/src/algorithms/data_type_adapter/adapters/ishort_to_cshort.h @@ -33,6 +33,7 @@ #include #include +#include "conjugate_sc.h" #include "gnss_block_interface.h" #include "interleaved_short_to_complex_short.h" @@ -85,6 +86,8 @@ private: unsigned int in_streams_; unsigned int out_streams_; gr::blocks::file_sink::sptr file_sink_; + conjugate_sc_sptr conjugate_sc_; + bool inverted_spectrum; }; #endif diff --git a/src/algorithms/libs/CMakeLists.txt b/src/algorithms/libs/CMakeLists.txt index e7d8b60bd..cc085ae75 100644 --- a/src/algorithms/libs/CMakeLists.txt +++ b/src/algorithms/libs/CMakeLists.txt @@ -32,6 +32,9 @@ set(GNSS_SPLIBS_SOURCES cshort_to_float_x2.cc short_x2_to_cshort.cc complex_float_to_complex_byte.cc + conjugate_cc.cc + conjugate_sc.cc + conjugate_ic.cc ) diff --git a/src/algorithms/libs/conjugate_cc.cc b/src/algorithms/libs/conjugate_cc.cc new file mode 100644 index 000000000..60063473a --- /dev/null +++ b/src/algorithms/libs/conjugate_cc.cc @@ -0,0 +1,29 @@ +#include "conjugate_cc.h" +#include +#include + + +conjugate_cc_sptr make_conjugate_cc() +{ + return conjugate_cc_sptr(new conjugate_cc()); +} + + +conjugate_cc::conjugate_cc() : gr::sync_block("conjugate_cc", + gr::io_signature::make (1, 1, sizeof(gr_complex)), + gr::io_signature::make (1, 1, sizeof(gr_complex))) +{ + const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex); + set_alignment(std::max(1, alignment_multiple)); +} + + +int conjugate_cc::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const gr_complex *in = reinterpret_cast(input_items[0]); + gr_complex *out = reinterpret_cast(output_items[0]); + volk_32fc_conjugate_32fc(out, in, noutput_items); + return noutput_items; +} diff --git a/src/algorithms/libs/conjugate_cc.h b/src/algorithms/libs/conjugate_cc.h new file mode 100644 index 000000000..556f79c6d --- /dev/null +++ b/src/algorithms/libs/conjugate_cc.h @@ -0,0 +1,59 @@ +/*! + * \file conjugate_cc.h + * \brief Conjugate + * \author Carles Fernandez Prades, cfernandez(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_CONJUGATE_CC_H_ +#define GNSS_SDR_CONJUGATE_CC_H_ + +#include +#include + +class conjugate_cc; + +typedef boost::shared_ptr conjugate_cc_sptr; + +conjugate_cc_sptr make_conjugate_cc(); + +/*! + * \brief This class adapts a std::complex stream + * into two 32-bits (float) streams + */ +class conjugate_cc : public gr::sync_block +{ +private: + friend conjugate_cc_sptr make_conjugate_cc(); +public: + conjugate_cc(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif diff --git a/src/algorithms/libs/conjugate_ic.cc b/src/algorithms/libs/conjugate_ic.cc new file mode 100644 index 000000000..b1f85e39f --- /dev/null +++ b/src/algorithms/libs/conjugate_ic.cc @@ -0,0 +1,29 @@ +#include "conjugate_ic.h" +#include +#include + + +conjugate_ic_sptr make_conjugate_ic() +{ + return conjugate_ic_sptr(new conjugate_ic()); +} + + +conjugate_ic::conjugate_ic() : gr::sync_block("conjugate_ic", + gr::io_signature::make (1, 1, sizeof(lv_8sc_t)), + gr::io_signature::make (1, 1, sizeof(lv_8sc_t))) +{ + const int alignment_multiple = volk_gnsssdr_get_alignment() / sizeof(lv_8sc_t); + set_alignment(std::max(1, alignment_multiple)); +} + + +int conjugate_ic::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const lv_8sc_t *in = reinterpret_cast(input_items[0]); + lv_8sc_t *out = reinterpret_cast(output_items[0]); + volk_gnsssdr_8ic_conjugate_8ic(out, in, noutput_items); + return noutput_items; +} diff --git a/src/algorithms/libs/conjugate_ic.h b/src/algorithms/libs/conjugate_ic.h new file mode 100644 index 000000000..38eb21a35 --- /dev/null +++ b/src/algorithms/libs/conjugate_ic.h @@ -0,0 +1,59 @@ +/*! + * \file conjugate_ic.h + * \brief Adapts a std::complex stream into two float streams + * \author Carles Fernandez Prades, cfernandez(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_CONJUGATE_IC_H_ +#define GNSS_SDR_CONJUGATE_IC_H_ + +#include +#include + +class conjugate_ic; + +typedef boost::shared_ptr conjugate_ic_sptr; + +conjugate_ic_sptr make_conjugate_ic(); + +/*! + * \brief This class adapts a std::complex stream + * into two 32-bits (float) streams + */ +class conjugate_ic : public gr::sync_block +{ +private: + friend conjugate_ic_sptr make_conjugate_ic(); +public: + conjugate_ic(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif diff --git a/src/algorithms/libs/conjugate_sc.cc b/src/algorithms/libs/conjugate_sc.cc new file mode 100644 index 000000000..ac22d7723 --- /dev/null +++ b/src/algorithms/libs/conjugate_sc.cc @@ -0,0 +1,29 @@ +#include "conjugate_sc.h" +#include +#include + + +conjugate_sc_sptr make_conjugate_sc() +{ + return conjugate_sc_sptr(new conjugate_sc()); +} + + +conjugate_sc::conjugate_sc() : gr::sync_block("conjugate_sc", + gr::io_signature::make (1, 1, sizeof(lv_16sc_t)), + gr::io_signature::make (1, 1, sizeof(lv_16sc_t))) +{ + const int alignment_multiple = volk_gnsssdr_get_alignment() / sizeof(lv_16sc_t); + set_alignment(std::max(1, alignment_multiple)); +} + + +int conjugate_sc::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const lv_16sc_t *in = reinterpret_cast(input_items[0]); + lv_16sc_t *out = reinterpret_cast(output_items[0]); + volk_gnsssdr_16ic_conjugate_16ic(out, in, noutput_items); + return noutput_items; +} diff --git a/src/algorithms/libs/conjugate_sc.h b/src/algorithms/libs/conjugate_sc.h new file mode 100644 index 000000000..b26a66c79 --- /dev/null +++ b/src/algorithms/libs/conjugate_sc.h @@ -0,0 +1,59 @@ +/*! + * \file conjugate_sc.h + * \brief Adapts a std::complex stream into two float streams + * \author Carles Fernandez Prades, cfernandez(at)cttc.es + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_CONJUGATE_SC_H_ +#define GNSS_SDR_CONJUGATE_SC_H_ + +#include +#include + +class conjugate_sc; + +typedef boost::shared_ptr conjugate_sc_sptr; + +conjugate_sc_sptr make_conjugate_sc(); + +/*! + * \brief This class adapts a std::complex stream + * into two 32-bits (float) streams + */ +class conjugate_sc : public gr::sync_block +{ +private: + friend conjugate_sc_sptr make_conjugate_sc(); +public: + conjugate_sc(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif diff --git a/src/algorithms/libs/pass_through.cc b/src/algorithms/libs/pass_through.cc index 94394866e..87f2b1be6 100644 --- a/src/algorithms/libs/pass_through.cc +++ b/src/algorithms/libs/pass_through.cc @@ -57,7 +57,7 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro } item_type_ = configuration->property(role + ".item_type", input_type); - vector_size_ = configuration->property(role + ".vector_size", 1); + inverted_spectrum = configuration->property(role + ".inverted_spectrum", false); if(item_type_.compare("float") == 0) { @@ -66,6 +66,10 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro else if(item_type_.compare("gr_complex") == 0) { item_size_ = sizeof(gr_complex); + if(inverted_spectrum) + { + conjugate_cc_ = make_conjugate_cc(); + } } else if(item_type_.compare("short") == 0) { @@ -78,6 +82,10 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro else if(item_type_.compare("cshort") == 0) { item_size_ = sizeof(lv_16sc_t); + if(inverted_spectrum) + { + conjugate_sc_ = make_conjugate_sc(); + } } else if(item_type_.compare("byte") == 0) { @@ -90,12 +98,17 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string ro else if(item_type_.compare("cbyte") == 0) { item_size_ = sizeof(lv_8sc_t); + if(inverted_spectrum) + { + conjugate_ic_ = make_conjugate_ic(); + } } else { LOG(WARNING) << item_type_ << " unrecognized item type. Using float"; item_size_ = sizeof(float); } + kludge_copy_ = gr::blocks::copy::make(item_size_); DLOG(INFO) << "kludge_copy(" << kludge_copy_->unique_id() << ")"; } @@ -125,6 +138,27 @@ void Pass_Through::disconnect(gr::top_block_sptr top_block) gr::basic_block_sptr Pass_Through::get_left_block() { + if(inverted_spectrum) + { + if(item_type_.compare("gr_complex") == 0) + { + return conjugate_cc_; + } + else if(item_type_.compare("cshort") == 0) + { + return conjugate_sc_; + } + else if(item_type_.compare("cbyte") == 0) + { + return conjugate_ic_; + } + else + { + LOG(WARNING) << "Setting inverted_spectrum to true with item_type " + << item_type_ << " is not defined and has no effect."; + } + } + return kludge_copy_; } @@ -132,5 +166,26 @@ gr::basic_block_sptr Pass_Through::get_left_block() gr::basic_block_sptr Pass_Through::get_right_block() { + if(inverted_spectrum) + { + if(item_type_.compare("gr_complex") == 0) + { + return conjugate_cc_; + } + else if(item_type_.compare("cshort") == 0) + { + return conjugate_sc_; + } + else if(item_type_.compare("cbyte") == 0) + { + return conjugate_ic_; + } + else + { + DLOG(WARNING) << "Setting inverted_spectrum to true with item_type " + << item_type_ << " is not defined and has no effect."; + } + } + return kludge_copy_; } diff --git a/src/algorithms/libs/pass_through.h b/src/algorithms/libs/pass_through.h index 02cc1647f..39d4c5468 100644 --- a/src/algorithms/libs/pass_through.h +++ b/src/algorithms/libs/pass_through.h @@ -37,6 +37,10 @@ #include #include #include "gnss_block_interface.h" +#include "conjugate_cc.h" +#include "conjugate_sc.h" +#include "conjugate_ic.h" + class ConfigurationInterface; @@ -69,11 +73,6 @@ public: return item_type_; } - inline size_t vector_size() const - { - return vector_size_; - } - inline size_t item_size() override { return item_size_; @@ -86,13 +85,16 @@ public: private: std::string item_type_; - size_t vector_size_; std::string role_; unsigned int in_streams_; unsigned int out_streams_; //gr_kludge_copy_sptr kludge_copy_; gr::blocks::copy::sptr kludge_copy_; size_t item_size_; + conjugate_cc_sptr conjugate_cc_; + conjugate_sc_sptr conjugate_sc_; + conjugate_ic_sptr conjugate_ic_; + bool inverted_spectrum; }; #endif /*GNSS_SDR_PASS_THROUGH_H_*/ diff --git a/src/tests/unit-tests/signal-processing-blocks/adapter/pass_through_test.cc b/src/tests/unit-tests/signal-processing-blocks/adapter/pass_through_test.cc index 656a0d688..070196fe6 100644 --- a/src/tests/unit-tests/signal-processing-blocks/adapter/pass_through_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/adapter/pass_through_test.cc @@ -41,9 +41,6 @@ TEST(PassThroughTest, Instantiate) { std::shared_ptr config = std::make_shared(); config->set_property("Test.item_type", "gr_complex"); - config->set_property("Test.vector_size", "2"); std::shared_ptr signal_conditioner = std::make_shared(config.get(), "Test", 1, 1); EXPECT_STREQ("gr_complex", signal_conditioner->item_type().c_str()); - unsigned int expected2 = 2; - EXPECT_EQ(expected2, signal_conditioner->vector_size()); } From 929125cce521187b33c232fffb6bd2caf2df6fdc Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 17 Nov 2017 14:47:50 +0100 Subject: [PATCH 48/60] Add matio library and add test case for it --- CMakeLists.txt | 48 +++++++ cmake/Modules/FindMATIO.cmake | 100 +++++++++++++ src/tests/CMakeLists.txt | 2 + src/tests/test_main.cc | 1 + src/tests/unit-tests/arithmetic/matio_test.cc | 134 ++++++++++++++++++ 5 files changed, 285 insertions(+) create mode 100644 cmake/Modules/FindMATIO.cmake create mode 100644 src/tests/unit-tests/arithmetic/matio_test.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 04377cc46..1948cf75a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1442,6 +1442,54 @@ endif(ENABLE_GPROF) +######################################################################## +# Matio (OPTIONAL) - https://github.com/tbeu/matio +######################################################################## +find_package(MATIO) +if(NOT MATIO_FOUND) + find_package(ZLIB) + get_filename_component(ZLIB_BASE_DIR ${ZLIB_INCLUDE_DIRS} DIRECTORY) + find_package(HDF5) + list(GET ${HDF5_INCLUDE_DIRS} 0 HDF5_INCLUDE_FIRST_DIR) + get_filename_component(HDF5_BASE_DIR ${HDF5_INCLUDE_FIRST_DIR} DIRECTORY) + if(OS_IS_MACOSX) + if(EXISTS /opt/local/include/hdf5.h) + set(HDF5_BASE_DIR /opt/local) + endif(EXISTS /opt/local/include/hdf5.h) + if(EXISTS /usr/local/include/hdf5.h) + set(HDF5_BASE_DIR /usr/local) + endif(EXISTS /usr/local/include/hdf5.h) + endif(OS_IS_MACOSX) + if(CMAKE_VERSION VERSION_LESS 3.2) + ExternalProject_Add( + matio + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/matio + GIT_REPOSITORY https://github.com/tbeu/matio + GIT_TAG master + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio + UPDATE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio/autogen.sh + CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio/configure --with-hdf5=${HDF5_BASE_DIR} --with-zlib=${ZLIB_BASE_DIR} --with-default-file-ver=7.3 --enable-mat73=yes --prefix= + BUILD_COMMAND "${CMAKE_MAKE_PROGRAM}" + ) + else(CMAKE_VERSION VERSION_LESS 3.2) + ExternalProject_Add( + matio + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/matio + GIT_REPOSITORY https://github.com/tbeu/matio + GIT_TAG master + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio + UPDATE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio/autogen.sh + CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio/configure --with-hdf5=${HDF5_BASE_DIR} --with-zlib=${ZLIB_BASE_DIR} --with-default-file-ver=7.3 --enable-mat73=yes --prefix= + BUILD_COMMAND "${CMAKE_MAKE_PROGRAM}" + BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/matio/lib/${CMAKE_FIND_LIBRARY_PREFIXES}matio${CMAKE_STATIC_LIBRARY_SUFFIX} + ) + endif(CMAKE_VERSION VERSION_LESS 3.2) + set(MATIO_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/matio/lib/${CMAKE_FIND_LIBRARY_PREFIXES}matio${CMAKE_STATIC_LIBRARY_SUFFIX} ${HDF5_LIBRARIES} ${ZLIB_LIBRARIES} ) + set(MATIO_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/matio/include ) +endif(NOT MATIO_FOUND) + + + ######################################################################## # Set compiler flags ######################################################################## diff --git a/cmake/Modules/FindMATIO.cmake b/cmake/Modules/FindMATIO.cmake new file mode 100644 index 000000000..e1cb458d8 --- /dev/null +++ b/cmake/Modules/FindMATIO.cmake @@ -0,0 +1,100 @@ +# FindMATIO +# +# Try to find MATIO library +# +# Once done this will define: +# +# MATIO_FOUND - True if MATIO found. +# MATIO_LIBRARIES - MATIO libraries. +# MATIO_INCLUDE_DIRS - where to find matio.h, etc.. +# MATIO_VERSION_STRING - version number as a string (e.g.: "1.3.4") +# +#============================================================================= +# Copyright 2015 Avtech Scientific +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the names of Kitware, Inc., the Insight Software Consortium, +# nor the names of their contributors may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#============================================================================= +# + +# Look for the header file. +find_path(MATIO_INCLUDE_DIR NAMES matio.h DOC "The MATIO include directory") + +# Look for the library. +find_library(MATIO_LIBRARY NAMES matio DOC "The MATIO library") + +if(MATIO_INCLUDE_DIR) + # --------------------------------------------------- + # Extract version information from MATIO + # --------------------------------------------------- + + # If the file is missing, set all values to 0 + set(MATIO_MAJOR_VERSION 0) + set(MATIO_MINOR_VERSION 0) + set(MATIO_RELEASE_LEVEL 0) + + # new versions of MATIO have `matio_pubconf.h` + if(EXISTS ${MATIO_INCLUDE_DIR}/matio_pubconf.h) + set(MATIO_CONFIG_FILE "matio_pubconf.h") + else() + set(MATIO_CONFIG_FILE "matioConfig.h") + endif() + + if(MATIO_CONFIG_FILE) + + # Read and parse MATIO config header file for version number + file(STRINGS "${MATIO_INCLUDE_DIR}/${MATIO_CONFIG_FILE}" _matio_HEADER_CONTENTS REGEX "#define MATIO_((MAJOR|MINOR)_VERSION)|(RELEASE_LEVEL) ") + + foreach(line ${_matio_HEADER_CONTENTS}) + if(line MATCHES "#define ([A-Z_]+) ([0-9]+)") + set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}") + endif() + endforeach() + + unset(_matio_HEADER_CONTENTS) + endif() + + set(MATIO_VERSION_STRING "${MATIO_MAJOR_VERSION}.${MATIO_MINOR_VERSION}.${MATIO_RELEASE_LEVEL}") +endif () + +#================== + +mark_as_advanced(MATIO_INCLUDE_DIR MATIO_LIBRARY) + +# handle the QUIETLY and REQUIRED arguments and set MATIO_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(MATIO REQUIRED_VARS MATIO_LIBRARY MATIO_INCLUDE_DIR VERSION_VAR MATIO_VERSION_STRING) + +if(MATIO_FOUND) + set(MATIO_LIBRARIES ${MATIO_LIBRARY}) + set(MATIO_INCLUDE_DIRS ${MATIO_INCLUDE_DIR}) +else(MATIO_FOUND) + set(MATIO_LIBRARIES) + set(MATIO_INCLUDE_DIRS) +endif(MATIO_FOUND) \ No newline at end of file diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 2bafedc98..53d04cc9d 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -320,6 +320,7 @@ include_directories( ${VOLK_GNSSSDR_INCLUDE_DIRS} ${GNSS_SDR_TEST_OPTIONAL_HEADERS} ${GNSS_SDR_TEST_OPTIONAL_HEADERS} + ${MATIO_INCLUDE_DIRS} ) @@ -354,6 +355,7 @@ if(ENABLE_UNIT_TESTING) signal_processing_testing_lib ${VOLK_GNSSSDR_LIBRARIES} ${GNSS_SDR_TEST_OPTIONAL_LIBS} + ${MATIO_LIBRARIES} ) if(NOT ${GTEST_DIR_LOCAL}) add_dependencies(run_tests gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) diff --git a/src/tests/test_main.cc b/src/tests/test_main.cc index b84fa312a..efb2ee422 100644 --- a/src/tests/test_main.cc +++ b/src/tests/test_main.cc @@ -70,6 +70,7 @@ DECLARE_string(log_dir); #include "unit-tests/arithmetic/code_generation_test.cc" #include "unit-tests/arithmetic/fft_length_test.cc" #include "unit-tests/arithmetic/fft_speed_test.cc" +#include "unit-tests/arithmetic/matio_test.cc" #include "unit-tests/control-plane/file_configuration_test.cc" #include "unit-tests/control-plane/in_memory_configuration_test.cc" diff --git a/src/tests/unit-tests/arithmetic/matio_test.cc b/src/tests/unit-tests/arithmetic/matio_test.cc new file mode 100644 index 000000000..c3dd32af7 --- /dev/null +++ b/src/tests/unit-tests/arithmetic/matio_test.cc @@ -0,0 +1,134 @@ +/*! + * \file matio_test.cc + * \brief This file implements tests for the matio library + * in long arrays. + * \author Carles Fernandez-Prades, 2017. cfernandez(at)cttc.es + * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include +#include +#include + +TEST(MatioTest, WriteAndReadDoubles) +{ + // Write a .mat file + mat_t *matfp; + matvar_t *matvar; + std::string filename = "./test.mat"; + matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); + ASSERT_FALSE(reinterpret_cast(matfp) == NULL) << "Error creating .mat file"; + + double x[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + size_t dims[2] = {10, 1}; + matvar = Mat_VarCreate("x", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, x, 0); + ASSERT_FALSE(reinterpret_cast(matvar) == NULL) << "Error creating variable for ’x’"; + + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + Mat_Close(matfp); + + // Read a .mat file + mat_t *matfp_read; + matvar_t *matvar_read; + + matfp_read = Mat_Open(filename.c_str(), MAT_ACC_RDONLY); + ASSERT_FALSE(reinterpret_cast(matfp_read) == NULL) << "Error reading .mat file"; + + matvar_read = Mat_VarReadInfo(matfp_read, "x"); + ASSERT_FALSE(reinterpret_cast(matvar_read) == NULL) << "Error reading variable in .mat file"; + + matvar_read = Mat_VarRead(matfp_read, "x"); + double *x_read = reinterpret_cast(matvar_read->data); + Mat_Close(matfp_read); + for(int i = 0; i < 10; i++) + { + EXPECT_DOUBLE_EQ(x[i], x_read[i]); + } + ASSERT_EQ(remove(filename.c_str()), 0); +} + + +TEST(MatioTest, WriteAndReadGrComplex) +{ + // Write a .mat file + mat_t *matfp; + matvar_t *matvar; + std::string filename = "./test2.mat"; + matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); + ASSERT_FALSE(reinterpret_cast(matfp) == NULL) << "Error creating .mat file"; + + std::vector x_v = { {1, 10}, {2, 9}, {3, 8}, {4, 7}, {5, 6}, {6, -5}, {7, -4}, {8, 3}, {9, 2}, {10, 1}}; + const int size = x_v.size(); + float x_real[size]; + float x_imag[size]; + for (int i = 0; i < x_v.size(); i++) + { + x_real[i] = x_v.at(i).real(); + x_imag[i] = x_v.at(i).imag(); + } + + struct mat_complex_split_t x = {x_real, x_imag}; + size_t dims[2] = {static_cast(size), 1}; + matvar = Mat_VarCreate("x", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, &x, MAT_F_COMPLEX); + ASSERT_FALSE(reinterpret_cast(matvar) == NULL) << "Error creating variable for ’x’"; + + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + Mat_Close(matfp); + + // Read a .mat file + mat_t *matfp_read; + matvar_t *matvar_read; + + matfp_read = Mat_Open(filename.c_str(), MAT_ACC_RDONLY); + ASSERT_FALSE(reinterpret_cast(matfp_read) == NULL) << "Error reading .mat file"; + + matvar_read = Mat_VarReadInfo(matfp_read, "x"); + ASSERT_FALSE(reinterpret_cast(matvar_read) == NULL) << "Error reading variable in .mat file"; + + matvar_read = Mat_VarRead(matfp_read, "x"); + mat_complex_split_t *x_read_st = reinterpret_cast(matvar_read->data); + float * x_read_real = reinterpret_cast(x_read_st->Re); + float * x_read_imag = reinterpret_cast(x_read_st->Im); + std::vector x_v_read; + for(int i = 0; i < size; i++) + { + x_v_read.push_back(gr_complex(x_read_real[i], x_read_imag[i])); + } + + Mat_Close(matfp_read); + + for(int i = 0; i < size; i++) + { + EXPECT_FLOAT_EQ(x_v[i].real(), x_v_read[i].real()); + EXPECT_FLOAT_EQ(x_v[i].imag(), x_v_read[i].imag()); + } + ASSERT_EQ(remove(filename.c_str()), 0); +} From 00e37a83a663efa8857d5969a756759e5d46559b Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 17 Nov 2017 21:20:56 +0100 Subject: [PATCH 49/60] Fix building in Linux --- CMakeLists.txt | 82 ++++++++++--------- src/tests/unit-tests/arithmetic/matio_test.cc | 10 ++- 2 files changed, 50 insertions(+), 42 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1948cf75a..1fc49400b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -326,6 +326,7 @@ set(GNSSSDR_ARMADILLO_LOCAL_VERSION "unstable") set(GNSSSDR_GTEST_LOCAL_VERSION "1.8.0") set(GNSSSDR_GNSS_SIM_LOCAL_VERSION "master") set(GNSSSDR_GPSTK_LOCAL_VERSION "2.10") +set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.11") @@ -1448,44 +1449,49 @@ endif(ENABLE_GPROF) find_package(MATIO) if(NOT MATIO_FOUND) find_package(ZLIB) - get_filename_component(ZLIB_BASE_DIR ${ZLIB_INCLUDE_DIRS} DIRECTORY) - find_package(HDF5) - list(GET ${HDF5_INCLUDE_DIRS} 0 HDF5_INCLUDE_FIRST_DIR) - get_filename_component(HDF5_BASE_DIR ${HDF5_INCLUDE_FIRST_DIR} DIRECTORY) - if(OS_IS_MACOSX) - if(EXISTS /opt/local/include/hdf5.h) - set(HDF5_BASE_DIR /opt/local) - endif(EXISTS /opt/local/include/hdf5.h) - if(EXISTS /usr/local/include/hdf5.h) - set(HDF5_BASE_DIR /usr/local) - endif(EXISTS /usr/local/include/hdf5.h) - endif(OS_IS_MACOSX) - if(CMAKE_VERSION VERSION_LESS 3.2) - ExternalProject_Add( - matio - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/matio - GIT_REPOSITORY https://github.com/tbeu/matio - GIT_TAG master - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio - UPDATE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio/autogen.sh - CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio/configure --with-hdf5=${HDF5_BASE_DIR} --with-zlib=${ZLIB_BASE_DIR} --with-default-file-ver=7.3 --enable-mat73=yes --prefix= - BUILD_COMMAND "${CMAKE_MAKE_PROGRAM}" - ) - else(CMAKE_VERSION VERSION_LESS 3.2) - ExternalProject_Add( - matio - PREFIX ${CMAKE_CURRENT_BINARY_DIR}/matio - GIT_REPOSITORY https://github.com/tbeu/matio - GIT_TAG master - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio - UPDATE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio/autogen.sh - CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio/configure --with-hdf5=${HDF5_BASE_DIR} --with-zlib=${ZLIB_BASE_DIR} --with-default-file-ver=7.3 --enable-mat73=yes --prefix= - BUILD_COMMAND "${CMAKE_MAKE_PROGRAM}" - BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/matio/lib/${CMAKE_FIND_LIBRARY_PREFIXES}matio${CMAKE_STATIC_LIBRARY_SUFFIX} - ) - endif(CMAKE_VERSION VERSION_LESS 3.2) - set(MATIO_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/matio/lib/${CMAKE_FIND_LIBRARY_PREFIXES}matio${CMAKE_STATIC_LIBRARY_SUFFIX} ${HDF5_LIBRARIES} ${ZLIB_LIBRARIES} ) - set(MATIO_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/matio/include ) + if(ZLIB_FOUND) + get_filename_component(ZLIB_BASE_DIR ${ZLIB_INCLUDE_DIRS} DIRECTORY) + find_package(HDF5) + if(HDF5_FOUND) + list(GET HDF5_LIBRARIES 0 HDF5_FIRST_DIR) + get_filename_component(HDF5_BASE_DIR2 ${HDF5_FIRST_DIR} DIRECTORY) + get_filename_component(HDF5_BASE_DIR ${HDF5_BASE_DIR2} DIRECTORY) + if(OS_IS_MACOSX) + if(EXISTS /opt/local/include/hdf5.h) + set(HDF5_BASE_DIR /opt/local) + endif(EXISTS /opt/local/include/hdf5.h) + if(EXISTS /usr/local/include/hdf5.h) + set(HDF5_BASE_DIR /usr/local) + endif(EXISTS /usr/local/include/hdf5.h) + endif(OS_IS_MACOSX) + if(CMAKE_VERSION VERSION_LESS 3.2) + ExternalProject_Add( + matio-${GNSSSDR_MATIO_LOCAL_VERSION} + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/mati + GIT_REPOSITORY https://github.com/tbeu/matio + GIT_TAG v${GNSSSDR_MATIO_LOCAL_VERSION} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION} + UPDATE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION}/autogen.sh + CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION}/configure --with-hdf5=${HDF5_BASE_DIR} --with-zlib=${ZLIB_BASE_DIR} --with-default-file-ver=7.3 --enable-mat73=yes --prefix= + BUILD_COMMAND "${CMAKE_MAKE_PROGRAM}" + ) + else(CMAKE_VERSION VERSION_LESS 3.2) + ExternalProject_Add( + matio-${GNSSSDR_MATIO_LOCAL_VERSION} + PREFIX ${CMAKE_CURRENT_BINARY_DIR}/matio + GIT_REPOSITORY https://github.com/tbeu/matio + GIT_TAG v${GNSSSDR_MATIO_LOCAL_VERSION} + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION} + UPDATE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION}/autogen.sh + CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION}/configure --with-hdf5=${HDF5_BASE_DIR} --with-zlib=${ZLIB_BASE_DIR} --with-default-file-ver=7.3 --enable-mat73=yes --prefix= + BUILD_COMMAND "${CMAKE_MAKE_PROGRAM}" + BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/matio/lib/${CMAKE_FIND_LIBRARY_PREFIXES}matio${CMAKE_STATIC_LIBRARY_SUFFIX} + ) + endif(CMAKE_VERSION VERSION_LESS 3.2) + set(MATIO_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/matio/lib/${CMAKE_FIND_LIBRARY_PREFIXES}matio${CMAKE_STATIC_LIBRARY_SUFFIX} ${HDF5_LIBRARIES} ${ZLIB_LIBRARIES} ) + set(MATIO_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/matio/include ) + endif(HDF5_FOUND) + endif(ZLIB_FOUND) endif(NOT MATIO_FOUND) diff --git a/src/tests/unit-tests/arithmetic/matio_test.cc b/src/tests/unit-tests/arithmetic/matio_test.cc index c3dd32af7..8ef276bdc 100644 --- a/src/tests/unit-tests/arithmetic/matio_test.cc +++ b/src/tests/unit-tests/arithmetic/matio_test.cc @@ -87,10 +87,12 @@ TEST(MatioTest, WriteAndReadGrComplex) const int size = x_v.size(); float x_real[size]; float x_imag[size]; - for (int i = 0; i < x_v.size(); i++) + unsigned int i = 0; + for (std::vector::const_iterator it = x_v.cbegin(); it != x_v.cend(); it++) { - x_real[i] = x_v.at(i).real(); - x_imag[i] = x_v.at(i).imag(); + x_real[i] = it->real(); + x_imag[i] = it->imag(); + i++; } struct mat_complex_split_t x = {x_real, x_imag}; @@ -118,7 +120,7 @@ TEST(MatioTest, WriteAndReadGrComplex) float * x_read_real = reinterpret_cast(x_read_st->Re); float * x_read_imag = reinterpret_cast(x_read_st->Im); std::vector x_v_read; - for(int i = 0; i < size; i++) + for(unsigned int i = 0; i < size; i++) { x_v_read.push_back(gr_complex(x_read_real[i], x_read_imag[i])); } From d4aa35316d998268d8a6db0476a1b41e9165eadd Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 17 Nov 2017 21:54:02 +0100 Subject: [PATCH 50/60] Add matio --- CMakeLists.txt | 1 + README.md | 4 +++- src/tests/unit-tests/arithmetic/matio_test.cc | 6 ++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1fc49400b..fdf3954a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1490,6 +1490,7 @@ if(NOT MATIO_FOUND) endif(CMAKE_VERSION VERSION_LESS 3.2) set(MATIO_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/matio/lib/${CMAKE_FIND_LIBRARY_PREFIXES}matio${CMAKE_STATIC_LIBRARY_SUFFIX} ${HDF5_LIBRARIES} ${ZLIB_LIBRARIES} ) set(MATIO_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/matio/include ) + set(MATIO_LOCAL true) endif(HDF5_FOUND) endif(ZLIB_FOUND) endif(NOT MATIO_FOUND) diff --git a/README.md b/README.md index a72c79577..1b513a25e 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ $ sudo apt-get install build-essential cmake git libboost-dev libboost-date-time libboost-serialization-dev libboost-program-options-dev libboost-test-dev \ liblog4cpp5-dev libuhd-dev gnuradio-dev gr-osmosdr libblas-dev liblapack-dev \ libarmadillo-dev libgflags-dev libgoogle-glog-dev libgnutls-openssl-dev libgtest-dev \ - python-mako python-six + python-mako python-six libmatio-dev ~~~~~~ Alternatively, and starting from Ubuntu 16.04 LTS, you can install all the required dependencies by adding the line @@ -495,6 +495,7 @@ $ sudo port install gnutls $ sudo port install google-glog +gflags $ sudo port install py27-mako $ sudo port install py27-six +$ sudo port install matio ~~~~~~ You also might need to activate a Python installation. The list of installed versions can be retrieved with: @@ -533,6 +534,7 @@ $ brew install cmake hdf5 arpack superlu $ brew install armadillo $ brew install glog gflags gnutls $ brew install gnuradio +$ brew install libmatio $ pip install mako $ pip install six ~~~~~~ diff --git a/src/tests/unit-tests/arithmetic/matio_test.cc b/src/tests/unit-tests/arithmetic/matio_test.cc index 8ef276bdc..e49cf7b63 100644 --- a/src/tests/unit-tests/arithmetic/matio_test.cc +++ b/src/tests/unit-tests/arithmetic/matio_test.cc @@ -66,6 +66,7 @@ TEST(MatioTest, WriteAndReadDoubles) matvar_read = Mat_VarRead(matfp_read, "x"); double *x_read = reinterpret_cast(matvar_read->data); Mat_Close(matfp_read); + Mat_VarFree(matvar_read); for(int i = 0; i < 10; i++) { EXPECT_DOUBLE_EQ(x[i], x_read[i]); @@ -84,7 +85,7 @@ TEST(MatioTest, WriteAndReadGrComplex) ASSERT_FALSE(reinterpret_cast(matfp) == NULL) << "Error creating .mat file"; std::vector x_v = { {1, 10}, {2, 9}, {3, 8}, {4, 7}, {5, 6}, {6, -5}, {7, -4}, {8, 3}, {9, 2}, {10, 1}}; - const int size = x_v.size(); + const unsigned int size = x_v.size(); float x_real[size]; float x_imag[size]; unsigned int i = 0; @@ -126,8 +127,9 @@ TEST(MatioTest, WriteAndReadGrComplex) } Mat_Close(matfp_read); + Mat_VarFree(matvar_read); - for(int i = 0; i < size; i++) + for(unsigned int i = 0; i < size; i++) { EXPECT_FLOAT_EQ(x_v[i].real(), x_v_read[i].real()); EXPECT_FLOAT_EQ(x_v[i].imag(), x_v_read[i].imag()); From 8926821fa31698d15889dcb39ee83225bdc14159 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 17 Nov 2017 23:17:08 +0100 Subject: [PATCH 51/60] Fix building if hdf5 is not found --- src/tests/CMakeLists.txt | 4 ++++ src/tests/test_main.cc | 2 ++ src/tests/unit-tests/arithmetic/matio_test.cc | 22 ++++++++++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 53d04cc9d..30b20eadb 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -161,6 +161,10 @@ if(GNUPLOT_FOUND) add_definitions(-DGNUPLOT_EXECUTABLE="${GNUPLOT_EXECUTABLE}") endif(GNUPLOT_FOUND) +if(MATIO_FOUND OR MATIO_LOCAL) + add_definitions(-DMATIO_TEST=1) +endif(MATIO_FOUND OR MATIO_LOCAL) + ################################################################################ # Optional generator ################################################################################ diff --git a/src/tests/test_main.cc b/src/tests/test_main.cc index efb2ee422..ce8de7097 100644 --- a/src/tests/test_main.cc +++ b/src/tests/test_main.cc @@ -70,7 +70,9 @@ DECLARE_string(log_dir); #include "unit-tests/arithmetic/code_generation_test.cc" #include "unit-tests/arithmetic/fft_length_test.cc" #include "unit-tests/arithmetic/fft_speed_test.cc" +#if MATIO_TEST #include "unit-tests/arithmetic/matio_test.cc" +#endif #include "unit-tests/control-plane/file_configuration_test.cc" #include "unit-tests/control-plane/in_memory_configuration_test.cc" diff --git a/src/tests/unit-tests/arithmetic/matio_test.cc b/src/tests/unit-tests/arithmetic/matio_test.cc index e49cf7b63..00bfb1bba 100644 --- a/src/tests/unit-tests/arithmetic/matio_test.cc +++ b/src/tests/unit-tests/arithmetic/matio_test.cc @@ -101,8 +101,28 @@ TEST(MatioTest, WriteAndReadGrComplex) matvar = Mat_VarCreate("x", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, &x, MAT_F_COMPLEX); ASSERT_FALSE(reinterpret_cast(matvar) == NULL) << "Error creating variable for ’x’"; + std::vector y_v = { {1.1, -10}, {2, -9}, {3, -8}, {4, -7}, {5, 6}, {6, -5}, {7, -4}, {8, 3}, {9, 2}, {10, 1}}; + const unsigned int size_y = y_v.size(); + float y_real[size_y]; + float y_imag[size_y]; + i = 0; + for (std::vector::const_iterator it = y_v.cbegin(); it != y_v.cend(); it++) + { + y_real[i] = it->real(); + y_imag[i] = it->imag(); + i++; + } + + struct mat_complex_split_t y = {y_real, y_imag}; + size_t dims_y[2] = {static_cast(size_y), 1}; + matvar_t *matvar_y; + matvar_y = Mat_VarCreate("y", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims_y, &y, MAT_F_COMPLEX); + ASSERT_FALSE(reinterpret_cast(matvar_y) == NULL) << "Error creating variable for ’y’"; + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarWrite(matfp, matvar_y, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE Mat_VarFree(matvar); + Mat_VarFree(matvar_y); Mat_Close(matfp); @@ -134,5 +154,5 @@ TEST(MatioTest, WriteAndReadGrComplex) EXPECT_FLOAT_EQ(x_v[i].real(), x_v_read[i].real()); EXPECT_FLOAT_EQ(x_v[i].imag(), x_v_read[i].imag()); } - ASSERT_EQ(remove(filename.c_str()), 0); + //ASSERT_EQ(remove(filename.c_str()), 0); } From 2f05ba47262b195fc5d5bfff163578341664a822 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 18 Nov 2017 01:06:57 +0100 Subject: [PATCH 52/60] Warn user about lack of hdf5 --- CMakeLists.txt | 14 ++++++++++++++ src/tests/CMakeLists.txt | 5 ++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fdf3954a2..967150b27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1491,7 +1491,21 @@ if(NOT MATIO_FOUND) set(MATIO_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/matio/lib/${CMAKE_FIND_LIBRARY_PREFIXES}matio${CMAKE_STATIC_LIBRARY_SUFFIX} ${HDF5_LIBRARIES} ${ZLIB_LIBRARIES} ) set(MATIO_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/matio/include ) set(MATIO_LOCAL true) + else(HDF5_FOUND) + message(STATUS " The hdf5 library has not been found in your system.") + message(STATUS " Please try to install it by doing:") + if(OS_IS_MACOSX) + message(STATUS " $ sudo port install hdf5") + message(STATUS " or") + message(STATUS " $ brew install hdf5") + endif(OS_IS_MACOSX) + if(OS_IS_LINUX) + message(STATUS " $ sudo apt-get install libhdf5-dev") + endif(OS_IS_LINUX) + message(FATAL_ERROR "*** The hdf5 library is required to build gnss-sdr") endif(HDF5_FOUND) + else(ZLIB_FOUND) + message(FATAL_ERROR "*** The zlib library is required to build gnss-sdr") endif(ZLIB_FOUND) endif(NOT MATIO_FOUND) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 30b20eadb..e817b6ca4 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -163,6 +163,8 @@ endif(GNUPLOT_FOUND) if(MATIO_FOUND OR MATIO_LOCAL) add_definitions(-DMATIO_TEST=1) + set(GNSS_SDR_TEST_OPTIONAL_LIBS "${GNSS_SDR_TEST_OPTIONAL_LIBS};${MATIO_LIBRARIES}") + set(GNSS_SDR_TEST_OPTIONAL_HEADERS "${GNSS_SDR_TEST_OPTIONAL_HEADERS};${MATIO_INCLUDE_DIRS}") endif(MATIO_FOUND OR MATIO_LOCAL) ################################################################################ @@ -323,8 +325,6 @@ include_directories( ${VOLK_INCLUDE_DIRS} ${VOLK_GNSSSDR_INCLUDE_DIRS} ${GNSS_SDR_TEST_OPTIONAL_HEADERS} - ${GNSS_SDR_TEST_OPTIONAL_HEADERS} - ${MATIO_INCLUDE_DIRS} ) @@ -359,7 +359,6 @@ if(ENABLE_UNIT_TESTING) signal_processing_testing_lib ${VOLK_GNSSSDR_LIBRARIES} ${GNSS_SDR_TEST_OPTIONAL_LIBS} - ${MATIO_LIBRARIES} ) if(NOT ${GTEST_DIR_LOCAL}) add_dependencies(run_tests gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) From fcaf4cfa50a7c924730f08c61ee173a498f806fd Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 18 Nov 2017 10:05:14 +0100 Subject: [PATCH 53/60] Fix test in Ubuntu 16.04 --- src/tests/unit-tests/arithmetic/matio_test.cc | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/tests/unit-tests/arithmetic/matio_test.cc b/src/tests/unit-tests/arithmetic/matio_test.cc index 00bfb1bba..212a564b6 100644 --- a/src/tests/unit-tests/arithmetic/matio_test.cc +++ b/src/tests/unit-tests/arithmetic/matio_test.cc @@ -66,11 +66,12 @@ TEST(MatioTest, WriteAndReadDoubles) matvar_read = Mat_VarRead(matfp_read, "x"); double *x_read = reinterpret_cast(matvar_read->data); Mat_Close(matfp_read); - Mat_VarFree(matvar_read); + for(int i = 0; i < 10; i++) { EXPECT_DOUBLE_EQ(x[i], x_read[i]); } + Mat_VarFree(matvar_read); ASSERT_EQ(remove(filename.c_str()), 0); } @@ -79,8 +80,8 @@ TEST(MatioTest, WriteAndReadGrComplex) { // Write a .mat file mat_t *matfp; - matvar_t *matvar; - std::string filename = "./test2.mat"; + matvar_t *matvar1; + std::string filename = "./test3.mat"; matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); ASSERT_FALSE(reinterpret_cast(matfp) == NULL) << "Error creating .mat file"; @@ -98,15 +99,15 @@ TEST(MatioTest, WriteAndReadGrComplex) struct mat_complex_split_t x = {x_real, x_imag}; size_t dims[2] = {static_cast(size), 1}; - matvar = Mat_VarCreate("x", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, &x, MAT_F_COMPLEX); - ASSERT_FALSE(reinterpret_cast(matvar) == NULL) << "Error creating variable for ’x’"; + matvar1 = Mat_VarCreate("x", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, &x, MAT_F_COMPLEX); + ASSERT_FALSE(reinterpret_cast(matvar1) == NULL) << "Error creating variable for ’x’"; - std::vector y_v = { {1.1, -10}, {2, -9}, {3, -8}, {4, -7}, {5, 6}, {6, -5}, {7, -4}, {8, 3}, {9, 2}, {10, 1}}; - const unsigned int size_y = y_v.size(); + std::vector x2 = { {1.1, -10}, {2, -9}, {3, -8}, {4, -7}, {5, 6}, {6, -5}, {7, -4}, {8, 3}, {9, 2}, {10, 1}}; + const unsigned int size_y = x2.size(); float y_real[size_y]; float y_imag[size_y]; i = 0; - for (std::vector::const_iterator it = y_v.cbegin(); it != y_v.cend(); it++) + for (std::vector::const_iterator it = x2.cbegin(); it != x2.cend(); it++) { y_real[i] = it->real(); y_imag[i] = it->imag(); @@ -115,14 +116,14 @@ TEST(MatioTest, WriteAndReadGrComplex) struct mat_complex_split_t y = {y_real, y_imag}; size_t dims_y[2] = {static_cast(size_y), 1}; - matvar_t *matvar_y; - matvar_y = Mat_VarCreate("y", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims_y, &y, MAT_F_COMPLEX); - ASSERT_FALSE(reinterpret_cast(matvar_y) == NULL) << "Error creating variable for ’y’"; + matvar_t *matvar2; + matvar2 = Mat_VarCreate("y", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims_y, &y, MAT_F_COMPLEX); + ASSERT_FALSE(reinterpret_cast(matvar2) == NULL) << "Error creating variable for ’y’"; Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarWrite(matfp, matvar_y, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarWrite(matfp, matvar2, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE Mat_VarFree(matvar); - Mat_VarFree(matvar_y); + Mat_VarFree(matvar2); Mat_Close(matfp); @@ -154,5 +155,5 @@ TEST(MatioTest, WriteAndReadGrComplex) EXPECT_FLOAT_EQ(x_v[i].real(), x_v_read[i].real()); EXPECT_FLOAT_EQ(x_v[i].imag(), x_v_read[i].imag()); } - //ASSERT_EQ(remove(filename.c_str()), 0); + ASSERT_EQ(remove(filename.c_str()), 0); } From 0fd605e2ef07c5ef4e24153bd922556483b9affc Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 18 Nov 2017 10:10:23 +0100 Subject: [PATCH 54/60] Test fixes --- src/tests/unit-tests/arithmetic/matio_test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/unit-tests/arithmetic/matio_test.cc b/src/tests/unit-tests/arithmetic/matio_test.cc index 212a564b6..552414d5d 100644 --- a/src/tests/unit-tests/arithmetic/matio_test.cc +++ b/src/tests/unit-tests/arithmetic/matio_test.cc @@ -120,9 +120,9 @@ TEST(MatioTest, WriteAndReadGrComplex) matvar2 = Mat_VarCreate("y", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims_y, &y, MAT_F_COMPLEX); ASSERT_FALSE(reinterpret_cast(matvar2) == NULL) << "Error creating variable for ’y’"; - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarWrite(matfp, matvar1, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE Mat_VarWrite(matfp, matvar2, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); + Mat_VarFree(matvar1); Mat_VarFree(matvar2); Mat_Close(matfp); From b50545b446ab99ddd8787ebd24c2f6aa848abaaa Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 19 Nov 2017 17:52:45 +0100 Subject: [PATCH 55/60] Use matio library in tracking blocks --- .../tracking/gnuradio_blocks/CMakeLists.txt | 3 +- .../galileo_e1_dll_pll_veml_tracking_cc.cc | 231 ++++++++++++++++++ .../galileo_e1_dll_pll_veml_tracking_cc.h | 2 + .../galileo_e5a_dll_pll_tracking_cc.cc | 222 +++++++++++++++++ .../galileo_e5a_dll_pll_tracking_cc.h | 2 + .../gps_l1_ca_dll_pll_c_aid_tracking_cc.cc | 222 ++++++++++++++++- .../gps_l1_ca_dll_pll_c_aid_tracking_cc.h | 2 + ...ps_l1_ca_dll_pll_c_aid_tracking_fpga_sc.cc | 225 +++++++++++++++++ ...gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc.h | 2 + .../gps_l1_ca_dll_pll_c_aid_tracking_sc.cc | 221 +++++++++++++++++ .../gps_l1_ca_dll_pll_c_aid_tracking_sc.h | 2 + .../gps_l1_ca_dll_pll_tracking_cc.cc | 225 ++++++++++++++++- .../gps_l1_ca_dll_pll_tracking_cc.h | 1 + .../gps_l2_m_dll_pll_tracking_cc.cc | 220 +++++++++++++++++ .../gps_l2_m_dll_pll_tracking_cc.h | 2 + 15 files changed, 1579 insertions(+), 3 deletions(-) diff --git a/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt b/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt index d7c8981c6..cb42a6725 100644 --- a/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt @@ -51,6 +51,7 @@ include_directories( ${GNURADIO_RUNTIME_INCLUDE_DIRS} ${VOLK_GNSSSDR_INCLUDE_DIRS} ${OPT_TRACKING_INCLUDES} + ${MATIO_INCLUDE_DIRS} ) if(ENABLE_GENERIC_ARCH) @@ -62,7 +63,7 @@ list(SORT TRACKING_GR_BLOCKS_HEADERS) add_library(tracking_gr_blocks ${TRACKING_GR_BLOCKS_SOURCES} ${TRACKING_GR_BLOCKS_HEADERS}) source_group(Headers FILES ${TRACKING_GR_BLOCKS_HEADERS}) -target_link_libraries(tracking_gr_blocks tracking_lib ${GNURADIO_RUNTIME_LIBRARIES} gnss_sp_libs ${Boost_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES} ${OPT_TRACKING_LIBRARIES}) +target_link_libraries(tracking_gr_blocks tracking_lib ${GNURADIO_RUNTIME_LIBRARIES} gnss_sp_libs ${Boost_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES} ${MATIO_LIBRARIES} ${OPT_TRACKING_LIBRARIES}) if(NOT VOLK_GNSSSDR_FOUND) add_dependencies(tracking_gr_blocks volk_gnsssdr_module) diff --git a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.cc index 9c23835dc..d1db687ac 100755 --- a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.cc @@ -42,6 +42,7 @@ #include #include #include +#include #include #include "galileo_e1_signal_processing.h" #include "tracking_discriminators.h" @@ -262,6 +263,18 @@ galileo_e1_dll_pll_veml_tracking_cc::~galileo_e1_dll_pll_veml_tracking_cc() LOG(WARNING) << "Exception in destructor " << ex.what(); } } + if(d_dump) + { + if(d_channel == 0) + { + std::cout << "Writing .mat files ..."; + } + galileo_e1_dll_pll_veml_tracking_cc::save_matfile(); + if(d_channel == 0) + { + std::cout << " done." << std::endl; + } + } try { volk_gnsssdr_free(d_local_code_shift_chips); @@ -509,6 +522,224 @@ int galileo_e1_dll_pll_veml_tracking_cc::general_work (int noutput_items __attri } +int galileo_e1_dll_pll_veml_tracking_cc::save_matfile() +{ + // READ DUMP FILE + std::ifstream::pos_type size; + int number_of_double_vars = 1; + int number_of_float_vars = 17; + int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars + + sizeof(float) * number_of_float_vars + sizeof(unsigned int); + std::ifstream dump_file; + dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + try + { + dump_file.open(d_dump_filename.c_str(), std::ios::binary | std::ios::ate); + } + catch(const std::ifstream::failure &e) + { + std::cerr << "Problem opening dump file:" << e.what() << std::endl; + return 1; + } + // count number of epochs and rewind + long int num_epoch = 0; + if (dump_file.is_open()) + { + size = dump_file.tellg(); + num_epoch = static_cast(size) / static_cast(epoch_size_bytes); + dump_file.seekg(0, std::ios::beg); + } + else + { + return 1; + } + float * abs_VE = new float [num_epoch]; + float * abs_E = new float [num_epoch]; + float * abs_P = new float [num_epoch]; + float * abs_L = new float [num_epoch]; + float * abs_VL = new float [num_epoch]; + float * Prompt_I = new float [num_epoch]; + float * Prompt_Q = new float [num_epoch]; + unsigned long int * PRN_start_sample_count = new unsigned long int [num_epoch]; + float * acc_carrier_phase_rad = new float [num_epoch]; + float * carrier_doppler_hz = new float [num_epoch]; + float * code_freq_chips = new float [num_epoch]; + float * carr_error_hz = new float [num_epoch]; + float * carr_error_filt_hz = new float [num_epoch]; + float * code_error_chips = new float [num_epoch]; + float * code_error_filt_chips = new float [num_epoch]; + float * CN0_SNV_dB_Hz = new float [num_epoch]; + float * carrier_lock_test = new float [num_epoch]; + float * aux1 = new float [num_epoch]; + double * aux2 = new double [num_epoch]; + unsigned int * PRN = new unsigned int [num_epoch]; + + try + { + if (dump_file.is_open()) + { + for(long int i = 0; i < num_epoch; i++) + { + dump_file.read(reinterpret_cast(&abs_VE[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_E[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_P[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_L[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_VL[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&Prompt_I[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&Prompt_Q[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(unsigned long int)); + dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&carr_error_hz[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&carr_error_filt_hz[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&code_error_chips[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&code_error_filt_chips[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&CN0_SNV_dB_Hz[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&carrier_lock_test[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&aux1[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&aux2[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&PRN[i]), sizeof(unsigned int)); + } + } + dump_file.close(); + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem reading dump file:" << e.what() << std::endl; + delete[] abs_E; + delete[] abs_P; + delete[] abs_L; + delete[] Prompt_I; + delete[] Prompt_Q; + delete[] PRN_start_sample_count; + delete[] acc_carrier_phase_rad; + delete[] carrier_doppler_hz; + delete[] code_freq_chips; + delete[] carr_error_hz; + delete[] carr_error_filt_hz; + delete[] code_error_chips; + delete[] code_error_filt_chips; + delete[] CN0_SNV_dB_Hz; + delete[] carrier_lock_test; + delete[] aux1; + delete[] aux2; + delete[] PRN; + return 1; + } + + // WRITE MAT FILE + mat_t *matfp; + matvar_t *matvar; + std::string filename = d_dump_filename; + filename.erase(filename.length() - 4, 4); + filename.append(".mat"); + matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); + if(reinterpret_cast(matfp) != NULL) + { + size_t dims[2] = {1, static_cast(num_epoch)}; + matvar = Mat_VarCreate("abs_VE", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_P", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_P, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_L", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_L, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_VL", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Prompt_I", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_I, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Prompt_Q", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_Q, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN_start_sample_count", MAT_C_UINT64, MAT_T_UINT64, 2, dims, PRN_start_sample_count, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("acc_carrier_phase_rad", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, acc_carrier_phase_rad, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_doppler_hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carrier_doppler_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_freq_chips", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, code_freq_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_error_hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carr_error_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_error_filt_hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carr_error_filt_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_error_chips", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, code_error_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_error_filt_chips", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, code_error_filt_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("CN0_SNV_dB_Hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, CN0_SNV_dB_Hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_lock_test", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carrier_lock_test, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("aux1", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, aux1, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("aux2", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux2, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN", MAT_C_UINT32, MAT_T_UINT32, 2, dims, PRN, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + } + Mat_Close(matfp); + delete[] abs_E; + delete[] abs_P; + delete[] abs_L; + delete[] Prompt_I; + delete[] Prompt_Q; + delete[] PRN_start_sample_count; + delete[] acc_carrier_phase_rad; + delete[] carrier_doppler_hz; + delete[] code_freq_chips; + delete[] carr_error_hz; + delete[] carr_error_filt_hz; + delete[] code_error_chips; + delete[] code_error_filt_chips; + delete[] CN0_SNV_dB_Hz; + delete[] carrier_lock_test; + delete[] aux1; + delete[] aux2; + delete[] PRN; + return 0; +} + void galileo_e1_dll_pll_veml_tracking_cc::set_channel(unsigned int channel) { diff --git a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.h b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.h index 09e6fffe6..2d1aef220 100755 --- a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.h +++ b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.h @@ -174,6 +174,8 @@ private: std::map systemName; std::string sys; + + int save_matfile(); }; #endif //GNSS_SDR_GALILEO_E1_DLL_PLL_VEML_TRACKING_CC_H diff --git a/src/algorithms/tracking/gnuradio_blocks/galileo_e5a_dll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/galileo_e5a_dll_pll_tracking_cc.cc index 74446bf96..bdc4b7d00 100644 --- a/src/algorithms/tracking/gnuradio_blocks/galileo_e5a_dll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/galileo_e5a_dll_pll_tracking_cc.cc @@ -41,6 +41,7 @@ #include #include #include +#include #include #include "galileo_e5_signal_processing.h" #include "tracking_discriminators.h" @@ -224,6 +225,20 @@ Galileo_E5a_Dll_Pll_Tracking_cc::~Galileo_E5a_Dll_Pll_Tracking_cc() LOG(WARNING)<<"Exception in destructor "<(size) / static_cast(epoch_size_bytes); + dump_file.seekg(0, std::ios::beg); + } + else + { + return 1; + } + float * abs_E = new float [num_epoch]; + float * abs_P = new float [num_epoch]; + float * abs_L = new float [num_epoch]; + float * Prompt_I = new float [num_epoch]; + float * Prompt_Q = new float [num_epoch]; + unsigned long int * PRN_start_sample_count = new unsigned long int [num_epoch]; + double * acc_carrier_phase_rad = new double [num_epoch]; + double * carrier_doppler_hz = new double [num_epoch]; + double * code_freq_chips = new double [num_epoch]; + double * carr_error_hz = new double [num_epoch]; + double * carr_error_filt_hz = new double [num_epoch]; + double * code_error_chips = new double [num_epoch]; + double * code_error_filt_chips = new double [num_epoch]; + double * CN0_SNV_dB_Hz = new double [num_epoch]; + double * carrier_lock_test = new double [num_epoch]; + double * aux1 = new double [num_epoch]; + double * aux2 = new double [num_epoch]; + unsigned int * PRN = new unsigned int [num_epoch]; + + try + { + if (dump_file.is_open()) + { + for(long int i = 0; i < num_epoch; i++) + { + dump_file.read(reinterpret_cast(&abs_E[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_P[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_L[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&Prompt_I[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&Prompt_Q[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(unsigned long int)); + dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carr_error_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carr_error_filt_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_error_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_error_filt_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&CN0_SNV_dB_Hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carrier_lock_test[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&aux1[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&aux2[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&PRN[i]), sizeof(unsigned int)); + } + } + dump_file.close(); + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem reading dump file:" << e.what() << std::endl; + delete[] abs_E; + delete[] abs_P; + delete[] abs_L; + delete[] Prompt_I; + delete[] Prompt_Q; + delete[] PRN_start_sample_count; + delete[] acc_carrier_phase_rad; + delete[] carrier_doppler_hz; + delete[] code_freq_chips; + delete[] carr_error_hz; + delete[] carr_error_filt_hz; + delete[] code_error_chips; + delete[] code_error_filt_chips; + delete[] CN0_SNV_dB_Hz; + delete[] carrier_lock_test; + delete[] aux1; + delete[] aux2; + delete[] PRN; + return 1; + } + + // WRITE MAT FILE + mat_t *matfp; + matvar_t *matvar; + std::string filename = d_dump_filename; + filename.erase(filename.length() - 4, 4); + filename.append(".mat"); + matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); + if(reinterpret_cast(matfp) != NULL) + { + size_t dims[2] = {1, static_cast(num_epoch)}; + matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_P", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_P, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_L", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_L, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Prompt_I", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_I, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Prompt_Q", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_Q, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN_start_sample_count", MAT_C_UINT64, MAT_T_UINT64, 2, dims, PRN_start_sample_count, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("acc_carrier_phase_rad", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, acc_carrier_phase_rad, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_doppler_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_doppler_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_freq_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_freq_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_error_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_error_filt_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_filt_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_error_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_error_filt_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_filt_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("CN0_SNV_dB_Hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, CN0_SNV_dB_Hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_lock_test", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_lock_test, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("aux1", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux1, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("aux2", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux2, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN", MAT_C_UINT32, MAT_T_UINT32, 2, dims, PRN, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + } + Mat_Close(matfp); + delete[] abs_E; + delete[] abs_P; + delete[] abs_L; + delete[] Prompt_I; + delete[] Prompt_Q; + delete[] PRN_start_sample_count; + delete[] acc_carrier_phase_rad; + delete[] carrier_doppler_hz; + delete[] code_freq_chips; + delete[] carr_error_hz; + delete[] carr_error_filt_hz; + delete[] code_error_chips; + delete[] code_error_filt_chips; + delete[] CN0_SNV_dB_Hz; + delete[] carrier_lock_test; + delete[] aux1; + delete[] aux2; + delete[] PRN; + return 0; +} + + void Galileo_E5a_Dll_Pll_Tracking_cc::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) { d_acquisition_gnss_synchro = p_gnss_synchro; diff --git a/src/algorithms/tracking/gnuradio_blocks/galileo_e5a_dll_pll_tracking_cc.h b/src/algorithms/tracking/gnuradio_blocks/galileo_e5a_dll_pll_tracking_cc.h index 3d21bd7c0..b9bdb342a 100644 --- a/src/algorithms/tracking/gnuradio_blocks/galileo_e5a_dll_pll_tracking_cc.h +++ b/src/algorithms/tracking/gnuradio_blocks/galileo_e5a_dll_pll_tracking_cc.h @@ -204,6 +204,8 @@ private: std::map systemName; std::string sys; + + int save_matfile(); }; #endif /* GNSS_SDR_GALILEO_E5A_DLL_PLL_TRACKING_CC_H_ */ diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc index 8f68d765d..4bab79242 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -299,7 +300,6 @@ void gps_l1_ca_dll_pll_c_aid_tracking_cc::start_tracking() gps_l1_ca_dll_pll_c_aid_tracking_cc::~gps_l1_ca_dll_pll_c_aid_tracking_cc() { - if (d_dump_file.is_open()) { try @@ -311,6 +311,20 @@ gps_l1_ca_dll_pll_c_aid_tracking_cc::~gps_l1_ca_dll_pll_c_aid_tracking_cc() LOG(WARNING) << "Exception in destructor " << ex.what(); } } + + if(d_dump) + { + if(d_channel == 0) + { + std::cout << "Writing .mat files ..."; + } + gps_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile(); + if(d_channel == 0) + { + std::cout << " done." << std::endl; + } + } + try { volk_gnsssdr_free(d_local_code_shift_chips); @@ -326,6 +340,212 @@ gps_l1_ca_dll_pll_c_aid_tracking_cc::~gps_l1_ca_dll_pll_c_aid_tracking_cc() } +int gps_l1_ca_dll_pll_c_aid_tracking_cc::save_matfile() +{ + // READ DUMP FILE + std::ifstream::pos_type size; + 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 + sizeof(unsigned int); + std::ifstream dump_file; + dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + try + { + dump_file.open(d_dump_filename.c_str(), std::ios::binary | std::ios::ate); + } + catch(const std::ifstream::failure &e) + { + std::cerr << "Problem opening dump file:" << e.what() << std::endl; + return 1; + } + // count number of epochs and rewind + long int num_epoch = 0; + if (dump_file.is_open()) + { + size = dump_file.tellg(); + num_epoch = static_cast(size) / static_cast(epoch_size_bytes); + dump_file.seekg(0, std::ios::beg); + } + else + { + return 1; + } + float * abs_E = new float [num_epoch]; + float * abs_P = new float [num_epoch]; + float * abs_L = new float [num_epoch]; + float * Prompt_I = new float [num_epoch]; + float * Prompt_Q = new float [num_epoch]; + unsigned long int * PRN_start_sample_count = new unsigned long int [num_epoch]; + double * acc_carrier_phase_rad = new double [num_epoch]; + double * carrier_doppler_hz = new double [num_epoch]; + double * code_freq_chips = new double [num_epoch]; + double * carr_error_hz = new double [num_epoch]; + double * carr_error_filt_hz = new double [num_epoch]; + double * code_error_chips = new double [num_epoch]; + double * code_error_filt_chips = new double [num_epoch]; + double * CN0_SNV_dB_Hz = new double [num_epoch]; + double * carrier_lock_test = new double [num_epoch]; + double * aux1 = new double [num_epoch]; + double * aux2 = new double [num_epoch]; + unsigned int * PRN = new unsigned int [num_epoch]; + + try + { + if (dump_file.is_open()) + { + for(long int i = 0; i < num_epoch; i++) + { + dump_file.read(reinterpret_cast(&abs_E[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_P[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_L[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&Prompt_I[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&Prompt_Q[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(unsigned long int)); + dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carr_error_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carr_error_filt_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_error_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_error_filt_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&CN0_SNV_dB_Hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carrier_lock_test[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&aux1[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&aux2[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&PRN[i]), sizeof(unsigned int)); + } + } + dump_file.close(); + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem reading dump file:" << e.what() << std::endl; + delete[] abs_E; + delete[] abs_P; + delete[] abs_L; + delete[] Prompt_I; + delete[] Prompt_Q; + delete[] PRN_start_sample_count; + delete[] acc_carrier_phase_rad; + delete[] carrier_doppler_hz; + delete[] code_freq_chips; + delete[] carr_error_hz; + delete[] carr_error_filt_hz; + delete[] code_error_chips; + delete[] code_error_filt_chips; + delete[] CN0_SNV_dB_Hz; + delete[] carrier_lock_test; + delete[] aux1; + delete[] aux2; + delete[] PRN; + return 1; + } + + // WRITE MAT FILE + mat_t *matfp; + matvar_t *matvar; + std::string filename = d_dump_filename; + filename.erase(filename.length() - 4, 4); + filename.append(".mat"); + matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); + if(reinterpret_cast(matfp) != NULL) + { + size_t dims[2] = {1, static_cast(num_epoch)}; + matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_P", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_P, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_L", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_L, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Prompt_I", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_I, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Prompt_Q", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_Q, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN_start_sample_count", MAT_C_UINT64, MAT_T_UINT64, 2, dims, PRN_start_sample_count, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("acc_carrier_phase_rad", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, acc_carrier_phase_rad, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_doppler_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_doppler_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_freq_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_freq_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_error_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_error_filt_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_filt_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_error_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_error_filt_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_filt_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("CN0_SNV_dB_Hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, CN0_SNV_dB_Hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_lock_test", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_lock_test, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("aux1", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux1, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("aux2", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux2, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN", MAT_C_UINT32, MAT_T_UINT32, 2, dims, PRN, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + } + Mat_Close(matfp); + delete[] abs_E; + delete[] abs_P; + delete[] abs_L; + delete[] Prompt_I; + delete[] Prompt_Q; + delete[] PRN_start_sample_count; + delete[] acc_carrier_phase_rad; + delete[] carrier_doppler_hz; + delete[] code_freq_chips; + delete[] carr_error_hz; + delete[] carr_error_filt_hz; + delete[] code_error_chips; + delete[] code_error_filt_chips; + delete[] CN0_SNV_dB_Hz; + delete[] carrier_lock_test; + delete[] aux1; + delete[] aux2; + delete[] PRN; + return 0; +} + int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work (int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.h b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.h index 8801a96fb..cf6f31b5f 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.h +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.h @@ -196,6 +196,8 @@ private: std::map systemName; std::string sys; + + int save_matfile(); }; #endif //GNSS_SDR_GPS_L1_CA_DLL_PLL_C_AID_TRACKING_CC_H diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc.cc index 22d504786..0b39b1ebe 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc.cc @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -309,6 +310,20 @@ gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::~gps_l1_ca_dll_pll_c_aid_tracking_fpga LOG(WARNING)<< "Exception in destructor " << ex.what(); } } + + if(d_dump) + { + if(d_channel == 0) + { + std::cout << "Writing .mat files ..."; + } + gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::save_matfile(); + if(d_channel == 0) + { + std::cout << " done." << std::endl; + } + } + try { volk_gnsssdr_free(d_local_code_shift_chips); @@ -665,6 +680,10 @@ int gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::general_work( d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + + // PRN + unsigned int prn_ = d_acquisition_gnss_synchro->PRN; + d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); } catch (const std::ifstream::failure* e) { @@ -710,6 +729,212 @@ void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::set_channel(unsigned int channel) } +int gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::save_matfile() +{ + // READ DUMP FILE + std::ifstream::pos_type size; + 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 + sizeof(unsigned int); + std::ifstream dump_file; + dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + try + { + dump_file.open(d_dump_filename.c_str(), std::ios::binary | std::ios::ate); + } + catch(const std::ifstream::failure &e) + { + std::cerr << "Problem opening dump file:" << e.what() << std::endl; + return 1; + } + // count number of epochs and rewind + long int num_epoch = 0; + if (dump_file.is_open()) + { + size = dump_file.tellg(); + num_epoch = static_cast(size) / static_cast(epoch_size_bytes); + dump_file.seekg(0, std::ios::beg); + } + else + { + return 1; + } + float * abs_E = new float [num_epoch]; + float * abs_P = new float [num_epoch]; + float * abs_L = new float [num_epoch]; + float * Prompt_I = new float [num_epoch]; + float * Prompt_Q = new float [num_epoch]; + unsigned long int * PRN_start_sample_count = new unsigned long int [num_epoch]; + double * acc_carrier_phase_rad = new double [num_epoch]; + double * carrier_doppler_hz = new double [num_epoch]; + double * code_freq_chips = new double [num_epoch]; + double * carr_error_hz = new double [num_epoch]; + double * carr_error_filt_hz = new double [num_epoch]; + double * code_error_chips = new double [num_epoch]; + double * code_error_filt_chips = new double [num_epoch]; + double * CN0_SNV_dB_Hz = new double [num_epoch]; + double * carrier_lock_test = new double [num_epoch]; + double * aux1 = new double [num_epoch]; + double * aux2 = new double [num_epoch]; + unsigned int * PRN = new unsigned int [num_epoch]; + + try + { + if (dump_file.is_open()) + { + for(long int i = 0; i < num_epoch; i++) + { + dump_file.read(reinterpret_cast(&abs_E[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_P[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_L[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&Prompt_I[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&Prompt_Q[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(unsigned long int)); + dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carr_error_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carr_error_filt_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_error_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_error_filt_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&CN0_SNV_dB_Hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carrier_lock_test[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&aux1[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&aux2[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&PRN[i]), sizeof(unsigned int)); + } + } + dump_file.close(); + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem reading dump file:" << e.what() << std::endl; + delete[] abs_E; + delete[] abs_P; + delete[] abs_L; + delete[] Prompt_I; + delete[] Prompt_Q; + delete[] PRN_start_sample_count; + delete[] acc_carrier_phase_rad; + delete[] carrier_doppler_hz; + delete[] code_freq_chips; + delete[] carr_error_hz; + delete[] carr_error_filt_hz; + delete[] code_error_chips; + delete[] code_error_filt_chips; + delete[] CN0_SNV_dB_Hz; + delete[] carrier_lock_test; + delete[] aux1; + delete[] aux2; + delete[] PRN; + return 1; + } + + // WRITE MAT FILE + mat_t *matfp; + matvar_t *matvar; + std::string filename = d_dump_filename; + filename.erase(filename.length() - 4, 4); + filename.append(".mat"); + matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); + if(reinterpret_cast(matfp) != NULL) + { + size_t dims[2] = {1, static_cast(num_epoch)}; + matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_P", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_P, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_L", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_L, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Prompt_I", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_I, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Prompt_Q", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_Q, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN_start_sample_count", MAT_C_UINT64, MAT_T_UINT64, 2, dims, PRN_start_sample_count, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("acc_carrier_phase_rad", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, acc_carrier_phase_rad, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_doppler_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_doppler_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_freq_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_freq_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_error_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_error_filt_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_filt_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_error_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_error_filt_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_filt_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("CN0_SNV_dB_Hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, CN0_SNV_dB_Hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_lock_test", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_lock_test, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("aux1", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux1, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("aux2", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux2, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN", MAT_C_UINT32, MAT_T_UINT32, 2, dims, PRN, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + } + Mat_Close(matfp); + delete[] abs_E; + delete[] abs_P; + delete[] abs_L; + delete[] Prompt_I; + delete[] Prompt_Q; + delete[] PRN_start_sample_count; + delete[] acc_carrier_phase_rad; + delete[] carrier_doppler_hz; + delete[] code_freq_chips; + delete[] carr_error_hz; + delete[] carr_error_filt_hz; + delete[] code_error_chips; + delete[] code_error_filt_chips; + delete[] CN0_SNV_dB_Hz; + delete[] carrier_lock_test; + delete[] aux1; + delete[] aux2; + delete[] PRN; + return 0; +} + void gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::set_gnss_synchro( Gnss_Synchro* p_gnss_synchro) { diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc.h b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc.h index 444ffbc72..9dded8939 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc.h +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc.h @@ -178,6 +178,8 @@ private: std::map systemName; std::string sys; + + int save_matfile(); }; #endif //GNSS_SDR_GPS_L1_CA_DLL_PLL_C_AID_TRACKING_FPGA_SC_H diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.cc index 24e96ff02..8973bb6a4 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.cc @@ -39,6 +39,7 @@ #include #include #include +#include #include "gnss_synchro.h" #include "gps_sdr_signal_processing.h" #include "tracking_discriminators.h" @@ -313,6 +314,20 @@ gps_l1_ca_dll_pll_c_aid_tracking_sc::~gps_l1_ca_dll_pll_c_aid_tracking_sc() LOG(WARNING) << "Exception in destructor " << ex.what(); } } + + if(d_dump) + { + if(d_channel == 0) + { + std::cout << "Writing .mat files ..."; + } + gps_l1_ca_dll_pll_c_aid_tracking_sc::save_matfile(); + if(d_channel == 0) + { + std::cout << " done." << std::endl; + } + } + try { volk_gnsssdr_free(d_local_code_shift_chips); @@ -330,6 +345,212 @@ gps_l1_ca_dll_pll_c_aid_tracking_sc::~gps_l1_ca_dll_pll_c_aid_tracking_sc() } +int gps_l1_ca_dll_pll_c_aid_tracking_sc::save_matfile() +{ + // READ DUMP FILE + std::ifstream::pos_type size; + 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 + sizeof(unsigned int); + std::ifstream dump_file; + dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + try + { + dump_file.open(d_dump_filename.c_str(), std::ios::binary | std::ios::ate); + } + catch(const std::ifstream::failure &e) + { + std::cerr << "Problem opening dump file:" << e.what() << std::endl; + return 1; + } + // count number of epochs and rewind + long int num_epoch = 0; + if (dump_file.is_open()) + { + size = dump_file.tellg(); + num_epoch = static_cast(size) / static_cast(epoch_size_bytes); + dump_file.seekg(0, std::ios::beg); + } + else + { + return 1; + } + float * abs_E = new float [num_epoch]; + float * abs_P = new float [num_epoch]; + float * abs_L = new float [num_epoch]; + float * Prompt_I = new float [num_epoch]; + float * Prompt_Q = new float [num_epoch]; + unsigned long int * PRN_start_sample_count = new unsigned long int [num_epoch]; + double * acc_carrier_phase_rad = new double [num_epoch]; + double * carrier_doppler_hz = new double [num_epoch]; + double * code_freq_chips = new double [num_epoch]; + double * carr_error_hz = new double [num_epoch]; + double * carr_error_filt_hz = new double [num_epoch]; + double * code_error_chips = new double [num_epoch]; + double * code_error_filt_chips = new double [num_epoch]; + double * CN0_SNV_dB_Hz = new double [num_epoch]; + double * carrier_lock_test = new double [num_epoch]; + double * aux1 = new double [num_epoch]; + double * aux2 = new double [num_epoch]; + unsigned int * PRN = new unsigned int [num_epoch]; + + try + { + if (dump_file.is_open()) + { + for(long int i = 0; i < num_epoch; i++) + { + dump_file.read(reinterpret_cast(&abs_E[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_P[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_L[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&Prompt_I[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&Prompt_Q[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(unsigned long int)); + dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carr_error_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carr_error_filt_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_error_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_error_filt_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&CN0_SNV_dB_Hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carrier_lock_test[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&aux1[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&aux2[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&PRN[i]), sizeof(unsigned int)); + } + } + dump_file.close(); + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem reading dump file:" << e.what() << std::endl; + delete[] abs_E; + delete[] abs_P; + delete[] abs_L; + delete[] Prompt_I; + delete[] Prompt_Q; + delete[] PRN_start_sample_count; + delete[] acc_carrier_phase_rad; + delete[] carrier_doppler_hz; + delete[] code_freq_chips; + delete[] carr_error_hz; + delete[] carr_error_filt_hz; + delete[] code_error_chips; + delete[] code_error_filt_chips; + delete[] CN0_SNV_dB_Hz; + delete[] carrier_lock_test; + delete[] aux1; + delete[] aux2; + delete[] PRN; + return 1; + } + + // WRITE MAT FILE + mat_t *matfp; + matvar_t *matvar; + std::string filename = d_dump_filename; + filename.erase(filename.length() - 4, 4); + filename.append(".mat"); + matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); + if(reinterpret_cast(matfp) != NULL) + { + size_t dims[2] = {1, static_cast(num_epoch)}; + matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_P", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_P, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_L", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_L, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Prompt_I", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_I, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Prompt_Q", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_Q, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN_start_sample_count", MAT_C_UINT64, MAT_T_UINT64, 2, dims, PRN_start_sample_count, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("acc_carrier_phase_rad", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, acc_carrier_phase_rad, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_doppler_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_doppler_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_freq_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_freq_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_error_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_error_filt_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_filt_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_error_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_error_filt_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_filt_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("CN0_SNV_dB_Hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, CN0_SNV_dB_Hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_lock_test", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_lock_test, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("aux1", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux1, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("aux2", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux2, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN", MAT_C_UINT32, MAT_T_UINT32, 2, dims, PRN, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + } + Mat_Close(matfp); + delete[] abs_E; + delete[] abs_P; + delete[] abs_L; + delete[] Prompt_I; + delete[] Prompt_Q; + delete[] PRN_start_sample_count; + delete[] acc_carrier_phase_rad; + delete[] carrier_doppler_hz; + delete[] code_freq_chips; + delete[] carr_error_hz; + delete[] carr_error_filt_hz; + delete[] code_error_chips; + delete[] code_error_filt_chips; + delete[] CN0_SNV_dB_Hz; + delete[] carrier_lock_test; + delete[] aux1; + delete[] aux2; + delete[] PRN; + return 0; +} + int gps_l1_ca_dll_pll_c_aid_tracking_sc::general_work (int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.h b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.h index caf81d7c8..cd9753b6d 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.h +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.h @@ -200,6 +200,8 @@ private: std::map systemName; std::string sys; + + int save_matfile(); }; #endif //GNSS_SDR_GPS_L1_CA_DLL_PLL_C_AID_TRACKING_SC_H diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.cc index 32d96c079..ec5004c56 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.cc @@ -43,6 +43,7 @@ #include #include #include +#include #include "gps_sdr_signal_processing.h" #include "tracking_discriminators.h" #include "lock_detectors.h" @@ -266,6 +267,213 @@ void Gps_L1_Ca_Dll_Pll_Tracking_cc::start_tracking() } +int Gps_L1_Ca_Dll_Pll_Tracking_cc::save_matfile() +{ + // READ DUMP FILE + std::ifstream::pos_type size; + 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 + sizeof(unsigned int); + std::ifstream dump_file; + dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + try + { + dump_file.open(d_dump_filename.c_str(), std::ios::binary | std::ios::ate); + } + catch(const std::ifstream::failure &e) + { + std::cerr << "Problem opening dump file:" << e.what() << std::endl; + return 1; + } + // count number of epochs and rewind + long int num_epoch = 0; + if (dump_file.is_open()) + { + size = dump_file.tellg(); + num_epoch = static_cast(size) / static_cast(epoch_size_bytes); + dump_file.seekg(0, std::ios::beg); + } + else + { + return 1; + } + float * abs_E = new float [num_epoch]; + float * abs_P = new float [num_epoch]; + float * abs_L = new float [num_epoch]; + float * Prompt_I = new float [num_epoch]; + float * Prompt_Q = new float [num_epoch]; + unsigned long int * PRN_start_sample_count = new unsigned long int [num_epoch]; + double * acc_carrier_phase_rad = new double [num_epoch]; + double * carrier_doppler_hz = new double [num_epoch]; + double * code_freq_chips = new double [num_epoch]; + double * carr_error_hz = new double [num_epoch]; + double * carr_error_filt_hz = new double [num_epoch]; + double * code_error_chips = new double [num_epoch]; + double * code_error_filt_chips = new double [num_epoch]; + double * CN0_SNV_dB_Hz = new double [num_epoch]; + double * carrier_lock_test = new double [num_epoch]; + double * aux1 = new double [num_epoch]; + double * aux2 = new double [num_epoch]; + unsigned int * PRN = new unsigned int [num_epoch]; + + try + { + if (dump_file.is_open()) + { + for(long int i = 0; i < num_epoch; i++) + { + dump_file.read(reinterpret_cast(&abs_E[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_P[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_L[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&Prompt_I[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&Prompt_Q[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(unsigned long int)); + dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carr_error_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carr_error_filt_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_error_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_error_filt_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&CN0_SNV_dB_Hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carrier_lock_test[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&aux1[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&aux2[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&PRN[i]), sizeof(unsigned int)); + } + } + dump_file.close(); + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem reading dump file:" << e.what() << std::endl; + delete[] abs_E; + delete[] abs_P; + delete[] abs_L; + delete[] Prompt_I; + delete[] Prompt_Q; + delete[] PRN_start_sample_count; + delete[] acc_carrier_phase_rad; + delete[] carrier_doppler_hz; + delete[] code_freq_chips; + delete[] carr_error_hz; + delete[] carr_error_filt_hz; + delete[] code_error_chips; + delete[] code_error_filt_chips; + delete[] CN0_SNV_dB_Hz; + delete[] carrier_lock_test; + delete[] aux1; + delete[] aux2; + delete[] PRN; + return 1; + } + + // WRITE MAT FILE + mat_t *matfp; + matvar_t *matvar; + std::string filename = d_dump_filename; + filename.erase(filename.length() - 4, 4); + filename.append(".mat"); + matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); + if(reinterpret_cast(matfp) != NULL) + { + size_t dims[2] = {1, static_cast(num_epoch)}; + matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_P", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_P, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_L", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_L, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Prompt_I", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_I, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Prompt_Q", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_Q, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN_start_sample_count", MAT_C_UINT64, MAT_T_UINT64, 2, dims, PRN_start_sample_count, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("acc_carrier_phase_rad", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, acc_carrier_phase_rad, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_doppler_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_doppler_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_freq_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_freq_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_error_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_error_filt_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_filt_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_error_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_error_filt_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_filt_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("CN0_SNV_dB_Hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, CN0_SNV_dB_Hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_lock_test", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_lock_test, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("aux1", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux1, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("aux2", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux2, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN", MAT_C_UINT32, MAT_T_UINT32, 2, dims, PRN, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + } + Mat_Close(matfp); + delete[] abs_E; + delete[] abs_P; + delete[] abs_L; + delete[] Prompt_I; + delete[] Prompt_Q; + delete[] PRN_start_sample_count; + delete[] acc_carrier_phase_rad; + delete[] carrier_doppler_hz; + delete[] code_freq_chips; + delete[] carr_error_hz; + delete[] carr_error_filt_hz; + delete[] code_error_chips; + delete[] code_error_filt_chips; + delete[] CN0_SNV_dB_Hz; + delete[] carrier_lock_test; + delete[] aux1; + delete[] aux2; + delete[] PRN; + return 0; +} + + Gps_L1_Ca_Dll_Pll_Tracking_cc::~Gps_L1_Ca_Dll_Pll_Tracking_cc() { if (d_dump_file.is_open()) @@ -279,6 +487,20 @@ Gps_L1_Ca_Dll_Pll_Tracking_cc::~Gps_L1_Ca_Dll_Pll_Tracking_cc() LOG(WARNING) << "Exception in destructor " << ex.what(); } } + + if(d_dump) + { + if(d_channel == 0) + { + std::cout << "Writing .mat files ..."; + } + Gps_L1_Ca_Dll_Pll_Tracking_cc::save_matfile(); + if(d_channel == 0) + { + std::cout << " done." << std::endl; + } + } + try { volk_gnsssdr_free(d_local_code_shift_chips); @@ -291,6 +513,7 @@ Gps_L1_Ca_Dll_Pll_Tracking_cc::~Gps_L1_Ca_Dll_Pll_Tracking_cc() { LOG(WARNING) << "Exception in destructor " << ex.what(); } + } @@ -443,7 +666,7 @@ int Gps_L1_Ca_Dll_Pll_Tracking_cc::general_work (int noutput_items __attribute__ d_correlator_outs[n] = gr_complex(0,0); } - current_synchro_data.Tracking_sample_counter =d_sample_counter + d_current_prn_length_samples; + current_synchro_data.Tracking_sample_counter = d_sample_counter + d_current_prn_length_samples; current_synchro_data.System = {'G'}; current_synchro_data.correlation_length_ms = 1; } diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.h b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.h index 9fe80fec7..346f7076a 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.h +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.h @@ -101,6 +101,7 @@ private: float dll_bw_hz, float early_late_space_chips); + int save_matfile(); // tracking configuration vars unsigned int d_vector_length; bool d_dump; diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l2_m_dll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l2_m_dll_pll_tracking_cc.cc index 18d6a2fc2..dfa1b6990 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l2_m_dll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l2_m_dll_pll_tracking_cc.cc @@ -42,6 +42,7 @@ #include #include #include +#include #include #include "gps_l2c_signal.h" #include "tracking_discriminators.h" @@ -269,6 +270,213 @@ void gps_l2_m_dll_pll_tracking_cc::start_tracking() } +int gps_l2_m_dll_pll_tracking_cc::save_matfile() +{ + // READ DUMP FILE + std::ifstream::pos_type size; + 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 + sizeof(unsigned int); + std::ifstream dump_file; + dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + try + { + dump_file.open(d_dump_filename.c_str(), std::ios::binary | std::ios::ate); + } + catch(const std::ifstream::failure &e) + { + std::cerr << "Problem opening dump file:" << e.what() << std::endl; + return 1; + } + // count number of epochs and rewind + long int num_epoch = 0; + if (dump_file.is_open()) + { + size = dump_file.tellg(); + num_epoch = static_cast(size) / static_cast(epoch_size_bytes); + dump_file.seekg(0, std::ios::beg); + } + else + { + return 1; + } + float * abs_E = new float [num_epoch]; + float * abs_P = new float [num_epoch]; + float * abs_L = new float [num_epoch]; + float * Prompt_I = new float [num_epoch]; + float * Prompt_Q = new float [num_epoch]; + unsigned long int * PRN_start_sample_count = new unsigned long int [num_epoch]; + double * acc_carrier_phase_rad = new double [num_epoch]; + double * carrier_doppler_hz = new double [num_epoch]; + double * code_freq_chips = new double [num_epoch]; + double * carr_error_hz = new double [num_epoch]; + double * carr_error_filt_hz = new double [num_epoch]; + double * code_error_chips = new double [num_epoch]; + double * code_error_filt_chips = new double [num_epoch]; + double * CN0_SNV_dB_Hz = new double [num_epoch]; + double * carrier_lock_test = new double [num_epoch]; + double * aux1 = new double [num_epoch]; + double * aux2 = new double [num_epoch]; + unsigned int * PRN = new unsigned int [num_epoch]; + + try + { + if (dump_file.is_open()) + { + for(long int i = 0; i < num_epoch; i++) + { + dump_file.read(reinterpret_cast(&abs_E[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_P[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_L[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&Prompt_I[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&Prompt_Q[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(unsigned long int)); + dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carr_error_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carr_error_filt_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_error_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_error_filt_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&CN0_SNV_dB_Hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carrier_lock_test[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&aux1[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&aux2[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&PRN[i]), sizeof(unsigned int)); + } + } + dump_file.close(); + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem reading dump file:" << e.what() << std::endl; + delete[] abs_E; + delete[] abs_P; + delete[] abs_L; + delete[] Prompt_I; + delete[] Prompt_Q; + delete[] PRN_start_sample_count; + delete[] acc_carrier_phase_rad; + delete[] carrier_doppler_hz; + delete[] code_freq_chips; + delete[] carr_error_hz; + delete[] carr_error_filt_hz; + delete[] code_error_chips; + delete[] code_error_filt_chips; + delete[] CN0_SNV_dB_Hz; + delete[] carrier_lock_test; + delete[] aux1; + delete[] aux2; + delete[] PRN; + return 1; + } + + // WRITE MAT FILE + mat_t *matfp; + matvar_t *matvar; + std::string filename = d_dump_filename; + filename.erase(filename.length() - 4, 4); + filename.append(".mat"); + matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); + if(reinterpret_cast(matfp) != NULL) + { + size_t dims[2] = {1, static_cast(num_epoch)}; + matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_P", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_P, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_L", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_L, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Prompt_I", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_I, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Prompt_Q", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_Q, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN_start_sample_count", MAT_C_UINT64, MAT_T_UINT64, 2, dims, PRN_start_sample_count, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("acc_carrier_phase_rad", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, acc_carrier_phase_rad, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_doppler_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_doppler_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_freq_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_freq_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_error_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_error_filt_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_filt_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_error_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_error_filt_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_filt_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("CN0_SNV_dB_Hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, CN0_SNV_dB_Hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_lock_test", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_lock_test, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("aux1", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux1, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("aux2", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux2, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN", MAT_C_UINT32, MAT_T_UINT32, 2, dims, PRN, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + } + Mat_Close(matfp); + delete[] abs_E; + delete[] abs_P; + delete[] abs_L; + delete[] Prompt_I; + delete[] Prompt_Q; + delete[] PRN_start_sample_count; + delete[] acc_carrier_phase_rad; + delete[] carrier_doppler_hz; + delete[] code_freq_chips; + delete[] carr_error_hz; + delete[] carr_error_filt_hz; + delete[] code_error_chips; + delete[] code_error_filt_chips; + delete[] CN0_SNV_dB_Hz; + delete[] carrier_lock_test; + delete[] aux1; + delete[] aux2; + delete[] PRN; + return 0; +} + + gps_l2_m_dll_pll_tracking_cc::~gps_l2_m_dll_pll_tracking_cc() { if (d_dump_file.is_open()) @@ -282,6 +490,18 @@ gps_l2_m_dll_pll_tracking_cc::~gps_l2_m_dll_pll_tracking_cc() LOG(WARNING) << "Exception in destructor " << ex.what(); } } + if(d_dump) + { + if(d_channel == 0) + { + std::cout << "Writing .mat files ..."; + } + gps_l2_m_dll_pll_tracking_cc::save_matfile(); + if(d_channel == 0) + { + std::cout << " done." << std::endl; + } + } try { volk_gnsssdr_free(d_local_code_shift_chips); diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l2_m_dll_pll_tracking_cc.h b/src/algorithms/tracking/gnuradio_blocks/gps_l2_m_dll_pll_tracking_cc.h index 37942778b..cf46636e2 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l2_m_dll_pll_tracking_cc.h +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l2_m_dll_pll_tracking_cc.h @@ -162,6 +162,8 @@ private: std::map systemName; std::string sys; + + int save_matfile(); }; #endif //GNSS_SDR_GPS_L2_M_DLL_PLL_TRACKING_CC_H From f719b4a22a63c6a73a54d7669040c62eaeab4bb9 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 19 Nov 2017 20:45:52 +0100 Subject: [PATCH 56/60] Add .mat storing capability to Observables block --- .../gnuradio_blocks/CMakeLists.txt | 3 +- .../gnuradio_blocks/hybrid_observables_cc.cc | 203 +++++++++++++++++- .../gnuradio_blocks/hybrid_observables_cc.h | 2 + 3 files changed, 204 insertions(+), 4 deletions(-) diff --git a/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt b/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt index d195adf03..74bb5280f 100644 --- a/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt @@ -31,6 +31,7 @@ include_directories( ${ARMADILLO_INCLUDE_DIRS} ${GLOG_INCLUDE_DIRS} ${GFlags_INCLUDE_DIRS} + ${MATIO_INCLUDE_DIRS} ) file(GLOB OBS_GR_BLOCKS_HEADERS "*.h") @@ -38,4 +39,4 @@ list(SORT OBS_GR_BLOCKS_HEADERS) add_library(obs_gr_blocks ${OBS_GR_BLOCKS_SOURCES} ${OBS_GR_BLOCKS_HEADERS}) source_group(Headers FILES ${OBS_GR_BLOCKS_HEADERS}) add_dependencies(obs_gr_blocks glog-${glog_RELEASE} armadillo-${armadillo_RELEASE}) -target_link_libraries(obs_gr_blocks ${GNURADIO_RUNTIME_LIBRARIES} ${ARMADILLO_LIBRARIES}) +target_link_libraries(obs_gr_blocks ${GNURADIO_RUNTIME_LIBRARIES} ${ARMADILLO_LIBRARIES} ${MATIO_LIBRARIES}) diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc index 9bc7f7e00..51259294d 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc @@ -38,6 +38,7 @@ #include #include #include +#include #include "Galileo_E1.h" #include "GPS_L1_CA.h" @@ -104,6 +105,197 @@ hybrid_observables_cc::~hybrid_observables_cc() LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what(); } } + if(d_dump == true) + { + std::cout << "Writing observables .mat files ..."; + hybrid_observables_cc::save_matfile(); + std::cout << " done." << std::endl; + } +} + + +int hybrid_observables_cc::save_matfile() +{ + // READ DUMP FILE + std::ifstream::pos_type size; + int number_of_double_vars = 7; + int epoch_size_bytes = sizeof(double) * number_of_double_vars * d_nchannels; + std::ifstream dump_file; + dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + try + { + dump_file.open(d_dump_filename.c_str(), std::ios::binary | std::ios::ate); + } + catch(const std::ifstream::failure &e) + { + std::cerr << "Problem opening dump file:" << e.what() << std::endl; + return 1; + } + // count number of epochs and rewind + long int num_epoch = 0; + if (dump_file.is_open()) + { + size = dump_file.tellg(); + num_epoch = static_cast(size) / static_cast(epoch_size_bytes); + dump_file.seekg(0, std::ios::beg); + } + else + { + return 1; + } + double ** RX_time = new double * [d_nchannels]; + double ** TOW_at_current_symbol_s = new double * [d_nchannels]; + double ** Carrier_Doppler_hz = new double * [d_nchannels]; + double ** Carrier_phase_cycles = new double * [d_nchannels]; + double ** Pseudorange_m = new double * [d_nchannels]; + double ** PRN = new double * [d_nchannels]; + double ** Flag_valid_pseudorange = new double * [d_nchannels]; + + for(unsigned int i = 0; i < d_nchannels; i++) + { + RX_time[i] = new double [num_epoch]; + TOW_at_current_symbol_s[i] = new double[num_epoch]; + Carrier_Doppler_hz[i] = new double[num_epoch]; + Carrier_phase_cycles[i] = new double[num_epoch]; + Pseudorange_m[i] = new double[num_epoch]; + PRN[i] = new double[num_epoch]; + Flag_valid_pseudorange[i] = new double[num_epoch]; + } + + try + { + if (dump_file.is_open()) + { + for(long int i = 0; i < num_epoch; i++) + { + for(unsigned int chan = 0; chan < d_nchannels; chan++) + { + dump_file.read(reinterpret_cast(&RX_time[chan][i]), sizeof(double)); + dump_file.read(reinterpret_cast(&TOW_at_current_symbol_s[chan][i]), sizeof(double)); + dump_file.read(reinterpret_cast(&Carrier_Doppler_hz[chan][i]), sizeof(double)); + dump_file.read(reinterpret_cast(&Carrier_phase_cycles[chan][i]), sizeof(double)); + dump_file.read(reinterpret_cast(&Pseudorange_m[chan][i]), sizeof(double)); + dump_file.read(reinterpret_cast(&PRN[chan][i]), sizeof(double)); + dump_file.read(reinterpret_cast(&Flag_valid_pseudorange[chan][i]), sizeof(double)); + } + } + } + dump_file.close(); + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem reading dump file:" << e.what() << std::endl; + for(unsigned int i = 0; i < d_nchannels; i++) + { + delete[] RX_time[i]; + delete[] TOW_at_current_symbol_s[i]; + delete[] Carrier_Doppler_hz[i]; + delete[] Carrier_phase_cycles[i]; + delete[] Pseudorange_m[i]; + delete[] PRN[i]; + delete[] Flag_valid_pseudorange[i]; + } + delete[] RX_time; + delete[] TOW_at_current_symbol_s; + delete[] Carrier_Doppler_hz; + delete[] Carrier_phase_cycles; + delete[] Pseudorange_m; + delete[] PRN; + delete[] Flag_valid_pseudorange; + + return 1; + } + + double * RX_time_aux = new double [d_nchannels * num_epoch]; + double * TOW_at_current_symbol_s_aux = new double [d_nchannels * num_epoch]; + double * Carrier_Doppler_hz_aux = new double [d_nchannels * num_epoch]; + double * Carrier_phase_cycles_aux = new double [d_nchannels * num_epoch]; + double * Pseudorange_m_aux = new double [d_nchannels * num_epoch]; + double * PRN_aux = new double [d_nchannels * num_epoch]; + double * Flag_valid_pseudorange_aux = new double[d_nchannels * num_epoch]; + unsigned int k = 0; + for(unsigned int j = 0; j < num_epoch; j++ ) + { + for(unsigned int i = 0; i < d_nchannels; i++ ) + { + RX_time_aux[k] = RX_time[i][j]; + TOW_at_current_symbol_s_aux[k] = TOW_at_current_symbol_s[i][j]; + Carrier_Doppler_hz_aux[k] = Carrier_Doppler_hz[i][j]; + Carrier_phase_cycles_aux[k] = Carrier_phase_cycles[i][j]; + Pseudorange_m_aux[k] = Pseudorange_m[i][j]; + PRN_aux[k] = PRN[i][j]; + Flag_valid_pseudorange_aux[k] = Flag_valid_pseudorange[i][j]; + k++; + } + } + + // WRITE MAT FILE + mat_t *matfp; + matvar_t *matvar; + std::string filename = d_dump_filename; + filename.erase(filename.length() - 4, 4); + filename.append(".mat"); + matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); + if(reinterpret_cast(matfp) != NULL) + { + size_t dims[2] = {static_cast(d_nchannels), static_cast(num_epoch)}; + matvar = Mat_VarCreate("RX_time", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, RX_time_aux, MAT_F_DONT_COPY_DATA); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("TOW_at_current_symbol_s", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, TOW_at_current_symbol_s_aux, MAT_F_DONT_COPY_DATA); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Carrier_Doppler_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, Carrier_Doppler_hz_aux, MAT_F_DONT_COPY_DATA); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Carrier_phase_cycles", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, Carrier_phase_cycles_aux, MAT_F_DONT_COPY_DATA); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Pseudorange_m", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, Pseudorange_m_aux, MAT_F_DONT_COPY_DATA); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, PRN_aux, MAT_F_DONT_COPY_DATA); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Flag_valid_pseudorange", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, Flag_valid_pseudorange_aux, MAT_F_DONT_COPY_DATA); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + } + Mat_Close(matfp); + + for(unsigned int i = 0; i < d_nchannels; i++) + { + delete[] RX_time[i]; + delete[] TOW_at_current_symbol_s[i]; + delete[] Carrier_Doppler_hz[i]; + delete[] Carrier_phase_cycles[i]; + delete[] Pseudorange_m[i]; + delete[] PRN[i]; + delete[] Flag_valid_pseudorange[i]; + + } + delete[] RX_time; + delete[] TOW_at_current_symbol_s; + delete[] Carrier_Doppler_hz; + delete[] Carrier_phase_cycles; + delete[] Pseudorange_m; + delete[] PRN; + delete[] Flag_valid_pseudorange; + + delete[] RX_time_aux; + delete[] TOW_at_current_symbol_s_aux; + delete[] Carrier_Doppler_hz_aux; + delete[] Carrier_phase_cycles_aux; + delete[] Pseudorange_m_aux; + delete[] PRN_aux; + delete[] Flag_valid_pseudorange_aux; + return 0; } @@ -149,7 +341,11 @@ int hybrid_observables_cc::general_work (int noutput_items __attribute__((unused double past_history_s = 100e-3; Gnss_Synchro current_gnss_synchro[d_nchannels]; - + Gnss_Synchro aux = Gnss_Synchro(); + for(unsigned int i = 0; i < d_nchannels; i++) + { + current_gnss_synchro[i] = aux; + } /* * 1. Read the GNSS SYNCHRO objects from available channels. * Multi-rate GNURADIO Block. Read how many input items are avaliable in each channel @@ -339,13 +535,13 @@ int hybrid_observables_cc::general_work (int noutput_items __attribute__((unused d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); tmp_double = current_gnss_synchro[i].Carrier_Doppler_hz; d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = current_gnss_synchro[i].Carrier_phase_rads/GPS_TWO_PI; + tmp_double = current_gnss_synchro[i].Carrier_phase_rads / GPS_TWO_PI; d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); tmp_double = current_gnss_synchro[i].Pseudorange_m; d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); tmp_double = current_gnss_synchro[i].PRN; d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = current_gnss_synchro[i].Flag_valid_pseudorange; + tmp_double = static_cast(current_gnss_synchro[i].Flag_valid_pseudorange); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); } } @@ -384,3 +580,4 @@ int hybrid_observables_cc::general_work (int noutput_items __attribute__((unused return n_outputs; } + diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h index 202a8582e..4d7e67338 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.h @@ -72,6 +72,8 @@ private: unsigned int history_deep; std::string d_dump_filename; std::ofstream d_dump_file; + + int save_matfile(); }; #endif From d8c924a2cacb4bb5f745d767109f9b3bd4da853c Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 20 Nov 2017 08:22:04 +0100 Subject: [PATCH 57/60] Fix warning --- .../observables/gnuradio_blocks/hybrid_observables_cc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc index 51259294d..fb30b58ac 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc @@ -214,7 +214,7 @@ int hybrid_observables_cc::save_matfile() double * PRN_aux = new double [d_nchannels * num_epoch]; double * Flag_valid_pseudorange_aux = new double[d_nchannels * num_epoch]; unsigned int k = 0; - for(unsigned int j = 0; j < num_epoch; j++ ) + for(long int j = 0; j < num_epoch; j++ ) { for(unsigned int i = 0; i < d_nchannels; i++ ) { From 72be91ad1f2dd51610f1435777e72130dded9f2e Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 20 Nov 2017 11:02:17 +0100 Subject: [PATCH 58/60] Fix some defects detected by Coverity Scan --- src/tests/common-files/gnuplot_i.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/tests/common-files/gnuplot_i.h b/src/tests/common-files/gnuplot_i.h index 3627a38af..3e9b966c6 100644 --- a/src/tests/common-files/gnuplot_i.h +++ b/src/tests/common-files/gnuplot_i.h @@ -1895,12 +1895,13 @@ bool Gnuplot::get_program_path() else { std::list ls; + std::string path_str = path; //split path (one long string) into list ls of strings #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__) - stringtok(ls,path,";"); + stringtok(ls,path_str,";"); #elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__) - stringtok(ls,path,":"); + stringtok(ls,path_str,":"); #endif // scan list for Gnuplot program files @@ -1921,10 +1922,8 @@ bool Gnuplot::get_program_path() tmp = "Can't find gnuplot neither in PATH nor in \"" + Gnuplot::m_sGNUPlotPath + "\""; - throw GnuplotException(tmp); - Gnuplot::m_sGNUPlotPath = ""; - return false; + throw GnuplotException(tmp); } } @@ -2046,7 +2045,6 @@ std::string Gnuplot::create_tmpfile(std::ofstream &tmp) std::ostringstream except; except << "Cannot create temporary file \"" << name << "\""; throw GnuplotException(except.str()); - return ""; } // @@ -2064,7 +2062,8 @@ void Gnuplot::remove_tmpfiles() if ((tmpfile_list).size() > 0) { for (unsigned int i = 0; i < tmpfile_list.size(); i++) - remove( tmpfile_list[i].c_str() ); + if(remove( tmpfile_list[i].c_str() ) != 0) + std::cout << "Problem closing files" << std::endl; Gnuplot::tmpfile_num -= tmpfile_list.size(); } From 16a5f100cb97534fda51493bf9c8f9e7bc912eaf Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 20 Nov 2017 11:21:23 +0100 Subject: [PATCH 59/60] Remove blanks --- CMakeLists.txt | 2 +- src/tests/CMakeLists.txt | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 967150b27..09e932f15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1450,7 +1450,7 @@ find_package(MATIO) if(NOT MATIO_FOUND) find_package(ZLIB) if(ZLIB_FOUND) - get_filename_component(ZLIB_BASE_DIR ${ZLIB_INCLUDE_DIRS} DIRECTORY) + get_filename_component(ZLIB_BASE_DIR ${ZLIB_INCLUDE_DIRS} DIRECTORY) find_package(HDF5) if(HDF5_FOUND) list(GET HDF5_LIBRARIES 0 HDF5_FIRST_DIR) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index e817b6ca4..04bbf7841 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -416,19 +416,19 @@ if(ENABLE_SYSTEM_TESTING) endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") add_definitions(-DHOST_SYSTEM="${HOST_SYSTEM}") set(TTFF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/ttff_gps_l1.cc) - + # Ensure that ttff is rebuilt if it was previously built and then removed if(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/ttff) - execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${TTFF_SOURCES}) + execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${TTFF_SOURCES}) endif(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/ttff) - + add_executable(ttff ${TTFF_SOURCES} ) if(NOT ${GTEST_DIR_LOCAL}) add_dependencies(ttff gtest-${GNSSSDR_GTEST_LOCAL_VERSION}) else(NOT ${GTEST_DIR_LOCAL}) add_dependencies(ttff gtest) endif(NOT ${GTEST_DIR_LOCAL}) - + target_link_libraries(ttff ${Boost_LIBRARIES} ${GFlags_LIBS} @@ -459,7 +459,7 @@ if(ENABLE_SYSTEM_TESTING) set(POSITION_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/position_test.cc) # Ensure that position_test is rebuilt if it was previously built and then removed if(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/position_test) - execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${POSITION_TEST_SOURCES}) + execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${POSITION_TEST_SOURCES}) endif(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/position_test) add_executable(position_test ${POSITION_TEST_SOURCES}) if(NOT ${GTEST_DIR_LOCAL}) @@ -497,17 +497,17 @@ if(ENABLE_SYSTEM_TESTING) set(OBS_GPS_L1_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/obs_gps_l1_system_test.cc) # Ensure that obs_gps_l1_system_test is rebuilt if it was previously built and then removed if(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) - execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${OBS_GPS_L1_TEST_SOURCES}) + execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${OBS_GPS_L1_TEST_SOURCES}) endif(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) add_executable(obs_gps_l1_system_test ${OBS_GPS_L1_TEST_SOURCES}) - + set(OBS_SYSTEM_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/system-tests/obs_system_test.cc) # Ensure that obs_system_test is rebuilt if it was previously built and then removed if(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test) - execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${OBS_SYSTEM_TEST_SOURCES}) + execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${OBS_SYSTEM_TEST_SOURCES}) endif(NOT EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test) add_executable(obs_system_test ${OBS_SYSTEM_TEST_SOURCES}) - + if(NOT ${GTEST_DIR_LOCAL}) add_dependencies(obs_gps_l1_system_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION} ) add_dependencies(obs_system_test gtest-${GNSSSDR_GTEST_LOCAL_VERSION} ) @@ -522,7 +522,7 @@ if(ENABLE_SYSTEM_TESTING) gnss_sp_libs gnss_rx ${gpstk_libs}) - + target_link_libraries(obs_system_test ${GFlags_LIBS} ${GLOG_LIBRARIES} ${GTEST_LIBRARIES} @@ -535,7 +535,7 @@ if(ENABLE_SYSTEM_TESTING) file(REMOVE ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) endif(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) install(TARGETS obs_gps_l1_system_test RUNTIME DESTINATION bin COMPONENT "obs_gps_l1_system_test") - + if(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test) file(REMOVE ${CMAKE_SOURCE_DIR}/install/obs_system_test) endif(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test) @@ -566,7 +566,7 @@ else(ENABLE_SYSTEM_TESTING) # Avoid working with old executables if they were switched ON and then OFF if(EXISTS ${CMAKE_SOURCE_DIR}/install/ttff) file(REMOVE ${CMAKE_SOURCE_DIR}/install/ttff) - endif(EXISTS ${CMAKE_SOURCE_DIR}/install/ttff) + endif(EXISTS ${CMAKE_SOURCE_DIR}/install/ttff) if(EXISTS ${CMAKE_SOURCE_DIR}/install/position_test) file(REMOVE ${CMAKE_SOURCE_DIR}/install/position_test) endif(EXISTS ${CMAKE_SOURCE_DIR}/install/position_test) @@ -575,7 +575,7 @@ else(ENABLE_SYSTEM_TESTING) endif(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_gps_l1_system_test) if(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test) file(REMOVE ${CMAKE_SOURCE_DIR}/install/obs_system_test) - endif(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test) + endif(EXISTS ${CMAKE_SOURCE_DIR}/install/obs_system_test) endif(ENABLE_SYSTEM_TESTING) From bc78416f52625ebe6f7be507d780a9050e6cc13f Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 20 Nov 2017 12:17:57 +0100 Subject: [PATCH 60/60] Delete variables going out of scope --- .../gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.cc index d1db687ac..9250de398 100755 --- a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.cc @@ -607,9 +607,11 @@ int galileo_e1_dll_pll_veml_tracking_cc::save_matfile() catch (const std::ifstream::failure &e) { std::cerr << "Problem reading dump file:" << e.what() << std::endl; + delete[] abs_VE; delete[] abs_E; delete[] abs_P; delete[] abs_L; + delete[] abs_VL; delete[] Prompt_I; delete[] Prompt_Q; delete[] PRN_start_sample_count; @@ -719,9 +721,11 @@ int galileo_e1_dll_pll_veml_tracking_cc::save_matfile() Mat_VarFree(matvar); } Mat_Close(matfp); + delete[] abs_VE; delete[] abs_E; delete[] abs_P; delete[] abs_L; + delete[] abs_VL; delete[] Prompt_I; delete[] Prompt_Q; delete[] PRN_start_sample_count;