From 9c8dd1929d0a2e9ee49230923b5ebfa1d2ad9724 Mon Sep 17 00:00:00 2001 From: Jim Melton Date: Tue, 28 Feb 2023 14:13:31 -0700 Subject: [PATCH 01/38] REALLY suppress tags this time --- .../adapters/zmq_signal_source.cc | 44 +++++++------------ 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/src/algorithms/signal_source/adapters/zmq_signal_source.cc b/src/algorithms/signal_source/adapters/zmq_signal_source.cc index 7a6370000..bc8616ccd 100644 --- a/src/algorithms/signal_source/adapters/zmq_signal_source.cc +++ b/src/algorithms/signal_source/adapters/zmq_signal_source.cc @@ -42,20 +42,24 @@ ZmqSignalSource::ZmqSignalSource(const ConfigurationInterface* configuration, if (!endpoint.empty()) { LOG(INFO) << "Connecting to ZMQ pub at " << endpoint; - // work around gnuradio interface deficiency + // work around gnuradio interface const-deficiency d_source_block = gr::zeromq::sub_source::make(d_item_size, vlen, const_cast(endpoint.data()), timeout_ms, pass_tags, hwm); - d_source_block->set_tag_propagation_policy(gr::block::TPP_DONT); // GNSS-SDR doesn't do well with tags/ + + // work around another bug. GNU Radio passes tags through the ZMQ block + // unconditionally if pass_tags is true, but that flag controls protocol more + // than the intent of the block. Since we have the vector-to-stream block, + // unconditionally create it, and have it squelch the tags. GNSS-SDR should + // not fail if unexpected tags are received + + // vector-to-stream should be coherent even if vlen == 1 + d_vec_block = gr::blocks::vector_to_stream::make(item_size(), vlen); + d_vec_block->set_tag_propagation_policy(gr::block::TPP_DONT); // GNSS-SDR doesn't do well with tags/ } else { std::cerr << "For ZMQ_Signal_Source " << property << " must be defined" << std::endl; throw std::invalid_argument(property + ": undefined"); } - - if (vlen > 1) - { - d_vec_block = gr::blocks::vector_to_stream::make(item_size(), vlen); - } } @@ -64,15 +68,13 @@ auto ZmqSignalSource::item_size() -> size_t { return d_item_size; } auto ZmqSignalSource::connect(gr::top_block_sptr top_block) -> void { - if (d_vec_block) - { - top_block->connect(d_source_block, 0, d_vec_block, 0); - } if (d_dump) { d_dump_sink = gr::blocks::file_sink::make(item_size(), d_dump_filename.data()); top_block->connect(get_right_block(), 0, d_dump_sink, 0); } + + top_block->connect(d_source_block, 0, d_vec_block, 0); } @@ -83,25 +85,13 @@ auto ZmqSignalSource::disconnect(gr::top_block_sptr top_block) -> void top_block->disconnect(d_dump_sink); } - if (d_vec_block) - { - top_block->disconnect(d_vec_block); - } + // this might be redundant + top_block->disconnect(d_vec_block); + top_block->disconnect(d_source_block); } auto ZmqSignalSource::get_right_block() -> gr::basic_block_sptr { - auto result = gr::basic_block_sptr(); - - if (d_vec_block) - { - result = d_vec_block; - } - else - { - result = d_source_block; - } - - return result; + return d_vec_block; } From 1b2087944ece1d3e0a0575105360825b7dcb81c7 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 17 Mar 2023 10:39:22 +0100 Subject: [PATCH 02/38] Add Geohash of PVT solution to internal logs --- docs/CHANGELOG.md | 2 + .../PVT/gnuradio_blocks/rtklib_pvt_gs.cc | 4 +- .../PVT/gnuradio_blocks/rtklib_pvt_gs.h | 2 + src/algorithms/PVT/libs/CMakeLists.txt | 2 + src/algorithms/PVT/libs/geohash.cc | 195 ++++++++++++++++++ src/algorithms/PVT/libs/geohash.h | 74 +++++++ src/tests/test_main.cc | 1 + .../pvt/geohash_test.cc | 38 ++++ .../pvt/nmea_printer_test.cc | 2 +- 9 files changed, 318 insertions(+), 2 deletions(-) create mode 100644 src/algorithms/PVT/libs/geohash.cc create mode 100644 src/algorithms/PVT/libs/geohash.h create mode 100644 src/tests/unit-tests/signal-processing-blocks/pvt/geohash_test.cc diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index fafe79b12..aff709642 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -111,6 +111,8 @@ All notable changes to GNSS-SDR will be documented in this file. - New configuration parameter `PVT.use_unhealthy_sats`, set by default to `false`, allows processing observables of satellites that report an unhealthy status in the navigation message if set to `true`. +- Added the [Geohash](https://en.wikipedia.org/wiki/Geohash) of the PVT solution + in the internal logs. - Allowed the CMake project to be a sub-project. See the definitions of concepts and metrics at diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index 500db4d4c..9d2b843b3 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -28,6 +28,7 @@ #include "galileo_has_data.h" #include "galileo_iono.h" #include "galileo_utc_model.h" +#include "geohash.h" #include "geojson_printer.h" #include "glonass_gnav_almanac.h" #include "glonass_gnav_ephemeris.h" @@ -124,6 +125,7 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels, gr::io_signature::make(nchannels, nchannels, sizeof(Gnss_Synchro)), gr::io_signature::make(0, 0, 0)), d_dump_filename(conf_.dump_filename), + d_geohash(std::make_unique()), d_gps_ephemeris_sptr_type_hash_code(typeid(std::shared_ptr).hash_code()), d_gps_iono_sptr_type_hash_code(typeid(std::shared_ptr).hash_code()), d_gps_utc_model_sptr_type_hash_code(typeid(std::shared_ptr).hash_code()), @@ -2432,7 +2434,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item LOG(INFO) << "Position at " << boost::posix_time::to_simple_string(d_user_pvt_solver->get_position_UTC_time()) << " UTC using " << d_user_pvt_solver->get_num_valid_observations() << " observations is Lat = " << d_user_pvt_solver->get_latitude() << " [deg], Long = " << d_user_pvt_solver->get_longitude() << " [deg], Height = " << d_user_pvt_solver->get_height() << " [m]"; - + LOG(INFO) << "geohash: " << d_geohash->encode(d_user_pvt_solver->get_latitude(), d_user_pvt_solver->get_longitude()); /* std::cout << "Dilution of Precision at " << boost::posix_time::to_simple_string(d_user_pvt_solver->get_position_UTC_time()) << " UTC using "<< d_user_pvt_solver->get_num_valid_observations() <<" observations is HDOP = " << d_user_pvt_solver->get_hdop() << " VDOP = " << d_user_pvt_solver->get_vdop() diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.h b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.h index 94ffb458a..747c31c65 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.h +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.h @@ -50,6 +50,7 @@ class Beidou_Dnav_Ephemeris; class Galileo_Almanac; class Galileo_Ephemeris; class Galileo_HAS_data; +class Geohash; class GeoJSON_Printer; class Gps_Almanac; class Gps_Ephemeris; @@ -204,6 +205,7 @@ private: std::queue d_TimeChannelTagTimestamps; boost::posix_time::time_duration d_utc_diff_time; + std::unique_ptr d_geohash; size_t d_gps_ephemeris_sptr_type_hash_code; size_t d_gps_iono_sptr_type_hash_code; diff --git a/src/algorithms/PVT/libs/CMakeLists.txt b/src/algorithms/PVT/libs/CMakeLists.txt index 8e2785144..2460a3d4b 100644 --- a/src/algorithms/PVT/libs/CMakeLists.txt +++ b/src/algorithms/PVT/libs/CMakeLists.txt @@ -22,6 +22,7 @@ set(PVT_LIB_SOURCES monitor_pvt_udp_sink.cc monitor_ephemeris_udp_sink.cc has_simple_printer.cc + geohash.cc ) set(PVT_LIB_HEADERS @@ -43,6 +44,7 @@ set(PVT_LIB_HEADERS serdes_gps_eph.h monitor_ephemeris_udp_sink.h has_simple_printer.h + geohash.h ) list(SORT PVT_LIB_HEADERS) diff --git a/src/algorithms/PVT/libs/geohash.cc b/src/algorithms/PVT/libs/geohash.cc new file mode 100644 index 000000000..3682a7e0e --- /dev/null +++ b/src/algorithms/PVT/libs/geohash.cc @@ -0,0 +1,195 @@ +/*! + * \file geohash.cc + * \brief Implementation of a class for geohash encoding / decoding + * \author Carles Fernandez-Prades, 2023. cfernandez(at)cttc.es + * + * + * ----------------------------------------------------------------------------- + * + * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + * This file is part of GNSS-SDR. + * + * Copyright (C) 2010-2023 (see AUTHORS file for a list of contributors) + * SPDX-License-Identifier: GPL-3.0-or-later + * + * ----------------------------------------------------------------------------- + */ + +#include "geohash.h" +#include +#include +#include +#include +#include +#include + + +Geohash::Geohash() +{ + base32 = "0123456789bcdefghjkmnpqrstuvwxyz"; +} + +std::string Geohash::encode(double lat, double lon, int precision) const +{ + // infer precision? + if (precision == -1) + { + // refine geohash until it matches precision of supplied lat/lon + for (int p = 1; p <= 12; ++p) + { + const auto hash = Geohash::encode(lat, lon, p); + const auto posn = Geohash::decode(hash); + + if ((std::fabs(posn[0] - lat) < std::numeric_limits::epsilon()) && + (std::fabs(posn[1] - lon) < std::numeric_limits::epsilon())) + { + return hash; + } + } + precision = 12; // set to maximum + } + + if (std::isnan(lat) || std::isnan(lon) || precision < 1) + { + throw std::invalid_argument("Invalid geohash"); + } + + int idx = 0; // index into base32 map + int bit = 0; // each char holds 5 bits + bool evenBit = true; + std::string geohash = ""; + + double latMin = -90.0; + double latMax = 90.0; + double lonMin = -180.0; + double lonMax = 180.0; + + while (geohash.length() < static_cast(precision)) + { + if (evenBit) + { + // bisect E-W longitude + const double lonMid = (lonMin + lonMax) / 2.0; + if (lon >= lonMid) + { + idx = idx * 2 + 1; + lonMin = lonMid; + } + else + { + idx = idx * 2; + lonMax = lonMid; + } + } + else + { + // bisect N-S latitude + const double latMid = (latMin + latMax) / 2.0; + if (lat >= latMid) + { + idx = idx * 2 + 1; + latMin = latMid; + } + else + { + idx = idx * 2; + latMax = latMid; + } + } + evenBit = !evenBit; + + if (++bit == 5) + { + // 5 bits gives us a character: append it and start over + geohash += base32[idx]; + bit = 0; + idx = 0; + } + } + + return geohash; +} + + +std::array Geohash::decode(std::string geohash) const +{ + const auto bounds = Geohash::bounds(geohash); + + const double latMin = bounds[0]; + const double lonMin = bounds[1]; + const double latMax = bounds[2]; + const double lonMax = bounds[3]; + + // cell centre + double lat = (latMin + latMax) / 2.0; + double lon = (lonMin + lonMax) / 2.0; + + // round to close to centre without excessive precision: ⌊2-log10(Δ°)⌋ decimal places + std::array latlon{}; + latlon[0] = std::floor(lat * std::pow(10, std::floor(2 - std::log10(latMax - latMin)))); + latlon[1] = std::floor(lon * std::pow(10, std::floor(2 - std::log10(lonMax - lonMin)))); + + return latlon; +} + + +std::array Geohash::bounds(std::string geohash) const +{ + if (geohash.length() == 0) + { + throw std::runtime_error("Invalid geohash"); + } + + std::transform(geohash.begin(), geohash.end(), geohash.begin(), + [](unsigned char c) { return std::tolower(c); }); + + bool evenBit = true; + double latMin = -90.0; + double latMax = 90.0; + double lonMin = -180.0; + double lonMax = 180.0; + + for (size_t i = 0; i < geohash.length(); i++) + { + char chr = geohash[i]; + int idx = base32.find(chr); + if (idx == -1) + { + throw std::runtime_error("Invalid geohash"); + } + + for (int n = 4; n >= 0; n--) + { + int bitN = idx >> n & 1; + if (evenBit) + { + // longitude + double lonMid = (lonMin + lonMax) / 2; + if (bitN == 1) + { + lonMin = lonMid; + } + else + { + lonMax = lonMid; + } + } + else + { + // latitude + double latMid = (latMin + latMax) / 2; + if (bitN == 1) + { + latMin = latMid; + } + else + { + latMax = latMid; + } + } + evenBit = !evenBit; + } + } + + return {latMin, lonMin, latMax, lonMax}; +} \ No newline at end of file diff --git a/src/algorithms/PVT/libs/geohash.h b/src/algorithms/PVT/libs/geohash.h new file mode 100644 index 000000000..019dbaea5 --- /dev/null +++ b/src/algorithms/PVT/libs/geohash.h @@ -0,0 +1,74 @@ +/*! + * \file geohash.h + * \brief Interface of a class that encodes / decodes geohashes + * \author Carles Fernandez-Prades, 2023. cfernandez(at)cttc.es + * + * + * ----------------------------------------------------------------------------- + * + * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + * This file is part of GNSS-SDR. + * + * Copyright (C) 2010-2023 (see AUTHORS file for a list of contributors) + * SPDX-License-Identifier: GPL-3.0-or-later + * + * ----------------------------------------------------------------------------- + */ + + +#ifndef GNSS_SDR_GEOHASH_H +#define GNSS_SDR_GEOHASH_H + +#include +#include + +/** \addtogroup PVT + * \{ */ +/** \addtogroup PVT_libs + * \{ */ + +/*! + * \brief Class for geohash encoding / decoding + * See https://en.wikipedia.org/wiki/Geohash + */ +class Geohash +{ +public: + Geohash(); + + /** + * Encodes latitude/longitude to geohash, either to specified precision or + * to automatically evaluated precision. + * + * @param {double} lat - Latitude in degrees. + * @param {double} lon - Longitude in degrees. + * @param {int} [precision] - Number of characters in resulting geohash. + * @returns {string} Geohash of supplied latitude/longitude. + * @throws Invalid geohash. + * + */ + std::string encode(double lat, double lon, int precision = -1) const; + + /** + * Decode geohash to latitude/longitude (location is approximate centre of + * geohash cell, to reasonable precision). + * + * @param {string} geohash - Geohash string to be converted to + * latitude/longitude. + * @returns {lat, lon} (Center of) geohashed location. + * @throws Invalid geohash. + * + */ + std::array decode(std::string geohash) const; + +private: + /* + * Returns SW/NE latitude/longitude bounds of specified geohash. + */ + std::array bounds(std::string geohash) const; + std::string base32; +}; + +/** \} */ +/** \} */ +#endif // GNSS_SDR_GEOHASH_H diff --git a/src/tests/test_main.cc b/src/tests/test_main.cc index 15b5ffacc..3769756aa 100644 --- a/src/tests/test_main.cc +++ b/src/tests/test_main.cc @@ -72,6 +72,7 @@ DECLARE_string(log_dir); #include "unit-tests/signal-processing-blocks/adapter/adapter_test.cc" #include "unit-tests/signal-processing-blocks/adapter/pass_through_test.cc" #include "unit-tests/signal-processing-blocks/libs/item_type_helpers_test.cc" +#include "unit-tests/signal-processing-blocks/pvt/geohash_test.cc" #include "unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc" #include "unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc" #include "unit-tests/signal-processing-blocks/pvt/rtcm_printer_test.cc" diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/geohash_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/geohash_test.cc new file mode 100644 index 000000000..bb1168a08 --- /dev/null +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/geohash_test.cc @@ -0,0 +1,38 @@ +/*! + * \file geohash_test.cc + * \brief Implements Unit Tests for the Geohash class. + * \author Carles Fernandez-Prades, 2023. cfernandez(at)cttc.es + * + * ----------------------------------------------------------------------------- + * + * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + * This file is part of GNSS-SDR. + * + * Copyright (C) 2010-2023 (see AUTHORS file for a list of contributors) + * SPDX-License-Identifier: GPL-3.0-or-later + * + * ----------------------------------------------------------------------------- + */ + +#include "geohash.h" + +TEST(Geohash_Test, Encode) +{ + Geohash gh = Geohash(); + std::string hash; + EXPECT_NO_THROW(hash = gh.encode(52.205, 0.119, 7)); + + EXPECT_EQ(0, hash.compare("u120fxw")); + + EXPECT_THROW(gh.encode(52.205, 0.119, 0), std::invalid_argument); +} + +TEST(Geohash_Test, precision) +{ + Geohash gh = Geohash(); + std::string hash; + EXPECT_NO_THROW(hash = gh.encode(52.205, 0.119, 6)); + EXPECT_EQ(0, hash.compare("u120fx")); + EXPECT_NO_THROW(hash = gh.encode(52.205, 0.119, 5)); + EXPECT_EQ(0, hash.compare("u120f")); +} \ No newline at end of file diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc index b4dfc483f..99c2bc0a3 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc @@ -1,5 +1,5 @@ /*! - * \file nma_printer_test.cc + * \file nmea_printer_test.cc * \brief Implements Unit Tests for the Nmea_Printer class. * \author Carles Fernandez-Prades, 2017. cfernandez(at)cttc.es * From 18e5345669a33ca60adce26ca784c66e3377173a Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 17 Mar 2023 13:51:01 +0100 Subject: [PATCH 03/38] clang-tidy fixes --- src/algorithms/PVT/libs/geohash.cc | 19 +++++++------------ src/algorithms/PVT/libs/geohash.h | 4 ++-- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/algorithms/PVT/libs/geohash.cc b/src/algorithms/PVT/libs/geohash.cc index 3682a7e0e..0021a752d 100644 --- a/src/algorithms/PVT/libs/geohash.cc +++ b/src/algorithms/PVT/libs/geohash.cc @@ -22,13 +22,9 @@ #include #include #include +#include -Geohash::Geohash() -{ - base32 = "0123456789bcdefghjkmnpqrstuvwxyz"; -} - std::string Geohash::encode(double lat, double lon, int precision) const { // infer precision? @@ -113,7 +109,7 @@ std::string Geohash::encode(double lat, double lon, int precision) const std::array Geohash::decode(std::string geohash) const { - const auto bounds = Geohash::bounds(geohash); + const auto bounds = Geohash::bounds(std::move(geohash)); const double latMin = bounds[0]; const double lonMin = bounds[1]; @@ -126,8 +122,8 @@ std::array Geohash::decode(std::string geohash) const // round to close to centre without excessive precision: ⌊2-log10(Δ°)⌋ decimal places std::array latlon{}; - latlon[0] = std::floor(lat * std::pow(10, std::floor(2 - std::log10(latMax - latMin)))); - latlon[1] = std::floor(lon * std::pow(10, std::floor(2 - std::log10(lonMax - lonMin)))); + latlon[0] = std::floor(lat * std::pow(10, std::floor(2.0 - std::log10(latMax - latMin)))); + latlon[1] = std::floor(lon * std::pow(10, std::floor(2.0 - std::log10(lonMax - lonMin)))); return latlon; } @@ -149,9 +145,8 @@ std::array Geohash::bounds(std::string geohash) const double lonMin = -180.0; double lonMax = 180.0; - for (size_t i = 0; i < geohash.length(); i++) + for (char chr : geohash) { - char chr = geohash[i]; int idx = base32.find(chr); if (idx == -1) { @@ -164,7 +159,7 @@ std::array Geohash::bounds(std::string geohash) const if (evenBit) { // longitude - double lonMid = (lonMin + lonMax) / 2; + double lonMid = (lonMin + lonMax) / 2.0; if (bitN == 1) { lonMin = lonMid; @@ -177,7 +172,7 @@ std::array Geohash::bounds(std::string geohash) const else { // latitude - double latMid = (latMin + latMax) / 2; + double latMid = (latMin + latMax) / 2.0; if (bitN == 1) { latMin = latMid; diff --git a/src/algorithms/PVT/libs/geohash.h b/src/algorithms/PVT/libs/geohash.h index 019dbaea5..a97015f44 100644 --- a/src/algorithms/PVT/libs/geohash.h +++ b/src/algorithms/PVT/libs/geohash.h @@ -34,7 +34,7 @@ class Geohash { public: - Geohash(); + Geohash() = default; /** * Encodes latitude/longitude to geohash, either to specified precision or @@ -66,7 +66,7 @@ private: * Returns SW/NE latitude/longitude bounds of specified geohash. */ std::array bounds(std::string geohash) const; - std::string base32; + std::string base32{"0123456789bcdefghjkmnpqrstuvwxyz"}; }; /** \} */ From da1a75ec39e3f6131fe8fcc462835a9886ef50c5 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 18 Mar 2023 08:47:35 +0100 Subject: [PATCH 04/38] Fix geohash decoding --- src/algorithms/PVT/libs/geohash.cc | 8 ++++++-- .../pvt/geohash_test.cc | 19 +++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/algorithms/PVT/libs/geohash.cc b/src/algorithms/PVT/libs/geohash.cc index 0021a752d..33f14c705 100644 --- a/src/algorithms/PVT/libs/geohash.cc +++ b/src/algorithms/PVT/libs/geohash.cc @@ -122,8 +122,12 @@ std::array Geohash::decode(std::string geohash) const // round to close to centre without excessive precision: ⌊2-log10(Δ°)⌋ decimal places std::array latlon{}; - latlon[0] = std::floor(lat * std::pow(10, std::floor(2.0 - std::log10(latMax - latMin)))); - latlon[1] = std::floor(lon * std::pow(10, std::floor(2.0 - std::log10(lonMax - lonMin)))); + int decimalPlaces = std::floor(2.0 - std::log10(latMax - latMin)); + double factor = std::pow(10, decimalPlaces); + latlon[0] = std::round(lat * factor) / factor; + int decimalPlaces2 = std::floor(2.0 - std::log10(lonMax - lonMin)); + double factor2 = std::pow(10, decimalPlaces2); + latlon[1] = std::round(lon * factor2) / factor2; return latlon; } diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/geohash_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/geohash_test.cc index bb1168a08..9eb0080ad 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/geohash_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/geohash_test.cc @@ -19,15 +19,22 @@ TEST(Geohash_Test, Encode) { Geohash gh = Geohash(); - std::string hash; - EXPECT_NO_THROW(hash = gh.encode(52.205, 0.119, 7)); - - EXPECT_EQ(0, hash.compare("u120fxw")); - + std::string geohash; + EXPECT_NO_THROW(geohash = gh.encode(52.205, 0.119, 7)); + EXPECT_EQ(0, geohash.compare("u120fxw")); EXPECT_THROW(gh.encode(52.205, 0.119, 0), std::invalid_argument); } -TEST(Geohash_Test, precision) +TEST(Geohash_Test, Decode) +{ + Geohash gh = Geohash(); + auto latlon = gh.decode("sp36v1zk0e2g"); + EXPECT_NEAR(41.274966141209006, latlon[0], 1e-8); + EXPECT_NEAR(1.9875180535018444, latlon[1], 1e-8); + EXPECT_THROW(gh.decode(""), std::runtime_error); +} + +TEST(Geohash_Test, Precision) { Geohash gh = Geohash(); std::string hash; From 43eec445799548a9b23000a05e99002c9c3a3d04 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 18 Mar 2023 11:39:44 +0100 Subject: [PATCH 05/38] Improve geohash test, make it easier to read the log --- .../PVT/gnuradio_blocks/rtklib_pvt_gs.cc | 2 +- .../signal-processing-blocks/pvt/geohash_test.cc | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index 9d2b843b3..8f6f1648a 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -2434,7 +2434,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item LOG(INFO) << "Position at " << boost::posix_time::to_simple_string(d_user_pvt_solver->get_position_UTC_time()) << " UTC using " << d_user_pvt_solver->get_num_valid_observations() << " observations is Lat = " << d_user_pvt_solver->get_latitude() << " [deg], Long = " << d_user_pvt_solver->get_longitude() << " [deg], Height = " << d_user_pvt_solver->get_height() << " [m]"; - LOG(INFO) << "geohash: " << d_geohash->encode(d_user_pvt_solver->get_latitude(), d_user_pvt_solver->get_longitude()); + LOG(INFO) << "geohash=" << d_geohash->encode(d_user_pvt_solver->get_latitude(), d_user_pvt_solver->get_longitude()); /* std::cout << "Dilution of Precision at " << boost::posix_time::to_simple_string(d_user_pvt_solver->get_position_UTC_time()) << " UTC using "<< d_user_pvt_solver->get_num_valid_observations() <<" observations is HDOP = " << d_user_pvt_solver->get_hdop() << " VDOP = " << d_user_pvt_solver->get_vdop() diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/geohash_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/geohash_test.cc index 9eb0080ad..845c67937 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/geohash_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/geohash_test.cc @@ -22,18 +22,28 @@ TEST(Geohash_Test, Encode) std::string geohash; EXPECT_NO_THROW(geohash = gh.encode(52.205, 0.119, 7)); EXPECT_EQ(0, geohash.compare("u120fxw")); + EXPECT_NO_THROW(geohash = gh.encode(41.274966141209, 1.987518053501)); + EXPECT_EQ(0, geohash.compare("sp36v1zk0e2g")); EXPECT_THROW(gh.encode(52.205, 0.119, 0), std::invalid_argument); } + TEST(Geohash_Test, Decode) { Geohash gh = Geohash(); auto latlon = gh.decode("sp36v1zk0e2g"); - EXPECT_NEAR(41.274966141209006, latlon[0], 1e-8); - EXPECT_NEAR(1.9875180535018444, latlon[1], 1e-8); + EXPECT_NEAR(41.274966141209, latlon[0], 1e-8); + EXPECT_NEAR(1.987518053501, latlon[1], 1e-8); EXPECT_THROW(gh.decode(""), std::runtime_error); + latlon = gh.decode("w21zd2mkt"); + EXPECT_NEAR(1.320527, latlon[0], 1e-8); + EXPECT_NEAR(103.81726, latlon[1], 1e-8); + latlon = gh.decode("W21ZD2MKT"); + EXPECT_NEAR(1.320527, latlon[0], 1e-8); + EXPECT_NEAR(103.81726, latlon[1], 1e-8); } + TEST(Geohash_Test, Precision) { Geohash gh = Geohash(); From 060c3af12406169b3bbd4b58afe13dd10ceea9fc Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 18 Mar 2023 11:41:43 +0100 Subject: [PATCH 06/38] cpu_features: Add Windows Arm64 support, update C++ standard for tests from C++11 to C++14, add Raptor Lake-P and Raptor Lake-HX/S detection --- .../volk_gnsssdr/cpu_features/CMakeLists.txt | 5 +- .../include/cpu_features_macros.h | 2 +- .../cpu_features/include/cpuinfo_aarch64.h | 103 +++++++++- .../include/internal/windows_utils.h | 32 +++ .../cpu_features/src/impl_aarch64_windows.c | 130 ++++++++++++ .../cpu_features/test/CMakeLists.txt | 6 +- .../cpu_features/test/cpuinfo_aarch64_test.cc | 188 ++++++++---------- .../cpu_features/test/cpuinfo_x86_test.cc | 35 ++++ 8 files changed, 388 insertions(+), 113 deletions(-) create mode 100644 src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64_windows.c diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/CMakeLists.txt index 56c411c53..c213b6016 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/CMakeLists.txt @@ -85,6 +85,7 @@ macro(add_cpu_features_headers_and_sources HDRS_LIST_NAME SRCS_LIST_NAME) list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_arm.h) elseif(PROCESSOR_IS_AARCH64) list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_aarch64.h) + list(APPEND ${SRCS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/internal/windows_utils.h) elseif(PROCESSOR_IS_X86) list(APPEND ${HDRS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/cpuinfo_x86.h) list(APPEND ${SRCS_LIST_NAME} ${PROJECT_SOURCE_DIR}/include/internal/cpuid_x86.h) @@ -185,9 +186,9 @@ if(BUILD_TESTING) # found. enable_language(CXX) - set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) - set(CMAKE_CXX_EXTENSIONS OFF) # prefer use of -std11 instead of -gnustd11 + set(CMAKE_CXX_EXTENSIONS OFF) # prefer use of -std14 instead of -gnustd14 if(NOT TARGET gtest OR NOT TARGET gmock_main) # Download and unpack googletest at configure time. diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpu_features_macros.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpu_features_macros.h index ace763248..2a8442db9 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpu_features_macros.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpu_features_macros.h @@ -28,7 +28,7 @@ #define CPU_FEATURES_ARCH_ARM #endif -#if defined(__aarch64__) +#if (defined(__aarch64__) || defined(_M_ARM64)) #define CPU_FEATURES_ARCH_AARCH64 #endif diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_aarch64.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_aarch64.h index b68869e3f..9fafccab8 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_aarch64.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/cpuinfo_aarch64.h @@ -1,6 +1,100 @@ // SPDX-FileCopyrightText: 2017 Google LLC // SPDX-License-Identifier: Apache-2.0 +//////////////////////////////////////////////////////////////////////////////// +// A note on Windows AArch64 implementation +//////////////////////////////////////////////////////////////////////////////// + +// Getting cpu info via EL1 system registers is not possible, so we delegate it +// to the Windows API (i.e., IsProcessorFeaturePresent and GetNativeSystemInfo). +// The `implementer`, `variant` and `part` fields of the `Aarch64Info` struct +// are not used, so they are set to 0. To get `revision` we use +// `wProcessorRevision` from `SYSTEM_INFO`. +// +// Cryptographic Extension: +// ----------------------------------------------------------------------------- +// According to documentation Arm Architecture Reference Manual for +// A-profile architecture. A2.3 The Armv8 Cryptographic Extension. The Armv8.0 +// Cryptographic Extension provides instructions for the acceleration of +// encryption and decryption, and includes the following features: FEAT_AES, +// FEAT_PMULL, FEAT_SHA1, FEAT_SHA256. +// see: https://developer.arm.com/documentation/ddi0487/latest +// +// We use `PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE` to detect all Armv8.0 crypto +// features. This value reports all features or nothing, so even if you only +// have support FEAT_AES and FEAT_PMULL, it will still return false. +// +// From Armv8.2, an implementation of the Armv8.0 Cryptographic Extension can +// include either or both of: +// +// • The AES functionality, including support for multiplication of 64-bit +// polynomials. The ID_AA64ISAR0_EL1.AES field indicates whether this +// functionality is supported. +// • The SHA1 and SHA2-256 functionality. The ID_AA64ISAR0_EL1.{SHA2, SHA1} +// fields indicate whether this functionality is supported. +// +// ID_AA64ISAR0_EL1.AES, bits [7:4]: +// Indicates support for AES instructions in AArch64 state. Defined values are: +// - 0b0000 No AES instructions implemented. +// - 0b0001 AESE, AESD, AESMC, and AESIMC instructions implemented. +// - 0b0010 As for 0b0001, plus PMULL/PMULL2 instructions operating on 64-bit +// data quantities. +// +// FEAT_AES implements the functionality identified by the value 0b0001. +// FEAT_PMULL implements the functionality identified by the value 0b0010. +// From Armv8, the permitted values are 0b0000 and 0b0010. +// +// ID_AA64ISAR0_EL1.SHA1, bits [11:8]: +// Indicates support for SHA1 instructions in AArch64 state. Defined values are: +// - 0b0000 No SHA1 instructions implemented. +// - 0b0001 SHA1C, SHA1P, SHA1M, SHA1H, SHA1SU0, and SHA1SU1 instructions +// implemented. +// +// FEAT_SHA1 implements the functionality identified by the value 0b0001. +// From Armv8, the permitted values are 0b0000 and 0b0001. +// If the value of ID_AA64ISAR0_EL1.SHA2 is 0b0000, this field must have the +// value 0b0000. +// +// ID_AA64ISAR0_EL1.SHA2, bits [15:12]: +// Indicates support for SHA2 instructions in AArch64 state. Defined values are: +// - 0b0000 No SHA2 instructions implemented. +// - 0b0001 Implements instructions: SHA256H, SHA256H2, SHA256SU0, and +// SHA256SU1. +// - 0b0010 Implements instructions: +// • SHA256H, SHA256H2, SHA256SU0, and SHA256SU1. +// • SHA512H, SHA512H2, SHA512SU0, and SHA512SU1. +// +// FEAT_SHA256 implements the functionality identified by the value 0b0001. +// FEAT_SHA512 implements the functionality identified by the value 0b0010. +// +// In Armv8, the permitted values are 0b0000 and 0b0001. +// From Armv8.2, the permitted values are 0b0000, 0b0001, and 0b0010. +// +// If the value of ID_AA64ISAR0_EL1.SHA1 is 0b0000, this field must have the +// value 0b0000. +// +// If the value of this field is 0b0010, ID_AA64ISAR0_EL1.SHA3 +// must have the value 0b0001. +// +// Other cryptographic features that we cannot detect such as sha512, sha3, sm3, +// sm4, sveaes, svepmull, svesha3, svesm4 we set to 0. +// +// FP/SIMD: +// ----------------------------------------------------------------------------- +// FP/SIMD must be implemented on all Armv8.0 implementations, but +// implementations targeting specialized markets may support the following +// combinations: +// +// • No NEON or floating-point. +// • Full floating-point and SIMD support with exception trapping. +// • Full floating-point and SIMD support without exception trapping. +// +// ref: +// https://developer.arm.com/documentation/den0024/a/AArch64-Floating-point-and-NEON +// +// So, we use `PF_ARM_VFP_32_REGISTERS_AVAILABLE`, +// `PF_ARM_NEON_INSTRUCTIONS_AVAILABLE` to detect `asimd` and `fp` + #ifndef CPU_FEATURES_INCLUDE_CPUINFO_AARCH64_H_ #define CPU_FEATURES_INCLUDE_CPUINFO_AARCH64_H_ @@ -72,10 +166,11 @@ typedef struct typedef struct { Aarch64Features features; - int implementer; - int variant; - int part; - int revision; + int implementer; // We set 0 for Windows. + int variant; // We set 0 for Windows. + int part; // We set 0 for Windows. + int revision; // We use GetNativeSystemInfo to get processor revision for + // Windows. } Aarch64Info; Aarch64Info GetAarch64Info(void); diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/windows_utils.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/windows_utils.h index 1790adc9c..cc08d3c9f 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/windows_utils.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/include/internal/windows_utils.h @@ -22,5 +22,37 @@ #define PF_SSE4_2_INSTRUCTIONS_AVAILABLE 38 #endif +#if !defined(PF_ARM_VFP_32_REGISTERS_AVAILABLE) +#define PF_ARM_VFP_32_REGISTERS_AVAILABLE 18 +#endif + +#if !defined(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) +#define PF_ARM_NEON_INSTRUCTIONS_AVAILABLE 19 +#endif + +#if !defined(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE) +#define PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE 30 +#endif + +#if !defined(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE) +#define PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE 31 +#endif + +#if !defined(PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE) +#define PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE 34 +#endif + +#if !defined(PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE) +#define PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE 43 +#endif + +#if !defined(PF_ARM_V83_JSCVT_INSTRUCTIONS_AVAILABLE) +#define PF_ARM_V83_JSCVT_INSTRUCTIONS_AVAILABLE 44 +#endif + +#if !defined(PF_ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE) +#define PF_ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE 45 +#endif + #endif // CPU_FEATURES_OS_WINDOWS #endif // CPU_FEATURES_INCLUDE_INTERNAL_WINDOWS_UTILS_H_ diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64_windows.c b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64_windows.c new file mode 100644 index 000000000..dd830863b --- /dev/null +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_aarch64_windows.c @@ -0,0 +1,130 @@ +// SPDX-FileCopyrightText: 2023 Google LLC +// SPDX-License-Identifier: Apache-2.0 + +#include "cpu_features_macros.h" + +#ifdef CPU_FEATURES_ARCH_AARCH64 +#ifdef CPU_FEATURES_OS_WINDOWS + +#include "cpuinfo_aarch64.h" + +//////////////////////////////////////////////////////////////////////////////// +// Definitions for introspection. +//////////////////////////////////////////////////////////////////////////////// +#define INTROSPECTION_TABLE \ + LINE(AARCH64_FP, fp, , , ) \ + LINE(AARCH64_ASIMD, asimd, , , ) \ + LINE(AARCH64_EVTSTRM, evtstrm, , , ) \ + LINE(AARCH64_AES, aes, , , ) \ + LINE(AARCH64_PMULL, pmull, , , ) \ + LINE(AARCH64_SHA1, sha1, , , ) \ + LINE(AARCH64_SHA2, sha2, , , ) \ + LINE(AARCH64_CRC32, crc32, , , ) \ + LINE(AARCH64_ATOMICS, atomics, , , ) \ + LINE(AARCH64_FPHP, fphp, , , ) \ + LINE(AARCH64_ASIMDHP, asimdhp, , , ) \ + LINE(AARCH64_CPUID, cpuid, , , ) \ + LINE(AARCH64_ASIMDRDM, asimdrdm, , , ) \ + LINE(AARCH64_JSCVT, jscvt, , , ) \ + LINE(AARCH64_FCMA, fcma, , , ) \ + LINE(AARCH64_LRCPC, lrcpc, , , ) \ + LINE(AARCH64_DCPOP, dcpop, , , ) \ + LINE(AARCH64_SHA3, sha3, , , ) \ + LINE(AARCH64_SM3, sm3, , , ) \ + LINE(AARCH64_SM4, sm4, , , ) \ + LINE(AARCH64_ASIMDDP, asimddp, , , ) \ + LINE(AARCH64_SHA512, sha512, , , ) \ + LINE(AARCH64_SVE, sve, , , ) \ + LINE(AARCH64_ASIMDFHM, asimdfhm, , , ) \ + LINE(AARCH64_DIT, dit, , , ) \ + LINE(AARCH64_USCAT, uscat, , , ) \ + LINE(AARCH64_ILRCPC, ilrcpc, , , ) \ + LINE(AARCH64_FLAGM, flagm, , , ) \ + LINE(AARCH64_SSBS, ssbs, , , ) \ + LINE(AARCH64_SB, sb, , , ) \ + LINE(AARCH64_PACA, paca, , , ) \ + LINE(AARCH64_PACG, pacg, , , ) \ + LINE(AARCH64_DCPODP, dcpodp, , , ) \ + LINE(AARCH64_SVE2, sve2, , , ) \ + LINE(AARCH64_SVEAES, sveaes, , , ) \ + LINE(AARCH64_SVEPMULL, svepmull, , , ) \ + LINE(AARCH64_SVEBITPERM, svebitperm, , , ) \ + LINE(AARCH64_SVESHA3, svesha3, , , ) \ + LINE(AARCH64_SVESM4, svesm4, , , ) \ + LINE(AARCH64_FLAGM2, flagm2, , , ) \ + LINE(AARCH64_FRINT, frint, , , ) \ + LINE(AARCH64_SVEI8MM, svei8mm, , , ) \ + LINE(AARCH64_SVEF32MM, svef32mm, , , ) \ + LINE(AARCH64_SVEF64MM, svef64mm, , , ) \ + LINE(AARCH64_SVEBF16, svebf16, , , ) \ + LINE(AARCH64_I8MM, i8mm, , , ) \ + LINE(AARCH64_BF16, bf16, , , ) \ + LINE(AARCH64_DGH, dgh, , , ) \ + LINE(AARCH64_RNG, rng, , , ) \ + LINE(AARCH64_BTI, bti, , , ) \ + LINE(AARCH64_MTE, mte, , , ) \ + LINE(AARCH64_ECV, ecv, , , ) \ + LINE(AARCH64_AFP, afp, , , ) \ + LINE(AARCH64_RPRES, rpres, , , ) +#define INTROSPECTION_PREFIX Aarch64 +#define INTROSPECTION_ENUM_PREFIX AARCH64 +#include "define_introspection.inl" + +//////////////////////////////////////////////////////////////////////////////// +// Implementation. +//////////////////////////////////////////////////////////////////////////////// + +#include "internal/windows_utils.h" +#include + +#ifdef CPU_FEATURES_MOCK_CPUID_AARCH64 +extern bool GetWindowsIsProcessorFeaturePresent(DWORD); +extern WORD GetWindowsNativeSystemInfoProcessorRevision(); +#else // CPU_FEATURES_MOCK_CPUID_AARCH64 +static bool +GetWindowsIsProcessorFeaturePresent(DWORD dwProcessorFeature) +{ + return IsProcessorFeaturePresent(dwProcessorFeature); +} + +static WORD GetWindowsNativeSystemInfoProcessorRevision() +{ + SYSTEM_INFO system_info; + GetNativeSystemInfo(&system_info); + return system_info.wProcessorRevision; +} +#endif + +static const Aarch64Info kEmptyAarch64Info; + +Aarch64Info GetAarch64Info(void) +{ + Aarch64Info info = kEmptyAarch64Info; + info.revision = GetWindowsNativeSystemInfoProcessorRevision(); + info.features.fp = + GetWindowsIsProcessorFeaturePresent(PF_ARM_VFP_32_REGISTERS_AVAILABLE); + info.features.asimd = + GetWindowsIsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE); + info.features.crc32 = GetWindowsIsProcessorFeaturePresent( + PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE); + info.features.asimddp = + GetWindowsIsProcessorFeaturePresent(PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE); + info.features.jscvt = GetWindowsIsProcessorFeaturePresent( + PF_ARM_V83_JSCVT_INSTRUCTIONS_AVAILABLE); + info.features.lrcpc = GetWindowsIsProcessorFeaturePresent( + PF_ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE); + info.features.atomics = GetWindowsIsProcessorFeaturePresent( + PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE); + + + bool is_crypto_available = GetWindowsIsProcessorFeaturePresent( + PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE); + info.features.aes = is_crypto_available; + info.features.sha1 = is_crypto_available; + info.features.sha2 = is_crypto_available; + info.features.pmull = is_crypto_available; + return info; +} + +#endif // CPU_FEATURES_OS_WINDOWS +#endif // CPU_FEATURES_ARCH_AARCH64 \ No newline at end of file diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/CMakeLists.txt index 8df134964..5d41179e5 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/CMakeLists.txt @@ -74,7 +74,11 @@ endif() ##------------------------------------------------------------------------------ ## cpuinfo_aarch64_test if(PROCESSOR_IS_AARCH64) - add_executable(cpuinfo_aarch64_test cpuinfo_aarch64_test.cc ../src/impl_aarch64_linux_or_android.c) + add_executable(cpuinfo_aarch64_test + cpuinfo_aarch64_test.cc + ../src/impl_aarch64_linux_or_android.c + ../src/impl_aarch64_windows.c) + target_compile_definitions(cpuinfo_aarch64_test PUBLIC CPU_FEATURES_MOCK_CPUID_AARCH64) target_link_libraries(cpuinfo_aarch64_test all_libraries) add_test(NAME cpuinfo_aarch64_test COMMAND cpuinfo_aarch64_test) endif() diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_aarch64_test.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_aarch64_test.cc index 8d88e49d3..d2450752a 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_aarch64_test.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_aarch64_test.cc @@ -5,150 +5,103 @@ #include "filesystem_for_testing.h" #include "gtest/gtest.h" #include "hwcaps_for_testing.h" +#include + +#if defined(CPU_FEATURES_OS_WINDOWS) +#include "internal/windows_utils.h" +#endif // CPU_FEATURES_OS_WINDOWS namespace cpu_features { -namespace -{ -#if defined(CPU_FEATURES_OS_DARWIN) - -class FakeCpu +class FakeCpuAarch64 { public: - bool GetDarwinSysCtlByName(std::string name) const +#if defined(CPU_FEATURES_OS_WINDOWS) + bool GetWindowsIsProcessorFeaturePresent(DWORD dwProcessorFeature) { - return darwin_sysctlbyname_.count(name); + return windows_isprocessorfeaturepresent_.count(dwProcessorFeature); } - int GetDarwinSysCtlByNameValue(std::string name) const + void SetWindowsIsProcessorFeaturePresent(DWORD dwProcessorFeature) { - std::map::const_iterator iter = - darwin_sysctlbynamevalue_.find(name); - if (iter != std::end(darwin_sysctlbynamevalue_)) - { - return iter->second; - } - - return 0; + windows_isprocessorfeaturepresent_.insert(dwProcessorFeature); } - void SetDarwinSysCtlByName(std::string name) + WORD GetWindowsNativeSystemInfoProcessorRevision() const { - darwin_sysctlbyname_.insert(name); + return processor_revision_; } - void SetDarwinSysCtlByNameValue(std::string name, int value) + void SetWindowsNativeSystemInfoProcessorRevision(WORD wProcessorRevision) { - darwin_sysctlbynamevalue_[name] = value; + processor_revision_ = wProcessorRevision; } private: - std::set darwin_sysctlbyname_; - std::map darwin_sysctlbynamevalue_; + std::set windows_isprocessorfeaturepresent_; + WORD processor_revision_{}; +#endif // CPU_FEATURES_OS_WINDOWS }; -FakeCpu* g_fake_cpu = nullptr; +static FakeCpuAarch64* g_fake_cpu_instance = nullptr; -extern "C" bool GetDarwinSysCtlByName(const char* name) +static FakeCpuAarch64& cpu() { - return g_fake_cpu->GetDarwinSysCtlByName(name); + assert(g_fake_cpu_instance != nullptr); + return *g_fake_cpu_instance; } -extern "C" int GetDarwinSysCtlByNameValue(const char* name) +#if defined(CPU_FEATURES_OS_WINDOWS) +extern "C" bool GetWindowsIsProcessorFeaturePresent(DWORD dwProcessorFeature) { - return g_fake_cpu->GetDarwinSysCtlByNameValue(name); + return cpu().GetWindowsIsProcessorFeaturePresent(dwProcessorFeature); } -class CpuinfoAarch64Test : public ::testing::Test +extern "C" WORD GetWindowsNativeSystemInfoProcessorRevision() +{ + return cpu().GetWindowsNativeSystemInfoProcessorRevision(); +} +#endif // CPU_FEATURES_OS_WINDOWS + +namespace +{ + +class CpuidAarch64Test : public ::testing::Test { protected: - void SetUp() override { g_fake_cpu = new FakeCpu(); } - void TearDown() override { delete g_fake_cpu; } + void SetUp() override + { + assert(g_fake_cpu_instance == nullptr); + g_fake_cpu_instance = new FakeCpuAarch64(); + } + void TearDown() override + { + delete g_fake_cpu_instance; + g_fake_cpu_instance = nullptr; + } }; -TEST_F(CpuinfoAarch64Test, FromDarwinSysctlFromName) -{ - g_fake_cpu->SetDarwinSysCtlByName("hw.optional.floatingpoint"); - g_fake_cpu->SetDarwinSysCtlByName("hw.optional.neon"); - g_fake_cpu->SetDarwinSysCtlByName("hw.optional.neon_hpfp"); - g_fake_cpu->SetDarwinSysCtlByName("hw.optional.neon_fp16"); - g_fake_cpu->SetDarwinSysCtlByName("hw.optional.armv8_1_atomics"); - g_fake_cpu->SetDarwinSysCtlByName("hw.optional.armv8_crc32"); - g_fake_cpu->SetDarwinSysCtlByName("hw.optional.armv8_2_fhm"); - g_fake_cpu->SetDarwinSysCtlByName("hw.optional.armv8_2_sha512"); - g_fake_cpu->SetDarwinSysCtlByName("hw.optional.armv8_2_sha3"); - g_fake_cpu->SetDarwinSysCtlByName("hw.optional.amx_version"); - g_fake_cpu->SetDarwinSysCtlByName("hw.optional.ucnormal_mem"); - g_fake_cpu->SetDarwinSysCtlByName("hw.optional.arm64"); - - g_fake_cpu->SetDarwinSysCtlByNameValue("hw.cputype", 16777228); - g_fake_cpu->SetDarwinSysCtlByNameValue("hw.cpusubtype", 2); - g_fake_cpu->SetDarwinSysCtlByNameValue("hw.cpu64bit", 1); - g_fake_cpu->SetDarwinSysCtlByNameValue("hw.cpufamily", 458787763); - g_fake_cpu->SetDarwinSysCtlByNameValue("hw.cpusubfamily", 2); - - const auto info = GetAarch64Info(); - - EXPECT_EQ(info.implementer, 0x100000C); - EXPECT_EQ(info.variant, 2); - EXPECT_EQ(info.part, 0x1B588BB3); - EXPECT_EQ(info.revision, 2); - - EXPECT_TRUE(info.features.fp); - EXPECT_FALSE(info.features.asimd); - EXPECT_FALSE(info.features.evtstrm); - EXPECT_FALSE(info.features.aes); - EXPECT_FALSE(info.features.pmull); - EXPECT_FALSE(info.features.sha1); - EXPECT_FALSE(info.features.sha2); - EXPECT_TRUE(info.features.crc32); - EXPECT_TRUE(info.features.atomics); - EXPECT_TRUE(info.features.fphp); - EXPECT_FALSE(info.features.asimdhp); - EXPECT_FALSE(info.features.cpuid); - EXPECT_FALSE(info.features.asimdrdm); - EXPECT_FALSE(info.features.jscvt); - EXPECT_FALSE(info.features.fcma); - EXPECT_FALSE(info.features.lrcpc); - EXPECT_FALSE(info.features.dcpop); - EXPECT_TRUE(info.features.sha3); - EXPECT_FALSE(info.features.sm3); - EXPECT_FALSE(info.features.sm4); - EXPECT_FALSE(info.features.asimddp); - EXPECT_TRUE(info.features.sha512); - EXPECT_FALSE(info.features.sve); - EXPECT_TRUE(info.features.asimdfhm); - EXPECT_FALSE(info.features.dit); - EXPECT_FALSE(info.features.uscat); - EXPECT_FALSE(info.features.ilrcpc); - EXPECT_FALSE(info.features.flagm); - EXPECT_FALSE(info.features.ssbs); - EXPECT_FALSE(info.features.sb); - EXPECT_FALSE(info.features.paca); - EXPECT_FALSE(info.features.pacg); -} - -#else - -void DisableHardwareCapabilities() -{ - SetHardwareCapabilities(0, 0); -} - TEST(CpuinfoAarch64Test, Aarch64FeaturesEnum) { - const char *last_name = GetAarch64FeaturesEnumName(AARCH64_LAST_); + const char* last_name = GetAarch64FeaturesEnumName(AARCH64_LAST_); EXPECT_STREQ(last_name, "unknown_feature"); - for (int i = static_cast(AARCH64_FP); i != static_cast(AARCH64_LAST_); ++i) + for (int i = static_cast(AARCH64_FP); + i != static_cast(AARCH64_LAST_); ++i) { const auto feature = static_cast(i); - const char *name = GetAarch64FeaturesEnumName(feature); + const char* name = GetAarch64FeaturesEnumName(feature); ASSERT_FALSE(name == nullptr); EXPECT_STRNE(name, ""); EXPECT_STRNE(name, last_name); } } +#if defined(CPU_FEATURES_OS_LINUX) +void DisableHardwareCapabilities() +{ + SetHardwareCapabilities(0, 0); +} + TEST(CpuinfoAarch64Test, FromHardwareCap) { ResetHwcaps(); @@ -222,7 +175,7 @@ TEST(CpuinfoAarch64Test, FromHardwareCap2) TEST(CpuinfoAarch64Test, ARMCortexA53) { ResetHwcaps(); - auto &fs = GetEmptyFilesystem(); + auto& fs = GetEmptyFilesystem(); fs.CreateFile("/proc/cpuinfo", R"(Processor : AArch64 Processor rev 3 (aarch64) processor : 0 @@ -301,8 +254,33 @@ CPU revision : 3)"); EXPECT_FALSE(info.features.afp); EXPECT_FALSE(info.features.rpres); } +#endif // CPU_FEATURES_OS_LINUX -#endif +#if defined(CPU_FEATURES_OS_WINDOWS) +TEST_F(CpuidAarch64Test, WINDOWS_AARCH64_RPI4) +{ + cpu().SetWindowsNativeSystemInfoProcessorRevision(0x03); + cpu().SetWindowsIsProcessorFeaturePresent(PF_ARM_VFP_32_REGISTERS_AVAILABLE); + cpu().SetWindowsIsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE); + cpu().SetWindowsIsProcessorFeaturePresent( + PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE); + + const auto info = GetAarch64Info(); + + EXPECT_EQ(info.revision, 0x03); + EXPECT_TRUE(info.features.fp); + EXPECT_TRUE(info.features.asimd); + EXPECT_TRUE(info.features.crc32); + EXPECT_FALSE(info.features.aes); + EXPECT_FALSE(info.features.sha1); + EXPECT_FALSE(info.features.sha2); + EXPECT_FALSE(info.features.pmull); + EXPECT_FALSE(info.features.atomics); + EXPECT_FALSE(info.features.asimddp); + EXPECT_FALSE(info.features.jscvt); + EXPECT_FALSE(info.features.lrcpc); +} +#endif // CPU_FEATURES_OS_WINDOWS } // namespace -} // namespace cpu_features +} // namespace cpu_features \ No newline at end of file diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_x86_test.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_x86_test.cc index f83df2efa..3948e1399 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_x86_test.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/test/cpuinfo_x86_test.cc @@ -1708,6 +1708,41 @@ TEST_F(CpuidX86Test, INTEL_HASWELL_LZCNT) EXPECT_TRUE(info.features.lzcnt); } +// http://users.atw.hu/instlatx64/GenuineIntel/GenuineIntel00B06A2_RaptorLakeP_03_CPUID.txt +TEST_F(CpuidX86Test, INTEL_RAPTOR_LAKE_P) +{ + cpu().SetLeaves({ + {{0x00000000, 0}, Leaf{0x00000020, 0x756E6547, 0x6C65746E, 0x49656E69}}, + {{0x00000001, 0}, Leaf{0x000B06A3, 0x00400800, 0x7FFAFBFF, 0xBFEBFBFF}}, + {{0x80000000, 0}, Leaf{0x80000008, 0x00000000, 0x00000000, 0x00000000}}, + {{0x80000001, 0}, Leaf{0x00000000, 0x00000000, 0x00000121, 0x2C100000}}, + }); + const auto info = GetX86Info(); + + EXPECT_STREQ(info.vendor, CPU_FEATURES_VENDOR_GENUINE_INTEL); + EXPECT_EQ(info.family, 0x06); + EXPECT_EQ(info.model, 0xBA); + EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::INTEL_RPL); +} + +// http://users.atw.hu/instlatx64/GenuineIntel/GenuineIntel00B06F2_RaptorLakeS_02_CPUID.txt +TEST_F(CpuidX86Test, INTEL_RAPTOR_LAKE_S) +{ + cpu().SetLeaves({ + {{0x00000000, 0}, Leaf{0x00000020, 0x756E6547, 0x6C65746E, 0x49656E69}}, + {{0x00000001, 0}, Leaf{0x000B06F2, 0x00800800, 0x7FFAFBFF, 0xBFEBFBFF}}, + {{0x80000000, 0}, Leaf{0x80000008, 0x00000000, 0x00000000, 0x00000000}}, + {{0x80000001, 0}, Leaf{0x00000000, 0x00000000, 0x00000121, 0x2C100000}}, + }); + const auto info = GetX86Info(); + + EXPECT_STREQ(info.vendor, CPU_FEATURES_VENDOR_GENUINE_INTEL); + EXPECT_EQ(info.family, 0x06); + EXPECT_EQ(info.model, 0xBF); + EXPECT_EQ(GetX86Microarchitecture(&info), X86Microarchitecture::INTEL_RPL); +} + + // https://github.com/google/cpu_features/issues/200 // http://users.atw.hu/instlatx64/GenuineIntel/GenuineIntel00206F2_Eagleton_CPUID.txt #if defined(CPU_FEATURES_OS_WINDOWS) From 6004b8f90119e4a114a4053ebe13a71b3c999a64 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 19 Mar 2023 13:53:58 +0100 Subject: [PATCH 07/38] Fix logic for downloading test files (Fixes: #707) --- src/tests/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index af8e96075..53cc054d9 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -471,8 +471,8 @@ if(ENABLE_UNIT_TESTING_EXTRA OR ENABLE_SYSTEM_TESTING_EXTRA OR ENABLE_FPGA) endif() endif() -if(NOT ENABLE_PACKAGING OR NOT ENABLE_UNIT_TESTING_MINIMAL) - message(STATUS "Downloading some data files for testing...") +if(NOT (ENABLE_PACKAGING OR ENABLE_UNIT_TESTING_MINIMAL)) + message(STATUS "Downloading some data files for testing ...") if(NOT EXISTS ${GNSSSDR_BINARY_DIR}/thirdparty/signal_samples/Galileo_E1_ID_1_Fs_4Msps_8ms.dat) message(STATUS "Downloading file: Galileo_E1_ID_1_Fs_4Msps_8ms.dat") file(DOWNLOAD https://sourceforge.net/projects/gnss-sdr/files/data/Galileo_E1_ID_1_Fs_4Msps_8ms.dat @@ -510,7 +510,7 @@ endif() if(ENABLE_UNIT_TESTING_EXTRA) add_definitions(-DEXTRA_TESTS) - message(STATUS "Downloading some extra data files for testing...") + message(STATUS "Downloading some extra data files for testing ...") if(NOT EXISTS ${GNSSSDR_BINARY_DIR}/thirdparty/signal_samples/gps_l2c_m_prn7_5msps.dat) message(STATUS "Downloading file: gps_l2c_m_prn7_5msps.dat") file(DOWNLOAD https://sourceforge.net/projects/gnss-sdr/files/data/gps_l2c_m_prn7_5msps.dat From b99d1afb36044211f9c92a42211afc155e5b1ec6 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 21 Mar 2023 09:24:11 +0100 Subject: [PATCH 08/38] Fix some truncation warnings --- src/algorithms/libs/rtklib/rtklib_ionex.cc | 17 +++++++++-------- src/algorithms/libs/rtklib/rtklib_preceph.cc | 7 +++++-- src/algorithms/libs/rtklib/rtklib_rtkcmn.cc | 10 ++++++---- src/algorithms/libs/rtklib/rtklib_stream.cc | 13 +++++++------ 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/algorithms/libs/rtklib/rtklib_ionex.cc b/src/algorithms/libs/rtklib/rtklib_ionex.cc index 418782557..877044c9e 100644 --- a/src/algorithms/libs/rtklib/rtklib_ionex.cc +++ b/src/algorithms/libs/rtklib/rtklib_ionex.cc @@ -165,16 +165,17 @@ void readionexdcb(FILE *fp, double *dcb, double *rms) if (strstr(label, "PRN / BIAS / RMS") == label) { - strncpy(id, buff + 3, 3); - id[3] = '\0'; - - if (!(sat = satid2no(id))) + int ret = std::snprintf(id, 3, "%s", buff + 3); + if (ret >= 0 && ret < 3) { - trace(2, "ionex invalid satellite: %s\n", id); - continue; + if (!(sat = satid2no(id))) + { + trace(2, "ionex invalid satellite: %s\n", id); + continue; + } + dcb[sat - 1] = str2num(buff, 6, 10); + rms[sat - 1] = str2num(buff, 16, 10); } - dcb[sat - 1] = str2num(buff, 6, 10); - rms[sat - 1] = str2num(buff, 16, 10); } else if (strstr(label, "END OF AUX DATA") == label) { diff --git a/src/algorithms/libs/rtklib/rtklib_preceph.cc b/src/algorithms/libs/rtklib/rtklib_preceph.cc index 9c09dd392..224058d69 100644 --- a/src/algorithms/libs/rtklib/rtklib_preceph.cc +++ b/src/algorithms/libs/rtklib/rtklib_preceph.cc @@ -123,8 +123,11 @@ int readsp3h(FILE *fp, gtime_t *time, char *type, int *sats, } else if (i == 12) { - strncpy(tsys, buff + 9, 3); - tsys[3] = '\0'; + int ret = std::snprintf(tsys, 3, "%s", buff + 9); + if (ret < 0 || ret > 3) + { + trace(3, "Error reading sp3 header\n") + } } else if (i == 14) { diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc index b4074abb8..8f4b68023 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc @@ -2847,11 +2847,13 @@ int readantex(const char *file, pcvs_t *pcvs) { strncpy(pcv.type, buff, 20); // MAXANT (64) pcv.type[20] = '\0'; - strncpy(pcv.code, buff + 20, 20); // MAXANT (64) - pcv.code[20] = '\0'; - if (!strncmp(pcv.code + 3, " ", 8)) + int ret = std::snprintf(pcv.code, 20, "%s", buff + 20); // MAXANT (64) + if (ret >= 0 && ret < 20) { - pcv.sat = satid2no(pcv.code); + if (!strncmp(pcv.code + 3, " ", 8)) + { + pcv.sat = satid2no(pcv.code); + } } } else if (strstr(buff + 60, "VALID FROM")) diff --git a/src/algorithms/libs/rtklib/rtklib_stream.cc b/src/algorithms/libs/rtklib/rtklib_stream.cc index 106598524..ec4b95c08 100644 --- a/src/algorithms/libs/rtklib/rtklib_stream.cc +++ b/src/algorithms/libs/rtklib/rtklib_stream.cc @@ -795,8 +795,11 @@ void decodetcppath(const char *path, char *addr, char *port, char *user, } if (addr) { - std::strncpy(addr, p, 256); - addr[255] = '\0'; + int ret = std::snprintf(addr, 256, "%s", p); + if (ret < 0 || ret >= 256) + { + tracet(1, "error reading address"); + } } } @@ -1077,8 +1080,7 @@ void updatetcpsvr(tcpsvr_t *tcpsvr, char *msg) { continue; } - std::strncpy(saddr, tcpsvr->cli[i].saddr, 256); - saddr[255] = '\0'; + std::snprintf(saddr, 256, "%s", tcpsvr->cli[i].saddr); n++; } if (n == 0) @@ -1968,8 +1970,7 @@ void *ftpthread(void *arg) } if (fs::exists(tmpfile)) { - std::strncpy(ftp->local, tmpfile.c_str(), 1024); - ftp->local[1023] = '\0'; + std::snprintf(ftp->local, 1024, "%s", tmpfile.c_str()); tracet(3, "ftpthread: file exists %s\n", ftp->local); ftp->state = 2; return nullptr; From a75222eb14acd20b41644293c0b221ae7d0ca7b9 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 21 Mar 2023 09:24:56 +0100 Subject: [PATCH 09/38] cpu_features: add missing identifiers for Raptor Lake --- .../cpu_features/src/impl_x86__base_implementation.inl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_x86__base_implementation.inl b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_x86__base_implementation.inl index e18b7cbba..e067f22cd 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_x86__base_implementation.inl +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cpu_features/src/impl_x86__base_implementation.inl @@ -615,6 +615,8 @@ X86Microarchitecture GetX86Microarchitecture(const X86Info* info) // https://en.wikichip.org/wiki/intel/microarchitectures/rocket_lake return INTEL_RCL; case CPUID(0x06, 0xB7): + case CPUID(0x06, 0xBA): + case CPUID(0x06, 0xBF): // https://en.wikichip.org/wiki/intel/microarchitectures/raptor_lake return INTEL_RPL; case CPUID(0x06, 0x85): From 5f5077ffc5ec09193d28a14baee23492eb0ab34a Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 21 Mar 2023 09:26:43 +0100 Subject: [PATCH 10/38] Add missing semicolon --- src/algorithms/libs/rtklib/rtklib_preceph.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/libs/rtklib/rtklib_preceph.cc b/src/algorithms/libs/rtklib/rtklib_preceph.cc index 224058d69..6ab4d8af8 100644 --- a/src/algorithms/libs/rtklib/rtklib_preceph.cc +++ b/src/algorithms/libs/rtklib/rtklib_preceph.cc @@ -126,7 +126,7 @@ int readsp3h(FILE *fp, gtime_t *time, char *type, int *sats, int ret = std::snprintf(tsys, 3, "%s", buff + 9); if (ret < 0 || ret > 3) { - trace(3, "Error reading sp3 header\n") + trace(3, "Error reading sp3 header\n"); } } else if (i == 14) From 8e1818f743028c6a56dfbd8404bc44816821b27d Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 21 Mar 2023 09:53:16 +0100 Subject: [PATCH 11/38] Fix truncation warning --- src/algorithms/libs/rtklib/rtklib_stream.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/algorithms/libs/rtklib/rtklib_stream.cc b/src/algorithms/libs/rtklib/rtklib_stream.cc index ec4b95c08..3c0e56aad 100644 --- a/src/algorithms/libs/rtklib/rtklib_stream.cc +++ b/src/algorithms/libs/rtklib/rtklib_stream.cc @@ -2051,8 +2051,11 @@ void *ftpthread(void *arg) break; } } - std::strncpy(ftp->local, local.c_str(), 1024); - ftp->local[1023] = '\0'; + int ret2 = std::snprintf(ftp->local, 1024, "%s", local.c_str()); + if (ret2 < 0 || ret2 >= 1024) + { + tracet(3, "Error reading ftp local\n"); + } ftp->state = 2; /* ftp completed */ tracet(3, "ftpthread: complete cmd=%s\n", cmd_str.data()); From 318c7cba9fddca71fe2873d06b3715638e21c28a Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 21 Mar 2023 11:06:09 +0100 Subject: [PATCH 12/38] CI: Fix cpplint job --- src/algorithms/libs/rtklib/rtklib_ionex.cc | 2 +- src/algorithms/libs/rtklib/rtklib_preceph.cc | 2 +- src/algorithms/libs/rtklib/rtklib_rtkcmn.cc | 2 +- src/algorithms/libs/rtklib/rtklib_stream.cc | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/algorithms/libs/rtklib/rtklib_ionex.cc b/src/algorithms/libs/rtklib/rtklib_ionex.cc index 877044c9e..58e5653a0 100644 --- a/src/algorithms/libs/rtklib/rtklib_ionex.cc +++ b/src/algorithms/libs/rtklib/rtklib_ionex.cc @@ -165,7 +165,7 @@ void readionexdcb(FILE *fp, double *dcb, double *rms) if (strstr(label, "PRN / BIAS / RMS") == label) { - int ret = std::snprintf(id, 3, "%s", buff + 3); + int ret = std::snprintf(id, 3, "%s", buff + 3); // NOLINT(runtime/printf) if (ret >= 0 && ret < 3) { if (!(sat = satid2no(id))) diff --git a/src/algorithms/libs/rtklib/rtklib_preceph.cc b/src/algorithms/libs/rtklib/rtklib_preceph.cc index 6ab4d8af8..9cbb88509 100644 --- a/src/algorithms/libs/rtklib/rtklib_preceph.cc +++ b/src/algorithms/libs/rtklib/rtklib_preceph.cc @@ -123,7 +123,7 @@ int readsp3h(FILE *fp, gtime_t *time, char *type, int *sats, } else if (i == 12) { - int ret = std::snprintf(tsys, 3, "%s", buff + 9); + int ret = std::snprintf(tsys, 3, "%s", buff + 9); // NOLINT(runtime/printf) if (ret < 0 || ret > 3) { trace(3, "Error reading sp3 header\n"); diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc index 8f4b68023..53c67fa88 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc @@ -2847,7 +2847,7 @@ int readantex(const char *file, pcvs_t *pcvs) { strncpy(pcv.type, buff, 20); // MAXANT (64) pcv.type[20] = '\0'; - int ret = std::snprintf(pcv.code, 20, "%s", buff + 20); // MAXANT (64) + int ret = std::snprintf(pcv.code, 20, "%s", buff + 20); // NOLINT(runtime/printf) if (ret >= 0 && ret < 20) { if (!strncmp(pcv.code + 3, " ", 8)) diff --git a/src/algorithms/libs/rtklib/rtklib_stream.cc b/src/algorithms/libs/rtklib/rtklib_stream.cc index 3c0e56aad..e9a29cf3f 100644 --- a/src/algorithms/libs/rtklib/rtklib_stream.cc +++ b/src/algorithms/libs/rtklib/rtklib_stream.cc @@ -795,7 +795,7 @@ void decodetcppath(const char *path, char *addr, char *port, char *user, } if (addr) { - int ret = std::snprintf(addr, 256, "%s", p); + int ret = std::snprintf(addr, 256, "%s", p); // NOLINT(runtime/printf) if (ret < 0 || ret >= 256) { tracet(1, "error reading address"); @@ -1080,7 +1080,7 @@ void updatetcpsvr(tcpsvr_t *tcpsvr, char *msg) { continue; } - std::snprintf(saddr, 256, "%s", tcpsvr->cli[i].saddr); + std::snprintf(saddr, sizeof(saddr), "%s", tcpsvr->cli[i].saddr); n++; } if (n == 0) @@ -1970,7 +1970,7 @@ void *ftpthread(void *arg) } if (fs::exists(tmpfile)) { - std::snprintf(ftp->local, 1024, "%s", tmpfile.c_str()); + std::snprintf(ftp->local, 1024, "%s", tmpfile.c_str()); // NOLINT(runtime/printf) tracet(3, "ftpthread: file exists %s\n", ftp->local); ftp->state = 2; return nullptr; @@ -2051,7 +2051,7 @@ void *ftpthread(void *arg) break; } } - int ret2 = std::snprintf(ftp->local, 1024, "%s", local.c_str()); + int ret2 = std::snprintf(ftp->local, 1024, "%s", local.c_str()); // NOLINT(runtime/printf) if (ret2 < 0 || ret2 >= 1024) { tracet(3, "Error reading ftp local\n"); From 3a235e4859dfb2744bf71c941817a66e53574de5 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 21 Mar 2023 11:06:43 +0100 Subject: [PATCH 13/38] Remove unused variable, avoids warning --- .../libs/supl/asn-rrlp/UncompressedEphemeris.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/core/libs/supl/asn-rrlp/UncompressedEphemeris.c b/src/core/libs/supl/asn-rrlp/UncompressedEphemeris.c index 52dc2afef..1ea4deee4 100644 --- a/src/core/libs/supl/asn-rrlp/UncompressedEphemeris.c +++ b/src/core/libs/supl/asn-rrlp/UncompressedEphemeris.c @@ -12,7 +12,7 @@ static int ephemE_17_constraint(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - unsigned long value; + // unsigned long value; if (!sptr) { @@ -21,7 +21,7 @@ static int ephemE_17_constraint(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - value = *(const unsigned long *)sptr; + // value = *(const unsigned long *)sptr; /* Constraint check succeeded */ return 0; @@ -132,7 +132,7 @@ static int ephemAPowerHalf_19_constraint(asn_TYPE_descriptor_t *td, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - unsigned long value; + // unsigned long value; if (!sptr) { @@ -141,7 +141,7 @@ static int ephemAPowerHalf_19_constraint(asn_TYPE_descriptor_t *td, return -1; } - value = *(const unsigned long *)sptr; + // value = *(const unsigned long *)sptr; /* Constraint check succeeded */ return 0; @@ -647,7 +647,7 @@ static int memb_ephemE_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - unsigned long value; + // unsigned long value; if (!sptr) { @@ -656,7 +656,7 @@ static int memb_ephemE_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, return -1; } - value = *(const unsigned long *)sptr; + // value = *(const unsigned long *)sptr; /* Constraint check succeeded */ return 0; @@ -695,7 +695,7 @@ static int memb_ephemAPowerHalf_constraint_1( asn_TYPE_descriptor_t *td, const void *sptr, asn_app_constraint_failed_f *ctfailcb, void *app_key) { - unsigned long value; + // unsigned long value; if (!sptr) { @@ -704,7 +704,7 @@ static int memb_ephemAPowerHalf_constraint_1( return -1; } - value = *(const unsigned long *)sptr; + // value = *(const unsigned long *)sptr; /* Constraint check succeeded */ return 0; From 29cf1c246bf8253c285b0eb962e57528282222fb Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 25 Mar 2023 14:05:01 +0100 Subject: [PATCH 14/38] Improve copy and move constructors and assignment operators --- src/algorithms/PVT/libs/serdes_galileo_eph.h | 8 +- src/algorithms/PVT/libs/serdes_gps_eph.h | 8 +- src/algorithms/PVT/libs/serdes_monitor_pvt.h | 7 +- src/core/libs/serdes_nav_message.h | 25 ----- src/core/system_parameters/gnss_satellite.cc | 20 ++-- src/core/system_parameters/gnss_synchro.h | 40 ++++++-- .../libs/acquisition_dump_reader.cc | 97 ++++++++++++++++--- .../libs/acquisition_dump_reader.h | 12 +-- 8 files changed, 148 insertions(+), 69 deletions(-) diff --git a/src/algorithms/PVT/libs/serdes_galileo_eph.h b/src/algorithms/PVT/libs/serdes_galileo_eph.h index 94c954d1c..0767b1458 100644 --- a/src/algorithms/PVT/libs/serdes_galileo_eph.h +++ b/src/algorithms/PVT/libs/serdes_galileo_eph.h @@ -55,7 +55,8 @@ public: inline Serdes_Galileo_Eph& operator=(const Serdes_Galileo_Eph& rhs) noexcept //!< Copy assignment operator { - this->monitor_ = rhs.monitor_; + Serdes_Galileo_Eph temp(rhs); + std::swap(this->monitor_, temp.monitor_); return *this; } @@ -65,10 +66,7 @@ public: inline Serdes_Galileo_Eph& operator=(Serdes_Galileo_Eph&& other) noexcept //!< Move assignment operator { - if (this != &other) - { - this->monitor_ = std::move(other.monitor_); - } + std::swap(this->monitor_, other.monitor_); return *this; } diff --git a/src/algorithms/PVT/libs/serdes_gps_eph.h b/src/algorithms/PVT/libs/serdes_gps_eph.h index 7ffcaa28d..a402dd187 100644 --- a/src/algorithms/PVT/libs/serdes_gps_eph.h +++ b/src/algorithms/PVT/libs/serdes_gps_eph.h @@ -54,7 +54,8 @@ public: inline Serdes_Gps_Eph& operator=(const Serdes_Gps_Eph& rhs) noexcept //!< Copy assignment operator { - this->monitor_ = rhs.monitor_; + Serdes_Gps_Eph temp(rhs); + std::swap(this->monitor_, temp.monitor_); return *this; } @@ -64,10 +65,7 @@ public: inline Serdes_Gps_Eph& operator=(Serdes_Gps_Eph&& other) noexcept //!< Move assignment operator { - if (this != &other) - { - this->monitor_ = std::move(other.monitor_); - } + std::swap(this->monitor_, other.monitor_); return *this; } diff --git a/src/algorithms/PVT/libs/serdes_monitor_pvt.h b/src/algorithms/PVT/libs/serdes_monitor_pvt.h index b282e30bd..a792e18d6 100644 --- a/src/algorithms/PVT/libs/serdes_monitor_pvt.h +++ b/src/algorithms/PVT/libs/serdes_monitor_pvt.h @@ -55,12 +55,17 @@ public: inline Serdes_Monitor_Pvt& operator=(const Serdes_Monitor_Pvt& rhs) noexcept //!< Copy assignment operator { - this->monitor_ = rhs.monitor_; + if (this != &rhs) + { + this->monitor_.CopyFrom(rhs.monitor_); + } return *this; } inline Serdes_Monitor_Pvt(Serdes_Monitor_Pvt&& other) noexcept : monitor_(std::move(other.monitor_)) //!< Move constructor { + // Set the other object's monitor_ to a default-constructed state + other.monitor_ = gnss_sdr::MonitorPvt{}; } inline Serdes_Monitor_Pvt& operator=(Serdes_Monitor_Pvt&& other) noexcept //!< Move assignment operator diff --git a/src/core/libs/serdes_nav_message.h b/src/core/libs/serdes_nav_message.h index 0b7520ca9..98c53007f 100644 --- a/src/core/libs/serdes_nav_message.h +++ b/src/core/libs/serdes_nav_message.h @@ -50,31 +50,6 @@ public: // google::protobuf::ShutdownProtobufLibrary(); } - inline Serdes_Nav_Message(const Serdes_Nav_Message& other) noexcept //!< Copy constructor - { - this->navmsg_ = other.navmsg_; - } - - inline Serdes_Nav_Message& operator=(const Serdes_Nav_Message& rhs) noexcept //!< Copy assignment operator - { - this->navmsg_ = rhs.navmsg_; - return *this; - } - - inline Serdes_Nav_Message(Serdes_Nav_Message&& other) noexcept //!< Move constructor - { - this->navmsg_ = std::move(other.navmsg_); - } - - inline Serdes_Nav_Message& operator=(Serdes_Nav_Message&& other) noexcept //!< Move assignment operator - { - if (this != &other) - { - this->navmsg_ = std::move(other.navmsg_); - } - return *this; - } - inline std::string createProtobuffer(const std::shared_ptr nav_msg_packet) //!< Serialization into a string { navmsg_.Clear(); diff --git a/src/core/system_parameters/gnss_satellite.cc b/src/core/system_parameters/gnss_satellite.cc index 5c89ede73..9c386fb9b 100644 --- a/src/core/system_parameters/gnss_satellite.cc +++ b/src/core/system_parameters/gnss_satellite.cc @@ -74,7 +74,10 @@ bool operator==(const Gnss_Satellite& sat1, const Gnss_Satellite& sat2) // Copy constructor Gnss_Satellite::Gnss_Satellite(const Gnss_Satellite& other) noexcept { - *this = other; + system = other.system; + block = other.block; + PRN = other.PRN; + rf_link = other.rf_link; } @@ -96,7 +99,11 @@ Gnss_Satellite& Gnss_Satellite::operator=(const Gnss_Satellite& rhs) // Move constructor Gnss_Satellite::Gnss_Satellite(Gnss_Satellite&& other) noexcept { - *this = std::move(other); + system = std::move(other.system); + block = std::move(other.block); + PRN = other.PRN; + rf_link = other.rf_link; + other.reset(); } @@ -105,10 +112,11 @@ Gnss_Satellite& Gnss_Satellite::operator=(Gnss_Satellite&& other) noexcept { if (this != &other) { - this->system = other.get_system(); - this->block = other.get_block(); - this->PRN = other.get_PRN(); - this->rf_link = other.get_rf_link(); + system = std::move(other.system); + block = std::move(other.block); + PRN = other.PRN; + rf_link = other.rf_link; + other.reset(); } return *this; } diff --git a/src/core/system_parameters/gnss_synchro.h b/src/core/system_parameters/gnss_synchro.h index f2934f5de..4d8b75569 100644 --- a/src/core/system_parameters/gnss_synchro.h +++ b/src/core/system_parameters/gnss_synchro.h @@ -81,10 +81,7 @@ public: bool Flag_PLL_180_deg_phase_locked{}; //!< Set by Telemetry Decoder processing block /// Copy constructor - Gnss_Synchro(const Gnss_Synchro& other) noexcept - { - *this = other; - }; + Gnss_Synchro(const Gnss_Synchro& other) noexcept = default; /// Copy assignment operator Gnss_Synchro& operator=(const Gnss_Synchro& rhs) noexcept @@ -125,10 +122,7 @@ public: }; /// Move constructor - Gnss_Synchro(Gnss_Synchro&& other) noexcept - { - *this = std::move(other); - }; + Gnss_Synchro(Gnss_Synchro&& other) noexcept = default; /// Move assignment operator Gnss_Synchro& operator=(Gnss_Synchro&& other) noexcept @@ -163,6 +157,36 @@ public: this->Flag_valid_word = other.Flag_valid_word; this->Flag_valid_pseudorange = other.Flag_valid_pseudorange; this->Flag_PLL_180_deg_phase_locked = other.Flag_PLL_180_deg_phase_locked; + + // Leave the source object in a valid but unspecified state + other.Signal[0] = '\0'; + other.Signal[1] = '\0'; + other.Signal[2] = '\0'; + other.System = 0; + other.PRN = 0; + other.Channel_ID = 0; + other.Acq_delay_samples = 0.0; + other.Acq_doppler_hz = 0.0; + other.Acq_samplestamp_samples = 0; + other.Acq_doppler_step = 0; + other.fs = 0; + other.Prompt_I = 0.0; + other.Prompt_Q = 0.0; + other.CN0_dB_hz = 0.0; + other.Carrier_Doppler_hz = 0.0; + other.Carrier_phase_rads = 0.0; + other.Code_phase_samples = 0.0; + other.Tracking_sample_counter = 0; + other.correlation_length_ms = 0; + other.TOW_at_current_symbol_ms = 0; + other.Pseudorange_m = 0.0; + other.RX_time = 0.0; + other.interp_TOW_ms = 0.0; + other.Flag_valid_acquisition = false; + other.Flag_valid_symbol_output = false; + other.Flag_valid_word = false; + other.Flag_valid_pseudorange = false; + other.Flag_PLL_180_deg_phase_locked = false; } return *this; }; diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc index 66a6ebf7b..da08e0367 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc +++ b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc @@ -18,6 +18,7 @@ #include "acquisition_dump_reader.h" #include +#include #include #include #include @@ -27,13 +28,13 @@ bool Acquisition_Dump_Reader::read_binary_acq() mat_t* matfile = Mat_Open(d_dump_filename.c_str(), MAT_ACC_RDONLY); if (matfile == nullptr) { - std::cout << "¡¡¡Unreachable Acquisition dump file!!!\n"; + std::cout << "Unreachable Acquisition dump file " << d_dump_filename << '\n'; return false; } matvar_t* var_ = Mat_VarRead(matfile, "acq_grid"); if (var_ == nullptr) { - std::cout << "¡¡¡Unreachable grid variable into Acquisition dump file!!!\n"; + std::cout << "Unreachable grid variable in Acquisition dump file.\n"; Mat_Close(matfile); return false; } @@ -162,7 +163,7 @@ Acquisition_Dump_Reader::Acquisition_Dump_Reader(const std::string& basename, } else { - std::cout << "¡¡¡Unreachable Acquisition dump file!!!\n"; + std::cout << "Unreachable Acquisition dump file " << d_dump_filename << '\n'; } acq_doppler_hz = 0.0; acq_delay_samples = 0.0; @@ -222,18 +223,53 @@ Acquisition_Dump_Reader::Acquisition_Dump_Reader(const std::string& basename, // Copy constructor Acquisition_Dump_Reader::Acquisition_Dump_Reader(const Acquisition_Dump_Reader& other) noexcept + : doppler(other.doppler), + samples(other.samples), + mag(other.mag), + acq_doppler_hz(other.acq_doppler_hz), + acq_delay_samples(other.acq_delay_samples), + test_statistic(other.test_statistic), + input_power(other.input_power), + threshold(other.threshold), + positive_acq(other.positive_acq), + PRN(other.PRN), + num_dwells(other.num_dwells), + sample_counter(other.sample_counter), + d_basename(other.d_basename), + d_dump_filename(other.d_dump_filename), + d_sat(other.d_sat), + d_doppler_max(other.d_doppler_max), + d_doppler_step(other.d_doppler_step), + d_samples_per_code(other.d_samples_per_code), + d_num_doppler_bins(other.d_num_doppler_bins) { - *this = other; } // Copy assignment operator -Acquisition_Dump_Reader& Acquisition_Dump_Reader::operator=(const Acquisition_Dump_Reader& rhs) +Acquisition_Dump_Reader& Acquisition_Dump_Reader::operator=(const Acquisition_Dump_Reader& other) noexcept { - // Only do assignment if RHS is a different object from this. - if (this != &rhs) + if (this != &other) { - *this = rhs; + doppler = other.doppler; + samples = other.samples; + mag = other.mag; + acq_doppler_hz = other.acq_doppler_hz; + acq_delay_samples = other.acq_delay_samples; + test_statistic = other.test_statistic; + input_power = other.input_power; + threshold = other.threshold; + positive_acq = other.positive_acq; + PRN = other.PRN; + num_dwells = other.num_dwells; + sample_counter = other.sample_counter; + d_basename = other.d_basename; + d_dump_filename = other.d_dump_filename; + d_sat = other.d_sat; + d_doppler_max = other.d_doppler_max; + d_doppler_step = other.d_doppler_step; + d_samples_per_code = other.d_samples_per_code; + d_num_doppler_bins = other.d_num_doppler_bins; } return *this; } @@ -241,17 +277,54 @@ Acquisition_Dump_Reader& Acquisition_Dump_Reader::operator=(const Acquisition_Du // Move constructor Acquisition_Dump_Reader::Acquisition_Dump_Reader(Acquisition_Dump_Reader&& other) noexcept + : doppler(std::move(other.doppler)), + samples(std::move(other.samples)), + mag(std::move(other.mag)), + acq_doppler_hz(other.acq_doppler_hz), + acq_delay_samples(other.acq_delay_samples), + test_statistic(other.test_statistic), + input_power(other.input_power), + threshold(other.threshold), + positive_acq(other.positive_acq), + PRN(other.PRN), + num_dwells(other.num_dwells), + sample_counter(other.sample_counter), + d_basename(std::move(other.d_basename)), + d_dump_filename(std::move(other.d_dump_filename)), + d_sat(other.d_sat), + d_doppler_max(other.d_doppler_max), + d_doppler_step(other.d_doppler_step), + d_samples_per_code(other.d_samples_per_code), + d_num_doppler_bins(other.d_num_doppler_bins) { - *this = std::move(other); } // Move assignment operator Acquisition_Dump_Reader& Acquisition_Dump_Reader::operator=(Acquisition_Dump_Reader&& other) noexcept { - if (this != &other) + if (this != &other) // Check for self-assignment { - *this = other; + // Move member variables from the other object to this object + d_basename = std::move(other.d_basename); + d_dump_filename = std::move(other.d_dump_filename); + d_sat = std::move(other.d_sat); + d_doppler_max = std::move(other.d_doppler_max); + d_doppler_step = std::move(other.d_doppler_step); + d_samples_per_code = std::move(other.d_samples_per_code); + d_num_doppler_bins = std::move(other.d_num_doppler_bins); + doppler = std::move(other.doppler); + samples = std::move(other.samples); + mag = std::move(other.mag); + acq_doppler_hz = std::move(other.acq_doppler_hz); + acq_delay_samples = std::move(other.acq_delay_samples); + test_statistic = std::move(other.test_statistic); + input_power = std::move(other.input_power); + threshold = std::move(other.threshold); + positive_acq = std::move(other.positive_acq); + PRN = std::move(other.PRN); + num_dwells = std::move(other.num_dwells); + sample_counter = std::move(other.sample_counter); } return *this; -} +} \ No newline at end of file diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.h b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.h index 3c6142a7d..b28e42742 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.h +++ b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.h @@ -37,12 +37,10 @@ public: int channel = 0, int execution = 1); - ~Acquisition_Dump_Reader() = default; - - Acquisition_Dump_Reader(const Acquisition_Dump_Reader& other) noexcept; //!< Copy constructor - Acquisition_Dump_Reader& operator=(const Acquisition_Dump_Reader&); //!< Copy assignment operator - Acquisition_Dump_Reader(Acquisition_Dump_Reader&& other) noexcept; //!< Move constructor - Acquisition_Dump_Reader& operator=(Acquisition_Dump_Reader&& other) noexcept; //!< Move assignment operator + Acquisition_Dump_Reader(const Acquisition_Dump_Reader& other) noexcept; //!< Copy constructor + Acquisition_Dump_Reader& operator=(const Acquisition_Dump_Reader& other) noexcept; //!< Copy assignment operator + Acquisition_Dump_Reader(Acquisition_Dump_Reader&& other) noexcept; //!< Move constructor + Acquisition_Dump_Reader& operator=(Acquisition_Dump_Reader&& other) noexcept; //!< Move assignment operator bool read_binary_acq(); @@ -61,12 +59,12 @@ public: private: std::string d_basename; + std::string d_dump_filename; unsigned int d_sat{}; unsigned int d_doppler_max{}; unsigned int d_doppler_step{}; unsigned int d_samples_per_code{}; unsigned int d_num_doppler_bins{}; - std::string d_dump_filename; }; #endif // GNSS_SDR_ACQUISITION_DUMP_READER_H From c3c10987902d1384305e6716f86e56dc418d0600 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 25 Mar 2023 14:31:15 +0100 Subject: [PATCH 15/38] Define HAS ICD tables as const unordered_map, so they don't need to be recreated each time --- src/core/system_parameters/Galileo_CNAV.h | 59 +++++++++++++++ .../system_parameters/galileo_has_data.cc | 73 ++----------------- 2 files changed, 67 insertions(+), 65 deletions(-) diff --git a/src/core/system_parameters/Galileo_CNAV.h b/src/core/system_parameters/Galileo_CNAV.h index 226b1d888..ebb7d5bba 100644 --- a/src/core/system_parameters/Galileo_CNAV.h +++ b/src/core/system_parameters/Galileo_CNAV.h @@ -22,6 +22,8 @@ #include #include +#include +#include #include /** \addtogroup Core @@ -116,6 +118,63 @@ const std::pair GALILEO_MT1_HEADER_RESERVED({19, 4}); const std::pair GALILEO_MT1_HEADER_MASK_ID({23, 5}); const std::pair GALILEO_MT1_HEADER_IOD_SET_ID({28, 5}); +// HAS SIS ICD v1.0 Table 20 +const std::unordered_map> HAS_SIGNAL_INDEX_TABLE = { + {0, { + {0, "L1 C/A"}, + {1, "Reserved"}, + {2, "Reserved"}, + {3, "L1C(D)"}, + {4, "L1C(P)"}, + {5, "L1C(D+P)"}, + {6, "L2 CM"}, + {7, "L2 CL"}, + {8, "L2 CM+CL"}, + {9, "L2 P"}, + {10, "Reserved"}, + {11, "L5 I"}, + {12, "L5 Q"}, + {13, "L5 I + L5 Q"}, + {14, "Reserved"}, + {15, "Reserved"}, + }}, + {2, { + {0, "E1-B I/NAV OS"}, + {1, "E1-C"}, + {2, "E1-B + E1-C"}, + {3, "E5a-I F/NAV OS"}, + {4, "E5a-Q"}, + {5, "E5a-I+E5a-Q"}, + {6, "E5b-I I/NAV OS"}, + {7, "E5b-Q"}, + {8, "E5b-I+E5b-Q"}, + {9, "E5-I"}, + {10, "E5-Q"}, + {11, "E5-I + E5-Q"}, + {12, "E6-B C/NAV HAS"}, + {13, "E6-C"}, + {14, "E6-B + E6-C"}, + {15, "Reserved"}, + }}}; + +// HAS SIS ICD v1.0 Table 23 +const std::unordered_map HAS_VALIDITY_INTERVALS = { + {0, 5}, + {1, 10}, + {2, 15}, + {3, 20}, + {4, 30}, + {5, 60}, + {6, 90}, + {7, 120}, + {8, 180}, + {9, 240}, + {10, 300}, + {11, 600}, + {12, 900}, + {13, 1800}, + {14, 3600}}; + /** \} */ /** \} */ diff --git a/src/core/system_parameters/galileo_has_data.cc b/src/core/system_parameters/galileo_has_data.cc index 5168e33bf..2e722f64a 100644 --- a/src/core/system_parameters/galileo_has_data.cc +++ b/src/core/system_parameters/galileo_has_data.cc @@ -19,10 +19,9 @@ #include #include #include -#include #include #include -#include +#include #include @@ -32,44 +31,6 @@ std::vector Galileo_HAS_data::get_signals_in_mask(uint8_t nsys) con { return {}; } - // See HAS SIS ICD v1.0 Table 20 - std::unordered_map> signal_index_table = { - {0, { - {0, "L1 C/A"}, - {1, "Reserved"}, - {2, "Reserved"}, - {3, "L1C(D)"}, - {4, "L1C(P)"}, - {5, "L1C(D+P)"}, - {6, "L2 CM"}, - {7, "L2 CL"}, - {8, "L2 CM+CL"}, - {9, "L2 P"}, - {10, "Reserved"}, - {11, "L5 I"}, - {12, "L5 Q"}, - {13, "L5 I + L5 Q"}, - {14, "Reserved"}, - {15, "Reserved"}, - }}, - {2, { - {0, "E1-B I/NAV OS"}, - {1, "E1-C"}, - {2, "E1-B + E1-C"}, - {3, "E5a-I F/NAV OS"}, - {4, "E5a-Q"}, - {5, "E5a-I+E5a-Q"}, - {6, "E5b-I I/NAV OS"}, - {7, "E5b-Q"}, - {8, "E5b-I+E5b-Q"}, - {9, "E5-I"}, - {10, "E5-Q"}, - {11, "E5-I + E5-Q"}, - {12, "E6-B C/NAV HAS"}, - {13, "E6-C"}, - {14, "E6-B + E6-C"}, - {15, "Reserved"}, - }}}; std::vector signals_in_mask; uint16_t sig = signal_mask[nsys]; @@ -80,14 +41,14 @@ std::vector Galileo_HAS_data::get_signals_in_mask(uint8_t nsys) con { if ((bits[HAS_MSG_NUMBER_SIGNAL_MASKS - k - 1])) { - if (signal_index_table[system].count(k) == 0) + try + { + signals_in_mask.emplace_back(HAS_SIGNAL_INDEX_TABLE.at(system).at(k)); + } + catch (const std::out_of_range& e) { signals_in_mask.emplace_back("Unknown"); } - else - { - signals_in_mask.push_back(signal_index_table[system][k]); - } } } return signals_in_mask; @@ -923,26 +884,8 @@ uint16_t Galileo_HAS_data::get_nsat_sub() const uint16_t Galileo_HAS_data::get_validity_interval_s(uint8_t validity_interval_index) const { - // See HAS SIS ICD v1.0 Table 23 - const std::map validity_intervals = { - {0, 5}, - {1, 10}, - {2, 15}, - {3, 20}, - {4, 30}, - {5, 60}, - {6, 90}, - {7, 120}, - {8, 180}, - {9, 240}, - {10, 300}, - {11, 600}, - {12, 900}, - {13, 1800}, - {14, 3600}}; - - auto it = validity_intervals.find(validity_interval_index); - if (it == validity_intervals.end()) + const auto it = HAS_VALIDITY_INTERVALS.find(validity_interval_index); + if (it == HAS_VALIDITY_INTERVALS.cend()) { return 0; } From 090017dfaa583da234487c941007d0f9c299a3fa Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 25 Mar 2023 18:11:29 +0100 Subject: [PATCH 16/38] Improve copy and move constructors --- src/core/system_parameters/gnss_satellite.cc | 18 +++---- src/core/system_parameters/gnss_satellite.h | 2 +- .../libs/acquisition_dump_reader.cc | 52 +++++-------------- .../libs/acquisition_dump_reader.h | 2 +- 4 files changed, 25 insertions(+), 49 deletions(-) diff --git a/src/core/system_parameters/gnss_satellite.cc b/src/core/system_parameters/gnss_satellite.cc index 9c386fb9b..7f1b1030c 100644 --- a/src/core/system_parameters/gnss_satellite.cc +++ b/src/core/system_parameters/gnss_satellite.cc @@ -73,16 +73,16 @@ bool operator==(const Gnss_Satellite& sat1, const Gnss_Satellite& sat2) // Copy constructor Gnss_Satellite::Gnss_Satellite(const Gnss_Satellite& other) noexcept + : system(other.system), + block(other.block), + PRN(other.PRN), + rf_link(other.rf_link) { - system = other.system; - block = other.block; - PRN = other.PRN; - rf_link = other.rf_link; } // Copy assignment operator -Gnss_Satellite& Gnss_Satellite::operator=(const Gnss_Satellite& rhs) +Gnss_Satellite& Gnss_Satellite::operator=(const Gnss_Satellite& rhs) noexcept { // Only do assignment if RHS is a different object from this. if (this != &rhs) @@ -98,11 +98,11 @@ Gnss_Satellite& Gnss_Satellite::operator=(const Gnss_Satellite& rhs) // Move constructor Gnss_Satellite::Gnss_Satellite(Gnss_Satellite&& other) noexcept + : system(std::move(other.system)), + block(std::move(other.block)), + PRN(other.PRN), + rf_link(other.rf_link) { - system = std::move(other.system); - block = std::move(other.block); - PRN = other.PRN; - rf_link = other.rf_link; other.reset(); } diff --git a/src/core/system_parameters/gnss_satellite.h b/src/core/system_parameters/gnss_satellite.h index 9830e2a0b..e7a2759f8 100644 --- a/src/core/system_parameters/gnss_satellite.h +++ b/src/core/system_parameters/gnss_satellite.h @@ -44,7 +44,7 @@ public: ~Gnss_Satellite() = default; //!< Default Destructor. Gnss_Satellite(const Gnss_Satellite& other) noexcept; //!< Copy constructor - Gnss_Satellite& operator=(const Gnss_Satellite&); //!< Copy assignment operator + Gnss_Satellite& operator=(const Gnss_Satellite&) noexcept; //!< Copy assignment operator Gnss_Satellite(Gnss_Satellite&& other) noexcept; //!< Move constructor Gnss_Satellite& operator=(Gnss_Satellite&& other) noexcept; //!< Move assignment operator diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc index da08e0367..fb87911d6 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc +++ b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc @@ -221,30 +221,6 @@ Acquisition_Dump_Reader::Acquisition_Dump_Reader(const std::string& basename, } } -// Copy constructor -Acquisition_Dump_Reader::Acquisition_Dump_Reader(const Acquisition_Dump_Reader& other) noexcept - : doppler(other.doppler), - samples(other.samples), - mag(other.mag), - acq_doppler_hz(other.acq_doppler_hz), - acq_delay_samples(other.acq_delay_samples), - test_statistic(other.test_statistic), - input_power(other.input_power), - threshold(other.threshold), - positive_acq(other.positive_acq), - PRN(other.PRN), - num_dwells(other.num_dwells), - sample_counter(other.sample_counter), - d_basename(other.d_basename), - d_dump_filename(other.d_dump_filename), - d_sat(other.d_sat), - d_doppler_max(other.d_doppler_max), - d_doppler_step(other.d_doppler_step), - d_samples_per_code(other.d_samples_per_code), - d_num_doppler_bins(other.d_num_doppler_bins) -{ -} - // Copy assignment operator Acquisition_Dump_Reader& Acquisition_Dump_Reader::operator=(const Acquisition_Dump_Reader& other) noexcept @@ -308,23 +284,23 @@ Acquisition_Dump_Reader& Acquisition_Dump_Reader::operator=(Acquisition_Dump_Rea // Move member variables from the other object to this object d_basename = std::move(other.d_basename); d_dump_filename = std::move(other.d_dump_filename); - d_sat = std::move(other.d_sat); - d_doppler_max = std::move(other.d_doppler_max); - d_doppler_step = std::move(other.d_doppler_step); - d_samples_per_code = std::move(other.d_samples_per_code); - d_num_doppler_bins = std::move(other.d_num_doppler_bins); + d_sat = other.d_sat; + d_doppler_max = other.d_doppler_max; + d_doppler_step = other.d_doppler_step; + d_samples_per_code = other.d_samples_per_code; + d_num_doppler_bins = other.d_num_doppler_bins; doppler = std::move(other.doppler); samples = std::move(other.samples); mag = std::move(other.mag); - acq_doppler_hz = std::move(other.acq_doppler_hz); - acq_delay_samples = std::move(other.acq_delay_samples); - test_statistic = std::move(other.test_statistic); - input_power = std::move(other.input_power); - threshold = std::move(other.threshold); - positive_acq = std::move(other.positive_acq); - PRN = std::move(other.PRN); - num_dwells = std::move(other.num_dwells); - sample_counter = std::move(other.sample_counter); + acq_doppler_hz = other.acq_doppler_hz; + acq_delay_samples = other.acq_delay_samples; + test_statistic = other.test_statistic; + input_power = other.input_power; + threshold = other.threshold; + positive_acq = other.positive_acq; + PRN = other.PRN; + num_dwells = other.num_dwells; + sample_counter = other.sample_counter; } return *this; } \ No newline at end of file diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.h b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.h index b28e42742..8c38b30fe 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.h +++ b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.h @@ -37,7 +37,7 @@ public: int channel = 0, int execution = 1); - Acquisition_Dump_Reader(const Acquisition_Dump_Reader& other) noexcept; //!< Copy constructor + Acquisition_Dump_Reader(const Acquisition_Dump_Reader& other) noexcept = default; //!< Copy constructor Acquisition_Dump_Reader& operator=(const Acquisition_Dump_Reader& other) noexcept; //!< Copy assignment operator Acquisition_Dump_Reader(Acquisition_Dump_Reader&& other) noexcept; //!< Move constructor Acquisition_Dump_Reader& operator=(Acquisition_Dump_Reader&& other) noexcept; //!< Move assignment operator From 2eed0baefbf88d0a8233d2e2333bf99c44e40e24 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 25 Mar 2023 19:29:41 +0100 Subject: [PATCH 17/38] Fix for GCC 4.8 --- .../signal-processing-blocks/libs/acquisition_dump_reader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.h b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.h index 8c38b30fe..24d63f196 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.h +++ b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.h @@ -37,7 +37,7 @@ public: int channel = 0, int execution = 1); - Acquisition_Dump_Reader(const Acquisition_Dump_Reader& other) noexcept = default; //!< Copy constructor + Acquisition_Dump_Reader(const Acquisition_Dump_Reader& other) = default; //!< Copy constructor Acquisition_Dump_Reader& operator=(const Acquisition_Dump_Reader& other) noexcept; //!< Copy assignment operator Acquisition_Dump_Reader(Acquisition_Dump_Reader&& other) noexcept; //!< Move constructor Acquisition_Dump_Reader& operator=(Acquisition_Dump_Reader&& other) noexcept; //!< Move assignment operator From 79ebc32d8cfa477c78ee14845284dd7662935c78 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 26 Mar 2023 17:06:35 +0200 Subject: [PATCH 18/38] Remove noexpect from the copy assignment operator --- .../libs/acquisition_dump_reader.cc | 2 +- .../libs/acquisition_dump_reader.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc index fb87911d6..07b5ff7a4 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc +++ b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc @@ -223,7 +223,7 @@ Acquisition_Dump_Reader::Acquisition_Dump_Reader(const std::string& basename, // Copy assignment operator -Acquisition_Dump_Reader& Acquisition_Dump_Reader::operator=(const Acquisition_Dump_Reader& other) noexcept +Acquisition_Dump_Reader& Acquisition_Dump_Reader::operator=(const Acquisition_Dump_Reader& other) { if (this != &other) { diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.h b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.h index 24d63f196..691e104f1 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.h +++ b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.h @@ -37,10 +37,10 @@ public: int channel = 0, int execution = 1); - Acquisition_Dump_Reader(const Acquisition_Dump_Reader& other) = default; //!< Copy constructor - Acquisition_Dump_Reader& operator=(const Acquisition_Dump_Reader& other) noexcept; //!< Copy assignment operator - Acquisition_Dump_Reader(Acquisition_Dump_Reader&& other) noexcept; //!< Move constructor - Acquisition_Dump_Reader& operator=(Acquisition_Dump_Reader&& other) noexcept; //!< Move assignment operator + Acquisition_Dump_Reader(const Acquisition_Dump_Reader& other) = default; //!< Copy constructor + Acquisition_Dump_Reader& operator=(const Acquisition_Dump_Reader& other); //!< Copy assignment operator + Acquisition_Dump_Reader(Acquisition_Dump_Reader&& other) noexcept; //!< Move constructor + Acquisition_Dump_Reader& operator=(Acquisition_Dump_Reader&& other) noexcept; //!< Move assignment operator bool read_binary_acq(); From bf3c3918ef0dcce624642aa71e927966b6ceeeb4 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 31 Mar 2023 13:23:31 +0200 Subject: [PATCH 19/38] Update local version of Protocol Buffers to v22.2 (requires abseil-cpp >= 20230117). If abseil is not found or is too old, it falls back to Protocol Buffers v21.12 --- CMakeLists.txt | 273 +++++++++++++++++------------- README.md | 35 ++-- cmake/Modules/BuildProtobuf.cmake | 172 +++++++++++++++++++ docs/CHANGELOG.md | 8 + src/tests/data/protobuf22.patch | 12 ++ 5 files changed, 361 insertions(+), 139 deletions(-) create mode 100644 cmake/Modules/BuildProtobuf.cmake create mode 100644 src/tests/data/protobuf22.patch diff --git a/CMakeLists.txt b/CMakeLists.txt index 2222702cd..97c618979 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -351,7 +351,10 @@ else() endif() set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.23") set(GNSSSDR_PUGIXML_LOCAL_VERSION "1.13") -set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "21.9") +set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "22.2") +if(CMAKE_CROSSCOMPILING OR CMAKE_VERSION VERSION_LESS "3.13") + set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "21.12") +endif() set(GNSSSDR_BENCHMARK_LOCAL_VERSION "1.7.1") set(GNSSSDR_MATHJAX_EXTERNAL_VERSION "2.7.7") @@ -2341,6 +2344,7 @@ if(NOT MATIO_FOUND OR MATIO_VERSION_STRING VERSION_LESS ${GNSSSDR_MATIO_MIN_VERS PREFIX ${GNSSSDR_BINARY_DIR}/matio GIT_REPOSITORY https://github.com/tbeu/matio GIT_TAG v${GNSSSDR_MATIO_LOCAL_VERSION} + UPDATE_COMMAND "" SOURCE_DIR ${GNSSSDR_BINARY_DIR}/thirdparty/matio/matio-${GNSSSDR_MATIO_LOCAL_VERSION} BINARY_DIR ${GNSSSDR_BINARY_DIR}/matio CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} @@ -2588,136 +2592,177 @@ if((NOT Protobuf_FOUND) OR (NOT Protobuf_PROTOC_EXECUTABLE) OR (${Protobuf_VERSI set(PROTOBUF_PROTOC_EXECUTABLE "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/bin/protoc") endif() else() - if(${CMAKE_SYSTEM_NAME} MATCHES "Linux|kFreeBSD|GNU") - if(NOT EXISTS "/usr/bin/libtoolize") - message(" libtool has not been found.") - message(" You can try to install it by typing:") - if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") - message(" sudo yum groupinstall 'Development Tools'") - elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE") - message(" sudo zypper install libtoool") + if(CMAKE_VERSION VERSION_GREATER "3.13") + find_package(absl) + set_package_properties(absl PROPERTIES + URL "https://github.com/abseil/abseil-cpp" + PURPOSE "Abseil-cpp >= 20230117 required to be installed before building Protocol Buffers >22.x on the fly." + TYPE OPTIONAL + ) + if(absl_FOUND) + if(absl_VERSION) + if(${absl_VERSION} VERSION_LESS "20230117") + unset(absl_FOUND CACHE) + set(absl_FOUND OFF) + endif() else() - message(" sudo apt-get install libtool") + unset(absl_FOUND CACHE) + set(absl_FOUND OFF) endif() - message(FATAL_ERROR "libtool is required to build Protocol Buffers from source") endif() - if(EXISTS "/usr/bin/aclocal" OR - EXISTS "/usr/bin/aclocal-1.16" OR - EXISTS "/usr/bin/aclocal-1.15" OR - EXISTS "/usr/bin/aclocal-1.14" OR - EXISTS "/usr/bin/aclocal-1.13" OR - EXISTS "/usr/bin/aclocal-1.11" OR - EXISTS "/usr/bin/aclocal-1.10") - message(STATUS "Automake found.") + if(absl_FOUND) + set_package_properties(absl PROPERTIES + DESCRIPTION "An open-source collection of C++ code designed to augment the C++ standard library (found: v${absl_VERSION})" + ) else() - message(" aclocal has not been found.") - message(" You can try to install it by typing:") - if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") - message(" sudo yum groupinstall 'Development Tools'") - elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE") - message(" sudo zypper install automake") + if(absl_VERSION) + set_package_properties(absl PROPERTIES + DESCRIPTION "An open-source collection of C++ code designed to augment the C++ standard library (found: v${absl_VERSION})" + ) else() - message(" sudo apt-get install automake") + set_package_properties(absl PROPERTIES + DESCRIPTION "An open-source collection of C++ code designed to augment the C++ standard library" + ) endif() - message(FATAL_ERROR "aclocal is required to build Protocol Buffers from source") + message(STATUS "The Abseil library (https://github.com/abseil/abseil-cpp) >= v20230117 is required to be installed before building Protocol Buffers >22.x on the fly.") + message(STATUS " Instead, Protocol Buffers v21.12 will be built, which does not require Abseil.") + set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "21.12") endif() endif() - if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - if((NOT EXISTS /usr/local/bin/glibtoolize AND NOT EXISTS /opt/local/bin/glibtoolize) OR - (NOT EXISTS /usr/local/bin/aclocal AND NOT EXISTS /opt/local/bin/aclocal)) - message(" libtool/automake tools have not been found.") - message(" You can try to install them by typing:") - message(" 'sudo port install libtool automake', if you use Macports, or 'brew install libtool automake', if you use Homebrew") - message(FATAL_ERROR "libtool/automake tools are required to build Protocol Buffers from source") + if(CMAKE_VERSION VERSION_LESS "3.13" OR NOT absl_FOUND) + if(${CMAKE_SYSTEM_NAME} MATCHES "Linux|kFreeBSD|GNU") + if(NOT EXISTS "/usr/bin/libtoolize") + message(" libtool has not been found.") + message(" You can try to install it by typing:") + if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") + message(" sudo yum groupinstall 'Development Tools'") + elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE") + message(" sudo zypper install libtoool") + else() + message(" sudo apt-get install libtool") + endif() + message(FATAL_ERROR "libtool is required to build Protocol Buffers from source") + endif() + if(EXISTS "/usr/bin/aclocal" OR + EXISTS "/usr/bin/aclocal-1.16" OR + EXISTS "/usr/bin/aclocal-1.15" OR + EXISTS "/usr/bin/aclocal-1.14" OR + EXISTS "/usr/bin/aclocal-1.13" OR + EXISTS "/usr/bin/aclocal-1.11" OR + EXISTS "/usr/bin/aclocal-1.10") + message(STATUS "Automake found.") + else() + message(" aclocal has not been found.") + message(" You can try to install it by typing:") + if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") + message(" sudo yum groupinstall 'Development Tools'") + elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE") + message(" sudo zypper install automake") + else() + message(" sudo apt-get install automake") + endif() + message(FATAL_ERROR "aclocal is required to build Protocol Buffers from source") + endif() endif() - if(CMAKE_GENERATOR STREQUAL Xcode) - if(EXISTS /opt/local/bin/glibtoolize OR EXISTS /opt/local/bin/aclocal) - if(NOT EXISTS /usr/local/bin/glibtoolize OR NOT EXISTS /usr/local/bin/aclocal) - message(" WARNING: libtool/automake binaries cannot be found by Xcode. Please do:") - message("sudo ln -s /opt/local/bin/glibtoolize /usr/local/bin/") - message("sudo ln -s /opt/local/bin/aclocal /usr/local/bin/") - message("sudo ln -s /opt/local/bin/autom4te /usr/local/bin/") - message("sudo ln -s /opt/local/bin/automake /usr/local/bin/") - message("sudo ln -s /opt/local/bin/autoconf /usr/local/bin/") - message("sudo ln -s /opt/local/bin/autoreconf /usr/local/bin/") - message(FATAL_ERROR "libtool/automake tools cannot be found by Xcode") + if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + if((NOT EXISTS /usr/local/bin/glibtoolize AND NOT EXISTS /opt/local/bin/glibtoolize) OR + (NOT EXISTS /usr/local/bin/aclocal AND NOT EXISTS /opt/local/bin/aclocal)) + message(" libtool/automake tools have not been found.") + message(" You can try to install them by typing:") + message(" 'sudo port install libtool automake', if you use Macports, or 'brew install libtool automake', if you use Homebrew") + message(FATAL_ERROR "libtool/automake tools are required to build Protocol Buffers from source") + endif() + if(CMAKE_GENERATOR STREQUAL Xcode) + if(EXISTS /opt/local/bin/glibtoolize OR EXISTS /opt/local/bin/aclocal) + if(NOT EXISTS /usr/local/bin/glibtoolize OR NOT EXISTS /usr/local/bin/aclocal) + message(" WARNING: libtool/automake binaries cannot be found by Xcode. Please do:") + message("sudo ln -s /opt/local/bin/glibtoolize /usr/local/bin/") + message("sudo ln -s /opt/local/bin/aclocal /usr/local/bin/") + message("sudo ln -s /opt/local/bin/autom4te /usr/local/bin/") + message("sudo ln -s /opt/local/bin/automake /usr/local/bin/") + message("sudo ln -s /opt/local/bin/autoconf /usr/local/bin/") + message("sudo ln -s /opt/local/bin/autoreconf /usr/local/bin/") + message(FATAL_ERROR "libtool/automake tools cannot be found by Xcode") + endif() endif() endif() endif() - endif() - set(PROTOBUF_MAKE_PROGRAM ${CMAKE_MAKE_PROGRAM}) - if(PROTOBUF_MAKE_PROGRAM MATCHES "ninja" OR CMAKE_GENERATOR STREQUAL Xcode) - find_program(MAKE_EXECUTABLE make - PATHS - /usr/bin - /usr/local/bin - ) - if(NOT MAKE_EXECUTABLE) - message(FATAL_ERROR "make is required to build Protocol Buffers from source.") - endif() - set(PROTOBUF_MAKE_PROGRAM ${MAKE_EXECUTABLE}) - endif() - if(CMAKE_VERSION VERSION_LESS 3.2) - ExternalProject_Add(protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} - PREFIX ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} - GIT_REPOSITORY https://github.com/protocolbuffers/protobuf - GIT_TAG v${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} - SOURCE_DIR ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} - BINARY_DIR ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} - UPDATE_COMMAND ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/autogen.sh - CONFIGURE_COMMAND ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/configure --prefix=${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} - BUILD_COMMAND ${PROTOBUF_MAKE_PROGRAM} - INSTALL_COMMAND ${PROTOBUF_MAKE_PROGRAM} DESTDIR= install - ) - else() - if(CMAKE_MAKE_PROGRAM MATCHES "make") - include(ProcessorCount) - ProcessorCount(NUMBER_OF_PROCESSORS) - if(NUMBER_OF_PROCESSORS GREATER 1) - set(PROTOBUF_PARALLEL_BUILD "-j${NUMBER_OF_PROCESSORS}") + set(PROTOBUF_MAKE_PROGRAM ${CMAKE_MAKE_PROGRAM}) + if(PROTOBUF_MAKE_PROGRAM MATCHES "ninja" OR CMAKE_GENERATOR STREQUAL Xcode) + find_program(MAKE_EXECUTABLE make + PATHS + /usr/bin + /usr/local/bin + ) + if(NOT MAKE_EXECUTABLE) + message(FATAL_ERROR "make is required to build Protocol Buffers from source.") endif() + set(PROTOBUF_MAKE_PROGRAM ${MAKE_EXECUTABLE}) + endif() + if(CMAKE_VERSION VERSION_LESS 3.2) + ExternalProject_Add(protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} + PREFIX ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} + GIT_REPOSITORY https://github.com/protocolbuffers/protobuf + GIT_TAG v${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} + SOURCE_DIR ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} + BINARY_DIR ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} + UPDATE_COMMAND ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/autogen.sh + CONFIGURE_COMMAND ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/configure --prefix=${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} + BUILD_COMMAND ${PROTOBUF_MAKE_PROGRAM} + INSTALL_COMMAND ${PROTOBUF_MAKE_PROGRAM} DESTDIR= install + ) + else() + if(CMAKE_MAKE_PROGRAM MATCHES "make") + include(ProcessorCount) + ProcessorCount(NUMBER_OF_PROCESSORS) + if(NUMBER_OF_PROCESSORS GREATER 1) + set(PROTOBUF_PARALLEL_BUILD "-j${NUMBER_OF_PROCESSORS}") + endif() + endif() + ExternalProject_Add(protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} + PREFIX ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} + GIT_REPOSITORY https://github.com/protocolbuffers/protobuf + GIT_TAG v${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} + SOURCE_DIR ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} + BINARY_DIR ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} + UPDATE_COMMAND ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/autogen.sh + CONFIGURE_COMMAND ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/configure --prefix=${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} + BUILD_COMMAND ${PROTOBUF_MAKE_PROGRAM} ${PROTOBUF_PARALLEL_BUILD} + INSTALL_COMMAND ${PROTOBUF_MAKE_PROGRAM} DESTDIR= install + BUILD_BYPRODUCTS ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}protobuf${CMAKE_STATIC_LIBRARY_SUFFIX} + ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/bin/protoc + ) endif() - ExternalProject_Add(protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} - PREFIX ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} - GIT_REPOSITORY https://github.com/protocolbuffers/protobuf - GIT_TAG v${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} - SOURCE_DIR ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} - BINARY_DIR ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} - UPDATE_COMMAND ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/autogen.sh - CONFIGURE_COMMAND ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/configure --prefix=${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} - BUILD_COMMAND ${PROTOBUF_MAKE_PROGRAM} ${PROTOBUF_PARALLEL_BUILD} - INSTALL_COMMAND ${PROTOBUF_MAKE_PROGRAM} DESTDIR= install - BUILD_BYPRODUCTS ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}protobuf${CMAKE_STATIC_LIBRARY_SUFFIX} - ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/bin/protoc - ) - endif() - if(NOT TARGET protobuf::protoc) - add_executable(protobuf::protoc IMPORTED) - add_dependencies(protobuf::protoc protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}) + if(NOT TARGET protobuf::protoc) + add_executable(protobuf::protoc IMPORTED) + add_dependencies(protobuf::protoc protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}) + endif() + unset(Protobuf_PROTOC_EXECUTABLE) + set(PROTOBUF_PROTOC_EXECUTABLE "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/bin/protoc") + set_target_properties(protobuf::protoc PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/bin/protoc" + INTERFACE_LINK_LIBRARIES "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}protoc${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) + file(MAKE_DIRECTORY ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/include) + if(NOT TARGET protobuf::libprotobuf) + add_library(protobuf::libprotobuf STATIC IMPORTED) + add_dependencies(protobuf::libprotobuf protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}) + endif() + set_target_properties(protobuf::libprotobuf PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}protobuf${CMAKE_STATIC_LIBRARY_SUFFIX}" + INTERFACE_INCLUDE_DIRECTORIES "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/include" + INTERFACE_LINK_LIBRARIES "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}protobuf${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) + if(CMAKE_VERSION VERSION_LESS "3.10") + set(Protobuf_PROTOC_EXECUTABLE ${PROTOBUF_PROTOC_EXECUTABLE}) + endif() + else() # CMake >= 3.13 and Abseil found + include(BuildProtobuf) endif() - unset(Protobuf_PROTOC_EXECUTABLE) - set(PROTOBUF_PROTOC_EXECUTABLE "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/bin/protoc") - set_target_properties(protobuf::protoc PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" - IMPORTED_LOCATION "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/bin/protoc" - INTERFACE_LINK_LIBRARIES "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}protoc${CMAKE_STATIC_LIBRARY_SUFFIX}" - ) - endif() - file(MAKE_DIRECTORY ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/include) - if(NOT TARGET protobuf::libprotobuf) - add_library(protobuf::libprotobuf STATIC IMPORTED) - add_dependencies(protobuf::libprotobuf protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}) - endif() - set_target_properties(protobuf::libprotobuf PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" - IMPORTED_LOCATION "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}protobuf${CMAKE_STATIC_LIBRARY_SUFFIX}" - INTERFACE_INCLUDE_DIRECTORIES "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/include" - INTERFACE_LINK_LIBRARIES "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}protobuf${CMAKE_STATIC_LIBRARY_SUFFIX}" - ) - if(CMAKE_VERSION VERSION_LESS 3.10) - set(Protobuf_PROTOC_EXECUTABLE ${PROTOBUF_PROTOC_EXECUTABLE}) endif() if(${Protobuf_VERSION} VERSION_LESS ${GNSSSDR_PROTOBUF_MIN_VERSION}) if(NOT (${Protobuf_VERSION} EQUAL "0.0.0")) diff --git a/README.md b/README.md index d3461edfb..19961ccab 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ This section describes how to set up the compilation environment in GNU/Linux or ## GNU/Linux -- Tested distributions: Ubuntu 14.04 LTS and above; Debian 8.0 "jessie" and +- Tested distributions: Ubuntu 14.04 LTS and above; Debian 9.0 "stretch" and above; Arch Linux; CentOS 7; Fedora 26 and above; OpenSUSE 42.3 and above. - Supported microprocessor architectures: - i386: Intel x86 instruction set (32-bit microprocessors). @@ -160,7 +160,7 @@ packages. #### Debian / Ubuntu -If you are using Debian 8, Ubuntu 14.10 or above, this can be done by copying +If you are using Debian 9, Ubuntu 14.10 or above, this can be done by copying and pasting the following line in a terminal: ``` @@ -172,10 +172,9 @@ $ sudo apt-get install build-essential cmake git pkg-config libboost-dev libboos libprotobuf-dev protobuf-compiler python3-mako ``` -Please note that the required files from `libgtest-dev` were moved to -`googletest` in Debian 9 "stretch" and Ubuntu 18.04 "bionic", and moved back -again to `libgtest-dev` in Debian 10 "buster" and Ubuntu 18.10 "cosmic" (and -above). +Please note that the required files from `libgtest-dev` were named `googletest` +in Debian 9 "stretch" and Ubuntu 18.04 "bionic", and renamed to `libgtest-dev` +in Debian 10 "buster" and above. Since Ubuntu 21.04 Hirsute / Debian 11, the package `libcpu-features-dev` is also required. @@ -195,10 +194,6 @@ In distributions older than Ubuntu 16.04 or Debian 9, `python3-mako` must be replaced by `python-mako`. For Ubuntu 14.04, you will need to add the package `python-six` to the list of dependencies. -**Note for Debian 8 "jessie" users:** please see the note about `libmatio-dev` -above. Install `libtool`, `automake` and `libhdf5-dev` instead. You will also -need `python-six`. - Once you have installed these packages, you can jump directly to [download the source code and build GNSS-SDR](#clone-gnss-sdrs-git-repository). @@ -477,24 +472,14 @@ $ sudo ldconfig #### Install [Protocol Buffers](https://developers.google.com/protocol-buffers/ "Protocol Buffers' Homepage"), a portable mechanism for serialization of structured data GNSS-SDR requires Protocol Buffers v3.0.0 or later. If the packages that come -with your distribution are older than that (_e.g._, Ubuntu 16.04 Xenial and -Debian 8 Jessie came with older versions), then you will need to install it -manually. First, install the dependencies: +with your distribution are older than that (_e.g._, Ubuntu 16.04 Xenial came +with an older versions), then you will need to install it manually: ``` -$ sudo apt-get install autoconf automake libtool curl make g++ unzip -``` - -and then: - -``` -$ git clone https://github.com/protocolbuffers/protobuf.git +$ git clone --recursive https://github.com/protocolbuffers/protobuf.git $ cd protobuf -$ git submodule update --init --recursive -$ ./autogen.sh -$ /configure -$ make -j$(nproc) -$ sudo make install +$ cmake -DABSL_PROPAGATE_CXX_STD=ON -Dprotobuf_BUILD_TESTS=OFF . +$ cmake --build --config Release --target install . $ sudo ldconfig ``` diff --git a/cmake/Modules/BuildProtobuf.cmake b/cmake/Modules/BuildProtobuf.cmake new file mode 100644 index 000000000..1009e419c --- /dev/null +++ b/cmake/Modules/BuildProtobuf.cmake @@ -0,0 +1,172 @@ +# GNSS-SDR is a Global Navigation Satellite System software-defined receiver. +# This file is part of GNSS-SDR. +# +# SPDX-FileCopyrightText: 2023 C. Fernandez-Prades cfernandez(at)cttc.es +# SPDX-License-Identifier: BSD-3-Clause + +if(NOT GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION) + set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "22.2") +endif() + +if(NOT ZLIB_FOUND) + find_package(ZLIB) + set_package_properties(ZLIB PROPERTIES + URL "https://www.zlib.net/" + PURPOSE "Required to build Protocol Buffers." + TYPE REQUIRED + ) + if(ZLIB_FOUND AND ZLIB_VERSION_STRING) + set_package_properties(ZLIB PROPERTIES + DESCRIPTION "A Massively Spiffy Yet Delicately Unobtrusive Compression Library (found: v${ZLIB_VERSION_STRING})" + ) + else() + set_package_properties(ZLIB PROPERTIES + DESCRIPTION "A Massively Spiffy Yet Delicately Unobtrusive Compression Library" + ) + endif() + if(ZLIB_FOUND) + set(ZLIB_LIBRARIES_ ${ZLIB_LIBRARIES}) + set(USE_ZLIB -Dprotobuf_WITH_ZLIB=ON) + else() + set(ZLIB_LIBRARIES_ "") + set(USE_ZLIB -Dprotobuf_WITH_ZLIB=OFF) + endif() +else() + set(ZLIB_LIBRARIES_ ${ZLIB_LIBRARIES}) + set(USE_ZLIB -Dprotobuf_WITH_ZLIB=ON) +endif() + +include(GNUInstallDirs) + +list(APPEND UTF8_LIBRARIES + ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}utf8_validity${CMAKE_STATIC_LIBRARY_SUFFIX} + ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}utf8_range${CMAKE_STATIC_LIBRARY_SUFFIX} +) + +# Fix for GCC 13 +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "12.99") + find_program(Patch_EXECUTABLE NAME patch PATHS ENV PATH) + if(NOT Patch_EXECUTABLE) + message(FATAL_ERROR "The patch command is not found. It is required to build Protocol Buffers. Please check your OS documentation and install the patch command.") + endif() + set(PROTOBUF_PATCH_COMMAND + cd ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/src/google/protobuf/ && + ${Patch_EXECUTABLE} ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/src/google/protobuf/port.h < ${GNSSSDR_SOURCE_DIR}/src/tests/data/protobuf22.patch + ) + # Patch only once + if(EXISTS ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/src/google/protobuf/port.h) + set(PROTOBUF_PATCH_COMMAND "") + endif() + else() + set(PROTOBUF_PATCH_COMMAND "") + endif() +else() + set(PROTOBUF_PATCH_COMMAND "") +endif() + +ExternalProject_Add(protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} + PREFIX ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} + GIT_REPOSITORY https://github.com/protocolbuffers/protobuf + GIT_TAG v${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} + GIT_PROGRESS ON + UPDATE_COMMAND "" + PATCH_COMMAND ${PROTOBUF_PATCH_COMMAND} + SOURCE_DIR ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} + BINARY_DIR ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} + CMAKE_ARGS + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DBUILD_SHARED_LIBS=OFF + -DCMAKE_BUILD_TYPE=$<$:Debug>$<$:Release>$<$:RelWithDebInfo>$<$:MinSizeRel>$<$:Debug>$<$:Debug>$<$:RelWithDebInfo>$<$:RelWithDebInfo>$<$:Debug> + -DCMAKE_CXX_VISIBILITY_PRESET=hidden + -DCMAKE_VISIBILITY_INLINES_HIDDEN=1 + -DCMAKE_INSTALL_PREFIX=${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} + -Dprotobuf_BUILD_TESTS=OFF + -Dprotobuf_ABSL_PROVIDER=package + ${USE_ZLIB} + BUILD_COMMAND ${CMAKE_COMMAND} + "--build" "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}" + "--config" $<$:Debug>$<$:Release>$<$:RelWithDebInfo>$<$:MinSizeRel>$<$:Debug>$<$:Debug>$<$:RelWithDebInfo>$<$:RelWithDebInfo>$<$:Debug> + "--target" install + BUILD_BYPRODUCTS ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}protobuf${CMAKE_STATIC_LIBRARY_SUFFIX} + ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/bin/protoc + ${ABSL_LIBRARIES} + ${UTF8_LIBRARIES} + INSTALL_COMMAND "" +) + +file(MAKE_DIRECTORY ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/include) +file(MAKE_DIRECTORY ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/${CMAKE_INSTALL_LIBDIR}) + +if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + find_library(CoreFoundation CoreFoundation) +else() + set(CoreFoundation "") +endif() + +if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "ASAN") + set(DEBUG_POSTFIX d) +else() + set(DEBUG_POSTFIX "") +endif() + +set(PROTOBUF_ABSL_USED_TARGETS + absl::absl_check + absl::absl_log + absl::algorithm + absl::base + absl::bind_front + absl::bits + absl::btree + absl::cleanup + absl::cord + absl::core_headers + absl::debugging + absl::die_if_null + absl::dynamic_annotations + absl::flags + absl::flat_hash_map + absl::flat_hash_set + absl::function_ref + absl::hash + absl::layout + absl::log_initialize + absl::log_severity + absl::memory + absl::node_hash_map + absl::node_hash_set + absl::optional + absl::span + absl::status + absl::statusor + absl::strings + absl::synchronization + absl::time + absl::type_traits + absl::utility + absl::variant +) + +if(NOT TARGET protobuf::libprotobuf) + add_library(protobuf::libprotobuf STATIC IMPORTED) + add_dependencies(protobuf::libprotobuf protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}) + set_target_properties(protobuf::libprotobuf PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}protobuf${DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}" + INTERFACE_INCLUDE_DIRECTORIES "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/include" + INTERFACE_LINK_LIBRARIES "${ZLIB_LIBRARIES_};${CoreFoundation};${UTF8_LIBRARIES};${PROTOBUF_ABSL_USED_TARGETS};${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}protobuf${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) +endif() + +if(NOT TARGET protobuf::protoc) + add_executable(protobuf::protoc IMPORTED) + add_dependencies(protobuf::protoc protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}) + unset(Protobuf_PROTOC_EXECUTABLE) + set(PROTOBUF_PROTOC_EXECUTABLE "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/bin/protoc") + set_target_properties(protobuf::protoc PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/bin/protoc" + INTERFACE_LINK_LIBRARIES "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}protoc${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) +endif() diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index aff709642..6f6430b13 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -87,6 +87,14 @@ All notable changes to GNSS-SDR will be documented in this file. to CMake deactivates file downloading. - The `ENABLE_GENERIC_ARCH` building option was removed, simplifying the process of buiding the software in non-x86 processor architectures. +- If the Protocol Buffers dependency is not found, it is downloaded, built and + statically linked at buiding time. If CMake >= 3.13 and the + [Abseil C++ libraries](https://github.com/abseil/abseil-cpp) >= 20230117 are + installed on your system, Protocol Buffers v22.2 will be used. If those + requirements are not met, Protocol Buffers v21.4 will be used instead + (requires autotools). +- Since Debian 8 "Jessie", which enjoyed Long Term Support until the end of June + 2020, is not anymore in the Debian official repositories, we drop its support. ### Improvements in Usability: diff --git a/src/tests/data/protobuf22.patch b/src/tests/data/protobuf22.patch new file mode 100644 index 000000000..ac7dd27df --- /dev/null +++ b/src/tests/data/protobuf22.patch @@ -0,0 +1,12 @@ +SPDX-License-Identifier: GPL-3.0-or-later +SPDX-FileCopyrightText: 2023 Carles Fernandez-Prades +--- port.h 2023-03-31 11:40:38.000000000 +0100 ++++ port.h 2023-03-31 11:56:49.000000000 +0100 +@@ -38,6 +38,7 @@ + + #include + #include ++#include + #include + #include + #include \ No newline at end of file From 16ae6837174fa47dbbe8ae6cc4e411085ae6a2ca Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 1 Apr 2023 13:12:42 +0200 Subject: [PATCH 20/38] Fix positioning with LEO-based constellations --- src/algorithms/libs/rtklib/CMakeLists.txt | 1 + src/algorithms/libs/rtklib/rtklib_pntpos.cc | 112 ++++++++++++++++++++ 2 files changed, 113 insertions(+) diff --git a/src/algorithms/libs/rtklib/CMakeLists.txt b/src/algorithms/libs/rtklib/CMakeLists.txt index fae644536..faabc78b0 100644 --- a/src/algorithms/libs/rtklib/CMakeLists.txt +++ b/src/algorithms/libs/rtklib/CMakeLists.txt @@ -69,6 +69,7 @@ target_link_libraries(algorithms_libs_rtklib PRIVATE core_system_parameters algorithms_libs + Armadillo::armadillo Gflags::gflags Glog::glog LAPACK::LAPACK diff --git a/src/algorithms/libs/rtklib/rtklib_pntpos.cc b/src/algorithms/libs/rtklib/rtklib_pntpos.cc index 594815996..35f8d4402 100644 --- a/src/algorithms/libs/rtklib/rtklib_pntpos.cc +++ b/src/algorithms/libs/rtklib/rtklib_pntpos.cc @@ -33,6 +33,8 @@ #include "rtklib_ephemeris.h" #include "rtklib_ionex.h" #include "rtklib_sbas.h" +#include +#include #include #include @@ -599,6 +601,99 @@ int valsol(const double *azel, const int *vsat, int n, } +// Lorentz inner product +double lorentz(const arma::vec &x, const arma::vec &y) +{ + double p = x(0) * y(0) + x(1) * y(1) + x(2) * y(2) - x(3) * y(3); + return p; +} + + +// Bancroft method (see https://gssc.esa.int/navipedia/index.php/Bancroft_Method) +arma::vec bancroft(arma::mat B_pass) +{ + arma::vec pos = arma::zeros(4); + for (int iter = 1; iter <= 2; iter++) + { + arma::mat B = B_pass; + const int m = B.n_rows; + + for (int i = 0; i < m; i++) + { + double x = B(i, 0); + double y = B(i, 1); + double z = 0; + double traveltime = 0.072; + if (iter == 2) + { + z = B(i, 2); + double rho = std::pow(x - pos(0), 2) + std::pow(y - pos(1), 2) + std::pow(z - pos(2), 2); + traveltime = std::sqrt(rho) / SPEED_OF_LIGHT_M_S; + } + double angle = traveltime * GNSS_OMEGA_EARTH_DOT; + double cosa = std::cos(angle); + double sina = std::sin(angle); + B(i, 0) = cosa * x + sina * y; + B(i, 1) = -sina * x + cosa * y; + } + + arma::mat BBB; + if (m > 4) + { + BBB = arma::inv(B.t() * B) * B.t(); + } + else + { + BBB = arma::inv(B); + } + arma::vec e = arma::ones(m); + arma::vec alpha = arma::zeros(m); + for (int i = 0; i < m; i++) + { + arma::vec Bi = B.row(i).t(); + alpha(i) = lorentz(Bi, Bi) / 2; + } + arma::vec BBBe = BBB * e; + arma::vec BBBalpha = BBB * alpha; + double a = lorentz(BBBe, BBBe); + double b = lorentz(BBBe, BBBalpha) - 1; + double c = lorentz(BBBalpha, BBBalpha); + double root = sqrt(b * b - a * c); + arma::vec r(2); + r(0) = (-b - root) / a; + r(1) = (-b + root) / a; + arma::mat possible_pos = arma::zeros(4, 2); + for (int i = 0; i < 2; i++) + { + possible_pos.col(i) = r(i) * BBBe + BBBalpha; + possible_pos(3, i) = -possible_pos(3, i); + } + arma::vec abs_omc(2); + for (int j = 0; j < m; j++) + { + for (int i = 0; i < 2; i++) + { + double c_dt = possible_pos(3, i); + double calc = arma::norm(B.row(j).head(3).t() - possible_pos.head_rows(3).col(i)) + c_dt; + double omc = B(j, 3) - calc; + abs_omc(i) = std::abs(omc); + } + } + + if (abs_omc(0) > abs_omc(1)) + { + pos = possible_pos.col(1); + } + else + { + pos = possible_pos.col(0); + } + } + + return pos; +} + + /* estimate receiver position ------------------------------------------------*/ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts, const double *vare, const int *svh, const nav_t *nav, @@ -632,6 +727,23 @@ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts, x[i] = sol->rr[i]; } + // Rough first estimation to initialize the algorithm + if (std::sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]) < 0.1) + { + arma::mat B = arma::mat(n, 4, arma::fill::zeros); + for (i = 0; i < n; i++) + { + B(i, 0) = rs[0 + i * 6]; + B(i, 1) = rs[1 + i * 6]; + B(i, 2) = rs[2 + i * 6]; + B(i, 3) = obs[i].P[0]; + } + arma::vec pos = bancroft(B); + x[0] = pos(0); + x[1] = pos(1); + x[2] = pos(2); + } + for (i = 0; i < MAXITR; i++) { /* pseudorange residuals */ From 67c6dbcfda9781e28703cd2fbb4a0610900ad9ae Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 1 Apr 2023 18:09:35 +0200 Subject: [PATCH 21/38] Skip rotation in Bancroft method --- src/algorithms/libs/rtklib/rtklib_pntpos.cc | 42 ++++++--------------- 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/src/algorithms/libs/rtklib/rtklib_pntpos.cc b/src/algorithms/libs/rtklib/rtklib_pntpos.cc index 35f8d4402..f88cac58e 100644 --- a/src/algorithms/libs/rtklib/rtklib_pntpos.cc +++ b/src/algorithms/libs/rtklib/rtklib_pntpos.cc @@ -610,47 +610,29 @@ double lorentz(const arma::vec &x, const arma::vec &y) // Bancroft method (see https://gssc.esa.int/navipedia/index.php/Bancroft_Method) -arma::vec bancroft(arma::mat B_pass) +// without travel time rotation +arma::vec rough_bancroft(const arma::mat &B_pass) { + const int m = B_pass.n_rows; arma::vec pos = arma::zeros(4); for (int iter = 1; iter <= 2; iter++) { - arma::mat B = B_pass; - const int m = B.n_rows; - - for (int i = 0; i < m; i++) - { - double x = B(i, 0); - double y = B(i, 1); - double z = 0; - double traveltime = 0.072; - if (iter == 2) - { - z = B(i, 2); - double rho = std::pow(x - pos(0), 2) + std::pow(y - pos(1), 2) + std::pow(z - pos(2), 2); - traveltime = std::sqrt(rho) / SPEED_OF_LIGHT_M_S; - } - double angle = traveltime * GNSS_OMEGA_EARTH_DOT; - double cosa = std::cos(angle); - double sina = std::sin(angle); - B(i, 0) = cosa * x + sina * y; - B(i, 1) = -sina * x + cosa * y; - } - + // We should rotate the matrix accounting for the travel time here, + // but for a rough first estimation we can skip it arma::mat BBB; if (m > 4) { - BBB = arma::inv(B.t() * B) * B.t(); + BBB = arma::inv(B_pass.t() * B_pass) * B_pass.t(); } else { - BBB = arma::inv(B); + BBB = arma::inv(B_pass); } arma::vec e = arma::ones(m); arma::vec alpha = arma::zeros(m); for (int i = 0; i < m; i++) { - arma::vec Bi = B.row(i).t(); + arma::vec Bi = B_pass.row(i).t(); alpha(i) = lorentz(Bi, Bi) / 2; } arma::vec BBBe = BBB * e; @@ -658,7 +640,7 @@ arma::vec bancroft(arma::mat B_pass) double a = lorentz(BBBe, BBBe); double b = lorentz(BBBe, BBBalpha) - 1; double c = lorentz(BBBalpha, BBBalpha); - double root = sqrt(b * b - a * c); + double root = std::sqrt(b * b - a * c); arma::vec r(2); r(0) = (-b - root) / a; r(1) = (-b + root) / a; @@ -674,8 +656,8 @@ arma::vec bancroft(arma::mat B_pass) for (int i = 0; i < 2; i++) { double c_dt = possible_pos(3, i); - double calc = arma::norm(B.row(j).head(3).t() - possible_pos.head_rows(3).col(i)) + c_dt; - double omc = B(j, 3) - calc; + double calc = arma::norm(B_pass.row(j).head(3).t() - possible_pos.head_rows(3).col(i)) + c_dt; + double omc = B_pass(j, 3) - calc; abs_omc(i) = std::abs(omc); } } @@ -738,7 +720,7 @@ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts, B(i, 2) = rs[2 + i * 6]; B(i, 3) = obs[i].P[0]; } - arma::vec pos = bancroft(B); + arma::vec pos = rough_bancroft(B); x[0] = pos(0); x[1] = pos(1); x[2] = pos(2); From 318a39bd79cf94dae4cc9e5abfb63475e6181b30 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 1 Apr 2023 21:43:32 +0200 Subject: [PATCH 22/38] Make Bancroft work in other bands than L1, make the algorithm more stable in case of a singular matrix --- src/algorithms/libs/rtklib/rtklib_pntpos.cc | 38 ++++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/src/algorithms/libs/rtklib/rtklib_pntpos.cc b/src/algorithms/libs/rtklib/rtklib_pntpos.cc index f88cac58e..efe03d927 100644 --- a/src/algorithms/libs/rtklib/rtklib_pntpos.cc +++ b/src/algorithms/libs/rtklib/rtklib_pntpos.cc @@ -22,7 +22,7 @@ * ----------------------------------------------------------------------------- * Copyright (C) 2007-2013, T. Takasu * Copyright (C) 2017, Javier Arribas - * Copyright (C) 2017, Carles Fernandez + * Copyright (C) 2017-2023, Carles Fernandez * All rights reserved. * * SPDX-License-Identifier: BSD-2-Clause @@ -620,25 +620,34 @@ arma::vec rough_bancroft(const arma::mat &B_pass) // We should rotate the matrix accounting for the travel time here, // but for a rough first estimation we can skip it arma::mat BBB; + bool success; if (m > 4) { - BBB = arma::inv(B_pass.t() * B_pass) * B_pass.t(); + success = arma::inv(BBB, B_pass.t() * B_pass); + if (success) + { + BBB *= B_pass.t(); + } } else { - BBB = arma::inv(B_pass); + success = arma::inv(BBB, B_pass); } - arma::vec e = arma::ones(m); + if (!success) + { + return pos; + } + const arma::vec e = arma::ones(m); arma::vec alpha = arma::zeros(m); for (int i = 0; i < m; i++) { arma::vec Bi = B_pass.row(i).t(); - alpha(i) = lorentz(Bi, Bi) / 2; + alpha(i) = lorentz(Bi, Bi) / 2.0; } - arma::vec BBBe = BBB * e; - arma::vec BBBalpha = BBB * alpha; + const arma::vec BBBe = BBB * e; + const arma::vec BBBalpha = BBB * alpha; double a = lorentz(BBBe, BBBe); - double b = lorentz(BBBe, BBBalpha) - 1; + double b = lorentz(BBBe, BBBalpha) - 1.0; double c = lorentz(BBBalpha, BBBalpha); double root = std::sqrt(b * b - a * c); arma::vec r(2); @@ -718,7 +727,18 @@ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts, B(i, 0) = rs[0 + i * 6]; B(i, 1) = rs[1 + i * 6]; B(i, 2) = rs[2 + i * 6]; - B(i, 3) = obs[i].P[0]; + if (obs[i].code[0] != CODE_NONE) + { + B(i, 3) = obs[i].P[0]; + } + else if (obs[i].code[1] != CODE_NONE) + { + B(i, 3) = obs[i].P[1]; + } + else + { + B(i, 3) = obs[i].P[2]; + } } arma::vec pos = rough_bancroft(B); x[0] = pos(0); From 81eb2a07c31b2c6d9a53fce1cf4d7b631470e672 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 1 Apr 2023 21:54:03 +0200 Subject: [PATCH 23/38] Add const --- src/algorithms/libs/rtklib/rtklib_pntpos.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/algorithms/libs/rtklib/rtklib_pntpos.cc b/src/algorithms/libs/rtklib/rtklib_pntpos.cc index efe03d927..baf9f1eba 100644 --- a/src/algorithms/libs/rtklib/rtklib_pntpos.cc +++ b/src/algorithms/libs/rtklib/rtklib_pntpos.cc @@ -646,10 +646,10 @@ arma::vec rough_bancroft(const arma::mat &B_pass) } const arma::vec BBBe = BBB * e; const arma::vec BBBalpha = BBB * alpha; - double a = lorentz(BBBe, BBBe); - double b = lorentz(BBBe, BBBalpha) - 1.0; - double c = lorentz(BBBalpha, BBBalpha); - double root = std::sqrt(b * b - a * c); + const double a = lorentz(BBBe, BBBe); + const double b = lorentz(BBBe, BBBalpha) - 1.0; + const double c = lorentz(BBBalpha, BBBalpha); + const double root = std::sqrt(b * b - a * c); arma::vec r(2); r(0) = (-b - root) / a; r(1) = (-b + root) / a; @@ -664,9 +664,9 @@ arma::vec rough_bancroft(const arma::mat &B_pass) { for (int i = 0; i < 2; i++) { - double c_dt = possible_pos(3, i); - double calc = arma::norm(B_pass.row(j).head(3).t() - possible_pos.head_rows(3).col(i)) + c_dt; - double omc = B_pass(j, 3) - calc; + const double c_dt = possible_pos(3, i); + const double calc = arma::norm(B_pass.row(j).head(3).t() - possible_pos.head_rows(3).col(i)) + c_dt; + const double omc = B_pass(j, 3) - calc; abs_omc(i) = std::abs(omc); } } From 3def3c36cdde523470a00dbf33f87b14242c3431 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 2 Apr 2023 10:31:17 +0200 Subject: [PATCH 24/38] Save one iteration in the Bancroft algorithm --- src/algorithms/libs/rtklib/CMakeLists.txt | 6 ++ src/algorithms/libs/rtklib/rtklib_pntpos.cc | 113 ++++++++++---------- 2 files changed, 60 insertions(+), 59 deletions(-) diff --git a/src/algorithms/libs/rtklib/CMakeLists.txt b/src/algorithms/libs/rtklib/CMakeLists.txt index faabc78b0..c23d55119 100644 --- a/src/algorithms/libs/rtklib/CMakeLists.txt +++ b/src/algorithms/libs/rtklib/CMakeLists.txt @@ -76,6 +76,12 @@ target_link_libraries(algorithms_libs_rtklib BLAS::BLAS ) +if(ENABLE_ARMA_NO_DEBUG) + target_compile_definitions(algorithms_libs_rtklib + PRIVATE -DARMA_NO_BOUND_CHECKING=1 + ) +endif() + if(FILESYSTEM_FOUND) target_compile_definitions(algorithms_libs_rtklib PUBLIC -DHAS_STD_FILESYSTEM=1) if(find_experimental) diff --git a/src/algorithms/libs/rtklib/rtklib_pntpos.cc b/src/algorithms/libs/rtklib/rtklib_pntpos.cc index baf9f1eba..b9e74dfcb 100644 --- a/src/algorithms/libs/rtklib/rtklib_pntpos.cc +++ b/src/algorithms/libs/rtklib/rtklib_pntpos.cc @@ -29,6 +29,10 @@ * ----------------------------------------------------------------------------- */ +#if ARMA_NO_BOUND_CHECKING +#define ARMA_NO_DEBUG 1 +#endif + #include "rtklib_pntpos.h" #include "rtklib_ephemeris.h" #include "rtklib_ionex.h" @@ -615,70 +619,61 @@ arma::vec rough_bancroft(const arma::mat &B_pass) { const int m = B_pass.n_rows; arma::vec pos = arma::zeros(4); - for (int iter = 1; iter <= 2; iter++) + arma::mat BBB; + bool success; + if (m > 4) + { + success = arma::pinv(BBB, B_pass); + } + else + { + success = arma::inv(BBB, B_pass); + } + if (!success) + { + return pos; + } + const arma::vec e = arma::ones(m); + arma::vec alpha = arma::zeros(m); + for (int i = 0; i < m; i++) + { + arma::vec Bi = B_pass.row(i).t(); + alpha(i) = lorentz(Bi, Bi) / 2.0; + } + const arma::vec BBBe = BBB * e; + const arma::vec BBBalpha = BBB * alpha; + const double a = lorentz(BBBe, BBBe); + const double b = lorentz(BBBe, BBBalpha) - 1.0; + const double c = lorentz(BBBalpha, BBBalpha); + const double root = std::sqrt(b * b - a * c); + arma::vec r(2); + r(0) = (-b - root) / a; + r(1) = (-b + root) / a; + arma::mat possible_pos = arma::zeros(4, 2); + for (int i = 0; i < 2; i++) + { + possible_pos.col(i) = r(i) * BBBe + BBBalpha; + possible_pos(3, i) = -possible_pos(3, i); + } + arma::vec abs_omc(2); + for (int j = 0; j < m; j++) { - // We should rotate the matrix accounting for the travel time here, - // but for a rough first estimation we can skip it - arma::mat BBB; - bool success; - if (m > 4) - { - success = arma::inv(BBB, B_pass.t() * B_pass); - if (success) - { - BBB *= B_pass.t(); - } - } - else - { - success = arma::inv(BBB, B_pass); - } - if (!success) - { - return pos; - } - const arma::vec e = arma::ones(m); - arma::vec alpha = arma::zeros(m); - for (int i = 0; i < m; i++) - { - arma::vec Bi = B_pass.row(i).t(); - alpha(i) = lorentz(Bi, Bi) / 2.0; - } - const arma::vec BBBe = BBB * e; - const arma::vec BBBalpha = BBB * alpha; - const double a = lorentz(BBBe, BBBe); - const double b = lorentz(BBBe, BBBalpha) - 1.0; - const double c = lorentz(BBBalpha, BBBalpha); - const double root = std::sqrt(b * b - a * c); - arma::vec r(2); - r(0) = (-b - root) / a; - r(1) = (-b + root) / a; - arma::mat possible_pos = arma::zeros(4, 2); for (int i = 0; i < 2; i++) { - possible_pos.col(i) = r(i) * BBBe + BBBalpha; - possible_pos(3, i) = -possible_pos(3, i); - } - arma::vec abs_omc(2); - for (int j = 0; j < m; j++) - { - for (int i = 0; i < 2; i++) - { - const double c_dt = possible_pos(3, i); - const double calc = arma::norm(B_pass.row(j).head(3).t() - possible_pos.head_rows(3).col(i)) + c_dt; - const double omc = B_pass(j, 3) - calc; - abs_omc(i) = std::abs(omc); - } + const double c_dt = possible_pos(3, i); + const double calc = arma::norm(B_pass.row(j).head(3).t() - possible_pos.head_rows(3).col(i)) + c_dt; + const double omc = B_pass(j, 3) - calc; + abs_omc(i) = std::abs(omc); } + } - if (abs_omc(0) > abs_omc(1)) - { - pos = possible_pos.col(1); - } - else - { - pos = possible_pos.col(0); - } + if (abs_omc(0) > abs_omc(1)) + { + pos = possible_pos.col(1); + } + else + { + pos = possible_pos.col(0); } return pos; From 51418850bb9046f60614de66c6de304aac595106 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 3 Apr 2023 13:36:54 +0200 Subject: [PATCH 25/38] Add configuration parameter PVT.bancroft_init, by default to true, to opt-out for Bancroft initialization in the first iteration of PVT computation --- docs/CHANGELOG.md | 7 ++++++- src/algorithms/PVT/adapters/rtklib_pvt.cc | 5 ++++- src/algorithms/libs/rtklib/rtklib.h | 1 + src/algorithms/libs/rtklib/rtklib_pntpos.cc | 2 +- src/algorithms/libs/rtklib/rtklib_rtksvr.h | 2 +- .../signal-processing-blocks/pvt/nmea_printer_test.cc | 3 ++- .../signal-processing-blocks/pvt/rinex_printer_test.cc | 3 ++- .../signal-processing-blocks/pvt/rtklib_solver_test.cc | 3 ++- 8 files changed, 19 insertions(+), 7 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 6f6430b13..05d44735a 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -4,7 +4,7 @@ SPDX-License-Identifier: GPL-3.0-or-later ) [comment]: # ( -SPDX-FileCopyrightText: 2011-2022 Carles Fernandez-Prades +SPDX-FileCopyrightText: 2011-2023 Carles Fernandez-Prades ) @@ -30,6 +30,11 @@ All notable changes to GNSS-SDR will be documented in this file. - Improved non-coherent acquisition when `Acquisition_XX.blocking=false`. - Implemented processing of BeiDou PRN 34 up to PRN 63 signals. - Implemented Hamming code correction for Glonass navigation message. +- Now the first iteration of the PVT computation is initialized by the Bancroft + method. This allows to get PVT fixes in some unusual geometries (_e.g._, + GNSS-like signals transmitted by LEO satellites). This initialization is + performed by default. You can opt-out by setting `PVT.bancroft_init=false` in + your configuration file. ### Improvements in Interoperability: diff --git a/src/algorithms/PVT/adapters/rtklib_pvt.cc b/src/algorithms/PVT/adapters/rtklib_pvt.cc index a607d2655..9ce402bcc 100644 --- a/src/algorithms/PVT/adapters/rtklib_pvt.cc +++ b/src/algorithms/PVT/adapters/rtklib_pvt.cc @@ -764,6 +764,8 @@ Rtklib_Pvt::Rtklib_Pvt(const ConfigurationInterface* configuration, const double carrier_phase_error_factor_a = configuration->property(role + ".carrier_phase_error_factor_a", 0.003); const double carrier_phase_error_factor_b = configuration->property(role + ".carrier_phase_error_factor_b", 0.003); + const bool bancroft_init = configuration->property(role + ".bancroft_init", true); + snrmask_t snrmask = {{}, {{}, {}}}; prcopt_t rtklib_configuration_options = { @@ -822,7 +824,8 @@ Rtklib_Pvt::Rtklib_Pvt(const ConfigurationInterface* configuration, {{}, {}}, /* odisp[2][6*11] ocean tide loading parameters {rov,base} */ {{}, {{}, {}}, {{}, {}}, {}, {}}, /* exterr_t exterr extended receiver error model */ 0, /* disable L2-AR */ - {} /* char pppopt[256] ppp option "-GAP_RESION=" default gap to reset iono parameters (ep) */ + {}, /* char pppopt[256] ppp option "-GAP_RESION=" default gap to reset iono parameters (ep) */ + bancroft_init /* enable Bancroft initialization for the first iteration of the PVT computation, useful in some geometries */ }; rtkinit(&rtk, &rtklib_configuration_options); diff --git a/src/algorithms/libs/rtklib/rtklib.h b/src/algorithms/libs/rtklib/rtklib.h index b470dca83..b5658641e 100644 --- a/src/algorithms/libs/rtklib/rtklib.h +++ b/src/algorithms/libs/rtklib/rtklib.h @@ -1000,6 +1000,7 @@ typedef struct exterr_t exterr; /* extended receiver error model */ int freqopt; /* disable L2-AR */ char pppopt[256]; /* ppp option */ + bool bancroft_init; /* enable Bancroft initialization for the first iteration of the PVT computation */ } prcopt_t; diff --git a/src/algorithms/libs/rtklib/rtklib_pntpos.cc b/src/algorithms/libs/rtklib/rtklib_pntpos.cc index b9e74dfcb..8528d9f3d 100644 --- a/src/algorithms/libs/rtklib/rtklib_pntpos.cc +++ b/src/algorithms/libs/rtklib/rtklib_pntpos.cc @@ -714,7 +714,7 @@ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts, } // Rough first estimation to initialize the algorithm - if (std::sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]) < 0.1) + if (opt->bancroft_init && (std::sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]) < 0.1)) { arma::mat B = arma::mat(n, 4, arma::fill::zeros); for (i = 0; i < n; i++) diff --git a/src/algorithms/libs/rtklib/rtklib_rtksvr.h b/src/algorithms/libs/rtklib/rtklib_rtksvr.h index 5c2919e75..48854cd2c 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtksvr.h +++ b/src/algorithms/libs/rtklib/rtklib_rtksvr.h @@ -65,7 +65,7 @@ const prcopt_t PRCOPT_DEFAULT = { /* defaults processing options */ {}, {}, {}, /* baseline, ru, rb */ {"", ""}, /* anttype */ {}, {}, {}, /* antdel, pcv, exsats */ - 0, 0, 0, {"", ""}, {}, 0, {{}, {}}, {{}, {{}, {}}, {{}, {}}, {}, {}}, 0, {}}; + 0, 0, 0, {"", ""}, {}, 0, {{}, {}}, {{}, {{}, {}}, {{}, {}}, {}, {}}, 0, {}, true}; void writesolhead(stream_t *stream, const solopt_t *solopt); diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc index 99c2bc0a3..94c904f95 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc @@ -133,7 +133,8 @@ void NmeaPrinterTest::conf() {{}, {}}, /* odisp[2][6*11] ocean tide loading parameters {rov,base} */ {{}, {{}, {}}, {{}, {}}, {}, {}}, /* exterr_t exterr extended receiver error model */ 0, /* disable L2-AR */ - {} /* char pppopt[256] ppp option "-GAP_RESION=" default gap to reset iono parameters (ep) */ + {}, /* char pppopt[256] ppp option "-GAP_RESION=" default gap to reset iono parameters (ep) */ + true /* enable Bancroft initialization for the first iteration of the PVT computation, useful in some geometries */ }; rtkinit(&rtk, &rtklib_configuration_options); diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc index 2eb6e1987..05f7d115e 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc @@ -132,7 +132,8 @@ void RinexPrinterTest::conf() {{}, {}}, /* odisp[2][6*11] ocean tide loading parameters {rov,base} */ {{}, {{}, {}}, {{}, {}}, {}, {}}, /* exterr_t exterr extended receiver error model */ 0, /* disable L2-AR */ - {} /* char pppopt[256] ppp option "-GAP_RESION=" default gap to reset iono parameters (ep) */ + {}, /* char pppopt[256] ppp option "-GAP_RESION=" default gap to reset iono parameters (ep) */ + true /* enable Bancroft initialization for the first iteration of the PVT computation, useful in some geometries */ }; rtkinit(&rtk, &rtklib_configuration_options); diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/rtklib_solver_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/rtklib_solver_test.cc index 9804fbde1..4da572895 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/rtklib_solver_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/rtklib_solver_test.cc @@ -363,7 +363,8 @@ rtk_t configure_rtklib_options() {{}, {}}, /* odisp[2][6*11] ocean tide loading parameters {rov,base} */ {{}, {{}, {}}, {{}, {}}, {}, {}}, /* exterr_t exterr extended receiver error model */ 0, /* disable L2-AR */ - {} /* char pppopt[256] ppp option "-GAP_RESION=" default gap to reset iono parameters (ep) */ + {}, /* char pppopt[256] ppp option "-GAP_RESION=" default gap to reset iono parameters (ep) */ + true /* enable Bancroft initialization for the first iteration of the PVT computation, useful in some geometries */ }; rtk_t rtk; From 7209dc4e87c01c9084be72a08193b7ebdd605919 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 4 Apr 2023 08:39:35 +0200 Subject: [PATCH 26/38] Remove unnecessary temporary objects and destructors --- src/core/system_parameters/gnss_satellite.cc | 22 ++++++++++++------- .../gps_l1_ca_pcps_acquisition_test.cc | 6 ----- .../adapter/adapter_test.cc | 4 ---- .../filter/fir_filter_test.cc | 7 +++--- .../filter/notch_filter_lite_test.cc | 12 +++++----- .../filter/notch_filter_test.cc | 12 +++++----- .../filter/pulse_blanking_filter_test.cc | 14 +++++++----- .../cpu_multicorrelator_real_codes_test.cc | 8 +++---- .../tracking/cpu_multicorrelator_test.cc | 8 +++---- .../galileo_e1_dll_pll_veml_tracking_test.cc | 5 +---- 10 files changed, 47 insertions(+), 51 deletions(-) diff --git a/src/core/system_parameters/gnss_satellite.cc b/src/core/system_parameters/gnss_satellite.cc index 7f1b1030c..2a974cc0a 100644 --- a/src/core/system_parameters/gnss_satellite.cc +++ b/src/core/system_parameters/gnss_satellite.cc @@ -30,10 +30,10 @@ Gnss_Satellite::Gnss_Satellite(const std::string& system_, uint32_t PRN_) void Gnss_Satellite::reset() { - system = std::string(""); - block = std::string(""); - PRN = 0; - rf_link = 0; + this->system.clear(); + this->block.clear(); + this->PRN = 0; + this->rf_link = 0; } @@ -103,7 +103,10 @@ Gnss_Satellite::Gnss_Satellite(Gnss_Satellite&& other) noexcept PRN(other.PRN), rf_link(other.rf_link) { - other.reset(); + other.system.clear(); + other.block.clear(); + other.PRN = 0; + other.rf_link = 0; } @@ -116,7 +119,10 @@ Gnss_Satellite& Gnss_Satellite::operator=(Gnss_Satellite&& other) noexcept block = std::move(other.block); PRN = other.PRN; rf_link = other.rf_link; - other.reset(); + other.system.clear(); + other.block.clear(); + other.PRN = 0; + other.rf_link = 0; } return *this; } @@ -621,7 +627,7 @@ std::string Gnss_Satellite::what_block(const std::string& system_, uint32_t PRN_ block_ = std::string("FOC-FM19"); // Galileo Full Operational Capability (FOC) satellite FM19 / GSAT0219, launched on Jul. 25, 2018. UNDER COMMISSIONING. break; default: - block_ = std::string("Unknown(Simulated)"); + block_ = std::string("Unknown"); } } if (system_ == "Beidou") @@ -768,7 +774,7 @@ std::string Gnss_Satellite::what_block(const std::string& system_, uint32_t PRN_ block_ = std::string("BeiDou-3 GEOG3"); // launched 2020/06/2023 break; default: - block_ = std::string("Unknown(Simulated)"); + block_ = std::string("Unknown"); } } return block_; diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc index e9c5d9e45..76056cb3b 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc @@ -72,7 +72,6 @@ private: public: int rx_message{0}; - ~GpsL1CaPcpsAcquisitionTest_msg_rx() override; //!< Default destructor }; @@ -115,9 +114,6 @@ GpsL1CaPcpsAcquisitionTest_msg_rx::GpsL1CaPcpsAcquisitionTest_msg_rx() } -GpsL1CaPcpsAcquisitionTest_msg_rx::~GpsL1CaPcpsAcquisitionTest_msg_rx() = default; - - // ########################################################### class GpsL1CaPcpsAcquisitionTest : public ::testing::Test @@ -131,8 +127,6 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GpsL1CaPcpsAcquisitionTest() override = default; - void init(); void plot_grid() const; diff --git a/src/tests/unit-tests/signal-processing-blocks/adapter/adapter_test.cc b/src/tests/unit-tests/signal-processing-blocks/adapter/adapter_test.cc index d43d459d6..26ff99a38 100644 --- a/src/tests/unit-tests/signal-processing-blocks/adapter/adapter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/adapter/adapter_test.cc @@ -38,7 +38,6 @@ class DataTypeAdapter : public ::testing::Test { public: DataTypeAdapter(); - ~DataTypeAdapter() override; int run_byte_to_short_block() const; int run_ibyte_to_cbyte_block() const; int run_ibyte_to_complex_block() const; @@ -67,9 +66,6 @@ DataTypeAdapter::DataTypeAdapter() } -DataTypeAdapter::~DataTypeAdapter() = default; - - int DataTypeAdapter::run_ishort_to_cshort_block() const { std::shared_ptr config = std::make_shared(); 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 8bd2d98c4..a0d064dac 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 @@ -44,23 +44,24 @@ DEFINE_int32(filter_test_nsamples, 1000000, "Number of samples to filter in the class FirFilterTest : public ::testing::Test { protected: - FirFilterTest() : item_size(sizeof(gr_complex)) + FirFilterTest() : item_size(sizeof(gr_complex)), + nsamples(FLAGS_filter_test_nsamples) { queue = std::make_shared>(); config = std::make_shared(); } - ~FirFilterTest() override = default; void init(); void configure_cbyte_cbyte(); void configure_cbyte_gr_complex(); void configure_gr_complex_gr_complex(); void configure_cshort_cshort(); + std::shared_ptr> queue; gr::top_block_sptr top_block; std::shared_ptr config; size_t item_size; - int nsamples = FLAGS_filter_test_nsamples; + int nsamples; }; 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 12d6ddce4..db12b3bfc 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 @@ -43,28 +43,28 @@ DEFINE_int32(notch_filter_lite_test_nsamples, 1000000, "Number of samples to fil class NotchFilterLiteTest : public ::testing::Test { protected: - NotchFilterLiteTest() : item_size(sizeof(gr_complex)), nsamples(FLAGS_notch_filter_lite_test_nsamples) + NotchFilterLiteTest() : item_size(sizeof(gr_complex)), + nsamples(FLAGS_notch_filter_lite_test_nsamples) { queue = std::make_shared>(); config = std::make_shared(); } - ~NotchFilterLiteTest() override = default; - bool stop = false; - std::thread ch_thread; void start_queue(); void wait_message(); void process_message(); void stop_queue(); - pmt::pmt_t message; - void init(); void configure_gr_complex_gr_complex(); + std::shared_ptr> queue; gr::top_block_sptr top_block; std::shared_ptr config; + pmt::pmt_t message; + std::thread ch_thread; size_t item_size; int nsamples; + bool stop{false}; }; 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 4c2a3cb4a..36c7346a2 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 @@ -43,28 +43,28 @@ DEFINE_int32(notch_filter_test_nsamples, 1000000, "Number of samples to filter i class NotchFilterTest : public ::testing::Test { protected: - NotchFilterTest() : item_size(sizeof(gr_complex)), nsamples(FLAGS_notch_filter_test_nsamples) + NotchFilterTest() : item_size(sizeof(gr_complex)), + nsamples(FLAGS_notch_filter_test_nsamples) { queue = std::make_shared>(); config = std::make_shared(); } - ~NotchFilterTest() override = default; - bool stop = false; - std::thread ch_thread; void start_queue(); void wait_message(); void process_message(); void stop_queue(); - pmt::pmt_t message; - void init(); void configure_gr_complex_gr_complex(); + std::shared_ptr> queue; gr::top_block_sptr top_block; std::shared_ptr config; + std::thread ch_thread; + pmt::pmt_t message; size_t item_size; int nsamples; + bool stop{false}; }; 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 2bc731620..63038b5f1 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 @@ -43,26 +43,28 @@ DEFINE_int32(pb_filter_test_nsamples, 1000000, "Number of samples to filter in t class PulseBlankingFilterTest : public ::testing::Test { protected: - PulseBlankingFilterTest() : item_size(sizeof(gr_complex)), nsamples(FLAGS_pb_filter_test_nsamples) + PulseBlankingFilterTest() : item_size(sizeof(gr_complex)), + nsamples(FLAGS_pb_filter_test_nsamples) { queue = std::make_shared>(); config = std::make_shared(); } - ~PulseBlankingFilterTest() override = default; - bool stop = false; - std::thread ch_thread; + void start_queue(); void wait_message(); void process_message(); void stop_queue(); void init(); void configure_gr_complex_gr_complex(); + + std::thread ch_thread; std::shared_ptr> queue; - gr::top_block_sptr top_block; std::shared_ptr config; + gr::top_block_sptr top_block; + pmt::pmt_t message; size_t item_size; int nsamples; - pmt::pmt_t message; + bool stop{false}; }; diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_real_codes_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_real_codes_test.cc index 57ea5dfbe..34c4894d7 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_real_codes_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_real_codes_test.cc @@ -126,14 +126,14 @@ TEST(CpuMulticorrelatorRealCodesTest, MeasureExecutionTime) // create the concurrent correlator threads for (int current_thread = 0; current_thread < current_max_threads; current_thread++) { - thread_pool.emplace_back(std::thread(run_correlator_cpu_real_codes, + thread_pool.emplace_back(run_correlator_cpu_real_codes, correlator_pool[current_thread], d_rem_carrier_phase_rad, d_carrier_phase_step_rad, d_code_phase_step_chips, d_code_phase_rate_step_chips, d_rem_code_phase_chips, - correlation_sizes[correlation_sizes_idx])); + correlation_sizes[correlation_sizes_idx]); } // wait the threads to finish they work and destroy the thread objects for (auto& t : thread_pool) @@ -224,14 +224,14 @@ TEST(CpuMulticorrelatorRealCodesTest, MeasureExecutionTimeAlloc) // create the concurrent correlator threads for (int current_thread = 0; current_thread < current_max_threads; current_thread++) { - thread_pool.emplace_back(std::thread(run_correlator_cpu_real_codes, + thread_pool.emplace_back(run_correlator_cpu_real_codes, correlator_pool[current_thread], d_rem_carrier_phase_rad, d_carrier_phase_step_rad, d_code_phase_step_chips, d_code_phase_rate_step_chips, d_rem_code_phase_chips, - correlation_sizes[correlation_sizes_idx])); + correlation_sizes[correlation_sizes_idx]); } // wait the threads to finish they work and destroy the thread objects for (auto& t : thread_pool) diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_test.cc index 773b188b0..339205f43 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_test.cc @@ -122,13 +122,13 @@ TEST(CpuMulticorrelatorTest, MeasureExecutionTime) // create the concurrent correlator threads for (int current_thread = 0; current_thread < current_max_threads; current_thread++) { - thread_pool.push_back(std::thread(run_correlator_cpu, + thread_pool.emplace_back(run_correlator_cpu, correlator_pool[current_thread], d_rem_carrier_phase_rad, d_carrier_phase_step_rad, d_code_phase_step_chips, d_rem_code_phase_chips, - correlation_sizes[correlation_sizes_idx])); + correlation_sizes[correlation_sizes_idx]); } // wait the threads to finish they work and destroy the thread objects for (auto& t : thread_pool) @@ -220,13 +220,13 @@ TEST(CpuMulticorrelatorTest, MeasureExecutionTimeAlloc) // create the concurrent correlator threads for (int current_thread = 0; current_thread < current_max_threads; current_thread++) { - thread_pool.push_back(std::thread(run_correlator_cpu, + thread_pool.emplace_back(run_correlator_cpu, correlator_pool[current_thread], d_rem_carrier_phase_rad, d_carrier_phase_step_rad, d_code_phase_step_chips, d_rem_code_phase_chips, - correlation_sizes[correlation_sizes_idx])); + correlation_sizes[correlation_sizes_idx]); } // wait the threads to finish they work and destroy the thread objects for (auto& t : thread_pool) diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/galileo_e1_dll_pll_veml_tracking_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/galileo_e1_dll_pll_veml_tracking_test.cc index 734d70af2..0519b3de3 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/galileo_e1_dll_pll_veml_tracking_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/galileo_e1_dll_pll_veml_tracking_test.cc @@ -45,11 +45,8 @@ protected: { factory = std::make_shared(); config = std::make_shared(); - gnss_synchro = Gnss_Synchro(); } - ~GalileoE1DllPllVemlTrackingInternalTest() override = default; - void init(); std::shared_ptr> queue; @@ -58,8 +55,8 @@ protected: std::shared_ptr config; Gnss_Synchro gnss_synchro{}; size_t item_size; - bool stop{false}; int message{0}; + bool stop{false}; }; From 2889fdef0a98b1b5ce74ce30a2ffb18b8fe4ea5f Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 4 Apr 2023 09:10:15 +0200 Subject: [PATCH 27/38] Update local version of Armadillo to 12.x --- CMakeLists.txt | 95 +++++++++++++++++++++++++++----------------------- README.md | 6 ++-- 2 files changed, 55 insertions(+), 46 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 97c618979..f3d0339cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # GNSS-SDR is a Global Navigation Satellite System software-defined receiver. # This file is part of GNSS-SDR. # -# SPDX-FileCopyrightText: 2010-2022 C. Fernandez-Prades cfernandez(at)cttc.es +# SPDX-FileCopyrightText: 2010-2023 C. Fernandez-Prades cfernandez(at)cttc.es # SPDX-License-Identifier: BSD-3-Clause ################################################################################ @@ -315,55 +315,43 @@ endif() ################################################################################ # Minimum required versions ################################################################################ -set(GNSSSDR_GCC_MIN_VERSION "4.7.2") -set(GNSSSDR_CLANG_MIN_VERSION "3.4.0") set(GNSSSDR_APPLECLANG_MIN_VERSION "500") -set(GNSSSDR_GNURADIO_MIN_VERSION "3.7.3") -set(GNSSSDR_BOOST_MIN_VERSION "1.53") -set(GNSSSDR_PYTHON_MIN_VERSION "2.7") -set(GNSSSDR_PYTHON3_MIN_VERSION "3.4") -set(GNSSSDR_MAKO_MIN_VERSION "0.4.2") set(GNSSSDR_ARMADILLO_MIN_VERSION "5.300.0") +set(GNSSSDR_BOOST_MIN_VERSION "1.53") +set(GNSSSDR_CLANG_MIN_VERSION "3.4.0") +set(GNSSSDR_GCC_MIN_VERSION "4.7.2") set(GNSSSDR_GFLAGS_MIN_VERSION "2.1.2") +set(GNSSSDR_GNURADIO_MIN_VERSION "3.7.3") +set(GNSSSDR_MAKO_MIN_VERSION "0.4.2") set(GNSSSDR_MATIO_MIN_VERSION "1.5.3") set(GNSSSDR_PROTOBUF_MIN_VERSION "3.0.0") +set(GNSSSDR_PYTHON_MIN_VERSION "2.7") +set(GNSSSDR_PYTHON3_MIN_VERSION "3.4") ################################################################################ -# Versions to download and build (but not installed) if not found +# Versions to download and build (but not to install system-wide) if not found ################################################################################ +set(GNSSSDR_ARMADILLO_LOCAL_VERSION "12.2.x") set(GNSSSDR_GFLAGS_LOCAL_VERSION "2.2.2") set(GNSSSDR_GLOG_LOCAL_VERSION "0.6.0") -set(GNSSSDR_ARMADILLO_LOCAL_VERSION "11.2.x") -if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) OR - (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) OR - CMAKE_VERSION VERSION_LESS 3.5) - set(GNSSSDR_GTEST_LOCAL_VERSION "1.10.x") -else() - set(GNSSSDR_GTEST_LOCAL_VERSION "1.13.0") -endif() -set(GNSSSDR_GNSS_SIM_LOCAL_VERSION "master") -if(CMAKE_VERSION VERSION_GREATER 3.17.0) - set(GNSSSDR_GNSSTK_LOCAL_VERSION "14.0.0") -else() - set(GNSSSDR_GNSSTK_LOCAL_VERSION "13.7.0") -endif() set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.23") -set(GNSSSDR_PUGIXML_LOCAL_VERSION "1.13") set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "22.2") -if(CMAKE_CROSSCOMPILING OR CMAKE_VERSION VERSION_LESS "3.13") - set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "21.12") -endif() +set(GNSSSDR_PUGIXML_LOCAL_VERSION "1.13") +set(GNSSSDR_GTEST_LOCAL_VERSION "1.13.0") +set(GNSSSDR_GNSS_SIM_LOCAL_VERSION "master") +set(GNSSSDR_GNSSTK_LOCAL_VERSION "14.0.0") set(GNSSSDR_BENCHMARK_LOCAL_VERSION "1.7.1") set(GNSSSDR_MATHJAX_EXTERNAL_VERSION "2.7.7") +# Downgrade versions if requirements are not met if(CMAKE_VERSION VERSION_LESS "3.16") set(GNSSSDR_GLOG_LOCAL_VERSION "0.5.0") endif() if(CMAKE_VERSION VERSION_LESS "3.3") - set(GNSSSDR_GLOG_LOCAL_VERSION "0.4.0") # Fix for Debian 8 + set(GNSSSDR_GLOG_LOCAL_VERSION "0.4.0") endif() if(CMAKE_VERSION VERSION_LESS "3.0.2") @@ -371,6 +359,20 @@ if(CMAKE_VERSION VERSION_LESS "3.0.2") set(GNSSSDR_GLOG_LOCAL_VERSION "0.3.4") # Fix for Ubuntu 14.04 endif() +if(CMAKE_CROSSCOMPILING OR CMAKE_VERSION VERSION_LESS "3.13") + set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "21.12") +endif() + +if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) OR + (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) OR + CMAKE_VERSION VERSION_LESS 3.5) + set(GNSSSDR_GTEST_LOCAL_VERSION "1.10.x") +endif() + +if(CMAKE_VERSION VERSION_LESS "3.17") + set(GNSSSDR_GNSSTK_LOCAL_VERSION "13.7.0") +endif() + ################################################################################ @@ -1960,17 +1962,13 @@ if(NOT ARMADILLO_FOUND OR ENABLE_OWN_ARMADILLO) set(ARMADILLO_BUILD_COMMAND ${CMAKE_COMMAND} "--build" "${GNSSSDR_BINARY_DIR}/armadillo-${armadillo_RELEASE}" "--config" $<$:Debug>$<$:Release>$<$:RelWithDebInfo>$<$:MinSizeRel>$<$:Debug>$<$:Debug>$<$:RelWithDebInfo>$<$:RelWithDebInfo>$<$:Debug> + "--target" install ) if(CMAKE_TOOLCHAIN_FILE) set(ARMADILLO_TOOLCHAIN_FILE -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) else() set(ARMADILLO_TOOLCHAIN_FILE "") endif() - if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND ENABLE_OWN_ARMADILLO) - set(DARWIN_DISABLE_HDF5 -DDETECT_HDF5=false) - else() - set(DARWIN_DISABLE_HDF5 "") - endif() set(ARMADILLO_CXX_VERSION "") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 4.8.3) set(ARMADILLO_CXX_VERSION -DCMAKE_CXX_FLAGS=-std=c++11) @@ -1980,41 +1978,38 @@ if(NOT ARMADILLO_FOUND OR ENABLE_OWN_ARMADILLO) PREFIX ${GNSSSDR_BINARY_DIR}/armadillo-${armadillo_RELEASE} GIT_REPOSITORY https://gitlab.com/conradsnicta/armadillo-code.git GIT_TAG ${armadillo_BRANCH} + UPDATE_COMMAND "" SOURCE_DIR ${GNSSSDR_BINARY_DIR}/thirdparty/armadillo/armadillo-${armadillo_RELEASE} BINARY_DIR ${GNSSSDR_BINARY_DIR}/armadillo-${armadillo_RELEASE} CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_BUILD_TYPE=$<$:Debug>$<$:Release>$<$:RelWithDebInfo>$<$:MinSizeRel>$<$:Debug>$<$:Debug>$<$:RelWithDebInfo>$<$:RelWithDebInfo>$<$:Debug> + -DCMAKE_INSTALL_PREFIX=${GNSSSDR_BINARY_DIR}/armadillo-${armadillo_RELEASE} -DBUILD_SHARED_LIBS=OFF -DBUILD_SMOKE_TEST=OFF -DALLOW_BLAS_LAPACK_MACOS=ON ${ARMADILLO_CXX_VERSION} - ${DARWIN_DISABLE_HDF5} ${ARMADILLO_TOOLCHAIN_FILE} - -DCMAKE_BUILD_TYPE=$<$:Debug>$<$:Release>$<$:RelWithDebInfo>$<$:MinSizeRel>$<$:Debug>$<$:Debug>$<$:RelWithDebInfo>$<$:RelWithDebInfo>$<$:Debug> BUILD_COMMAND ${ARMADILLO_BUILD_COMMAND} - UPDATE_COMMAND "" INSTALL_COMMAND "" ) else() - if(CMAKE_VERSION VERSION_GREATER 3.12.0) - set(PARALLEL_BUILD "--parallel 2") - endif() ExternalProject_Add(armadillo-${armadillo_RELEASE} PREFIX ${GNSSSDR_BINARY_DIR}/armadillo-${armadillo_RELEASE} GIT_REPOSITORY https://gitlab.com/conradsnicta/armadillo-code.git GIT_TAG ${armadillo_BRANCH} + UPDATE_COMMAND "" SOURCE_DIR ${GNSSSDR_BINARY_DIR}/thirdparty/armadillo/armadillo-${armadillo_RELEASE} BINARY_DIR ${GNSSSDR_BINARY_DIR}/armadillo-${armadillo_RELEASE} CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_BUILD_TYPE=$<$:Debug>$<$:Release>$<$:RelWithDebInfo>$<$:MinSizeRel>$<$:Debug>$<$:Debug>$<$:RelWithDebInfo>$<$:RelWithDebInfo>$<$:Debug> + -DCMAKE_INSTALL_PREFIX=${GNSSSDR_BINARY_DIR}/armadillo-${armadillo_RELEASE} -DBUILD_SHARED_LIBS=OFF -DBUILD_SMOKE_TEST=OFF -DALLOW_BLAS_LAPACK_MACOS=ON ${ARMADILLO_CXX_VERSION} - ${DARWIN_DISABLE_HDF5} ${ARMADILLO_TOOLCHAIN_FILE} - -DCMAKE_BUILD_TYPE=$<$:Debug>$<$:Release>$<$:RelWithDebInfo>$<$:MinSizeRel>$<$:Debug>$<$:Debug>$<$:RelWithDebInfo>$<$:RelWithDebInfo>$<$:Debug> - BUILD_COMMAND "${ARMADILLO_BUILD_COMMAND} ${PARALLEL_BUILD}" + BUILD_COMMAND ${ARMADILLO_BUILD_COMMAND} BUILD_BYPRODUCTS ${GNSSSDR_BINARY_DIR}/armadillo-${armadillo_RELEASE}/${CMAKE_FIND_LIBRARY_PREFIXES}armadillo${CMAKE_STATIC_LIBRARY_SUFFIX} - UPDATE_COMMAND "" INSTALL_COMMAND "" ) endif() @@ -2067,6 +2062,20 @@ if(NOT ARMADILLO_FOUND OR ENABLE_OWN_ARMADILLO) if(ARPACK_LIBRARY) target_link_libraries(Armadillo::armadillo INTERFACE ${ARPACK_LIBRARY}) endif() + find_library(FLEXIBLAS_LIBRARY + NAMES flexiblas + PATHS ${CMAKE_SYSTEM_LIBRARY_PATH} /opt/local/lib /lib64 /lib /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib /opt/local/lib64 + ) + if(FLEXIBLAS_LIBRARY) + target_link_libraries(Armadillo::armadillo INTERFACE ${FLEXIBLAS_LIBRARY}) + endif() + find_library(SUPERLU_LIBRARY + NAMES superlu + PATHS ${CMAKE_SYSTEM_LIBRARY_PATH} /opt/local/lib /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib /opt/local/lib64 + ) + if(SUPERLU_LIBRARY) + target_link_libraries(Armadillo::armadillo INTERFACE ${SUPERLU_LIBRARY}) + endif() endif() diff --git a/README.md b/README.md index 19961ccab..315b0cdae 100644 --- a/README.md +++ b/README.md @@ -403,9 +403,9 @@ $ sudo apt-get install libblas-dev liblapack-dev # For Debian/Ubuntu/Linux $ sudo yum install lapack-devel blas-devel # For Fedora/CentOS/RHEL $ sudo zypper install lapack-devel blas-devel # For OpenSUSE $ sudo pacman -S blas lapack # For Arch Linux -$ wget https://sourceforge.net/projects/arma/files/armadillo-11.2.1.tar.xz -$ tar xvfz armadillo-11.2.1.tar.xz -$ cd armadillo-11.2.1 +$ wget https://sourceforge.net/projects/arma/files/armadillo-12.0.1.tar.xz +$ tar xvfz armadillo-12.0.1.tar.xz +$ cd armadillo-12.0.1 $ cmake . $ make $ sudo make install From 566ccf724a6f1e836746c3cc3669fd3d274ef5d3 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 4 Apr 2023 14:02:06 +0200 Subject: [PATCH 28/38] Handle Debug mode when building Protocol Buffers 22.2 locally --- cmake/Modules/BuildProtobuf.cmake | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/cmake/Modules/BuildProtobuf.cmake b/cmake/Modules/BuildProtobuf.cmake index 1009e419c..779f60a2c 100644 --- a/cmake/Modules/BuildProtobuf.cmake +++ b/cmake/Modules/BuildProtobuf.cmake @@ -89,7 +89,7 @@ ExternalProject_Add(protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION} "--build" "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}" "--config" $<$:Debug>$<$:Release>$<$:RelWithDebInfo>$<$:MinSizeRel>$<$:Debug>$<$:Debug>$<$:RelWithDebInfo>$<$:RelWithDebInfo>$<$:Debug> "--target" install - BUILD_BYPRODUCTS ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}protobuf${CMAKE_STATIC_LIBRARY_SUFFIX} + BUILD_BYPRODUCTS ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}protobuf$<$:d>${CMAKE_STATIC_LIBRARY_SUFFIX} ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/bin/protoc ${ABSL_LIBRARIES} ${UTF8_LIBRARIES} @@ -105,12 +105,6 @@ else() set(CoreFoundation "") endif() -if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "ASAN") - set(DEBUG_POSTFIX d) -else() - set(DEBUG_POSTFIX "") -endif() - set(PROTOBUF_ABSL_USED_TARGETS absl::absl_check absl::absl_log @@ -153,9 +147,19 @@ if(NOT TARGET protobuf::libprotobuf) add_dependencies(protobuf::libprotobuf protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}) set_target_properties(protobuf::libprotobuf PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" - IMPORTED_LOCATION "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}protobuf${DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}" - INTERFACE_INCLUDE_DIRECTORIES "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/include" - INTERFACE_LINK_LIBRARIES "${ZLIB_LIBRARIES_};${CoreFoundation};${UTF8_LIBRARIES};${PROTOBUF_ABSL_USED_TARGETS};${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}protobuf${CMAKE_STATIC_LIBRARY_SUFFIX}" + IMPORTED_CONFIGURATIONS "None;Debug;Release;RelWithDebInfo;MinSizeRel" + MAP_IMPORTED_CONFIG_NOOPTWITHASM Debug + MAP_IMPORTED_CONFIG_COVERAGE Debug + MAP_IMPORTED_CONFIG_O2WITHASM RelWithDebInfo + MAP_IMPORTED_CONFIG_O3WITHASM RelWithDebInfo + MAP_IMPORTED_CONFIG_ASAN Debug + IMPORTED_LOCATION_NONE ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}protobuf${CMAKE_STATIC_LIBRARY_SUFFIX} + IMPORTED_LOCATION_DEBUG ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}protobufd${CMAKE_STATIC_LIBRARY_SUFFIX} + IMPORTED_LOCATION_RELEASE ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}protobuf${CMAKE_STATIC_LIBRARY_SUFFIX} + IMPORTED_LOCATION_RELWITHDEBINFO ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}protobuf${CMAKE_STATIC_LIBRARY_SUFFIX} + IMPORTED_LOCATION_MINSIZEREL ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}protobuf${CMAKE_STATIC_LIBRARY_SUFFIX} + INTERFACE_INCLUDE_DIRECTORIES ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/include + INTERFACE_LINK_LIBRARIES "${ZLIB_LIBRARIES_};${CoreFoundation};${UTF8_LIBRARIES};${PROTOBUF_ABSL_USED_TARGETS};${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}protobuf$<$:d>${CMAKE_STATIC_LIBRARY_SUFFIX}" ) endif() @@ -166,7 +170,7 @@ if(NOT TARGET protobuf::protoc) set(PROTOBUF_PROTOC_EXECUTABLE "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/bin/protoc") set_target_properties(protobuf::protoc PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" - IMPORTED_LOCATION "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/bin/protoc" - INTERFACE_LINK_LIBRARIES "${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}protoc${CMAKE_STATIC_LIBRARY_SUFFIX}" + IMPORTED_LOCATION ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/bin/protoc + INTERFACE_LINK_LIBRARIES ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}protoc$<$:d>${CMAKE_STATIC_LIBRARY_SUFFIX} ) endif() From 5bfcf6a9a87458e8c8dfd4b324f4b4c3cc298aa9 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 4 Apr 2023 14:04:28 +0200 Subject: [PATCH 29/38] Add copy constructor, copy assignment operator, move constructor, and move assignment operator to Serdes_Nav_Message class --- src/core/libs/serdes_nav_message.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/core/libs/serdes_nav_message.h b/src/core/libs/serdes_nav_message.h index 98c53007f..603b39d3e 100644 --- a/src/core/libs/serdes_nav_message.h +++ b/src/core/libs/serdes_nav_message.h @@ -50,6 +50,35 @@ public: // google::protobuf::ShutdownProtobufLibrary(); } + inline Serdes_Nav_Message(const Serdes_Nav_Message& other) noexcept : navmsg_(other.navmsg_) //!< Copy constructor + { + } + + inline Serdes_Nav_Message& operator=(const Serdes_Nav_Message& rhs) noexcept //!< Copy assignment operator + { + if (this != &rhs) + { + this->navmsg_.CopyFrom(rhs.navmsg_); + } + return *this; + } + + inline Serdes_Nav_Message(Serdes_Nav_Message&& other) noexcept : navmsg_(std::move(other.navmsg_)) //!< Move constructor + { + // Set the other object's navmsg_ to a default-constructed state + other.navmsg_ = gnss_sdr::navMsg{}; + } + + inline Serdes_Nav_Message& operator=(Serdes_Nav_Message&& other) noexcept //!< Move assignment operator + { + if (this != &other) + { + navmsg_ = std::move(other.navmsg_); + other.navmsg_ = gnss_sdr::navMsg{}; + } + return *this; + } + inline std::string createProtobuffer(const std::shared_ptr nav_msg_packet) //!< Serialization into a string { navmsg_.Clear(); From ee2421426db86683f645a39e7c1b826f3314de57 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 5 Apr 2023 08:11:28 +0200 Subject: [PATCH 30/38] Raise maximum CMake policy to 3.26 --- CMakeLists.txt | 2 +- .../libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f3d0339cd..90c9ee43c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ endif() # Build type can still be overridden by setting -DCMAKE_BUILD_TYPE= set(CMAKE_BUILD_TYPE "Release" CACHE STRING "") -cmake_minimum_required(VERSION 2.8.12...3.25) +cmake_minimum_required(VERSION 2.8.12...3.26) project(gnss-sdr CXX C) set(GNSSSDR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) # Allows to be a sub-project 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 40286d2cb..6c5dd41b4 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt @@ -8,7 +8,7 @@ ######################################################################## # Project setup ######################################################################## -cmake_minimum_required(VERSION 2.8.12...3.25) +cmake_minimum_required(VERSION 2.8.12...3.26) set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose build type: None Debug Release RelWithDebInfo MinSizeRel") project(volk_gnsssdr) enable_language(CXX) From 5d6ee64c836c517e100d9ee3120c787fc0248692 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 5 Apr 2023 10:46:22 +0200 Subject: [PATCH 31/38] Temporarily add gnss-sdr_archs to next --- .github/workflows/gnss-sdr_archs.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gnss-sdr_archs.yml b/.github/workflows/gnss-sdr_archs.yml index 8105a6e31..c2972ff2e 100644 --- a/.github/workflows/gnss-sdr_archs.yml +++ b/.github/workflows/gnss-sdr_archs.yml @@ -7,7 +7,7 @@ on: push: branches: - "**-archs" - - main + - next workflow_dispatch: jobs: @@ -29,15 +29,15 @@ jobs: - arch: armv7 distro: ubuntu22.04 compiler: { name: g++-12, cc: gcc-12, cxx: g++-12 } + - arch: riscv64 + distro: ubuntu22.04 + compiler: { name: g++-12, cc: gcc-12, cxx: g++-12 } - arch: ppc64le distro: ubuntu22.04 compiler: { name: g++-12, cc: gcc-12, cxx: g++-12 } - arch: s390x distro: ubuntu22.04 compiler: { name: g++-12, cc: gcc-12, cxx: g++-12 } - - arch: riscv64 - distro: ubuntu22.04 - compiler: { name: g++-12, cc: gcc-12, cxx: g++-12 } steps: - uses: actions/checkout@v3.1.0 From 8f995b56938018c36701538f412ce1f875924e79 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 5 Apr 2023 10:47:27 +0200 Subject: [PATCH 32/38] Fix building with clang 16 --- .../volk_gnsssdr/lib/qa_utils.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc index 81f03d355..311122427 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc @@ -633,11 +633,11 @@ bool run_volk_gnsssdr_tests(volk_gnsssdr_func_desc_t desc, { if (inputsc[0].size == 2) { - run_cast_test1_s16ic((volk_gnsssdr_fn_1arg_s16ic)(manual_func), test_data[i], scalar, vlen, iter, arch_list[i]); + run_cast_test1_s16ic((volk_gnsssdr_fn_1arg_s16ic)(manual_func), test_data[i], lv_16sc_t(static_cast(scalar.real()), static_cast(scalar.imag())), vlen, iter, arch_list[i]); } else { - run_cast_test1_s8ic((volk_gnsssdr_fn_1arg_s8ic)(manual_func), test_data[i], scalar, vlen, iter, arch_list[i]); + run_cast_test1_s8ic((volk_gnsssdr_fn_1arg_s8ic)(manual_func), test_data[i], lv_8sc_t(static_cast(scalar.real()), static_cast(scalar.imag())), vlen, iter, arch_list[i]); } } else @@ -672,16 +672,16 @@ bool run_volk_gnsssdr_tests(volk_gnsssdr_func_desc_t desc, { if (inputsc[0].size == 2) { - run_cast_test2_s16ic((volk_gnsssdr_fn_2arg_s16ic)(manual_func), test_data[i], scalar, vlen, iter, arch_list[i]); + run_cast_test2_s16ic((volk_gnsssdr_fn_2arg_s16ic)(manual_func), test_data[i], lv_16sc_t(static_cast(scalar.real()), static_cast(scalar.imag())), vlen, iter, arch_list[i]); } else { - run_cast_test2_s8ic((volk_gnsssdr_fn_2arg_s8ic)(manual_func), test_data[i], scalar, vlen, iter, arch_list[i]); + run_cast_test2_s8ic((volk_gnsssdr_fn_2arg_s8ic)(manual_func), test_data[i], lv_8sc_t(static_cast(scalar.real()), static_cast(scalar.imag())), vlen, iter, arch_list[i]); } } else { - run_cast_test2_s8i((volk_gnsssdr_fn_2arg_s8i)(manual_func), test_data[i], scalar.real(), vlen, iter, arch_list[i]); + run_cast_test2_s8i((volk_gnsssdr_fn_2arg_s8i)(manual_func), test_data[i], static_cast(scalar.real()), vlen, iter, arch_list[i]); } } // ADDED BY GNSS-SDR. END @@ -712,11 +712,11 @@ bool run_volk_gnsssdr_tests(volk_gnsssdr_func_desc_t desc, { if (inputsc[0].size == 4) { - run_cast_test3_s16ic((volk_gnsssdr_fn_3arg_s16ic)(manual_func), test_data[i], scalar, vlen, iter, arch_list[i]); + run_cast_test3_s16ic((volk_gnsssdr_fn_3arg_s16ic)(manual_func), test_data[i], lv_16sc_t(static_cast(scalar.real()), static_cast(scalar.imag())), vlen, iter, arch_list[i]); } else { - run_cast_test3_s8ic((volk_gnsssdr_fn_3arg_s8ic)(manual_func), test_data[i], scalar, vlen, iter, arch_list[i]); + run_cast_test3_s8ic((volk_gnsssdr_fn_3arg_s8ic)(manual_func), test_data[i], lv_8sc_t(static_cast(scalar.real()), static_cast(scalar.imag())), vlen, iter, arch_list[i]); } } } From 08dcf3f88c6b7de26516cc00b3313df358623316 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 6 Apr 2023 08:33:42 +0200 Subject: [PATCH 33/38] CI: move back gnss-sdr arch jobs to main, deactivate ppc64le and s390x --- .github/workflows/gnss-sdr_archs.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/gnss-sdr_archs.yml b/.github/workflows/gnss-sdr_archs.yml index c2972ff2e..e2ee8c1b5 100644 --- a/.github/workflows/gnss-sdr_archs.yml +++ b/.github/workflows/gnss-sdr_archs.yml @@ -7,7 +7,7 @@ on: push: branches: - "**-archs" - - next + - main workflow_dispatch: jobs: @@ -32,12 +32,12 @@ jobs: - arch: riscv64 distro: ubuntu22.04 compiler: { name: g++-12, cc: gcc-12, cxx: g++-12 } - - arch: ppc64le - distro: ubuntu22.04 - compiler: { name: g++-12, cc: gcc-12, cxx: g++-12 } - - arch: s390x - distro: ubuntu22.04 - compiler: { name: g++-12, cc: gcc-12, cxx: g++-12 } + # - arch: ppc64le + # distro: ubuntu22.04 + # compiler: { name: g++-12, cc: gcc-12, cxx: g++-12 } + # - arch: s390x + # distro: ubuntu22.04 + # compiler: { name: g++-12, cc: gcc-12, cxx: g++-12 } steps: - uses: actions/checkout@v3.1.0 From 2479e889b8b0c1a88b99e06802378602609a3a2a Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 6 Apr 2023 11:11:52 +0200 Subject: [PATCH 34/38] Fix for Clang 16 --- cmake/Modules/BuildProtobuf.cmake | 43 +++++++++++++++++++------------ 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/cmake/Modules/BuildProtobuf.cmake b/cmake/Modules/BuildProtobuf.cmake index 779f60a2c..ca8ea19c7 100644 --- a/cmake/Modules/BuildProtobuf.cmake +++ b/cmake/Modules/BuildProtobuf.cmake @@ -4,10 +4,24 @@ # SPDX-FileCopyrightText: 2023 C. Fernandez-Prades cfernandez(at)cttc.es # SPDX-License-Identifier: BSD-3-Clause +# Downloads and builds the protoc compiler and static libraries of Protocol +# Buffers >= v22.0 (see https://protobuf.dev/) It requires CMake >= 3.10 and the +# abseil-cpp >= 20230117 libraries (see https://github.com/abseil/abseil-cpp) +# already installed. Zlib is used if found. +# +# Note: requires the patch command if using GCC >= 13 or Clang >= 16 +# +# Creates protobuf::libprotobuf and protobuf::protoc imported targets. + + if(NOT GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION) set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "22.2") endif() +if(NOT GNSSSDR_BINARY_DIR) + set(GNSSSDR_BINARY_DIR "${PROJECT_BINARY_DIR}") +endif() + if(NOT ZLIB_FOUND) find_package(ZLIB) set_package_properties(ZLIB PROPERTIES @@ -43,22 +57,19 @@ list(APPEND UTF8_LIBRARIES ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}utf8_range${CMAKE_STATIC_LIBRARY_SUFFIX} ) -# Fix for GCC 13 -if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "12.99") - find_program(Patch_EXECUTABLE NAME patch PATHS ENV PATH) - if(NOT Patch_EXECUTABLE) - message(FATAL_ERROR "The patch command is not found. It is required to build Protocol Buffers. Please check your OS documentation and install the patch command.") - endif() - set(PROTOBUF_PATCH_COMMAND - cd ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/src/google/protobuf/ && - ${Patch_EXECUTABLE} ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/src/google/protobuf/port.h < ${GNSSSDR_SOURCE_DIR}/src/tests/data/protobuf22.patch - ) - # Patch only once - if(EXISTS ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/src/google/protobuf/port.h) - set(PROTOBUF_PATCH_COMMAND "") - endif() - else() +# Fix for GCC 13 and Clang 16 +if(((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "13")) OR + ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "16"))) + find_program(Patch_EXECUTABLE NAME patch PATHS ENV PATH) + if(NOT Patch_EXECUTABLE) + message(FATAL_ERROR "The patch command is not found. It is required to build Protocol Buffers. Please check your OS documentation and install the patch command.") + endif() + set(PROTOBUF_PATCH_COMMAND + cd ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/src/google/protobuf/ && + ${Patch_EXECUTABLE} ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/src/google/protobuf/port.h < ${GNSSSDR_SOURCE_DIR}/src/tests/data/protobuf22.patch + ) + # Patch only once + if(EXISTS ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/src/google/protobuf/port.h) set(PROTOBUF_PATCH_COMMAND "") endif() else() From dae9feb617d1b2fe15e49406025a45fa2e2f494e Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 6 Apr 2023 11:11:52 +0200 Subject: [PATCH 35/38] Fix for Clang 16 --- cmake/Modules/BuildProtobuf.cmake | 43 +++++++++++++++++++------------ 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/cmake/Modules/BuildProtobuf.cmake b/cmake/Modules/BuildProtobuf.cmake index 779f60a2c..ca8ea19c7 100644 --- a/cmake/Modules/BuildProtobuf.cmake +++ b/cmake/Modules/BuildProtobuf.cmake @@ -4,10 +4,24 @@ # SPDX-FileCopyrightText: 2023 C. Fernandez-Prades cfernandez(at)cttc.es # SPDX-License-Identifier: BSD-3-Clause +# Downloads and builds the protoc compiler and static libraries of Protocol +# Buffers >= v22.0 (see https://protobuf.dev/) It requires CMake >= 3.10 and the +# abseil-cpp >= 20230117 libraries (see https://github.com/abseil/abseil-cpp) +# already installed. Zlib is used if found. +# +# Note: requires the patch command if using GCC >= 13 or Clang >= 16 +# +# Creates protobuf::libprotobuf and protobuf::protoc imported targets. + + if(NOT GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION) set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "22.2") endif() +if(NOT GNSSSDR_BINARY_DIR) + set(GNSSSDR_BINARY_DIR "${PROJECT_BINARY_DIR}") +endif() + if(NOT ZLIB_FOUND) find_package(ZLIB) set_package_properties(ZLIB PROPERTIES @@ -43,22 +57,19 @@ list(APPEND UTF8_LIBRARIES ${GNSSSDR_BINARY_DIR}/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}utf8_range${CMAKE_STATIC_LIBRARY_SUFFIX} ) -# Fix for GCC 13 -if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "12.99") - find_program(Patch_EXECUTABLE NAME patch PATHS ENV PATH) - if(NOT Patch_EXECUTABLE) - message(FATAL_ERROR "The patch command is not found. It is required to build Protocol Buffers. Please check your OS documentation and install the patch command.") - endif() - set(PROTOBUF_PATCH_COMMAND - cd ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/src/google/protobuf/ && - ${Patch_EXECUTABLE} ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/src/google/protobuf/port.h < ${GNSSSDR_SOURCE_DIR}/src/tests/data/protobuf22.patch - ) - # Patch only once - if(EXISTS ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/src/google/protobuf/port.h) - set(PROTOBUF_PATCH_COMMAND "") - endif() - else() +# Fix for GCC 13 and Clang 16 +if(((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "13")) OR + ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "16"))) + find_program(Patch_EXECUTABLE NAME patch PATHS ENV PATH) + if(NOT Patch_EXECUTABLE) + message(FATAL_ERROR "The patch command is not found. It is required to build Protocol Buffers. Please check your OS documentation and install the patch command.") + endif() + set(PROTOBUF_PATCH_COMMAND + cd ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/src/google/protobuf/ && + ${Patch_EXECUTABLE} ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/src/google/protobuf/port.h < ${GNSSSDR_SOURCE_DIR}/src/tests/data/protobuf22.patch + ) + # Patch only once + if(EXISTS ${GNSSSDR_BINARY_DIR}/thirdparty/protobuf/protobuf-${GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION}/src/google/protobuf/port.h) set(PROTOBUF_PATCH_COMMAND "") endif() else() From d955266d55c6e23fb887cd0c73ef788f89134eb4 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 6 Apr 2023 11:20:17 +0200 Subject: [PATCH 36/38] Bump version number --- AUTHORS | 1 + CITATION.cff | 6 +++--- CMakeLists.txt | 6 +++--- docs/CHANGELOG.md | 7 +++---- docs/manpage/gnss-sdr-manpage | 2 +- .../libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt | 2 +- .../cmake/Packaging/volk_gnsssdr-config-info-manpage | 2 +- .../cmake/Packaging/volk_gnsssdr_profile-manpage | 2 +- src/main/main.cc | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/AUTHORS b/AUTHORS index 970c52a8d..653f8a16c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -51,6 +51,7 @@ David Pubill david.pubill@cttc.cat Contributor Fran Fabra fabra@ice.csic.es Contributor Gabriel Araujo gabriel.araujo.5000@gmail.com Contributor Gerald LaMountain gerald@gece.neu.edu Contributor +Into Pääkkönen into.paakkonen@aalto.fi Contributor Jim Melton jim.melton@sncorp.com Contributor Josh Schindehette jschindehette@geontech.com Contributor Leonardo Tonetto tonetto.dev@gmail.com Contributor diff --git a/CITATION.cff b/CITATION.cff index 49f6673b3..27266990b 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-3.0-or-later -# SPDX-FileCopyrightText: 2022 C. Fernandez-Prades carles.fernandez(at)cttc.es +# SPDX-FileCopyrightText: 2023 C. Fernandez-Prades carles.fernandez(at)cttc.es --- authors: - affiliation: "Centre Tecnològic de Telecomunicacions de Catalunya (CTTC)" @@ -110,7 +110,7 @@ authors: family-names: "van der Linden" given-names: Stefan cff-version: "1.2.0" -date-released: "2022-04-20" +date-released: "2023-04-06" identifiers: - description: "The concept DOI of the work. This is a DOI always pointing to the latest stable release." type: doi @@ -318,4 +318,4 @@ repository-code: "https://github.com/gnss-sdr/gnss-sdr" title: GNSS-SDR type: software url: "https://gnss-sdr.org" -version: "0.0.17" +version: "0.0.18" diff --git a/CMakeLists.txt b/CMakeLists.txt index 90c9ee43c..b730b8997 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,7 +140,7 @@ option(ENABLE_ORC "Use (if available) the Optimized Inner Loop Runtime Compiler ################################################################################ # GNSS-SDR version information ################################################################################ -set(THIS_IS_A_RELEASE OFF) # only related to version name, no further implications. +set(THIS_IS_A_RELEASE ON) # only related to version name, no further implications. if(NOT ${THIS_IS_A_RELEASE}) find_package(Git) set_package_properties(Git PROPERTIES @@ -176,9 +176,9 @@ endif() set(VERSION_INFO_MAJOR_VERSION 0) set(VERSION_INFO_API_COMPAT 0) if(${THIS_IS_A_RELEASE}) - set(VERSION_INFO_MINOR_VERSION 17) + set(VERSION_INFO_MINOR_VERSION 18) else() - set(VERSION_INFO_MINOR_VERSION 17.git-${GIT_BRANCH}-${GIT_COMMIT_HASH}) + set(VERSION_INFO_MINOR_VERSION 18.git-${GIT_BRANCH}-${GIT_COMMIT_HASH}) endif() set(VERSION ${VERSION_INFO_MAJOR_VERSION}.${VERSION_INFO_API_COMPAT}.${VERSION_INFO_MINOR_VERSION}) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 05d44735a..6a3c18db1 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -12,7 +12,7 @@ SPDX-FileCopyrightText: 2011-2023 Carles Fernandez-Prades .\" Contact carles.fernandez@cttc.es to correct errors or typos. -.TH gnss\-sdr 1 "20 Apr 2022" "0.0.17" "gnss\-sdr man page" +.TH gnss\-sdr 1 "6 Apr 2023" "0.0.18" "gnss\-sdr man page" .SH NAME \fBgnss\-sdr\fR \- GNSS Software Defined Receiver. .SH SYNOPSIS 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 6c5dd41b4..0a668f741 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt @@ -206,7 +206,7 @@ message(STATUS "Build type set to ${CMAKE_BUILD_TYPE}.") set(VERSION_INFO_MAJOR_VERSION 0) set(VERSION_INFO_MINOR_VERSION 0) -set(VERSION_INFO_MAINT_VERSION 17.git) +set(VERSION_INFO_MAINT_VERSION 18) include(VolkGnsssdrVersion) # setup version info diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Packaging/volk_gnsssdr-config-info-manpage b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Packaging/volk_gnsssdr-config-info-manpage index 8bc4acadc..bd5f400de 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Packaging/volk_gnsssdr-config-info-manpage +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Packaging/volk_gnsssdr-config-info-manpage @@ -2,7 +2,7 @@ .\" SPDX-License-Identifier: GPL-3.0-or-later .\" SPDX-FileCopyrightText: Carles Fernandez-Prades .\" Contact carles.fernandez@cttc.es to correct errors or typos. -.TH volk_gnsssdr\-config\-info 1 "20 Apr 2022" "0.0.17" "volk_gnsssdr\-config\-info man page" +.TH volk_gnsssdr\-config\-info 1 "6 Apr 2023" "0.0.18" "volk_gnsssdr\-config\-info man page" .SH NAME \fBvolk_gnsssdr\-config\-info\fR \- Prints configuration information of libvolk_gnsssdr functions. .SH SYNOPSIS diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Packaging/volk_gnsssdr_profile-manpage b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Packaging/volk_gnsssdr_profile-manpage index 6d20c2bda..19636133c 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Packaging/volk_gnsssdr_profile-manpage +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Packaging/volk_gnsssdr_profile-manpage @@ -2,7 +2,7 @@ .\" SPDX-License-Identifier: GPL-3.0-or-later .\" SPDX-FileCopyrightText: Carles Fernandez-Prades .\" Contact carles.fernandez@cttc.es to correct errors or typos. -.TH volk_gnsssdr_profile 1 "20 Apr 2022" "0.0.17" "volk_gnsssdr_profile man page" +.TH volk_gnsssdr_profile 1 "6 Apr 2023" "0.0.18" "volk_gnsssdr_profile man page" .SH NAME \fBvolk_gnsssdr_profile\fR \- Profiler application for libvolk_gnsssdr functions. .SH SYNOPSIS diff --git a/src/main/main.cc b/src/main/main.cc index b48e2272d..f01f050ee 100644 --- a/src/main/main.cc +++ b/src/main/main.cc @@ -18,7 +18,7 @@ */ #ifndef GNSS_SDR_VERSION -#define GNSS_SDR_VERSION "0.0.17" +#define GNSS_SDR_VERSION "0.0.18" #endif #ifndef GOOGLE_STRIP_LOG From e7b0bac67f322aa94e113e4ad3b68ad32a042098 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 6 Apr 2023 15:06:16 +0200 Subject: [PATCH 37/38] The action continues in the next bracnh --- CMakeLists.txt | 2 +- docs/CHANGELOG.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b730b8997..024d573a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,7 +140,7 @@ option(ENABLE_ORC "Use (if available) the Optimized Inner Loop Runtime Compiler ################################################################################ # GNSS-SDR version information ################################################################################ -set(THIS_IS_A_RELEASE ON) # only related to version name, no further implications. +set(THIS_IS_A_RELEASE OFF) # only related to version name, no further implications. if(NOT ${THIS_IS_A_RELEASE}) find_package(Git) set_package_properties(Git PROPERTIES diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 6a3c18db1..5fd567b0c 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -14,6 +14,8 @@ All notable changes to GNSS-SDR will be documented in this file. ## [GNSS-SDR v0.0.18](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.18) - 2023-04-06 +[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7805514.svg)](https://doi.org/10.5281/zenodo.7805514) + ### Improvements in Accuracy: - Processing and application of the corrections provided by the Galileo High From 2c69d2f2135a3bfe7aa841522aaa161d8905f9ac Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 7 Apr 2023 09:43:21 +0200 Subject: [PATCH 38/38] Fix clang-format version to 15 in CI job --- .github/workflows/main.yml | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d25e7b2ff..26108abcf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -85,19 +85,15 @@ jobs: ../install/position_test clang-format: - runs-on: macos-latest + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: install dependencies - run: brew install clang-format - name: run clang-format - run: find . -iname \*.h -o -iname \*.c -o -iname \*.cc | xargs clang-format -style=file -i - - name: check - run: | - git diff > clang_format.patch - echo -e "if \n [ -s clang_format.patch ] \nthen \n echo "clang-format not applied:"; echo ""; more clang_format.patch; exit 1 \nfi \n" > detect - chmod +x ./detect - ./detect + uses: jidicula/clang-format-action@v4.11.0 + with: + clang-format-version: "15" + check-path: "src" + exclude-regex: '(libs\/gsl\/)|^.*\.(cu|proto)$' clang-tidy: runs-on: macos-latest