From 324391ef0fc599a388e5bfe1184cc6e1b479325c Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 4 Jul 2022 10:49:18 +0200 Subject: [PATCH 1/2] Avoid Armadillo warnings (operator << deprecated in 11.2) No change in functionality --- .../gnuradio_blocks/kf_vtl_tracking.cc | 84 +++++++++---------- 1 file changed, 38 insertions(+), 46 deletions(-) diff --git a/src/algorithms/tracking/gnuradio_blocks/kf_vtl_tracking.cc b/src/algorithms/tracking/gnuradio_blocks/kf_vtl_tracking.cc index f0fce6afd..69548b4ac 100644 --- a/src/algorithms/tracking/gnuradio_blocks/kf_vtl_tracking.cc +++ b/src/algorithms/tracking/gnuradio_blocks/kf_vtl_tracking.cc @@ -844,18 +844,17 @@ void kf_vtl_tracking::init_kf(double acq_code_phase_chips, double acq_doppler_hz const double Ti = d_correlation_length_ms * 0.001; // state vector: code_phase_chips, carrier_phase_rads, carrier_freq_hz,carrier_freq_rate_hz, code_freq_chips_s d_F = arma::mat(5, 5); - d_F << 1 << 0 << 0 << 0 << Ti << arma::endr - << 0 << 1 << 2.0 * GNSS_PI * Ti << GNSS_PI * (Ti * Ti) << 0 << arma::endr - << 0 << 0 << 1 << Ti << 0 << arma::endr - << 0 << 0 << 0 << 1 << 0 << arma::endr - << 0 << 0 << 0 << 0 << 1 << arma::endr; + d_F = {{1, 0, 0, 0, Ti}, + {0, 1, 2.0 * GNSS_PI * Ti, GNSS_PI * (Ti * Ti), 0}, + {0, 0, 1, Ti, 0}, + {0, 0, 0, 1, 0}, + {0, 0, 0, 0, 1}}; const double B = d_code_chip_rate / d_signal_carrier_freq; // carrier to code rate factor d_H = arma::mat(2, 5); - d_H << 1 << 0 << -B * Ti / 2.0 << B * (Ti * Ti) / 6.0 << 0 << arma::endr - << 0 << 1 << -GNSS_PI * Ti << GNSS_PI * (Ti * Ti) / 3.0 << 0 << arma::endr; - + d_H = {{1, 0, -B * Ti / 2.0, B * (Ti * Ti) / 6.0, 0}, + {0, 1, -GNSS_PI * Ti, GNSS_PI * (Ti * Ti) / 3.0, 0}}; // Phase noise variance // const double CN0_lin = pow(10.0, d_trk_parameters.expected_cn0_dbhz / 10.0); // CN0 in Hz // const double N_periods = 1; // Only 1 interval @@ -866,32 +865,26 @@ void kf_vtl_tracking::init_kf(double acq_code_phase_chips, double acq_doppler_hz d_R = arma::mat(2, 2); // d_R << Sigma2_Tau << 0 << arma::endr // << 0 << Sigma2_Phase << arma::endr; - - d_R << pow(d_trk_parameters.code_disc_sd_chips, 2.0) << 0 << arma::endr - << 0 << pow(d_trk_parameters.carrier_disc_sd_rads, 2.0) << arma::endr; - + d_R = {{pow(d_trk_parameters.code_disc_sd_chips, 2.0), 0}, + {0, pow(d_trk_parameters.carrier_disc_sd_rads, 2.0)}}; // system covariance matrix (static) d_Q = arma::mat(5, 5); - d_Q << pow(d_trk_parameters.code_phase_sd_chips, 2.0) << 0 << 0 << 0 << 0 << arma::endr - << 0 << pow(d_trk_parameters.carrier_phase_sd_rad, 2.0) << 0 << 0 << 0 << arma::endr - << 0 << 0 << pow(d_trk_parameters.carrier_freq_sd_hz, 2.0) << 0 << 0 << arma::endr - << 0 << 0 << 0 << pow(d_trk_parameters.carrier_freq_rate_sd_hz_s, 2.0) << 0 << arma::endr - << 0 << 0 << 0 << 0 << pow(d_trk_parameters.code_rate_sd_chips_s, 2.0) << arma::endr; - + d_Q = {{pow(d_trk_parameters.code_phase_sd_chips, 2.0), 0, 0, 0, 0}, + {0, pow(d_trk_parameters.carrier_phase_sd_rad, 2.0), 0, 0, 0}, + {0, 0, pow(d_trk_parameters.carrier_freq_sd_hz, 2.0), 0, 0}, + {0, 0, 0, pow(d_trk_parameters.carrier_freq_rate_sd_hz_s, 2.0), 0}, + {0, 0, 0, 0, pow(d_trk_parameters.code_rate_sd_chips_s, 2.0)}}; // initial Kalman covariance matrix d_P_old_old = arma::mat(5, 5); - - d_P_old_old << pow(d_trk_parameters.init_code_phase_sd_chips, 2.0) << 0 << 0 << 0 << 0 << arma::endr - << 0 << pow(d_trk_parameters.init_carrier_phase_sd_rad, 2.0) << 0 << 0 << 0 << arma::endr - << 0 << 0 << pow(d_trk_parameters.init_carrier_freq_sd_hz, 2.0) << 0 << 0 << arma::endr - << 0 << 0 << 0 << pow(d_trk_parameters.init_carrier_freq_rate_sd_hz_s, 2.0) << 0 << arma::endr - << 0 << 0 << 0 << 0 << pow(d_trk_parameters.init_code_rate_sd_chips_s, 2.0) << arma::endr; - + d_P_old_old = {{pow(d_trk_parameters.init_code_phase_sd_chips, 2.0), 0, 0, 0, 0}, + {0, pow(d_trk_parameters.init_carrier_phase_sd_rad, 2.0), 0, 0, 0}, + {0, 0, pow(d_trk_parameters.init_carrier_freq_rate_sd_hz_s, 2.0), 0, 0}, + {0, 0, 0, pow(d_trk_parameters.init_carrier_freq_rate_sd_hz_s, 2.0), 0}, + {0, 0, 0, 0, pow(d_trk_parameters.init_code_rate_sd_chips_s, 2.0)}}; // init state vector d_x_old_old = arma::vec(5); // states: code_phase_chips, carrier_phase_rads, carrier_freq_hz, carrier_freq_rate_hz_s, code_freq_rate_chips_s - d_x_old_old << acq_code_phase_chips << 0 << acq_doppler_hz << 0 << 0 << arma::endr; - + d_x_old_old = {acq_code_phase_chips, 0, acq_doppler_hz, 0, 0}; // std::cout << "F: " << d_F << "\n"; // std::cout << "H: " << d_H << "\n"; // std::cout << "R: " << d_R << "\n"; @@ -907,27 +900,26 @@ void kf_vtl_tracking::update_kf_narrow_integration_time() const double Ti = d_current_correlation_time_s; // state vector: code_phase_chips, carrier_phase_rads, carrier_freq_hz,carrier_freq_rate_hz, code_freq_chips_s - d_F << 1 << 0 << 0 << 0 << Ti << arma::endr - << 0 << 1 << 2.0 * GNSS_PI * Ti << GNSS_PI * (Ti * Ti) << 0 << arma::endr - << 0 << 0 << 1 << Ti << 0 << arma::endr - << 0 << 0 << 0 << 1 << 0 << arma::endr - << 0 << 0 << 0 << 0 << 1 << arma::endr; - + d_F = {{1, 0, 0, 0, Ti}, + {0, 1, 2.0 * GNSS_PI * Ti, GNSS_PI * (Ti * Ti), 0}, + {0, 0, 1, Ti, 0}, + {0, 0, 0, 1, 0}, + {0, 0, 0, 0, 1}}; const double B = d_code_chip_rate / d_signal_carrier_freq; // carrier to code rate factor - d_H << 1 << 0 << -B * Ti / 2.0 << B * (Ti * Ti) / 6.0 << 0 << arma::endr - << 0 << 1 << -GNSS_PI * Ti << GNSS_PI * (Ti * Ti) / 3.0 << 0 << arma::endr; + d_H = {{1, 0, -B * Ti / 2.0, B * (Ti * Ti) / 6.0, 0}, + {0, 1, -GNSS_PI * Ti, GNSS_PI * (Ti * Ti) / 3.0, 0}}; // measurement covariance matrix (static) - d_R << pow(d_trk_parameters.code_disc_sd_chips, 2.0) << 0 << arma::endr - << 0 << pow(d_trk_parameters.carrier_disc_sd_rads, 2.0) << arma::endr; + d_R = {{pow(d_trk_parameters.code_disc_sd_chips, 2.0), 0}, + {0, pow(d_trk_parameters.carrier_disc_sd_rads, 2.0)}}; // system covariance matrix (static) - d_Q << pow(d_trk_parameters.narrow_code_phase_sd_chips, 2.0) << 0 << 0 << 0 << 0 << arma::endr - << 0 << pow(d_trk_parameters.narrow_carrier_phase_sd_rad, 2.0) << 0 << 0 << 0 << arma::endr - << 0 << 0 << pow(d_trk_parameters.narrow_carrier_freq_sd_hz, 2.0) << 0 << 0 << arma::endr - << 0 << 0 << 0 << pow(d_trk_parameters.narrow_carrier_freq_rate_sd_hz_s, 2.0) << 0 << arma::endr - << 0 << 0 << 0 << 0 << pow(d_trk_parameters.narrow_code_rate_sd_chips_s, 2.0) << arma::endr; + d_Q = {{pow(d_trk_parameters.narrow_code_phase_sd_chips, 2.0), 0, 0, 0, 0}, + {0, pow(d_trk_parameters.narrow_carrier_phase_sd_rad, 2.0), 0, 0, 0}, + {0, 0, pow(d_trk_parameters.narrow_carrier_freq_sd_hz, 2.0), 0, 0}, + {0, 0, 0, pow(d_trk_parameters.narrow_carrier_freq_rate_sd_hz_s, 2.0), 0}, + {0, 0, 0, 0, pow(d_trk_parameters.narrow_code_rate_sd_chips_s, 2.0)}}; } @@ -938,8 +930,8 @@ void kf_vtl_tracking::update_kf_cn0(double current_cn0_dbhz) const double B = d_code_chip_rate / d_signal_carrier_freq; // carrier to code rate factor d_H = arma::mat(2, 5); - d_H << 1 << 0 << -B * Ti / 2.0 << B * (Ti * Ti) / 6.0 << 0 << arma::endr - << 0 << 1 << -GNSS_PI * Ti << GNSS_PI * (Ti * Ti) / 3.0 << 0 << arma::endr; + d_H = {{1, 0, -B * Ti / 2.0, B * (Ti * Ti) / 6.0, 0}, + {0, 1, -GNSS_PI * Ti, GNSS_PI * (Ti * Ti) / 3.0, 0}}; // Phase noise variance const double CN0_lin = pow(10.0, current_cn0_dbhz / 10.0); // CN0 in Hz @@ -949,8 +941,8 @@ void kf_vtl_tracking::update_kf_cn0(double current_cn0_dbhz) // measurement covariance matrix (static) d_R = arma::mat(2, 2); - d_R << Sigma2_Tau << 0 << arma::endr - << 0 << Sigma2_Phase << arma::endr; + d_R = {{Sigma2_Tau, 0}, + {0, Sigma2_Phase}}; } From cb52bc71e86346dc801534d2a98e914b907af2db Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 4 Jul 2022 10:50:21 +0200 Subject: [PATCH 2/2] Fix building in Debug mode with Googletest 1.12.1 --- src/tests/CMakeLists.txt | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index d73362ad2..8d0dc49b9 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -43,6 +43,11 @@ if(NOT GOOGLETEST_FOUND) else() set(GOOGLETEST_GIT_TAG release-${GNSSSDR_GTEST_LOCAL_VERSION}) endif() + if(GNSSSDR_GTEST_LOCAL_VERSION VERSION_LESS 1.12.0) + set(DEBUG_DECORATION "d") + else() + set(DEBUG_DECORATION "") + endif() if(CMAKE_VERSION VERSION_LESS 3.2) ExternalProject_Add(gtest-${GNSSSDR_GTEST_LOCAL_VERSION} GIT_REPOSITORY https://github.com/google/googletest @@ -65,11 +70,12 @@ if(NOT GOOGLETEST_FOUND) ${CMAKE_BINARY_DIR}/gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} ${CMAKE_BINARY_DIR}/gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX} ) + if((CMAKE_BUILD_TYPE STREQUAL Debug) OR (CMAKE_BUILD_TYPE STREQUAL NoOptWithASM) OR (CMAKE_BUILD_TYPE STREQUAL Coverage) OR (CMAKE_BUILD_TYPE STREQUAL ASAN)) # Workaround for Ninja generator set(GOOGLETEST_BUILD_BYPRODUCTS - ${CMAKE_BINARY_DIR}/gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtestd${CMAKE_STATIC_LIBRARY_SUFFIX} - ${CMAKE_BINARY_DIR}/gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_maind${CMAKE_STATIC_LIBRARY_SUFFIX} + ${CMAKE_BINARY_DIR}/gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${DEBUG_DECORATION}${CMAKE_STATIC_LIBRARY_SUFFIX} + ${CMAKE_BINARY_DIR}/gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${DEBUG_DECORATION}${CMAKE_STATIC_LIBRARY_SUFFIX} ) endif() ExternalProject_Add(gtest-${GNSSSDR_GTEST_LOCAL_VERSION} @@ -105,20 +111,20 @@ if(NOT GOOGLETEST_FOUND) MAP_IMPORTED_CONFIG_O3WITHASM RelWithDebInfo MAP_IMPORTED_CONFIG_ASAN Debug IMPORTED_LOCATION_NONE ${binary_dir}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} - IMPORTED_LOCATION_DEBUG ${binary_dir}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtestd${CMAKE_STATIC_LIBRARY_SUFFIX} + IMPORTED_LOCATION_DEBUG ${binary_dir}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${DEBUG_DECORATION}${CMAKE_STATIC_LIBRARY_SUFFIX} IMPORTED_LOCATION_RELEASE ${binary_dir}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} IMPORTED_LOCATION_RELWITHDEBINFO ${binary_dir}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} IMPORTED_LOCATION_MINSIZEREL ${binary_dir}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/thirdparty/gtest/gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/googletest/include - INTERFACE_LINK_LIBRARIES ${binary_dir}/lib/gtest$<$:d>${CMAKE_STATIC_LIBRARY_SUFFIX} + INTERFACE_LINK_LIBRARIES ${binary_dir}/lib/gtest$<$:${DEBUG_DECORATION}>${CMAKE_STATIC_LIBRARY_SUFFIX} ) if((CMAKE_GENERATOR STREQUAL Xcode) OR MSVC) set_target_properties(GTest::GTest PROPERTIES - IMPORTED_LOCATION_DEBUG ${binary_dir}/lib/Debug/${CMAKE_FIND_LIBRARY_PREFIXES}gtestd${CMAKE_STATIC_LIBRARY_SUFFIX} + IMPORTED_LOCATION_DEBUG ${binary_dir}/lib/Debug/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${DEBUG_DECORATION}${CMAKE_STATIC_LIBRARY_SUFFIX} IMPORTED_LOCATION_RELEASE ${binary_dir}/lib/Release/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} IMPORTED_LOCATION_RELWITHDEBINFO ${binary_dir}/lib/RelWithDebInfo/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} IMPORTED_LOCATION_MINSIZEREL ${binary_dir}/lib/MinSizeRel/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} - INTERFACE_LINK_LIBRARIES ${binary_dir}/lib/$<$:Debug/>$<$:Release/>$<$:RelWithDebInfo/>$<$:MinSizeRel/>gtest$<$:d>${CMAKE_STATIC_LIBRARY_SUFFIX} + INTERFACE_LINK_LIBRARIES ${binary_dir}/lib/$<$:Debug/>$<$:Release/>$<$:RelWithDebInfo/>$<$:MinSizeRel/>gtest$<$:${DEBUG_DECORATION}>${CMAKE_STATIC_LIBRARY_SUFFIX} ) endif() set_target_properties(GTest::GTest PROPERTIES @@ -137,20 +143,20 @@ if(NOT GOOGLETEST_FOUND) MAP_IMPORTED_CONFIG_O3WITHASM RelWithDebInfo MAP_IMPORTED_CONFIG_ASAN Debug IMPORTED_LOCATION_NONE ${binary_dir}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX} - IMPORTED_LOCATION_DEBUG ${binary_dir}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_maind${CMAKE_STATIC_LIBRARY_SUFFIX} + IMPORTED_LOCATION_DEBUG ${binary_dir}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${DEBUG_DECORATION}${CMAKE_STATIC_LIBRARY_SUFFIX} IMPORTED_LOCATION_RELEASE ${binary_dir}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX} IMPORTED_LOCATION_RELWITHDEBINFO ${binary_dir}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX} IMPORTED_LOCATION_MINSIZEREL ${binary_dir}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX} INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/thirdparty/gtest/gtest-${GNSSSDR_GTEST_LOCAL_VERSION}/googletest/include - INTERFACE_LINK_LIBRARIES ${binary_dir}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main$<$:d>${CMAKE_STATIC_LIBRARY_SUFFIX} + INTERFACE_LINK_LIBRARIES ${binary_dir}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main$<$:${DEBUG_DECORATION}>${CMAKE_STATIC_LIBRARY_SUFFIX} ) if((CMAKE_GENERATOR STREQUAL Xcode) OR MSVC) set_target_properties(GTest::Main PROPERTIES - IMPORTED_LOCATION_DEBUG ${binary_dir}/lib/Debug/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_maind${CMAKE_STATIC_LIBRARY_SUFFIX} + IMPORTED_LOCATION_DEBUG ${binary_dir}/lib/Debug/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${DEBUG_DECORATION}${CMAKE_STATIC_LIBRARY_SUFFIX} IMPORTED_LOCATION_RELEASE ${binary_dir}/lib/Release/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX} IMPORTED_LOCATION_RELWITHDEBINFO ${binary_dir}/lib/RelWithDebInfo/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX} IMPORTED_LOCATION_MINSIZEREL ${binary_dir}/lib/MinSizeRel/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX} - INTERFACE_LINK_LIBRARIES ${binary_dir}/lib/$<$:Debug/>$<$:Release/>$<$:RelWithDebInfo/>$<$:MinSizeRel/>${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main$<$:d>${CMAKE_STATIC_LIBRARY_SUFFIX} + INTERFACE_LINK_LIBRARIES ${binary_dir}/lib/$<$:Debug/>$<$:Release/>$<$:RelWithDebInfo/>$<$:MinSizeRel/>${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main$<$:${DEBUG_DECORATION}>${CMAKE_STATIC_LIBRARY_SUFFIX} ) endif() endif()