diff --git a/docs/changelog b/docs/changelog index f4fe83fe7..500dbe45b 100644 --- a/docs/changelog +++ b/docs/changelog @@ -45,6 +45,7 @@ SPDX-License-Identifier: GPL-3.0-or-later - Rewriting of acquisition and tracking adapters, thus avoiding a lot of code duplication. - New CMake option ENABLE_ARMA_NO_DEBUG defines the macro ARMA_NO_DEBUG, which disables all run-time checks, such as bounds checking, in the Armadillo library. This will result in faster code. This option is disabled by default during development, but automatically set to ON if the option ENABLE_PACKAGING is set to ON. +- All shadowed variables detected by passing -Wshadow to the compiler have been fixed (see https://rules.sonarsource.com/cpp/RSPEC-1117?search=shadow). - Apply more clang-tidy checks related to readability: readability-avoid-const-params-in-decls, readability-braces-around-statements, readability-isolate-declaration, readability-redundant-control-flow, readability-uppercase-literal-suffix. Fixed raised warnings. - Fixed a number of defects detected by cpplint.py. Filters applied: +build/class,+build/c++14,+build/deprecated,+build/explicit_make_pair,+build/include_what_you_use,+build/printf_format,+build/storage_class,+readability/constructors,+readability/namespace,+readability/newline,+readability/utf8,+runtime/casting,+runtime/explicit,+runtime/indentation_namespace,+runtime/init,+runtime/invalid_increment,+runtime/member_string_references,+runtime/memset,+runtime/operator,+runtime/printf,+runtime/printf_format,+whitespace/blank_line. - clang-format can now be applied to the whole code tree without breaking compilation. diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index 2137b7b5e..bf6ae5a28 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -3769,7 +3769,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map 16) { - std::string decimal(timestring, 16, 1); + decimal = std::string(timestring, 16, 1); } line += decimal; line += std::string(1, ' '); @@ -4184,8 +4184,8 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.d_OMEGA, 18, 2); line += std::string(1, ' '); const double OMEGA_DOT_REF = -2.6e-9; // semicircles / s, see IS-GPS-200K pp. 164 - double OMEGA_DOT = OMEGA_DOT_REF + gps_ephemeris_iter->second.d_DELTA_OMEGA_DOT; - line += Rinex_Printer::doub2for(OMEGA_DOT, 18, 2); + double OMEGA_DOT_aux = OMEGA_DOT_REF + gps_ephemeris_iter->second.d_DELTA_OMEGA_DOT; + line += Rinex_Printer::doub2for(OMEGA_DOT_aux, 18, 2); Rinex_Printer::lengthCheck(line); out << line << std::endl; @@ -4528,7 +4528,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map 16) { - std::string decimal(timestring, 16, 1); + decimal = std::string(timestring, 16, 1); } line += decimal; line += std::string(1, ' '); diff --git a/src/algorithms/PVT/libs/rtcm.cc b/src/algorithms/PVT/libs/rtcm.cc index e78f42faa..65840b3bd 100644 --- a/src/algorithms/PVT/libs/rtcm.cc +++ b/src/algorithms/PVT/libs/rtcm.cc @@ -3388,15 +3388,15 @@ std::map Rtcm::galileo_signal_map = [] { boost::posix_time::ptime Rtcm::compute_GPS_time(const Gps_Ephemeris& eph, double obs_time) const { const double gps_t = obs_time; - boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(eph.i_GPS_week)) * 1000)); // NOLINT(google-runtime-int) + boost::posix_time::time_duration t_duration = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(eph.i_GPS_week)) * 1000)); // NOLINT(google-runtime-int) if (eph.i_GPS_week < 512) { - boost::posix_time::ptime p_time(boost::gregorian::date(2019, 4, 7), t); + boost::posix_time::ptime p_time(boost::gregorian::date(2019, 4, 7), t_duration); return p_time; } - boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t); + boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t_duration); return p_time; } @@ -3404,8 +3404,8 @@ boost::posix_time::ptime Rtcm::compute_GPS_time(const Gps_Ephemeris& eph, double boost::posix_time::ptime Rtcm::compute_GPS_time(const Gps_CNAV_Ephemeris& eph, double obs_time) const { const double gps_t = obs_time; - boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(eph.i_GPS_week)) * 1000)); // NOLINT(google-runtime-int) - boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t); + boost::posix_time::time_duration t_duration = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(eph.i_GPS_week)) * 1000)); // NOLINT(google-runtime-int) + boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t_duration); return p_time; } @@ -3413,8 +3413,8 @@ boost::posix_time::ptime Rtcm::compute_GPS_time(const Gps_CNAV_Ephemeris& eph, d boost::posix_time::ptime Rtcm::compute_Galileo_time(const Galileo_Ephemeris& eph, double obs_time) const { double galileo_t = obs_time; - boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((galileo_t + 604800 * static_cast(eph.WN_5)) * 1000)); // NOLINT(google-runtime-int) - boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t); + boost::posix_time::time_duration t_duration = boost::posix_time::milliseconds(static_cast((galileo_t + 604800 * static_cast(eph.WN_5)) * 1000)); // NOLINT(google-runtime-int) + boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t_duration); return p_time; } @@ -4206,16 +4206,16 @@ int32_t Rtcm::set_DF050(const Gnss_Synchro& gnss_synchro) int32_t Rtcm::set_DF051(const Gps_Ephemeris& gps_eph, double obs_time) { const double gps_t = obs_time; - boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(gps_eph.i_GPS_week)) * 1000)); + boost::posix_time::time_duration t_duration = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(gps_eph.i_GPS_week)) * 1000)); std::string now_ptime; if (gps_eph.i_GPS_week < 512) { - boost::posix_time::ptime p_time(boost::gregorian::date(2019, 4, 7), t); + boost::posix_time::ptime p_time(boost::gregorian::date(2019, 4, 7), t_duration); now_ptime = to_iso_string(p_time); } else { - boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t); + boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t_duration); now_ptime = to_iso_string(p_time); } std::string today_ptime = now_ptime.substr(0, 8); @@ -4229,16 +4229,16 @@ int32_t Rtcm::set_DF051(const Gps_Ephemeris& gps_eph, double obs_time) int32_t Rtcm::set_DF052(const Gps_Ephemeris& gps_eph, double obs_time) { const double gps_t = obs_time; - boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(gps_eph.i_GPS_week)) * 1000)); + boost::posix_time::time_duration t_duration = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(gps_eph.i_GPS_week)) * 1000)); std::string now_ptime; if (gps_eph.i_GPS_week < 512) { - boost::posix_time::ptime p_time(boost::gregorian::date(2019, 4, 7), t); + boost::posix_time::ptime p_time(boost::gregorian::date(2019, 4, 7), t_duration); now_ptime = to_iso_string(p_time); } else { - boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t); + boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t_duration); now_ptime = to_iso_string(p_time); } std::string hours = now_ptime.substr(9, 2); @@ -4649,8 +4649,8 @@ int32_t Rtcm::set_DF119(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF120(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - uint32_t P3 = static_cast(std::round(glonass_gnav_eph.d_P_3)); - DF120 = std::bitset<1>(P3); + auto P3_aux = static_cast(std::round(glonass_gnav_eph.d_P_3)); + DF120 = std::bitset<1>(P3_aux); return 0; } @@ -4668,8 +4668,8 @@ int32_t Rtcm::set_DF121(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF122(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto P = static_cast(std::round(glonass_gnav_eph.d_P)); - DF122 = std::bitset<2>(P); + auto P_aux = static_cast(std::round(glonass_gnav_eph.d_P)); + DF122 = std::bitset<2>(P_aux); return 0; } @@ -4714,8 +4714,8 @@ int32_t Rtcm::set_DF126(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF127(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto P4 = static_cast(std::round(glonass_gnav_eph.d_P_4)); - DF127 = std::bitset<1>(P4); + auto P4_aux = static_cast(std::round(glonass_gnav_eph.d_P_4)); + DF127 = std::bitset<1>(P4_aux); return 0; } @@ -4738,8 +4738,8 @@ int32_t Rtcm::set_DF129(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) int32_t Rtcm::set_DF130(const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - auto M = static_cast(std::round(glonass_gnav_eph.d_M)); - DF130 = std::bitset<2>(M); + auto M_aux = static_cast(std::round(glonass_gnav_eph.d_M)); + DF130 = std::bitset<2>(M_aux); return 0; } @@ -4754,8 +4754,8 @@ int32_t Rtcm::set_DF131(uint32_t fifth_str_additional_data_ind) int32_t Rtcm::set_DF132(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) { - auto N_A = static_cast(std::round(glonass_gnav_utc_model.d_N_A)); - DF132 = std::bitset<11>(N_A); + auto N_A_aux = static_cast(std::round(glonass_gnav_utc_model.d_N_A)); + DF132 = std::bitset<11>(N_A_aux); return 0; } @@ -4770,8 +4770,8 @@ int32_t Rtcm::set_DF133(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) int32_t Rtcm::set_DF134(const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) { - auto N_4 = static_cast(std::round(glonass_gnav_utc_model.d_N_4)); - DF134 = std::bitset<5>(N_4); + auto N_4_aux = static_cast(std::round(glonass_gnav_utc_model.d_N_4)); + DF134 = std::bitset<5>(N_4_aux); return 0; } 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 5efe66f74..770a00aee 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 @@ -224,10 +224,10 @@ void read_results(std::vector *results, std::string found = 127; } str_size = config_str.size(); - char buffer[128] = {'\0'}; - config_str.copy(buffer, found + 1, 0); - buffer[found] = '\0'; - single_kernel_result.push_back(std::string(buffer)); + char buffer_aux[128] = {'\0'}; + config_str.copy(buffer_aux, found + 1, 0); + buffer_aux[found] = '\0'; + single_kernel_result.push_back(std::string(buffer_aux)); config_str.erase(0, found + 1); } diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_8i_max_s8i.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_8i_max_s8i.h index 0cf2dab6f..99fe43393 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_8i_max_s8i.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_8i_max_s8i.h @@ -359,17 +359,17 @@ static inline void volk_gnsssdr_8i_max_s8i_a_sse2(char* target, const char* src0 { _mm_store_si128((__m128i*)¤tValuesBuffer, currentValues); mask = ~mask; - int i = 0; + int i32 = 0; while (mask > 0) { if ((mask & 1) == 1) { - if (currentValuesBuffer[i] > max) + if (currentValuesBuffer[i32] > max) { - max = currentValuesBuffer[i]; + max = currentValuesBuffer[i32]; } } - i++; + i32++; mask >>= 1; } maxValues = _mm_set1_epi8(max); diff --git a/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.cc b/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.cc index 6ac3b4a86..abad46c6c 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.cc @@ -23,9 +23,9 @@ #include #include -unpack_spir_gss6450_samples_sptr make_unpack_spir_gss6450_samples(unsigned int adc_nbit) +unpack_spir_gss6450_samples_sptr make_unpack_spir_gss6450_samples(unsigned int adc_nbit_) { - return unpack_spir_gss6450_samples_sptr(new unpack_spir_gss6450_samples(adc_nbit)); + return unpack_spir_gss6450_samples_sptr(new unpack_spir_gss6450_samples(adc_nbit_)); } @@ -38,12 +38,12 @@ unpack_spir_gss6450_samples::unpack_spir_gss6450_samples(unsigned int adc_nbit) } -void unpack_spir_gss6450_samples::decode_4bits_word(uint32_t input_uint32, gr_complex* out, int adc_bits) +void unpack_spir_gss6450_samples::decode_4bits_word(uint32_t input_uint32, gr_complex* out, int adc_bits_) { int8_t tmp_char; float Q; float I; - switch (adc_bits) + switch (adc_bits_) { case 2: // four bits per complex sample (2 I + 2 Q), 8 samples per int32[s0,s1,s2,s3,s4,s5,s6,s7] diff --git a/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.h b/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.h index 4032a29f5..53f3fa338 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.h +++ b/src/algorithms/signal_source/gnuradio_blocks/unpack_spir_gss6450_samples.h @@ -27,7 +27,7 @@ class unpack_spir_gss6450_samples; using unpack_spir_gss6450_samples_sptr = boost::shared_ptr; -unpack_spir_gss6450_samples_sptr make_unpack_spir_gss6450_samples(unsigned int adc_nbit); +unpack_spir_gss6450_samples_sptr make_unpack_spir_gss6450_samples(unsigned int adc_nbit_); class unpack_spir_gss6450_samples : public gr::sync_interpolator @@ -36,7 +36,7 @@ public: int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); friend unpack_spir_gss6450_samples_sptr make_unpack_spir_gss6450_samples_sptr(unsigned int adc_nbit); - void decode_4bits_word(uint32_t input_uint32, gr_complex *out, int adc_bits); + void decode_4bits_word(uint32_t input_uint32, gr_complex *out, int adc_bits_); explicit unpack_spir_gss6450_samples(unsigned int adc_nbit); ~unpack_spir_gss6450_samples() = default; diff --git a/src/algorithms/signal_source/libs/ad9361_manager.cc b/src/algorithms/signal_source/libs/ad9361_manager.cc index acd51536f..94f847689 100644 --- a/src/algorithms/signal_source/libs/ad9361_manager.cc +++ b/src/algorithms/signal_source/libs/ad9361_manager.cc @@ -1061,7 +1061,9 @@ bool load_fir_filter( std::string line(buf); if (line.find(',') == std::string::npos) - throw std::runtime_error("Incompatible filter file"); + { + throw std::runtime_error("Incompatible filter file"); + } } ifs.seekg(0, ifs.end); diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.cc index 13461e8ce..8103f9754 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.cc @@ -432,8 +432,8 @@ int32_t Gps_L1_Ca_Kf_Tracking_cc::save_matfile() auto carr_error_hz = std::vector(num_epoch); auto carr_noise_sigma2 = std::vector(num_epoch); auto carr_error_filt_hz = std::vector(num_epoch); - auto code_error_chips = std::vector(num_epoch); - auto code_error_filt_chips = std::vector(num_epoch); + auto code_error_chips_aux = std::vector(num_epoch); + auto code_error_filt_chips_aux = std::vector(num_epoch); auto CN0_SNV_dB_Hz = std::vector(num_epoch); auto carrier_lock_test = std::vector(num_epoch); auto aux1 = std::vector(num_epoch); @@ -461,8 +461,8 @@ int32_t Gps_L1_Ca_Kf_Tracking_cc::save_matfile() dump_file.read(reinterpret_cast(&carr_error_hz[i]), sizeof(float)); dump_file.read(reinterpret_cast(&carr_noise_sigma2[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(&code_error_chips_aux[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&code_error_filt_chips_aux[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)); @@ -548,11 +548,11 @@ int32_t Gps_L1_Ca_Kf_Tracking_cc::save_matfile() 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.data(), code_error_chips.data(), 0); + matvar = Mat_VarCreate("code_error_chips", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims.data(), code_error_chips_aux.data(), 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.data(), code_error_filt_chips.data(), 0); + matvar = Mat_VarCreate("code_error_filt_chips", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims.data(), code_error_filt_chips_aux.data(), 0); Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE Mat_VarFree(matvar); @@ -619,8 +619,8 @@ int Gps_L1_Ca_Kf_Tracking_cc::general_work(int noutput_items __attribute__((unus { // process vars d_carr_phase_error_rad = 0.0; - double code_error_chips = 0.0; - double code_error_filt_chips = 0.0; + code_error_chips = 0.0; + code_error_filt_chips = 0.0; // Block input data and block output stream pointers const auto *in = reinterpret_cast(input_items[0]); diff --git a/src/core/libs/gnss_sdr_supl_client.cc b/src/core/libs/gnss_sdr_supl_client.cc index 892b8c856..2cbd8a6db 100644 --- a/src/core/libs/gnss_sdr_supl_client.cc +++ b/src/core/libs/gnss_sdr_supl_client.cc @@ -802,16 +802,16 @@ bool Gnss_Sdr_Supl_Client::load_gps_almanac_xml(const std::string& file_name) } -bool Gnss_Sdr_Supl_Client::save_gps_almanac_xml(const std::string& file_name, std::map gps_almanac_map) +bool Gnss_Sdr_Supl_Client::save_gps_almanac_xml(const std::string& file_name, std::map gps_almanac_map_to_save) { - if (gps_almanac_map.empty() == false) + if (gps_almanac_map_to_save.empty() == false) { std::ofstream ofs; try { ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_gps_almanac_map", gps_almanac_map); + xml << boost::serialization::make_nvp("GNSS-SDR_gps_almanac_map", gps_almanac_map_to_save); LOG(INFO) << "Saved GPS almanac data"; } catch (std::exception& e) @@ -899,16 +899,16 @@ bool Gnss_Sdr_Supl_Client::read_gal_almanac_from_gsa(const std::string& file_nam } -bool Gnss_Sdr_Supl_Client::save_gal_almanac_xml(const std::string& file_name, std::map gal_almanac_map) +bool Gnss_Sdr_Supl_Client::save_gal_almanac_xml(const std::string& file_name, std::map galileo_almanac_map_to_save) { - if (gal_almanac_map.empty() == false) + if (galileo_almanac_map_to_save.empty() == false) { std::ofstream ofs; try { ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out); boost::archive::xml_oarchive xml(ofs); - xml << boost::serialization::make_nvp("GNSS-SDR_gal_almanac_map", gal_almanac_map); + xml << boost::serialization::make_nvp("GNSS-SDR_gal_almanac_map", galileo_almanac_map_to_save); LOG(INFO) << "Saved Galileo almanac data"; } catch (std::exception& e) diff --git a/src/core/libs/gnss_sdr_supl_client.h b/src/core/libs/gnss_sdr_supl_client.h index 2dd70b054..326fc65ba 100644 --- a/src/core/libs/gnss_sdr_supl_client.h +++ b/src/core/libs/gnss_sdr_supl_client.h @@ -182,7 +182,7 @@ public: /*! * \brief Save Galileo almanac map to XML file */ - bool save_gal_almanac_xml(const std::string& file_name, std::map gal_almanac); + bool save_gal_almanac_xml(const std::string& file_name, std::map galileo_almanac_map_to_save); /*! * \brief Read GPS almanac map from XML file @@ -192,7 +192,7 @@ public: /*! * \brief Save GPS almanac map to XML file */ - bool save_gps_almanac_xml(const std::string& file_name, std::map gps_almanac_map); + bool save_gps_almanac_xml(const std::string& file_name, std::map gps_almanac_map_to_save); /*! * \brief Read iono from XML file diff --git a/src/core/receiver/file_configuration.cc b/src/core/receiver/file_configuration.cc index 9cc942d11..ea57f23b4 100644 --- a/src/core/receiver/file_configuration.cc +++ b/src/core/receiver/file_configuration.cc @@ -27,7 +27,6 @@ #include "in_memory_configuration.h" #include "string_converter.h" #include -#include #include @@ -45,12 +44,6 @@ FileConfiguration::FileConfiguration() } -FileConfiguration::~FileConfiguration() -{ - LOG(INFO) << "Destructor called"; -} - - std::string FileConfiguration::property(std::string property_name, std::string default_value) { if (overrided_->is_present(property_name)) @@ -168,7 +161,7 @@ void FileConfiguration::set_property(std::string property_name, std::string valu void FileConfiguration::init() { - std::unique_ptr converter_(new StringConverter); + converter_ = std::make_shared(); overrided_ = std::make_shared(); ini_reader_ = std::make_shared(filename_); error_ = ini_reader_->ParseError(); diff --git a/src/core/receiver/file_configuration.h b/src/core/receiver/file_configuration.h index bb2fb0ec4..c03ebd540 100644 --- a/src/core/receiver/file_configuration.h +++ b/src/core/receiver/file_configuration.h @@ -48,8 +48,7 @@ class FileConfiguration : public ConfigurationInterface public: explicit FileConfiguration(std::string filename); FileConfiguration(); - //! Virtual destructor - ~FileConfiguration(); + ~FileConfiguration() = default; std::string property(std::string property_name, std::string default_value); bool property(std::string property_name, bool default_value); int64_t property(std::string property_name, int64_t default_value); @@ -67,7 +66,7 @@ private: std::string filename_; std::shared_ptr ini_reader_; std::shared_ptr overrided_; - std::unique_ptr converter_; + std::shared_ptr converter_; int error_{}; }; diff --git a/src/core/receiver/in_memory_configuration.cc b/src/core/receiver/in_memory_configuration.cc index 181c2df36..607671c37 100644 --- a/src/core/receiver/in_memory_configuration.cc +++ b/src/core/receiver/in_memory_configuration.cc @@ -21,13 +21,13 @@ #include "in_memory_configuration.h" #include "string_converter.h" -#include #include InMemoryConfiguration::InMemoryConfiguration() { - std::unique_ptr converter_(new StringConverter); + std::unique_ptr converter_aux(new StringConverter); + converter_ = std::move(converter_aux); } diff --git a/src/core/receiver/in_memory_configuration.h b/src/core/receiver/in_memory_configuration.h index 7e17f64fe..99627cc45 100644 --- a/src/core/receiver/in_memory_configuration.h +++ b/src/core/receiver/in_memory_configuration.h @@ -43,7 +43,7 @@ class InMemoryConfiguration : public ConfigurationInterface { public: InMemoryConfiguration(); - virtual ~InMemoryConfiguration(); + ~InMemoryConfiguration(); std::string property(std::string property_name, std::string default_value); bool property(std::string property_name, bool default_value); int64_t property(std::string property_name, int64_t default_value); diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc index be03c4f54..76d6cc22e 100644 --- a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc @@ -284,7 +284,6 @@ public: uint32_t smoother_length, bool high_dyn); - gr::top_block_sptr top_block; std::shared_ptr factory; std::shared_ptr config; Gnss_Synchro gnss_synchro_master; @@ -342,8 +341,8 @@ int HybridObservablesTest::generate_signal() bool HybridObservablesTest::acquire_signal() { // 1. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) - gr::top_block_sptr top_block; - top_block = gr::make_top_block("Acquisition test"); + gr::top_block_sptr top_block_acq; + top_block_acq = gr::make_top_block("Acquisition test"); int SV_ID = 1; // initial sv id // Satellite signal definition Gnss_Synchro tmp_gnss_synchro; @@ -451,7 +450,7 @@ bool HybridObservablesTest::acquire_signal() acquisition->init(); acquisition->set_local_code(); acquisition->set_state(1); // Ensure that acquisition starts at the first sample - acquisition->connect(top_block); + acquisition->connect(top_block_acq); gr::blocks::file_source::sptr file_source; std::string file = FLAGS_signal_file; @@ -460,9 +459,9 @@ bool HybridObservablesTest::acquire_signal() file_source->seek(2 * FLAGS_skip_samples, 0); // skip head. ibyte, two bytes per complex sample gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); // gr::blocks::head::sptr head_samples = gr::blocks::head::make(sizeof(gr_complex), baseband_sampling_freq * FLAGS_duration); - // top_block->connect(head_samples, 0, acquisition->get_left_block(), 0); + // top_block_acq->connect(head_samples, 0, acquisition->get_left_block(), 0); - top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); + top_block_acq->connect(file_source, 0, gr_interleaved_char_to_complex, 0); // Enable automatic resampler for the acquisition, if required if (FLAGS_use_acquisition_resampler == true) @@ -521,25 +520,25 @@ bool HybridObservablesTest::acquire_signal() std::cout << "Enabled decimation low pass filter with " << taps.size() << " taps and decimation factor of " << decimation << std::endl; acquisition->set_resampler_latency((taps.size() - 1) / 2); gr::basic_block_sptr fir_filter_ccf_ = gr::filter::fir_filter_ccf::make(decimation, taps); - top_block->connect(gr_interleaved_char_to_complex, 0, fir_filter_ccf_, 0); - top_block->connect(fir_filter_ccf_, 0, acquisition->get_left_block(), 0); + top_block_acq->connect(gr_interleaved_char_to_complex, 0, fir_filter_ccf_, 0); + top_block_acq->connect(fir_filter_ccf_, 0, acquisition->get_left_block(), 0); } else { std::cout << "Disabled acquisition resampler because the input sampling frequency is too low\n"; - top_block->connect(gr_interleaved_char_to_complex, 0, acquisition->get_left_block(), 0); + top_block_acq->connect(gr_interleaved_char_to_complex, 0, acquisition->get_left_block(), 0); } } else { std::cout << "Disabled acquisition resampler because the input sampling frequency is too low\n"; - top_block->connect(gr_interleaved_char_to_complex, 0, acquisition->get_left_block(), 0); + top_block_acq->connect(gr_interleaved_char_to_complex, 0, acquisition->get_left_block(), 0); } } else { - top_block->connect(gr_interleaved_char_to_complex, 0, acquisition->get_left_block(), 0); - // top_block->connect(head_samples, 0, acquisition->get_left_block(), 0); + top_block_acq->connect(gr_interleaved_char_to_complex, 0, acquisition->get_left_block(), 0); + // top_block_acq->connect(head_samples, 0, acquisition->get_left_block(), 0); } boost::shared_ptr msg_rx; @@ -553,8 +552,8 @@ bool HybridObservablesTest::acquire_signal() exit(0); } - msg_rx->top_block = top_block; - top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + msg_rx->top_block = top_block_acq; + top_block_acq->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); // 5. Run the flowgraph // Get visible GPS satellites (positive acquisitions with Doppler measurements) @@ -588,7 +587,7 @@ bool HybridObservablesTest::acquire_signal() acquisition->reset(); acquisition->set_state(1); msg_rx->rx_message = 0; - top_block->run(); + top_block_acq->run(); if (start_msg == true) { std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; @@ -609,7 +608,7 @@ bool HybridObservablesTest::acquire_signal() { std::cout << " . "; } - top_block->stop(); + top_block_acq->stop(); file_source->seek(2 * FLAGS_skip_samples, 0); // skip head. ibyte, two bytes per complex sample std::cout.flush(); } @@ -1797,7 +1796,7 @@ TEST_F(HybridObservablesTest, ValidationOfResults) }) << "Failure setting gnss_synchro."; } - top_block = gr::make_top_block("Telemetry_Decoder test"); + auto top_block_tlm = gr::make_top_block("Telemetry_Decoder test"); boost::shared_ptr dummy_msg_rx_trk = HybridObservablesTest_msg_rx_make(); boost::shared_ptr dummy_tlm_msg_rx = HybridObservablesTest_tlm_msg_rx_make(); // Observables @@ -1806,7 +1805,7 @@ TEST_F(HybridObservablesTest, ValidationOfResults) for (auto& n : tracking_ch_vec) { ASSERT_NO_THROW({ - n->connect(top_block); + n->connect(top_block_tlm); }) << "Failure connecting tracking to the top_block."; } @@ -1825,19 +1824,19 @@ TEST_F(HybridObservablesTest, ValidationOfResults) gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); int observable_interval_ms = 20; gnss_sdr_sample_counter_sptr samp_counter = gnss_sdr_make_sample_counter(static_cast(baseband_sampling_freq), observable_interval_ms, sizeof(gr_complex)); - top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); - top_block->connect(gr_interleaved_char_to_complex, 0, samp_counter, 0); + top_block_tlm->connect(file_source, 0, gr_interleaved_char_to_complex, 0); + top_block_tlm->connect(gr_interleaved_char_to_complex, 0, samp_counter, 0); for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) { - top_block->connect(gr_interleaved_char_to_complex, 0, tracking_ch_vec.at(n)->get_left_block(), 0); - top_block->connect(tracking_ch_vec.at(n)->get_right_block(), 0, tlm_ch_vec.at(n)->get_left_block(), 0); - top_block->connect(tlm_ch_vec.at(n)->get_right_block(), 0, observables->get_left_block(), n); - top_block->msg_connect(tracking_ch_vec.at(n)->get_right_block(), pmt::mp("events"), dummy_msg_rx_trk, pmt::mp("events")); - top_block->connect(observables->get_right_block(), n, null_sink_vec.at(n), 0); + top_block_tlm->connect(gr_interleaved_char_to_complex, 0, tracking_ch_vec.at(n)->get_left_block(), 0); + top_block_tlm->connect(tracking_ch_vec.at(n)->get_right_block(), 0, tlm_ch_vec.at(n)->get_left_block(), 0); + top_block_tlm->connect(tlm_ch_vec.at(n)->get_right_block(), 0, observables->get_left_block(), n); + top_block_tlm->msg_connect(tracking_ch_vec.at(n)->get_right_block(), pmt::mp("events"), dummy_msg_rx_trk, pmt::mp("events")); + top_block_tlm->connect(observables->get_right_block(), n, null_sink_vec.at(n), 0); } // connect sample counter and timmer to the last channel in observables block (extra channel) - top_block->connect(samp_counter, 0, observables->get_left_block(), tracking_ch_vec.size()); + top_block_tlm->connect(samp_counter, 0, observables->get_left_block(), tracking_ch_vec.size()); file_source->seek(2 * FLAGS_skip_samples, 0); // skip head. ibyte, two bytes per complex sample }) << "Failure connecting the blocks."; @@ -1849,7 +1848,7 @@ TEST_F(HybridObservablesTest, ValidationOfResults) EXPECT_NO_THROW({ start = std::chrono::system_clock::now(); - top_block->run(); // Start threads and wait + top_block_tlm->run(); // Start threads and wait end = std::chrono::system_clock::now(); elapsed_seconds = end - start; }) << "Failure running the top_block."; diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc index 5fcdbd66e..9182dec88 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc @@ -708,7 +708,7 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults) arma::vec true_prn_delay_chips = arma::zeros(n_true_epochs, 1); arma::vec true_tow_s = arma::zeros(n_true_epochs, 1); - int64_t epoch_counter = 0; + epoch_counter = 0; while (true_obs_data.read_binary_obs()) { true_timestamp_s(epoch_counter) = true_obs_data.signal_timestamp_s; diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test.cc index 96c8b4fba..e5cf0af0b 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test.cc @@ -212,7 +212,7 @@ public: int extend_correlation_symbols); bool acquire_signal(int SV_ID); - gr::top_block_sptr top_block; + std::shared_ptr factory; std::shared_ptr config; Gnss_Synchro gnss_synchro; @@ -369,8 +369,8 @@ void TrackingPullInTest::configure_receiver( bool TrackingPullInTest::acquire_signal(int SV_ID) { // 1. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) - gr::top_block_sptr top_block; - top_block = gr::make_top_block("Acquisition test"); + gr::top_block_sptr top_block_acq; + top_block_acq = gr::make_top_block("Acquisition test"); // Satellite signal definition Gnss_Synchro tmp_gnss_synchro; @@ -479,7 +479,7 @@ bool TrackingPullInTest::acquire_signal(int SV_ID) acquisition->init(); acquisition->set_local_code(); acquisition->set_state(1); // Ensure that acquisition starts at the first sample - acquisition->connect(top_block); + acquisition->connect(top_block_acq); gr::blocks::file_source::sptr file_source; std::string file = FLAGS_signal_file; @@ -489,7 +489,7 @@ bool TrackingPullInTest::acquire_signal(int SV_ID) gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); // gr::blocks::head::sptr head_samples = gr::blocks::head::make(sizeof(gr_complex), baseband_sampling_freq * FLAGS_duration); - top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); + top_block_acq->connect(file_source, 0, gr_interleaved_char_to_complex, 0); // Enable automatic resampler for the acquisition, if required if (FLAGS_use_acquisition_resampler == true) @@ -548,28 +548,27 @@ bool TrackingPullInTest::acquire_signal(int SV_ID) std::cout << "Enabled decimation low pass filter with " << taps.size() << " taps and decimation factor of " << decimation << std::endl; acquisition->set_resampler_latency((taps.size() - 1) / 2); gr::basic_block_sptr fir_filter_ccf_ = gr::filter::fir_filter_ccf::make(decimation, taps); - top_block->connect(gr_interleaved_char_to_complex, 0, fir_filter_ccf_, 0); - top_block->connect(fir_filter_ccf_, 0, acquisition->get_left_block(), 0); + top_block_acq->connect(gr_interleaved_char_to_complex, 0, fir_filter_ccf_, 0); + top_block_acq->connect(fir_filter_ccf_, 0, acquisition->get_left_block(), 0); } else { std::cout << "Disabled acquisition resampler because the input sampling frequency is too low\n"; - top_block->connect(gr_interleaved_char_to_complex, 0, acquisition->get_left_block(), 0); + top_block_acq->connect(gr_interleaved_char_to_complex, 0, acquisition->get_left_block(), 0); } } else { std::cout << "Disabled acquisition resampler because the input sampling frequency is too low\n"; - top_block->connect(gr_interleaved_char_to_complex, 0, acquisition->get_left_block(), 0); + top_block_acq->connect(gr_interleaved_char_to_complex, 0, acquisition->get_left_block(), 0); } } else { - top_block->connect(gr_interleaved_char_to_complex, 0, acquisition->get_left_block(), 0); - // top_block->connect(head_samples, 0, acquisition->get_left_block(), 0); + top_block_acq->connect(gr_interleaved_char_to_complex, 0, acquisition->get_left_block(), 0); + // top_block_acq->connect(head_samples, 0, acquisition->get_left_block(), 0); } - boost::shared_ptr msg_rx; try { @@ -581,8 +580,8 @@ bool TrackingPullInTest::acquire_signal(int SV_ID) exit(0); } - msg_rx->top_block = top_block; - top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + msg_rx->top_block = top_block_acq; + top_block_acq->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); // 5. Run the flowgraph // Get visible GPS satellites (positive acquisitions with Doppler measurements) @@ -620,7 +619,7 @@ bool TrackingPullInTest::acquire_signal(int SV_ID) acquisition->reset(); acquisition->set_state(1); msg_rx->rx_message = 0; - top_block->run(); + top_block_acq->run(); if (start_msg == true) { std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; @@ -643,7 +642,7 @@ bool TrackingPullInTest::acquire_signal(int SV_ID) { std::cout << " . "; } - top_block->stop(); + top_block_acq->stop(); file_source->seek(2 * FLAGS_skip_samples, SEEK_SET); // skip head. ibyte, two bytes per complex sample std::cout.flush(); } @@ -664,6 +663,7 @@ bool TrackingPullInTest::acquire_signal(int SV_ID) return true; } + TEST_F(TrackingPullInTest, ValidationOfResults) { // ************************************************* @@ -685,7 +685,6 @@ TEST_F(TrackingPullInTest, ValidationOfResults) acq_delay_error_chips_values.push_back(tmp_vector); } - // *********************************************************** // ***** STEP 2: Generate the input signal (if required) ***** // *********************************************************** @@ -735,7 +734,6 @@ TEST_F(TrackingPullInTest, ValidationOfResults) } } - configure_receiver(FLAGS_PLL_bw_hz_start, FLAGS_DLL_bw_hz_start, FLAGS_PLL_narrow_bw_hz, @@ -802,7 +800,7 @@ TEST_F(TrackingPullInTest, ValidationOfResults) gnss_synchro.Acq_delay_samples = true_acq_delay_samples + (acq_delay_error_chips_values.at(current_acq_doppler_error_idx).at(current_acq_code_error_idx) / GPS_L1_CA_CODE_RATE_CPS) * static_cast(baseband_sampling_freq); // create flowgraph - top_block = gr::make_top_block("Tracking test"); + auto top_block_trk = gr::make_top_block("Tracking test"); std::shared_ptr trk_ = factory->GetBlock(config, "Tracking", config->property("Tracking.implementation", std::string("undefined")), 1, 1); std::shared_ptr tracking = std::dynamic_pointer_cast(trk_); boost::shared_ptr msg_rx = TrackingPullInTest_msg_rx_make(); @@ -816,7 +814,7 @@ TEST_F(TrackingPullInTest, ValidationOfResults) }) << "Failure setting gnss_synchro."; ASSERT_NO_THROW({ - tracking->connect(top_block); + tracking->connect(top_block_trk); }) << "Failure connecting tracking to the top_block."; std::string file; @@ -834,23 +832,22 @@ TEST_F(TrackingPullInTest, ValidationOfResults) gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); gr::blocks::null_sink::sptr sink = gr::blocks::null_sink::make(sizeof(Gnss_Synchro)); gr::blocks::head::sptr head_samples = gr::blocks::head::make(sizeof(gr_complex), baseband_sampling_freq * FLAGS_duration); - top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); - top_block->connect(gr_interleaved_char_to_complex, 0, head_samples, 0); + top_block_trk->connect(file_source, 0, gr_interleaved_char_to_complex, 0); + top_block_trk->connect(gr_interleaved_char_to_complex, 0, head_samples, 0); if (acq_to_trk_delay_samples > 0) { - top_block->connect(head_samples, 0, resetable_valve_, 0); - top_block->connect(resetable_valve_, 0, tracking->get_left_block(), 0); + top_block_trk->connect(head_samples, 0, resetable_valve_, 0); + top_block_trk->connect(resetable_valve_, 0, tracking->get_left_block(), 0); } else { - top_block->connect(head_samples, 0, tracking->get_left_block(), 0); + top_block_trk->connect(head_samples, 0, tracking->get_left_block(), 0); } - top_block->connect(tracking->get_right_block(), 0, sink, 0); - top_block->msg_connect(tracking->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + top_block_trk->connect(tracking->get_right_block(), 0, sink, 0); + top_block_trk->msg_connect(tracking->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); file_source->seek(2 * FLAGS_skip_samples, 0); // skip head. ibyte, two bytes per complex sample }) << "Failure connecting the blocks of tracking test."; - // ******************************************************************** // ***** STEP 5: Perform the signal tracking and read the results ***** // ******************************************************************** @@ -861,7 +858,7 @@ TEST_F(TrackingPullInTest, ValidationOfResults) EXPECT_NO_THROW({ start = std::chrono::system_clock::now(); std::cout << "--- SIMULATING A PULL-IN DELAY OF " << FLAGS_acq_to_trk_delay_s << " SECONDS ---\n"; - top_block->start(); + top_block_trk->start(); std::cout << " Waiting for valve...\n"; // wait the valve message indicating the circulation of the amount of samples of the delay pmt::pmt_t msg; @@ -870,17 +867,16 @@ TEST_F(TrackingPullInTest, ValidationOfResults) tracking->start_tracking(); resetable_valve_->open_valve(); std::cout << " Waiting flowgraph..\n"; - top_block->wait(); + top_block_trk->wait(); end = std::chrono::system_clock::now(); }) << "Failure running the top_block."; } else { tracking->start_tracking(); - std::chrono::time_point start, end; EXPECT_NO_THROW({ start = std::chrono::system_clock::now(); - top_block->run(); // Start threads and wait + top_block_trk->run(); // Start threads and wait end = std::chrono::system_clock::now(); }) << "Failure running the top_block."; }