diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d0fba91cb..ddd445d27 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -123,7 +123,7 @@ jobs: steps: - uses: actions/checkout@v5 - name: run clang-format - uses: jidicula/clang-format-action@v4.15.0 + uses: jidicula/clang-format-action@v4.16.0 with: clang-format-version: "19" check-path: ${{ matrix.path }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 62e055be4..df1bf75e2 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...4.1) +cmake_minimum_required(VERSION 2.8.12...4.2) project(gnss-sdr CXX C) set(GNSSSDR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) # Allows to be a sub-project @@ -358,7 +358,7 @@ set(GNSSSDR_ABSEIL_MIN_VERSION "20240116") set(GNSSSDR_ARMADILLO_LOCAL_VERSION "15.0.x") set(GNSSSDR_GFLAGS_LOCAL_VERSION "2.2.2") set(GNSSSDR_GLOG_LOCAL_VERSION "0.7.1") -set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.28") +set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.29") set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "32.1") set(GNSSSDR_PUGIXML_LOCAL_VERSION "1.15") set(GNSSSDR_GTEST_LOCAL_VERSION "1.17.0") diff --git a/README.md b/README.md index 11b418ed8..0914312a0 100644 --- a/README.md +++ b/README.md @@ -186,6 +186,9 @@ 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. +Starting from Debian 13 / Ubuntu 25.10, `libabsl-dev` can replace +`libgflags-dev` and `libgoogle-glog-dev`. + Once you have installed these packages, you can jump directly to [download the source code and build GNSS-SDR](#clone-gnss-sdrs-git-repository). @@ -355,9 +358,9 @@ $ sudo pacman -S openssl # For Arch Linux #### Install [Matio](https://github.com/tbeu/matio "Matio's Homepage"), MATLAB MAT file I/O library ``` -$ wget https://github.com/tbeu/matio/releases/download/v1.5.28/matio-1.5.28.tar.gz -$ tar xvfz matio-1.5.28.tar.gz -$ cd matio-1.5.28 +$ wget https://github.com/tbeu/matio/releases/download/v1.5.29/matio-1.5.29.tar.gz +$ tar xvfz matio-1.5.29.tar.gz +$ cd matio-1.5.29 $ ./configure $ make $ sudo make install diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index 98d6100e6..e7424faae 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -3582,7 +3582,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Beidou_Dnav_Utc_M void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) const { std::string line; - const auto sys_char = satelliteSystem.at("GPS"); + const auto& sys_char = satelliteSystem.at("GPS"); for (const auto& gps_ephemeris_iter : eph_map) { @@ -3802,7 +3802,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) { - const auto sys_char = satelliteSystem.at("GPS"); + const auto& sys_char = satelliteSystem.at("GPS"); for (const auto& gps_ephemeris_iter : eph_map) { @@ -3864,7 +3864,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) const { - const auto sys_char = satelliteSystem.at("Galileo"); + const auto& sys_char = satelliteSystem.at("Galileo"); for (const auto& galileo_ephemeris_iter : eph_map) { @@ -3950,7 +3950,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) const { std::string line; - const auto sys_char = satelliteSystem.at("GLONASS"); + const auto& sys_char = satelliteSystem.at("GLONASS"); for (const auto& glonass_gnav_ephemeris_iter : eph_map) { @@ -4099,7 +4099,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) const { - const auto sys_char = satelliteSystem.at("Beidou"); + const auto& sys_char = satelliteSystem.at("Beidou"); for (const auto& bds_ephemeris_iter : eph_map) { diff --git a/src/algorithms/acquisition/adapters/CMakeLists.txt b/src/algorithms/acquisition/adapters/CMakeLists.txt index b191c5de4..003ed544a 100644 --- a/src/algorithms/acquisition/adapters/CMakeLists.txt +++ b/src/algorithms/acquisition/adapters/CMakeLists.txt @@ -7,6 +7,7 @@ set(ACQ_ADAPTER_SOURCES base_pcps_acquisition.cc + base_pcps_acquisition_custom.cc gps_l1_ca_pcps_acquisition.cc gps_l1_ca_pcps_assisted_acquisition.cc gps_l1_ca_pcps_acquisition_fine_doppler.cc @@ -31,6 +32,7 @@ set(ACQ_ADAPTER_SOURCES set(ACQ_ADAPTER_HEADERS base_pcps_acquisition.h + base_pcps_acquisition_custom.h gps_l1_ca_pcps_acquisition.h gps_l1_ca_pcps_assisted_acquisition.h gps_l1_ca_pcps_acquisition_fine_doppler.h diff --git a/src/algorithms/acquisition/adapters/base_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/base_pcps_acquisition.cc index 09b5c89f0..892fa61cd 100644 --- a/src/algorithms/acquisition/adapters/base_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/base_pcps_acquisition.cc @@ -1,11 +1,8 @@ /*! - * \file gps_l1_ca_pcps_acquisition.cc - * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for - * GPS L1 C/A signals + * \file base_ca_pcps_acquisition.h + * \brief Adapts a PCPS acquisition block to an AcquisitionInterface * \authors
    - *
  • Javier Arribas, 2011. jarribas(at)cttc.es - *
  • Luis Esteve, 2012. luis(at)epsilon-formacion.com - *
  • Marc Molina, 2013. marc.molina.pena(at)gmail.com + *
  • Mathieu Favreau, 2025. favreau.mathieu(at)hotmail.com *
* * ----------------------------------------------------------------------------- @@ -13,7 +10,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2025 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -44,6 +41,7 @@ Acq_Conf get_acq_conf(const ConfigurationInterface* configuration, const std::st { Acq_Conf acq_parameters; acq_parameters.ms_per_code = ms_per_code; + acq_parameters.sampled_ms = ms_per_code; // Set as default value acq_parameters.SetFromConfiguration(configuration, role, chip_rate, opt_freq); #if USE_GLOG_AND_GFLAGS @@ -51,11 +49,19 @@ Acq_Conf get_acq_conf(const ConfigurationInterface* configuration, const std::st { acq_parameters.doppler_max = FLAGS_doppler_max; } + if (FLAGS_doppler_step != 0) + { + acq_parameters.doppler_step = FLAGS_doppler_step; + } #else if (absl::GetFlag(FLAGS_doppler_max) != 0) { acq_parameters.doppler_max = absl::GetFlag(FLAGS_doppler_max); } + if (absl::GetFlag(FLAGS_doppler_step) != 0) + { + acq_parameters.doppler_step = absl::GetFlag(FLAGS_doppler_step); + } #endif return acq_parameters; @@ -71,6 +77,7 @@ BasePcpsAcquisition::BasePcpsAcquisition( double opt_freq, double code_length_chips, uint32_t ms_per_code) : acq_parameters_(get_acq_conf(configuration, role, chip_rate, opt_freq, ms_per_code)), + gnss_synchro_(nullptr), role_(role), vector_length_(std::floor(acq_parameters_.sampled_ms * acq_parameters_.samples_per_ms) * (acq_parameters_.bit_transition_flag ? 2.0 : 1.0)), code_length_(static_cast(std::floor(static_cast(acq_parameters_.resampled_fs) / (chip_rate / code_length_chips)))), @@ -109,18 +116,6 @@ void BasePcpsAcquisition::set_threshold(float threshold) } -void BasePcpsAcquisition::set_doppler_max(unsigned int doppler_max) -{ - acquisition_->set_doppler_max(doppler_max); -} - - -void BasePcpsAcquisition::set_doppler_step(unsigned int doppler_step) -{ - acquisition_->set_doppler_step(doppler_step); -} - - void BasePcpsAcquisition::set_doppler_center(int doppler_center) { acquisition_->set_doppler_center(doppler_center); @@ -140,24 +135,12 @@ signed int BasePcpsAcquisition::mag() } -void BasePcpsAcquisition::init() -{ - acquisition_->init(); -} - - void BasePcpsAcquisition::reset() { acquisition_->set_active(true); } -void BasePcpsAcquisition::set_state(int state) -{ - acquisition_->set_state(state); -} - - void BasePcpsAcquisition::connect(gr::top_block_sptr top_block) { if (acq_parameters_.item_type == "gr_complex" || acq_parameters_.item_type == "cshort") diff --git a/src/algorithms/acquisition/adapters/base_pcps_acquisition.h b/src/algorithms/acquisition/adapters/base_pcps_acquisition.h index e1da2523b..40d31183e 100644 --- a/src/algorithms/acquisition/adapters/base_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/base_pcps_acquisition.h @@ -2,7 +2,7 @@ * \file base_ca_pcps_acquisition.h * \brief Adapts a PCPS acquisition block to an AcquisitionInterface * \authors
    - *
  • Mathieu Favreau, 2011. favreau.mathieu(at)hotmail.com + *
  • Mathieu Favreau, 2025. favreau.mathieu(at)hotmail.com *
* * ----------------------------------------------------------------------------- @@ -98,25 +98,11 @@ public: */ void set_threshold(float threshold) override; - /*! - * \brief Set maximum Doppler off grid search - */ - void set_doppler_max(unsigned int doppler_max) override; - - /*! - * \brief Set Doppler steps for the grid search - */ - void set_doppler_step(unsigned int doppler_step) override; - /*! * \brief Set Doppler center for the grid search */ void set_doppler_center(int doppler_center) override; - /*! - * \brief Initializes acquisition algorithm. - */ - void init() override; /*! * \brief Returns the maximum peak of grid search @@ -128,11 +114,6 @@ public: */ void reset() override; - /*! - * \brief If state = 1, it forces the block to start acquiring from the first sample - */ - void set_state(int state) override; - /*! * \brief Stop running acquisition */ diff --git a/src/algorithms/acquisition/adapters/base_pcps_acquisition_custom.cc b/src/algorithms/acquisition/adapters/base_pcps_acquisition_custom.cc new file mode 100644 index 000000000..6f2909a7d --- /dev/null +++ b/src/algorithms/acquisition/adapters/base_pcps_acquisition_custom.cc @@ -0,0 +1,275 @@ +/*! + * \file base_ca_pcps_acquisition_custom.h + * \brief Adapts a PCPS acquisition block to an AcquisitionInterface + * \authors
    + *
  • Mathieu Favreau, 2025. favreau.mathieu(at)hotmail.com + *
+ * + * ----------------------------------------------------------------------------- + * + * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + * This file is part of GNSS-SDR. + * + * Copyright (C) 2010-2025 (see AUTHORS file for a list of contributors) + * SPDX-License-Identifier: GPL-3.0-or-later + * + * ----------------------------------------------------------------------------- + */ + +#include "base_pcps_acquisition_custom.h" +#include "configuration_interface.h" +#include "gnss_sdr_flags.h" +#include + +#if USE_GLOG_AND_GFLAGS +#include +#else +#include +#endif + + +namespace +{ +const std::string default_dump_filename("./acquisition.dat"); + +Acq_Conf get_acq_conf( + const ConfigurationInterface* configuration, + const std::string& role, + double chip_rate, + double opt_freq, + uint32_t ms_per_code, + uint32_t max_sampled_ms) +{ + Acq_Conf acq_parameters; + acq_parameters.ms_per_code = ms_per_code; + acq_parameters.sampled_ms = ms_per_code; // Set as default value + acq_parameters.dump_filename = default_dump_filename; // Set as default value + acq_parameters.SetFromConfiguration(configuration, role, chip_rate, opt_freq); + +#if USE_GLOG_AND_GFLAGS + if (FLAGS_doppler_max != 0) + { + acq_parameters.doppler_max = FLAGS_doppler_max; + } + if (FLAGS_doppler_step != 0) + { + acq_parameters.doppler_step = FLAGS_doppler_step; + } +#else + if (absl::GetFlag(FLAGS_doppler_max) != 0) + { + acq_parameters.doppler_max = absl::GetFlag(FLAGS_doppler_max); + } + if (absl::GetFlag(FLAGS_doppler_step) != 0) + { + acq_parameters.doppler_step = absl::GetFlag(FLAGS_doppler_step); + } +#endif + + if (acq_parameters.sampled_ms > max_sampled_ms) + { + acq_parameters.sampled_ms = max_sampled_ms; + DLOG(INFO) << "Coherent integration time should be " << max_sampled_ms << " ms or less. Changing to " << max_sampled_ms << "ms "; + std::cout << "Too high coherent integration time. Changing to " << max_sampled_ms << "ms\n"; + } + + return acq_parameters; +} +} // namespace + + +BasePcpsAcquisitionCustom::BasePcpsAcquisitionCustom( + const ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams, + double chip_rate, + double code_length_chips, + unsigned int ms_per_code, + bool use_stream_to_vector, + bool compute_threshold_from_pfa, + uint32_t max_sampled_ms) + : acq_parameters_(get_acq_conf(configuration, role, chip_rate, 0, ms_per_code, max_sampled_ms)), + num_codes_(acq_parameters_.sampled_ms / ms_per_code), + code_length_(static_cast(round(acq_parameters_.fs_in / (chip_rate / code_length_chips)))), + vector_length_(code_length_ * num_codes_), + gnss_synchro_(nullptr), + channel_(0), + code_(vector_length_), + role_(role), + is_type_gr_complex_(acq_parameters_.item_type == "gr_complex"), + item_size_(is_type_gr_complex_ ? sizeof(gr_complex) : 0), + use_stream_to_vector_(use_stream_to_vector), + compute_threshold_from_pfa_(compute_threshold_from_pfa) +{ + DLOG(INFO) << "role " << role_; + + if (is_type_gr_complex_) + { + if (use_stream_to_vector_) + { + stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); + DLOG(INFO) << "stream_to_vector(" << stream_to_vector_->unique_id() << ")"; + } + } + else + { + LOG(WARNING) << acq_parameters_.item_type << " unknown acquisition item type"; + } + + if (in_streams > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams > 0) + { + LOG(ERROR) << "This implementation does not provide an output stream"; + } +} + + +void BasePcpsAcquisitionCustom::connect(gr::top_block_sptr top_block) +{ + if (is_type_gr_complex_ && use_stream_to_vector_) + { + top_block->connect(stream_to_vector_, 0, acquisition_cc_, 0); + } +} + + +void BasePcpsAcquisitionCustom::disconnect(gr::top_block_sptr top_block) +{ + if (is_type_gr_complex_ && use_stream_to_vector_) + { + top_block->disconnect(stream_to_vector_, 0, acquisition_cc_, 0); + } +} + + +gr::basic_block_sptr BasePcpsAcquisitionCustom::get_left_block() +{ + if (use_stream_to_vector_) + { + return stream_to_vector_; + } + return acquisition_cc_; +} + + +gr::basic_block_sptr BasePcpsAcquisitionCustom::get_right_block() +{ + return acquisition_cc_; +} + + +void BasePcpsAcquisitionCustom::set_gnss_synchro(Gnss_Synchro* gnss_synchro) +{ + gnss_synchro_ = gnss_synchro; + + if (is_type_gr_complex_) + { + acquisition_cc_->set_gnss_synchro(gnss_synchro); + } +} + +void BasePcpsAcquisitionCustom::set_channel(unsigned int channel) +{ + channel_ = channel; + + if (is_type_gr_complex_) + { + acquisition_cc_->set_channel(channel); + } +} + + +void BasePcpsAcquisitionCustom::set_channel_fsm(std::weak_ptr channel_fsm) +{ + if (is_type_gr_complex_) + { + acquisition_cc_->set_channel_fsm(channel_fsm); + } +} + + +signed int BasePcpsAcquisitionCustom::mag() +{ + if (is_type_gr_complex_) + { + return acquisition_cc_->mag(); + } + return 0; +} + + +void BasePcpsAcquisitionCustom::reset() +{ + if (is_type_gr_complex_) + { + acquisition_cc_->set_active(true); + } +} + + +void BasePcpsAcquisitionCustom::stop_acquisition() +{ + if (is_type_gr_complex_) + { + acquisition_cc_->set_active(false); + } +} + + +void BasePcpsAcquisitionCustom::set_threshold(float threshold) +{ + if (is_type_gr_complex_) + { + if (compute_threshold_from_pfa_ && acq_parameters_.pfa != 0) + { + threshold = calculate_threshold(acq_parameters_.pfa); + DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold; + } + + acquisition_cc_->set_threshold(threshold); + } +} + + +void BasePcpsAcquisitionCustom::set_local_code() +{ + if (is_type_gr_complex()) + { + std::vector> code(code_length_); + code_gen_complex_sampled(code, gnss_synchro_->PRN, acq_parameters_.fs_in); + + own::span code_span(code_.data(), vector_length_); + for (unsigned int i = 0; i < num_codes_; i++) + { + std::copy_n(code.data(), code_length_, code_span.subspan(i * code_length_, code_length_).data()); + } + + acquisition_cc_->set_local_code(code_.data()); + } +} + + +float BasePcpsAcquisitionCustom::calculate_threshold(float pfa) const +{ + // Calculate the threshold + unsigned int frequency_bins = 0; + for (int doppler = -acq_parameters_.doppler_max; doppler <= acq_parameters_.doppler_max; doppler += acq_parameters_.doppler_step) + { + frequency_bins++; + } + + DLOG(INFO) << "Channel " << channel_ << " Pfa = " << pfa; + + const auto ncells = vector_length_ * frequency_bins; + const auto exponent = 1 / static_cast(ncells); + const auto val = pow(1.0 - pfa, exponent); + const auto lambda = static_cast(vector_length_); + boost::math::exponential_distribution mydist(lambda); + const auto threshold = static_cast(quantile(mydist, val)); + + return threshold; +} diff --git a/src/algorithms/acquisition/adapters/base_pcps_acquisition_custom.h b/src/algorithms/acquisition/adapters/base_pcps_acquisition_custom.h new file mode 100644 index 000000000..d4596e7a6 --- /dev/null +++ b/src/algorithms/acquisition/adapters/base_pcps_acquisition_custom.h @@ -0,0 +1,144 @@ +/*! + * \file base_ca_pcps_acquisition_custom.h + * \brief Adapts a PCPS acquisition block to an AcquisitionInterface + * \authors
    + *
  • Mathieu Favreau, 2025. favreau.mathieu(at)hotmail.com + *
+ * + * ----------------------------------------------------------------------------- + * + * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + * This file is part of GNSS-SDR. + * + * Copyright (C) 2010-2025 (see AUTHORS file for a list of contributors) + * SPDX-License-Identifier: GPL-3.0-or-later + * + * ----------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_BASE_PCPS_ACQUISITION_CUSTOM_H +#define GNSS_SDR_BASE_PCPS_ACQUISITION_CUSTOM_H + +#include "acquisition_impl_interface.h" +#include "channel_fsm.h" +#include "gnss_synchro.h" +#include "pcps_acquisition.h" +#include +#include +#include + +/** \addtogroup Acquisition + * Classes for GNSS signal acquisition + * \{ */ +/** \addtogroup Acq_adapters acquisition_adapters + * Wrap GNU Radio acquisition blocks with an AcquisitionInterface + * \{ */ + + +class ConfigurationInterface; + +/*! + * \brief This class adapts a PCPS acquisition block to an AcquisitionInterface + */ +class BasePcpsAcquisitionCustom : public AcquisitionInterface +{ +public: + BasePcpsAcquisitionCustom(const ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams, + double chip_rate, + double code_length_chips, + unsigned int ms_per_code, + bool use_stream_to_vector, + bool compute_threshold_from_pfa, + uint32_t max_sampled_ms = std::numeric_limits::max()); + + ~BasePcpsAcquisitionCustom() = default; + + inline std::string role() override { return role_; } + + inline size_t item_size() override { return item_size_; } + + void connect(gr::top_block_sptr top_block) override; + void disconnect(gr::top_block_sptr top_block) override; + gr::basic_block_sptr get_left_block() override; + gr::basic_block_sptr get_right_block() override; + + /*! + * \brief Set acquisition/tracking common Gnss_Synchro object pointer + * to efficiently exchange synchronization data between acquisition and + * tracking blocks + */ + void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; + + /*! + * \brief Set acquisition channel unique ID + */ + void set_channel(unsigned int channel) override; + + /*! + * \brief Set channel fsm associated to this acquisition instance + */ + void set_channel_fsm(std::weak_ptr channel_fsm) override; + + /*! + * \brief Returns the maximum peak of grid search + */ + signed int mag() override; + + /*! + * \brief Restart acquisition algorithm + */ + void reset() override; + + /*! + * \brief Stop running acquisition + */ + void stop_acquisition() override; + + /*! + * \brief Set statistics threshold of PCPS algorithm + */ + void set_threshold(float threshold) override; + + void set_resampler_latency(uint32_t /*latency_samples*/) override {}; + + /*! + * \brief Sets local code + */ + void set_local_code() override; + + +protected: + bool is_type_gr_complex() const { return is_type_gr_complex_; } + + const Acq_Conf acq_parameters_; + const unsigned int num_codes_; + const unsigned int code_length_; + const unsigned int vector_length_; + acquisition_impl_interface_sptr acquisition_cc_; + Gnss_Synchro* gnss_synchro_; + unsigned int channel_; + volk_gnsssdr::vector> code_; + +private: + virtual float calculate_threshold(float pfa) const; + + /*! + * \brief Generate code + */ + virtual void code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) = 0; + + gr::blocks::stream_to_vector::sptr stream_to_vector_; + const std::string role_; + const bool is_type_gr_complex_; + const size_t item_size_; + const bool use_stream_to_vector_; + const bool compute_threshold_from_pfa_; +}; + + +/** \} */ +/** \} */ +#endif // GNSS_SDR_BASE_PCPS_ACQUISITION_H diff --git a/src/algorithms/acquisition/adapters/base_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/base_pcps_acquisition_fpga.cc index 7d3dc6aec..2ed702de3 100644 --- a/src/algorithms/acquisition/adapters/base_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/base_pcps_acquisition_fpga.cc @@ -36,20 +36,13 @@ BasePcpsAcquisitionFpga::BasePcpsAcquisitionFpga( uint32_t acq_buff, unsigned int in_streams, unsigned int out_streams) - : doppler_center_(0), - doppler_max_(0), - doppler_step_(0), - role_(std::move(role)), - gnss_synchro_(nullptr), - channel_(0), - in_streams_(in_streams), - out_streams_(out_streams) + : role_(std::move(role)) { - if (in_streams_ > 1) + if (in_streams > 1) { LOG(ERROR) << "This implementation only supports one input stream"; } - if (out_streams_ > 0) + if (out_streams > 0) { LOG(ERROR) << "This implementation does not provide an output stream"; } @@ -90,14 +83,20 @@ BasePcpsAcquisitionFpga::BasePcpsAcquisitionFpga( { acq_parameters_.doppler_max = FLAGS_doppler_max; } + if (FLAGS_doppler_step != 0) + { + acq_parameters_.doppler_step = static_cast(FLAGS_doppler_step); + } #else if (absl::GetFlag(FLAGS_doppler_max) != 0) { acq_parameters_.doppler_max = absl::GetFlag(FLAGS_doppler_max); } + if (absl::GetFlag(FLAGS_doppler_step) != 0) + { + acq_parameters_.doppler_step = static_cast(absl::GetFlag(FLAGS_doppler_step)); + } #endif - doppler_max_ = acq_parameters_.doppler_max; - doppler_step_ = static_cast(acq_parameters_.doppler_step); } @@ -133,30 +132,27 @@ gr::basic_block_sptr BasePcpsAcquisitionFpga::get_right_block() void BasePcpsAcquisitionFpga::set_gnss_synchro(Gnss_Synchro* gnss_synchro) { - gnss_synchro_ = gnss_synchro; if (acquisition_fpga_) { - acquisition_fpga_->set_gnss_synchro(gnss_synchro_); + acquisition_fpga_->set_gnss_synchro(gnss_synchro); } } void BasePcpsAcquisitionFpga::set_channel(unsigned int channel) { - channel_ = channel; if (acquisition_fpga_) { - acquisition_fpga_->set_channel(channel_); + acquisition_fpga_->set_channel(channel); } } void BasePcpsAcquisitionFpga::set_channel_fsm(std::weak_ptr channel_fsm) { - channel_fsm_ = std::move(channel_fsm); if (acquisition_fpga_) { - acquisition_fpga_->set_channel_fsm(channel_fsm_); + acquisition_fpga_->set_channel_fsm(channel_fsm); } } @@ -170,41 +166,11 @@ void BasePcpsAcquisitionFpga::set_threshold(float threshold) } -void BasePcpsAcquisitionFpga::set_doppler_max(unsigned int doppler_max) -{ - doppler_max_ = doppler_max; - if (acquisition_fpga_) - { - acquisition_fpga_->set_doppler_max(doppler_max_); - } -} - - -void BasePcpsAcquisitionFpga::set_doppler_step(unsigned int doppler_step) -{ - doppler_step_ = doppler_step; - if (acquisition_fpga_) - { - acquisition_fpga_->set_doppler_step(doppler_step_); - } -} - - void BasePcpsAcquisitionFpga::set_doppler_center(int doppler_center) { - doppler_center_ = doppler_center; if (acquisition_fpga_) { - acquisition_fpga_->set_doppler_center(doppler_center_); - } -} - - -void BasePcpsAcquisitionFpga::set_state(int state) -{ - if (acquisition_fpga_) - { - acquisition_fpga_->set_state(state); + acquisition_fpga_->set_doppler_center(doppler_center); } } @@ -227,15 +193,6 @@ void BasePcpsAcquisitionFpga::stop_acquisition() } -void BasePcpsAcquisitionFpga::init() -{ - if (acquisition_fpga_) - { - acquisition_fpga_->init(); - } -} - - signed int BasePcpsAcquisitionFpga::mag() { if (acquisition_fpga_) diff --git a/src/algorithms/acquisition/adapters/base_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/base_pcps_acquisition_fpga.h index 10ee76b6f..bce56b11d 100644 --- a/src/algorithms/acquisition/adapters/base_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/base_pcps_acquisition_fpga.h @@ -28,7 +28,6 @@ #include #include #include -#include /** \addtogroup Acquisition * Classes for GNSS signal acquisition @@ -72,13 +71,9 @@ public: void set_channel(unsigned int channel) override; void set_channel_fsm(std::weak_ptr channel_fsm) override; void set_threshold(float threshold) override; - void set_doppler_max(unsigned int doppler_max) override; - void set_doppler_step(unsigned int doppler_step) override; void set_doppler_center(int doppler_center) override; - void set_state(int state) override; void reset() override; void stop_acquisition() override; - void init() override; void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override {} void set_local_code() override; @@ -93,21 +88,13 @@ protected: static const uint32_t ACQ_BUFF_1 = 1; // FPGA Acquisition IP buffer containing L2 or L5/E5 frequency band samples by default. // Members subclasses must set - pcps_acquisition_fpga_sptr acquisition_fpga_; volk_gnsssdr::vector d_all_fft_codes_; Acq_Conf_Fpga acq_parameters_; - int32_t doppler_center_; - uint32_t doppler_max_; - uint32_t doppler_step_; private: // Managed entirely by the base class - std::weak_ptr channel_fsm_; - std::string role_; - Gnss_Synchro* gnss_synchro_; - uint32_t channel_; - unsigned int in_streams_; - unsigned int out_streams_; + pcps_acquisition_fpga_sptr acquisition_fpga_; + const std::string role_; }; diff --git a/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.cc index a5d1e7e4e..225d0ca49 100644 --- a/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.cc @@ -26,7 +26,15 @@ BeidouB1iPcpsAcquisition::BeidouB1iPcpsAcquisition( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : BasePcpsAcquisition(configuration, role, in_streams, out_streams, BEIDOU_B1I_CODE_RATE_CPS, 10e6, BEIDOU_B1I_CODE_LENGTH_CHIPS, 1) + unsigned int out_streams) + : BasePcpsAcquisition(configuration, + role, + in_streams, + out_streams, + BEIDOU_B1I_CODE_RATE_CPS, + BEIDOU_B1I_OPT_ACQ_FS_SPS, + BEIDOU_B1I_CODE_LENGTH_CHIPS, + BEIDOU_B1I_CODE_PERIOD_MS) { } diff --git a/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h b/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h index ac04886bb..d4ca54c1d 100644 --- a/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h @@ -27,9 +27,6 @@ /** \addtogroup Acq_adapters * \{ */ - -class ConfigurationInterface; - /*! * \brief This class adapts a PCPS acquisition block to an AcquisitionInterface * for GPS L1 C/A signals diff --git a/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.cc index 36f447072..1bbf18787 100644 --- a/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.cc @@ -24,7 +24,15 @@ BeidouB3iPcpsAcquisition::BeidouB3iPcpsAcquisition( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : BasePcpsAcquisition(configuration, role, in_streams, out_streams, BEIDOU_B3I_CODE_RATE_CPS, 100e6, BEIDOU_B3I_CODE_LENGTH_CHIPS, 1) + unsigned int out_streams) + : BasePcpsAcquisition(configuration, + role, + in_streams, + out_streams, + BEIDOU_B3I_CODE_RATE_CPS, + BEIDOU_B3I_OPT_ACQ_FS_SPS, + BEIDOU_B3I_CODE_LENGTH_CHIPS, + BEIDOU_B3I_CODE_PERIOD_MS) { } diff --git a/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.h b/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.h index 30da657e5..07217799f 100644 --- a/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.h @@ -25,9 +25,6 @@ /** \addtogroup Acq_adapters * \{ */ - -class ConfigurationInterface; - /*! * \brief This class adapts a PCPS acquisition block to an AcquisitionInterface * for BeiDou B3I signals diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.cc index 21386f58d..fcd2d006f 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.cc @@ -17,11 +17,9 @@ #include "galileo_e1_pcps_8ms_ambiguous_acquisition.h" #include "Galileo_E1.h" -#include "configuration_interface.h" #include "galileo_e1_signal_replica.h" -#include "gnss_sdr_flags.h" +#include "galileo_pcps_8ms_acquisition_cc.h" #include -#include #if USE_GLOG_AND_GFLAGS #include @@ -29,266 +27,38 @@ #include #endif -#if HAS_STD_SPAN -#include -namespace own = std; -#else -#include -namespace own = gsl_lite; -#endif GalileoE1Pcps8msAmbiguousAcquisition::GalileoE1Pcps8msAmbiguousAcquisition( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) - : configuration_(configuration), - gnss_synchro_(nullptr), - role_(role), - item_size_(sizeof(gr_complex)), - threshold_(0.0), - channel_(0), - doppler_max_(configuration_->property(role + ".doppler_max", 5000)), - doppler_step_(0), - sampled_ms_(configuration_->property(role + ".coherent_integration_time_ms", 4)), - max_dwells_(configuration_->property(role + ".max_dwells", 1)), - in_streams_(in_streams), - out_streams_(out_streams), - dump_(configuration_->property(role + ".dump", false)) + : BasePcpsAcquisitionCustom( + configuration, + role, + in_streams, + out_streams, + GALILEO_E1_CODE_CHIP_RATE_CPS, + GALILEO_E1_B_CODE_LENGTH_CHIPS, + GALILEO_E1_CODE_PERIOD_MS, + true, + true), + cboc_(configuration->property(role + ".cboc", false)) { - const std::string default_item_type("gr_complex"); - const std::string default_dump_filename("./acquisition.dat"); - item_type_ = configuration_->property(role_ + ".item_type", default_item_type); - int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 4000000); - fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - dump_filename_ = configuration_->property(role_ + ".dump_filename", default_dump_filename); - -#if USE_GLOG_AND_GFLAGS - if (FLAGS_doppler_max != 0) + if (is_type_gr_complex()) { - doppler_max_ = FLAGS_doppler_max; - } -#else - if (absl::GetFlag(FLAGS_doppler_max) != 0) - { - doppler_max_ = absl::GetFlag(FLAGS_doppler_max); - } -#endif - - if (sampled_ms_ % 4 != 0) - { - sampled_ms_ = static_cast(sampled_ms_ / 4) * 4; - LOG(WARNING) << "coherent_integration_time should be multiple of " - << "Galileo code length (4 ms). coherent_integration_time = " - << sampled_ms_ << " ms will be used."; - } - - // -- Find number of samples per spreading code (4 ms) ----------------- - code_length_ = static_cast(round( - fs_in_ / (GALILEO_E1_CODE_CHIP_RATE_CPS / GALILEO_E1_B_CODE_LENGTH_CHIPS))); - - vector_length_ = code_length_ * static_cast(sampled_ms_ / 4); - - auto samples_per_ms = static_cast(code_length_) / 4; - - code_ = std::vector>(vector_length_); - - bool enable_monitor_output = configuration->property("AcquisitionMonitor.enable_monitor", false); - - DLOG(INFO) << "role " << role_; - if (item_type_ == "gr_complex") - { - acquisition_cc_ = galileo_pcps_8ms_make_acquisition_cc(sampled_ms_, max_dwells_, - doppler_max_, fs_in_, samples_per_ms, code_length_, - dump_, dump_filename_, enable_monitor_output); - stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); - DLOG(INFO) << "stream_to_vector(" - << stream_to_vector_->unique_id() << ")"; - DLOG(INFO) << "acquisition(" << acquisition_cc_->unique_id() - << ")"; - } - else - { - item_size_ = 0; - acquisition_cc_ = nullptr; - stream_to_vector_ = nullptr; - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - } - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 0) - { - LOG(ERROR) << "This implementation does not provide an output stream"; + acquisition_cc_ = galileo_pcps_8ms_make_acquisition_cc(acq_parameters_); + DLOG(INFO) << "acquisition(" << acquisition_cc_->unique_id() << ")"; } } -void GalileoE1Pcps8msAmbiguousAcquisition::stop_acquisition() +void GalileoE1Pcps8msAmbiguousAcquisition::code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) { - acquisition_cc_->set_active(false); -} - - -void GalileoE1Pcps8msAmbiguousAcquisition::set_threshold(float threshold) -{ - float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", static_cast(0.0)); - - if (pfa == 0.0) - { - pfa = configuration_->property(role_ + ".pfa", static_cast(0.0)); - } - - if (pfa == 0.0) - { - threshold_ = threshold; - } - else - { - threshold_ = calculate_threshold(pfa); - } - - DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold_; - - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_threshold(threshold_); - } -} - - -void GalileoE1Pcps8msAmbiguousAcquisition::set_doppler_max(unsigned int doppler_max) -{ - doppler_max_ = doppler_max; - - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_doppler_max(doppler_max_); - } -} - - -void GalileoE1Pcps8msAmbiguousAcquisition::set_doppler_step(unsigned int doppler_step) -{ - doppler_step_ = doppler_step; - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_doppler_step(doppler_step_); - } -} - - -void GalileoE1Pcps8msAmbiguousAcquisition::set_gnss_synchro( - Gnss_Synchro* gnss_synchro) -{ - gnss_synchro_ = gnss_synchro; - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_gnss_synchro(gnss_synchro_); - } -} - - -signed int GalileoE1Pcps8msAmbiguousAcquisition::mag() -{ - if (item_type_ == "gr_complex") - { - return acquisition_cc_->mag(); - } - return 0; -} - - -void GalileoE1Pcps8msAmbiguousAcquisition::init() -{ - acquisition_cc_->init(); -} - - -void GalileoE1Pcps8msAmbiguousAcquisition::set_local_code() -{ - if (item_type_ == "gr_complex") - { - bool cboc = configuration_->property( - "Acquisition" + std::to_string(channel_) + ".cboc", false); - - std::vector> code(code_length_); - std::array Signal_{}; - Signal_[0] = gnss_synchro_->Signal[0]; - Signal_[1] = gnss_synchro_->Signal[1]; - Signal_[2] = '\0'; - - galileo_e1_code_gen_complex_sampled(code, Signal_, - cboc, gnss_synchro_->PRN, fs_in_, 0, false); - - own::span code_span(code_.data(), vector_length_); - for (unsigned int i = 0; i < sampled_ms_ / 4; i++) - { - std::copy_n(code.data(), code_length_, code_span.subspan(i * code_length_, code_length_).data()); - } - - acquisition_cc_->set_local_code(code_.data()); - } -} - - -void GalileoE1Pcps8msAmbiguousAcquisition::reset() -{ - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_active(true); - } -} - - -float GalileoE1Pcps8msAmbiguousAcquisition::calculate_threshold(float pfa) const -{ - unsigned int frequency_bins = 0; - for (int doppler = static_cast(-doppler_max_); doppler <= static_cast(doppler_max_); doppler += static_cast(doppler_step_)) - { - frequency_bins++; - } - - DLOG(INFO) << "Channel " << channel_ << " Pfa = " << pfa; - - unsigned int ncells = vector_length_ * frequency_bins; - double exponent = 1 / static_cast(ncells); - double val = pow(1.0 - pfa, exponent); - auto lambda = static_cast(vector_length_); - boost::math::exponential_distribution mydist(lambda); - auto threshold = static_cast(quantile(mydist, val)); - - return threshold; -} - - -void GalileoE1Pcps8msAmbiguousAcquisition::connect(gr::top_block_sptr top_block) -{ - if (item_type_ == "gr_complex") - { - top_block->connect(stream_to_vector_, 0, acquisition_cc_, 0); - } -} - - -void GalileoE1Pcps8msAmbiguousAcquisition::disconnect(gr::top_block_sptr top_block) -{ - if (item_type_ == "gr_complex") - { - top_block->disconnect(stream_to_vector_, 0, acquisition_cc_, 0); - } -} - - -gr::basic_block_sptr GalileoE1Pcps8msAmbiguousAcquisition::get_left_block() -{ - return stream_to_vector_; -} - - -gr::basic_block_sptr GalileoE1Pcps8msAmbiguousAcquisition::get_right_block() -{ - return acquisition_cc_; + std::array Signal_{}; + Signal_[0] = gnss_synchro_->Signal[0]; + Signal_[1] = gnss_synchro_->Signal[1]; + Signal_[2] = '\0'; + + galileo_e1_code_gen_complex_sampled(dest, Signal_, cboc_, prn, sampling_freq, 0, false); } diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.h index 9e29e67a8..4b968b4f3 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.h @@ -18,28 +18,18 @@ #ifndef GNSS_SDR_GALILEO_E1_PCPS_8MS_AMBIGUOUS_ACQUISITION_H #define GNSS_SDR_GALILEO_E1_PCPS_8MS_AMBIGUOUS_ACQUISITION_H -#include "acquisition_interface.h" -#include "galileo_pcps_8ms_acquisition_cc.h" -#include "gnss_synchro.h" -#include -#include -#include -#include -#include +#include "base_pcps_acquisition_custom.h" /** \addtogroup Acquisition * \{ */ /** \addtogroup Acq_adapters * \{ */ - -class ConfigurationInterface; - /*! * \brief Adapts a PCPS 8ms acquisition block to an * AcquisitionInterface for Galileo E1 Signals */ -class GalileoE1Pcps8msAmbiguousAcquisition : public AcquisitionInterface +class GalileoE1Pcps8msAmbiguousAcquisition : public BasePcpsAcquisitionCustom { public: GalileoE1Pcps8msAmbiguousAcquisition(const ConfigurationInterface* configuration, @@ -49,11 +39,6 @@ public: ~GalileoE1Pcps8msAmbiguousAcquisition() = default; - inline std::string role() override - { - return role_; - } - /*! * \brief Returns "Galileo_E1_PCPS_8ms_Ambiguous_Acquisition" */ @@ -62,111 +47,10 @@ public: return "Galileo_E1_PCPS_8ms_Ambiguous_Acquisition"; } - inline size_t item_size() override - { - return item_size_; - } - - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and - * tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - - /*! - * \brief Set acquisition channel unique ID - */ - inline void set_channel(unsigned int channel) override - { - channel_ = channel; - acquisition_cc_->set_channel(channel_); - } - - /*! - * \brief Set channel fsm associated to this acquisition instance - */ - inline void set_channel_fsm(std::weak_ptr channel_fsm) override - { - channel_fsm_ = std::move(channel_fsm); - acquisition_cc_->set_channel_fsm(channel_fsm_); - } - - /*! - * \brief Set statistics threshold of PCPS algorithm - */ - void set_threshold(float threshold) override; - - /*! - * \brief Set maximum Doppler off grid search - */ - void set_doppler_max(unsigned int doppler_max) override; - - /*! - * \brief Set Doppler steps for the grid search - */ - void set_doppler_step(unsigned int doppler_step) override; - - /*! - * \brief Initializes acquisition algorithm. - */ - void init() override; - - /*! - * \brief Sets local code for Galileo E1 PCPS acquisition algorithm. - */ - void set_local_code() override; - - /*! - * \brief Returns the maximum peak of grid search - */ - signed int mag() override; - - /*! - * \brief Restart acquisition algorithm - */ - void reset() override; - - /*! - * \brief Stop running acquisition - */ - void stop_acquisition() override; - - void set_state(int state __attribute__((unused))) override {}; - - void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override {}; - - private: - float calculate_threshold(float pfa) const; + void code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) override; - const ConfigurationInterface* configuration_; - galileo_pcps_8ms_acquisition_cc_sptr acquisition_cc_; - gr::blocks::stream_to_vector::sptr stream_to_vector_; - std::weak_ptr channel_fsm_; - std::vector> code_; - Gnss_Synchro* gnss_synchro_; - std::string item_type_; - std::string dump_filename_; - std::string role_; - int64_t fs_in_; - size_t item_size_; - float threshold_; - unsigned int vector_length_; - unsigned int code_length_; - unsigned int channel_; - unsigned int doppler_max_; - unsigned int doppler_step_; - unsigned int sampled_ms_; - unsigned int max_dwells_; - unsigned int in_streams_; - unsigned int out_streams_; - bool dump_; + const bool cboc_; }; diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc index 0b25d04a4..5281e33a6 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc @@ -17,168 +17,43 @@ #include "galileo_e1_pcps_ambiguous_acquisition.h" #include "Galileo_E1.h" -#include "acq_conf.h" -#include "configuration_interface.h" #include "galileo_e1_signal_replica.h" -#include "gnss_sdr_flags.h" -#include -#include -#if USE_GLOG_AND_GFLAGS -#include -#else -#include -#endif - -#if HAS_STD_SPAN -#include -namespace own = std; -#else -#include -namespace own = gsl_lite; -#endif GalileoE1PcpsAmbiguousAcquisition::GalileoE1PcpsAmbiguousAcquisition( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) - : gnss_synchro_(nullptr), - configuration_(configuration), - role_(role), - threshold_(0.0), - doppler_center_(0), - channel_(0), - in_streams_(in_streams), - out_streams_(out_streams), - acquire_pilot_(configuration->property(role + ".acquire_pilot", false)) + : BasePcpsAcquisition(configuration, + role, + in_streams, + out_streams, + GALILEO_E1_CODE_CHIP_RATE_CPS, + GALILEO_E1_OPT_ACQ_FS_SPS, + GALILEO_E1_B_CODE_LENGTH_CHIPS, + GALILEO_E1_CODE_PERIOD_MS), + acquire_pilot_(configuration->property(role + ".acquire_pilot", false)), + cboc_(configuration->property(role + ".cboc", false)), + gnss_synchro_(nullptr) { - acq_parameters_.ms_per_code = 4; - acq_parameters_.SetFromConfiguration(configuration_, role_, GALILEO_E1_CODE_CHIP_RATE_CPS, GALILEO_E1_OPT_ACQ_FS_SPS); - -#if USE_GLOG_AND_GFLAGS - if (FLAGS_doppler_max != 0) - { - acq_parameters_.doppler_max = FLAGS_doppler_max; - } -#else - if (absl::GetFlag(FLAGS_doppler_max) != 0) - { - acq_parameters_.doppler_max = absl::GetFlag(FLAGS_doppler_max); - } -#endif - doppler_max_ = acq_parameters_.doppler_max; - doppler_step_ = static_cast(acq_parameters_.doppler_step); - item_type_ = acq_parameters_.item_type; - item_size_ = acq_parameters_.it_size; - fs_in_ = acq_parameters_.fs_in; - - code_length_ = static_cast(std::floor(static_cast(acq_parameters_.resampled_fs) / (GALILEO_E1_CODE_CHIP_RATE_CPS / GALILEO_E1_B_CODE_LENGTH_CHIPS))); - vector_length_ = static_cast(std::floor(acq_parameters_.sampled_ms * acq_parameters_.samples_per_ms) * (acq_parameters_.bit_transition_flag ? 2.0 : 1.0)); - code_ = volk_gnsssdr::vector>(vector_length_); - - sampled_ms_ = acq_parameters_.sampled_ms; - - DLOG(INFO) << "role " << role_; - acquisition_ = pcps_make_acquisition(acq_parameters_); - DLOG(INFO) << "acquisition(" << acquisition_->unique_id() << ")"; - - if (item_type_ == "cbyte") - { - cbyte_to_float_x2_ = make_complex_byte_to_float_x2(); - float_to_complex_ = gr::blocks::float_to_complex::make(); - } - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 0) - { - LOG(ERROR) << "This implementation does not provide an output stream"; - } } -void GalileoE1PcpsAmbiguousAcquisition::stop_acquisition() +void GalileoE1PcpsAmbiguousAcquisition::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) { - acquisition_->set_active(false); + gnss_synchro_ = p_gnss_synchro; + BasePcpsAcquisition::set_gnss_synchro(p_gnss_synchro); } -void GalileoE1PcpsAmbiguousAcquisition::set_threshold(float threshold) +void GalileoE1PcpsAmbiguousAcquisition::code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) { - threshold_ = threshold; - - acquisition_->set_threshold(threshold_); -} - - -void GalileoE1PcpsAmbiguousAcquisition::set_doppler_max(unsigned int doppler_max) -{ - doppler_max_ = doppler_max; - - acquisition_->set_doppler_max(doppler_max_); -} - - -void GalileoE1PcpsAmbiguousAcquisition::set_doppler_step(unsigned int doppler_step) -{ - doppler_step_ = doppler_step; - - acquisition_->set_doppler_step(doppler_step_); -} - - -void GalileoE1PcpsAmbiguousAcquisition::set_doppler_center(int doppler_center) -{ - doppler_center_ = doppler_center; - - acquisition_->set_doppler_center(doppler_center_); -} - - -void GalileoE1PcpsAmbiguousAcquisition::set_gnss_synchro(Gnss_Synchro* gnss_synchro) -{ - gnss_synchro_ = gnss_synchro; - - acquisition_->set_gnss_synchro(gnss_synchro_); -} - - -signed int GalileoE1PcpsAmbiguousAcquisition::mag() -{ - return acquisition_->mag(); -} - - -void GalileoE1PcpsAmbiguousAcquisition::init() -{ - acquisition_->init(); -} - - -void GalileoE1PcpsAmbiguousAcquisition::set_local_code() -{ - bool cboc = configuration_->property( - "Acquisition" + std::to_string(channel_) + ".cboc", false); - - volk_gnsssdr::vector> code(code_length_); - if (acquire_pilot_ == true) { // set local signal generator to Galileo E1 pilot component (1C) - std::array pilot_signal = {{'1', 'C', '\0'}}; - if (acq_parameters_.use_automatic_resampler) - { - galileo_e1_code_gen_complex_sampled(code, pilot_signal, - cboc, gnss_synchro_->PRN, acq_parameters_.resampled_fs, 0, false); - } - else - { - galileo_e1_code_gen_complex_sampled(code, pilot_signal, - cboc, gnss_synchro_->PRN, fs_in_, 0, false); - } + const std::array pilot_signal = {{'1', 'C', '\0'}}; + galileo_e1_code_gen_complex_sampled(dest, pilot_signal, cboc_, prn, sampling_freq, 0, false); } else { @@ -186,103 +61,6 @@ void GalileoE1PcpsAmbiguousAcquisition::set_local_code() Signal_[0] = gnss_synchro_->Signal[0]; Signal_[1] = gnss_synchro_->Signal[1]; Signal_[2] = '\0'; - if (acq_parameters_.use_automatic_resampler) - { - galileo_e1_code_gen_complex_sampled(code, Signal_, - cboc, gnss_synchro_->PRN, acq_parameters_.resampled_fs, 0, false); - } - else - { - galileo_e1_code_gen_complex_sampled(code, Signal_, - cboc, gnss_synchro_->PRN, fs_in_, 0, false); - } - } - - own::span code_span(code_.data(), vector_length_); - for (unsigned int i = 0; i < sampled_ms_ / 4; i++) - { - std::copy_n(code.data(), code_length_, code_span.subspan(i * code_length_, code_length_).data()); - } - - acquisition_->set_local_code(code_.data()); -} - - -void GalileoE1PcpsAmbiguousAcquisition::reset() -{ - acquisition_->set_active(true); -} - - -void GalileoE1PcpsAmbiguousAcquisition::set_state(int state) -{ - acquisition_->set_state(state); -} - - -void GalileoE1PcpsAmbiguousAcquisition::connect(gr::top_block_sptr top_block) -{ - if (item_type_ == "gr_complex" || item_type_ == "cshort") - { - // nothing to connect - } - else if (item_type_ == "cbyte") - { - // Since a byte-based acq implementation is not available, - // we just convert cshorts to gr_complex - top_block->connect(cbyte_to_float_x2_, 0, float_to_complex_, 0); - top_block->connect(cbyte_to_float_x2_, 1, float_to_complex_, 1); - top_block->connect(float_to_complex_, 0, acquisition_, 0); - } - else - { - LOG(WARNING) << item_type_ << " unknown acquisition item type"; + galileo_e1_code_gen_complex_sampled(dest, Signal_, cboc_, prn, sampling_freq, 0, false); } } - - -void GalileoE1PcpsAmbiguousAcquisition::disconnect(gr::top_block_sptr top_block) -{ - if (item_type_ == "gr_complex" || item_type_ == "cshort") - { - // nothing to disconnect - } - else if (item_type_ == "cbyte") - { - top_block->disconnect(cbyte_to_float_x2_, 0, float_to_complex_, 0); - top_block->disconnect(cbyte_to_float_x2_, 1, float_to_complex_, 1); - top_block->disconnect(float_to_complex_, 0, acquisition_, 0); - } - else - { - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - } -} - - -gr::basic_block_sptr GalileoE1PcpsAmbiguousAcquisition::get_left_block() -{ - if (item_type_ == "gr_complex" || item_type_ == "cshort") - { - return acquisition_; - } - if (item_type_ == "cbyte") - { - return cbyte_to_float_x2_; - } - - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - return nullptr; -} - - -gr::basic_block_sptr GalileoE1PcpsAmbiguousAcquisition::get_right_block() -{ - return acquisition_; -} - - -void GalileoE1PcpsAmbiguousAcquisition::set_resampler_latency(uint32_t latency_samples) -{ - acquisition_->set_resampler_latency(latency_samples); -} diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.h index aea4c2d99..ec0c96dfa 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.h @@ -18,16 +18,7 @@ #ifndef GNSS_SDR_GALILEO_E1_PCPS_AMBIGUOUS_ACQUISITION_H #define GNSS_SDR_GALILEO_E1_PCPS_AMBIGUOUS_ACQUISITION_H -#include "acq_conf.h" -#include "channel_fsm.h" -#include "complex_byte_to_float_x2.h" -#include "gnss_synchro.h" -#include "pcps_acquisition.h" -#include -#include -#include -#include -#include +#include "base_pcps_acquisition.h" /** \addtogroup Acquisition * \{ */ @@ -35,13 +26,11 @@ * \{ */ -class ConfigurationInterface; - /*! * \brief This class adapts a PCPS acquisition block to an * AcquisitionInterface for Galileo E1 Signals */ -class GalileoE1PcpsAmbiguousAcquisition : public AcquisitionInterface +class GalileoE1PcpsAmbiguousAcquisition : public BasePcpsAcquisition { public: GalileoE1PcpsAmbiguousAcquisition( @@ -52,11 +41,6 @@ public: ~GalileoE1PcpsAmbiguousAcquisition() = default; - inline std::string role() override - { - return role_; - } - /*! * \brief Returns "Galileo_E1_PCPS_Ambiguous_Acquisition" */ @@ -65,121 +49,17 @@ public: return "Galileo_E1_PCPS_Ambiguous_Acquisition"; } - size_t item_size() override - { - return item_size_; - } - - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and - * tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - /*! * \brief Set acquisition channel unique ID */ - inline void set_channel(unsigned int channel) override - { - channel_ = channel; - acquisition_->set_channel(channel_); - } - - /*! - * \brief Set channel fsm associated to this acquisition instance - */ - inline void set_channel_fsm(std::weak_ptr channel_fsm) override - { - channel_fsm_ = std::move(channel_fsm); - acquisition_->set_channel_fsm(channel_fsm_); - } - - /*! - * \brief Set statistics threshold of PCPS algorithm - */ - void set_threshold(float threshold) override; - - /*! - * \brief Set maximum Doppler off grid search - */ - void set_doppler_max(unsigned int doppler_max) override; - - /*! - * \brief Set Doppler steps for the grid search - */ - void set_doppler_step(unsigned int doppler_step) override; - - /*! - * \brief Set Doppler center for the grid search - */ - void set_doppler_center(int doppler_center) override; - - /*! - * \brief Initializes acquisition algorithm. - */ - void init() override; - - /*! - * \brief Sets local code for Galileo E1 PCPS acquisition algorithm. - */ - void set_local_code() override; - - /*! - * \brief Returns the maximum peak of grid search - */ - signed int mag() override; - - /*! - * \brief Restart acquisition algorithm - */ - void reset() override; - - /*! - * \brief If state = 1, it forces the block to start acquiring from the first sample - */ - void set_state(int state) override; - - /*! - * \brief Stop running acquisition - */ - void stop_acquisition() override; - - /*! - * \brief Sets the resampler latency to account it in the acquisition code delay estimation - */ - void set_resampler_latency(uint32_t latency_samples) override; + void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; private: - pcps_acquisition_sptr acquisition_; - volk_gnsssdr::vector> code_; - std::weak_ptr channel_fsm_; - gr::blocks::float_to_complex::sptr float_to_complex_; - complex_byte_to_float_x2_sptr cbyte_to_float_x2_; + void code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) override; + + const bool acquire_pilot_; + const bool cboc_; Gnss_Synchro* gnss_synchro_; - const ConfigurationInterface* configuration_; - Acq_Conf acq_parameters_; - std::string item_type_; - std::string dump_filename_; - std::string role_; - int64_t fs_in_; - size_t item_size_; - float threshold_; - int doppler_center_; - unsigned int vector_length_; - unsigned int code_length_; - unsigned int channel_; - unsigned int doppler_max_; - unsigned int doppler_step_; - unsigned int sampled_ms_; - unsigned int in_streams_; - unsigned int out_streams_; - bool acquire_pilot_; }; diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc index 831dcae06..8bee77a18 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc @@ -48,9 +48,9 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( DEFAULT_FPGA_BLK_EXP, ACQ_BUFF_0, in_streams, - out_streams) + out_streams), + acquire_pilot_(configuration->property(role + ".acquire_pilot", false)) { - acquire_pilot_ = configuration->property(role + ".acquire_pilot", false); generate_galileo_e1_prn_codes(); DLOG(INFO) << "Initialized FPGA acquisition adapter for role " << role; } diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h index 2fb1e5bd3..70548f8fb 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h @@ -26,8 +26,6 @@ * \{ */ -class ConfigurationInterface; - /*! * \brief This class adapts a PCPS acquisition block off-loaded on an FPGA * to an AcquisitionInterface for Galileo E1 Signals @@ -55,7 +53,7 @@ public: private: static const uint32_t DEFAULT_FPGA_BLK_EXP = 13; // default block exponent void generate_galileo_e1_prn_codes(); - bool acquire_pilot_; + const bool acquire_pilot_; }; diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.cc index dab9dcc47..fd28befca 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.cc @@ -19,7 +19,7 @@ #include "Galileo_E1.h" #include "configuration_interface.h" #include "galileo_e1_signal_replica.h" -#include "gnss_sdr_flags.h" +#include "pcps_cccwsr_acquisition_cc.h" #include #if USE_GLOG_AND_GFLAGS @@ -33,229 +33,39 @@ GalileoE1PcpsCccwsrAmbiguousAcquisition::GalileoE1PcpsCccwsrAmbiguousAcquisition const std::string& role, unsigned int in_streams, unsigned int out_streams) - : configuration_(configuration), - role_(role), - gnss_synchro_(nullptr), - item_size_(sizeof(gr_complex)), - threshold_(0.0), - channel_(0), - doppler_max_(configuration_->property(role + ".doppler_max", 5000)), - doppler_step_(0), - sampled_ms_(configuration_->property(role + ".coherent_integration_time_ms", 4)), - max_dwells_(configuration_->property(role + ".max_dwells", 1)), - in_streams_(in_streams), - out_streams_(out_streams), - dump_(configuration_->property(role + ".dump", false)) + : BasePcpsAcquisitionCustom( + configuration, + role, + in_streams, + out_streams, + GALILEO_E1_CODE_CHIP_RATE_CPS, + GALILEO_E1_B_CODE_LENGTH_CHIPS, + GALILEO_E1_CODE_PERIOD_MS, + true, + false), + code_pilot_(vector_length_), + cboc_(configuration->property(role + ".cboc", false)) { - const std::string default_item_type("gr_complex"); - const std::string default_dump_filename("./acquisition.dat"); - item_type_ = configuration_->property(role_ + ".item_type", default_item_type); - int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 4000000); - fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - dump_filename_ = configuration_->property(role_ + ".dump_filename", default_dump_filename); - -#if USE_GLOG_AND_GFLAGS - if (FLAGS_doppler_max != 0) + if (is_type_gr_complex()) { - doppler_max_ = FLAGS_doppler_max; + acquisition_cc_ = pcps_cccwsr_make_acquisition_cc(acq_parameters_); + DLOG(INFO) << "acquisition(" << acquisition_cc_->unique_id() << ")"; } -#else - if (absl::GetFlag(FLAGS_doppler_max) != 0) - { - doppler_max_ = absl::GetFlag(FLAGS_doppler_max); - } -#endif - - if (sampled_ms_ % 4 != 0) - { - sampled_ms_ = static_cast(sampled_ms_ / 4) * 4; - LOG(WARNING) << "coherent_integration_time should be multiple of " - << "Galileo code length (4 ms). coherent_integration_time = " - << sampled_ms_ << " ms will be used."; - } - - // -- Find number of samples per spreading code (4 ms) ----------------- - code_length_ = static_cast(round( - fs_in_ / (GALILEO_E1_CODE_CHIP_RATE_CPS / GALILEO_E1_B_CODE_LENGTH_CHIPS))); - - vector_length_ = code_length_ * static_cast(sampled_ms_ / 4); - - auto samples_per_ms = static_cast(code_length_) / 4; - - code_data_ = std::vector>(vector_length_); - code_pilot_ = std::vector>(vector_length_); - - bool enable_monitor_output = configuration_->property("AcquisitionMonitor.enable_monitor", false); - - DLOG(INFO) << "role " << role_; - if (item_type_ == "gr_complex") - { - acquisition_cc_ = pcps_cccwsr_make_acquisition_cc(sampled_ms_, max_dwells_, - doppler_max_, fs_in_, samples_per_ms, code_length_, - dump_, dump_filename_, enable_monitor_output); - stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); - DLOG(INFO) << "stream_to_vector(" - << stream_to_vector_->unique_id() << ")"; - DLOG(INFO) << "acquisition(" << acquisition_cc_->unique_id() - << ")"; - } - else - { - item_size_ = 0; - acquisition_cc_ = nullptr; - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - } - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 0) - { - LOG(ERROR) << "This implementation does not provide an output stream"; - } -} - - -void GalileoE1PcpsCccwsrAmbiguousAcquisition::stop_acquisition() -{ - acquisition_cc_->set_state(0); - acquisition_cc_->set_active(false); -} - - -void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_threshold(float threshold) -{ - threshold_ = threshold; - - DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold_; - - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_threshold(threshold_); - } -} - - -void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_doppler_max(unsigned int doppler_max) -{ - doppler_max_ = doppler_max; - - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_doppler_max(doppler_max_); - } -} - - -void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_doppler_step(unsigned int doppler_step) -{ - doppler_step_ = doppler_step; - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_doppler_step(doppler_step_); - } -} - - -void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_gnss_synchro( - Gnss_Synchro* gnss_synchro) -{ - gnss_synchro_ = gnss_synchro; - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_gnss_synchro(gnss_synchro_); - } -} - - -signed int GalileoE1PcpsCccwsrAmbiguousAcquisition::mag() -{ - if (item_type_ == "gr_complex") - { - return acquisition_cc_->mag(); - } - return 0; -} - - -void GalileoE1PcpsCccwsrAmbiguousAcquisition::init() -{ - acquisition_cc_->init(); } void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_local_code() { - if (item_type_ == "gr_complex") + if (is_type_gr_complex()) { - bool cboc = configuration_->property( - "Acquisition" + std::to_string(channel_) + ".cboc", false); + auto& code_data_ = code_; std::array signal = {{'1', 'B', '\0'}}; - - galileo_e1_code_gen_complex_sampled(code_data_, signal, - cboc, gnss_synchro_->PRN, fs_in_, 0, false); + galileo_e1_code_gen_complex_sampled(code_data_, signal, cboc_, gnss_synchro_->PRN, acq_parameters_.fs_in, 0, false); std::array signal_C = {{'1', 'C', '\0'}}; - - galileo_e1_code_gen_complex_sampled(code_pilot_, signal_C, - cboc, gnss_synchro_->PRN, fs_in_, 0, false); + galileo_e1_code_gen_complex_sampled(code_pilot_, signal_C, cboc_, gnss_synchro_->PRN, acq_parameters_.fs_in, 0, false); acquisition_cc_->set_local_code(code_data_.data(), code_pilot_.data()); } } - - -void GalileoE1PcpsCccwsrAmbiguousAcquisition::reset() -{ - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_active(true); - } -} - - -void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_state(int state) -{ - acquisition_cc_->set_state(state); -} - - -float GalileoE1PcpsCccwsrAmbiguousAcquisition::calculate_threshold(float pfa) -{ - if (pfa > 0.0) - { /* Not implemented*/ - }; - return 0.0; -} - - -void GalileoE1PcpsCccwsrAmbiguousAcquisition::connect(gr::top_block_sptr top_block) -{ - if (item_type_ == "gr_complex") - { - top_block->connect(stream_to_vector_, 0, acquisition_cc_, 0); - } -} - - -void GalileoE1PcpsCccwsrAmbiguousAcquisition::disconnect(gr::top_block_sptr top_block) -{ - if (item_type_ == "gr_complex") - { - top_block->disconnect(stream_to_vector_, 0, acquisition_cc_, 0); - } -} - - -gr::basic_block_sptr GalileoE1PcpsCccwsrAmbiguousAcquisition::get_left_block() -{ - return stream_to_vector_; -} - - -gr::basic_block_sptr GalileoE1PcpsCccwsrAmbiguousAcquisition::get_right_block() -{ - return acquisition_cc_; -} diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.h index bcda0172f..e4b7cdc17 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.h @@ -18,28 +18,18 @@ #ifndef GNSS_SDR_GALILEO_E1_PCPS_CCCWSR_AMBIGUOUS_ACQUISITION_H #define GNSS_SDR_GALILEO_E1_PCPS_CCCWSR_AMBIGUOUS_ACQUISITION_H -#include "channel_fsm.h" -#include "gnss_synchro.h" -#include "pcps_cccwsr_acquisition_cc.h" -#include -#include -#include -#include -#include +#include "base_pcps_acquisition_custom.h" /** \addtogroup Acquisition * \{ */ /** \addtogroup Acq_adapters * \{ */ - -class ConfigurationInterface; - /*! * \brief Adapts a PCPS CCCWSR acquisition block to an AcquisitionInterface * for Galileo E1 Signals */ -class GalileoE1PcpsCccwsrAmbiguousAcquisition : public AcquisitionInterface +class GalileoE1PcpsCccwsrAmbiguousAcquisition : public BasePcpsAcquisitionCustom { public: GalileoE1PcpsCccwsrAmbiguousAcquisition( @@ -50,11 +40,6 @@ public: ~GalileoE1PcpsCccwsrAmbiguousAcquisition() = default; - inline std::string role() override - { - return role_; - } - /*! * \brief Returns "Galileo_E1_PCPS_CCCWSR_Ambiguous_Acquisition" */ @@ -63,111 +48,14 @@ public: return "Galileo_E1_PCPS_CCCWSR_Ambiguous_Acquisition"; } - inline size_t item_size() override - { - return item_size_; - } - - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and - * tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - - /*! - * \brief Set acquisition channel unique ID - */ - inline void set_channel(unsigned int channel) override - { - channel_ = channel; - acquisition_cc_->set_channel(channel_); - } - - /*! - * \brief Set channel fsm associated to this acquisition instance - */ - inline void set_channel_fsm(std::weak_ptr channel_fsm) override - { - channel_fsm_ = std::move(channel_fsm); - acquisition_cc_->set_channel_fsm(channel_fsm_); - } - - /*! - * \brief Set statistics threshold of CCCWSR algorithm - */ - void set_threshold(float threshold) override; - - /*! - * \brief Set maximum Doppler off grid search - */ - void set_doppler_max(unsigned int doppler_max) override; - - /*! - * \brief Set Doppler steps for the grid search - */ - void set_doppler_step(unsigned int doppler_step) override; - - /*! - * \brief Initializes acquisition algorithm. - */ - void init() override; - void set_local_code() override; - /*! - * \brief Returns the maximum peak of grid search - */ - signed int mag() override; - - /*! - * \brief Restart acquisition algorithm - */ - void reset() override; - - /*! - * \brief If state = 1, it forces the block to start acquiring from the first sample - */ - void set_state(int state) override; - - /*! - * \brief Stop running acquisition - */ - void stop_acquisition() override; - - void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override {}; - private: - float calculate_threshold(float pfa); + // We don't implement this function since we override set_local_code + void code_gen_complex_sampled(own::span> /*dest*/, uint32_t /*prn*/, int32_t /*sampling_freq*/) override {} - const ConfigurationInterface* configuration_; - pcps_cccwsr_acquisition_cc_sptr acquisition_cc_; - gr::blocks::stream_to_vector::sptr stream_to_vector_; - std::weak_ptr channel_fsm_; - std::vector> code_data_; std::vector> code_pilot_; - std::string item_type_; - std::string dump_filename_; - std::string role_; - Gnss_Synchro* gnss_synchro_; - int64_t fs_in_; - size_t item_size_; - float threshold_; - unsigned int vector_length_; - unsigned int code_length_; - unsigned int channel_; - unsigned int doppler_max_; - unsigned int doppler_step_; - unsigned int sampled_ms_; - unsigned int max_dwells_; - unsigned int in_streams_; - unsigned int out_streams_; - bool dump_; + const bool cboc_; }; diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.cc index 8ea6f7c0e..d9b90ce8b 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.cc @@ -19,9 +19,8 @@ #include "Galileo_E1.h" #include "configuration_interface.h" #include "galileo_e1_signal_replica.h" -#include "gnss_sdr_flags.h" +#include "pcps_quicksync_acquisition_cc.h" #include -#include #if USE_GLOG_AND_GFLAGS #include @@ -29,269 +28,66 @@ #include #endif -#if HAS_STD_SPAN -#include -namespace own = std; -#else -#include -namespace own = gsl_lite; -#endif +namespace +{ +uint32_t get_folding_factor(const ConfigurationInterface* configuration, const std::string& role) +{ + /* Calculate the folding factor value based on the formula described in the paper. + This may be a bug, but acquisition also work by variying the folding factor at va- + lues different that the expressed in the paper. In addition, it is important to point + out that by making the folding factor smaller we were able to get QuickSync work with + Galileo. Future work should be directed to test this assumption statistically. */ + + // return static_cast(ceil(sqrt(log2(code_length_)))); + return configuration->property(role + ".folding_factor", 2); +} +} // namespace GalileoE1PcpsQuickSyncAmbiguousAcquisition::GalileoE1PcpsQuickSyncAmbiguousAcquisition( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) - : configuration_(configuration), - role_(role), - gnss_synchro_(nullptr), - item_size_(sizeof(gr_complex)), - threshold_(0.0), - channel_(0), - doppler_max_(configuration_->property(role + ".doppler_max", 5000)), - doppler_step_(0), - sampled_ms_(configuration_->property(role + ".coherent_integration_time_ms", 8)), - in_streams_(in_streams), - out_streams_(out_streams), - bit_transition_flag_(configuration_->property(role + ".bit_transition_flag", false)), - dump_(configuration_->property(role + ".dump", false)) + : BasePcpsAcquisitionCustom( + configuration, + role, + in_streams, + out_streams, + GALILEO_E1_CODE_CHIP_RATE_CPS, + GALILEO_E1_B_CODE_LENGTH_CHIPS, + GALILEO_E1_CODE_PERIOD_MS * get_folding_factor(configuration, role), + true, + true), + folding_factor_(get_folding_factor(configuration, role)), + cboc_(configuration->property(role + ".cboc", false)) { - const std::string default_item_type("gr_complex"); - const std::string default_dump_filename("./acquisition.dat"); - item_type_ = configuration_->property(role + ".item_type", default_item_type); - int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 4000000); - fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - dump_filename_ = configuration_->property(role + ".dump_filename", default_dump_filename); - -#if USE_GLOG_AND_GFLAGS - if (FLAGS_doppler_max != 0) + if (is_type_gr_complex()) { - doppler_max_ = FLAGS_doppler_max; - } -#else - if (absl::GetFlag(FLAGS_doppler_max) != 0) - { - doppler_max_ = absl::GetFlag(FLAGS_doppler_max); - } -#endif + // const auto samples_per_ms = static_cast(round(code_length_ / acq_parameters_.sampled_ms)); + const unsigned int max_dwells = acq_parameters_.bit_transition_flag ? 2 : acq_parameters_.max_dwells; - /* --- Find number of samples per spreading code (4 ms) -----------------*/ - code_length_ = static_cast(round( - fs_in_ / (GALILEO_E1_CODE_CHIP_RATE_CPS / GALILEO_E1_B_CODE_LENGTH_CHIPS))); + acquisition_cc_ = pcps_quicksync_make_acquisition_cc(acq_parameters_, folding_factor_, vector_length_, max_dwells, code_length_); - auto samples_per_ms = static_cast(round(code_length_ / 4.0)); - - DLOG(INFO) << "role " << role; - /*Calculate the folding factor value based on the formula described in the paper. - This may be a bug, but acquisition also work by variying the folding factor at va- - lues different that the expressed in the paper. In addition, it is important to point - out that by making the folding factor smaller we were able to get QuickSync work with - Galileo. Future work should be directed to test this assumption statistically.*/ - - // folding_factor_ = static_cast(ceil(sqrt(log2(code_length_)))); - folding_factor_ = configuration_->property(role + ".folding_factor", 2); - - if (sampled_ms_ % (folding_factor_ * 4) != 0) - { - LOG(WARNING) << "QuickSync Algorithm requires a coherent_integration_time" - << " multiple of " << (folding_factor_ * 4) << "ms, Value entered " - << sampled_ms_ << " ms"; - - if (sampled_ms_ < (folding_factor_ * 4)) - { - sampled_ms_ = static_cast(folding_factor_ * 4); - } - else - { - sampled_ms_ = static_cast(sampled_ms_ / (folding_factor_ * 4)) * (folding_factor_ * 4); - } - LOG(WARNING) << "coherent_integration_time should be multiple of " - << "Galileo code length (4 ms). coherent_integration_time = " - << sampled_ms_ << " ms will be used."; - } - // vector_length_ = (sampled_ms_/folding_factor_) * code_length_; - vector_length_ = sampled_ms_ * samples_per_ms; - - if (!bit_transition_flag_) - { - max_dwells_ = configuration_->property(role + ".max_dwells", 1); - } - else - { - max_dwells_ = 2; - } - - - bool enable_monitor_output = configuration_->property("AcquisitionMonitor.enable_monitor", false); - - code_ = std::vector>(code_length_); - LOG(INFO) << "Vector Length: " << vector_length_ - << ", Samples per ms: " << samples_per_ms - << ", Folding factor: " << folding_factor_ - << ", Sampled ms: " << sampled_ms_ - << ", Code Length: " << code_length_; - if (item_type_ == "gr_complex") - { - acquisition_cc_ = pcps_quicksync_make_acquisition_cc(folding_factor_, - sampled_ms_, max_dwells_, doppler_max_, fs_in_, - samples_per_ms, code_length_, bit_transition_flag_, - dump_, dump_filename_, enable_monitor_output); - stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, - vector_length_); - DLOG(INFO) << "stream_to_vector_quicksync(" - << stream_to_vector_->unique_id() << ")"; - DLOG(INFO) << "acquisition_quicksync(" << acquisition_cc_->unique_id() - << ")"; - } - else - { - acquisition_cc_ = nullptr; - item_size_ = 0; - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - } - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 0) - { - LOG(ERROR) << "This implementation does not provide an output stream"; + DLOG(INFO) << "acquisition_quicksync(" << acquisition_cc_->unique_id() << ")"; } } -void GalileoE1PcpsQuickSyncAmbiguousAcquisition::stop_acquisition() +void GalileoE1PcpsQuickSyncAmbiguousAcquisition::code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) { - acquisition_cc_->set_state(0); - acquisition_cc_->set_active(false); -} + std::array Signal_{}; + Signal_[0] = gnss_synchro_->Signal[0]; + Signal_[1] = gnss_synchro_->Signal[1]; + Signal_[2] = '\0'; - -void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_threshold(float threshold) -{ - float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", static_cast(0.0)); - - if (pfa == 0.0) - { - pfa = configuration_->property(role_ + ".pfa", static_cast(0.0)); - } - - if (pfa == 0.0) - { - threshold_ = threshold; - } - else - { - threshold_ = calculate_threshold(pfa); - } - - DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold_; - - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_threshold(threshold_); - } -} - - -void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_doppler_max(unsigned int doppler_max) -{ - doppler_max_ = doppler_max; - - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_doppler_max(doppler_max_); - } -} - - -void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_doppler_step(unsigned int doppler_step) -{ - doppler_step_ = doppler_step; - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_doppler_step(doppler_step_); - } -} - -void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_gnss_synchro( - Gnss_Synchro* gnss_synchro) -{ - gnss_synchro_ = gnss_synchro; - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_gnss_synchro(gnss_synchro_); - } -} - - -signed int -GalileoE1PcpsQuickSyncAmbiguousAcquisition::mag() -{ - if (item_type_ == "gr_complex") - { - return acquisition_cc_->mag(); - } - return 0; -} - - -void GalileoE1PcpsQuickSyncAmbiguousAcquisition::init() -{ - acquisition_cc_->init(); -} - - -void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_local_code() -{ - if (item_type_ == "gr_complex") - { - bool cboc = configuration_->property( - "Acquisition" + std::to_string(channel_) + ".cboc", false); - - std::vector> code(code_length_); - std::array Signal_{}; - Signal_[0] = gnss_synchro_->Signal[0]; - Signal_[1] = gnss_synchro_->Signal[1]; - Signal_[2] = '\0'; - - galileo_e1_code_gen_complex_sampled(code, Signal_, - cboc, gnss_synchro_->PRN, fs_in_, 0, false); - - own::span code_span(code_.data(), vector_length_); - for (unsigned int i = 0; i < (sampled_ms_ / (folding_factor_ * 4)); i++) - { - std::copy_n(code.data(), code_length_, code_span.subspan(i * code_length_, code_length_).data()); - } - - acquisition_cc_->set_local_code(code_.data()); - } -} - - -void GalileoE1PcpsQuickSyncAmbiguousAcquisition::reset() -{ - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_active(true); - } -} - - -void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_state(int state) -{ - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_state(state); - } + galileo_e1_code_gen_complex_sampled(dest, Signal_, cboc_, prn, sampling_freq, 0, false); } float GalileoE1PcpsQuickSyncAmbiguousAcquisition::calculate_threshold(float pfa) const { unsigned int frequency_bins = 0; - for (int doppler = static_cast(-doppler_max_); doppler <= static_cast(doppler_max_); doppler += static_cast(doppler_step_)) + for (int doppler = -acq_parameters_.doppler_max; doppler <= acq_parameters_.doppler_max; doppler += acq_parameters_.doppler_step) { frequency_bins++; } @@ -307,33 +103,3 @@ float GalileoE1PcpsQuickSyncAmbiguousAcquisition::calculate_threshold(float pfa) return threshold; } - - -void GalileoE1PcpsQuickSyncAmbiguousAcquisition::connect(gr::top_block_sptr top_block) -{ - if (item_type_ == "gr_complex") - { - top_block->connect(stream_to_vector_, 0, acquisition_cc_, 0); - } -} - - -void GalileoE1PcpsQuickSyncAmbiguousAcquisition::disconnect(gr::top_block_sptr top_block) -{ - if (item_type_ == "gr_complex") - { - top_block->disconnect(stream_to_vector_, 0, acquisition_cc_, 0); - } -} - - -gr::basic_block_sptr GalileoE1PcpsQuickSyncAmbiguousAcquisition::get_left_block() -{ - return stream_to_vector_; -} - - -gr::basic_block_sptr GalileoE1PcpsQuickSyncAmbiguousAcquisition::get_right_block() -{ - return acquisition_cc_; -} diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.h index 9bfd524c2..b8315aa64 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.h @@ -18,28 +18,18 @@ #ifndef GNSS_SDR_GALILEO_E1_PCPS_QUICKSYNC_AMBIGUOUS_ACQUISITION_H #define GNSS_SDR_GALILEO_E1_PCPS_QUICKSYNC_AMBIGUOUS_ACQUISITION_H -#include "channel_fsm.h" -#include "gnss_synchro.h" -#include "pcps_quicksync_acquisition_cc.h" -#include -#include -#include -#include -#include +#include "base_pcps_acquisition_custom.h" /** \addtogroup Acquisition * \{ */ /** \addtogroup Acq_adapters * \{ */ - -class ConfigurationInterface; - /*! * \brief This class adapts a PCPS acquisition block to an * AcquisitionInterface for Galileo E1 Signals */ -class GalileoE1PcpsQuickSyncAmbiguousAcquisition : public AcquisitionInterface +class GalileoE1PcpsQuickSyncAmbiguousAcquisition : public BasePcpsAcquisitionCustom { public: GalileoE1PcpsQuickSyncAmbiguousAcquisition( @@ -50,11 +40,6 @@ public: ~GalileoE1PcpsQuickSyncAmbiguousAcquisition() = default; - inline std::string role() override - { - return role_; - } - /*! * \brief Returns "Galileo_E1_PCPS_Ambiguous_Acquisition" */ @@ -63,115 +48,12 @@ public: return "Galileo_E1_PCPS_QuickSync_Ambiguous_Acquisition"; } - inline size_t item_size() override - { - return item_size_; - } - - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and - * tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - - /*! - * \brief Set acquisition channel unique ID - */ - inline void set_channel(unsigned int channel) override - { - channel_ = channel; - acquisition_cc_->set_channel(channel_); - } - - /*! - * \brief Set channel fsm associated to this acquisition instance - */ - inline void set_channel_fsm(std::weak_ptr channel_fsm) override - { - channel_fsm_ = std::move(channel_fsm); - acquisition_cc_->set_channel_fsm(channel_fsm_); - } - - /*! - * \brief Set statistics threshold of PCPS algorithm - */ - void set_threshold(float threshold) override; - - /*! - * \brief Set maximum Doppler off grid search - */ - void set_doppler_max(unsigned int doppler_max) override; - - /*! - * \brief Set Doppler steps for the grid search - */ - void set_doppler_step(unsigned int doppler_step) override; - - /*! - * \brief Initializes acquisition algorithm. - */ - void init() override; - - /*! - * \brief Sets local code for Galileo E1 PCPS acquisition algorithm. - */ - void set_local_code() override; - - /*! - * \brief Returns the maximum peak of grid search - */ - signed int mag() override; - - /*! - * \brief Restart acquisition algorithm - */ - void reset() override; - - /*! - * \brief If state = 1, it forces the block to start acquiring from the first sample - */ - void set_state(int state) override; - - /*! - * \brief Stop running acquisition - */ - void stop_acquisition() override; - - void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override {}; - private: - float calculate_threshold(float pfa) const; + float calculate_threshold(float pfa) const override; + void code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) override; - const ConfigurationInterface* configuration_; - pcps_quicksync_acquisition_cc_sptr acquisition_cc_; - gr::blocks::stream_to_vector::sptr stream_to_vector_; - std::weak_ptr channel_fsm_; - std::vector> code_; - std::string item_type_; - std::string role_; - std::string dump_filename_; - Gnss_Synchro* gnss_synchro_; - int64_t fs_in_; - size_t item_size_; - float threshold_; - unsigned int vector_length_; - unsigned int code_length_; - unsigned int channel_; - unsigned int doppler_max_; - unsigned int doppler_step_; - unsigned int sampled_ms_; - unsigned int max_dwells_; - unsigned int folding_factor_; - unsigned int in_streams_; - unsigned int out_streams_; - bool bit_transition_flag_; - bool dump_; + const unsigned int folding_factor_; + const bool cboc_; }; diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.cc index 21c1da480..db70c77ba 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.cc @@ -17,11 +17,9 @@ #include "galileo_e1_pcps_tong_ambiguous_acquisition.h" #include "Galileo_E1.h" -#include "configuration_interface.h" #include "galileo_e1_signal_replica.h" -#include "gnss_sdr_flags.h" +#include "pcps_tong_acquisition_cc.h" #include -#include #if USE_GLOG_AND_GFLAGS #include @@ -29,277 +27,43 @@ #include #endif -#if HAS_STD_SPAN -#include -namespace own = std; -#else -#include -namespace own = gsl_lite; -#endif GalileoE1PcpsTongAmbiguousAcquisition::GalileoE1PcpsTongAmbiguousAcquisition( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) - : configuration_(configuration), - gnss_synchro_(nullptr), - role_(role), - item_size_(sizeof(gr_complex)), - threshold_(0.0), - channel_(0), - doppler_max_(configuration_->property(role + ".doppler_max", 5000)), - doppler_step_(0), - sampled_ms_(configuration_->property(role + ".coherent_integration_time_ms", 4)), - tong_init_val_(configuration->property(role + ".tong_init_val", 1)), - tong_max_val_(configuration->property(role + ".tong_max_val", 2)), - tong_max_dwells_(configuration->property(role + ".tong_max_dwells", tong_max_val_ + 1)), - in_streams_(in_streams), - out_streams_(out_streams), - dump_(configuration_->property(role + ".dump", false)) + : BasePcpsAcquisitionCustom( + configuration, + role, + in_streams, + out_streams, + GALILEO_E1_CODE_CHIP_RATE_CPS, + GALILEO_E1_B_CODE_LENGTH_CHIPS, + GALILEO_E1_CODE_PERIOD_MS, + true, + true), + cboc_(configuration->property(role + ".cboc", false)) { - const std::string default_item_type("gr_complex"); - const std::string default_dump_filename("./acquisition.dat"); - - DLOG(INFO) << "role " << role_; - - item_type_ = configuration_->property(role_ + ".item_type", default_item_type); - int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 4000000); - fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - dump_filename_ = configuration_->property(role_ + ".dump_filename", default_dump_filename); - - if (sampled_ms_ % 4 != 0) + if (is_type_gr_complex()) { - sampled_ms_ = static_cast(sampled_ms_ / 4) * 4; - LOG(WARNING) << "coherent_integration_time should be multiple of " - << "Galileo code length (4 ms). coherent_integration_time = " - << sampled_ms_ << " ms will be used."; - } + const auto tong_init_val = configuration->property(role + ".tong_init_val", 1U); + const auto tong_max_val = configuration->property(role + ".tong_max_val", 2U); + const auto tong_max_dwells = configuration->property(role + ".tong_max_dwells", tong_max_val + 1U); -#if USE_GLOG_AND_GFLAGS - if (FLAGS_doppler_max != 0) - { - doppler_max_ = FLAGS_doppler_max; - } -#else - if (absl::GetFlag(FLAGS_doppler_max) != 0) - { - doppler_max_ = absl::GetFlag(FLAGS_doppler_max); - } -#endif + acquisition_cc_ = pcps_tong_make_acquisition_cc(acq_parameters_, tong_init_val, tong_max_val, tong_max_dwells); - bool enable_monitor_output = configuration_->property("AcquisitionMonitor.enable_monitor", false); - - // -- Find number of samples per spreading code (4 ms) ----------------- - - code_length_ = static_cast(round( - fs_in_ / (GALILEO_E1_CODE_CHIP_RATE_CPS / GALILEO_E1_B_CODE_LENGTH_CHIPS))); - - vector_length_ = code_length_ * static_cast(sampled_ms_ / 4); - - auto samples_per_ms = static_cast(code_length_) / 4; - - code_ = std::vector>(vector_length_); - - if (item_type_ == "gr_complex") - { - acquisition_cc_ = pcps_tong_make_acquisition_cc(sampled_ms_, doppler_max_, - fs_in_, samples_per_ms, code_length_, tong_init_val_, - tong_max_val_, tong_max_dwells_, dump_, dump_filename_, enable_monitor_output); - - stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); - DLOG(INFO) << "stream_to_vector(" - << stream_to_vector_->unique_id() << ")"; - DLOG(INFO) << "acquisition(" << acquisition_cc_->unique_id() - << ")"; - } - else - { - item_size_ = 0; - acquisition_cc_ = nullptr; - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - } - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 0) - { - LOG(ERROR) << "This implementation does not provide an output stream"; + DLOG(INFO) << "acquisition(" << acquisition_cc_->unique_id() << ")"; } } -void GalileoE1PcpsTongAmbiguousAcquisition::stop_acquisition() +void GalileoE1PcpsTongAmbiguousAcquisition::code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) { - acquisition_cc_->set_state(0); - acquisition_cc_->set_active(false); -} - - -void GalileoE1PcpsTongAmbiguousAcquisition::set_threshold(float threshold) -{ - float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", static_cast(0.0)); - - if (pfa == 0.0) - { - pfa = configuration_->property(role_ + ".pfa", static_cast(0.0)); - } - - if (pfa == 0.0) - { - threshold_ = threshold; - } - else - { - threshold_ = calculate_threshold(pfa); - } - - DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold_; - - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_threshold(threshold_); - } -} - - -void GalileoE1PcpsTongAmbiguousAcquisition::set_doppler_max(unsigned int doppler_max) -{ - doppler_max_ = doppler_max; - - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_doppler_max(doppler_max_); - } -} - - -void GalileoE1PcpsTongAmbiguousAcquisition::set_doppler_step(unsigned int doppler_step) -{ - doppler_step_ = doppler_step; - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_doppler_step(doppler_step_); - } -} - - -void GalileoE1PcpsTongAmbiguousAcquisition::set_gnss_synchro( - Gnss_Synchro* gnss_synchro) -{ - gnss_synchro_ = gnss_synchro; - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_gnss_synchro(gnss_synchro_); - } -} - - -signed int GalileoE1PcpsTongAmbiguousAcquisition::mag() -{ - if (item_type_ == "gr_complex") - { - return acquisition_cc_->mag(); - } - return 0; -} - - -void GalileoE1PcpsTongAmbiguousAcquisition::init() -{ - acquisition_cc_->init(); -} - - -void GalileoE1PcpsTongAmbiguousAcquisition::set_local_code() -{ - if (item_type_ == "gr_complex") - { - bool cboc = configuration_->property( - "Acquisition" + std::to_string(channel_) + ".cboc", false); - - std::vector> code(code_length_); - std::array Signal_{}; - Signal_[0] = gnss_synchro_->Signal[0]; - Signal_[1] = gnss_synchro_->Signal[1]; - Signal_[2] = '\0'; - galileo_e1_code_gen_complex_sampled(code, Signal_, - cboc, gnss_synchro_->PRN, fs_in_, 0, false); - - own::span code_span(code_.data(), vector_length_); - for (unsigned int i = 0; i < sampled_ms_ / 4; i++) - { - std::copy_n(code.data(), code_length_, code_span.subspan(i * code_length_, code_length_).data()); - } - - acquisition_cc_->set_local_code(code_.data()); - } -} - - -void GalileoE1PcpsTongAmbiguousAcquisition::reset() -{ - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_active(true); - } -} - - -void GalileoE1PcpsTongAmbiguousAcquisition::set_state(int state) -{ - acquisition_cc_->set_state(state); -} - - -float GalileoE1PcpsTongAmbiguousAcquisition::calculate_threshold(float pfa) const -{ - unsigned int frequency_bins = 0; - for (int doppler = static_cast(-doppler_max_); doppler <= static_cast(doppler_max_); doppler += static_cast(doppler_step_)) - { - frequency_bins++; - } - - DLOG(INFO) << "Channel " << channel_ << " Pfa = " << pfa; - - unsigned int ncells = vector_length_ * frequency_bins; - double exponent = 1 / static_cast(ncells); - double val = pow(1.0 - pfa, exponent); - auto lambda = static_cast(vector_length_); - boost::math::exponential_distribution mydist(lambda); - auto threshold = static_cast(quantile(mydist, val)); - - return threshold; -} - - -void GalileoE1PcpsTongAmbiguousAcquisition::connect(gr::top_block_sptr top_block) -{ - if (item_type_ == "gr_complex") - { - top_block->connect(stream_to_vector_, 0, acquisition_cc_, 0); - } -} - - -void GalileoE1PcpsTongAmbiguousAcquisition::disconnect(gr::top_block_sptr top_block) -{ - if (item_type_ == "gr_complex") - { - top_block->disconnect(stream_to_vector_, 0, acquisition_cc_, 0); - } -} - - -gr::basic_block_sptr GalileoE1PcpsTongAmbiguousAcquisition::get_left_block() -{ - return stream_to_vector_; -} - - -gr::basic_block_sptr GalileoE1PcpsTongAmbiguousAcquisition::get_right_block() -{ - return acquisition_cc_; + std::array Signal_{}; + Signal_[0] = gnss_synchro_->Signal[0]; + Signal_[1] = gnss_synchro_->Signal[1]; + Signal_[2] = '\0'; + + galileo_e1_code_gen_complex_sampled(dest, Signal_, cboc_, prn, sampling_freq, 0, false); } diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.h index 786723ea8..4f5e2921b 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.h @@ -18,28 +18,18 @@ #ifndef GNSS_SDR_GALILEO_E1_PCPS_TONG_AMBIGUOUS_ACQUISITION_H #define GNSS_SDR_GALILEO_E1_PCPS_TONG_AMBIGUOUS_ACQUISITION_H -#include "channel_fsm.h" -#include "gnss_synchro.h" -#include "pcps_tong_acquisition_cc.h" -#include -#include -#include -#include -#include +#include "base_pcps_acquisition_custom.h" /** \addtogroup Acquisition * \{ */ /** \addtogroup Acq_adapters * \{ */ - -class ConfigurationInterface; - /*! * \brief Adapts a PCPS Tong acquisition block to an AcquisitionInterface * for Galileo E1 Signals */ -class GalileoE1PcpsTongAmbiguousAcquisition : public AcquisitionInterface +class GalileoE1PcpsTongAmbiguousAcquisition : public BasePcpsAcquisitionCustom { public: GalileoE1PcpsTongAmbiguousAcquisition( @@ -50,11 +40,6 @@ public: ~GalileoE1PcpsTongAmbiguousAcquisition() = default; - inline std::string role() override - { - return role_; - } - /*! * \brief Returns "Galileo_E1_PCPS_Tong_Ambiguous_Acquisition" */ @@ -63,114 +48,10 @@ public: return "Galileo_E1_PCPS_Tong_Ambiguous_Acquisition"; } - inline size_t item_size() override - { - return item_size_; - } - - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and - * tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - - /*! - * \brief Set acquisition channel unique ID - */ - inline void set_channel(unsigned int channel) override - { - channel_ = channel; - acquisition_cc_->set_channel(channel_); - } - - /*! - * \brief Set channel fsm associated to this acquisition instance - */ - inline void set_channel_fsm(std::weak_ptr channel_fsm) override - { - channel_fsm_ = std::move(channel_fsm); - acquisition_cc_->set_channel_fsm(channel_fsm_); - } - - /*! - * \brief Set statistics threshold of TONG algorithm - */ - void set_threshold(float threshold) override; - - /*! - * \brief Set maximum Doppler off grid search - */ - void set_doppler_max(unsigned int doppler_max) override; - - /*! - * \brief Set Doppler steps for the grid search - */ - void set_doppler_step(unsigned int doppler_step) override; - - /*! - * \brief Initializes acquisition algorithm. - */ - void init() override; - - /*! - * \brief Sets local code for Galileo E1 TONG acquisition algorithm. - */ - void set_local_code() override; - - /*! - * \brief Returns the maximum peak of grid search - */ - signed int mag() override; - - /*! - * \brief Restart acquisition algorithm - */ - void reset() override; - - /*! - * \brief If state = 1, it forces the block to start acquiring from the first sample - */ - void set_state(int state) override; - - /*! - * \brief Stop running acquisition - */ - void stop_acquisition() override; - - void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override {}; - private: - float calculate_threshold(float pfa) const; - const ConfigurationInterface* configuration_; - pcps_tong_acquisition_cc_sptr acquisition_cc_; - gr::blocks::stream_to_vector::sptr stream_to_vector_; - std::weak_ptr channel_fsm_; - std::vector> code_; - Gnss_Synchro* gnss_synchro_; - std::string item_type_; - std::string dump_filename_; - std::string role_; - int64_t fs_in_; - size_t item_size_; - float threshold_; - unsigned int vector_length_; - unsigned int code_length_; - unsigned int channel_; - unsigned int doppler_max_; - unsigned int doppler_step_; - unsigned int sampled_ms_; - unsigned int tong_init_val_; - unsigned int tong_max_val_; - unsigned int tong_max_dwells_; - unsigned int in_streams_; - unsigned int out_streams_; - bool dump_; + void code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) override; + + const bool cboc_; }; diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.cc b/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.cc index ef43693c9..1ebf19c14 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.cc @@ -25,7 +25,7 @@ #include "Galileo_E5a.h" #include "configuration_interface.h" #include "galileo_e5_signal_replica.h" -#include "gnss_sdr_flags.h" +#include "galileo_e5a_noncoherent_iq_acquisition_caf_cc.h" #include #include @@ -43,213 +43,87 @@ namespace own = std; namespace own = gsl_lite; #endif +namespace +{ +int get_zero_padding(const ConfigurationInterface* configuration, const std::string& role) +{ + return configuration->property(role + ".Zero_padding", 0); +} + +uint32_t get_max_sampled_ms(const ConfigurationInterface* configuration, const std::string& role) +{ + const auto zero_padding = get_zero_padding(configuration, role); + + if (zero_padding > 0) + { + DLOG(INFO) << "Zero padding activated. Changing to 1ms code + 1ms zero padding "; + std::cout << "Zero padding activated. Changing to 1ms code + 1ms zero padding\n"; + return 2; + } + + return 3; +} +} // namespace + GalileoE5aNoncoherentIQAcquisitionCaf::GalileoE5aNoncoherentIQAcquisitionCaf( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) - : configuration_(configuration), - role_(role), - gnss_synchro_(nullptr), - item_size_(sizeof(gr_complex)), - threshold_(0.0), - Zero_padding(configuration_->property(role + ".Zero_padding", 0)), - CAF_window_hz_(configuration_->property(role + ".CAF_window_hz", 0)), - channel_(0), - doppler_max_(configuration_->property(role + ".doppler_max", 5000)), - doppler_step_(0), - sampled_ms_(configuration_->property(role + ".coherent_integration_time_ms", 1)), - max_dwells_(configuration_->property(role + ".max_dwells", 1)), - in_streams_(in_streams), - out_streams_(out_streams), - bit_transition_flag_(configuration_->property(role + ".bit_transition_flag", false)), - dump_(configuration_->property(role + ".dump", false)) + : BasePcpsAcquisitionCustom( + configuration, + role, + in_streams, + out_streams, + GALILEO_E5A_CODE_CHIP_RATE_CPS, + GALILEO_E5A_CODE_LENGTH_CHIPS, + GALILEO_E5A_CODE_PERIOD_MS, + false, + true, + get_max_sampled_ms(configuration, role)), + zero_padding_(get_zero_padding(configuration, role)), + caf_window_hz_(configuration->property(role + ".CAF_window_hz", 0)), + codeQ_(vector_length_) { - const std::string default_item_type("gr_complex"); - const std::string default_dump_filename("./acquisition.dat"); - item_type_ = configuration_->property(role_ + ".item_type", default_item_type); - dump_filename_ = configuration_->property(role_ + ".dump_filename", default_dump_filename); - int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 32000000); - fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - -#if USE_GLOG_AND_GFLAGS - if (FLAGS_doppler_max != 0) + if (is_type_gr_complex()) { - doppler_max_ = FLAGS_doppler_max; + const auto sig = configuration->property("Channel.signal", std::string("5X")); + const auto both_signal_components = (sig.at(0) == '5' && sig.at(1) == 'X'); + + acquisition_cc_ = galileo_e5a_noncoherentIQ_make_acquisition_caf_cc( + acq_parameters_, both_signal_components, caf_window_hz_, zero_padding_); } -#else - if (absl::GetFlag(FLAGS_doppler_max) != 0) - { - doppler_max_ = absl::GetFlag(FLAGS_doppler_max); - } -#endif - - DLOG(INFO) << "role " << role_; - if (sampled_ms_ > 3) - { - sampled_ms_ = 3; - DLOG(INFO) << "Coherent integration time should be 3 ms or less. Changing to 3ms "; - std::cout << "Too high coherent integration time. Changing to 3ms\n"; - } - if (Zero_padding > 0) - { - sampled_ms_ = 2; - DLOG(INFO) << "Zero padding activated. Changing to 1ms code + 1ms zero padding "; - std::cout << "Zero padding activated. Changing to 1ms code + 1ms zero padding\n"; - } - - // -- Find number of samples per spreading code (1ms)------------------------- - code_length_ = static_cast(round(static_cast(fs_in_) / GALILEO_E5A_CODE_CHIP_RATE_CPS * static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS))); - - vector_length_ = code_length_ * sampled_ms_; - - codeI_ = std::vector>(vector_length_); - codeQ_ = std::vector>(vector_length_); - both_signal_components = false; - - bool enable_monitor_output = configuration->property("AcquisitionMonitor.enable_monitor", false); - - std::string sig_ = configuration_->property("Channel.signal", std::string("5X")); - if (sig_.at(0) == '5' && sig_.at(1) == 'X') - { - both_signal_components = true; - } - if (item_type_ == "gr_complex") - { - acquisition_cc_ = galileo_e5a_noncoherentIQ_make_acquisition_caf_cc(sampled_ms_, max_dwells_, - doppler_max_, fs_in_, code_length_, code_length_, bit_transition_flag_, - dump_, dump_filename_, both_signal_components, CAF_window_hz_, Zero_padding, enable_monitor_output); - } - else - { - item_size_ = 0; - acquisition_cc_ = nullptr; - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - } - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 0) - { - LOG(ERROR) << "This implementation does not provide an output stream"; - } -} - - -void GalileoE5aNoncoherentIQAcquisitionCaf::stop_acquisition() -{ - acquisition_cc_->set_state(0); - acquisition_cc_->set_active(false); -} - - -void GalileoE5aNoncoherentIQAcquisitionCaf::set_threshold(float threshold) -{ - float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", static_cast(0.0)); - - if (pfa == 0.0) - { - pfa = configuration_->property(role_ + ".pfa", static_cast(0.0)); - } - - if (pfa == 0.0) - { - threshold_ = threshold; - } - else - { - threshold_ = calculate_threshold(pfa); - } - - DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold_; - - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_threshold(threshold_); - } -} - - -void GalileoE5aNoncoherentIQAcquisitionCaf::set_doppler_max(unsigned int doppler_max) -{ - doppler_max_ = doppler_max; - - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_doppler_max(doppler_max_); - } -} - - -void GalileoE5aNoncoherentIQAcquisitionCaf::set_doppler_step(unsigned int doppler_step) -{ - doppler_step_ = doppler_step; - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_doppler_step(doppler_step_); - } -} - - -void GalileoE5aNoncoherentIQAcquisitionCaf::set_gnss_synchro( - Gnss_Synchro* gnss_synchro) -{ - gnss_synchro_ = gnss_synchro; - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_gnss_synchro(gnss_synchro_); - } -} - - -signed int GalileoE5aNoncoherentIQAcquisitionCaf::mag() -{ - if (item_type_ == "gr_complex") - { - return static_cast(acquisition_cc_->mag()); - } - return 0; -} - - -void GalileoE5aNoncoherentIQAcquisitionCaf::init() -{ - acquisition_cc_->init(); } void GalileoE5aNoncoherentIQAcquisitionCaf::set_local_code() { - if (item_type_ == "gr_complex") + if (is_type_gr_complex()) { + auto& codeI_ = code_; std::vector> codeI(code_length_); std::vector> codeQ(code_length_); if (gnss_synchro_->Signal[0] == '5' && gnss_synchro_->Signal[1] == 'X') { std::array a = {{'5', 'I', '\0'}}; - galileo_e5_a_code_gen_complex_sampled(codeI, - gnss_synchro_->PRN, a, fs_in_, 0); + galileo_e5_a_code_gen_complex_sampled(codeI, gnss_synchro_->PRN, a, acq_parameters_.fs_in, 0); std::array b = {{'5', 'Q', '\0'}}; - galileo_e5_a_code_gen_complex_sampled(codeQ, - gnss_synchro_->PRN, b, fs_in_, 0); + galileo_e5_a_code_gen_complex_sampled(codeQ, gnss_synchro_->PRN, b, acq_parameters_.fs_in, 0); } else { std::array signal_type_ = {{'5', 'X', '\0'}}; - galileo_e5_a_code_gen_complex_sampled(codeI, - gnss_synchro_->PRN, signal_type_, fs_in_, 0); + galileo_e5_a_code_gen_complex_sampled(codeI, gnss_synchro_->PRN, signal_type_, acq_parameters_.fs_in, 0); } // WARNING: 3ms are coherently integrated. Secondary sequence (1,1,1) // is generated, and modulated in the 'block'. - own::span codeQ_span(codeQ_.data(), vector_length_); own::span codeI_span(codeI_.data(), vector_length_); - if (Zero_padding == 0) // if no zero_padding + own::span codeQ_span(codeQ_.data(), vector_length_); + if (zero_padding_ == 0) // if no zero_padding { - for (unsigned int i = 0; i < sampled_ms_; i++) + for (unsigned int i = 0; i < acq_parameters_.sampled_ms; i++) { std::copy_n(codeI.data(), code_length_, codeI_span.subspan(i * code_length_, code_length_).data()); if (gnss_synchro_->Signal[0] == '5' && gnss_synchro_->Signal[1] == 'X') @@ -271,68 +145,3 @@ void GalileoE5aNoncoherentIQAcquisitionCaf::set_local_code() acquisition_cc_->set_local_code(codeI_.data(), codeQ_.data()); } } - - -void GalileoE5aNoncoherentIQAcquisitionCaf::reset() -{ - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_active(true); - } -} - - -float GalileoE5aNoncoherentIQAcquisitionCaf::calculate_threshold(float pfa) const -{ - // Calculate the threshold - unsigned int frequency_bins = 0; - for (int doppler = static_cast(-doppler_max_); doppler <= static_cast(doppler_max_); doppler += static_cast(doppler_step_)) - { - frequency_bins++; - } - DLOG(INFO) << "Channel " << channel_ << " Pfa = " << pfa; - unsigned int ncells = vector_length_ * frequency_bins; - double exponent = 1 / static_cast(ncells); - double val = pow(1.0 - pfa, exponent); - auto lambda = static_cast(vector_length_); - boost::math::exponential_distribution mydist(lambda); - auto threshold = static_cast(quantile(mydist, val)); - - return threshold; -} - - -void GalileoE5aNoncoherentIQAcquisitionCaf::set_state(int state) -{ - acquisition_cc_->set_state(state); -} - - -void GalileoE5aNoncoherentIQAcquisitionCaf::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // Nothing to connect internally -} - - -void GalileoE5aNoncoherentIQAcquisitionCaf::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // Nothing to disconnect internally -} - - -gr::basic_block_sptr GalileoE5aNoncoherentIQAcquisitionCaf::get_left_block() -{ - return acquisition_cc_; -} - - -gr::basic_block_sptr GalileoE5aNoncoherentIQAcquisitionCaf::get_right_block() -{ - return acquisition_cc_; -} diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h b/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h index 805799f49..b1b23ff8c 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.h @@ -24,23 +24,14 @@ #ifndef GNSS_SDR_GALILEO_E5A_NONCOHERENT_IQ_ACQUISITION_CAF_H #define GNSS_SDR_GALILEO_E5A_NONCOHERENT_IQ_ACQUISITION_CAF_H -#include "channel_fsm.h" -#include "galileo_e5a_noncoherent_iq_acquisition_caf_cc.h" -#include "gnss_synchro.h" -#include -#include -#include -#include +#include "base_pcps_acquisition_custom.h" /** \addtogroup Acquisition * \{ */ /** \addtogroup Acq_adapters * \{ */ - -class ConfigurationInterface; - -class GalileoE5aNoncoherentIQAcquisitionCaf : public AcquisitionInterface +class GalileoE5aNoncoherentIQAcquisitionCaf : public BasePcpsAcquisitionCustom { public: GalileoE5aNoncoherentIQAcquisitionCaf(const ConfigurationInterface* configuration, @@ -50,11 +41,6 @@ public: ~GalileoE5aNoncoherentIQAcquisitionCaf() = default; - inline std::string role() override - { - return role_; - } - /*! * \brief Returns "Galileo_E5a_Noncoherent_IQ_Acquisition_CAF" */ @@ -63,119 +49,19 @@ public: return "Galileo_E5a_Noncoherent_IQ_Acquisition_CAF"; } - inline size_t item_size() override - { - return item_size_; - } - - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and - * tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - - /*! - * \brief Set acquisition channel unique ID - */ - inline void set_channel(unsigned int channel) override - { - channel_ = channel; - acquisition_cc_->set_channel(channel_); - } - - /*! - * \brief Set channel fsm associated to this acquisition instance - */ - inline void set_channel_fsm(std::weak_ptr channel_fsm) override - { - channel_fsm_ = std::move(channel_fsm); - acquisition_cc_->set_channel_fsm(channel_fsm_); - } - - /*! - * \brief Set statistics threshold of PCPS algorithm - */ - void set_threshold(float threshold) override; - - /*! - * \brief Set maximum Doppler off grid search - */ - void set_doppler_max(unsigned int doppler_max) override; - - /*! - * \brief Set Doppler steps for the grid search - */ - void set_doppler_step(unsigned int doppler_step) override; - - /*! - * \brief Initializes acquisition algorithm. - */ - void init() override; - /*! * \brief Sets local Galileo E5a code for PCPS acquisition algorithm. */ void set_local_code() override; - /*! - * \brief Returns the maximum peak of grid search - */ - signed int mag() override; - - /*! - * \brief Restart acquisition algorithm - */ - void reset() override; - - /*! - * \brief If set to 1, ensures that acquisition starts at the - * first available sample. - * \param state - int=1 forces start of acquisition - */ - void set_state(int state) override; - - /*! - * \brief Stop running acquisition - */ - void stop_acquisition() override; - - void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override {}; - private: - float calculate_threshold(float pfa) const; + // We don't implement this function since we override set_local_code + void code_gen_complex_sampled(own::span> /*dest*/, uint32_t /*prn*/, int32_t /*sampling_freq*/) override {} + + const int zero_padding_; + const int caf_window_hz_; - const ConfigurationInterface* configuration_; - galileo_e5a_noncoherentIQ_acquisition_caf_cc_sptr acquisition_cc_; - std::weak_ptr channel_fsm_; - std::vector> codeI_; std::vector> codeQ_; - std::string item_type_; - std::string role_; - std::string dump_filename_; - Gnss_Synchro* gnss_synchro_; - int64_t fs_in_; - size_t item_size_; - float threshold_; - int Zero_padding; - int CAF_window_hz_; - int code_length_; - unsigned int vector_length_; - unsigned int channel_; - unsigned int doppler_max_; - unsigned int doppler_step_; - unsigned int sampled_ms_; - unsigned int max_dwells_; - unsigned int in_streams_; - unsigned int out_streams_; - bool bit_transition_flag_; - bool both_signal_components; - bool dump_; }; diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.cc index c4a45cab7..405c2d6f0 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.cc @@ -43,7 +43,14 @@ GalileoE5aPcpsAcquisition::GalileoE5aPcpsAcquisition( const std::string& role, unsigned int in_streams, unsigned int out_streams) - : BasePcpsAcquisition(configuration, role, in_streams, out_streams, GALILEO_E5A_CODE_CHIP_RATE_CPS, GALILEO_E5A_OPT_ACQ_FS_SPS, GALILEO_E5A_CODE_LENGTH_CHIPS, 1), + : BasePcpsAcquisition(configuration, + role, + in_streams, + out_streams, + GALILEO_E5A_CODE_CHIP_RATE_CPS, + GALILEO_E5A_OPT_ACQ_FS_SPS, + GALILEO_E5A_CODE_LENGTH_CHIPS, + GALILEO_E5A_CODE_PERIOD_MS), acq_pilot_(configuration->property(role + ".acquire_pilot", false)), acq_iq_(configuration->property(role + ".acquire_iq", false)) { diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h index fd071b27e..82aa736d5 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h @@ -26,9 +26,6 @@ * \{ */ -class ConfigurationInterface; - - /*! * \brief This class adapts a PCPS acquisition block off-loaded on an FPGA * to an AcquisitionInterface for Galileo E5a signals diff --git a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition.cc index 6be32df12..79f236daf 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition.cc @@ -24,7 +24,14 @@ GalileoE5bPcpsAcquisition::GalileoE5bPcpsAcquisition(const ConfigurationInterfac const std::string& role, unsigned int in_streams, unsigned int out_streams) - : BasePcpsAcquisition(configuration, role, in_streams, out_streams, GALILEO_E5B_CODE_CHIP_RATE_CPS, GALILEO_E5B_OPT_ACQ_FS_SPS, GALILEO_E5B_CODE_LENGTH_CHIPS, 1), + : BasePcpsAcquisition(configuration, + role, + in_streams, + out_streams, + GALILEO_E5B_CODE_CHIP_RATE_CPS, + GALILEO_E5B_OPT_ACQ_FS_SPS, + GALILEO_E5B_CODE_LENGTH_CHIPS, + GALILEO_E5B_CODE_PERIOD_MS), acq_pilot_(configuration->property(role + ".acquire_pilot", false)), acq_iq_(configuration->property(role + ".acquire_iq", false)) { diff --git a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition.h index 8f99d5f69..8f650d359 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition.h @@ -27,9 +27,6 @@ /** \addtogroup Acq_adapters * \{ */ - -class ConfigurationInterface; - class GalileoE5bPcpsAcquisition : public BasePcpsAcquisition { public: diff --git a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.cc index db0d4b440..984fe37b1 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.cc @@ -46,10 +46,10 @@ GalileoE5bPcpsAcquisitionFpga::GalileoE5bPcpsAcquisitionFpga( DEFAULT_FPGA_BLK_EXP, ACQ_BUFF_1, in_streams, - out_streams) + out_streams), + acq_pilot_(configuration->property(role + ".acquire_pilot", false)), + acq_iq_(configuration->property(role + ".acquire_iq", false)) { - acq_pilot_ = configuration->property(role + ".acquire_pilot", false); - acq_iq_ = configuration->property(role + ".acquire_iq", false); generate_galileo_e5b_prn_codes(); DLOG(INFO) << "Initialized FPGA acquisition adapter for role " << role; } diff --git a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h index 07c074749..de772f15c 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition_fpga.h @@ -27,8 +27,6 @@ * \{ */ -class ConfigurationInterface; - /*! * \brief This class adapts a PCPS acquisition block off-loaded on an FPGA * to an AcquisitionInterface for Galileo E5b signals @@ -56,7 +54,7 @@ private: static const uint32_t DEFAULT_FPGA_BLK_EXP = 13; // default block exponent void generate_galileo_e5b_prn_codes(); bool acq_pilot_; - bool acq_iq_; + const bool acq_iq_; }; diff --git a/src/algorithms/acquisition/adapters/galileo_e6_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e6_pcps_acquisition.cc index d456ab3b5..901614c76 100644 --- a/src/algorithms/acquisition/adapters/galileo_e6_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e6_pcps_acquisition.cc @@ -24,7 +24,15 @@ GalileoE6PcpsAcquisition::GalileoE6PcpsAcquisition( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : BasePcpsAcquisition(configuration, role, in_streams, out_streams, GALILEO_E6_B_CODE_CHIP_RATE_CPS, GALILEO_E6_OPT_ACQ_FS_SPS, GALILEO_E6_B_CODE_LENGTH_CHIPS, 1) + unsigned int out_streams) + : BasePcpsAcquisition(configuration, + role, + in_streams, + out_streams, + GALILEO_E6_B_CODE_CHIP_RATE_CPS, + GALILEO_E6_OPT_ACQ_FS_SPS, + GALILEO_E6_B_CODE_LENGTH_CHIPS, + GALILEO_E6_CODE_PERIOD_MS) { } diff --git a/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.cc index ad6494f73..90c5bea54 100644 --- a/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.cc @@ -26,7 +26,15 @@ GlonassL1CaPcpsAcquisition::GlonassL1CaPcpsAcquisition( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : BasePcpsAcquisition(configuration, role, in_streams, out_streams, GLONASS_L1_CA_CODE_RATE_CPS, 100e6, GLONASS_L1_CA_CODE_LENGTH_CHIPS, 1) + unsigned int out_streams) + : BasePcpsAcquisition(configuration, + role, + in_streams, + out_streams, + GLONASS_L1_CA_CODE_RATE_CPS, + 100e6, + GLONASS_L1_CA_CODE_LENGTH_CHIPS, + GLONASS_L1_CA_CODE_PEROD_MS) { } diff --git a/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.h b/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.h index 7478d294c..2d71f710c 100644 --- a/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.h @@ -27,9 +27,6 @@ /** \addtogroup Acq_adapters * \{ */ - -class ConfigurationInterface; - /*! * \brief This class adapts a PCPS acquisition block to an AcquisitionInterface * for GPS L1 C/A signals diff --git a/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc index ba78a1760..d4e018601 100644 --- a/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc @@ -25,7 +25,15 @@ GlonassL2CaPcpsAcquisition::GlonassL2CaPcpsAcquisition( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : BasePcpsAcquisition(configuration, role, in_streams, out_streams, GLONASS_L2_CA_CODE_RATE_CPS, 100e6, GLONASS_L2_CA_CODE_LENGTH_CHIPS, 1) + unsigned int out_streams) + : BasePcpsAcquisition(configuration, + role, + in_streams, + out_streams, + GLONASS_L2_CA_CODE_RATE_CPS, + 100e6, + GLONASS_L2_CA_CODE_LENGTH_CHIPS, + GLONASS_L2_CA_CODE_PEROD_MS) { } diff --git a/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.h b/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.h index b9d91337e..57b789826 100644 --- a/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.h @@ -19,26 +19,13 @@ #ifndef GNSS_SDR_GLONASS_L2_CA_PCPS_ACQUISITION_H #define GNSS_SDR_GLONASS_L2_CA_PCPS_ACQUISITION_H -#include "acq_conf.h" #include "base_pcps_acquisition.h" -#include "channel_fsm.h" -#include "complex_byte_to_float_x2.h" -#include "gnss_synchro.h" -#include "pcps_acquisition.h" -#include -#include -#include -#include -#include /** \addtogroup Acquisition * \{ */ /** \addtogroup Acq_adapters * \{ */ - -class ConfigurationInterface; - /*! * \brief This class adapts a PCPS acquisition block to an AcquisitionInterface * for GLONASS L2 C/A signals diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc index 846861a6a..288e4332c 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc @@ -28,7 +28,15 @@ GpsL1CaPcpsAcquisition::GpsL1CaPcpsAcquisition( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : BasePcpsAcquisition(configuration, role, in_streams, out_streams, GPS_L1_CA_CODE_RATE_CPS, GPS_L1_CA_OPT_ACQ_FS_SPS, GPS_L1_CA_CODE_LENGTH_CHIPS, 1) + unsigned int out_streams) + : BasePcpsAcquisition(configuration, + role, + in_streams, + out_streams, + GPS_L1_CA_CODE_RATE_CPS, + GPS_L1_CA_OPT_ACQ_FS_SPS, + GPS_L1_CA_CODE_LENGTH_CHIPS, + GPS_L1_CA_CODE_PERIOD_MS) { } diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.h index 7e0c55f23..0cd6d94a4 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.h @@ -31,9 +31,6 @@ * Wrap GNU Radio acquisition blocks with an AcquisitionInterface * \{ */ - -class ConfigurationInterface; - /*! * \brief This class adapts a PCPS acquisition block to an AcquisitionInterface * for GPS L1 C/A signals diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.cc index f119a60c4..2da1e63f4 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.cc @@ -21,9 +21,8 @@ #include "gps_l1_ca_pcps_acquisition_fine_doppler.h" #include "GPS_L1_CA.h" #include "acq_conf.h" -#include "configuration_interface.h" -#include "gnss_sdr_flags.h" #include "gps_sdr_signal_replica.h" +#include "pcps_acquisition_fine_doppler_cc.h" #if USE_GLOG_AND_GFLAGS #include @@ -36,166 +35,30 @@ GpsL1CaPcpsAcquisitionFineDoppler::GpsL1CaPcpsAcquisitionFineDoppler( const std::string& role, unsigned int in_streams, unsigned int out_streams) - : role_(role), - gnss_synchro_(nullptr), - item_size_(sizeof(gr_complex)), - threshold_(0.0), - doppler_max_(configuration->property(role + ".doppler_max", 5000)), - max_dwells_(configuration->property(role + ".max_dwells", 1)), - channel_(0), - doppler_step_(0), - sampled_ms_(configuration->property(role + ".coherent_integration_time_ms", 1)), - in_streams_(in_streams), - out_streams_(out_streams), - dump_(configuration->property(role + ".dump", false)) + : BasePcpsAcquisitionCustom( + configuration, + role, + in_streams, + out_streams, + GPS_L1_CA_CODE_RATE_CPS, + GPS_L1_CA_CODE_LENGTH_CHIPS, + GPS_L1_CA_CODE_PERIOD_MS, + false, + false) { - const std::string default_item_type("gr_complex"); - std::string default_dump_filename = "./acquisition.mat"; - Acq_Conf acq_parameters = Acq_Conf(); - - item_type_ = configuration->property(role_ + ".item_type", default_item_type); - int64_t fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); - fs_in_ = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - acq_parameters.fs_in = fs_in_; - acq_parameters.samples_per_chip = static_cast(ceil(GPS_L1_CA_CHIP_PERIOD_S * static_cast(acq_parameters.fs_in))); - acq_parameters.dump = dump_; - dump_filename_ = configuration->property(role_ + ".dump_filename", std::move(default_dump_filename)); - acq_parameters.dump_filename = dump_filename_; -#if USE_GLOG_AND_GFLAGS - if (FLAGS_doppler_max != 0) + if (is_type_gr_complex()) { - doppler_max_ = FLAGS_doppler_max; - } -#else - if (absl::GetFlag(FLAGS_doppler_max) != 0) - { - doppler_max_ = absl::GetFlag(FLAGS_doppler_max); - } -#endif - acq_parameters.doppler_max = doppler_max_; - acq_parameters.sampled_ms = sampled_ms_; - acq_parameters.max_dwells = max_dwells_; - acq_parameters.blocking_on_standby = configuration->property(role + ".blocking_on_standby", false); + Acq_Conf acq_parameters = acq_parameters_; + acq_parameters.samples_per_ms = static_cast(vector_length_); - // -- Find number of samples per spreading code ------------------------- - vector_length_ = static_cast(round(fs_in_ / (GPS_L1_CA_CODE_RATE_CPS / GPS_L1_CA_CODE_LENGTH_CHIPS))); - acq_parameters.samples_per_ms = static_cast(vector_length_); - code_ = std::vector>(vector_length_); - - DLOG(INFO) << "role " << role_; - if (item_type_ == "gr_complex") - { acquisition_cc_ = pcps_make_acquisition_fine_doppler_cc(acq_parameters); - } - else - { - item_size_ = 0; - acquisition_cc_ = nullptr; - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - } - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 0) - { - LOG(ERROR) << "This implementation does not provide an output stream"; + DLOG(INFO) << "acquisition(" << acquisition_cc_->unique_id() << ")"; } } -void GpsL1CaPcpsAcquisitionFineDoppler::stop_acquisition() +void GpsL1CaPcpsAcquisitionFineDoppler::code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) { - acquisition_cc_->set_state(0); - acquisition_cc_->set_active(false); -} - - -void GpsL1CaPcpsAcquisitionFineDoppler::set_threshold(float threshold) -{ - threshold_ = threshold; - acquisition_cc_->set_threshold(threshold_); -} - - -void GpsL1CaPcpsAcquisitionFineDoppler::set_doppler_max(unsigned int doppler_max) -{ - doppler_max_ = static_cast(doppler_max); - acquisition_cc_->set_doppler_max(doppler_max_); -} - - -void GpsL1CaPcpsAcquisitionFineDoppler::set_doppler_step(unsigned int doppler_step) -{ - doppler_step_ = doppler_step; - acquisition_cc_->set_doppler_step(doppler_step_); -} - - -void GpsL1CaPcpsAcquisitionFineDoppler::set_gnss_synchro(Gnss_Synchro* gnss_synchro) -{ - gnss_synchro_ = gnss_synchro; - acquisition_cc_->set_gnss_synchro(gnss_synchro_); -} - - -signed int GpsL1CaPcpsAcquisitionFineDoppler::mag() -{ - return static_cast(acquisition_cc_->mag()); -} - - -void GpsL1CaPcpsAcquisitionFineDoppler::init() -{ - acquisition_cc_->init(); -} - - -void GpsL1CaPcpsAcquisitionFineDoppler::set_local_code() -{ - gps_l1_ca_code_gen_complex_sampled(code_, gnss_synchro_->PRN, fs_in_, 0); - acquisition_cc_->set_local_code(code_.data()); -} - - -void GpsL1CaPcpsAcquisitionFineDoppler::reset() -{ - acquisition_cc_->set_active(true); -} - - -void GpsL1CaPcpsAcquisitionFineDoppler::set_state(int state) -{ - acquisition_cc_->set_state(state); -} - - -void GpsL1CaPcpsAcquisitionFineDoppler::connect(gnss_shared_ptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to disconnect, now the tracking uses gr_sync_decimator -} - - -void GpsL1CaPcpsAcquisitionFineDoppler::disconnect(gnss_shared_ptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to disconnect, now the tracking uses gr_sync_decimator -} - - -gnss_shared_ptr GpsL1CaPcpsAcquisitionFineDoppler::get_left_block() -{ - return acquisition_cc_; -} - - -gnss_shared_ptr GpsL1CaPcpsAcquisitionFineDoppler::get_right_block() -{ - return acquisition_cc_; + gps_l1_ca_code_gen_complex_sampled(dest, prn, sampling_freq, 0); } diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.h index 9288a1ce6..a75d80c3f 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.h @@ -20,13 +20,7 @@ #ifndef GNSS_SDR_GPS_L1_CA_PCPS_ACQUISITION_FINE_DOPPLER_H #define GNSS_SDR_GPS_L1_CA_PCPS_ACQUISITION_FINE_DOPPLER_H -#include "channel_fsm.h" -#include "gnss_synchro.h" -#include "pcps_acquisition_fine_doppler_cc.h" -#include -#include -#include -#include +#include "base_pcps_acquisition_custom.h" /** \addtogroup Acquisition * \{ */ @@ -34,15 +28,11 @@ * \{ */ -using pcps_acquisition_fine_doppler_cc_sptr = gnss_shared_ptr; - -class ConfigurationInterface; - /*! * \brief This class Adapts a PCPS acquisition block with fine Doppler estimation to an AcquisitionInterface for * GPS L1 C/A signals */ -class GpsL1CaPcpsAcquisitionFineDoppler : public AcquisitionInterface +class GpsL1CaPcpsAcquisitionFineDoppler : public BasePcpsAcquisitionCustom { public: GpsL1CaPcpsAcquisitionFineDoppler(const ConfigurationInterface* configuration, @@ -52,11 +42,6 @@ public: ~GpsL1CaPcpsAcquisitionFineDoppler() = default; - inline std::string role() override - { - return role_; - } - /*! * \brief Returns "GPS_L1_CA_PCPS_Acquisition_Fine_Doppler" */ @@ -65,105 +50,8 @@ public: return "GPS_L1_CA_PCPS_Acquisition_Fine_Doppler"; } - inline size_t item_size() override - { - return item_size_; - } - - void connect(gnss_shared_ptr top_block) override; - void disconnect(gnss_shared_ptr top_block) override; - gnss_shared_ptr get_left_block() override; - gnss_shared_ptr get_right_block() override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and - * tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - - /*! - * \brief Set acquisition channel unique ID - */ - inline void set_channel(unsigned int channel) override - { - channel_ = channel; - acquisition_cc_->set_channel(channel_); - } - - /*! - * \brief Set channel fsm associated to this acquisition instance - */ - inline void set_channel_fsm(std::weak_ptr channel_fsm) override - { - channel_fsm_ = std::move(channel_fsm); - acquisition_cc_->set_channel_fsm(channel_fsm_); - } - - /*! - * \brief Set statistics threshold of PCPS algorithm - */ - void set_threshold(float threshold) override; - - /*! - * \brief Set maximum Doppler off grid search - */ - void set_doppler_max(unsigned int doppler_max) override; - - /*! - * \brief Set Doppler steps for the grid search - */ - void set_doppler_step(unsigned int doppler_step) override; - - /*! - * \brief Initializes acquisition algorithm. - */ - void init() override; - - void set_local_code() override; - - /*! - * \brief Returns the maximum peak of grid search - */ - signed int mag() override; - - /*! - * \brief Restart acquisition algorithm - */ - void reset() override; - - /*! - * \brief If state = 1, it forces the block to start acquiring from the first sample - */ - void set_state(int state) override; - - /*! - * \brief Stop running acquisition - */ - void stop_acquisition() override; - - void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override {}; - private: - pcps_acquisition_fine_doppler_cc_sptr acquisition_cc_; - std::weak_ptr channel_fsm_; - std::vector> code_; - std::string item_type_; - std::string dump_filename_; - std::string role_; - Gnss_Synchro* gnss_synchro_; - int64_t fs_in_; - size_t item_size_; - float threshold_; - int doppler_max_; - int max_dwells_; - unsigned int vector_length_; - unsigned int channel_; - unsigned int doppler_step_; - unsigned int sampled_ms_; - unsigned int in_streams_; - unsigned int out_streams_; - bool dump_; + void code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) override; }; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h index b878f2de6..a0c39f894 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h @@ -28,9 +28,6 @@ /** \addtogroup Acq_adapters * \{ */ - -class ConfigurationInterface; - /*! * \brief This class adapts a PCPS acquisition block off-loaded on an FPGA * to an AcquisitionInterface for GPS L1 C/A signals diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.cc index 0bd82c2dc..1311f4d58 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.cc @@ -20,9 +20,8 @@ #include "gps_l1_ca_pcps_assisted_acquisition.h" #include "GPS_L1_CA.h" -#include "configuration_interface.h" -#include "gnss_sdr_flags.h" #include "gps_sdr_signal_replica.h" +#include "pcps_assisted_acquisition_cc.h" #if USE_GLOG_AND_GFLAGS #include @@ -35,156 +34,26 @@ GpsL1CaPcpsAssistedAcquisition::GpsL1CaPcpsAssistedAcquisition( const std::string& role, unsigned int in_streams, unsigned int out_streams) - : role_(role), - gnss_synchro_(nullptr), - item_size_(sizeof(gr_complex)), - threshold_(0.0), - doppler_max_(configuration->property(role + ".doppler_max", 5000)), - max_dwells_(configuration->property(role + ".max_dwells", 1)), - channel_(0), - doppler_step_(0), - sampled_ms_(configuration->property(role + ".coherent_integration_time_ms", 1)), - in_streams_(in_streams), - out_streams_(out_streams), - dump_(configuration->property(role + ".dump", false)) + : BasePcpsAcquisitionCustom( + configuration, + role, + in_streams, + out_streams, + GPS_L1_CA_CODE_RATE_CPS, + GPS_L1_CA_CODE_LENGTH_CHIPS, + GPS_L1_CA_CODE_PERIOD_MS, + false, + false) { - const std::string default_item_type("gr_complex"); - std::string default_dump_filename = "./data/acquisition.dat"; - dump_filename_ = configuration->property(role_ + ".dump_filename", std::move(default_dump_filename)); - item_type_ = configuration->property(role_ + ".item_type", default_item_type); - int64_t fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); - fs_in_ = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - -#if USE_GLOG_AND_GFLAGS - if (FLAGS_doppler_max != 0) + if (is_type_gr_complex()) { - doppler_max_ = FLAGS_doppler_max; - } -#else - if (absl::GetFlag(FLAGS_doppler_max) != 0) - { - doppler_max_ = absl::GetFlag(FLAGS_doppler_max); - } -#endif - doppler_min_ = configuration->property(role_ + ".doppler_min", -doppler_max_); - - bool enable_monitor_output = configuration->property("AcquisitionMonitor.enable_monitor", false); - - // --- Find number of samples per spreading code ------------------------- - vector_length_ = static_cast(round(fs_in_ / (GPS_L1_CA_CODE_RATE_CPS / GPS_L1_CA_CODE_LENGTH_CHIPS))); - - code_ = std::vector>(vector_length_); - - DLOG(INFO) << "role " << role_; - if (item_type_ == "gr_complex") - { - acquisition_cc_ = pcps_make_assisted_acquisition_cc(max_dwells_, sampled_ms_, - doppler_max_, doppler_min_, fs_in_, vector_length_, - dump_, dump_filename_, enable_monitor_output); - } - else - { - item_size_ = 0; - acquisition_cc_ = nullptr; - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - } - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 0) - { - LOG(ERROR) << "This implementation does not provide an output stream"; + acquisition_cc_ = pcps_make_assisted_acquisition_cc(acq_parameters_); + DLOG(INFO) << "acquisition(" << acquisition_cc_->unique_id() << ")"; } } -void GpsL1CaPcpsAssistedAcquisition::stop_acquisition() +void GpsL1CaPcpsAssistedAcquisition::code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) { - acquisition_cc_->set_active(false); - acquisition_cc_->set_state(0); -} - - -void GpsL1CaPcpsAssistedAcquisition::set_threshold(float threshold) -{ - threshold_ = threshold; - acquisition_cc_->set_threshold(threshold_); -} - - -void GpsL1CaPcpsAssistedAcquisition::set_doppler_max(unsigned int doppler_max) -{ - doppler_max_ = static_cast(doppler_max); - acquisition_cc_->set_doppler_max(doppler_max_); -} - - -void GpsL1CaPcpsAssistedAcquisition::set_doppler_step(unsigned int doppler_step) -{ - doppler_step_ = doppler_step; - acquisition_cc_->set_doppler_step(doppler_step_); -} - - -void GpsL1CaPcpsAssistedAcquisition::set_gnss_synchro(Gnss_Synchro* gnss_synchro) -{ - gnss_synchro_ = gnss_synchro; - acquisition_cc_->set_gnss_synchro(gnss_synchro_); -} - - -signed int GpsL1CaPcpsAssistedAcquisition::mag() -{ - return acquisition_cc_->mag(); -} - - -void GpsL1CaPcpsAssistedAcquisition::init() -{ - acquisition_cc_->init(); -} - - -void GpsL1CaPcpsAssistedAcquisition::set_local_code() -{ - gps_l1_ca_code_gen_complex_sampled(code_, gnss_synchro_->PRN, fs_in_, 0); - acquisition_cc_->set_local_code(code_.data()); -} - - -void GpsL1CaPcpsAssistedAcquisition::reset() -{ - acquisition_cc_->set_active(true); -} - - -void GpsL1CaPcpsAssistedAcquisition::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to disconnect, now the tracking uses gr_sync_decimator -} - - -void GpsL1CaPcpsAssistedAcquisition::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to disconnect, now the tracking uses gr_sync_decimator -} - - -gr::basic_block_sptr GpsL1CaPcpsAssistedAcquisition::get_left_block() -{ - return acquisition_cc_; -} - - -gr::basic_block_sptr GpsL1CaPcpsAssistedAcquisition::get_right_block() -{ - return acquisition_cc_; + gps_l1_ca_code_gen_complex_sampled(dest, prn, sampling_freq, 0); } diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.h index e5acbed3f..033a8ec17 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.h @@ -20,13 +20,7 @@ #ifndef GNSS_SDR_GPS_L1_CA_PCPS_ASSISTED_ACQUISITION_H #define GNSS_SDR_GPS_L1_CA_PCPS_ASSISTED_ACQUISITION_H -#include "channel_fsm.h" -#include "gnss_synchro.h" -#include "pcps_assisted_acquisition_cc.h" -#include -#include -#include -#include +#include "base_pcps_acquisition_custom.h" /** \addtogroup Acquisition * \{ */ @@ -34,13 +28,11 @@ * \{ */ -class ConfigurationInterface; - /*! * \brief This class adapts a PCPS acquisition block to an AcquisitionInterface * for GPS L1 C/A signals */ -class GpsL1CaPcpsAssistedAcquisition : public AcquisitionInterface +class GpsL1CaPcpsAssistedAcquisition : public BasePcpsAcquisitionCustom { public: GpsL1CaPcpsAssistedAcquisition( @@ -51,11 +43,6 @@ public: ~GpsL1CaPcpsAssistedAcquisition() = default; - inline std::string role() override - { - return role_; - } - /*! * \brief Returns "GPS_L1_CA_PCPS_Assisted_Acquisition" */ @@ -64,107 +51,8 @@ public: return "GPS_L1_CA_PCPS_Assisted_Acquisition"; } - inline size_t item_size() override - { - return item_size_; - } - - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and - * tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - - /*! - * \brief Set acquisition channel unique ID - */ - inline void set_channel(unsigned int channel) override - { - channel_ = channel; - acquisition_cc_->set_channel(channel_); - } - - /*! - * \brief Set channel fsm associated to this acquisition instance - */ - inline void set_channel_fsm(std::weak_ptr channel_fsm) override - { - channel_fsm_ = std::move(channel_fsm); - acquisition_cc_->set_channel_fsm(channel_fsm_); - } - - /*! - * \brief Set statistics threshold of PCPS algorithm - */ - void set_threshold(float threshold) override; - - /*! - * \brief Set maximum Doppler off grid search - */ - void set_doppler_max(unsigned int doppler_max) override; - - /*! - * \brief Set Doppler steps for the grid search - */ - void set_doppler_step(unsigned int doppler_step) override; - - /*! - * \brief Initializes acquisition algorithm. - */ - void init() override; - - void set_local_code() override; - - /*! - * \brief Returns the maximum peak of grid search - */ - signed int mag() override; - - /*! - * \brief Restart acquisition algorithm - */ - void reset() override; - void set_state(int state __attribute__((unused))) override {}; - - /*! - * \brief Stop running acquisition - */ - void stop_acquisition() override; - - void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override {}; - private: - pcps_assisted_acquisition_cc_sptr acquisition_cc_; - std::weak_ptr channel_fsm_; - std::vector> code_; - - std::string item_type_; - std::string dump_filename_; - std::string role_; - - Gnss_Synchro* gnss_synchro_; - - size_t item_size_; - int64_t fs_in_; - - float threshold_; - int doppler_max_; - int doppler_min_; - int max_dwells_; - unsigned int vector_length_; - unsigned int channel_; - unsigned int doppler_step_; - unsigned int sampled_ms_; - unsigned int in_streams_; - unsigned int out_streams_; - - bool dump_; + void code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) override; }; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.cc index c45abadf5..137b0a908 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.cc @@ -20,6 +20,7 @@ #include "configuration_interface.h" #include "gnss_sdr_flags.h" #include "gps_sdr_signal_replica.h" +#include "pcps_opencl_acquisition_cc.h" #include #include @@ -29,260 +30,38 @@ #include #endif -#if HAS_STD_SPAN -#include -namespace own = std; -#else -#include -namespace own = gsl_lite; -#endif GpsL1CaPcpsOpenClAcquisition::GpsL1CaPcpsOpenClAcquisition( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) - : configuration_(configuration), - gnss_synchro_(nullptr), - role_(role), - threshold_(0.0), - channel_(0), - doppler_step_(0), - in_streams_(in_streams), - out_streams_(out_streams) + : BasePcpsAcquisitionCustom( + configuration, + role, + in_streams, + out_streams, + GPS_L1_CA_CODE_RATE_CPS, + GPS_L1_CA_CODE_LENGTH_CHIPS, + GPS_L1_CA_CODE_PERIOD_MS, + true, + true), + opencl_ready_(false) { - const std::string default_item_type("gr_complex"); - std::string default_dump_filename = "./data/acquisition.dat"; - - DLOG(INFO) << "role " << role; - - item_type_ = configuration->property(role + ".item_type", - default_item_type); - - int64_t fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); - fs_in_ = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - dump_ = configuration->property(role + ".dump", false); - doppler_max_ = configuration->property(role + ".doppler_max", 5000); -#if USE_GLOG_AND_GFLAGS - if (FLAGS_doppler_max != 0) + if (is_type_gr_complex()) { - doppler_max_ = FLAGS_doppler_max; - } -#else - if (absl::GetFlag(FLAGS_doppler_max) != 0) - { - doppler_max_ = absl::GetFlag(FLAGS_doppler_max); - } -#endif - sampled_ms_ = configuration->property(role + ".coherent_integration_time_ms", 1); + const unsigned int max_dwells = acq_parameters_.bit_transition_flag ? 2 : acq_parameters_.max_dwells; + auto acquisition_cc = pcps_make_opencl_acquisition_cc(acq_parameters_, max_dwells); - bit_transition_flag_ = configuration->property("Acquisition.bit_transition_flag", false); + opencl_ready_ = acquisition_cc->opencl_ready(); + acquisition_cc_ = std::move(acquisition_cc); - if (!bit_transition_flag_) - { - max_dwells_ = configuration->property(role + ".max_dwells", 1); - } - else - { - max_dwells_ = 2; - } - - dump_filename_ = configuration->property(role + ".dump_filename", - default_dump_filename); - - // -- Find number of samples per spreading code ------------------------- - code_length_ = static_cast(round(fs_in_ / (GPS_L1_CA_CODE_RATE_CPS / GPS_L1_CA_CODE_LENGTH_CHIPS))); - - vector_length_ = code_length_ * sampled_ms_; - - code_ = std::vector>(vector_length_); - - if (item_type_ == "gr_complex") - { - item_size_ = sizeof(gr_complex); - acquisition_cc_ = pcps_make_opencl_acquisition_cc(sampled_ms_, max_dwells_, - doppler_max_, fs_in_, code_length_, code_length_, - bit_transition_flag_, dump_, dump_filename_, false); - - stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); - - DLOG(INFO) << "stream_to_vector(" << stream_to_vector_->unique_id() << ")"; DLOG(INFO) << "acquisition(" << acquisition_cc_->unique_id() << ")"; } - else - { - item_size_ = sizeof(gr_complex); - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - } - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 0) - { - LOG(ERROR) << "This implementation does not provide an output stream"; - } } -void GpsL1CaPcpsOpenClAcquisition::stop_acquisition() +void GpsL1CaPcpsOpenClAcquisition::code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) { - acquisition_cc_->set_active(false); - acquisition_cc_->set_state(0); -} - - -void GpsL1CaPcpsOpenClAcquisition::set_threshold(float threshold) -{ - float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", static_cast(0.0)); - - if (pfa == 0.0) - { - pfa = configuration_->property(role_ + ".pfa", static_cast(0.0)); - } - if (pfa == 0.0) - { - threshold_ = threshold; - } - else - { - threshold_ = calculate_threshold(pfa); - } - - DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold_; - - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_threshold(threshold_); - } -} - - -void GpsL1CaPcpsOpenClAcquisition::set_doppler_max(unsigned int doppler_max) -{ - doppler_max_ = doppler_max; - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_doppler_max(doppler_max_); - } -} - - -void GpsL1CaPcpsOpenClAcquisition::set_doppler_step(unsigned int doppler_step) -{ - doppler_step_ = doppler_step; - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_doppler_step(doppler_step_); - } -} - - -void GpsL1CaPcpsOpenClAcquisition::set_gnss_synchro(Gnss_Synchro* gnss_synchro) -{ - gnss_synchro_ = gnss_synchro; - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_gnss_synchro(gnss_synchro_); - } -} - - -signed int GpsL1CaPcpsOpenClAcquisition::mag() -{ - if (item_type_ == "gr_complex") - { - return acquisition_cc_->mag(); - } - else - { - return 0; - } -} - - -void GpsL1CaPcpsOpenClAcquisition::init() -{ - acquisition_cc_->init(); -} - - -void GpsL1CaPcpsOpenClAcquisition::set_local_code() -{ - if (item_type_ == "gr_complex") - { - std::vector> code(code_length_); - - gps_l1_ca_code_gen_complex_sampled(code, gnss_synchro_->PRN, fs_in_, 0); - - own::span code_span(code_.data(), vector_length_); - for (unsigned int i = 0; i < sampled_ms_; i++) - { - std::copy_n(code.data(), code_length_, code_span.subspan(i * code_length_, code_length_).data()); - } - - acquisition_cc_->set_local_code(code_.data()); - } -} - - -void GpsL1CaPcpsOpenClAcquisition::reset() -{ - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_active(true); - } -} - - -float GpsL1CaPcpsOpenClAcquisition::calculate_threshold(float pfa) const -{ - // Calculate the threshold - unsigned int frequency_bins = 0; - for (int doppler = static_cast(-doppler_max_); doppler <= static_cast(doppler_max_); doppler += static_cast(doppler_step_)) - { - frequency_bins++; - } - - DLOG(INFO) << "Channel " << channel_ << " Pfa = " << pfa; - - unsigned int ncells = vector_length_ * frequency_bins; - double exponent = 1 / static_cast(ncells); - double val = pow(1.0 - pfa, exponent); - auto lambda = static_cast(vector_length_); - boost::math::exponential_distribution mydist(lambda); - auto threshold = static_cast(quantile(mydist, val)); - - return threshold; -} - - -void GpsL1CaPcpsOpenClAcquisition::connect(gr::top_block_sptr top_block) -{ - if (item_type_ == "gr_complex") - { - top_block->connect(stream_to_vector_, 0, acquisition_cc_, 0); - } -} - - -void GpsL1CaPcpsOpenClAcquisition::disconnect(gr::top_block_sptr top_block) -{ - if (item_type_ == "gr_complex") - { - top_block->disconnect(stream_to_vector_, 0, acquisition_cc_, 0); - } -} - - -gr::basic_block_sptr GpsL1CaPcpsOpenClAcquisition::get_left_block() -{ - return stream_to_vector_; -} - - -gr::basic_block_sptr GpsL1CaPcpsOpenClAcquisition::get_right_block() -{ - return acquisition_cc_; + gps_l1_ca_code_gen_complex_sampled(dest, prn, sampling_freq, 0); } diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.h index 084c0a5c4..0eaa12efe 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_opencl_acquisition.h @@ -18,28 +18,18 @@ #ifndef GNSS_SDR_GPS_L1_CA_PCPS_OPENCL_ACQUISITION_H #define GNSS_SDR_GPS_L1_CA_PCPS_OPENCL_ACQUISITION_H -#include "channel_fsm.h" -#include "gnss_synchro.h" -#include "pcps_opencl_acquisition_cc.h" -#include -#include -#include -#include -#include +#include "base_pcps_acquisition_custom.h" /** \addtogroup Acquisition * \{ */ /** \addtogroup Acq_adapters * \{ */ - -class ConfigurationInterface; - /*! * \brief This class adapts an OpenCL PCPS acquisition block to an * AcquisitionInterface for GPS L1 C/A signals */ -class GpsL1CaPcpsOpenClAcquisition : public AcquisitionInterface +class GpsL1CaPcpsOpenClAcquisition : public BasePcpsAcquisitionCustom { public: GpsL1CaPcpsOpenClAcquisition(const ConfigurationInterface* configuration, @@ -49,11 +39,6 @@ public: ~GpsL1CaPcpsOpenClAcquisition() = default; - inline std::string role() override - { - return role_; - } - /*! * \brief Returns "GPS_L1_CA_PCPS_OpenCl_Acquisition" */ @@ -62,119 +47,15 @@ public: return "GPS_L1_CA_PCPS_OpenCl_Acquisition"; } - inline size_t item_size() override - { - return item_size_; - } - - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and - * tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - - /*! - * \brief Set acquisition channel unique ID - */ - inline void set_channel(unsigned int channel) override - { - channel_ = channel; - acquisition_cc_->set_channel(channel_); - } - - /*! - * \brief Set channel fsm associated to this acquisition instance - */ - inline void set_channel_fsm(std::weak_ptr channel_fsm) override - { - channel_fsm_ = std::move(channel_fsm); - acquisition_cc_->set_channel_fsm(channel_fsm_); - } - - /*! - * \brief Set statistics threshold of PCPS algorithm - */ - void set_threshold(float threshold) override; - - /*! - * \brief Set maximum Doppler off grid search - */ - void set_doppler_max(unsigned int doppler_max) override; - - /*! - * \brief Set Doppler steps for the grid search - */ - void set_doppler_step(unsigned int doppler_step) override; - - /*! - * \brief Initializes acquisition algorithm. - */ - void init() override; - - /*! - * \brief Sets local code for GPS L1/CA PCPS acquisition algorithm. - */ - void set_local_code() override; - - /*! - * \brief Returns the maximum peak of grid search - */ - signed int mag() override; - - /*! - * \brief Restart acquisition algorithm - */ - void reset() override; - void set_state(int state __attribute__((unused))) override {}; - - /*! - * \brief Stop running acquisition - */ - void stop_acquisition() override; - - void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override {}; - inline bool opencl_ready() const { - bool ready = this->acquisition_cc_->opencl_ready(); - return ready; + return opencl_ready_; } private: - float calculate_threshold(float pfa) const; - const ConfigurationInterface* configuration_; - pcps_opencl_acquisition_cc_sptr acquisition_cc_; - gr::blocks::stream_to_vector::sptr stream_to_vector_; - std::weak_ptr channel_fsm_; - std::vector> code_; - Gnss_Synchro* gnss_synchro_; + void code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) override; - std::string item_type_; - std::string dump_filename_; - std::string role_; - - int64_t fs_in_; - size_t item_size_; - - float threshold_; - - unsigned int vector_length_; - unsigned int code_length_; - unsigned int channel_; - unsigned int doppler_max_; - unsigned int doppler_step_; - unsigned int sampled_ms_; - unsigned int max_dwells_; - unsigned int in_streams_; - unsigned int out_streams_; - bool bit_transition_flag_; - bool dump_; + bool opencl_ready_; }; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.cc index b250ff51d..56e1adc3c 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.cc @@ -19,10 +19,9 @@ #include "gps_l1_ca_pcps_quicksync_acquisition.h" #include "GPS_L1_CA.h" #include "configuration_interface.h" -#include "gnss_sdr_flags.h" #include "gps_sdr_signal_replica.h" +#include "pcps_quicksync_acquisition_cc.h" #include -#include #if USE_GLOG_AND_GFLAGS #include @@ -30,247 +29,50 @@ #include #endif -#if HAS_STD_SPAN -#include -namespace own = std; -#else -#include -namespace own = gsl_lite; -#endif +namespace +{ +uint32_t get_folding_factor(const ConfigurationInterface* configuration, const std::string& role) +{ + const int64_t fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", static_cast(4000000)); + const auto fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + const auto code_length = static_cast(round(fs_in / (GPS_L1_CA_CODE_RATE_CPS / GPS_L1_CA_CODE_LENGTH_CHIPS))); + const auto folding_factor = static_cast(ceil(sqrt(log2(code_length)))); + return configuration->property(role + ".folding_factor", folding_factor); +} +} // namespace GpsL1CaPcpsQuickSyncAcquisition::GpsL1CaPcpsQuickSyncAcquisition( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) - : configuration_(configuration), - role_(role), - gnss_synchro_(nullptr), - item_size_(sizeof(gr_complex)), - threshold_(0.0), - channel_(0), - doppler_max_(configuration->property(role + ".doppler_max", 5000)), - doppler_step_(0), - sampled_ms_(configuration_->property(role + ".coherent_integration_time_ms", 4)), - in_streams_(in_streams), - out_streams_(out_streams), - bit_transition_flag_(configuration_->property(role + ".bit_transition_flag", false)), - dump_(configuration_->property(role + ".dump", false)) + : BasePcpsAcquisitionCustom( + configuration, + role, + in_streams, + out_streams, + GPS_L1_CA_CODE_RATE_CPS, + GPS_L1_CA_CODE_LENGTH_CHIPS, + GPS_L1_CA_CODE_PERIOD_MS * get_folding_factor(configuration, role), + true, + true), + folding_factor_(get_folding_factor(configuration, role)) { - const std::string default_item_type("gr_complex"); - std::string default_dump_filename = "./data/acquisition.dat"; - item_type_ = configuration_->property(role_ + ".item_type", default_item_type); - int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); - fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - -#if USE_GLOG_AND_GFLAGS - if (FLAGS_doppler_max != 0) + if (is_type_gr_complex()) { - doppler_max_ = FLAGS_doppler_max; - } -#else - if (absl::GetFlag(FLAGS_doppler_max) != 0) - { - doppler_max_ = absl::GetFlag(FLAGS_doppler_max); - } -#endif + // const int samples_per_ms = round(code_length_ / acq_parameters_.sampled_ms); + const unsigned int max_dwells = acq_parameters_.bit_transition_flag ? 2 : acq_parameters_.max_dwells; - // -- Find number of samples per spreading code ------------------------- - code_length_ = static_cast(round(fs_in_ / (GPS_L1_CA_CODE_RATE_CPS / GPS_L1_CA_CODE_LENGTH_CHIPS))); + acquisition_cc_ = pcps_quicksync_make_acquisition_cc(acq_parameters_, folding_factor_, vector_length_, max_dwells, code_length_); - /* Calculate the folding factor value */ - auto temp = static_cast(ceil(sqrt(log2(code_length_)))); - folding_factor_ = configuration_->property(role_ + ".folding_factor", temp); - - if (sampled_ms_ % folding_factor_ != 0) - { - LOG(WARNING) << "QuickSync Algorithm requires a coherent_integration_time" - << " multiple of " << folding_factor_ << "ms, Value entered " - << sampled_ms_ << " ms"; - if (sampled_ms_ < folding_factor_) - { - sampled_ms_ = static_cast(folding_factor_); - } - else - { - sampled_ms_ = static_cast(sampled_ms_ / folding_factor_) * folding_factor_; - } - - LOG(WARNING) << " Coherent_integration_time of " - << sampled_ms_ << " ms will be used instead."; - } - - vector_length_ = code_length_ * sampled_ms_; - - if (!bit_transition_flag_) - { - max_dwells_ = configuration_->property(role_ + ".max_dwells", 1); - } - else - { - max_dwells_ = 2; - } - - dump_filename_ = configuration_->property(role_ + ".dump_filename", std::move(default_dump_filename)); - - bool enable_monitor_output = configuration_->property("AcquisitionMonitor.enable_monitor", false); - - int samples_per_ms = round(code_length_); - code_ = std::vector>(code_length_); - - DLOG(INFO) << "role " << role_; - /* Object relevant information for debugging */ - LOG(INFO) << "Implementation: " << this->implementation() - << ", Vector Length: " << vector_length_ - << ", Samples per ms: " << samples_per_ms - << ", Folding factor: " << folding_factor_ - << ", Sampled ms: " << sampled_ms_ - << ", Code Length: " << code_length_; - - if (item_type_ == "gr_complex") - { - acquisition_cc_ = pcps_quicksync_make_acquisition_cc(folding_factor_, - sampled_ms_, max_dwells_, doppler_max_, fs_in_, - samples_per_ms, code_length_, bit_transition_flag_, - dump_, dump_filename_, enable_monitor_output); - - stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, - code_length_ * folding_factor_); - - DLOG(INFO) << "stream_to_vector_quicksync(" << stream_to_vector_->unique_id() << ")"; DLOG(INFO) << "acquisition(" << acquisition_cc_->unique_id() << ")"; } - else - { - item_size_ = 0; - acquisition_cc_ = nullptr; - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - } - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 0) - { - LOG(ERROR) << "This implementation does not provide an output stream"; - } } -void GpsL1CaPcpsQuickSyncAcquisition::stop_acquisition() +void GpsL1CaPcpsQuickSyncAcquisition::code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) { - acquisition_cc_->set_state(0); - acquisition_cc_->set_active(false); -} - - -void GpsL1CaPcpsQuickSyncAcquisition::set_threshold(float threshold) -{ - float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", static_cast(0.0)); - - if (pfa == 0.0) - { - pfa = configuration_->property(role_ + ".pfa", static_cast(0.0)); - } - if (pfa == 0.0) - { - threshold_ = threshold; - } - else - { - threshold_ = calculate_threshold(pfa); - } - - DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold_; - - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_threshold(threshold_); - } -} - - -void GpsL1CaPcpsQuickSyncAcquisition::set_doppler_max(unsigned int doppler_max) -{ - doppler_max_ = doppler_max; - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_doppler_max(doppler_max_); - } -} - - -void GpsL1CaPcpsQuickSyncAcquisition::set_doppler_step(unsigned int doppler_step) -{ - doppler_step_ = doppler_step; - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_doppler_step(doppler_step_); - } -} - - -void GpsL1CaPcpsQuickSyncAcquisition::set_gnss_synchro(Gnss_Synchro* gnss_synchro) -{ - gnss_synchro_ = gnss_synchro; - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_gnss_synchro(gnss_synchro_); - } -} - - -signed int GpsL1CaPcpsQuickSyncAcquisition::mag() -{ - if (item_type_ == "gr_complex") - { - return acquisition_cc_->mag(); - } - return 0; -} - - -void GpsL1CaPcpsQuickSyncAcquisition::init() -{ - acquisition_cc_->init(); -} - - -void GpsL1CaPcpsQuickSyncAcquisition::set_local_code() -{ - if (item_type_ == "gr_complex") - { - std::vector> code(code_length_); - - gps_l1_ca_code_gen_complex_sampled(code, gnss_synchro_->PRN, fs_in_, 0); - - own::span code_span(code_.data(), vector_length_); - for (unsigned int i = 0; i < (sampled_ms_ / folding_factor_); i++) - { - std::copy_n(code.data(), code_length_, code_span.subspan(i * code_length_, code_length_).data()); - } - - acquisition_cc_->set_local_code(code_.data()); - } -} - - -void GpsL1CaPcpsQuickSyncAcquisition::reset() -{ - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_active(true); - } -} - - -void GpsL1CaPcpsQuickSyncAcquisition::set_state(int state) -{ - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_state(state); - } + gps_l1_ca_code_gen_complex_sampled(dest, prn, sampling_freq, 0); } @@ -278,7 +80,7 @@ float GpsL1CaPcpsQuickSyncAcquisition::calculate_threshold(float pfa) const { // Calculate the threshold unsigned int frequency_bins = 0; - for (int doppler = static_cast(-doppler_max_); doppler <= static_cast(doppler_max_); doppler += static_cast(doppler_step_)) + for (int doppler = -acq_parameters_.doppler_max; doppler <= acq_parameters_.doppler_max; doppler += static_cast(acq_parameters_.doppler_step)) { frequency_bins++; } @@ -292,33 +94,3 @@ float GpsL1CaPcpsQuickSyncAcquisition::calculate_threshold(float pfa) const return threshold; } - - -void GpsL1CaPcpsQuickSyncAcquisition::connect(gr::top_block_sptr top_block) -{ - if (item_type_ == "gr_complex") - { - top_block->connect(stream_to_vector_, 0, acquisition_cc_, 0); - } -} - - -void GpsL1CaPcpsQuickSyncAcquisition::disconnect(gr::top_block_sptr top_block) -{ - if (item_type_ == "gr_complex") - { - top_block->disconnect(stream_to_vector_, 0, acquisition_cc_, 0); - } -} - - -gr::basic_block_sptr GpsL1CaPcpsQuickSyncAcquisition::get_left_block() -{ - return stream_to_vector_; -} - - -gr::basic_block_sptr GpsL1CaPcpsQuickSyncAcquisition::get_right_block() -{ - return acquisition_cc_; -} diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.h index 5ae294ae8..0f35073b5 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.h @@ -19,29 +19,18 @@ #ifndef GNSS_SDR_GPS_L1_CA_PCPS_QUICKSYNC_ACQUISITION_H #define GNSS_SDR_GPS_L1_CA_PCPS_QUICKSYNC_ACQUISITION_H -#include "channel_fsm.h" -#include "configuration_interface.h" -#include "gnss_synchro.h" -#include "pcps_quicksync_acquisition_cc.h" -#include -#include -#include -#include -#include +#include "base_pcps_acquisition_custom.h" /** \addtogroup Acquisition * \{ */ /** \addtogroup Acq_adapters * \{ */ - -class ConfigurationInterface; - /*! * \brief This class adapts a PCPS acquisition block to an AcquisitionInterface * for GPS L1 C/A signals */ -class GpsL1CaPcpsQuickSyncAcquisition : public AcquisitionInterface +class GpsL1CaPcpsQuickSyncAcquisition : public BasePcpsAcquisitionCustom { public: GpsL1CaPcpsQuickSyncAcquisition( @@ -52,11 +41,6 @@ public: ~GpsL1CaPcpsQuickSyncAcquisition() = default; - inline std::string role() override - { - return role_; - } - /*! * \brief Returns "GPS_L1_CA_PCPS_QuickSync_Acquisition" */ @@ -65,118 +49,11 @@ public: return "GPS_L1_CA_PCPS_QuickSync_Acquisition"; } - inline size_t item_size() override - { - return item_size_; - } - - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and - * tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - - /*! - * \brief Set acquisition channel unique ID - */ - inline void set_channel(unsigned int channel) override - { - channel_ = channel; - acquisition_cc_->set_channel(channel_); - } - - /*! - * \brief Set channel fsm associated to this acquisition instance - */ - inline void set_channel_fsm(std::weak_ptr channel_fsm) override - { - channel_fsm_ = std::move(channel_fsm); - acquisition_cc_->set_channel_fsm(channel_fsm_); - } - - /*! - * \brief Set statistics threshold of PCPS algorithm - */ - void set_threshold(float threshold) override; - - /*! - * \brief Set maximum Doppler off grid search - */ - void set_doppler_max(unsigned int doppler_max) override; - - /*! - * \brief Set Doppler steps for the grid search - */ - void set_doppler_step(unsigned int doppler_step) override; - - /*! - * \brief Initializes acquisition algorithm. - */ - void init() override; - - /*! - * \brief Sets local code for GPS L1/CA PCPS acquisition algorithm. - */ - void set_local_code() override; - - /*! - * \brief Returns the maximum peak of grid search - */ - signed int mag() override; - - /*! - * \brief Restart acquisition algorithm - */ - void reset() override; - - /*! - * \brief If state = 1, it forces the block to start acquiring from the first sample - */ - void set_state(int state) override; - - /*! - * \brief Stop running acquisition - */ - void stop_acquisition() override; - - void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override {}; - private: - float calculate_threshold(float pfa) const; + float calculate_threshold(float pfa) const override; + void code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) override; - const ConfigurationInterface* configuration_; - pcps_quicksync_acquisition_cc_sptr acquisition_cc_; - std::weak_ptr channel_fsm_; - - gr::blocks::stream_to_vector::sptr stream_to_vector_; - std::vector> code_; - std::string item_type_; - std::string dump_filename_; - std::string role_; - - Gnss_Synchro* gnss_synchro_; - - int64_t fs_in_; - size_t item_size_; - float threshold_; - unsigned int vector_length_; - unsigned int code_length_; - unsigned int channel_; - unsigned int doppler_max_; - unsigned int doppler_step_; - unsigned int sampled_ms_; - unsigned int max_dwells_; - unsigned int folding_factor_; - unsigned int in_streams_; - unsigned int out_streams_; - bool bit_transition_flag_; - bool dump_; + const unsigned int folding_factor_; }; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.cc index f16c10454..34b86b7e4 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.cc @@ -17,11 +17,9 @@ #include "gps_l1_ca_pcps_tong_acquisition.h" #include "GPS_L1_CA.h" -#include "configuration_interface.h" -#include "gnss_sdr_flags.h" #include "gps_sdr_signal_replica.h" +#include "pcps_tong_acquisition_cc.h" #include -#include #if USE_GLOG_AND_GFLAGS #include @@ -29,257 +27,37 @@ #include #endif -#if HAS_STD_SPAN -#include -namespace own = std; -#else -#include -namespace own = gsl_lite; -#endif GpsL1CaPcpsTongAcquisition::GpsL1CaPcpsTongAcquisition( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) - : configuration_(configuration), - gnss_synchro_(nullptr), - role_(role), - item_size_(sizeof(gr_complex)), - threshold_(0.0), - channel_(0), - doppler_max_(configuration->property(role + ".doppler_max", 5000)), - doppler_step_(0), - sampled_ms_(configuration_->property(role + ".coherent_integration_time_ms", 1)), - tong_init_val_(configuration->property(role + ".tong_init_val", 1)), - tong_max_val_(configuration->property(role + ".tong_max_val", 2)), - tong_max_dwells_(configuration->property(role + ".tong_max_dwells", tong_max_val_ + 1)), - in_streams_(in_streams), - out_streams_(out_streams), - dump_(configuration_->property(role + ".dump", false)) + : BasePcpsAcquisitionCustom( + configuration, + role, + in_streams, + out_streams, + GPS_L1_CA_CODE_RATE_CPS, + GPS_L1_CA_CODE_LENGTH_CHIPS, + GPS_L1_CA_CODE_PERIOD_MS, + true, + true) { - const std::string default_item_type("gr_complex"); - std::string default_dump_filename = "./data/acquisition.dat"; - - DLOG(INFO) << "role " << role_; - - item_type_ = configuration_->property(role_ + ".item_type", default_item_type); - int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); - fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - dump_filename_ = configuration_->property(role_ + ".dump_filename", std::move(default_dump_filename)); - -#if USE_GLOG_AND_GFLAGS - if (FLAGS_doppler_max != 0) + if (is_type_gr_complex()) { - doppler_max_ = FLAGS_doppler_max; - } -#else - if (absl::GetFlag(FLAGS_doppler_max) != 0) - { - doppler_max_ = absl::GetFlag(FLAGS_doppler_max); - } -#endif - bool enable_monitor_output = configuration_->property("AcquisitionMonitor.enable_monitor", false); + const auto tong_init_val = configuration->property(role + ".tong_init_val", 1U); + const auto tong_max_val = configuration->property(role + ".tong_max_val", 2U); + const auto tong_max_dwells = configuration->property(role + ".tong_max_dwells", tong_max_val + 1U); - // -- Find number of samples per spreading code ------------------------- - code_length_ = static_cast(round(fs_in_ / (GPS_L1_CA_CODE_RATE_CPS / GPS_L1_CA_CODE_LENGTH_CHIPS))); + acquisition_cc_ = pcps_tong_make_acquisition_cc(acq_parameters_, tong_init_val, tong_max_val, tong_max_dwells); - vector_length_ = code_length_ * sampled_ms_; - - code_ = std::vector>(vector_length_); - - if (item_type_ == "gr_complex") - { - acquisition_cc_ = pcps_tong_make_acquisition_cc(sampled_ms_, doppler_max_, fs_in_, - code_length_, code_length_, tong_init_val_, tong_max_val_, tong_max_dwells_, - dump_, dump_filename_, enable_monitor_output); - - stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); - - DLOG(INFO) << "stream_to_vector(" << stream_to_vector_->unique_id() << ")"; DLOG(INFO) << "acquisition(" << acquisition_cc_->unique_id() << ")"; } - else - { - acquisition_cc_ = nullptr; - item_size_ = 0; - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - } - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 0) - { - LOG(ERROR) << "This implementation does not provide an output stream"; - } } -void GpsL1CaPcpsTongAcquisition::stop_acquisition() +void GpsL1CaPcpsTongAcquisition::code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) { - acquisition_cc_->set_state(0); - acquisition_cc_->set_active(false); -} - - -void GpsL1CaPcpsTongAcquisition::set_threshold(float threshold) -{ - float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", static_cast(0.0)); - - if (pfa == 0.0) - { - pfa = configuration_->property(role_ + ".pfa", static_cast(0.0)); - } - if (pfa == 0.0) - { - threshold_ = threshold; - } - else - { - threshold_ = calculate_threshold(pfa); - } - - DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold_; - - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_threshold(threshold_); - } -} - - -void GpsL1CaPcpsTongAcquisition::set_doppler_max(unsigned int doppler_max) -{ - doppler_max_ = doppler_max; - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_doppler_max(doppler_max_); - } -} - - -void GpsL1CaPcpsTongAcquisition::set_doppler_step(unsigned int doppler_step) -{ - doppler_step_ = doppler_step; - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_doppler_step(doppler_step_); - } -} - - -void GpsL1CaPcpsTongAcquisition::set_gnss_synchro(Gnss_Synchro* gnss_synchro) -{ - gnss_synchro_ = gnss_synchro; - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_gnss_synchro(gnss_synchro_); - } -} - - -signed int GpsL1CaPcpsTongAcquisition::mag() -{ - if (item_type_ == "gr_complex") - { - return acquisition_cc_->mag(); - } - return 0; -} - - -void GpsL1CaPcpsTongAcquisition::init() -{ - acquisition_cc_->init(); -} - - -void GpsL1CaPcpsTongAcquisition::set_local_code() -{ - if (item_type_ == "gr_complex") - { - std::vector> code(code_length_); - - gps_l1_ca_code_gen_complex_sampled(code, gnss_synchro_->PRN, fs_in_, 0); - - own::span code_span(code_.data(), vector_length_); - for (unsigned int i = 0; i < sampled_ms_; i++) - { - std::copy_n(code.data(), code_length_, code_span.subspan(i * code_length_, code_length_).data()); - } - - acquisition_cc_->set_local_code(code_.data()); - } -} - - -void GpsL1CaPcpsTongAcquisition::reset() -{ - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_active(true); - } -} - - -void GpsL1CaPcpsTongAcquisition::set_state(int state) -{ - if (item_type_ == "gr_complex") - { - acquisition_cc_->set_state(state); - } -} - - -float GpsL1CaPcpsTongAcquisition::calculate_threshold(float pfa) const -{ - // Calculate the threshold - unsigned int frequency_bins = 0; - for (int doppler = static_cast(-doppler_max_); doppler <= static_cast(doppler_max_); doppler += static_cast(doppler_step_)) - { - frequency_bins++; - } - - DLOG(INFO) << "Channel " << channel_ << " Pfa = " << pfa; - - unsigned int ncells = vector_length_ * frequency_bins; - double exponent = 1 / static_cast(ncells); - double val = pow(1.0 - pfa, exponent); - auto lambda = static_cast(vector_length_); - boost::math::exponential_distribution mydist(lambda); - auto threshold = static_cast(quantile(mydist, val)); - - return threshold; -} - - -void GpsL1CaPcpsTongAcquisition::connect(gr::top_block_sptr top_block) -{ - if (item_type_ == "gr_complex") - { - top_block->connect(stream_to_vector_, 0, acquisition_cc_, 0); - } -} - - -void GpsL1CaPcpsTongAcquisition::disconnect(gr::top_block_sptr top_block) -{ - if (item_type_ == "gr_complex") - { - top_block->disconnect(stream_to_vector_, 0, acquisition_cc_, 0); - } -} - - -gr::basic_block_sptr GpsL1CaPcpsTongAcquisition::get_left_block() -{ - return stream_to_vector_; -} - - -gr::basic_block_sptr GpsL1CaPcpsTongAcquisition::get_right_block() -{ - return acquisition_cc_; + gps_l1_ca_code_gen_complex_sampled(dest, prn, sampling_freq, 0); } diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.h index 8cba53e04..b5b414390 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.h @@ -18,29 +18,18 @@ #ifndef GNSS_SDR_GPS_L1_CA_TONG_ACQUISITION_H #define GNSS_SDR_GPS_L1_CA_TONG_ACQUISITION_H -#include "channel_fsm.h" -#include "configuration_interface.h" -#include "gnss_synchro.h" -#include "pcps_tong_acquisition_cc.h" -#include -#include -#include -#include -#include +#include "base_pcps_acquisition_custom.h" /** \addtogroup Acquisition * \{ */ /** \addtogroup Acq_adapters * \{ */ - -class ConfigurationInterface; - /*! * \brief This class adapts a PCPS Tong acquisition block to an * AcquisitionInterface for GPS L1 C/A signals */ -class GpsL1CaPcpsTongAcquisition : public AcquisitionInterface +class GpsL1CaPcpsTongAcquisition : public BasePcpsAcquisitionCustom { public: GpsL1CaPcpsTongAcquisition(const ConfigurationInterface* configuration, @@ -50,11 +39,6 @@ public: ~GpsL1CaPcpsTongAcquisition() = default; - inline std::string role() override - { - return role_; - } - /*! * \brief Returns "GPS_L1_CA_PCPS_Tong_Acquisition" */ @@ -63,115 +47,8 @@ public: return "GPS_L1_CA_PCPS_Tong_Acquisition"; } - inline size_t item_size() override - { - return item_size_; - } - - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and - * tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - - /*! - * \brief Set acquisition channel unique ID - */ - inline void set_channel(unsigned int channel) override - { - channel_ = channel; - acquisition_cc_->set_channel(channel_); - } - - /*! - * \brief Set channel fsm associated to this acquisition instance - */ - inline void set_channel_fsm(std::weak_ptr channel_fsm) override - { - channel_fsm_ = std::move(channel_fsm); - acquisition_cc_->set_channel_fsm(channel_fsm_); - } - - /*! - * \brief Set statistics threshold of TONG algorithm - */ - void set_threshold(float threshold) override; - - /*! - * \brief Set maximum Doppler off grid search - */ - void set_doppler_max(unsigned int doppler_max) override; - - /*! - * \brief Set Doppler steps for the grid search - */ - void set_doppler_step(unsigned int doppler_step) override; - - /*! - * \brief Initializes acquisition algorithm. - */ - void init() override; - - /*! - * \brief Sets local code for GPS L1/CA TONG acquisition algorithm. - */ - void set_local_code() override; - - /*! - * \brief Returns the maximum peak of grid search - */ - signed int mag() override; - - /*! - * \brief Restart acquisition algorithm - */ - void reset() override; - - /*! - * \brief If state = 1, it forces the block to start acquiring from the first sample - */ - void set_state(int state) override; - - /*! - * \brief Stop running acquisition - */ - void stop_acquisition() override; - - void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override {}; - private: - float calculate_threshold(float pfa) const; - - const ConfigurationInterface* configuration_; - pcps_tong_acquisition_cc_sptr acquisition_cc_; - gr::blocks::stream_to_vector::sptr stream_to_vector_; - std::weak_ptr channel_fsm_; - std::vector> code_; - Gnss_Synchro* gnss_synchro_; - std::string item_type_; - std::string dump_filename_; - std::string role_; - int64_t fs_in_; - size_t item_size_; - float threshold_; - unsigned int vector_length_; - unsigned int code_length_; - unsigned int channel_; - unsigned int doppler_max_; - unsigned int doppler_step_; - unsigned int sampled_ms_; - unsigned int tong_init_val_; - unsigned int tong_max_val_; - unsigned int tong_max_dwells_; - unsigned int in_streams_; - unsigned int out_streams_; - bool dump_; + void code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) override; }; diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.cc index 118d668f5..23ee08b78 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.cc @@ -26,7 +26,15 @@ GpsL2MPcpsAcquisition::GpsL2MPcpsAcquisition( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : BasePcpsAcquisition(configuration, role, in_streams, out_streams, GPS_L2_M_CODE_RATE_CPS, GPS_L2C_OPT_ACQ_FS_SPS, GPS_L2_M_CODE_LENGTH_CHIPS, 20) + unsigned int out_streams) + : BasePcpsAcquisition(configuration, + role, + in_streams, + out_streams, + GPS_L2_M_CODE_RATE_CPS, + GPS_L2C_OPT_ACQ_FS_SPS, + GPS_L2_M_CODE_LENGTH_CHIPS, + GPS_L2_M_CODE_PERIOD_MS) { } diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.h b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.h index 10a5ff8fc..0dbae3b9e 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.h @@ -27,9 +27,6 @@ /** \addtogroup Acq_adapters * \{ */ - -class ConfigurationInterface; - /*! * \brief This class adapts a PCPS acquisition block to an AcquisitionInterface * for GPS L2 M signals diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h index ea4f2536a..67c7c1b4b 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h @@ -27,9 +27,6 @@ /** \addtogroup Acq_adapters * \{ */ - -class ConfigurationInterface; - /*! * \brief This class adapts a PCPS acquisition block off-loaded on an FPGA * to an AcquisitionInterface for GPS L2 M signals diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.cc index eecd5d478..771bf8fc1 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.cc @@ -26,7 +26,15 @@ GpsL5iPcpsAcquisition::GpsL5iPcpsAcquisition( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : BasePcpsAcquisition(configuration, role, in_streams, out_streams, GPS_L5I_CODE_RATE_CPS, GPS_L5_OPT_ACQ_FS_SPS, GPS_L5I_CODE_LENGTH_CHIPS, 1) + unsigned int out_streams) + : BasePcpsAcquisition(configuration, + role, + in_streams, + out_streams, + GPS_L5I_CODE_RATE_CPS, + GPS_L5_OPT_ACQ_FS_SPS, + GPS_L5I_CODE_LENGTH_CHIPS, + GPS_L5I_PERIOD_MS) { } diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.h b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.h index 7fad5c612..4c1bd5299 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.h @@ -27,9 +27,6 @@ /** \addtogroup Acq_adapters * \{ */ - -class ConfigurationInterface; - /*! * \brief This class adapts a PCPS acquisition block to an AcquisitionInterface * for GPS L5i signals diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h index ff0f6444d..efa18df02 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h @@ -28,9 +28,6 @@ /** \addtogroup Acq_adapters * \{ */ - -class ConfigurationInterface; - /*! * \brief This class adapts a PCPS acquisition block off-loaded on an FPGA * to an AcquisitionInterface for GPS L5i signals diff --git a/src/algorithms/acquisition/gnuradio_blocks/CMakeLists.txt b/src/algorithms/acquisition/gnuradio_blocks/CMakeLists.txt index de689f5b3..aa049ae86 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/acquisition/gnuradio_blocks/CMakeLists.txt @@ -17,6 +17,7 @@ set(ACQ_GR_BLOCKS_SOURCES ) set(ACQ_GR_BLOCKS_HEADERS + acquisition_impl_interface.h pcps_acquisition.h pcps_assisted_acquisition_cc.h pcps_acquisition_fine_doppler_cc.h diff --git a/src/algorithms/acquisition/gnuradio_blocks/acquisition_impl_interface.h b/src/algorithms/acquisition/gnuradio_blocks/acquisition_impl_interface.h new file mode 100644 index 000000000..3a1c28bdd --- /dev/null +++ b/src/algorithms/acquisition/gnuradio_blocks/acquisition_impl_interface.h @@ -0,0 +1,70 @@ +/*! + * \file acquisition_impl_interface.h + * \brief Header file of the interface to an acquisition implementation GNSS block. + * \author Mathieu Favraeu, 2025. favreau.mathieu(at)hotmail.com + * + * This header file contains the interface to an abstract class + * for acquisition algorithms. Since all its methods are virtual, + * this class cannot be instantiated directly, and a subclass can only be + * instantiated directly if all inherited pure virtual methods have been + * implemented by that class or a parent class. + * + * ----------------------------------------------------------------------------- + * + * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + * This file is part of GNSS-SDR. + * + * Copyright (C) 2010-2025 (see AUTHORS file for a list of contributors) + * SPDX-License-Identifier: GPL-3.0-or-later + * + * ----------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_ACQUISITION_IMPL_INTERFACE_H +#define GNSS_SDR_ACQUISITION_IMPL_INTERFACE_H + +#include "gnss_block_interface.h" +#include "gnss_synchro.h" +#include +#include +#include + +/** \addtogroup Core + * \{ */ +/** \addtogroup GNSS_Block_Interfaces GNSS block interfaces + * GNSS block interfaces. + * \{ */ + +class ChannelFsm; +class acquisition_impl_interface; + +using acquisition_impl_interface_sptr = gnss_shared_ptr; + +/*! \brief This abstract class represents an interface to an acquisition GNSS block. + * + * Abstract class for acquisition algorithms. Since all its methods are virtual, + * this class cannot be instantiated directly, and a subclass can only be + * instantiated directly if all inherited pure virtual methods have been + * implemented by that class or a parent class. + */ +class acquisition_impl_interface : public gr::block +{ +public: + acquisition_impl_interface(const std::string& name, + gr::io_signature::sptr input_signature, + gr::io_signature::sptr output_signature) : gr::block(name, std::move(input_signature), std::move(output_signature)) {} + + virtual void set_gnss_synchro(Gnss_Synchro* gnss_synchro) = 0; + virtual void set_channel(uint32_t channel_id) = 0; + virtual void set_channel_fsm(std::weak_ptr channel_fsm) = 0; + virtual void set_threshold(float threshold) = 0; + virtual void set_local_code(std::complex* /*code*/) {}; + virtual void set_local_code(std::complex* /*code_data*/, std::complex* /*code_pilot*/) {}; + virtual uint32_t mag() const = 0; + virtual void set_active(bool active) = 0; +}; + + +/** \} */ +/** \} */ +#endif // GNSS_SDR_ACQUISITION_INTERFACE */ diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc index b9e962959..66a686a76 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc @@ -39,86 +39,60 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc_sptr galileo_e5a_noncoherentIQ_make_acquisition_caf_cc( - unsigned int sampled_ms, - unsigned int max_dwells, - unsigned int doppler_max, int64_t fs_in, - int samples_per_ms, int samples_per_code, - bool bit_transition_flag, - bool dump, - const std::string &dump_filename, - bool both_signal_components_, - int CAF_window_hz_, - int Zero_padding_, - bool enable_monitor_output) + const Acq_Conf &conf, + bool both_signal_components, + int CAF_window_hz, + int Zero_padding) { return galileo_e5a_noncoherentIQ_acquisition_caf_cc_sptr( - new galileo_e5a_noncoherentIQ_acquisition_caf_cc(sampled_ms, max_dwells, doppler_max, fs_in, samples_per_ms, - samples_per_code, bit_transition_flag, dump, dump_filename, both_signal_components_, CAF_window_hz_, Zero_padding_, enable_monitor_output)); + new galileo_e5a_noncoherentIQ_acquisition_caf_cc(conf, both_signal_components, CAF_window_hz, Zero_padding)); } galileo_e5a_noncoherentIQ_acquisition_caf_cc::galileo_e5a_noncoherentIQ_acquisition_caf_cc( - unsigned int sampled_ms, - unsigned int max_dwells, - unsigned int doppler_max, - int64_t fs_in, - int samples_per_ms, - int samples_per_code, - bool bit_transition_flag, - bool dump, - const std::string &dump_filename, - bool both_signal_components_, - int CAF_window_hz_, - int Zero_padding_, - bool enable_monitor_output) - : gr::block("galileo_e5a_noncoherentIQ_acquisition_caf_cc", + const Acq_Conf &conf, + bool both_signal_components, + int CAF_window_hz, + int Zero_padding) + : acquisition_impl_interface("galileo_e5a_noncoherentIQ_acquisition_caf_cc", gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(0, 1, sizeof(Gnss_Synchro))), - d_dump_filename(dump_filename), + d_acq_params(conf), d_gnss_synchro(nullptr), - d_fs_in(fs_in), d_sample_counter(0ULL), d_threshold(0), - d_doppler_freq(0), d_mag(0), d_input_power(0.0), d_test_statistics(0), d_state(0), - d_samples_per_ms(samples_per_ms), - d_samples_per_code(samples_per_code), - d_CAF_window_hz(CAF_window_hz_), + d_CAF_window_hz(CAF_window_hz), d_buffer_count(0), d_doppler_resolution(0), - d_doppler_max(static_cast(doppler_max)), - d_doppler_step(250), - d_fft_size(static_cast(sampled_ms) * d_samples_per_ms), + d_fft_size(static_cast(conf.sampled_ms) * conf.samples_per_ms), d_num_doppler_bins(0), d_gr_stream_buffer(0), d_channel(0), - d_max_dwells(max_dwells), d_well_count(0), d_code_phase(0), - d_bit_transition_flag(bit_transition_flag), d_active(false), - d_dump(dump), - d_both_signal_components(both_signal_components_), - d_enable_monitor_output(enable_monitor_output) + d_both_signal_components(both_signal_components), + d_fft_if(gnss_fft_fwd_make_unique(d_fft_size)), + d_ifft(gnss_fft_rev_make_unique(d_fft_size)), + d_fft_code_I_A(d_fft_size), + d_inbuffer(d_fft_size), + d_magnitudeIA(d_fft_size) { this->message_port_register_out(pmt::mp("events")); - if (Zero_padding_ > 0) + if (Zero_padding > 0) { d_sampled_ms = 1; } else { - d_sampled_ms = sampled_ms; + d_sampled_ms = conf.sampled_ms; } - d_inbuffer = std::vector(d_fft_size); - d_fft_code_I_A = std::vector(d_fft_size); - d_magnitudeIA = std::vector(d_fft_size); - if (d_both_signal_components == true) { d_fft_code_Q_A = std::vector(d_fft_size); @@ -137,8 +111,34 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc::galileo_e5a_noncoherentIQ_acquisit } } - d_fft_if = gnss_fft_fwd_make_unique(d_fft_size); - d_ifft = gnss_fft_rev_make_unique(d_fft_size); + // Count the number of bins + d_num_doppler_bins = 0; + for (int doppler = -d_acq_params.doppler_max; doppler <= d_acq_params.doppler_max; doppler += d_acq_params.doppler_step) + { + d_num_doppler_bins++; + } + + // Create the carrier Doppler wipeoff signals + d_grid_doppler_wipeoffs = std::vector>(d_num_doppler_bins, std::vector(d_fft_size)); + for (int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + { + int doppler = -d_acq_params.doppler_max + d_acq_params.doppler_step * doppler_index; + float phase_step_rad = static_cast(TWO_PI) * static_cast(doppler) / static_cast(d_acq_params.fs_in); + std::array _phase{}; + volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index].data(), -phase_step_rad, _phase.data(), d_fft_size); + } + + /* CAF Filtering to resolve doppler ambiguity. Phase and quadrature must be processed + * separately before non-coherent integration */ + if (d_CAF_window_hz > 0) + { + d_CAF_vector = std::vector(d_num_doppler_bins); + d_CAF_vector_I = std::vector(d_num_doppler_bins); + if (d_both_signal_components == true) + { + d_CAF_vector_Q = std::vector(d_num_doppler_bins); + } + } } @@ -146,14 +146,14 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc::~galileo_e5a_noncoherentIQ_acquisi { try { - if (d_dump) + if (d_acq_params.dump) { d_dump_file.close(); } } catch (const std::ofstream::failure &e) { - std::cerr << "Problem closing Acquisition dump file: " << d_dump_filename << '\n'; + std::cerr << "Problem closing Acquisition dump file: " << d_acq_params.dump_filename << '\n'; } catch (const std::exception &e) { @@ -193,11 +193,11 @@ void galileo_e5a_noncoherentIQ_acquisition_caf_cc::set_local_code(std::complexget_inbuf())[0], &codeI[0], &minus_one, - d_samples_per_code); + static_cast(d_acq_params.samples_per_code)); #else volk_32fc_s32fc_multiply_32fc(&(d_fft_if->get_inbuf())[0], &codeI[0], gr_complex(-1, 0), - d_samples_per_code); + static_cast(d_acq_params.samples_per_code)); #endif d_fft_if->execute(); // We need the FFT of local code @@ -211,11 +211,11 @@ void galileo_e5a_noncoherentIQ_acquisition_caf_cc::set_local_code(std::complexget_inbuf())[0], &codeQ[0], &minus_one, - d_samples_per_code); + static_cast(d_acq_params.samples_per_code)); #else volk_32fc_s32fc_multiply_32fc(&(d_fft_if->get_inbuf())[0], &codeQ[0], gr_complex(-1, 0), - d_samples_per_code); + static_cast(d_acq_params.samples_per_code)); #endif d_fft_if->execute(); // We need the FFT of local code @@ -226,77 +226,6 @@ void galileo_e5a_noncoherentIQ_acquisition_caf_cc::set_local_code(std::complexFlag_valid_acquisition = false; - d_gnss_synchro->Flag_valid_symbol_output = false; - d_gnss_synchro->Flag_valid_pseudorange = false; - d_gnss_synchro->Flag_valid_word = false; - - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_doppler_step = 0U; - d_gnss_synchro->Acq_samplestamp_samples = 0ULL; - d_mag = 0.0; - d_input_power = 0.0; - - // Count the number of bins - d_num_doppler_bins = 0; - for (int doppler = -d_doppler_max; - doppler <= d_doppler_max; - doppler += d_doppler_step) - { - d_num_doppler_bins++; - } - - // Create the carrier Doppler wipeoff signals - d_grid_doppler_wipeoffs = std::vector>(d_num_doppler_bins, std::vector(d_fft_size)); - for (int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) - { - int doppler = -d_doppler_max + d_doppler_step * doppler_index; - float phase_step_rad = static_cast(TWO_PI) * static_cast(doppler) / static_cast(d_fs_in); - std::array _phase{}; - volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index].data(), -phase_step_rad, _phase.data(), d_fft_size); - } - - /* CAF Filtering to resolve doppler ambiguity. Phase and quadrature must be processed - * separately before non-coherent integration */ - if (d_CAF_window_hz > 0) - { - d_CAF_vector = std::vector(d_num_doppler_bins); - d_CAF_vector_I = std::vector(d_num_doppler_bins); - if (d_both_signal_components == true) - { - d_CAF_vector_Q = std::vector(d_num_doppler_bins); - } - } -} - - -void galileo_e5a_noncoherentIQ_acquisition_caf_cc::set_state(int state) -{ - d_state = state; - if (d_state == 1) - { - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0ULL; - d_gnss_synchro->Acq_doppler_step = 0U; - d_well_count = 0; - d_mag = 0.0; - d_input_power = 0.0; - d_test_statistics = 0.0; - } - else if (d_state == 0) - { - } - else - { - LOG(ERROR) << "State can only be set to 0 or 1"; - } -} - - int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) @@ -315,6 +244,14 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items int acquisition_message = -1; // 0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL int return_value = 0; // 0=Produces no Gnss_Synchro objects + + if (!d_active) + { + d_sample_counter += static_cast(ninput_items[0]); // sample counter + consume_each(ninput_items[0]); + return 0; + } + /* States: 0 Stop Channel * 1 Load the buffer until it reaches fft_size * 2 Acquisition algorithm @@ -325,22 +262,16 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items { case 0: { - if (d_active) - { - // restart acquisition variables - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0ULL; - d_gnss_synchro->Acq_doppler_step = 0U; - d_well_count = 0; - d_mag = 0.0; - d_input_power = 0.0; - d_test_statistics = 0.0; - d_state = 1; - } - d_sample_counter += static_cast(ninput_items[0]); // sample counter - consume_each(ninput_items[0]); - + // restart acquisition variables + d_gnss_synchro->Acq_delay_samples = 0.0; + d_gnss_synchro->Acq_doppler_hz = 0.0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; + d_gnss_synchro->Acq_doppler_step = 0U; + d_well_count = 0; + d_mag = 0.0; + d_input_power = 0.0; + d_test_statistics = 0.0; + d_state = 1; break; } case 1: @@ -396,8 +327,8 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items DLOG(INFO) << "Channel: " << d_channel << " , doing acquisition of satellite: " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN << " ,sample stamp: " << d_sample_counter << ", threshold: " - << d_threshold << ", doppler_max: " << d_doppler_max - << ", doppler_step: " << d_doppler_step; + << d_threshold << ", doppler_max: " << d_acq_params.doppler_max + << ", doppler_step: " << d_acq_params.doppler_step; // 1- Compute the input signal power estimation volk_32fc_magnitude_squared_32f(d_magnitudeIA.data(), d_inbuffer.data(), d_fft_size); @@ -408,7 +339,7 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items for (int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { // doppler search steps - doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + doppler = -d_acq_params.doppler_max + d_acq_params.doppler_step * doppler_index; volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), d_inbuffer.data(), d_grid_doppler_wipeoffs[doppler_index].data(), d_fft_size); @@ -574,19 +505,19 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items // the maximum test statistics in the previous dwell is greater than // current d_mag/d_input_power). Note that d_test_statistics is not // restarted between consecutive dwells in multidwell operation. - if (d_test_statistics < (d_mag / d_input_power) || !d_bit_transition_flag) + if (d_test_statistics < (d_mag / d_input_power) || !d_acq_params.bit_transition_flag) { - d_gnss_synchro->Acq_delay_samples = static_cast(indext % d_samples_per_code); + d_gnss_synchro->Acq_delay_samples = static_cast(indext % static_cast(d_acq_params.samples_per_code)); d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; - d_gnss_synchro->Acq_doppler_step = d_doppler_step; + d_gnss_synchro->Acq_doppler_step = d_acq_params.doppler_step; // 5- Compute the test statistics and compare to the threshold d_test_statistics = d_mag / d_input_power; } } // Record results to file if required - if (d_dump) + if (d_acq_params.dump) { std::stringstream filename; std::streamsize n = sizeof(float) * (d_fft_size); // noncomplex file write @@ -618,7 +549,7 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items { int CAF_bins_half; std::array accum{}; - CAF_bins_half = d_CAF_window_hz / (2 * d_doppler_step); + CAF_bins_half = d_CAF_window_hz / (2 * d_acq_params.doppler_step); float weighting_factor; weighting_factor = 0.5F / static_cast(CAF_bins_half); // weighting_factor = 0; @@ -686,10 +617,10 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items // Recompute the maximum doppler peak volk_gnsssdr_32f_index_max_32u(&indext, d_CAF_vector.data(), d_num_doppler_bins); - doppler = -d_doppler_max + d_doppler_step * static_cast(indext); + doppler = -d_acq_params.doppler_max + d_acq_params.doppler_step * static_cast(indext); d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); // Dump if required, appended at the end of the file - if (d_dump) + if (d_acq_params.dump) { std::stringstream filename; std::streamsize n = sizeof(float) * (d_num_doppler_bins); // noncomplex file write @@ -701,7 +632,7 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items } } - if (d_well_count == d_max_dwells) + if (d_well_count == d_acq_params.max_dwells) { if (d_test_statistics > d_threshold) { @@ -743,7 +674,7 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items consume_each(ninput_items[0]); // Copy and push current Gnss_Synchro to monitor queue - if (d_enable_monitor_output) + if (d_acq_params.enable_monitor_output) { auto **out = reinterpret_cast(&output_items[0]); Gnss_Synchro current_synchro_data = Gnss_Synchro(); diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.h b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.h index f3230ae74..3b8758cd8 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.h @@ -24,6 +24,8 @@ #ifndef GNSS_SDR_GALILEO_E5A_NONCOHERENT_IQ_ACQUISITION_CAF_CC_H #define GNSS_SDR_GALILEO_E5A_NONCOHERENT_IQ_ACQUISITION_CAF_CC_H +#include "acq_conf.h" +#include "acquisition_impl_interface.h" #include "channel_fsm.h" #include "gnss_sdr_fft.h" #include "gnss_synchro.h" @@ -46,17 +48,10 @@ class galileo_e5a_noncoherentIQ_acquisition_caf_cc; using galileo_e5a_noncoherentIQ_acquisition_caf_cc_sptr = gnss_shared_ptr; galileo_e5a_noncoherentIQ_acquisition_caf_cc_sptr galileo_e5a_noncoherentIQ_make_acquisition_caf_cc( - unsigned int sampled_ms, - unsigned int max_dwells, - unsigned int doppler_max, int64_t fs_in, - int samples_per_ms, int samples_per_code, - bool bit_transition_flag, - bool dump, - const std::string& dump_filename, - bool both_signal_components_, - int CAF_window_hz_, - int Zero_padding_, - bool enable_monitor_output); + const Acq_Conf& conf, + bool both_signal_components, + int CAF_window_hz, + int Zero_padding); /*! * \brief This class implements a Parallel Code Phase Search Acquisition. @@ -64,7 +59,7 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc_sptr galileo_e5a_noncoherentIQ_make * Check \ref Navitec2012 "An Open Source Galileo E1 Software Receiver", * Algorithm 1, for a pseudocode description of this implementation. */ -class galileo_e5a_noncoherentIQ_acquisition_caf_cc : public gr::block +class galileo_e5a_noncoherentIQ_acquisition_caf_cc : public acquisition_impl_interface { public: /*! @@ -77,7 +72,7 @@ public: * to exchange synchronization data between acquisition and tracking blocks. * \param p_gnss_synchro Satellite information shared by the processing blocks. */ - inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) + inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override { d_gnss_synchro = p_gnss_synchro; } @@ -85,44 +80,37 @@ public: /*! * \brief Returns the maximum peak of grid search. */ - inline unsigned int mag() const + inline unsigned int mag() const override { return d_mag; } - /*! - * \brief Initializes acquisition algorithm. - */ - void init(); - /*! * \brief Sets local code for PCPS acquisition algorithm. * \param code - Pointer to the PRN code. */ - void set_local_code(std::complex* code, std::complex* codeQ); + void set_local_code(std::complex* code, std::complex* codeQ) override; /*! * \brief Starts acquisition algorithm, turning from standby mode to * active mode * \param active - bool that activates/deactivates the block. */ - inline void set_active(bool active) + inline void set_active(bool active) override { + if (!active) + { + d_state = 0; + } + d_active = active; } - /*! - * \brief If set to 1, ensures that acquisition starts at the - * first available sample. - * \param state - int=1 forces start of acquisition - */ - void set_state(int state); - /*! * \brief Set acquisition channel unique ID * \param channel - receiver channel. */ - inline void set_channel(unsigned int channel) + inline void set_channel(unsigned int channel) override { d_channel = channel; } @@ -130,7 +118,7 @@ public: /*! * \brief Set channel fsm associated to this acquisition instance */ - inline void set_channel_fsm(std::weak_ptr channel_fsm) + inline void set_channel_fsm(std::weak_ptr channel_fsm) override { d_channel_fsm = std::move(channel_fsm); } @@ -140,69 +128,66 @@ public: * \param threshold - Threshold for signal detection (check \ref Navitec2012, * Algorithm 1, for a definition of this threshold). */ - inline void set_threshold(float threshold) + inline void set_threshold(float threshold) override { d_threshold = threshold; } - /*! - * \brief Set maximum Doppler grid search - * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz]. - */ - inline void set_doppler_max(unsigned int doppler_max) - { - d_doppler_max = doppler_max; - } - - /*! - * \brief Set Doppler steps for the grid search - * \param doppler_step - Frequency bin of the search grid [Hz]. - */ - inline void set_doppler_step(unsigned int doppler_step) - { - d_doppler_step = doppler_step; - } - /*! * \brief Parallel Code Phase Search Acquisition signal processing. */ int general_work(int noutput_items, gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items); + gr_vector_void_star& output_items) override; private: friend galileo_e5a_noncoherentIQ_acquisition_caf_cc_sptr galileo_e5a_noncoherentIQ_make_acquisition_caf_cc( - unsigned int sampled_ms, - unsigned int max_dwells, - unsigned int doppler_max, int64_t fs_in, - int samples_per_ms, int samples_per_code, - bool bit_transition_flag, - bool dump, - const std::string& dump_filename, - bool both_signal_components_, - int CAF_window_hz_, - int Zero_padding_, - bool enable_monitor_output); + const Acq_Conf& conf, + bool both_signal_components, + int CAF_window_hz, + int Zero_padding); galileo_e5a_noncoherentIQ_acquisition_caf_cc( - unsigned int sampled_ms, - unsigned int max_dwells, - unsigned int doppler_max, int64_t fs_in, - int samples_per_ms, int samples_per_code, - bool bit_transition_flag, - bool dump, - const std::string& dump_filename, - bool both_signal_components_, - int CAF_window_hz_, - int Zero_padding_, - bool enable_monitor_output); + const Acq_Conf& conf, + bool both_signal_components, + int CAF_window_hz, + int Zero_padding); void calculate_magnitudes(gr_complex* fft_begin, int doppler_shift, int doppler_offset); float estimate_input_power(gr_complex* in); + std::string d_satellite_str; + + const Acq_Conf d_acq_params; + std::ofstream d_dump_file; + + Gnss_Synchro* d_gnss_synchro; + + uint64_t d_sample_counter; + + float d_threshold; + float d_mag; + float d_input_power; + float d_test_statistics; + + int d_state; + const int d_CAF_window_hz; + int d_buffer_count; + int d_doppler_resolution; + const int d_fft_size; + int d_num_doppler_bins; + unsigned int d_gr_stream_buffer; + unsigned int d_channel; + unsigned int d_well_count; + unsigned int d_sampled_ms; + unsigned int d_code_phase; + + bool d_active; + const bool d_both_signal_components; + std::weak_ptr d_channel_fsm; std::unique_ptr d_fft_if; std::unique_ptr d_ifft; @@ -220,45 +205,6 @@ private: std::vector d_CAF_vector; std::vector d_CAF_vector_I; std::vector d_CAF_vector_Q; - - std::string d_satellite_str; - std::string d_dump_filename; - - std::ofstream d_dump_file; - - Gnss_Synchro* d_gnss_synchro; - - int64_t d_fs_in; - uint64_t d_sample_counter; - - float d_threshold; - float d_doppler_freq; - float d_mag; - float d_input_power; - float d_test_statistics; - - int d_state; - int d_samples_per_ms; - int d_samples_per_code; - int d_CAF_window_hz; - int d_buffer_count; - int d_doppler_resolution; - int d_doppler_max; - int d_doppler_step; - int d_fft_size; - int d_num_doppler_bins; - unsigned int d_gr_stream_buffer; - unsigned int d_channel; - unsigned int d_max_dwells; - unsigned int d_well_count; - unsigned int d_sampled_ms; - unsigned int d_code_phase; - - bool d_bit_transition_flag; - bool d_active; - bool d_dump; - bool d_both_signal_components; - bool d_enable_monitor_output; }; diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc index d684dd7da..aa4397e4e 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc @@ -31,69 +31,53 @@ #include #endif -galileo_pcps_8ms_acquisition_cc_sptr galileo_pcps_8ms_make_acquisition_cc( - uint32_t sampled_ms, - uint32_t max_dwells, - uint32_t doppler_max, - int64_t fs_in, - int32_t samples_per_ms, - int32_t samples_per_code, - bool dump, - const std::string &dump_filename, - bool enable_monitor_output) +galileo_pcps_8ms_acquisition_cc_sptr galileo_pcps_8ms_make_acquisition_cc(const Acq_Conf &conf) { - return galileo_pcps_8ms_acquisition_cc_sptr( - new galileo_pcps_8ms_acquisition_cc(sampled_ms, max_dwells, doppler_max, fs_in, samples_per_ms, - samples_per_code, dump, dump_filename, enable_monitor_output)); + return galileo_pcps_8ms_acquisition_cc_sptr(new galileo_pcps_8ms_acquisition_cc(conf)); } -galileo_pcps_8ms_acquisition_cc::galileo_pcps_8ms_acquisition_cc( - uint32_t sampled_ms, - uint32_t max_dwells, - uint32_t doppler_max, - int64_t fs_in, - int32_t samples_per_ms, - int32_t samples_per_code, - bool dump, - const std::string &dump_filename, - bool enable_monitor_output) - : gr::block("galileo_pcps_8ms_acquisition_cc", - gr::io_signature::make(1, 1, static_cast(sizeof(gr_complex) * sampled_ms * samples_per_ms)), +galileo_pcps_8ms_acquisition_cc::galileo_pcps_8ms_acquisition_cc(const Acq_Conf &conf) + : acquisition_impl_interface("galileo_pcps_8ms_acquisition_cc", + gr::io_signature::make(1, 1, static_cast(sizeof(gr_complex) * conf.sampled_ms * conf.samples_per_ms)), gr::io_signature::make(0, 1, sizeof(Gnss_Synchro))), - d_dump_filename(dump_filename), + d_acq_params(conf), d_gnss_synchro(nullptr), - d_fs_in(fs_in), d_sample_counter(0ULL), d_threshold(0), - d_doppler_freq(0), d_mag(0), d_input_power(0.0), d_test_statistics(0), d_state(0), - d_samples_per_ms(samples_per_ms), - d_samples_per_code(samples_per_code), d_channel(0), - d_doppler_resolution(0), - d_doppler_max(doppler_max), - d_doppler_step(0), - d_sampled_ms(sampled_ms), - d_max_dwells(max_dwells), d_well_count(0), - d_fft_size(d_sampled_ms * d_samples_per_ms), + d_fft_size(conf.sampled_ms * conf.samples_per_ms), d_num_doppler_bins(0), d_code_phase(0), d_active(false), - d_dump(dump), - d_enable_monitor_output(enable_monitor_output) + d_fft_if(gnss_fft_fwd_make_unique(d_fft_size)), + d_ifft(gnss_fft_rev_make_unique(d_fft_size)), + d_fft_code_A(d_fft_size, lv_cmake(0.0F, 0.0F)), + d_fft_code_B(d_fft_size, lv_cmake(0.0F, 0.0F)), + d_magnitude(d_fft_size, 0.0F) { this->message_port_register_out(pmt::mp("events")); - d_fft_code_A = std::vector(d_fft_size, lv_cmake(0.0F, 0.0F)); - d_fft_code_B = std::vector(d_fft_size, lv_cmake(0.0F, 0.0F)); - d_magnitude = std::vector(d_fft_size, 0.0F); - d_fft_if = gnss_fft_fwd_make_unique(d_fft_size); - d_ifft = gnss_fft_rev_make_unique(d_fft_size); + // Count the number of bins + for (auto doppler = -d_acq_params.doppler_max; doppler <= d_acq_params.doppler_max; doppler += d_acq_params.doppler_step) + { + d_num_doppler_bins++; + } + + // Create the carrier Doppler wipeoff signals + d_grid_doppler_wipeoffs = std::vector>(d_num_doppler_bins, std::vector(d_fft_size)); + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + { + int32_t doppler = -d_acq_params.doppler_max + d_acq_params.doppler_step * doppler_index; + float phase_step_rad = static_cast(TWO_PI) * doppler / static_cast(d_acq_params.fs_in); + std::array _phase{}; + volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index].data(), -phase_step_rad, _phase.data(), d_fft_size); + } } @@ -101,14 +85,14 @@ galileo_pcps_8ms_acquisition_cc::~galileo_pcps_8ms_acquisition_cc() { try { - if (d_dump) + if (d_acq_params.dump) { d_dump_file.close(); } } catch (const std::ofstream::failure &e) { - std::cerr << "Problem closing Acquisition dump file: " << d_dump_filename << '\n'; + std::cerr << "Problem closing Acquisition dump file: " << d_acq_params.dump_filename << '\n'; } catch (const std::exception &e) { @@ -128,15 +112,16 @@ void galileo_pcps_8ms_acquisition_cc::set_local_code(std::complex *code) volk_32fc_conjugate_32fc(d_fft_code_A.data(), d_fft_if->get_outbuf(), d_fft_size); // code B: two replicas of a primary code; the second replica is inverted. + const auto samples_per_code = static_cast(d_acq_params.samples_per_code); #if VOLK_EQUAL_OR_GREATER_31 auto minus_one = gr_complex(-1, 0); - volk_32fc_s32fc_multiply2_32fc(&(d_fft_if->get_inbuf())[d_samples_per_code], - &code[d_samples_per_code], &minus_one, - d_samples_per_code); + volk_32fc_s32fc_multiply2_32fc(&(d_fft_if->get_inbuf())[samples_per_code], + &code[samples_per_code], &minus_one, + samples_per_code); #else - volk_32fc_s32fc_multiply_32fc(&(d_fft_if->get_inbuf())[d_samples_per_code], - &code[d_samples_per_code], gr_complex(-1, 0), - d_samples_per_code); + volk_32fc_s32fc_multiply_32fc(&(d_fft_if->get_inbuf())[samples_per_code], + &code[samples_per_code], gr_complex(-1, 0), + samples_per_code); #endif d_fft_if->execute(); // We need the FFT of local code @@ -145,91 +130,33 @@ void galileo_pcps_8ms_acquisition_cc::set_local_code(std::complex *code) } -void galileo_pcps_8ms_acquisition_cc::init() -{ - d_gnss_synchro->Flag_valid_acquisition = false; - d_gnss_synchro->Flag_valid_symbol_output = false; - d_gnss_synchro->Flag_valid_pseudorange = false; - d_gnss_synchro->Flag_valid_word = false; - d_gnss_synchro->Acq_doppler_step = 0U; - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0ULL; - d_mag = 0.0; - d_input_power = 0.0; - - // Count the number of bins - d_num_doppler_bins = 0; - for (auto doppler = static_cast(-d_doppler_max); - doppler <= static_cast(d_doppler_max); - doppler += d_doppler_step) - { - d_num_doppler_bins++; - } - // Create the carrier Doppler wipeoff signals - d_grid_doppler_wipeoffs = std::vector>(d_num_doppler_bins, std::vector(d_fft_size)); - for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) - { - int32_t doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; - float phase_step_rad = static_cast(TWO_PI) * doppler / static_cast(d_fs_in); - std::array _phase{}; - volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index].data(), -phase_step_rad, _phase.data(), d_fft_size); - } -} - - -void galileo_pcps_8ms_acquisition_cc::set_state(int32_t state) -{ - d_state = state; - if (d_state == 1) - { - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0ULL; - d_gnss_synchro->Acq_doppler_step = 0U; - d_well_count = 0; - d_mag = 0.0; - d_input_power = 0.0; - d_test_statistics = 0.0; - } - else if (d_state == 0) - { - } - else - { - LOG(ERROR) << "State can only be set to 0 or 1"; - } -} - - int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { int32_t acquisition_message = -1; // 0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL + if (!d_active) + { + d_sample_counter += static_cast(d_fft_size) * ninput_items[0]; // sample counter + consume_each(ninput_items[0]); + return 0; + } + switch (d_state) { case 0: { - if (d_active) - { - // restart acquisition variables - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0ULL; - d_gnss_synchro->Acq_doppler_step = 0U; - d_well_count = 0; - d_mag = 0.0; - d_input_power = 0.0; - d_test_statistics = 0.0; - - d_state = 1; - } - - d_sample_counter += static_cast(d_fft_size) * ninput_items[0]; // sample counter - consume_each(ninput_items[0]); - + // restart acquisition variables + d_gnss_synchro->Acq_delay_samples = 0.0; + d_gnss_synchro->Acq_doppler_hz = 0.0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; + d_gnss_synchro->Acq_doppler_step = 0U; + d_well_count = 0; + d_mag = 0.0; + d_input_power = 0.0; + d_test_statistics = 0.0; + d_state = 1; break; } @@ -255,8 +182,8 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items, DLOG(INFO) << "Channel: " << d_channel << " , doing acquisition of satellite: " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN << " ,sample stamp: " << d_sample_counter << ", threshold: " - << d_threshold << ", doppler_max: " << d_doppler_max - << ", doppler_step: " << d_doppler_step; + << d_threshold << ", doppler_max: " << d_acq_params.doppler_max + << ", doppler_step: " << d_acq_params.doppler_step; // 1- Compute the input signal power estimation volk_32fc_magnitude_squared_32f(d_magnitude.data(), in, d_fft_size); @@ -267,7 +194,7 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items, for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { // doppler search steps - doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + doppler = -d_acq_params.doppler_max + d_acq_params.doppler_step * doppler_index; volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), in, d_grid_doppler_wipeoffs[doppler_index].data(), d_fft_size); @@ -324,14 +251,14 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items, if (d_mag < magt) { d_mag = magt; - d_gnss_synchro->Acq_delay_samples = static_cast(indext % d_samples_per_code); + d_gnss_synchro->Acq_delay_samples = static_cast(indext % static_cast(d_acq_params.samples_per_code)); d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; - d_gnss_synchro->Acq_doppler_step = d_doppler_step; + d_gnss_synchro->Acq_doppler_step = d_acq_params.doppler_step; } // Record results to file if required - if (d_dump) + if (d_acq_params.dump) { std::stringstream filename; std::streamsize n = 2 * sizeof(float) * (d_fft_size); // complex file write @@ -353,7 +280,7 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items, { d_state = 2; // Positive acquisition } - else if (d_well_count == d_max_dwells) + else if (d_well_count == d_acq_params.max_dwells) { d_state = 3; // Negative acquisition } @@ -386,7 +313,7 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items, this->message_port_pub(pmt::mp("events"), pmt::from_long(acquisition_message)); // Copy and push current Gnss_Synchro to monitor queue - if (d_enable_monitor_output) + if (d_acq_params.enable_monitor_output) { auto **out = reinterpret_cast(&output_items[0]); Gnss_Synchro current_synchro_data = Gnss_Synchro(); diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.h b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.h index 6ed5200cf..9ddd50492 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.h @@ -18,6 +18,8 @@ #ifndef GNSS_SDR_PCPS_8MS_ACQUISITION_CC_H #define GNSS_SDR_PCPS_8MS_ACQUISITION_CC_H +#include "acq_conf.h" +#include "acquisition_impl_interface.h" #include "channel_fsm.h" #include "gnss_sdr_fft.h" #include "gnss_synchro.h" @@ -40,21 +42,13 @@ class galileo_pcps_8ms_acquisition_cc; using galileo_pcps_8ms_acquisition_cc_sptr = gnss_shared_ptr; galileo_pcps_8ms_acquisition_cc_sptr -galileo_pcps_8ms_make_acquisition_cc(uint32_t sampled_ms, - uint32_t max_dwells, - uint32_t doppler_max, - int64_t fs_in, - int32_t samples_per_ms, - int32_t samples_per_code, - bool dump, - const std::string& dump_filename, - bool enable_monitor_output); +galileo_pcps_8ms_make_acquisition_cc(const Acq_Conf& conf); /*! * \brief This class implements a Parallel Code Phase Search Acquisition for * Galileo E1 signals with coherent integration time = 8 ms (two codes) */ -class galileo_pcps_8ms_acquisition_cc : public gr::block +class galileo_pcps_8ms_acquisition_cc : public acquisition_impl_interface { public: /*! @@ -67,7 +61,7 @@ public: * to exchange synchronization data between acquisition and tracking blocks. * \param p_gnss_synchro Satellite information shared by the processing blocks. */ - inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) + inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override { d_gnss_synchro = p_gnss_synchro; } @@ -75,44 +69,37 @@ public: /*! * \brief Returns the maximum peak of grid search. */ - inline uint32_t mag() const + inline uint32_t mag() const override { return d_mag; } - /*! - * \brief Initializes acquisition algorithm. - */ - void init(); - /*! * \brief Sets local code for PCPS acquisition algorithm. * \param code - Pointer to the PRN code. */ - void set_local_code(std::complex* code); + void set_local_code(std::complex* code) override; /*! * \brief Starts acquisition algorithm, turning from standby mode to * active mode * \param active - bool that activates/deactivates the block. */ - inline void set_active(bool active) + inline void set_active(bool active) override { + if (!active) + { + d_state = 0; + } + d_active = active; } - /*! - * \brief If set to 1, ensures that acquisition starts at the - * first available sample. - * \param state - int=1 forces start of acquisition - */ - void set_state(int32_t state); - /*! * \brief Set acquisition channel unique ID * \param channel - receiver channel. */ - inline void set_channel(uint32_t channel) + inline void set_channel(uint32_t channel) override { d_channel = channel; } @@ -120,7 +107,7 @@ public: /*! * \brief Set channel fsm associated to this acquisition instance */ - inline void set_channel_fsm(std::weak_ptr channel_fsm) + inline void set_channel_fsm(std::weak_ptr channel_fsm) override { d_channel_fsm = std::move(channel_fsm); } @@ -130,65 +117,50 @@ public: * \param threshold - Threshold for signal detection (check \ref Navitec2012, * Algorithm 1, for a definition of this threshold). */ - inline void set_threshold(float threshold) + inline void set_threshold(float threshold) override { d_threshold = threshold; } - /*! - * \brief Set maximum Doppler grid search - * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz]. - */ - inline void set_doppler_max(uint32_t doppler_max) - { - d_doppler_max = doppler_max; - } - - /*! - * \brief Set Doppler steps for the grid search - * \param doppler_step - Frequency bin of the search grid [Hz]. - */ - inline void set_doppler_step(uint32_t doppler_step) - { - d_doppler_step = doppler_step; - } - /*! * \brief Parallel Code Phase Search Acquisition signal processing. */ int general_work(int noutput_items, gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items); + gr_vector_void_star& output_items) override; private: friend galileo_pcps_8ms_acquisition_cc_sptr - galileo_pcps_8ms_make_acquisition_cc( - uint32_t sampled_ms, - uint32_t max_dwells, - uint32_t doppler_max, - int64_t fs_in, - int32_t samples_per_ms, - int32_t samples_per_code, - bool dump, - const std::string& dump_filename, - bool enable_monitor_output); + galileo_pcps_8ms_make_acquisition_cc(const Acq_Conf& conf); - galileo_pcps_8ms_acquisition_cc( - uint32_t sampled_ms, - uint32_t max_dwells, - uint32_t doppler_max, - int64_t fs_in, - int32_t samples_per_ms, - int32_t samples_per_code, - bool dump, - const std::string& dump_filename, - bool enable_monitor_output); + explicit galileo_pcps_8ms_acquisition_cc(const Acq_Conf& conf); void calculate_magnitudes( gr_complex* fft_begin, int32_t doppler_shift, int32_t doppler_offset); + std::string d_satellite_str; + const Acq_Conf d_acq_params; + std::ofstream d_dump_file; + + Gnss_Synchro* d_gnss_synchro; + + uint64_t d_sample_counter; + + float d_threshold; + float d_mag; + float d_input_power; + float d_test_statistics; + int32_t d_state; + uint32_t d_channel; + uint32_t d_well_count; + const uint32_t d_fft_size; + uint32_t d_num_doppler_bins; + uint32_t d_code_phase; + + bool d_active; + std::weak_ptr d_channel_fsm; std::unique_ptr d_fft_if; std::unique_ptr d_ifft; @@ -197,38 +169,6 @@ private: std::vector d_fft_code_A; std::vector d_fft_code_B; std::vector d_magnitude; - - std::string d_satellite_str; - std::string d_dump_filename; - std::ofstream d_dump_file; - - Gnss_Synchro* d_gnss_synchro; - - int64_t d_fs_in; - uint64_t d_sample_counter; - - float d_threshold; - float d_doppler_freq; - float d_mag; - float d_input_power; - float d_test_statistics; - int32_t d_state; - int32_t d_samples_per_ms; - int32_t d_samples_per_code; - uint32_t d_channel; - uint32_t d_doppler_resolution; - uint32_t d_doppler_max; - uint32_t d_doppler_step; - uint32_t d_sampled_ms; - uint32_t d_max_dwells; - uint32_t d_well_count; - uint32_t d_fft_size; - uint32_t d_num_doppler_bins; - uint32_t d_code_phase; - - bool d_active; - bool d_dump; - bool d_enable_monitor_output; }; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc index 0b5e286a3..e166c6aeb 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc @@ -54,7 +54,7 @@ pcps_acquisition_sptr pcps_make_acquisition(const Acq_Conf& conf_) pcps_acquisition::pcps_acquisition(const Acq_Conf& conf_) - : gr::block("pcps_acquisition", + : acquisition_impl_interface("pcps_acquisition", gr::io_signature::make(1, 1, conf_.it_size), gr::io_signature::make(0, 1, sizeof(Gnss_Synchro))), d_acq_parameters(conf_), @@ -77,7 +77,7 @@ pcps_acquisition::pcps_acquisition(const Acq_Conf& conf_) d_num_noncoherent_integrations_counter(0U), d_consumed_samples(conf_.sampled_ms * conf_.samples_per_ms * (conf_.bit_transition_flag ? 2.0 : 1.0)), d_fft_size(conf_.sampled_ms == conf_.ms_per_code ? d_consumed_samples : d_consumed_samples * 2), - d_num_doppler_bins(0U), + d_num_doppler_bins(static_cast(std::ceil(static_cast(2 * d_doppler_max) / static_cast(d_doppler_step)))), d_num_doppler_bins_step2(conf_.num_doppler_bins_step2), d_dump_channel(conf_.dump_channel), d_buffer_count(0U), @@ -87,7 +87,15 @@ pcps_acquisition::pcps_acquisition(const Acq_Conf& conf_) d_cshort(conf_.it_size != sizeof(gr_complex)), d_step_two(false), d_use_CFAR_algorithm_flag(conf_.use_CFAR_algorithm_flag), - d_dump(conf_.dump) + d_dump(conf_.dump), + d_magnitude_grid(d_num_doppler_bins, volk_gnsssdr::vector(d_fft_size)), + d_tmp_buffer(d_fft_size), + d_input_signal(d_fft_size), + d_grid_doppler_wipeoffs(d_num_doppler_bins, volk_gnsssdr::vector>(d_fft_size)), + d_fft_codes(d_fft_size), + d_data_buffer(d_consumed_samples), + d_fft_if(gnss_fft_fwd_make_unique(d_fft_size)), + d_ifft(gnss_fft_rev_make_unique(d_fft_size)) { this->message_port_register_out(pmt::mp("events")); @@ -109,21 +117,23 @@ pcps_acquisition::pcps_acquisition(const Acq_Conf& conf_) // d_acq_parameters.max_dwells = 1; // Activation of d_acq_parameters.bit_transition_flag invalidates the value of d_acq_parameters.max_dwells // } - d_tmp_buffer = volk_gnsssdr::vector(d_fft_size); - d_fft_codes = volk_gnsssdr::vector>(d_fft_size); - d_input_signal = volk_gnsssdr::vector>(d_fft_size); - d_fft_if = gnss_fft_fwd_make_unique(d_fft_size); - d_ifft = gnss_fft_rev_make_unique(d_fft_size); - - d_grid = arma::fmat(); - d_narrow_grid = arma::fmat(); - - d_data_buffer = volk_gnsssdr::vector>(d_consumed_samples); if (d_cshort) { d_data_buffer_sc = volk_gnsssdr::vector(d_consumed_samples); } + if (d_acq_parameters.make_2_steps && (d_grid_doppler_wipeoffs_step_two.empty())) + { + d_grid_doppler_wipeoffs_step_two = volk_gnsssdr::vector>>(d_num_doppler_bins_step2, volk_gnsssdr::vector>(d_fft_size)); + } + + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + { + std::fill(d_magnitude_grid[doppler_index].begin(), d_magnitude_grid[doppler_index].end(), 0.0); + } + + update_grid_doppler_wipeoffs(); + if (d_dump) { std::string dump_path; @@ -154,6 +164,10 @@ pcps_acquisition::pcps_acquisition(const Acq_Conf& conf_) std::cerr << "GNSS-SDR cannot create dump file for the Acquisition block. Wrong permissions?\n"; d_dump = false; } + + const uint32_t effective_fft_size = (d_acq_parameters.bit_transition_flag ? (d_fft_size / 2) : d_fft_size); + d_grid = arma::fmat(effective_fft_size, d_num_doppler_bins, arma::fill::zeros); + d_narrow_grid = arma::fmat(effective_fft_size, d_num_doppler_bins_step2, arma::fill::zeros); } } @@ -238,53 +252,6 @@ void pcps_acquisition::update_local_carrier(own::span carrier_vector } -void pcps_acquisition::init() -{ - d_gnss_synchro->Flag_valid_acquisition = false; - d_gnss_synchro->Flag_valid_symbol_output = false; - d_gnss_synchro->Flag_valid_pseudorange = false; - d_gnss_synchro->Flag_valid_word = false; - d_gnss_synchro->Acq_doppler_step = 0U; - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0ULL; - d_mag = 0.0; - d_input_power = 0.0; - - d_num_doppler_bins = static_cast(std::ceil(static_cast(2 * d_doppler_max) / static_cast(d_doppler_step))); - - // Create the carrier Doppler wipeoff signals - if (d_grid_doppler_wipeoffs.empty()) - { - d_grid_doppler_wipeoffs = volk_gnsssdr::vector>>(d_num_doppler_bins, volk_gnsssdr::vector>(d_fft_size)); - } - if (d_acq_parameters.make_2_steps && (d_grid_doppler_wipeoffs_step_two.empty())) - { - d_grid_doppler_wipeoffs_step_two = volk_gnsssdr::vector>>(d_num_doppler_bins_step2, volk_gnsssdr::vector>(d_fft_size)); - } - - if (d_magnitude_grid.empty()) - { - d_magnitude_grid = volk_gnsssdr::vector>(d_num_doppler_bins, volk_gnsssdr::vector(d_fft_size)); - } - - for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) - { - std::fill(d_magnitude_grid[doppler_index].begin(), d_magnitude_grid[doppler_index].end(), 0.0); - } - - update_grid_doppler_wipeoffs(); - d_worker_active = false; - - if (d_dump) - { - const uint32_t effective_fft_size = (d_acq_parameters.bit_transition_flag ? (d_fft_size / 2) : d_fft_size); - d_grid = arma::fmat(effective_fft_size, d_num_doppler_bins, arma::fill::zeros); - d_narrow_grid = arma::fmat(effective_fft_size, d_num_doppler_bins_step2, arma::fill::zeros); - } -} - - void pcps_acquisition::update_grid_doppler_wipeoffs() { for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) @@ -305,29 +272,6 @@ void pcps_acquisition::update_grid_doppler_wipeoffs_step2() } -void pcps_acquisition::set_state(int32_t state) -{ - gr::thread::scoped_lock lock(d_setlock); // require mutex with work function called by the scheduler - d_state = state; - if (d_state == 1) - { - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0ULL; - d_gnss_synchro->Acq_doppler_step = 0U; - d_mag = 0.0; - d_active = true; - } - else if (d_state == 0) - { - } - else - { - LOG(ERROR) << "State can only be set to 0 or 1"; - } -} - - void pcps_acquisition::send_positive_acquisition(float test_statistics) { // Declare positive acquisition using a message port @@ -414,11 +358,13 @@ void pcps_acquisition::dump_results(int32_t effective_fft_size, float test_stati dims[0] = static_cast(1); dims[1] = static_cast(1); - matvar = Mat_VarCreate("doppler_max", MAT_C_INT32, MAT_T_INT32, 1, dims.data(), &d_doppler_max, 0); + auto doppler_max = d_doppler_max; + matvar = Mat_VarCreate("doppler_max", MAT_C_INT32, MAT_T_INT32, 1, dims.data(), &doppler_max, 0); Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE Mat_VarFree(matvar); - matvar = Mat_VarCreate("doppler_step", MAT_C_INT32, MAT_T_INT32, 1, dims.data(), &d_doppler_step, 0); + auto doppler_step = d_doppler_step; + matvar = Mat_VarCreate("doppler_step", MAT_C_INT32, MAT_T_INT32, 1, dims.data(), &doppler_step, 0); Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE Mat_VarFree(matvar); @@ -703,7 +649,7 @@ void pcps_acquisition::acquisition_core(uint64_t samp_count) DLOG(INFO) << "Channel: " << d_channel << " , doing acquisition of satellite: " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN - << " ,sample stamp: " << samp_count << ", threshold: " + << " , sample stamp: " << samp_count << ", threshold: " << d_threshold << ", doppler_max: " << d_doppler_max << ", doppler_step: " << d_doppler_step << ", use_CFAR_algorithm_flag: " << (d_use_CFAR_algorithm_flag ? "true" : "false"); @@ -916,11 +862,6 @@ int pcps_acquisition::general_work(int noutput_items __attribute__((unused)), d_mag = 0.0; d_state = 1; d_buffer_count = 0U; - if (!d_acq_parameters.blocking_on_standby) - { - d_sample_counter += static_cast(ninput_items[0]); // sample counter - consume_each(ninput_items[0]); - } break; } case 1: diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.h index 58b932f35..ff01e81e2 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.h @@ -38,6 +38,7 @@ #ifndef GNSS_SDR_PCPS_ACQUISITION_H #define GNSS_SDR_PCPS_ACQUISITION_H +#include "acquisition_impl_interface.h" #if ARMA_NO_BOUND_CHECKING #define ARMA_NO_DEBUG 1 #endif @@ -89,22 +90,17 @@ pcps_acquisition_sptr pcps_make_acquisition(const Acq_Conf& conf_); * Check \ref Navitec2012 "An Open Source Galileo E1 Software Receiver", * Algorithm 1, for a pseudocode description of this implementation. */ -class pcps_acquisition : public gr::block +class pcps_acquisition : public acquisition_impl_interface { public: ~pcps_acquisition() override = default; - /*! - * \brief Initializes acquisition algorithm and reserves memory. - */ - void init(); - /*! * \brief Set acquisition/tracking common Gnss_Synchro object pointer * to exchange synchronization data between acquisition and tracking blocks. * \param p_gnss_synchro Satellite information shared by the processing blocks. */ - inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) + inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override { gr::thread::scoped_lock lock(d_setlock); // require mutex with work function called by the scheduler d_gnss_synchro = p_gnss_synchro; @@ -114,21 +110,14 @@ public: * \brief Sets local code for PCPS acquisition algorithm. * \param code - Pointer to the PRN code. */ - void set_local_code(std::complex* code); - - /*! - * \brief If set to 1, ensures that acquisition starts at the - * first available sample. - * \param state - int=1 forces start of acquisition - */ - void set_state(int32_t state); + void set_local_code(std::complex* code) override; void set_resampler_latency(uint32_t latency_samples); /*! * \brief Returns the maximum peak of grid search. */ - inline uint32_t mag() const + inline uint32_t mag() const override { return d_mag; } @@ -138,7 +127,7 @@ public: * active mode * \param active - bool that activates/deactivates the block. */ - inline void set_active(bool active) + inline void set_active(bool active) override { gr::thread::scoped_lock lock(d_setlock); // require mutex with work function called by the scheduler d_active = active; @@ -148,7 +137,7 @@ public: * \brief Set acquisition channel unique ID * \param channel - receiver channel. */ - inline void set_channel(uint32_t channel) + inline void set_channel(uint32_t channel) override { d_channel = channel; } @@ -156,7 +145,7 @@ public: /*! * \brief Set channel fsm associated to this acquisition instance */ - inline void set_channel_fsm(std::weak_ptr channel_fsm) + inline void set_channel_fsm(std::weak_ptr channel_fsm) override { d_channel_fsm = std::move(channel_fsm); } @@ -166,32 +155,12 @@ public: * \param threshold - Threshold for signal detection (check \ref Navitec2012, * Algorithm 1, for a definition of this threshold). */ - inline void set_threshold(float threshold) + inline void set_threshold(float threshold) override { gr::thread::scoped_lock lock(d_setlock); // require mutex with work function called by the scheduler d_threshold = threshold; } - /*! - * \brief Set maximum Doppler grid search - * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz]. - */ - inline void set_doppler_max(uint32_t doppler_max) - { - gr::thread::scoped_lock lock(d_setlock); // require mutex with work function called by the scheduler - d_doppler_max = doppler_max; - } - - /*! - * \brief Set Doppler steps for the grid search - * \param doppler_step - Frequency bin of the search grid [Hz]. - */ - inline void set_doppler_step(uint32_t doppler_step) - { - gr::thread::scoped_lock lock(d_setlock); // require mutex with work function called by the scheduler - d_doppler_step = doppler_step; - } - /*! * \brief Set Doppler center frequency for the grid search. It will refresh the Doppler grid. * \param doppler_center - Frequency center of the search grid [Hz]. @@ -225,19 +194,6 @@ private: float first_vs_second_peak_statistic(uint32_t& indext, int32_t& doppler, uint32_t num_doppler_bins, int32_t doppler_max, int32_t doppler_step); float max_to_input_power_statistic(uint32_t& indext, int32_t& doppler, uint32_t num_doppler_bins, int32_t doppler_max, int32_t doppler_step); - volk_gnsssdr::vector> d_magnitude_grid; - volk_gnsssdr::vector d_tmp_buffer; - volk_gnsssdr::vector> d_input_signal; - volk_gnsssdr::vector>> d_grid_doppler_wipeoffs; - volk_gnsssdr::vector>> d_grid_doppler_wipeoffs_step_two; - volk_gnsssdr::vector> d_fft_codes; - volk_gnsssdr::vector> d_data_buffer; - volk_gnsssdr::vector d_data_buffer_sc; - - std::unique_ptr d_fft_if; - std::unique_ptr d_ifft; - std::weak_ptr d_channel_fsm; - const Acq_Conf d_acq_parameters; Gnss_Synchro* d_gnss_synchro; arma::fmat d_grid; @@ -253,7 +209,7 @@ private: float d_mag; float d_input_power; float d_doppler_center_step_two; - float d_doppler_max; + const float d_doppler_max; int32_t d_state; int32_t d_positive_acq; @@ -261,11 +217,11 @@ private: int32_t d_doppler_bias; uint32_t d_channel; const uint32_t d_samplesPerChip; - uint32_t d_doppler_step; + const uint32_t d_doppler_step; uint32_t d_num_noncoherent_integrations_counter; const uint32_t d_consumed_samples; const uint32_t d_fft_size; - uint32_t d_num_doppler_bins; + const uint32_t d_num_doppler_bins; const uint32_t d_num_doppler_bins_step2; const uint32_t d_dump_channel; uint32_t d_buffer_count; @@ -277,6 +233,19 @@ private: bool d_step_two; const bool d_use_CFAR_algorithm_flag; bool d_dump; + + volk_gnsssdr::vector> d_magnitude_grid; + volk_gnsssdr::vector d_tmp_buffer; + volk_gnsssdr::vector> d_input_signal; + volk_gnsssdr::vector>> d_grid_doppler_wipeoffs; + volk_gnsssdr::vector>> d_grid_doppler_wipeoffs_step_two; + volk_gnsssdr::vector> d_fft_codes; + volk_gnsssdr::vector> d_data_buffer; + volk_gnsssdr::vector d_data_buffer_sc; + + std::unique_ptr d_fft_if; + std::unique_ptr d_ifft; + std::weak_ptr d_channel_fsm; }; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc index 0efa83fa7..3d5e906bc 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc @@ -26,8 +26,6 @@ #include #include // std::rotate, std::fill_n #include -#include -#include #if USE_GLOG_AND_GFLAGS #include @@ -44,40 +42,37 @@ pcps_acquisition_fine_doppler_cc_sptr pcps_make_acquisition_fine_doppler_cc(cons pcps_acquisition_fine_doppler_cc::pcps_acquisition_fine_doppler_cc(const Acq_Conf &conf_) - : gr::block("pcps_acquisition_fine_doppler_cc", + : acquisition_impl_interface("pcps_acquisition_fine_doppler_cc", gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(0, 1, sizeof(Gnss_Synchro))), + d_acq_params(conf_), d_dump_filename(conf_.dump_filename), d_gnss_synchro(nullptr), - acq_parameters(conf_), - d_fs_in(conf_.fs_in), d_dump_number(0), d_sample_counter(0ULL), d_threshold(0), d_test_statistics(0), d_positive_acq(0), d_state(0), - d_samples_per_ms(static_cast(conf_.samples_per_ms)), - d_max_dwells(conf_.max_dwells), - d_config_doppler_max(conf_.doppler_max), - d_num_doppler_points(0), + d_num_doppler_points(floor(std::abs(2 * d_acq_params.doppler_max) / d_acq_params.doppler_step)), d_well_count(0), d_n_samples_in_buffer(0), - d_fft_size(d_samples_per_ms), + d_fft_size(static_cast(conf_.samples_per_ms)), d_gnuradio_forecast_samples(d_fft_size), - d_doppler_step(0), d_channel(0), d_dump_channel(0), d_active(false), - d_dump(conf_.dump) + d_dump(conf_.dump), + d_fft_if(gnss_fft_fwd_make_unique(d_fft_size)), + d_ifft(gnss_fft_rev_make_unique(d_fft_size)), + d_grid_data(d_num_doppler_points, volk_gnsssdr::vector(d_fft_size)), + d_fft_codes(d_fft_size), + d_10_ms_buffer(50 * d_fft_size), + d_magnitude(d_fft_size) { this->message_port_register_out(pmt::mp("events")); - d_fft_codes = volk_gnsssdr::vector(d_fft_size); - d_magnitude = volk_gnsssdr::vector(d_fft_size); - d_10_ms_buffer = volk_gnsssdr::vector(50 * d_samples_per_ms); - d_fft_if = gnss_fft_fwd_make_unique(d_fft_size); - d_ifft = gnss_fft_rev_make_unique(d_fft_size); + update_carrier_wipeoff(); // this implementation can only produce dumps in channel 0 // todo: migrate config parameters to the unified acquisition config class @@ -111,6 +106,8 @@ pcps_acquisition_fine_doppler_cc::pcps_acquisition_fine_doppler_cc(const Acq_Con std::cerr << "GNSS-SDR cannot create dump file for the Acquisition block. Wrong permissions?\n"; d_dump = false; } + + grid_ = arma::fmat(d_fft_size, d_num_doppler_points, arma::fill::zeros); } } @@ -131,24 +128,6 @@ unsigned int pcps_acquisition_fine_doppler_cc::nextPowerOf2(unsigned int n) } -void pcps_acquisition_fine_doppler_cc::set_doppler_step(unsigned int doppler_step) -{ - d_doppler_step = doppler_step; - // Create the search grid array - - d_num_doppler_points = floor(std::abs(2 * d_config_doppler_max) / d_doppler_step); - - d_grid_data = volk_gnsssdr::vector>(d_num_doppler_points, volk_gnsssdr::vector(d_fft_size)); - - if (d_dump) - { - grid_ = arma::fmat(d_fft_size, d_num_doppler_points, arma::fill::zeros); - } - - update_carrier_wipeoff(); -} - - void pcps_acquisition_fine_doppler_cc::set_local_code(std::complex *code) { std::copy(code, code + d_fft_size, d_fft_if->get_inbuf()); @@ -158,20 +137,6 @@ void pcps_acquisition_fine_doppler_cc::set_local_code(std::complex *code) } -void pcps_acquisition_fine_doppler_cc::init() -{ - d_gnss_synchro->Flag_valid_acquisition = false; - d_gnss_synchro->Flag_valid_symbol_output = false; - d_gnss_synchro->Flag_valid_pseudorange = false; - d_gnss_synchro->Flag_valid_word = false; - d_gnss_synchro->Acq_doppler_step = 0U; - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0ULL; - d_state = 0; -} - - void pcps_acquisition_fine_doppler_cc::forecast(int noutput_items, gr_vector_int &ninput_items_required) { @@ -204,10 +169,10 @@ void pcps_acquisition_fine_doppler_cc::update_carrier_wipeoff() d_grid_doppler_wipeoffs = volk_gnsssdr::vector>>(d_num_doppler_points, volk_gnsssdr::vector>(d_fft_size)); for (int doppler_index = 0; doppler_index < d_num_doppler_points; doppler_index++) { - doppler_hz = static_cast(d_doppler_step) * doppler_index - d_config_doppler_max; + doppler_hz = d_acq_params.doppler_step * doppler_index - d_acq_params.doppler_step; // doppler search steps // compute the carrier doppler wipe-off signal and store it - phase_step_rad = static_cast(TWO_PI) * static_cast(doppler_hz) / static_cast(d_fs_in); + phase_step_rad = static_cast(TWO_PI) * static_cast(doppler_hz) / static_cast(d_acq_params.fs_in); float _phase[1]; _phase[0] = 0; volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index].data(), -phase_step_rad, _phase, d_fft_size); @@ -244,7 +209,7 @@ float pcps_acquisition_fine_doppler_cc::compute_CAF() } // -- - Find 1 chip wide code phase exclude range around the peak - uint32_t samplesPerChip = ceil(GPS_L1_CA_CHIP_PERIOD_S * static_cast(this->d_fs_in)); + uint32_t samplesPerChip = ceil(GPS_L1_CA_CHIP_PERIOD_S * static_cast(d_acq_params.fs_in)); int32_t excludeRangeIndex1 = index_time - samplesPerChip; int32_t excludeRangeIndex2 = index_time + samplesPerChip; @@ -279,9 +244,9 @@ float pcps_acquisition_fine_doppler_cc::compute_CAF() // 4- record the maximum peak and the associated synchronization parameters d_gnss_synchro->Acq_delay_samples = static_cast(index_time); - d_gnss_synchro->Acq_doppler_hz = static_cast(index_doppler * d_doppler_step - d_config_doppler_max); + d_gnss_synchro->Acq_doppler_hz = static_cast(index_doppler * d_acq_params.doppler_step - d_acq_params.doppler_max); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; - d_gnss_synchro->Acq_doppler_step = d_doppler_step; + d_gnss_synchro->Acq_doppler_step = d_acq_params.doppler_step; return d_test_statistics; } @@ -307,8 +272,8 @@ int pcps_acquisition_fine_doppler_cc::compute_and_accumulate_grid(gr_vector_cons DLOG(INFO) << "Channel: " << d_channel << " , doing acquisition of satellite: " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN << " ,sample stamp: " << d_sample_counter << ", threshold: " - << d_threshold << ", doppler_max: " << d_config_doppler_max - << ", doppler_step: " << d_doppler_step; + << d_threshold << ", doppler_max: " << d_acq_params.doppler_max + << ", doppler_step: " << d_acq_params.doppler_step; // 2- Doppler frequency search loop volk_gnsssdr::vector p_tmp_vector(d_fft_size); @@ -365,7 +330,7 @@ int pcps_acquisition_fine_doppler_cc::estimate_Doppler() // 1. generate local code aligned with the acquisition code phase estimation volk_gnsssdr::vector code_replica(signal_samples); - gps_l1_ca_code_gen_complex_sampled(code_replica, d_gnss_synchro->PRN, d_fs_in, 0); + gps_l1_ca_code_gen_complex_sampled(code_replica, d_gnss_synchro->PRN, d_acq_params.fs_in, 0); int shift_index = static_cast(d_gnss_synchro->Acq_delay_samples); @@ -398,13 +363,13 @@ int pcps_acquisition_fine_doppler_cc::estimate_Doppler() for (int k = 0; k < (fft_size_extended / 2); k++) { - fftFreqBins[counter] = ((static_cast(d_fs_in) / 2.0) * static_cast(k)) / (static_cast(fft_size_extended) / 2.0); + fftFreqBins[counter] = ((static_cast(d_acq_params.fs_in) / 2.0) * static_cast(k)) / (static_cast(fft_size_extended) / 2.0); counter++; } for (int k = fft_size_extended / 2; k > 0; k--) { - fftFreqBins[counter] = ((-static_cast(d_fs_in) / 2.0) * static_cast(k)) / (static_cast(fft_size_extended) / 2.0); + fftFreqBins[counter] = ((-static_cast(d_acq_params.fs_in) / 2.0) * static_cast(k)) / (static_cast(fft_size_extended) / 2.0); counter++; } @@ -432,32 +397,6 @@ bool pcps_acquisition_fine_doppler_cc::start() } -void pcps_acquisition_fine_doppler_cc::set_state(int state) -{ - // gr::thread::scoped_lock lock(d_setlock); // require mutex with work function called by the scheduler - d_state = state; - - if (d_state == 1) - { - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0ULL; - d_gnss_synchro->Acq_doppler_step = 0U; - d_well_count = 0; - d_test_statistics = 0.0; - d_active = true; - reset_grid(); - } - else if (d_state == 0) - { - } - else - { - LOG(ERROR) << "State can only be set to 0 or 1"; - } -} - - int pcps_acquisition_fine_doppler_cc::general_work(int noutput_items, gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) @@ -479,27 +418,33 @@ int pcps_acquisition_fine_doppler_cc::general_work(int noutput_items, int return_value = 0; // Number of Gnss_Syncro objects produced int samples_remaining; const auto *in_aux = reinterpret_cast(input_items[0]); + + if (!d_active) + { + d_sample_counter += static_cast(d_fft_size); // sample counter + consume_each(ninput_items[0]); + return 0; + } + switch (d_state) { case 0: // S0. StandBy - if (d_active == true) - { - reset_grid(); - d_n_samples_in_buffer = 0; - d_state = 1; - } - if (!acq_parameters.blocking_on_standby) - { - d_sample_counter += static_cast(d_fft_size); // sample counter - consume_each(d_fft_size); - } + d_gnss_synchro->Acq_delay_samples = 0.0; + d_gnss_synchro->Acq_doppler_hz = 0.0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; + d_gnss_synchro->Acq_doppler_step = 0U; + d_well_count = 0; + d_test_statistics = 0.0; + reset_grid(); + d_n_samples_in_buffer = 0; + d_state = 1; break; case 1: // S1. ComputeGrid compute_and_accumulate_grid(input_items); std::copy(in_aux, in_aux + d_fft_size, &d_10_ms_buffer[d_n_samples_in_buffer]); d_n_samples_in_buffer += d_fft_size; d_well_count++; - if (d_well_count >= d_max_dwells) + if (d_well_count >= static_cast(d_acq_params.max_dwells)) { d_state = 2; } @@ -520,7 +465,7 @@ int pcps_acquisition_fine_doppler_cc::general_work(int noutput_items, break; case 3: // Fine doppler estimation - samples_remaining = 10 * d_samples_per_ms - d_n_samples_in_buffer; + samples_remaining = 10 * static_cast(d_acq_params.samples_per_ms) - d_n_samples_in_buffer; if (samples_remaining > noutput_items) { @@ -560,13 +505,13 @@ int pcps_acquisition_fine_doppler_cc::general_work(int noutput_items, // Send message to channel port //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL this->message_port_pub(pmt::mp("events"), pmt::from_long(1)); d_state = 0; - if (!acq_parameters.blocking_on_standby) + if (!d_acq_params.blocking_on_standby) { d_sample_counter += static_cast(noutput_items); // sample counter consume_each(noutput_items); } // Copy and push current Gnss_Synchro to monitor queue - if (acq_parameters.enable_monitor_output) + if (d_acq_params.enable_monitor_output) { auto **out = reinterpret_cast(&output_items[0]); Gnss_Synchro current_synchro_data = Gnss_Synchro(); @@ -593,7 +538,7 @@ int pcps_acquisition_fine_doppler_cc::general_work(int noutput_items, // Send message to channel port //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL this->message_port_pub(pmt::mp("events"), pmt::from_long(2)); d_state = 0; - if (!acq_parameters.blocking_on_standby) + if (!d_acq_params.blocking_on_standby) { d_sample_counter += static_cast(noutput_items); // sample counter consume_each(noutput_items); @@ -601,7 +546,7 @@ int pcps_acquisition_fine_doppler_cc::general_work(int noutput_items, break; default: d_state = 0; - if (!acq_parameters.blocking_on_standby) + if (!d_acq_params.blocking_on_standby) { d_sample_counter += static_cast(noutput_items); // sample counter consume_each(noutput_items); @@ -643,11 +588,13 @@ void pcps_acquisition_fine_doppler_cc::dump_results(int effective_fft_size) dims[0] = static_cast(1); dims[1] = static_cast(1); - matvar = Mat_VarCreate("doppler_max", MAT_C_INT32, MAT_T_INT32, 1, dims.data(), &d_config_doppler_max, 0); + auto doppler_max = d_acq_params.doppler_max; + matvar = Mat_VarCreate("doppler_max", MAT_C_INT32, MAT_T_INT32, 1, dims.data(), &doppler_max, 0); Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE Mat_VarFree(matvar); - matvar = Mat_VarCreate("doppler_step", MAT_C_INT32, MAT_T_INT32, 1, dims.data(), &d_doppler_step, 0); + auto doppler_step = d_acq_params.doppler_step; + matvar = Mat_VarCreate("doppler_step", MAT_C_INT32, MAT_T_INT32, 1, dims.data(), &doppler_step, 0); Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE Mat_VarFree(matvar); diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.h index d9c073e01..c6db7a227 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.h @@ -35,6 +35,7 @@ #ifndef GNSS_SDR_PCPS_ACQUISITION_FINE_DOPPLER_CC_H #define GNSS_SDR_PCPS_ACQUISITION_FINE_DOPPLER_CC_H +#include "acquisition_impl_interface.h" #if ARMA_NO_BOUND_CHECKING #define ARMA_NO_DEBUG 1 #endif @@ -70,7 +71,7 @@ pcps_acquisition_fine_doppler_cc_sptr pcps_make_acquisition_fine_doppler_cc(cons * \brief This class implements a Parallel Code Phase Search Acquisition. * */ -class pcps_acquisition_fine_doppler_cc : public gr::block +class pcps_acquisition_fine_doppler_cc : public acquisition_impl_interface { public: /*! @@ -83,7 +84,7 @@ public: * to exchange synchronization data between acquisition and tracking blocks. * \param p_gnss_synchro Satellite information shared by the processing blocks. */ - inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) + inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override { d_gnss_synchro = p_gnss_synchro; } @@ -91,29 +92,29 @@ public: /*! * \brief Returns the maximum peak of grid search. */ - inline unsigned int mag() const + inline unsigned int mag() const override { return d_test_statistics; } - /*! - * \brief Initializes acquisition algorithm. - */ - void init(); - /*! * \brief Sets local code for PCPS acquisition algorithm. * \param code - Pointer to the PRN code. */ - void set_local_code(std::complex* code); + void set_local_code(std::complex* code) override; /*! * \brief Starts acquisition algorithm, turning from standby mode to * active mode * \param active - bool that activates/deactivates the block. */ - inline void set_active(bool active) + inline void set_active(bool active) override { + if (!active) + { + d_state = 0; + } + d_active = active; } @@ -121,7 +122,7 @@ public: * \brief Set acquisition channel unique ID * \param channel - receiver channel. */ - inline void set_channel(unsigned int channel) + inline void set_channel(unsigned int channel) override { d_channel = channel; d_dump_channel = d_channel; @@ -130,7 +131,7 @@ public: /*! * \brief Set channel fsm associated to this acquisition instance */ - inline void set_channel_fsm(std::weak_ptr channel_fsm) + inline void set_channel_fsm(std::weak_ptr channel_fsm) override { d_channel_fsm = std::move(channel_fsm); } @@ -140,33 +141,19 @@ public: * \param threshold - Threshold for signal detection (check \ref Navitec2012, * Algorithm 1, for a definition of this threshold). */ - inline void set_threshold(float threshold) + inline void set_threshold(float threshold) override { d_threshold = threshold; } /*! - * \brief Set maximum Doppler grid search - * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz]. + * \brief Parallel Code Phase Search Acquisition signal processing. */ - inline void set_doppler_max(unsigned int doppler_max) - { - d_config_doppler_max = doppler_max; - } - - /*! - * \brief Set Doppler steps for the grid search - * \param doppler_step - Frequency bin of the search grid [Hz]. - */ - void set_doppler_step(unsigned int doppler_step); - - /*! - * \brief If set to 1, ensures that acquisition starts at the - * first available sample. - * \param state - int=1 forces start of acquisition - */ - void set_state(int state); + int general_work(int noutput_items, gr_vector_int& ninput_items, + gr_vector_const_void_star& input_items, + gr_vector_void_star& output_items) override; +private: /*! * \brief Obtains the next power of 2 greater or equal to the input parameter * \param n - Integer value to obtain the next power of 2. @@ -175,16 +162,8 @@ public: void dump_results(int effective_fft_size); - void forecast(int noutput_items, gr_vector_int& ninput_items_required); + void forecast(int noutput_items, gr_vector_int& ninput_items_required) override; - /*! - * \brief Parallel Code Phase Search Acquisition signal processing. - */ - int general_work(int noutput_items, gr_vector_int& ninput_items, - gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items); - -private: friend pcps_acquisition_fine_doppler_cc_sptr pcps_make_acquisition_fine_doppler_cc(const Acq_Conf& conf_); explicit pcps_acquisition_fine_doppler_cc(const Acq_Conf& conf_); @@ -194,7 +173,35 @@ private: float compute_CAF(); void reset_grid(); void update_carrier_wipeoff(); - bool start(); + bool start() override; + + arma::fmat grid_; + + std::string d_satellite_str; + + const Acq_Conf d_acq_params; + std::string d_dump_filename; + + Gnss_Synchro* d_gnss_synchro; + + int64_t d_dump_number; + uint64_t d_sample_counter; + + float d_threshold; + float d_test_statistics; + + int d_positive_acq; + int d_state; + const int d_num_doppler_points; + int d_well_count; + int d_n_samples_in_buffer; + const int d_fft_size; + int d_gnuradio_forecast_samples; + unsigned int d_channel; + unsigned int d_dump_channel; + + bool d_active; + bool d_dump; std::weak_ptr d_channel_fsm; std::unique_ptr d_fft_if; @@ -205,39 +212,6 @@ private: volk_gnsssdr::vector d_fft_codes; volk_gnsssdr::vector d_10_ms_buffer; volk_gnsssdr::vector d_magnitude; - - arma::fmat grid_; - - std::string d_satellite_str; - std::string d_dump_filename; - - Gnss_Synchro* d_gnss_synchro; - - Acq_Conf acq_parameters; - - int64_t d_fs_in; - int64_t d_dump_number; - uint64_t d_sample_counter; - - float d_threshold; - float d_test_statistics; - - int d_positive_acq; - int d_state; - int d_samples_per_ms; - int d_max_dwells; - int d_config_doppler_max; - int d_num_doppler_points; - int d_well_count; - int d_n_samples_in_buffer; - int d_fft_size; - int d_gnuradio_forecast_samples; - unsigned int d_doppler_step; - unsigned int d_channel; - unsigned int d_dump_channel; - - bool d_active; - bool d_dump; }; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index d7b99b57a..5ee9ea401 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -52,17 +52,21 @@ pcps_acquisition_fpga::pcps_acquisition_fpga(Acq_Conf_Fpga *conf_, uint32_t acq_ d_state(0), d_doppler_index(0U), d_channel(0U), - d_doppler_step(0U), + d_doppler_step(d_acq_parameters->doppler_step), d_doppler_max(d_acq_parameters->doppler_max), - d_num_doppler_bins(0U), + d_num_doppler_bins(static_cast(std::ceil(static_cast(static_cast(d_doppler_max) - static_cast(-d_doppler_max)) / static_cast(d_doppler_step))) + 1), d_total_block_exp(d_acq_parameters->total_block_exp), d_num_doppler_bins_step2(d_acq_parameters->num_doppler_bins_step2), d_max_num_acqs(d_acq_parameters->max_num_acqs), d_active(false), d_make_2_steps(d_acq_parameters->make_2_steps) { - d_acquisition_fpga = std::make_unique(d_acq_parameters->device_name, acq_buff_num, - downsampling_filter_specs, max_FFT_size); + d_acquisition_fpga = std::make_unique(d_acq_parameters->device_name, + acq_buff_num, + downsampling_filter_specs, + max_FFT_size); + d_acquisition_fpga->init(d_acq_parameters->code_length, d_acq_parameters->fft_size, + d_acq_parameters->resampled_fs, d_acq_parameters->downsampling_filter_num, d_acq_parameters->excludelimit, d_acq_parameters->all_fft_codes); } void pcps_acquisition_fpga::set_local_code() @@ -70,45 +74,6 @@ void pcps_acquisition_fpga::set_local_code() d_acquisition_fpga->set_local_code(d_gnss_synchro->PRN); } -void pcps_acquisition_fpga::init() -{ - d_acquisition_fpga->init(d_acq_parameters->code_length, d_doppler_max, d_acq_parameters->fft_size, - d_acq_parameters->resampled_fs, d_acq_parameters->downsampling_filter_num, d_acq_parameters->excludelimit, d_acq_parameters->all_fft_codes); - d_gnss_synchro->Flag_valid_acquisition = false; - d_gnss_synchro->Flag_valid_symbol_output = false; - d_gnss_synchro->Flag_valid_pseudorange = false; - d_gnss_synchro->Flag_valid_word = false; - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; - d_mag = 0.0; - d_input_power = 0.0; - - d_num_doppler_bins = static_cast(std::ceil(static_cast(static_cast(d_doppler_max) - static_cast(-d_doppler_max)) / static_cast(d_doppler_step))) + 1; -} - -void pcps_acquisition_fpga::set_state(int32_t state) -{ - d_state = state; - if (d_state == 1) - { - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0; - d_mag = 0.0; - d_input_power = 0.0; - d_test_statistics = 0.0; - d_active = true; - } - else if (d_state == 0) - { - } - else - { - LOG(ERROR) << "State can only be set to 0 or 1"; - } -} - void pcps_acquisition_fpga::send_positive_acquisition() { @@ -202,6 +167,9 @@ void pcps_acquisition_fpga::set_active(bool active) d_active = active; d_input_power = 0.0; d_mag = 0.0; + d_gnss_synchro->Acq_delay_samples = 0.0; + d_gnss_synchro->Acq_doppler_hz = 0.0; + d_gnss_synchro->Acq_samplestamp_samples = 0; DLOG(INFO) << "Channel: " << d_channel << " , doing acquisition of satellite: " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h index d1fca2179..c9386b530 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h @@ -81,23 +81,11 @@ public: return d_mag; } - /*! - * \brief Initializes acquisition algorithm. - */ - void init(); - /*! * \brief Sets local code for PCPS acquisition algorithm. */ void set_local_code(); - /*! - * \brief If set to 1, ensures that acquisition starts at the - * first available sample. - * \param state - int=1 forces start of acquisition - */ - void set_state(int32_t state); - /*! * \brief Starts acquisition algorithm, turning from standby mode to * active mode @@ -132,26 +120,6 @@ public: d_threshold = threshold; } - /*! - * \brief Set maximum Doppler grid search - * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz]. - */ - inline void set_doppler_max(uint32_t doppler_max) - { - d_doppler_max = doppler_max; - d_acquisition_fpga->set_doppler_max(doppler_max); - } - - /*! - * \brief Set Doppler steps for the grid search - * \param doppler_step - Frequency bin of the search grid [Hz]. - */ - inline void set_doppler_step(uint32_t doppler_step) - { - d_doppler_step = doppler_step; - d_acquisition_fpga->set_doppler_step(doppler_step); - } - /*! * \brief Set Doppler center frequency for the grid search. It will refresh the Doppler grid. * \param doppler_center - Frequency center of the search grid [Hz]. @@ -198,9 +166,9 @@ private: uint32_t d_doppler_index; uint32_t d_channel; - uint32_t d_doppler_step; - uint32_t d_doppler_max; - uint32_t d_num_doppler_bins; + const uint32_t d_doppler_step; + const uint32_t d_doppler_max; + const uint32_t d_num_doppler_bins; uint32_t d_total_block_exp; uint32_t d_num_doppler_bins_step2; uint32_t d_max_num_acqs; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc index c6957957e..f827c9e97 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc @@ -38,65 +38,38 @@ extern Concurrent_Map global_gps_acq_assist_map; -pcps_assisted_acquisition_cc_sptr pcps_make_assisted_acquisition_cc( - int32_t max_dwells, uint32_t sampled_ms, int32_t doppler_max, int32_t doppler_min, - int64_t fs_in, int32_t samples_per_ms, bool dump, - const std::string &dump_filename, bool enable_monitor_output) +pcps_assisted_acquisition_cc_sptr pcps_make_assisted_acquisition_cc(const Acq_Conf &conf) { - return pcps_assisted_acquisition_cc_sptr( - new pcps_assisted_acquisition_cc(max_dwells, sampled_ms, doppler_max, doppler_min, - fs_in, samples_per_ms, dump, dump_filename, enable_monitor_output)); + return pcps_assisted_acquisition_cc_sptr(new pcps_assisted_acquisition_cc(conf)); } -pcps_assisted_acquisition_cc::pcps_assisted_acquisition_cc( - int32_t max_dwells, uint32_t sampled_ms, int32_t doppler_max, int32_t doppler_min, - int64_t fs_in, int32_t samples_per_ms, bool dump, const std::string &dump_filename, - bool enable_monitor_output) - : gr::block("pcps_assisted_acquisition_cc", +pcps_assisted_acquisition_cc::pcps_assisted_acquisition_cc(const Acq_Conf &conf) + : acquisition_impl_interface("pcps_assisted_acquisition_cc", gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(0, 1, sizeof(Gnss_Synchro))), - d_dump_filename(dump_filename), + d_acq_params(conf), d_gnss_synchro(nullptr), - d_fs_in(fs_in), d_sample_counter(0ULL), d_threshold(0), - d_doppler_freq(0), d_input_power(0.0), d_test_statistics(0), - d_doppler_resolution(0), d_channel(0), - d_sampled_ms(sampled_ms), d_code_phase(0), - d_samples_per_ms(samples_per_ms), - d_fft_size(d_sampled_ms * d_samples_per_ms), - d_max_dwells(max_dwells), + d_fft_size(conf.sampled_ms * conf.samples_per_ms), d_gnuradio_forecast_samples(d_fft_size * 4), d_doppler_max(0), d_doppler_min(0), - d_config_doppler_max(doppler_max), - d_config_doppler_min(doppler_min), d_num_doppler_points(0), - d_doppler_step(0), d_state(0), d_well_count(0), d_active(false), d_disable_assist(false), - d_dump(dump), - d_enable_monitor_output(enable_monitor_output) + d_fft_if(gnss_fft_fwd_make_unique(d_fft_size)), + d_ifft(gnss_fft_rev_make_unique(d_fft_size)), + d_fft_codes(d_fft_size) { this->message_port_register_out(pmt::mp("events")); - - d_fft_codes = std::vector(d_fft_size); - - d_fft_if = gnss_fft_fwd_make_unique(d_fft_size); - d_ifft = gnss_fft_rev_make_unique(d_fft_size); -} - - -void pcps_assisted_acquisition_cc::set_doppler_step(uint32_t doppler_step) -{ - d_doppler_step = doppler_step; } @@ -104,14 +77,14 @@ pcps_assisted_acquisition_cc::~pcps_assisted_acquisition_cc() { try { - if (d_dump) + if (d_acq_params.dump) { d_dump_file.close(); } } catch (const std::ofstream::failure &e) { - std::cerr << "Problem closing Acquisition dump file: " << d_dump_filename << '\n'; + std::cerr << "Problem closing Acquisition dump file: " << d_acq_params.dump_filename << '\n'; } catch (const std::exception &e) { @@ -123,22 +96,6 @@ pcps_assisted_acquisition_cc::~pcps_assisted_acquisition_cc() void pcps_assisted_acquisition_cc::set_local_code(std::complex *code) { std::copy(code, code + d_fft_size, d_fft_if->get_inbuf()); -} - - -void pcps_assisted_acquisition_cc::init() -{ - d_gnss_synchro->Flag_valid_acquisition = false; - d_gnss_synchro->Flag_valid_symbol_output = false; - d_gnss_synchro->Flag_valid_pseudorange = false; - d_gnss_synchro->Flag_valid_word = false; - d_gnss_synchro->Acq_doppler_step = 0U; - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0ULL; - d_input_power = 0.0; - d_state = 0; - d_fft_if->execute(); // We need the FFT of local code // Conjugate the local code @@ -201,11 +158,11 @@ void pcps_assisted_acquisition_cc::redefine_grid() { if (this->d_disable_assist == true) { - d_doppler_max = d_config_doppler_max; - d_doppler_min = d_config_doppler_min; + d_doppler_max = d_acq_params.doppler_max; + d_doppler_min = d_acq_params.doppler_min; } // Create the search grid array - d_num_doppler_points = floor(std::abs(d_doppler_max - d_doppler_min) / d_doppler_step); + d_num_doppler_points = floor(std::abs(d_doppler_max - d_doppler_min) / d_acq_params.doppler_step); d_grid_data = std::vector>(d_num_doppler_points, std::vector(d_fft_size)); @@ -215,10 +172,10 @@ void pcps_assisted_acquisition_cc::redefine_grid() d_grid_doppler_wipeoffs = std::vector>>(d_num_doppler_points, std::vector>(d_fft_size)); for (int32_t doppler_index = 0; doppler_index < d_num_doppler_points; doppler_index++) { - doppler_hz = d_doppler_min + d_doppler_step * doppler_index; + doppler_hz = d_doppler_min + d_acq_params.doppler_step * doppler_index; // doppler search steps // compute the carrier doppler wipe-off signal and store it - phase_step_rad = static_cast(TWO_PI) * doppler_hz / static_cast(d_fs_in); + phase_step_rad = static_cast(TWO_PI) * doppler_hz / static_cast(d_acq_params.fs_in); std::array _phase{}; volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index].data(), -phase_step_rad, _phase.data(), d_fft_size); } @@ -253,12 +210,12 @@ float pcps_assisted_acquisition_cc::search_maximum() // 4- record the maximum peak and the associated synchronization parameters d_gnss_synchro->Acq_delay_samples = static_cast(index_time); - d_gnss_synchro->Acq_doppler_hz = static_cast(index_doppler * d_doppler_step + d_doppler_min); + d_gnss_synchro->Acq_doppler_hz = static_cast(index_doppler * d_acq_params.doppler_step + d_doppler_min); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; - d_gnss_synchro->Acq_doppler_step = d_doppler_step; + d_gnss_synchro->Acq_doppler_step = d_acq_params.doppler_step; // Record results to file if required - if (d_dump) + if (d_acq_params.dump) { std::stringstream filename; std::streamsize n = 2 * sizeof(float) * (d_fft_size); // complex file write @@ -299,7 +256,7 @@ int32_t pcps_assisted_acquisition_cc::compute_and_accumulate_grid(gr_vector_cons << d_gnss_synchro->PRN << " ,sample stamp: " << d_sample_counter << ", threshold: " << d_threshold << ", doppler_max: " << d_doppler_max - << ", doppler_step: " << d_doppler_step; + << ", doppler_step: " << d_acq_params.doppler_step; // 2- Doppler frequency search loop std::vector p_tmp_vector(d_fft_size); @@ -350,15 +307,17 @@ int pcps_assisted_acquisition_cc::general_work(int noutput_items, * S5. Negative_Acq: Send message and stop acq -> S0 */ + if (!d_active) + { + d_sample_counter += static_cast(ninput_items[0]); // sample counter + consume_each(ninput_items[0]); + return 0; + } + switch (d_state) { case 0: // S0. StandBy - if (d_active == true) - { - d_state = 1; - } - d_sample_counter += static_cast(ninput_items[0]); // sample counter - consume_each(ninput_items[0]); + d_state = 1; break; case 1: // S1. GetAssist get_assistance(); @@ -372,7 +331,7 @@ int pcps_assisted_acquisition_cc::general_work(int noutput_items, int32_t consumed_samples; consumed_samples = compute_and_accumulate_grid(input_items); d_well_count++; - if (d_well_count >= d_max_dwells) + if (d_well_count >= static_cast(d_acq_params.max_dwells)) { d_state = 3; } @@ -426,7 +385,7 @@ int pcps_assisted_acquisition_cc::general_work(int noutput_items, consume_each(ninput_items[0]); d_state = 0; // Copy and push current Gnss_Synchro to monitor queue - if (d_enable_monitor_output) + if (d_acq_params.enable_monitor_output) { auto **out = reinterpret_cast(&output_items[0]); Gnss_Synchro current_synchro_data = Gnss_Synchro(); diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.h index 4115130f2..6913beaee 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.h @@ -34,6 +34,8 @@ #ifndef GNSS_SDR_PCPS_ASSISTED_ACQUISITION_CC_H #define GNSS_SDR_PCPS_ASSISTED_ACQUISITION_CC_H +#include "acq_conf.h" +#include "acquisition_impl_interface.h" #include "channel_fsm.h" #include "gnss_sdr_fft.h" #include "gnss_synchro.h" @@ -55,16 +57,7 @@ class pcps_assisted_acquisition_cc; using pcps_assisted_acquisition_cc_sptr = gnss_shared_ptr; -pcps_assisted_acquisition_cc_sptr pcps_make_assisted_acquisition_cc( - int32_t max_dwells, - uint32_t sampled_ms, - int32_t doppler_max, - int32_t doppler_min, - int64_t fs_in, - int32_t samples_per_ms, - bool dump, - const std::string& dump_filename, - bool enable_monitor_output); +pcps_assisted_acquisition_cc_sptr pcps_make_assisted_acquisition_cc(const Acq_Conf& conf); /*! * \brief This class implements a Parallel Code Phase Search Acquisition. @@ -72,7 +65,7 @@ pcps_assisted_acquisition_cc_sptr pcps_make_assisted_acquisition_cc( * Check \ref Navitec2012 "An Open Source Galileo E1 Software Receiver", * Algorithm 1, for a pseudocode description of this implementation. */ -class pcps_assisted_acquisition_cc : public gr::block +class pcps_assisted_acquisition_cc : public acquisition_impl_interface { public: /*! @@ -85,7 +78,7 @@ public: * to exchange synchronization data between acquisition and tracking blocks. * \param p_gnss_synchro Satellite information shared by the processing blocks. */ - inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) + inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override { d_gnss_synchro = p_gnss_synchro; } @@ -93,29 +86,29 @@ public: /*! * \brief Returns the maximum peak of grid search. */ - inline uint32_t mag() const + inline uint32_t mag() const override { return d_test_statistics; } - /*! - * \brief Initializes acquisition algorithm. - */ - void init(); - /*! * \brief Sets local code for PCPS acquisition algorithm. * \param code - Pointer to the PRN code. */ - void set_local_code(std::complex* code); + void set_local_code(std::complex* code) override; /*! * \brief Starts acquisition algorithm, turning from standby mode to * active mode * \param active - bool that activates/deactivates the block. */ - inline void set_active(bool active) + inline void set_active(bool active) override { + if (!active) + { + d_state = 0; + } + d_active = active; } @@ -123,7 +116,7 @@ public: * \brief Set acquisition channel unique ID * \param channel - receiver channel. */ - inline void set_channel(uint32_t channel) + inline void set_channel(uint32_t channel) override { d_channel = channel; } @@ -131,7 +124,7 @@ public: /*! * \brief Set channel fsm associated to this acquisition instance */ - inline void set_channel_fsm(std::weak_ptr channel_fsm) + inline void set_channel_fsm(std::weak_ptr channel_fsm) override { d_channel_fsm = std::move(channel_fsm); } @@ -141,54 +134,28 @@ public: * \param threshold - Threshold for signal detection (check \ref Navitec2012, * Algorithm 1, for a definition of this threshold). */ - inline void set_threshold(float threshold) + inline void set_threshold(float threshold) override { d_threshold = threshold; } - inline void set_state(int32_t state) - { - d_state = state; - } - - /*! - * \brief Set maximum Doppler grid search - * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz]. - */ - inline void set_doppler_max(uint32_t doppler_max) - { - d_doppler_max = doppler_max; - } - - /*! - * \brief Set Doppler steps for the grid search - * \param doppler_step - Frequency bin of the search grid [Hz]. - */ - void set_doppler_step(uint32_t doppler_step); - /*! * \brief Parallel Code Phase Search Acquisition signal processing. */ int general_work(int noutput_items, gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items); + gr_vector_void_star& output_items) override; - void forecast(int noutput_items, gr_vector_int& ninput_items_required); private: + void forecast(int noutput_items, gr_vector_int& ninput_items_required) override; + friend pcps_assisted_acquisition_cc_sptr - pcps_make_assisted_acquisition_cc(int32_t max_dwells, uint32_t sampled_ms, - int32_t doppler_max, int32_t doppler_min, int64_t fs_in, - int32_t samples_per_ms, bool dump, - const std::string& dump_filename, bool enable_monitor_output); + pcps_make_assisted_acquisition_cc(const Acq_Conf& conf); - pcps_assisted_acquisition_cc(int32_t max_dwells, uint32_t sampled_ms, - int32_t doppler_max, int32_t doppler_min, int64_t fs_in, - int32_t samples_per_ms, bool dump, - const std::string& dump_filename, bool enable_monitor_output); + explicit pcps_assisted_acquisition_cc(const Acq_Conf& conf); - void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift, - int32_t doppler_offset); + void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift, int32_t doppler_offset); int32_t compute_and_accumulate_grid(gr_vector_const_void_star& input_items); float estimate_input_power(gr_vector_const_void_star& input_items) const; @@ -197,6 +164,33 @@ private: void reset_grid(); void redefine_grid(); + std::string d_satellite_str; + const Acq_Conf d_acq_params; + + std::ofstream d_dump_file; + + Gnss_Synchro* d_gnss_synchro; + + uint64_t d_sample_counter; + + float d_threshold; + float d_input_power; + float d_test_statistics; + + uint32_t d_channel; + uint32_t d_code_phase; + const uint32_t d_fft_size; + + const int32_t d_gnuradio_forecast_samples; + int32_t d_doppler_max; + int32_t d_doppler_min; + int32_t d_num_doppler_points; + int32_t d_state; + int32_t d_well_count; + + bool d_active; + bool d_disable_assist; + std::weak_ptr d_channel_fsm; std::unique_ptr d_fft_if; std::unique_ptr d_ifft; @@ -204,46 +198,6 @@ private: std::vector>> d_grid_doppler_wipeoffs; std::vector> d_grid_data; std::vector d_fft_codes; - - std::string d_satellite_str; - std::string d_dump_filename; - - std::ofstream d_dump_file; - - Gnss_Synchro* d_gnss_synchro; - - int64_t d_fs_in; - uint64_t d_sample_counter; - - float d_threshold; - float d_doppler_freq; - float d_input_power; - float d_test_statistics; - - uint32_t d_doppler_resolution; - uint32_t d_channel; - uint32_t d_sampled_ms; - uint32_t d_code_phase; - - int32_t d_samples_per_ms; - - uint32_t d_fft_size; - - int32_t d_max_dwells; - int32_t d_gnuradio_forecast_samples; - int32_t d_doppler_max; - int32_t d_doppler_min; - int32_t d_config_doppler_max; - int32_t d_config_doppler_min; - int32_t d_num_doppler_points; - int32_t d_doppler_step; - int32_t d_state; - int32_t d_well_count; - - bool d_active; - bool d_disable_assist; - bool d_dump; - bool d_enable_monitor_output; }; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc index 3e6860517..df378bc26 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc @@ -38,74 +38,59 @@ #endif -pcps_cccwsr_acquisition_cc_sptr pcps_cccwsr_make_acquisition_cc( - uint32_t sampled_ms, - uint32_t max_dwells, - uint32_t doppler_max, - int64_t fs_in, - int32_t samples_per_ms, - int32_t samples_per_code, - bool dump, - const std::string &dump_filename, - bool enable_monitor_output) +pcps_cccwsr_acquisition_cc_sptr pcps_cccwsr_make_acquisition_cc(const Acq_Conf &conf) { - return pcps_cccwsr_acquisition_cc_sptr( - new pcps_cccwsr_acquisition_cc(sampled_ms, max_dwells, doppler_max, fs_in, - samples_per_ms, samples_per_code, dump, dump_filename, enable_monitor_output)); + return pcps_cccwsr_acquisition_cc_sptr(new pcps_cccwsr_acquisition_cc(conf)); } -pcps_cccwsr_acquisition_cc::pcps_cccwsr_acquisition_cc( - uint32_t sampled_ms, - uint32_t max_dwells, - uint32_t doppler_max, - int64_t fs_in, - int32_t samples_per_ms, - int32_t samples_per_code, - bool dump, - const std::string &dump_filename, - bool enable_monitor_output) - : gr::block("pcps_cccwsr_acquisition_cc", - gr::io_signature::make(1, 1, static_cast(sizeof(gr_complex) * sampled_ms * samples_per_ms)), +pcps_cccwsr_acquisition_cc::pcps_cccwsr_acquisition_cc(const Acq_Conf &conf) + : acquisition_impl_interface("pcps_cccwsr_acquisition_cc", + gr::io_signature::make(1, 1, static_cast(sizeof(gr_complex) * conf.sampled_ms * conf.samples_per_ms)), gr::io_signature::make(0, 1, sizeof(Gnss_Synchro))), - d_dump_filename(dump_filename), + d_acq_params(conf), d_gnss_synchro(nullptr), - d_fs_in(fs_in), + d_fs_in(conf.fs_in), d_sample_counter(0ULL), d_threshold(0), - d_doppler_freq(0), d_mag(0), d_input_power(0.0), d_test_statistics(0), d_state(0), - d_samples_per_ms(samples_per_ms), - d_samples_per_code(samples_per_code), d_doppler_resolution(0), - d_doppler_max(doppler_max), - d_doppler_step(0), - d_sampled_ms(sampled_ms), - d_max_dwells(max_dwells), d_well_count(0), - d_fft_size(d_sampled_ms * d_samples_per_ms), + d_fft_size(conf.sampled_ms * conf.samples_per_ms), d_num_doppler_bins(0), d_code_phase(0), d_channel(0), d_active(false), - d_dump(dump), - d_enable_monitor_output(enable_monitor_output) + d_fft_if(gnss_fft_fwd_make_unique(d_fft_size)), + d_ifft(gnss_fft_rev_make_unique(d_fft_size)), + d_fft_code_data(d_fft_size), + d_fft_code_pilot(d_fft_size), + d_data_correlation(d_fft_size), + d_pilot_correlation(d_fft_size), + d_correlation_plus(d_fft_size), + d_correlation_minus(d_fft_size), + d_magnitude(d_fft_size) { this->message_port_register_out(pmt::mp("events")); - d_fft_code_data = std::vector(d_fft_size); - d_fft_code_pilot = std::vector(d_fft_size); - d_data_correlation = std::vector(d_fft_size); - d_pilot_correlation = std::vector(d_fft_size); - d_correlation_plus = std::vector(d_fft_size); - d_correlation_minus = std::vector(d_fft_size); - d_magnitude = std::vector(d_fft_size); + // Count the number of bins + for (auto doppler = -d_acq_params.doppler_max; doppler <= d_acq_params.doppler_max; doppler += d_acq_params.doppler_step) + { + d_num_doppler_bins++; + } - d_fft_if = gnss_fft_fwd_make_unique(d_fft_size); - d_ifft = gnss_fft_rev_make_unique(d_fft_size); + // Create the carrier Doppler wipeoff signals + d_grid_doppler_wipeoffs = std::vector>(d_num_doppler_bins, std::vector(d_fft_size)); + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + { + int32_t doppler = -d_acq_params.doppler_max + d_acq_params.doppler_step * doppler_index; + float phase_step_rad = static_cast(TWO_PI) * doppler / static_cast(d_fs_in); + std::array _phase{}; + volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index].data(), -phase_step_rad, _phase.data(), d_fft_size); + } } @@ -113,14 +98,14 @@ pcps_cccwsr_acquisition_cc::~pcps_cccwsr_acquisition_cc() { try { - if (d_dump) + if (d_acq_params.dump) { d_dump_file.close(); } } catch (const std::ofstream::failure &e) { - std::cerr << "Problem closing Acquisition dump file: " << d_dump_filename << '\n'; + std::cerr << "Problem closing Acquisition dump file: " << d_acq_params.dump_filename << '\n'; } catch (const std::exception &e) { @@ -150,92 +135,33 @@ void pcps_cccwsr_acquisition_cc::set_local_code(std::complex *code_data, } -void pcps_cccwsr_acquisition_cc::init() -{ - d_gnss_synchro->Flag_valid_acquisition = false; - d_gnss_synchro->Flag_valid_symbol_output = false; - d_gnss_synchro->Flag_valid_pseudorange = false; - d_gnss_synchro->Flag_valid_word = false; - d_gnss_synchro->Acq_doppler_step = 0U; - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0ULL; - d_mag = 0.0; - d_input_power = 0.0; - - // Count the number of bins - d_num_doppler_bins = 0; - for (auto doppler = static_cast(-d_doppler_max); - doppler <= static_cast(d_doppler_max); - doppler += d_doppler_step) - { - d_num_doppler_bins++; - } - - // Create the carrier Doppler wipeoff signals - d_grid_doppler_wipeoffs = std::vector>(d_num_doppler_bins, std::vector(d_fft_size)); - for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) - { - int32_t doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; - float phase_step_rad = static_cast(TWO_PI) * doppler / static_cast(d_fs_in); - std::array _phase{}; - volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index].data(), -phase_step_rad, _phase.data(), d_fft_size); - } -} - - -void pcps_cccwsr_acquisition_cc::set_state(int32_t state) -{ - d_state = state; - if (d_state == 1) - { - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0ULL; - d_gnss_synchro->Acq_doppler_step = 0U; - d_well_count = 0; - d_mag = 0.0; - d_input_power = 0.0; - d_test_statistics = 0.0; - } - else if (d_state == 0) - { - } - else - { - LOG(ERROR) << "State can only be set to 0 or 1"; - } -} - - int pcps_cccwsr_acquisition_cc::general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { int32_t acquisition_message = -1; // 0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL + if (!d_active) + { + d_sample_counter += static_cast(d_fft_size) * ninput_items[0]; // sample counter + consume_each(ninput_items[0]); + return 0; + } + switch (d_state) { case 0: { - if (d_active) - { - // restart acquisition variables - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0ULL; - d_gnss_synchro->Acq_doppler_step = 0U; - d_well_count = 0; - d_mag = 0.0; - d_input_power = 0.0; - d_test_statistics = 0.0; - - d_state = 1; - } - - d_sample_counter += static_cast(d_fft_size) * ninput_items[0]; // sample counter - consume_each(ninput_items[0]); - + // restart acquisition variables + d_gnss_synchro->Acq_delay_samples = 0.0; + d_gnss_synchro->Acq_doppler_hz = 0.0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; + d_gnss_synchro->Acq_doppler_step = 0U; + d_well_count = 0; + d_mag = 0.0; + d_input_power = 0.0; + d_test_statistics = 0.0; + d_state = 1; break; } case 1: @@ -259,8 +185,8 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items, DLOG(INFO) << "Channel: " << d_channel << " , doing acquisition of satellite: " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN << " ,sample stamp: " << d_sample_counter << ", threshold: " - << d_threshold << ", doppler_max: " << d_doppler_max - << ", doppler_step: " << d_doppler_step; + << d_threshold << ", doppler_max: " << d_acq_params.doppler_max + << ", doppler_step: " << d_acq_params.doppler_step; // 1- Compute the input signal power estimation volk_32fc_magnitude_squared_32f(d_magnitude.data(), in, d_fft_size); @@ -271,7 +197,7 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items, for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { // doppler search steps - doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + doppler = -d_acq_params.doppler_max + d_acq_params.doppler_step * doppler_index; volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), in, d_grid_doppler_wipeoffs[doppler_index].data(), d_fft_size); @@ -340,14 +266,14 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items, if (d_mag < magt) { d_mag = magt; - d_gnss_synchro->Acq_delay_samples = static_cast(indext % d_samples_per_code); + d_gnss_synchro->Acq_delay_samples = static_cast(indext % static_cast(d_acq_params.samples_per_code)); d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; - d_gnss_synchro->Acq_doppler_step = d_doppler_step; + d_gnss_synchro->Acq_doppler_step = d_acq_params.doppler_step; } // Record results to file if required - if (d_dump) + if (d_acq_params.dump) { std::stringstream filename; std::streamsize n = 2 * sizeof(float) * (d_fft_size); // complex file write @@ -370,7 +296,7 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items, { d_state = 2; // Positive acquisition } - else if (d_well_count == d_max_dwells) + else if (d_well_count == d_acq_params.max_dwells) { d_state = 3; // Negative acquisition } @@ -403,7 +329,7 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items, this->message_port_pub(pmt::mp("events"), pmt::from_long(acquisition_message)); // Copy and push current Gnss_Synchro to monitor queue - if (d_enable_monitor_output) + if (d_acq_params.enable_monitor_output) { auto **out = reinterpret_cast(&output_items[0]); Gnss_Synchro current_synchro_data = Gnss_Synchro(); diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.h index 83582cb42..1567481d3 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.h @@ -23,6 +23,8 @@ #ifndef GNSS_SDR_PCPS_CCCWSR_ACQUISITION_CC_H #define GNSS_SDR_PCPS_CCCWSR_ACQUISITION_CC_H +#include "acq_conf.h" +#include "acquisition_impl_interface.h" #include "channel_fsm.h" #include "gnss_sdr_fft.h" #include "gnss_synchro.h" @@ -44,22 +46,13 @@ class pcps_cccwsr_acquisition_cc; using pcps_cccwsr_acquisition_cc_sptr = gnss_shared_ptr; -pcps_cccwsr_acquisition_cc_sptr pcps_cccwsr_make_acquisition_cc( - uint32_t sampled_ms, - uint32_t max_dwells, - uint32_t doppler_max, - int64_t fs_in, - int32_t samples_per_ms, - int32_t samples_per_code, - bool dump, - const std::string& dump_filename, - bool enable_monitor_output); +pcps_cccwsr_acquisition_cc_sptr pcps_cccwsr_make_acquisition_cc(const Acq_Conf& conf); /*! * \brief This class implements a Parallel Code Phase Search Acquisition with * Coherent Channel Combining With Sign Recovery scheme. */ -class pcps_cccwsr_acquisition_cc : public gr::block +class pcps_cccwsr_acquisition_cc : public acquisition_impl_interface { public: /*! @@ -72,7 +65,7 @@ public: * to exchange synchronization data between acquisition and tracking blocks. * \param p_gnss_synchro Satellite information shared by the processing blocks. */ - inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) + inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override { d_gnss_synchro = p_gnss_synchro; } @@ -80,45 +73,38 @@ public: /*! * \brief Returns the maximum peak of grid search. */ - inline uint32_t mag() const + inline uint32_t mag() const override { return d_mag; } - /*! - * \brief Initializes acquisition algorithm. - */ - void init(); - /*! * \brief Sets local code for CCCWSR acquisition algorithm. * \param data_code - Pointer to the data PRN code. * \param pilot_code - Pointer to the pilot PRN code. */ - void set_local_code(std::complex* code_data, std::complex* code_pilot); + void set_local_code(std::complex* code_data, std::complex* code_pilot) override; /*! * \brief Starts acquisition algorithm, turning from standby mode to * active mode * \param active - bool that activates/deactivates the block. */ - inline void set_active(bool active) + inline void set_active(bool active) override { + if (!active) + { + d_state = 0; + } + d_active = active; } - /*! - * \brief If set to 1, ensures that acquisition starts at the - * first available sample. - * \param state - int=1 forces start of acquisition - */ - void set_state(int32_t state); - /*! * \brief Set acquisition channel unique ID * \param channel - receiver channel. */ - inline void set_channel(uint32_t channel) + inline void set_channel(uint32_t channel) override { d_channel = channel; } @@ -126,7 +112,7 @@ public: /*! * \brief Set channel fsm associated to this acquisition instance */ - inline void set_channel_fsm(std::weak_ptr channel_fsm) + inline void set_channel_fsm(std::weak_ptr channel_fsm) override { d_channel_fsm = std::move(channel_fsm); } @@ -136,50 +122,49 @@ public: * \param threshold - Threshold for signal detection (check \ref Navitec2012, * Algorithm 1, for a definition of this threshold). */ - inline void set_threshold(float threshold) + inline void set_threshold(float threshold) override { d_threshold = threshold; } - /*! - * \brief Set maximum Doppler grid search - * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz]. - */ - inline void set_doppler_max(uint32_t doppler_max) - { - d_doppler_max = doppler_max; - } - - /*! - * \brief Set Doppler steps for the grid search - * \param doppler_step - Frequency bin of the search grid [Hz]. - */ - inline void set_doppler_step(uint32_t doppler_step) - { - d_doppler_step = doppler_step; - } - /*! * \brief Coherent Channel Combining With Sign Recovery Acquisition signal processing. */ int general_work(int noutput_items, gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items); + gr_vector_void_star& output_items) override; private: friend pcps_cccwsr_acquisition_cc_sptr - pcps_cccwsr_make_acquisition_cc(uint32_t sampled_ms, uint32_t max_dwells, - uint32_t doppler_max, int64_t fs_in, - int32_t samples_per_ms, int32_t samples_per_code, - bool dump, const std::string& dump_filename, bool enable_monitor_output); + pcps_cccwsr_make_acquisition_cc(const Acq_Conf& conf); - pcps_cccwsr_acquisition_cc(uint32_t sampled_ms, uint32_t max_dwells, - uint32_t doppler_max, int64_t fs_in, - int32_t samples_per_ms, int32_t samples_per_code, - bool dump, const std::string& dump_filename, bool enable_monitor_output); + explicit pcps_cccwsr_acquisition_cc(const Acq_Conf& conf); - void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift, - int32_t doppler_offset); + void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift, int32_t doppler_offset); + + std::ofstream d_dump_file; + std::string d_satellite_str; + const Acq_Conf d_acq_params; + + Gnss_Synchro* d_gnss_synchro; + + int64_t d_fs_in; + uint64_t d_sample_counter; + + float d_threshold; + float d_mag; + float d_input_power; + float d_test_statistics; + + int32_t d_state; + uint32_t d_doppler_resolution; + uint32_t d_well_count; + const uint32_t d_fft_size; + uint32_t d_num_doppler_bins; + uint32_t d_code_phase; + uint32_t d_channel; + + bool d_active; std::weak_ptr d_channel_fsm; @@ -194,39 +179,6 @@ private: std::vector d_correlation_plus; std::vector d_correlation_minus; std::vector d_magnitude; - - std::ofstream d_dump_file; - std::string d_satellite_str; - std::string d_dump_filename; - - Gnss_Synchro* d_gnss_synchro; - - int64_t d_fs_in; - uint64_t d_sample_counter; - - float d_threshold; - float d_doppler_freq; - float d_mag; - float d_input_power; - float d_test_statistics; - - int32_t d_state; - int32_t d_samples_per_ms; - int32_t d_samples_per_code; - uint32_t d_doppler_resolution; - uint32_t d_doppler_max; - uint32_t d_doppler_step; - uint32_t d_sampled_ms; - uint32_t d_max_dwells; - uint32_t d_well_count; - uint32_t d_fft_size; - uint32_t d_num_doppler_bins; - uint32_t d_code_phase; - uint32_t d_channel; - - bool d_active; - bool d_dump; - bool d_enable_monitor_output; }; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.cc index 7738a2b9e..7737be7ce 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.cc @@ -56,65 +56,37 @@ #endif -pcps_opencl_acquisition_cc_sptr pcps_make_opencl_acquisition_cc( - uint32_t sampled_ms, uint32_t max_dwells, - uint32_t doppler_max, int64_t fs_in, - int samples_per_ms, int samples_per_code, - bool bit_transition_flag, - bool dump, - const std::string &dump_filename, - bool enable_monitor_output) +pcps_opencl_acquisition_cc_sptr pcps_make_opencl_acquisition_cc(const Acq_Conf &conf, uint32_t max_dwells) { - return pcps_opencl_acquisition_cc_sptr( - new pcps_opencl_acquisition_cc(sampled_ms, max_dwells, doppler_max, fs_in, samples_per_ms, - samples_per_code, bit_transition_flag, dump, dump_filename, enable_monitor_output)); + return pcps_opencl_acquisition_cc_sptr(new pcps_opencl_acquisition_cc(conf, max_dwells)); } -pcps_opencl_acquisition_cc::pcps_opencl_acquisition_cc( - uint32_t sampled_ms, - uint32_t max_dwells, - uint32_t doppler_max, - int64_t fs_in, - int samples_per_ms, - int samples_per_code, - bool bit_transition_flag, - bool dump, - const std::string &dump_filename, - bool enable_monitor_output) - : gr::block("pcps_opencl_acquisition_cc", - gr::io_signature::make(1, 1, static_cast(sizeof(gr_complex) * sampled_ms * samples_per_ms)), +pcps_opencl_acquisition_cc::pcps_opencl_acquisition_cc(const Acq_Conf &conf, uint32_t max_dwells) + : acquisition_impl_interface("pcps_opencl_acquisition_cc", + gr::io_signature::make(1, 1, static_cast(sizeof(gr_complex) * conf.sampled_ms * conf.samples_per_ms)), gr::io_signature::make(0, 1, sizeof(Gnss_Synchro))), + d_acq_params(conf), d_cl_fft_batch_size(1), - d_dump_filename(dump_filename), - d_fs_in(fs_in), d_sample_counter(0ULL), d_mag(0), d_input_power(0.0), - d_samples_per_ms(samples_per_ms), - d_samples_per_code(samples_per_code), d_state(0), - d_doppler_max(doppler_max), - d_sampled_ms(sampled_ms), d_max_dwells(max_dwells), d_well_count(0), - d_fft_size(d_sampled_ms * d_samples_per_ms), + d_fft_size(conf.sampled_ms * conf.samples_per_ms), d_fft_size_pow2(pow(2, ceil(log2(2 * d_fft_size)))), d_num_doppler_bins(0), d_in_dwell_count(0), - d_bit_transition_flag(bit_transition_flag), d_active(false), d_core_working(false), - d_dump(dump), - d_enable_monitor_output(enable_monitor_output) + d_in_buffer(d_max_dwells, std::vector(d_fft_size)), + d_magnitude(d_fft_size), + d_fft_codes(d_fft_size_pow2), + d_zero_vector(d_fft_size_pow2 - d_fft_size, 0.0) { this->message_port_register_out(pmt::mp("events")); - d_in_buffer = std::vector>(d_max_dwells, std::vector(d_fft_size)); - d_magnitude = std::vector(d_fft_size); - d_fft_codes = std::vector(d_fft_size_pow2); - d_zero_vector = std::vector(d_fft_size_pow2 - d_fft_size, 0.0); - d_opencl = init_opencl_environment("math_kernel.cl"); if (d_opencl != 0) @@ -125,6 +97,44 @@ pcps_opencl_acquisition_cc::pcps_opencl_acquisition_cc( // Inverse FFT d_ifft = gnss_fft_rev_make_unique(d_fft_size); } + + // Count the number of bins + for (int doppler = -d_acq_params.doppler_max; doppler <= d_acq_params.doppler_max; doppler += d_acq_params.doppler_step) + { + d_num_doppler_bins++; + } + + // Create the carrier Doppler wipeoff signals + d_grid_doppler_wipeoffs = std::vector>(d_num_doppler_bins, std::vector(d_fft_size)); + if (d_opencl == 0) + { + d_cl_buffer_grid_doppler_wipeoffs = new cl::Buffer *[d_num_doppler_bins]; + } + + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + { + int doppler = -d_acq_params.doppler_max + d_acq_params.doppler_step * doppler_index; + float phase_step_rad = static_cast(TWO_PI) * doppler / static_cast(d_acq_params.fs_in); + std::array _phase{}; + volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index].data(), -phase_step_rad, _phase.data(), d_fft_size); + + if (d_opencl == 0) + { + d_cl_buffer_grid_doppler_wipeoffs[doppler_index] = + new cl::Buffer(d_cl_context, CL_MEM_READ_WRITE, sizeof(gr_complex) * d_fft_size); + + d_cl_queue->enqueueWriteBuffer(*(d_cl_buffer_grid_doppler_wipeoffs[doppler_index]), + CL_TRUE, 0, sizeof(gr_complex) * d_fft_size, + d_grid_doppler_wipeoffs[doppler_index].data()); + } + } + + // zero padding in buffer_1 (FFT input) + if (d_opencl == 0) + { + d_cl_queue->enqueueWriteBuffer(*d_cl_buffer_1, CL_TRUE, sizeof(gr_complex) * d_fft_size, + sizeof(gr_complex) * (d_fft_size_pow2 - d_fft_size), d_zero_vector.data()); + } } @@ -148,14 +158,14 @@ pcps_opencl_acquisition_cc::~pcps_opencl_acquisition_cc() try { - if (d_dump) + if (d_acq_params.dump) { d_dump_file.close(); } } catch (const std::ofstream::failure &e) { - std::cerr << "Problem closing Acquisition dump file: " << d_dump_filename << '\n'; + std::cerr << "Problem closing Acquisition dump file: " << d_acq_params.dump_filename << '\n'; } catch (const std::exception &e) { @@ -253,62 +263,6 @@ int pcps_opencl_acquisition_cc::init_opencl_environment(const std::string &kerne } -void pcps_opencl_acquisition_cc::init() -{ - d_gnss_synchro->Flag_valid_acquisition = false; - d_gnss_synchro->Flag_valid_symbol_output = false; - d_gnss_synchro->Flag_valid_pseudorange = false; - d_gnss_synchro->Flag_valid_word = false; - d_gnss_synchro->Acq_doppler_step = 0U; - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0ULL; - d_mag = 0.0; - d_input_power = 0.0; - - // Count the number of bins - d_num_doppler_bins = 0; - for (int doppler = static_cast(-d_doppler_max); - doppler <= static_cast(d_doppler_max); - doppler += d_doppler_step) - { - d_num_doppler_bins++; - } - - // Create the carrier Doppler wipeoff signals - d_grid_doppler_wipeoffs = std::vector>(d_num_doppler_bins, std::vector(d_fft_size)); - if (d_opencl == 0) - { - d_cl_buffer_grid_doppler_wipeoffs = new cl::Buffer *[d_num_doppler_bins]; - } - - for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) - { - int doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; - float phase_step_rad = static_cast(TWO_PI) * doppler / static_cast(d_fs_in); - std::array _phase{}; - volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index].data(), -phase_step_rad, _phase.data(), d_fft_size); - - if (d_opencl == 0) - { - d_cl_buffer_grid_doppler_wipeoffs[doppler_index] = - new cl::Buffer(d_cl_context, CL_MEM_READ_WRITE, sizeof(gr_complex) * d_fft_size); - - d_cl_queue->enqueueWriteBuffer(*(d_cl_buffer_grid_doppler_wipeoffs[doppler_index]), - CL_TRUE, 0, sizeof(gr_complex) * d_fft_size, - d_grid_doppler_wipeoffs[doppler_index].data()); - } - } - - // zero padding in buffer_1 (FFT input) - if (d_opencl == 0) - { - d_cl_queue->enqueueWriteBuffer(*d_cl_buffer_1, CL_TRUE, sizeof(gr_complex) * d_fft_size, - sizeof(gr_complex) * (d_fft_size_pow2 - d_fft_size), d_zero_vector.data()); - } -} - - void pcps_opencl_acquisition_cc::set_local_code(std::complex *code) { if (d_opencl == 0) @@ -362,8 +316,8 @@ void pcps_opencl_acquisition_cc::acquisition_core_volk() DLOG(INFO) << "Channel: " << d_channel << " , doing acquisition of satellite: " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN << " ,sample stamp: " << d_sample_counter << ", threshold: " - << d_threshold << ", doppler_max: " << d_doppler_max - << ", doppler_step: " << d_doppler_step; + << d_threshold << ", doppler_max: " << d_acq_params.doppler_max + << ", doppler_step: " << d_acq_params.doppler_step; // 1- Compute the input signal power estimation volk_32fc_magnitude_squared_32f(d_magnitude.data(), d_in_buffer[d_well_count].data(), d_fft_size); @@ -374,7 +328,7 @@ void pcps_opencl_acquisition_cc::acquisition_core_volk() for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { // doppler search steps - doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + doppler = -d_acq_params.doppler_max + d_acq_params.doppler_step * doppler_index; volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), d_in_buffer[d_well_count].data(), d_grid_doppler_wipeoffs[doppler_index].data(), d_fft_size); @@ -410,12 +364,12 @@ void pcps_opencl_acquisition_cc::acquisition_core_volk() // the maximum test statistics in the previous dwell is greater than // current d_mag/d_input_power). Note that d_test_statistics is not // restarted between consecutive dwells in multidwell operation. - if (d_test_statistics < (d_mag / d_input_power) || !d_bit_transition_flag) + if (d_test_statistics < (d_mag / d_input_power) || !d_acq_params.bit_transition_flag) { - d_gnss_synchro->Acq_delay_samples = static_cast(indext % d_samples_per_code); + d_gnss_synchro->Acq_delay_samples = static_cast(indext % static_cast(d_acq_params.samples_per_code)); d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_gnss_synchro->Acq_samplestamp_samples = samplestamp; - d_gnss_synchro->Acq_doppler_step = d_doppler_step; + d_gnss_synchro->Acq_doppler_step = d_acq_params.doppler_step; // 5- Compute the test statistics and compare to the threshold // d_test_statistics = 2 * d_fft_size * d_mag / d_input_power; @@ -424,7 +378,7 @@ void pcps_opencl_acquisition_cc::acquisition_core_volk() } // Record results to file if required - if (d_dump) + if (d_acq_params.dump) { std::stringstream filename; std::streamsize n = 2 * sizeof(float) * (d_fft_size); // complex file write @@ -438,7 +392,7 @@ void pcps_opencl_acquisition_cc::acquisition_core_volk() } } - if (!d_bit_transition_flag) + if (!d_acq_params.bit_transition_flag) { if (d_test_statistics > d_threshold) { @@ -495,8 +449,8 @@ void pcps_opencl_acquisition_cc::acquisition_core_opencl() DLOG(INFO) << "Channel: " << d_channel << " , doing acquisition of satellite: " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN << " ,sample stamp: " << d_sample_counter << ", threshold: " - << d_threshold << ", doppler_max: " << d_doppler_max - << ", doppler_step: " << d_doppler_step; + << d_threshold << ", doppler_max: " << d_acq_params.doppler_max + << ", doppler_step: " << d_acq_params.doppler_step; // 1- Compute the input signal power estimation volk_32fc_magnitude_squared_32f(d_magnitude.data(), d_in_buffer[d_well_count].data(), d_fft_size); @@ -509,7 +463,7 @@ void pcps_opencl_acquisition_cc::acquisition_core_opencl() for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { // doppler search steps - doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + doppler = -d_acq_params.doppler_max + d_acq_params.doppler_step * doppler_index; // Multiply input signal with doppler wipe-off kernel = cl::Kernel(d_cl_program, "mult_vectors"); @@ -521,7 +475,7 @@ void pcps_opencl_acquisition_cc::acquisition_core_opencl() // In the previous operation, we store the result in the first d_fft_size positions // of d_cl_buffer_1. The rest d_fft_size_pow2-d_fft_size already have zeros - // (zero-padding is made in init() for optimization purposes). + // (zero-padding is made in constructor for optimization purposes). clFFT_ExecuteInterleaved((*d_cl_queue)(), d_cl_fft_plan, d_cl_fft_batch_size, clFFT_Forward, (*d_cl_buffer_1)(), (*d_cl_buffer_2)(), 0, nullptr, nullptr); @@ -571,12 +525,12 @@ void pcps_opencl_acquisition_cc::acquisition_core_opencl() // the maximum test statistics in the previous dwell is greater than // current d_mag/d_input_power). Note that d_test_statistics is not // restarted between consecutive dwells in multidwell operation. - if (d_test_statistics < (d_mag / d_input_power) || !d_bit_transition_flag) + if (d_test_statistics < (d_mag / d_input_power) || !d_acq_params.bit_transition_flag) { - d_gnss_synchro->Acq_delay_samples = static_cast(indext % d_samples_per_code); + d_gnss_synchro->Acq_delay_samples = static_cast(indext % static_cast(d_acq_params.samples_per_code)); d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_gnss_synchro->Acq_samplestamp_samples = samplestamp; - d_gnss_synchro->Acq_doppler_step = d_doppler_step; + d_gnss_synchro->Acq_doppler_step = d_acq_params.doppler_step; // 5- Compute the test statistics and compare to the threshold // d_test_statistics = 2 * d_fft_size * d_mag / d_input_power; @@ -585,7 +539,7 @@ void pcps_opencl_acquisition_cc::acquisition_core_opencl() } // Record results to file if required - if (d_dump) + if (d_acq_params.dump) { std::stringstream filename; std::streamsize n = 2 * sizeof(float) * (d_fft_size); // complex file write @@ -603,7 +557,7 @@ void pcps_opencl_acquisition_cc::acquisition_core_opencl() // end = tv.tv_sec *1e6 + tv.tv_usec; // std::cout << "Acq time = " << (end-begin) << " us\n"; - if (!d_bit_transition_flag) + if (!d_acq_params.bit_transition_flag) { if (d_test_statistics > d_threshold) { @@ -633,32 +587,6 @@ void pcps_opencl_acquisition_cc::acquisition_core_opencl() } -void pcps_opencl_acquisition_cc::set_state(int state) -{ - d_state = state; - if (d_state == 1) - { - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0ULL; - d_gnss_synchro->Acq_doppler_step = 0U; - d_well_count = 0; - d_mag = 0.0; - d_input_power = 0.0; - d_test_statistics = 0.0; - d_in_dwell_count = 0; - d_sample_counter_buffer.clear(); - } - else if (d_state == 0) - { - } - else - { - LOG(ERROR) << "State can only be set to 0 or 1"; - } -} - - int pcps_opencl_acquisition_cc::general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) @@ -765,7 +693,7 @@ int pcps_opencl_acquisition_cc::general_work(int noutput_items, this->message_port_pub(pmt::mp("events"), pmt::from_long(acquisition_message)); // Copy and push current Gnss_Synchro to monitor queue - if (d_enable_monitor_output) + if (d_acq_params.enable_monitor_output) { auto **out = reinterpret_cast(&output_items[0]); Gnss_Synchro current_synchro_data = Gnss_Synchro(); diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.h index caea4ffcc..206673c27 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_opencl_acquisition_cc.h @@ -38,6 +38,8 @@ #define GNSS_SDR_PCPS_OPENCL_ACQUISITION_CC_H #define CL_SILENCE_DEPRECATION +#include "acq_conf.h" +#include "acquisition_impl_interface.h" #include "channel_fsm.h" #include "gnss_block_interface.h" #include "gnss_sdr_fft.h" @@ -62,17 +64,7 @@ class pcps_opencl_acquisition_cc; using pcps_opencl_acquisition_cc_sptr = gnss_shared_ptr; -pcps_opencl_acquisition_cc_sptr pcps_make_opencl_acquisition_cc( - uint32_t sampled_ms, - uint32_t max_dwells, - uint32_t doppler_max, - int64_t fs_in, - int samples_per_ms, - int samples_per_code, - bool bit_transition_flag, - bool dump, - const std::string& dump_filename, - bool enable_monitor_output); +pcps_opencl_acquisition_cc_sptr pcps_make_opencl_acquisition_cc(const Acq_Conf& conf, uint32_t max_dwells); /*! * \brief This class implements a Parallel Code Phase Search Acquisition. @@ -80,7 +72,7 @@ pcps_opencl_acquisition_cc_sptr pcps_make_opencl_acquisition_cc( * Check \ref Navitec2012 "An Open Source Galileo E1 Software Receiver", * Algorithm 1, for a pseudocode description of this implementation. */ -class pcps_opencl_acquisition_cc : public gr::block +class pcps_opencl_acquisition_cc : public acquisition_impl_interface { public: /*! @@ -93,7 +85,7 @@ public: * to exchange synchronization data between acquisition and tracking blocks. * \param p_gnss_synchro Satellite information shared by the processing blocks. */ - inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) + inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override { d_gnss_synchro = p_gnss_synchro; } @@ -101,44 +93,37 @@ public: /*! * \brief Returns the maximum peak of grid search. */ - inline uint32_t mag() const + inline uint32_t mag() const override { return d_mag; } - /*! - * \brief Initializes acquisition algorithm. - */ - void init(); - /*! * \brief Sets local code for PCPS acquisition algorithm. * \param code - Pointer to the PRN code. */ - void set_local_code(std::complex* code); + void set_local_code(std::complex* code) override; /*! * \brief Starts acquisition algorithm, turning from standby mode to * active mode * \param active - bool that activates/deactivates the block. */ - inline void set_active(bool active) + inline void set_active(bool active) override { + if (!active) + { + d_state = 0; + } + d_active = active; } - /*! - * \brief If set to 1, ensures that acquisition starts at the - * first available sample. - * \param state - int=1 forces start of acquisition - */ - void set_state(int state); - /*! * \brief Set acquisition channel unique ID * \param channel - receiver channel. */ - inline void set_channel(uint32_t channel) + inline void set_channel(uint32_t channel) override { d_channel = channel; } @@ -146,7 +131,7 @@ public: /*! * \brief Set channel fsm associated to this acquisition instance */ - inline void set_channel_fsm(std::weak_ptr channel_fsm) + inline void set_channel_fsm(std::weak_ptr channel_fsm) override { d_channel_fsm = channel_fsm; } @@ -156,29 +141,11 @@ public: * \param threshold - Threshold for signal detection (check \ref Navitec2012, * Algorithm 1, for a definition of this threshold). */ - inline void set_threshold(float threshold) + inline void set_threshold(float threshold) override { d_threshold = threshold; } - /*! - * \brief Set maximum Doppler grid search - * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz]. - */ - inline void set_doppler_max(uint32_t doppler_max) - { - d_doppler_max = doppler_max; - } - - /*! - * \brief Set Doppler steps for the grid search - * \param doppler_step - Frequency bin of the search grid [Hz]. - */ - inline void set_doppler_step(uint32_t doppler_step) - { - d_doppler_step = doppler_step; - } - inline bool opencl_ready() const { bool ready = false; @@ -198,28 +165,15 @@ public: */ int general_work(int noutput_items, gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items); + gr_vector_void_star& output_items) override; private: friend pcps_opencl_acquisition_cc_sptr - pcps_make_opencl_acquisition_cc(uint32_t sampled_ms, uint32_t max_dwells, - uint32_t doppler_max, int64_t fs_in, - int samples_per_ms, int samples_per_code, - bool bit_transition_flag, - bool dump, - const std::string& dump_filename, - bool enable_monitor_output); + pcps_make_opencl_acquisition_cc(const Acq_Conf& conf, uint32_t max_dwells); - pcps_opencl_acquisition_cc(uint32_t sampled_ms, uint32_t max_dwells, - uint32_t doppler_max, int64_t fs_in, - int samples_per_ms, int samples_per_code, - bool bit_transition_flag, - bool dump, - const std::string& dump_filename, - bool enable_monitor_output); + explicit pcps_opencl_acquisition_cc(const Acq_Conf& conf, uint32_t max_dwells); - void calculate_magnitudes(gr_complex* fft_begin, int doppler_shift, - int doppler_offset); + void calculate_magnitudes(gr_complex* fft_begin, int doppler_shift, int doppler_offset); int init_opencl_environment(const std::string& kernel_filename); @@ -237,6 +191,37 @@ private: clFFT_Plan d_cl_fft_plan; cl_int d_cl_fft_batch_size; + std::string d_satellite_str; + const Acq_Conf d_acq_params; + + std::ofstream d_dump_file; + + Gnss_Synchro* d_gnss_synchro; + + uint64_t d_sample_counter; + + int* d_max_doppler_indexs; + + float d_threshold; + float d_mag; + float d_input_power; + float d_test_statistics; + + int d_state; + int d_opencl; + + uint32_t d_max_dwells; + uint32_t d_well_count; + const uint32_t d_fft_size; + uint32_t d_fft_size_pow2; + uint32_t d_num_doppler_bins; + uint32_t d_code_phase; + uint32_t d_channel; + uint32_t d_in_dwell_count; + + bool d_active; + bool d_core_working; + std::weak_ptr d_channel_fsm; std::unique_ptr d_fft_if; @@ -248,48 +233,6 @@ private: std::vector d_zero_vector; std::vector d_sample_counter_buffer; std::vector d_magnitude; - - std::string d_dump_filename; - std::string d_satellite_str; - - std::ofstream d_dump_file; - - Gnss_Synchro* d_gnss_synchro; - - int64_t d_fs_in; - uint64_t d_sample_counter; - - int* d_max_doppler_indexs; - - float d_threshold; - float d_doppler_freq; - float d_mag; - float d_input_power; - float d_test_statistics; - - int d_samples_per_ms; - int d_samples_per_code; - int d_state; - int d_opencl; - - uint32_t d_doppler_resolution; - uint32_t d_doppler_max; - uint32_t d_doppler_step; - uint32_t d_sampled_ms; - uint32_t d_max_dwells; - uint32_t d_well_count; - uint32_t d_fft_size; - uint32_t d_fft_size_pow2; - uint32_t d_num_doppler_bins; - uint32_t d_code_phase; - uint32_t d_channel; - uint32_t d_in_dwell_count; - - bool d_bit_transition_flag; - bool d_active; - bool d_core_working; - bool d_dump; - bool d_enable_monitor_output; }; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc index 4966efb70..50247d850 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc @@ -32,88 +32,68 @@ pcps_quicksync_acquisition_cc_sptr pcps_quicksync_make_acquisition_cc( - uint32_t folding_factor, - uint32_t sampled_ms, - uint32_t max_dwells, - uint32_t doppler_max, - int64_t fs_in, - int32_t samples_per_ms, - int32_t samples_per_code, - bool bit_transition_flag, - bool dump, - const std::string& dump_filename, - bool enable_monitor_output) + const Acq_Conf& conf, uint32_t folding_factor, uint32_t vector_length, uint32_t max_dwells, int32_t samples_per_code) { return pcps_quicksync_acquisition_cc_sptr( - new pcps_quicksync_acquisition_cc( - folding_factor, - sampled_ms, max_dwells, doppler_max, - fs_in, samples_per_ms, - samples_per_code, - bit_transition_flag, - dump, dump_filename, - enable_monitor_output)); + new pcps_quicksync_acquisition_cc(conf, folding_factor, vector_length, max_dwells, samples_per_code)); } pcps_quicksync_acquisition_cc::pcps_quicksync_acquisition_cc( - uint32_t folding_factor, - uint32_t sampled_ms, uint32_t max_dwells, - uint32_t doppler_max, int64_t fs_in, - int32_t samples_per_ms, int32_t samples_per_code, - bool bit_transition_flag, - bool dump, - const std::string& dump_filename, - bool enable_monitor_output) - : gr::block("pcps_quicksync_acquisition_cc", - gr::io_signature::make(1, 1, static_cast(sizeof(gr_complex) * sampled_ms * samples_per_ms)), + const Acq_Conf& conf, uint32_t folding_factor, uint32_t vector_length, uint32_t max_dwells, int32_t samples_per_code) + : acquisition_impl_interface("pcps_quicksync_acquisition_cc", + gr::io_signature::make(1, 1, static_cast(sizeof(gr_complex) * vector_length)), gr::io_signature::make(0, 1, sizeof(Gnss_Synchro))), - d_dump_filename(dump_filename), + d_acq_params(conf), d_gnss_synchro(nullptr), - d_fs_in(fs_in), d_sample_counter(0ULL), d_noise_floor_power(0), d_threshold(0), - d_doppler_freq(0), d_mag(0), d_input_power(0.0), d_test_statistics(0), - d_samples_per_ms(samples_per_ms), + d_vector_length(vector_length), d_samples_per_code(samples_per_code), d_state(0), d_channel(0), d_folding_factor(folding_factor), - d_doppler_resolution(0), - d_doppler_max(doppler_max), - d_doppler_step(0), - d_sampled_ms(sampled_ms), d_max_dwells(max_dwells), d_well_count(0), - d_fft_size((d_samples_per_code) / d_folding_factor), + d_fft_size(d_samples_per_code / d_folding_factor), d_num_doppler_bins(0), d_code_phase(0), - d_bit_transition_flag(bit_transition_flag), d_active(false), - d_dump(dump), - d_enable_monitor_output(enable_monitor_output) + d_fft_if(gnss_fft_fwd_make_unique(d_fft_size)), + d_ifft(gnss_fft_rev_make_unique(d_fft_size)), + d_code(d_samples_per_code, lv_cmake(0.0F, 0.0F)), + d_fft_codes(d_fft_size), + d_signal_folded(d_fft_size), + d_code_folded(d_fft_size, lv_cmake(0.0F, 0.0F)), + d_magnitude(d_samples_per_code * d_folding_factor), + d_corr_output_f(d_folding_factor), + d_magnitude_folded(d_fft_size), + d_possible_delay(d_folding_factor) { this->message_port_register_out(pmt::mp("events")); - d_fft_codes = std::vector(d_fft_size); - d_magnitude = std::vector(d_samples_per_code * d_folding_factor); - d_magnitude_folded = std::vector(d_fft_size); - d_possible_delay = std::vector(d_folding_factor); - d_corr_output_f = std::vector(d_folding_factor); - // Create the d_code vector, which would store the values of the code in its // original form to perform later correlation in time domain - d_code = std::vector(d_samples_per_code, lv_cmake(0.0F, 0.0F)); - d_fft_if = gnss_fft_fwd_make_unique(d_fft_size); - d_ifft = gnss_fft_rev_make_unique(d_fft_size); + // Count the number of bins + for (auto doppler = -d_acq_params.doppler_max; doppler <= d_acq_params.doppler_max; doppler += d_acq_params.doppler_step) + { + d_num_doppler_bins++; + } - d_code_folded = std::vector(d_fft_size, lv_cmake(0.0F, 0.0F)); - d_signal_folded = std::vector(d_fft_size); + // Create the carrier Doppler wipeoff signals + d_grid_doppler_wipeoffs = std::vector>(d_num_doppler_bins, std::vector(d_samples_per_code * d_folding_factor)); + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + { + int32_t doppler = -d_acq_params.doppler_max + d_acq_params.doppler_step * doppler_index; + float phase_step_rad = static_cast(TWO_PI) * doppler / static_cast(d_acq_params.fs_in); + std::array _phase{}; + volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index].data(), -phase_step_rad, _phase.data(), d_samples_per_code * d_folding_factor); + } } @@ -121,14 +101,14 @@ pcps_quicksync_acquisition_cc::~pcps_quicksync_acquisition_cc() { try { - if (d_dump) + if (d_acq_params.dump) { d_dump_file.close(); } } catch (const std::ofstream::failure& e) { - std::cerr << "Problem closing Acquisition dump file: " << d_dump_filename << '\n'; + std::cerr << "Problem closing Acquisition dump file: " << d_acq_params.dump_filename << '\n'; } catch (const std::exception& e) { @@ -162,69 +142,6 @@ void pcps_quicksync_acquisition_cc::set_local_code(std::complex* code) } -void pcps_quicksync_acquisition_cc::init() -{ - d_gnss_synchro->Flag_valid_acquisition = false; - d_gnss_synchro->Flag_valid_symbol_output = false; - d_gnss_synchro->Flag_valid_pseudorange = false; - d_gnss_synchro->Flag_valid_word = false; - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0ULL; - d_gnss_synchro->Acq_doppler_step = 0U; - d_mag = 0.0; - d_input_power = 0.0; - - if (d_doppler_step == 0) - { - d_doppler_step = 250; - } - - // Count the number of bins - d_num_doppler_bins = 0; - for (auto doppler = static_cast(-d_doppler_max); - doppler <= static_cast(d_doppler_max); - doppler += d_doppler_step) - { - d_num_doppler_bins++; - } - - // Create the carrier Doppler wipeoff signals - d_grid_doppler_wipeoffs = std::vector>(d_num_doppler_bins, std::vector(d_samples_per_code * d_folding_factor)); - for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) - { - int32_t doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; - float phase_step_rad = static_cast(TWO_PI) * doppler / static_cast(d_fs_in); - std::array _phase{}; - volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index].data(), -phase_step_rad, _phase.data(), d_samples_per_code * d_folding_factor); - } -} - - -void pcps_quicksync_acquisition_cc::set_state(int32_t state) -{ - d_state = state; - if (d_state == 1) - { - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0ULL; - d_gnss_synchro->Acq_doppler_step = 0U; - d_well_count = 0; - d_mag = 0.0; - d_input_power = 0.0; - d_test_statistics = 0.0; - d_active = true; - } - else if (d_state == 0) - { - } - else - { - LOG(ERROR) << "State can only be set to 0 or 1"; - } -} - int pcps_quicksync_acquisition_cc::general_work(int noutput_items, gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, gr_vector_void_star& output_items) @@ -241,29 +158,29 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, */ // DLOG(INFO) << "START GENERAL WORK"; int32_t acquisition_message = -1; // 0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL + + if (!d_active) + { + d_sample_counter += static_cast(d_vector_length) * ninput_items[0]; // sample counter + consume_each(ninput_items[0]); + return 0; + } + switch (d_state) { case 0: { - // DLOG(INFO) << "START CASE 0"; - if (d_active) - { - // restart acquisition variables - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0ULL; - d_gnss_synchro->Acq_doppler_step = 0U; - d_well_count = 0; - d_mag = 0.0; - d_input_power = 0.0; - d_test_statistics = 0.0; + // restart acquisition variables + d_gnss_synchro->Acq_delay_samples = 0.0; + d_gnss_synchro->Acq_doppler_hz = 0.0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; + d_gnss_synchro->Acq_doppler_step = 0U; + d_well_count = 0; + d_mag = 0.0; + d_input_power = 0.0; + d_test_statistics = 0.0; - d_state = 1; - } - - d_sample_counter += static_cast(d_sampled_ms) * d_samples_per_ms * ninput_items[0]; // sample counter - consume_each(ninput_items[0]); - // DLOG(INFO) << "END CASE 0"; + d_state = 1; break; } @@ -295,7 +212,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, d_test_statistics = 0.0; d_noise_floor_power = 0.0; - d_sample_counter += static_cast(d_sampled_ms) * d_samples_per_ms; // sample counter + d_sample_counter += static_cast(d_vector_length); // sample counter d_well_count++; @@ -305,8 +222,8 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, << " ,algorithm: pcps_quicksync_acquisition" << " ,folding factor: " << d_folding_factor << " ,sample stamp: " << d_sample_counter << ", threshold: " - << d_threshold << ", doppler_max: " << d_doppler_max - << ", doppler_step: " << d_doppler_step << ", Signal Size: " + << d_threshold << ", doppler_max: " << d_acq_params.doppler_max + << ", doppler_step: " << d_acq_params.doppler_step << ", Signal Size: " << d_samples_per_code * d_folding_factor; @@ -326,7 +243,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, // Doppler search steps and then multiplication of the incoming // signal with the doppler wipeoffs to eliminate frequency offset - doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + doppler = -d_acq_params.doppler_max + d_acq_params.doppler_step * doppler_index; // Perform multiplication of the incoming signal with the // complex exponential vector. This removes the frequency doppler @@ -383,7 +300,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, // the maximum test statistics in the previous dwell is greater than // current d_mag/d_input_power). Note that d_test_statistics is not // restarted between consecutive dwells in multidwell operation. - if (d_test_statistics < (d_mag / d_input_power) || !d_bit_transition_flag) + if (d_test_statistics < (d_mag / d_input_power) || !d_acq_params.bit_transition_flag) { uint32_t detected_delay_samples_folded = 0; detected_delay_samples_folded = (indext % d_samples_per_code); @@ -420,7 +337,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, d_gnss_synchro->Acq_delay_samples = static_cast(d_possible_delay[indext]); d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; - d_gnss_synchro->Acq_doppler_step = d_doppler_step; + d_gnss_synchro->Acq_doppler_step = d_acq_params.doppler_step; // 5- Compute the test statistics and compare to the threshold d_test_statistics = 2 * d_fft_size * d_mag / d_input_power; d_test_statistics = d_mag / d_input_power; @@ -428,7 +345,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, } // Record results to file if required - if (d_dump) + if (d_acq_params.dump) { // Since QuickSYnc performs a folded correlation in frequency by means // of the FFT, it is essential to also keep the values obtained from the @@ -445,7 +362,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, } } - if (!d_bit_transition_flag) + if (!d_acq_params.bit_transition_flag) { if (d_test_statistics > d_threshold) { @@ -499,7 +416,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, d_active = false; d_state = 0; - d_sample_counter += static_cast(d_sampled_ms) * d_samples_per_ms * ninput_items[0]; // sample counter + d_sample_counter += static_cast(d_vector_length) * ninput_items[0]; // sample counter consume_each(ninput_items[0]); acquisition_message = 1; @@ -507,7 +424,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, // DLOG(INFO) << "END CASE 2"; // Copy and push current Gnss_Synchro to monitor queue - if (d_enable_monitor_output) + if (d_acq_params.enable_monitor_output) { auto** out = reinterpret_cast(&output_items[0]); Gnss_Synchro current_synchro_data = Gnss_Synchro(); @@ -542,7 +459,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, d_active = false; d_state = 0; - d_sample_counter += static_cast(d_sampled_ms) * d_samples_per_ms * ninput_items[0]; // sample counter + d_sample_counter += static_cast(d_vector_length) * ninput_items[0]; // sample counter consume_each(ninput_items[0]); acquisition_message = 2; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.h index 44bb5cfb7..ad52fc838 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.h @@ -37,15 +37,15 @@ #ifndef GNSS_SDR_PCPS_QUICKSYNC_ACQUISITION_CC_H #define GNSS_SDR_PCPS_QUICKSYNC_ACQUISITION_CC_H +#include "acq_conf.h" +#include "acquisition_impl_interface.h" #include "channel_fsm.h" #include "gnss_sdr_fft.h" #include "gnss_synchro.h" #include #include -#include #include #include -#include #include // for weak_ptr #include #include @@ -62,17 +62,7 @@ class pcps_quicksync_acquisition_cc; using pcps_quicksync_acquisition_cc_sptr = gnss_shared_ptr; pcps_quicksync_acquisition_cc_sptr pcps_quicksync_make_acquisition_cc( - uint32_t folding_factor, - uint32_t sampled_ms, - uint32_t max_dwells, - uint32_t doppler_max, - int64_t fs_in, - int32_t samples_per_ms, - int32_t samples_per_code, - bool bit_transition_flag, - bool dump, - const std::string& dump_filename, - bool enable_monitor_output); + const Acq_Conf& conf, uint32_t folding_factor, uint32_t vector_length, uint32_t max_dwells, int32_t samples_per_code); /*! * \brief This class implements a Parallel Code Phase Search Acquisition with @@ -81,7 +71,7 @@ pcps_quicksync_acquisition_cc_sptr pcps_quicksync_make_acquisition_cc( * Check \ref Navitec2012 "Faster GPS via the Sparse Fourier Transform", * for details of its implementation and functionality. */ -class pcps_quicksync_acquisition_cc : public gr::block +class pcps_quicksync_acquisition_cc : public acquisition_impl_interface { public: /*! @@ -94,7 +84,7 @@ public: * to exchange synchronization data between acquisition and tracking blocks. * \param p_gnss_synchro Satellite information shared by the processing blocks. */ - inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) + inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override { d_gnss_synchro = p_gnss_synchro; } @@ -102,44 +92,37 @@ public: /*! * \brief Returns the maximum peak of grid search. */ - inline uint32_t mag() const + inline uint32_t mag() const override { return d_mag; } - /*! - * \brief Initializes acquisition algorithm. - */ - void init(); - /*! * \brief Sets local code for PCPS acquisition algorithm. * \param code - Pointer to the PRN code. */ - void set_local_code(std::complex* code); + void set_local_code(std::complex* code) override; /*! * \brief Starts acquisition algorithm, turning from standby mode to * active mode * \param active - bool that activates/deactivates the block. */ - inline void set_active(bool active) + inline void set_active(bool active) override { + if (!active) + { + d_state = 0; + } + d_active = active; } - /*! - * \brief If set to 1, ensures that acquisition starts at the - * first available sample. - * \param state - int=1 forces start of acquisition - */ - void set_state(int32_t state); - /*! * \brief Set acquisition channel unique ID * \param channel - receiver channel. */ - inline void set_channel(uint32_t channel) + inline void set_channel(uint32_t channel) override { d_channel = channel; } @@ -147,7 +130,7 @@ public: /*! * \brief Set channel fsm associated to this acquisition instance */ - inline void set_channel_fsm(std::weak_ptr channel_fsm) + inline void set_channel_fsm(std::weak_ptr channel_fsm) override { d_channel_fsm = std::move(channel_fsm); } @@ -157,58 +140,54 @@ public: * \param threshold - Threshold for signal detection (check \ref Navitec2012, * Algorithm 1, for a definition of this threshold). */ - inline void set_threshold(float threshold) + inline void set_threshold(float threshold) override { d_threshold = threshold; } - /*! - * \brief Set maximum Doppler grid search - * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz]. - */ - inline void set_doppler_max(uint32_t doppler_max) - { - d_doppler_max = doppler_max; - } - - /*! - * \brief Set Doppler steps for the grid search - * \param doppler_step - Frequency bin of the search grid [Hz]. - */ - inline void set_doppler_step(uint32_t doppler_step) - { - d_doppler_step = doppler_step; - } - /*! * \brief Parallel Code Phase Search Acquisition signal processing. */ int general_work(int noutput_items, gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items); + gr_vector_void_star& output_items) override; private: friend pcps_quicksync_acquisition_cc_sptr - pcps_quicksync_make_acquisition_cc(uint32_t folding_factor, - uint32_t sampled_ms, uint32_t max_dwells, - uint32_t doppler_max, int64_t fs_in, - int32_t samples_per_ms, int32_t samples_per_code, - bool bit_transition_flag, - bool dump, - const std::string& dump_filename, - bool enable_monitor_output); + pcps_quicksync_make_acquisition_cc( + const Acq_Conf& conf, uint32_t folding_factor, uint32_t vector_length, uint32_t max_dwells, int32_t samples_per_code); - pcps_quicksync_acquisition_cc(uint32_t folding_factor, - uint32_t sampled_ms, uint32_t max_dwells, - uint32_t doppler_max, int64_t fs_in, - int32_t samples_per_ms, int32_t samples_per_code, - bool bit_transition_flag, - bool dump, - const std::string& dump_filename, - bool enable_monitor_output); + explicit pcps_quicksync_acquisition_cc( + const Acq_Conf& conf, uint32_t folding_factor, uint32_t vector_length, uint32_t max_dwells, int32_t samples_per_code); - void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift, - int32_t doppler_offset); + void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift, int32_t doppler_offset); + + std::string d_satellite_str; + const Acq_Conf d_acq_params; + + std::ofstream d_dump_file; + + Gnss_Synchro* d_gnss_synchro; + + uint64_t d_sample_counter; + + float d_noise_floor_power; + float d_threshold; + float d_mag; + float d_input_power; + float d_test_statistics; + const int32_t d_vector_length; + const int32_t d_samples_per_code; + int32_t d_state; + uint32_t d_channel; + const uint32_t d_folding_factor; // also referred in the paper as 'p' + const uint32_t d_max_dwells; + uint32_t d_well_count; + const uint32_t d_fft_size; + uint32_t d_num_doppler_bins; + uint32_t d_code_phase; + + bool d_active; std::weak_ptr d_channel_fsm; @@ -224,42 +203,6 @@ private: std::vector d_corr_output_f; std::vector d_magnitude_folded; std::vector d_possible_delay; - - std::string d_dump_filename; - std::string d_satellite_str; - - std::ofstream d_dump_file; - - Gnss_Synchro* d_gnss_synchro; - - int64_t d_fs_in; - uint64_t d_sample_counter; - - float d_noise_floor_power; - float d_threshold; - float d_doppler_freq; - float d_mag; - float d_input_power; - float d_test_statistics; - int32_t d_samples_per_ms; - int32_t d_samples_per_code; - int32_t d_state; - uint32_t d_channel; - uint32_t d_folding_factor; // also referred in the paper as 'p' - uint32_t d_doppler_resolution; - uint32_t d_doppler_max; - uint32_t d_doppler_step; - uint32_t d_sampled_ms; - uint32_t d_max_dwells; - uint32_t d_well_count; - uint32_t d_fft_size; - uint32_t d_num_doppler_bins; - uint32_t d_code_phase; - - bool d_bit_transition_flag; - bool d_active; - bool d_dump; - bool d_enable_monitor_output; }; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc index dcabf4e22..9137dd473 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc @@ -52,75 +52,65 @@ pcps_tong_acquisition_cc_sptr pcps_tong_make_acquisition_cc( - uint32_t sampled_ms, - uint32_t doppler_max, - int64_t fs_in, - int32_t samples_per_ms, - int32_t samples_per_code, + const Acq_Conf &conf, uint32_t tong_init_val, uint32_t tong_max_val, - uint32_t tong_max_dwells, - bool dump, - const std::string &dump_filename, - bool enable_monitor_output) + uint32_t tong_max_dwellst) { return pcps_tong_acquisition_cc_sptr( - new pcps_tong_acquisition_cc(sampled_ms, doppler_max, fs_in, samples_per_ms, samples_per_code, - tong_init_val, tong_max_val, tong_max_dwells, dump, dump_filename, enable_monitor_output)); + new pcps_tong_acquisition_cc(conf, tong_init_val, tong_max_val, tong_max_dwellst)); } pcps_tong_acquisition_cc::pcps_tong_acquisition_cc( - uint32_t sampled_ms, - uint32_t doppler_max, - int64_t fs_in, - int32_t samples_per_ms, - int32_t samples_per_code, + const Acq_Conf &conf, uint32_t tong_init_val, uint32_t tong_max_val, - uint32_t tong_max_dwells, - bool dump, - const std::string &dump_filename, - bool enable_monitor_output) - : gr::block("pcps_tong_acquisition_cc", - gr::io_signature::make(1, 1, static_cast(sizeof(gr_complex) * sampled_ms * samples_per_ms)), + uint32_t tong_max_dwells) + : acquisition_impl_interface("pcps_tong_acquisition_cc", + gr::io_signature::make(1, 1, static_cast(sizeof(gr_complex) * conf.sampled_ms * conf.samples_per_ms)), gr::io_signature::make(0, 1, sizeof(Gnss_Synchro))), - d_dump_filename(dump_filename), + d_acq_params(conf), d_gnss_synchro(nullptr), - d_fs_in(fs_in), d_sample_counter(0ULL), d_threshold(0), - d_doppler_freq(0), d_mag(0), d_input_power(0.0), d_test_statistics(0), d_state(0), - d_samples_per_ms(samples_per_ms), - d_samples_per_code(samples_per_code), d_channel(0), - d_doppler_resolution(0), - d_doppler_max(doppler_max), - d_doppler_step(0), - d_sampled_ms(sampled_ms), d_dwell_count(0), d_tong_init_val(tong_init_val), d_tong_max_val(tong_max_val), d_tong_max_dwells(tong_max_dwells), d_tong_count(d_tong_init_val), - d_fft_size(d_sampled_ms * d_samples_per_ms), + d_fft_size(conf.sampled_ms * conf.samples_per_ms), d_num_doppler_bins(0), d_code_phase(0), d_active(false), - d_dump(dump), - d_enable_monitor_output(enable_monitor_output) + d_fft_if(gnss_fft_fwd_make_unique(d_fft_size)), + d_ifft(gnss_fft_rev_make_unique(d_fft_size)), + d_fft_codes(d_fft_size), + d_magnitude(d_fft_size) { this->message_port_register_out(pmt::mp("events")); - d_fft_codes = std::vector(d_fft_size); - d_magnitude = std::vector(d_fft_size); + // Count the number of bins + for (auto doppler = -d_acq_params.doppler_max; doppler <= d_acq_params.doppler_max; doppler += d_acq_params.doppler_step) + { + d_num_doppler_bins++; + } - d_fft_if = gnss_fft_fwd_make_unique(d_fft_size); - d_ifft = gnss_fft_rev_make_unique(d_fft_size); + // Create the carrier Doppler wipeoff signals and allocate data grid. + d_grid_doppler_wipeoffs = std::vector>(d_num_doppler_bins, std::vector(d_fft_size)); + d_grid_data = std::vector>(d_num_doppler_bins, std::vector(d_fft_size, 0.0)); + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + { + int32_t doppler = -d_acq_params.doppler_max + d_acq_params.doppler_step * doppler_index; + float phase_step_rad = static_cast(TWO_PI) * doppler / static_cast(d_acq_params.fs_in); + std::array _phase{}; + volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index].data(), -phase_step_rad, _phase.data(), d_fft_size); + } } @@ -128,14 +118,14 @@ pcps_tong_acquisition_cc::~pcps_tong_acquisition_cc() { try { - if (d_dump) + if (d_acq_params.dump) { d_dump_file.close(); } } catch (const std::ofstream::failure &e) { - std::cerr << "Problem closing Acquisition dump file: " << d_dump_filename << '\n'; + std::cerr << "Problem closing Acquisition dump file: " << d_acq_params.dump_filename << '\n'; } catch (const std::exception &e) { @@ -155,111 +145,43 @@ void pcps_tong_acquisition_cc::set_local_code(std::complex *code) } -void pcps_tong_acquisition_cc::init() -{ - d_gnss_synchro->Flag_valid_acquisition = false; - d_gnss_synchro->Flag_valid_symbol_output = false; - d_gnss_synchro->Flag_valid_pseudorange = false; - d_gnss_synchro->Flag_valid_word = false; - d_gnss_synchro->Acq_doppler_step = 0U; - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0ULL; - d_mag = 0.0; - d_input_power = 0.0; - - // Count the number of bins - d_num_doppler_bins = 0; - for (auto doppler = static_cast(-d_doppler_max); - doppler <= static_cast(d_doppler_max); - doppler += d_doppler_step) - { - d_num_doppler_bins++; - } - - // Create the carrier Doppler wipeoff signals and allocate data grid. - d_grid_doppler_wipeoffs = std::vector>(d_num_doppler_bins, std::vector(d_fft_size)); - d_grid_data = std::vector>(d_num_doppler_bins, std::vector(d_fft_size, 0.0)); - for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) - { - int32_t doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; - float phase_step_rad = static_cast(TWO_PI) * doppler / static_cast(d_fs_in); - std::array _phase{}; - volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index].data(), -phase_step_rad, _phase.data(), d_fft_size); - } -} - - -void pcps_tong_acquisition_cc::set_state(int32_t state) -{ - d_state = state; - if (d_state == 1) - { - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0ULL; - d_gnss_synchro->Acq_doppler_step = 0U; - d_dwell_count = 0; - d_tong_count = d_tong_init_val; - d_mag = 0.0; - d_input_power = 0.0; - d_test_statistics = 0.0; - - for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) - { - for (uint32_t i = 0; i < d_fft_size; i++) - { - d_grid_data[doppler_index][i] = 0.0; - } - } - } - else if (d_state == 0) - { - } - else - { - LOG(ERROR) << "State can only be set to 0 or 1"; - } -} - - int pcps_tong_acquisition_cc::general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { int32_t acquisition_message = -1; // 0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL + if (!d_active) + { + d_sample_counter += static_cast(d_fft_size) * ninput_items[0]; // sample counter + consume_each(ninput_items[0]); + return 0; + } + switch (d_state) { case 0: { - if (d_active) + // restart acquisition variables + d_gnss_synchro->Acq_delay_samples = 0.0; + d_gnss_synchro->Acq_doppler_hz = 0.0; + d_gnss_synchro->Acq_samplestamp_samples = 0ULL; + d_gnss_synchro->Acq_doppler_step = 0U; + d_dwell_count = 0; + d_tong_count = d_tong_init_val; + d_mag = 0.0; + d_input_power = 0.0; + d_test_statistics = 0.0; + + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { - // restart acquisition variables - d_gnss_synchro->Acq_delay_samples = 0.0; - d_gnss_synchro->Acq_doppler_hz = 0.0; - d_gnss_synchro->Acq_samplestamp_samples = 0ULL; - d_gnss_synchro->Acq_doppler_step = 0U; - d_dwell_count = 0; - d_tong_count = d_tong_init_val; - d_mag = 0.0; - d_input_power = 0.0; - d_test_statistics = 0.0; - - for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t i = 0; i < d_fft_size; i++) { - for (uint32_t i = 0; i < d_fft_size; i++) - { - d_grid_data[doppler_index][i] = 0.0; - } + d_grid_data[doppler_index][i] = 0.0; } - - d_state = 1; } - d_sample_counter += static_cast(d_fft_size) * ninput_items[0]; // sample counter - consume_each(ninput_items[0]); - + d_state = 1; break; } @@ -281,8 +203,8 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items, DLOG(INFO) << "Channel: " << d_channel << " , doing acquisition of satellite: " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN << " ,sample stamp: " << d_sample_counter << ", threshold: " - << d_threshold << ", doppler_max: " << d_doppler_max - << ", doppler_step: " << d_doppler_step; + << d_threshold << ", doppler_max: " << d_acq_params.doppler_max + << ", doppler_step: " << d_acq_params.doppler_step; // 1- Compute the input signal power estimation volk_32fc_magnitude_squared_32f(d_magnitude.data(), in, d_fft_size); @@ -293,7 +215,7 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items, for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { // doppler search steps - doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + doppler = -static_cast(d_acq_params.doppler_max) + d_acq_params.doppler_step * doppler_index; volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), in, d_grid_doppler_wipeoffs[doppler_index].data(), d_fft_size); @@ -330,14 +252,14 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items, if (d_mag < magt) { d_mag = magt; - d_gnss_synchro->Acq_delay_samples = static_cast(indext % d_samples_per_code); + d_gnss_synchro->Acq_delay_samples = static_cast(indext % static_cast(d_acq_params.samples_per_code)); d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; - d_gnss_synchro->Acq_doppler_step = d_doppler_step; + d_gnss_synchro->Acq_doppler_step = d_acq_params.doppler_step; } // Record results to file if required - if (d_dump) + if (d_acq_params.dump) { std::stringstream filename; std::streamsize n = 2 * sizeof(float) * (d_fft_size); // complex file write @@ -403,7 +325,7 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items, this->message_port_pub(pmt::mp("events"), pmt::from_long(acquisition_message)); // Copy and push current Gnss_Synchro to monitor queue - if (d_enable_monitor_output) + if (d_acq_params.enable_monitor_output) { auto **out = reinterpret_cast(&output_items[0]); Gnss_Synchro current_synchro_data = Gnss_Synchro(); diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.h index 2f3f9f498..bfd58f40c 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.h @@ -37,6 +37,8 @@ #ifndef GNSS_SDR_PCPS_TONG_ACQUISITION_CC_H #define GNSS_SDR_PCPS_TONG_ACQUISITION_CC_H +#include "acq_conf.h" +#include "acquisition_impl_interface.h" #include "channel_fsm.h" #include "gnss_sdr_fft.h" #include "gnss_synchro.h" @@ -59,23 +61,16 @@ class pcps_tong_acquisition_cc; using pcps_tong_acquisition_cc_sptr = gnss_shared_ptr; pcps_tong_acquisition_cc_sptr pcps_tong_make_acquisition_cc( - uint32_t sampled_ms, - uint32_t doppler_max, - int64_t fs_in, - int32_t samples_per_ms, - int32_t samples_per_code, + const Acq_Conf& conf, uint32_t tong_init_val, uint32_t tong_max_val, - uint32_t tong_max_dwells, - bool dump, - const std::string& dump_filename, - bool enable_monitor_output); + uint32_t tong_max_dwells); /*! * \brief This class implements a Parallel Code Phase Search Acquisition with * Tong algorithm. */ -class pcps_tong_acquisition_cc : public gr::block +class pcps_tong_acquisition_cc : public acquisition_impl_interface { public: /*! @@ -88,7 +83,7 @@ public: * to exchange synchronization data between acquisition and tracking blocks. * \param p_gnss_synchro Satellite information shared by the processing blocks. */ - inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) + inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override { d_gnss_synchro = p_gnss_synchro; } @@ -96,44 +91,37 @@ public: /*! * \brief Returns the maximum peak of grid search. */ - inline uint32_t mag() const + inline uint32_t mag() const override { return d_mag; } - /*! - * \brief Initializes acquisition algorithm. - */ - void init(); - /*! * \brief Sets local code for TONG acquisition algorithm. * \param code - Pointer to the PRN code. */ - void set_local_code(std::complex* code); + void set_local_code(std::complex* code) override; /*! * \brief Starts acquisition algorithm, turning from standby mode to * active mode * \param active - bool that activates/deactivates the block. */ - inline void set_active(bool active) + inline void set_active(bool active) override { + if (!active) + { + d_state = 0; + } + d_active = active; } - /*! - * \brief If set to 1, ensures that acquisition starts at the - * first available sample. - * \param state - int=1 forces start of acquisition - */ - void set_state(int32_t state); - /*! * \brief Set acquisition channel unique ID * \param channel - receiver channel. */ - inline void set_channel(uint32_t channel) + inline void set_channel(uint32_t channel) override { d_channel = channel; } @@ -141,7 +129,7 @@ public: /*! * \brief Set channel fsm associated to this acquisition instance */ - inline void set_channel_fsm(std::weak_ptr channel_fsm) + inline void set_channel_fsm(std::weak_ptr channel_fsm) override { d_channel_fsm = std::move(channel_fsm); } @@ -151,52 +139,59 @@ public: * \param threshold - Threshold for signal detection (check \ref Navitec2012, * Algorithm 1, for a definition of this threshold). */ - inline void set_threshold(float threshold) + inline void set_threshold(float threshold) override { d_threshold = threshold; } - /*! - * \brief Set maximum Doppler grid search - * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz]. - */ - inline void set_doppler_max(uint32_t doppler_max) - { - d_doppler_max = doppler_max; - } - - /*! - * \brief Set Doppler steps for the grid search - * \param doppler_step - Frequency bin of the search grid [Hz]. - */ - inline void set_doppler_step(uint32_t doppler_step) - { - d_doppler_step = doppler_step; - } - /*! * \brief Parallel Code Phase Search Acquisition signal processing. */ int general_work(int noutput_items, gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items); + gr_vector_void_star& output_items) override; private: friend pcps_tong_acquisition_cc_sptr - pcps_tong_make_acquisition_cc(uint32_t sampled_ms, uint32_t doppler_max, - int64_t fs_in, int32_t samples_per_ms, - int32_t samples_per_code, uint32_t tong_init_val, - uint32_t tong_max_val, uint32_t tong_max_dwells, - bool dump, const std::string& dump_filename, bool enable_monitor_output); + pcps_tong_make_acquisition_cc( + const Acq_Conf& conf, + uint32_t tong_init_val, + uint32_t tong_max_val, + uint32_t tong_max_dwells); - pcps_tong_acquisition_cc(uint32_t sampled_ms, uint32_t doppler_max, - int64_t fs_in, int32_t samples_per_ms, - int32_t samples_per_code, uint32_t tong_init_val, - uint32_t tong_max_val, uint32_t tong_max_dwells, - bool dump, const std::string& dump_filename, bool enable_monitor_output); + pcps_tong_acquisition_cc( + const Acq_Conf& conf, + uint32_t tong_init_val, + uint32_t tong_max_val, + uint32_t tong_max_dwells); - void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift, - int32_t doppler_offset); + void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift, int32_t doppler_offset); + + std::string d_satellite_str; + const Acq_Conf d_acq_params; + + std::ofstream d_dump_file; + + Gnss_Synchro* d_gnss_synchro; + + uint64_t d_sample_counter; + + float d_threshold; + float d_mag; + float d_input_power; + float d_test_statistics; + int32_t d_state; + uint32_t d_channel; + uint32_t d_dwell_count; + const uint32_t d_tong_init_val; + const uint32_t d_tong_max_val; + const uint32_t d_tong_max_dwells; + uint32_t d_tong_count; + const uint32_t d_fft_size; + uint32_t d_num_doppler_bins; + uint32_t d_code_phase; + + bool d_active; std::weak_ptr d_channel_fsm; std::unique_ptr d_fft_if; @@ -206,42 +201,6 @@ private: std::vector> d_grid_data; std::vector d_fft_codes; std::vector d_magnitude; - - std::string d_satellite_str; - std::string d_dump_filename; - - std::ofstream d_dump_file; - - Gnss_Synchro* d_gnss_synchro; - - int64_t d_fs_in; - uint64_t d_sample_counter; - - float d_threshold; - float d_doppler_freq; - float d_mag; - float d_input_power; - float d_test_statistics; - int32_t d_state; - int32_t d_samples_per_ms; - int32_t d_samples_per_code; - uint32_t d_channel; - uint32_t d_doppler_resolution; - uint32_t d_doppler_max; - uint32_t d_doppler_step; - uint32_t d_sampled_ms; - uint32_t d_dwell_count; - uint32_t d_tong_init_val; - uint32_t d_tong_max_val; - uint32_t d_tong_max_dwells; - uint32_t d_tong_count; - uint32_t d_fft_size; - uint32_t d_num_doppler_bins; - uint32_t d_code_phase; - - bool d_active; - bool d_dump; - bool d_enable_monitor_output; }; diff --git a/src/algorithms/acquisition/libs/acq_conf.h b/src/algorithms/acquisition/libs/acq_conf.h index b92609369..15432fc94 100644 --- a/src/algorithms/acquisition/libs/acq_conf.h +++ b/src/algorithms/acquisition/libs/acq_conf.h @@ -46,7 +46,6 @@ public: size_t it_size{sizeof(gr_complex)}; - float doppler_step{250.0}; float samples_per_ms{0.0}; float doppler_step2{125.0}; float pfa{0.0}; @@ -64,6 +63,7 @@ public: uint32_t dump_channel{0U}; int32_t doppler_max{5000}; int32_t doppler_min{-5000}; + int32_t doppler_step{500}; bool bit_transition_flag{false}; bool use_CFAR_algorithm_flag{true}; diff --git a/src/algorithms/acquisition/libs/acq_conf_fpga.cc b/src/algorithms/acquisition/libs/acq_conf_fpga.cc index 1f77f0ff2..ced4e07b2 100644 --- a/src/algorithms/acquisition/libs/acq_conf_fpga.cc +++ b/src/algorithms/acquisition/libs/acq_conf_fpga.cc @@ -22,12 +22,6 @@ #include #include -#if USE_GLOG_AND_GFLAGS -#include -#else -#include -#endif - void Acq_Conf_Fpga::SetFromConfiguration(const ConfigurationInterface *configuration, const std::string &role, uint32_t blk_exp, double code_chips_per_sec, double num_chips_per_code) { @@ -41,6 +35,9 @@ void Acq_Conf_Fpga::SetFromConfiguration(const ConfigurationInterface *configura // max doppler doppler_max = configuration->property(role + ".doppler_max", doppler_max); + // max doppler + doppler_step = configuration->property(role + ".doppler_step", 500); + // code chips per second code_rate_cps = code_chips_per_sec; @@ -89,6 +86,7 @@ void Acq_Conf_Fpga::SetFromConfiguration(const ConfigurationInterface *configura total_block_exp = configuration->property(role + ".total_block_exp", blk_exp); } + bool Acq_Conf_Fpga::ConfigureAutomaticResampler(std::vector> downsampling_filter_specs, uint32_t max_FFT_size, double opt_freq) { bool acq_configuration_valid = false; @@ -135,7 +133,8 @@ bool Acq_Conf_Fpga::ConfigureAutomaticResampler(std::vector> downsampling_filter_specs, uint32_t max_FFT_size, double opt_freq); - bool Is_acq_config_valid(uint32_t max_FFT_size); + bool Is_acq_config_valid(uint32_t max_FFT_size) const; /* PCPS Acquisition configuration */ std::string device_name = "uio0"; - uint32_t *all_fft_codes = NULL; // pointer to memory that contains all the code ffts double code_rate_cps; double code_length_chips; - int64_t fs_in{4000000LL}; - int64_t resampled_fs{4000000LL}; float doppler_step{250.0}; float doppler_step2{125.0}; + + int64_t fs_in{4000000LL}; + int64_t resampled_fs{4000000LL}; + + uint32_t *all_fft_codes = nullptr; // pointer to memory that contains all the code ffts uint32_t num_doppler_bins_step2{4U}; - int32_t doppler_max{5000}; uint32_t downsampling_filter_num{0U}; uint32_t downsampling_factor{1U}; uint32_t downsampling_filter_delay{0U}; @@ -62,6 +63,8 @@ public: uint32_t max_num_acqs{2U}; uint32_t fft_size{1U}; uint32_t code_length{16000U}; + int32_t doppler_max{5000}; + bool make_2_steps{false}; bool enable_zero_padding{false}; bool repeat_satellite{false}; diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.cc b/src/algorithms/acquisition/libs/fpga_acquisition.cc index 72fae5b51..8030aeb97 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.cc +++ b/src/algorithms/acquisition/libs/fpga_acquisition.cc @@ -26,6 +26,7 @@ #include // for operator<< #include // libraries used by the GIPO #include // for write, close, read, ssize_t +#include #if USE_GLOG_AND_GFLAGS #include @@ -49,7 +50,7 @@ Fpga_Acquisition::Fpga_Acquisition(std::string device_name, uint32_t select_queue, std::vector> &downsampling_filter_specs, - uint32_t &max_FFT_size) : d_device_name(device_name), + uint32_t &max_FFT_size) : d_device_name(std::move(device_name)), d_resampled_fs(0), d_map_base(nullptr), // driver memory map d_all_fft_codes(nullptr), @@ -61,8 +62,6 @@ Fpga_Acquisition::Fpga_Acquisition(std::string device_name, d_downsampling_factor(1), d_downsampling_filter_delay(0), d_select_queue(select_queue), - d_doppler_max(0), - d_doppler_step(0), d_PRN(0), d_IP_core_version(0) { @@ -74,7 +73,8 @@ Fpga_Acquisition::Fpga_Acquisition(std::string device_name, DLOG(INFO) << "Acquisition FPGA class created"; } -void Fpga_Acquisition::init(uint32_t nsamples, uint32_t doppler_max, uint32_t fft_size, + +void Fpga_Acquisition::init(uint32_t nsamples, uint32_t fft_size, int64_t resampled_fs, uint32_t downsampling_filter_num, uint32_t excludelimit, uint32_t *all_fft_codes) { d_resampled_fs = resampled_fs; @@ -88,7 +88,6 @@ void Fpga_Acquisition::init(uint32_t nsamples, uint32_t doppler_max, uint32_t ff d_downsampling_factor = d_downsampling_filter_specs[d_filter_num - 1].first; d_downsampling_filter_delay = d_downsampling_filter_specs[d_filter_num - 1].second; } - d_doppler_max = doppler_max; } @@ -147,6 +146,7 @@ void Fpga_Acquisition::fpga_acquisition_test_register() } } + void Fpga_Acquisition::read_ipcore_info(std::vector> &downsampling_filter_specs, uint32_t &max_FFT_size) { d_IP_core_version = d_map_base[FPGA_IP_CORE_VERSION_REG_ADDR]; @@ -192,6 +192,7 @@ void Fpga_Acquisition::read_ipcore_info(std::vector // for std::invalid_argument @@ -74,28 +73,7 @@ Channel::Channel(const ConfigurationInterface* configuration, } } - // IMPORTANT: Do not change the order between set_doppler_step and set_threshold - - uint32_t doppler_step = configuration->property("Acquisition_" + signal_str + std::to_string(channel_) + ".doppler_step", 0); - if (doppler_step == 0) - { - doppler_step = configuration->property("Acquisition_" + signal_str + ".doppler_step", 500); - } -#if USE_GLOG_AND_GFLAGS - if (FLAGS_doppler_step != 0) - { - doppler_step = static_cast(FLAGS_doppler_step); - } -#else - if (absl::GetFlag(FLAGS_doppler_step) != 0) - { - doppler_step = static_cast(absl::GetFlag(FLAGS_doppler_step)); - } -#endif - DLOG(INFO) << "Channel " << channel_ << " Doppler_step = " << doppler_step; - - acq_->set_doppler_step(doppler_step); - + // IMPORTANT: For future reference set_threshold needs to be called after doppler step is set (currently done at acquisition construction) float threshold = configuration->property("Acquisition_" + signal_str + std::to_string(channel_) + ".threshold", static_cast(0.0)); if (threshold == 0.0) { @@ -104,8 +82,6 @@ Channel::Channel(const ConfigurationInterface* configuration, acq_->set_threshold(threshold); - acq_->init(); - channel_fsm_->set_acquisition(acq_); channel_fsm_->set_tracking(trk_); channel_fsm_->set_telemetry(nav_); 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 431238a1e..6a0b44c25 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...4.1) +cmake_minimum_required(VERSION 2.8.12...4.2) set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose build type: None Debug Release RelWithDebInfo MinSizeRel") project(volk_gnsssdr) enable_language(CXX) diff --git a/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc b/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc index 26a2fa272..2c803d6cb 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc @@ -1287,17 +1287,14 @@ int labsat23_source::general_work(int noutput_items, if (!d_is_ls3w && !d_is_ls4) { - return parse_ls23_data(noutput_items, out); + return parse_ls23_data(noutput_items, std::move(out)); } else if (d_is_ls3w) // Labsat 3 Wideband { - return parse_ls3w_data(noutput_items, out); + return parse_ls3w_data(noutput_items, std::move(out)); } else // Labsat 4 { - return parse_ls4_data(noutput_items, out); + return parse_ls4_data(noutput_items, std::move(out)); } - - std::cout << "Warning!!\n"; - return 0; } diff --git a/src/algorithms/signal_source/libs/fpga_switch.cc b/src/algorithms/signal_source/libs/fpga_switch.cc index 2730bdf36..609cb240d 100644 --- a/src/algorithms/signal_source/libs/fpga_switch.cc +++ b/src/algorithms/signal_source/libs/fpga_switch.cc @@ -33,7 +33,7 @@ #include #endif -Fpga_Switch::Fpga_Switch(void) +Fpga_Switch::Fpga_Switch() { std::string device_io_name; // Switch UIO device file // find the uio device file corresponding to the switch. diff --git a/src/algorithms/telemetry_decoder/adapters/CMakeLists.txt b/src/algorithms/telemetry_decoder/adapters/CMakeLists.txt index a804a1a86..9641cc8ce 100644 --- a/src/algorithms/telemetry_decoder/adapters/CMakeLists.txt +++ b/src/algorithms/telemetry_decoder/adapters/CMakeLists.txt @@ -6,6 +6,7 @@ set(TELEMETRY_DECODER_ADAPTER_SOURCES + telemetry_decoder_adapter_base.cc gps_l1_ca_telemetry_decoder.cc gps_l2c_telemetry_decoder.cc gps_l5_telemetry_decoder.cc @@ -21,6 +22,7 @@ set(TELEMETRY_DECODER_ADAPTER_SOURCES ) set(TELEMETRY_DECODER_ADAPTER_HEADERS + telemetry_decoder_adapter_base.h gps_l1_ca_telemetry_decoder.h gps_l2c_telemetry_decoder.h gps_l5_telemetry_decoder.h diff --git a/src/algorithms/telemetry_decoder/adapters/beidou_b1i_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/beidou_b1i_telemetry_decoder.cc index 8f7229954..a45539426 100644 --- a/src/algorithms/telemetry_decoder/adapters/beidou_b1i_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/beidou_b1i_telemetry_decoder.cc @@ -17,74 +17,17 @@ #include "beidou_b1i_telemetry_decoder.h" -#include "configuration_interface.h" - -#if USE_GLOG_AND_GFLAGS -#include -#else -#include -#endif - +#include "beidou_b1i_telemetry_decoder_gs.h" BeidouB1iTelemetryDecoder::BeidouB1iTelemetryDecoder( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : role_(role), - in_streams_(in_streams), - out_streams_(out_streams) + unsigned int out_streams) + : TelemetryDecoderAdapterBase(configuration, + role, + in_streams, + out_streams) { - DLOG(INFO) << "role " << role; - tlm_parameters_.SetFromConfiguration(configuration, role); - // make telemetry decoder object - telemetry_decoder_ = beidou_b1i_make_telemetry_decoder_gs(satellite_, tlm_parameters_); - DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; - } -} - - -void BeidouB1iTelemetryDecoder::set_satellite(const Gnss_Satellite& satellite) -{ - satellite_ = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - telemetry_decoder_->set_satellite(satellite_); - DLOG(INFO) << "TELEMETRY DECODER: satellite set to " << satellite_; -} - - -void BeidouB1iTelemetryDecoder::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // Nothing to connect internally - DLOG(INFO) << "nothing to connect internally"; -} - - -void BeidouB1iTelemetryDecoder::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // Nothing to disconnect -} - - -gr::basic_block_sptr BeidouB1iTelemetryDecoder::get_left_block() -{ - return telemetry_decoder_; -} - - -gr::basic_block_sptr BeidouB1iTelemetryDecoder::get_right_block() -{ - return telemetry_decoder_; + InitializeDecoder(beidou_b1i_make_telemetry_decoder_gs(satellite(), tlm_parameters_)); } diff --git a/src/algorithms/telemetry_decoder/adapters/beidou_b1i_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/beidou_b1i_telemetry_decoder.h index edff366a7..027b7b43f 100644 --- a/src/algorithms/telemetry_decoder/adapters/beidou_b1i_telemetry_decoder.h +++ b/src/algorithms/telemetry_decoder/adapters/beidou_b1i_telemetry_decoder.h @@ -20,13 +20,8 @@ #ifndef GNSS_SDR_BEIDOU_B1I_TELEMETRY_DECODER_H #define GNSS_SDR_BEIDOU_B1I_TELEMETRY_DECODER_H -#include "beidou_b1i_telemetry_decoder_gs.h" -#include "gnss_satellite.h" // for Gnss_Satellite -#include "gnss_synchro.h" -#include "telemetry_decoder_interface.h" -#include "tlm_conf.h" -#include // for basic_block_sptr, top_block_sptr -#include // for size_t + +#include "telemetry_decoder_adapter_base.h" #include /** \addtogroup Telemetry_Decoder @@ -35,12 +30,10 @@ * \{ */ -class ConfigurationInterface; - /*! * \brief This class implements a NAV data decoder for BEIDOU B1I */ -class BeidouB1iTelemetryDecoder : public TelemetryDecoderInterface +class BeidouB1iTelemetryDecoder : public TelemetryDecoderAdapterBase { public: BeidouB1iTelemetryDecoder( @@ -49,43 +42,11 @@ public: unsigned int in_streams, unsigned int out_streams); - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - void set_satellite(const Gnss_Satellite& satellite) override; - - inline std::string role() override - { - return role_; - } - //! Returns "BEIDOU_B1I_Telemetry_Decoder" inline std::string implementation() override { return "BEIDOU_B1I_Telemetry_Decoder"; } - - inline void set_channel(int channel) override { telemetry_decoder_->set_channel(channel); } - - inline void reset() override - { - telemetry_decoder_->reset(); - } - - inline size_t item_size() override - { - return sizeof(Gnss_Synchro); - } - -private: - beidou_b1i_telemetry_decoder_gs_sptr telemetry_decoder_; - Gnss_Satellite satellite_; - Tlm_Conf tlm_parameters_; - std::string role_; - unsigned int in_streams_; - unsigned int out_streams_; }; diff --git a/src/algorithms/telemetry_decoder/adapters/beidou_b3i_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/beidou_b3i_telemetry_decoder.cc index 502479613..75d99129d 100644 --- a/src/algorithms/telemetry_decoder/adapters/beidou_b3i_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/beidou_b3i_telemetry_decoder.cc @@ -16,73 +16,17 @@ */ #include "beidou_b3i_telemetry_decoder.h" -#include "configuration_interface.h" - -#if USE_GLOG_AND_GFLAGS -#include -#else -#include -#endif +#include "beidou_b3i_telemetry_decoder_gs.h" BeidouB3iTelemetryDecoder::BeidouB3iTelemetryDecoder( const ConfigurationInterface *configuration, const std::string &role, unsigned int in_streams, - unsigned int out_streams) : role_(role), - in_streams_(in_streams), - out_streams_(out_streams) + unsigned int out_streams) + : TelemetryDecoderAdapterBase(configuration, + role, + in_streams, + out_streams) { - DLOG(INFO) << "role " << role; - tlm_parameters_.SetFromConfiguration(configuration, role); - // make telemetry decoder object - telemetry_decoder_ = beidou_b3i_make_telemetry_decoder_gs(satellite_, tlm_parameters_); - DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; - } -} - - -void BeidouB3iTelemetryDecoder::set_satellite(const Gnss_Satellite &satellite) -{ - satellite_ = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - telemetry_decoder_->set_satellite(satellite_); - DLOG(INFO) << "TELEMETRY DECODER: satellite set to " << satellite_; -} - - -void BeidouB3iTelemetryDecoder::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // Nothing to connect internally - DLOG(INFO) << "nothing to connect internally"; -} - - -void BeidouB3iTelemetryDecoder::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // Nothing to disconnect -} - - -gr::basic_block_sptr BeidouB3iTelemetryDecoder::get_left_block() -{ - return telemetry_decoder_; -} - - -gr::basic_block_sptr BeidouB3iTelemetryDecoder::get_right_block() -{ - return telemetry_decoder_; + InitializeDecoder(beidou_b3i_make_telemetry_decoder_gs(satellite(), tlm_parameters_)); } diff --git a/src/algorithms/telemetry_decoder/adapters/beidou_b3i_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/beidou_b3i_telemetry_decoder.h index 207fabf60..4726156cb 100644 --- a/src/algorithms/telemetry_decoder/adapters/beidou_b3i_telemetry_decoder.h +++ b/src/algorithms/telemetry_decoder/adapters/beidou_b3i_telemetry_decoder.h @@ -18,13 +18,8 @@ #ifndef GNSS_SDR_BEIDOU_B3I_TELEMETRY_DECODER_H #define GNSS_SDR_BEIDOU_B3I_TELEMETRY_DECODER_H -#include "beidou_b3i_telemetry_decoder_gs.h" -#include "gnss_satellite.h" // for Gnss_Satellite -#include "gnss_synchro.h" -#include "telemetry_decoder_interface.h" -#include "tlm_conf.h" -#include // for basic_block_sptr, top_block_sptr -#include // for size_t + +#include "telemetry_decoder_adapter_base.h" #include @@ -34,12 +29,10 @@ * \{ */ -class ConfigurationInterface; - /*! * \brief This class implements a NAV data decoder for BEIDOU B1I */ -class BeidouB3iTelemetryDecoder : public TelemetryDecoderInterface +class BeidouB3iTelemetryDecoder : public TelemetryDecoderAdapterBase { public: BeidouB3iTelemetryDecoder( @@ -47,40 +40,11 @@ public: const std::string &role, unsigned int in_streams, unsigned int out_streams); - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - void set_satellite(const Gnss_Satellite &satellite) override; - - inline std::string role() override { return role_; } - //! Returns "BEIDOU_B3I_Telemetry_Decoder" inline std::string implementation() override { return "BEIDOU_B3I_Telemetry_Decoder"; } - - inline void set_channel(int channel) override - { - telemetry_decoder_->set_channel(channel); - } - - inline void reset() override - { - telemetry_decoder_->reset(); - } - - inline size_t item_size() override { return sizeof(Gnss_Synchro); } - -private: - beidou_b3i_telemetry_decoder_gs_sptr telemetry_decoder_; - Gnss_Satellite satellite_; - Tlm_Conf tlm_parameters_; - std::string role_; - unsigned int in_streams_; - unsigned int out_streams_; }; /** \} */ diff --git a/src/algorithms/telemetry_decoder/adapters/galileo_e1b_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/galileo_e1b_telemetry_decoder.cc index e6c302437..a3d5415f9 100644 --- a/src/algorithms/telemetry_decoder/adapters/galileo_e1b_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/galileo_e1b_telemetry_decoder.cc @@ -16,78 +16,23 @@ * ----------------------------------------------------------------------------- */ - #include "galileo_e1b_telemetry_decoder.h" -#include "configuration_interface.h" - -#if USE_GLOG_AND_GFLAGS -#include -#else -#include -#endif - +#include "galileo_telemetry_decoder_gs.h" GalileoE1BTelemetryDecoder::GalileoE1BTelemetryDecoder( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : role_(role), - in_streams_(in_streams), - out_streams_(out_streams) + unsigned int out_streams) + : TelemetryDecoderAdapterBase(configuration, + role, + in_streams, + out_streams) { - DLOG(INFO) << "role " << role; - tlm_parameters_.SetFromConfiguration(configuration, role); - tlm_parameters_.enable_reed_solomon = configuration->property(role + ".enable_reed_solomon", false); - tlm_parameters_.use_ced = configuration->property(role + ".use_reduced_ced", false); - // make telemetry decoder object - telemetry_decoder_ = galileo_make_telemetry_decoder_gs(satellite_, tlm_parameters_, 1); // unified galileo decoder set to INAV (frame_type=1) - DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; - - if (in_streams_ > 1) + if (configuration != nullptr) { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; + tlm_parameters_.enable_reed_solomon = configuration->property(role + ".enable_reed_solomon", false); + tlm_parameters_.use_ced = configuration->property(role + ".use_reduced_ced", false); } -} - - -void GalileoE1BTelemetryDecoder::set_satellite(const Gnss_Satellite& satellite) -{ - satellite_ = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - telemetry_decoder_->set_satellite(satellite_); - DLOG(INFO) << "GALILEO TELEMETRY DECODER: satellite set to " << satellite_; -} - - -void GalileoE1BTelemetryDecoder::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // Nothing to connect internally - DLOG(INFO) << "nothing to connect internally"; -} - - -void GalileoE1BTelemetryDecoder::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // Nothing to disconnect -} - - -gr::basic_block_sptr GalileoE1BTelemetryDecoder::get_left_block() -{ - return telemetry_decoder_; -} - - -gr::basic_block_sptr GalileoE1BTelemetryDecoder::get_right_block() -{ - return telemetry_decoder_; + InitializeDecoder(galileo_make_telemetry_decoder_gs(satellite(), tlm_parameters_, 1)); } diff --git a/src/algorithms/telemetry_decoder/adapters/galileo_e1b_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/galileo_e1b_telemetry_decoder.h index 73283d251..c42462aa3 100644 --- a/src/algorithms/telemetry_decoder/adapters/galileo_e1b_telemetry_decoder.h +++ b/src/algorithms/telemetry_decoder/adapters/galileo_e1b_telemetry_decoder.h @@ -21,13 +21,7 @@ #define GNSS_SDR_GALILEO_E1B_TELEMETRY_DECODER_H -#include "galileo_telemetry_decoder_gs.h" -#include "gnss_satellite.h" -#include "gnss_synchro.h" -#include "telemetry_decoder_interface.h" -#include "tlm_conf.h" -#include // for basic_block_sptr, top_block_sptr -#include // for size_t +#include "telemetry_decoder_adapter_base.h" #include /** \addtogroup Telemetry_Decoder @@ -36,12 +30,10 @@ * \{ */ -class ConfigurationInterface; - /*! * \brief This class implements a NAV data decoder for Galileo INAV frames in E1B radio link */ -class GalileoE1BTelemetryDecoder : public TelemetryDecoderInterface +class GalileoE1BTelemetryDecoder : public TelemetryDecoderAdapterBase { public: GalileoE1BTelemetryDecoder( @@ -50,18 +42,6 @@ public: unsigned int in_streams, unsigned int out_streams); - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - void set_satellite(const Gnss_Satellite& satellite) override; - - inline std::string role() override - { - return role_; - } - /*! * \brief Returns "Galileo_E1B_Telemetry_Decoder" */ @@ -69,26 +49,6 @@ public: { return "Galileo_E1B_Telemetry_Decoder"; } - - inline void set_channel(int channel) override { telemetry_decoder_->set_channel(channel); } - - inline void reset() override - { - telemetry_decoder_->reset(); - } - - inline size_t item_size() override - { - return sizeof(Gnss_Synchro); - } - -private: - galileo_telemetry_decoder_gs_sptr telemetry_decoder_; - Gnss_Satellite satellite_; - Tlm_Conf tlm_parameters_; - std::string role_; - unsigned int in_streams_; - unsigned int out_streams_; }; diff --git a/src/algorithms/telemetry_decoder/adapters/galileo_e5a_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/galileo_e5a_telemetry_decoder.cc index cf0c3828c..6900bd98d 100644 --- a/src/algorithms/telemetry_decoder/adapters/galileo_e5a_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/galileo_e5a_telemetry_decoder.cc @@ -1,5 +1,5 @@ /*! - * \file galileo_e5a_telemetry_decoder.h + * \file galileo_e5a_telemetry_decoder.cc * \brief Interface of an adapter of a GALILEO E5a FNAV data decoder block * to a TelemetryDecoderInterface * \author Marc Sales, 2014. marcsales92(at)gmail.com @@ -21,74 +21,17 @@ */ #include "galileo_e5a_telemetry_decoder.h" -#include "configuration_interface.h" - -#if USE_GLOG_AND_GFLAGS -#include -#else -#include -#endif - +#include "galileo_telemetry_decoder_gs.h" GalileoE5aTelemetryDecoder::GalileoE5aTelemetryDecoder( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : role_(role), - in_streams_(in_streams), - out_streams_(out_streams) + unsigned int out_streams) + : TelemetryDecoderAdapterBase(configuration, + role, + in_streams, + out_streams) { - DLOG(INFO) << "role " << role; - tlm_parameters_.SetFromConfiguration(configuration, role); - // make telemetry decoder object - telemetry_decoder_ = galileo_make_telemetry_decoder_gs(satellite_, tlm_parameters_, 2); // unified galileo decoder set to FNAV (frame_type=2) - DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; - } -} - - -void GalileoE5aTelemetryDecoder::set_satellite(const Gnss_Satellite& satellite) -{ - satellite_ = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - telemetry_decoder_->set_satellite(satellite_); - DLOG(INFO) << "TELEMETRY DECODER: satellite set to " << satellite_; -} - - -void GalileoE5aTelemetryDecoder::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // Nothing to connect internally - DLOG(INFO) << "nothing to connect internally"; -} - - -void GalileoE5aTelemetryDecoder::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // Nothing to disconnect -} - - -gr::basic_block_sptr GalileoE5aTelemetryDecoder::get_left_block() -{ - return telemetry_decoder_; -} - - -gr::basic_block_sptr GalileoE5aTelemetryDecoder::get_right_block() -{ - return telemetry_decoder_; + InitializeDecoder(galileo_make_telemetry_decoder_gs(satellite(), tlm_parameters_, 2)); } diff --git a/src/algorithms/telemetry_decoder/adapters/galileo_e5a_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/galileo_e5a_telemetry_decoder.h index 9985b162b..f9f8a01f6 100644 --- a/src/algorithms/telemetry_decoder/adapters/galileo_e5a_telemetry_decoder.h +++ b/src/algorithms/telemetry_decoder/adapters/galileo_e5a_telemetry_decoder.h @@ -23,13 +23,8 @@ #ifndef GNSS_SDR_GALILEO_E5A_TELEMETRY_DECODER_H #define GNSS_SDR_GALILEO_E5A_TELEMETRY_DECODER_H -#include "galileo_telemetry_decoder_gs.h" -#include "gnss_satellite.h" // for Gnss_Satellite -#include "gnss_synchro.h" -#include "telemetry_decoder_interface.h" -#include "tlm_conf.h" -#include // for basic_block_sptr, top_block_sptr -#include // for size_t + +#include "telemetry_decoder_adapter_base.h" #include /** \addtogroup Telemetry_Decoder @@ -37,13 +32,10 @@ /** \addtogroup Telemetry_Decoder_adapters * \{ */ - -class ConfigurationInterface; - /*! * \brief This class implements a NAV data decoder for Galileo INAV frames in E1B radio link */ -class GalileoE5aTelemetryDecoder : public TelemetryDecoderInterface +class GalileoE5aTelemetryDecoder : public TelemetryDecoderAdapterBase { public: GalileoE5aTelemetryDecoder( @@ -52,18 +44,6 @@ public: unsigned int in_streams, unsigned int out_streams); - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - void set_satellite(const Gnss_Satellite& satellite) override; - - inline std::string role() override - { - return role_; - } - /*! * \brief Returns "Galileo_E5a_Telemetry_Decoder" */ @@ -71,26 +51,6 @@ public: { return "Galileo_E5A_Telemetry_Decoder"; } - - inline void set_channel(int channel) override { telemetry_decoder_->set_channel(channel); } - - inline void reset() override - { - telemetry_decoder_->reset(); - } - - inline size_t item_size() override - { - return sizeof(Gnss_Synchro); - } - -private: - galileo_telemetry_decoder_gs_sptr telemetry_decoder_; - Gnss_Satellite satellite_; - Tlm_Conf tlm_parameters_; - std::string role_; - unsigned int in_streams_; - unsigned int out_streams_; }; diff --git a/src/algorithms/telemetry_decoder/adapters/galileo_e5b_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/galileo_e5b_telemetry_decoder.cc index d6c66b20c..2ebfe6cc2 100644 --- a/src/algorithms/telemetry_decoder/adapters/galileo_e5b_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/galileo_e5b_telemetry_decoder.cc @@ -17,78 +17,18 @@ * ----------------------------------------------------------------------------- */ - #include "galileo_e5b_telemetry_decoder.h" -#include "configuration_interface.h" - -#if USE_GLOG_AND_GFLAGS -#include -#else -#include -#endif - +#include "galileo_telemetry_decoder_gs.h" GalileoE5bTelemetryDecoder::GalileoE5bTelemetryDecoder( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : role_(role), - in_streams_(in_streams), - out_streams_(out_streams) + unsigned int out_streams) + : TelemetryDecoderAdapterBase(configuration, + role, + in_streams, + out_streams) { - DLOG(INFO) << "role " << role; - tlm_parameters_.SetFromConfiguration(configuration, role); - // make telemetry decoder object - telemetry_decoder_ = galileo_make_telemetry_decoder_gs(satellite_, tlm_parameters_, 1); // unified galileo decoder set to INAV (frame_type=1) - DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; - } -} - - -void GalileoE5bTelemetryDecoder::set_satellite(const Gnss_Satellite& satellite) -{ - satellite_ = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - telemetry_decoder_->set_satellite(satellite_); - DLOG(INFO) << "GALILEO TELEMETRY DECODER: satellite set to " << satellite_; -} - - -void GalileoE5bTelemetryDecoder::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { - /* top_block is not null */ - }; - // Nothing to connect internally - DLOG(INFO) << "nothing to connect internally"; -} - - -void GalileoE5bTelemetryDecoder::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { - /* top_block is not null */ - }; - // Nothing to disconnect -} - - -gr::basic_block_sptr GalileoE5bTelemetryDecoder::get_left_block() -{ - return telemetry_decoder_; -} - - -gr::basic_block_sptr GalileoE5bTelemetryDecoder::get_right_block() -{ - return telemetry_decoder_; + InitializeDecoder(galileo_make_telemetry_decoder_gs(satellite(), tlm_parameters_, 1)); } diff --git a/src/algorithms/telemetry_decoder/adapters/galileo_e5b_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/galileo_e5b_telemetry_decoder.h index b095e0445..0e51fcf47 100644 --- a/src/algorithms/telemetry_decoder/adapters/galileo_e5b_telemetry_decoder.h +++ b/src/algorithms/telemetry_decoder/adapters/galileo_e5b_telemetry_decoder.h @@ -21,13 +21,7 @@ #ifndef GNSS_SDR_GALILEO_E5B_TELEMETRY_DECODER_H #define GNSS_SDR_GALILEO_E5B_TELEMETRY_DECODER_H -#include "galileo_telemetry_decoder_gs.h" -#include "gnss_satellite.h" -#include "gnss_synchro.h" -#include "telemetry_decoder_interface.h" -#include "tlm_conf.h" -#include // for basic_block_sptr, top_block_sptr -#include // for size_t +#include "telemetry_decoder_adapter_base.h" #include /** \addtogroup Telemetry_Decoder @@ -36,12 +30,10 @@ * \{ */ -class ConfigurationInterface; - /*! * \brief This class implements a NAV data decoder for Galileo INAV frames in E5b radio link */ -class GalileoE5bTelemetryDecoder : public TelemetryDecoderInterface +class GalileoE5bTelemetryDecoder : public TelemetryDecoderAdapterBase { public: GalileoE5bTelemetryDecoder( @@ -57,53 +49,6 @@ public: { return "Galileo_E5b_Telemetry_Decoder"; } - - /*! - * \brief Connect - */ - void connect(gr::top_block_sptr top_block) override; - - /*! - * \brief Disconnect - */ - void disconnect(gr::top_block_sptr top_block) override; - - /*! - * \brief Get left block - */ - gr::basic_block_sptr get_left_block() override; - - /*! - * \brief Get right block - */ - gr::basic_block_sptr get_right_block() override; - - void set_satellite(const Gnss_Satellite& satellite) override; - - inline std::string role() override - { - return role_; - } - - inline void set_channel(int channel) override { telemetry_decoder_->set_channel(channel); } - - inline void reset() override - { - telemetry_decoder_->reset(); - } - - inline size_t item_size() override - { - return sizeof(Gnss_Synchro); - } - -private: - galileo_telemetry_decoder_gs_sptr telemetry_decoder_; - Gnss_Satellite satellite_; - Tlm_Conf tlm_parameters_; - std::string role_; - unsigned int in_streams_; - unsigned int out_streams_; }; diff --git a/src/algorithms/telemetry_decoder/adapters/galileo_e6_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/galileo_e6_telemetry_decoder.cc index 5fd6342ea..488e7a33a 100644 --- a/src/algorithms/telemetry_decoder/adapters/galileo_e6_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/galileo_e6_telemetry_decoder.cc @@ -16,78 +16,18 @@ * ----------------------------------------------------------------------------- */ - #include "galileo_e6_telemetry_decoder.h" -#include "configuration_interface.h" - -#if USE_GLOG_AND_GFLAGS -#include -#else -#include -#endif - +#include "galileo_telemetry_decoder_gs.h" GalileoE6TelemetryDecoder::GalileoE6TelemetryDecoder( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : role_(role), - in_streams_(in_streams), - out_streams_(out_streams) + unsigned int out_streams) + : TelemetryDecoderAdapterBase(configuration, + role, + in_streams, + out_streams) { - DLOG(INFO) << "role " << role; - tlm_parameters_.SetFromConfiguration(configuration, role); - // make telemetry decoder object - telemetry_decoder_ = galileo_make_telemetry_decoder_gs(satellite_, tlm_parameters_, 3); // unified galileo decoder set to CNAV (frame_type=3) - DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; - } -} - - -void GalileoE6TelemetryDecoder::set_satellite(const Gnss_Satellite& satellite) -{ - satellite_ = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - telemetry_decoder_->set_satellite(satellite_); - DLOG(INFO) << "GALILEO TELEMETRY DECODER: satellite set to " << satellite_; -} - - -void GalileoE6TelemetryDecoder::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { - /* top_block is not null */ - }; - // Nothing to connect internally - DLOG(INFO) << "nothing to connect internally"; -} - - -void GalileoE6TelemetryDecoder::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { - /* top_block is not null */ - }; - // Nothing to disconnect -} - - -gr::basic_block_sptr GalileoE6TelemetryDecoder::get_left_block() -{ - return telemetry_decoder_; -} - - -gr::basic_block_sptr GalileoE6TelemetryDecoder::get_right_block() -{ - return telemetry_decoder_; + InitializeDecoder(galileo_make_telemetry_decoder_gs(satellite(), tlm_parameters_, 3)); } diff --git a/src/algorithms/telemetry_decoder/adapters/galileo_e6_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/galileo_e6_telemetry_decoder.h index 8647b8aa9..8b507a068 100644 --- a/src/algorithms/telemetry_decoder/adapters/galileo_e6_telemetry_decoder.h +++ b/src/algorithms/telemetry_decoder/adapters/galileo_e6_telemetry_decoder.h @@ -20,13 +20,7 @@ #ifndef GNSS_SDR_GALILEO_E6_TELEMETRY_DECODER_H #define GNSS_SDR_GALILEO_E6_TELEMETRY_DECODER_H -#include "galileo_telemetry_decoder_gs.h" -#include "gnss_satellite.h" -#include "gnss_synchro.h" -#include "telemetry_decoder_interface.h" -#include "tlm_conf.h" -#include // for basic_block_sptr, top_block_sptr -#include // for size_t +#include "telemetry_decoder_adapter_base.h" #include /** \addtogroup Telemetry_Decoder @@ -35,12 +29,10 @@ * \{ */ -class ConfigurationInterface; - /*! * \brief This class implements a NAV data decoder for Galileo CNAV frames in E6 radio link */ -class GalileoE6TelemetryDecoder : public TelemetryDecoderInterface +class GalileoE6TelemetryDecoder : public TelemetryDecoderAdapterBase { public: GalileoE6TelemetryDecoder( @@ -56,53 +48,6 @@ public: { return "Galileo_E6_Telemetry_Decoder"; } - - /*! - * \brief Connect - */ - void connect(gr::top_block_sptr top_block) override; - - /*! - * \brief Disconnect - */ - void disconnect(gr::top_block_sptr top_block) override; - - /*! - * \brief Get left block - */ - gr::basic_block_sptr get_left_block() override; - - /*! - * \brief Get right block - */ - gr::basic_block_sptr get_right_block() override; - - void set_satellite(const Gnss_Satellite& satellite) override; - - inline std::string role() override - { - return role_; - } - - inline void set_channel(int channel) override { telemetry_decoder_->set_channel(channel); } - - inline void reset() override - { - telemetry_decoder_->reset(); - } - - inline size_t item_size() override - { - return sizeof(Gnss_Synchro); - } - -private: - galileo_telemetry_decoder_gs_sptr telemetry_decoder_; - Gnss_Satellite satellite_; - Tlm_Conf tlm_parameters_; - std::string role_; - unsigned int in_streams_; - unsigned int out_streams_; }; diff --git a/src/algorithms/telemetry_decoder/adapters/glonass_l1_ca_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/glonass_l1_ca_telemetry_decoder.cc index c6de2b98f..eb753cdbb 100644 --- a/src/algorithms/telemetry_decoder/adapters/glonass_l1_ca_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/glonass_l1_ca_telemetry_decoder.cc @@ -16,76 +16,18 @@ * ----------------------------------------------------------------------------- */ - #include "glonass_l1_ca_telemetry_decoder.h" -#include "configuration_interface.h" - -#if USE_GLOG_AND_GFLAGS -#include -#else -#include -#endif - +#include "glonass_l1_ca_telemetry_decoder_gs.h" GlonassL1CaTelemetryDecoder::GlonassL1CaTelemetryDecoder( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : role_(role), - in_streams_(in_streams), - out_streams_(out_streams) + unsigned int out_streams) + : TelemetryDecoderAdapterBase(configuration, + role, + in_streams, + out_streams) { - DLOG(INFO) << "role " << role; - tlm_parameters_.SetFromConfiguration(configuration, role); - // make telemetry decoder object - telemetry_decoder_ = glonass_l1_ca_make_telemetry_decoder_gs(satellite_, tlm_parameters_); - DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; - } -} - - -void GlonassL1CaTelemetryDecoder::set_satellite(const Gnss_Satellite& satellite) -{ - satellite_ = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - telemetry_decoder_->set_satellite(satellite_); - DLOG(INFO) << "TELEMETRY DECODER: satellite set to " << satellite_; -} - - -void GlonassL1CaTelemetryDecoder::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // Nothing to connect internally - DLOG(INFO) << "nothing to connect internally"; -} - - -void GlonassL1CaTelemetryDecoder::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // Nothing to disconnect -} - - -gr::basic_block_sptr GlonassL1CaTelemetryDecoder::get_left_block() -{ - return telemetry_decoder_; -} - - -gr::basic_block_sptr GlonassL1CaTelemetryDecoder::get_right_block() -{ - return telemetry_decoder_; + InitializeDecoder(glonass_l1_ca_make_telemetry_decoder_gs(satellite(), tlm_parameters_)); } diff --git a/src/algorithms/telemetry_decoder/adapters/glonass_l1_ca_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/glonass_l1_ca_telemetry_decoder.h index 2f6f8eaf3..fb19931cd 100644 --- a/src/algorithms/telemetry_decoder/adapters/glonass_l1_ca_telemetry_decoder.h +++ b/src/algorithms/telemetry_decoder/adapters/glonass_l1_ca_telemetry_decoder.h @@ -20,13 +20,7 @@ #ifndef GNSS_SDR_GLONASS_L1_CA_TELEMETRY_DECODER_H #define GNSS_SDR_GLONASS_L1_CA_TELEMETRY_DECODER_H -#include "glonass_l1_ca_telemetry_decoder_gs.h" -#include "gnss_satellite.h" // for Gnss_Satellite -#include "gnss_synchro.h" -#include "telemetry_decoder_interface.h" -#include "tlm_conf.h" -#include // for basic_block_sptr, top_block_sptr -#include // for size_t +#include "telemetry_decoder_adapter_base.h" #include /** \addtogroup Telemetry_Decoder @@ -35,12 +29,10 @@ * \{ */ -class ConfigurationInterface; - /*! * \brief This class implements a NAV data decoder for GLONASS L1 C/A */ -class GlonassL1CaTelemetryDecoder : public TelemetryDecoderInterface +class GlonassL1CaTelemetryDecoder : public TelemetryDecoderAdapterBase { public: GlonassL1CaTelemetryDecoder( @@ -49,42 +41,11 @@ public: unsigned int in_streams, unsigned int out_streams); - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - void set_satellite(const Gnss_Satellite& satellite) override; - - inline void set_channel(int channel) override { telemetry_decoder_->set_channel(channel); } - - inline std::string role() override - { - return role_; - } - //! Returns "GLONASS_L1_CA_Telemetry_Decoder" inline std::string implementation() override { return "GLONASS_L1_CA_Telemetry_Decoder"; } - - inline void reset() override - { - telemetry_decoder_->reset(); - } - - inline size_t item_size() override - { - return sizeof(Gnss_Synchro); - } - -private: - glonass_l1_ca_telemetry_decoder_gs_sptr telemetry_decoder_; - Gnss_Satellite satellite_; - Tlm_Conf tlm_parameters_; - std::string role_; - unsigned int in_streams_; - unsigned int out_streams_; }; diff --git a/src/algorithms/telemetry_decoder/adapters/glonass_l2_ca_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/glonass_l2_ca_telemetry_decoder.cc index 77dfb5528..da4951b8e 100644 --- a/src/algorithms/telemetry_decoder/adapters/glonass_l2_ca_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/glonass_l2_ca_telemetry_decoder.cc @@ -15,76 +15,18 @@ * ----------------------------------------------------------------------------- */ - #include "glonass_l2_ca_telemetry_decoder.h" -#include "configuration_interface.h" - -#if USE_GLOG_AND_GFLAGS -#include -#else -#include -#endif - +#include "glonass_l2_ca_telemetry_decoder_gs.h" GlonassL2CaTelemetryDecoder::GlonassL2CaTelemetryDecoder( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : role_(role), - in_streams_(in_streams), - out_streams_(out_streams) + unsigned int out_streams) + : TelemetryDecoderAdapterBase(configuration, + role, + in_streams, + out_streams) { - DLOG(INFO) << "role " << role; - tlm_parameters_.SetFromConfiguration(configuration, role); - // make telemetry decoder object - telemetry_decoder_ = glonass_l2_ca_make_telemetry_decoder_gs(satellite_, tlm_parameters_); - DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; - } -} - - -void GlonassL2CaTelemetryDecoder::set_satellite(const Gnss_Satellite& satellite) -{ - satellite_ = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - telemetry_decoder_->set_satellite(satellite_); - DLOG(INFO) << "TELEMETRY DECODER: satellite set to " << satellite_; -} - - -void GlonassL2CaTelemetryDecoder::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // Nothing to connect internally - DLOG(INFO) << "nothing to connect internally"; -} - - -void GlonassL2CaTelemetryDecoder::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // Nothing to disconnect -} - - -gr::basic_block_sptr GlonassL2CaTelemetryDecoder::get_left_block() -{ - return telemetry_decoder_; -} - - -gr::basic_block_sptr GlonassL2CaTelemetryDecoder::get_right_block() -{ - return telemetry_decoder_; + InitializeDecoder(glonass_l2_ca_make_telemetry_decoder_gs(satellite(), tlm_parameters_)); } diff --git a/src/algorithms/telemetry_decoder/adapters/glonass_l2_ca_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/glonass_l2_ca_telemetry_decoder.h index 0099c080c..d9ae1c557 100644 --- a/src/algorithms/telemetry_decoder/adapters/glonass_l2_ca_telemetry_decoder.h +++ b/src/algorithms/telemetry_decoder/adapters/glonass_l2_ca_telemetry_decoder.h @@ -19,13 +19,7 @@ #ifndef GNSS_SDR_GLONASS_L2_CA_TELEMETRY_DECODER_H #define GNSS_SDR_GLONASS_L2_CA_TELEMETRY_DECODER_H -#include "glonass_l2_ca_telemetry_decoder_gs.h" -#include "gnss_satellite.h" // for Gnss_Satellite -#include "gnss_synchro.h" -#include "telemetry_decoder_interface.h" -#include "tlm_conf.h" -#include // for basic_block_sptr, top_block_sptr -#include // for size_t +#include "telemetry_decoder_adapter_base.h" #include /** \addtogroup Telemetry_Decoder @@ -34,12 +28,10 @@ * \{ */ -class ConfigurationInterface; - /*! * \brief This class implements a NAV data decoder for GLONASS L2 C/A */ -class GlonassL2CaTelemetryDecoder : public TelemetryDecoderInterface +class GlonassL2CaTelemetryDecoder : public TelemetryDecoderAdapterBase { public: GlonassL2CaTelemetryDecoder( @@ -48,42 +40,11 @@ public: unsigned int in_streams, unsigned int out_streams); - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - void set_satellite(const Gnss_Satellite& satellite) override; - - inline void set_channel(int channel) override { telemetry_decoder_->set_channel(channel); } - - inline std::string role() override - { - return role_; - } - //! Returns "GLONASS_L2_CA_Telemetry_Decoder" inline std::string implementation() override { return "GLONASS_L2_CA_Telemetry_Decoder"; } - - inline void reset() override - { - telemetry_decoder_->reset(); - } - - inline size_t item_size() override - { - return sizeof(Gnss_Synchro); - } - -private: - glonass_l2_ca_telemetry_decoder_gs_sptr telemetry_decoder_; - Gnss_Satellite satellite_; - Tlm_Conf tlm_parameters_; - std::string role_; - unsigned int in_streams_; - unsigned int out_streams_; }; diff --git a/src/algorithms/telemetry_decoder/adapters/gps_l1_ca_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/gps_l1_ca_telemetry_decoder.cc index 7f9a243bd..333e088b1 100644 --- a/src/algorithms/telemetry_decoder/adapters/gps_l1_ca_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/gps_l1_ca_telemetry_decoder.cc @@ -17,74 +17,18 @@ #include "gps_l1_ca_telemetry_decoder.h" -#include "configuration_interface.h" - -#if USE_GLOG_AND_GFLAGS -#include -#else -#include -#endif +#include "gps_l1_ca_telemetry_decoder_gs.h" GpsL1CaTelemetryDecoder::GpsL1CaTelemetryDecoder( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : role_(role), - in_streams_(in_streams), - out_streams_(out_streams) + unsigned int out_streams) + : TelemetryDecoderAdapterBase(configuration, + role, + in_streams, + out_streams) { - DLOG(INFO) << "role " << role; - tlm_parameters_.SetFromConfiguration(configuration, role); - // make telemetry decoder object - telemetry_decoder_ = gps_l1_ca_make_telemetry_decoder_gs(satellite_, tlm_parameters_); - DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; - } -} - - -void GpsL1CaTelemetryDecoder::set_satellite(const Gnss_Satellite& satellite) -{ - satellite_ = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - telemetry_decoder_->set_satellite(satellite_); - DLOG(INFO) << "TELEMETRY DECODER: satellite set to " << satellite_; -} - - -void GpsL1CaTelemetryDecoder::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // Nothing to connect internally - DLOG(INFO) << "nothing to connect internally"; -} - - -void GpsL1CaTelemetryDecoder::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // Nothing to disconnect -} - - -gr::basic_block_sptr GpsL1CaTelemetryDecoder::get_left_block() -{ - return telemetry_decoder_; -} - - -gr::basic_block_sptr GpsL1CaTelemetryDecoder::get_right_block() -{ - return telemetry_decoder_; + InitializeDecoder(gps_l1_ca_make_telemetry_decoder_gs(satellite(), tlm_parameters_)); } diff --git a/src/algorithms/telemetry_decoder/adapters/gps_l1_ca_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/gps_l1_ca_telemetry_decoder.h index 571c17be1..ca468d965 100644 --- a/src/algorithms/telemetry_decoder/adapters/gps_l1_ca_telemetry_decoder.h +++ b/src/algorithms/telemetry_decoder/adapters/gps_l1_ca_telemetry_decoder.h @@ -19,13 +19,7 @@ #ifndef GNSS_SDR_GPS_L1_CA_TELEMETRY_DECODER_H #define GNSS_SDR_GPS_L1_CA_TELEMETRY_DECODER_H -#include "gnss_satellite.h" // for Gnss_Satellite -#include "gnss_synchro.h" -#include "gps_l1_ca_telemetry_decoder_gs.h" -#include "telemetry_decoder_interface.h" -#include "tlm_conf.h" -#include // for basic_block_sptr, top_block_sptr -#include // for size_t +#include "telemetry_decoder_adapter_base.h" #include /** \addtogroup Telemetry_Decoder Telemetry Decoder @@ -37,12 +31,10 @@ * \{ */ -class ConfigurationInterface; - /*! * \brief This class implements a NAV data decoder for GPS L1 C/A */ -class GpsL1CaTelemetryDecoder : public TelemetryDecoderInterface +class GpsL1CaTelemetryDecoder : public TelemetryDecoderAdapterBase { public: GpsL1CaTelemetryDecoder( @@ -51,43 +43,11 @@ public: unsigned int in_streams, unsigned int out_streams); - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - void set_satellite(const Gnss_Satellite& satellite) override; - - inline std::string role() override - { - return role_; - } - //! Returns "GPS_L1_CA_Telemetry_Decoder" inline std::string implementation() override { return "GPS_L1_CA_Telemetry_Decoder"; } - - inline void set_channel(int channel) override { telemetry_decoder_->set_channel(channel); } - - inline void reset() override - { - telemetry_decoder_->reset(); - } - - inline size_t item_size() override - { - return sizeof(Gnss_Synchro); - } - -private: - gps_l1_ca_telemetry_decoder_gs_sptr telemetry_decoder_; - Gnss_Satellite satellite_; - Tlm_Conf tlm_parameters_; - std::string role_; - unsigned int in_streams_; - unsigned int out_streams_; }; diff --git a/src/algorithms/telemetry_decoder/adapters/gps_l2c_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/gps_l2c_telemetry_decoder.cc index 6db0843bb..336a66832 100644 --- a/src/algorithms/telemetry_decoder/adapters/gps_l2c_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/gps_l2c_telemetry_decoder.cc @@ -17,74 +17,17 @@ #include "gps_l2c_telemetry_decoder.h" -#include "configuration_interface.h" - -#if USE_GLOG_AND_GFLAGS -#include -#else -#include -#endif - +#include "gps_l2c_telemetry_decoder_gs.h" GpsL2CTelemetryDecoder::GpsL2CTelemetryDecoder( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : role_(role), - in_streams_(in_streams), - out_streams_(out_streams) + unsigned int out_streams) + : TelemetryDecoderAdapterBase(configuration, + role, + in_streams, + out_streams) { - DLOG(INFO) << "role " << role; - tlm_parameters_.SetFromConfiguration(configuration, role); - // make telemetry decoder object - telemetry_decoder_ = gps_l2c_make_telemetry_decoder_gs(satellite_, tlm_parameters_); - DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; - } -} - - -void GpsL2CTelemetryDecoder::set_satellite(const Gnss_Satellite& satellite) -{ - satellite_ = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - telemetry_decoder_->set_satellite(satellite_); - DLOG(INFO) << "TELEMETRY DECODER: satellite set to " << satellite_; -} - - -void GpsL2CTelemetryDecoder::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // Nothing to connect internally - DLOG(INFO) << "nothing to connect internally"; -} - - -void GpsL2CTelemetryDecoder::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // Nothing to disconnect -} - - -gr::basic_block_sptr GpsL2CTelemetryDecoder::get_left_block() -{ - return telemetry_decoder_; -} - - -gr::basic_block_sptr GpsL2CTelemetryDecoder::get_right_block() -{ - return telemetry_decoder_; + InitializeDecoder(gps_l2c_make_telemetry_decoder_gs(satellite(), tlm_parameters_)); } diff --git a/src/algorithms/telemetry_decoder/adapters/gps_l2c_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/gps_l2c_telemetry_decoder.h index b07517e2d..88173b872 100644 --- a/src/algorithms/telemetry_decoder/adapters/gps_l2c_telemetry_decoder.h +++ b/src/algorithms/telemetry_decoder/adapters/gps_l2c_telemetry_decoder.h @@ -19,13 +19,7 @@ #ifndef GNSS_SDR_GPS_L2C_TELEMETRY_DECODER_H #define GNSS_SDR_GPS_L2C_TELEMETRY_DECODER_H -#include "gnss_satellite.h" // for Gnss_Satellite -#include "gnss_synchro.h" -#include "gps_l2c_telemetry_decoder_gs.h" -#include "telemetry_decoder_interface.h" -#include "tlm_conf.h" -#include // for basic_block_sptr, top_block_sptr -#include // for size_t +#include "telemetry_decoder_adapter_base.h" #include @@ -35,12 +29,10 @@ * \{ */ -class ConfigurationInterface; - /*! * \brief This class implements a NAV data decoder for GPS L2 M */ -class GpsL2CTelemetryDecoder : public TelemetryDecoderInterface +class GpsL2CTelemetryDecoder : public TelemetryDecoderAdapterBase { public: GpsL2CTelemetryDecoder( @@ -49,43 +41,11 @@ public: unsigned int in_streams, unsigned int out_streams); - inline std::string role() override - { - return role_; - } - //! Returns "GPS_L2C_Telemetry_Decoder" inline std::string implementation() override { return "GPS_L2C_Telemetry_Decoder"; } - - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - void set_satellite(const Gnss_Satellite& satellite) override; - - inline void set_channel(int channel) override { telemetry_decoder_->set_channel(channel); } - - inline void reset() override - { - telemetry_decoder_->reset(); - } - - inline size_t item_size() override - { - return sizeof(Gnss_Synchro); - } - -private: - gps_l2c_telemetry_decoder_gs_sptr telemetry_decoder_; - Gnss_Satellite satellite_; - Tlm_Conf tlm_parameters_; - std::string role_; - unsigned int in_streams_; - unsigned int out_streams_; }; diff --git a/src/algorithms/telemetry_decoder/adapters/gps_l5_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/gps_l5_telemetry_decoder.cc index e5dadfa90..e5adc4866 100644 --- a/src/algorithms/telemetry_decoder/adapters/gps_l5_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/gps_l5_telemetry_decoder.cc @@ -17,74 +17,17 @@ #include "gps_l5_telemetry_decoder.h" -#include "configuration_interface.h" - -#if USE_GLOG_AND_GFLAGS -#include -#else -#include -#endif - +#include "gps_l5_telemetry_decoder_gs.h" GpsL5TelemetryDecoder::GpsL5TelemetryDecoder( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : role_(role), - in_streams_(in_streams), - out_streams_(out_streams) + unsigned int out_streams) + : TelemetryDecoderAdapterBase(configuration, + role, + in_streams, + out_streams) { - DLOG(INFO) << "role " << role; - tlm_parameters_.SetFromConfiguration(configuration, role); - // make telemetry decoder object - telemetry_decoder_ = gps_l5_make_telemetry_decoder_gs(satellite_, tlm_parameters_); - DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; - } -} - - -void GpsL5TelemetryDecoder::set_satellite(const Gnss_Satellite& satellite) -{ - satellite_ = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - telemetry_decoder_->set_satellite(satellite_); - DLOG(INFO) << "TELEMETRY DECODER: satellite set to " << satellite_; -} - - -void GpsL5TelemetryDecoder::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // Nothing to connect internally - DLOG(INFO) << "nothing to connect internally"; -} - - -void GpsL5TelemetryDecoder::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // Nothing to disconnect -} - - -gr::basic_block_sptr GpsL5TelemetryDecoder::get_left_block() -{ - return telemetry_decoder_; -} - - -gr::basic_block_sptr GpsL5TelemetryDecoder::get_right_block() -{ - return telemetry_decoder_; + InitializeDecoder(gps_l5_make_telemetry_decoder_gs(satellite(), tlm_parameters_)); } diff --git a/src/algorithms/telemetry_decoder/adapters/gps_l5_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/gps_l5_telemetry_decoder.h index ea4614352..c47d8376a 100644 --- a/src/algorithms/telemetry_decoder/adapters/gps_l5_telemetry_decoder.h +++ b/src/algorithms/telemetry_decoder/adapters/gps_l5_telemetry_decoder.h @@ -20,13 +20,7 @@ #define GNSS_SDR_GPS_L5_TELEMETRY_DECODER_H -#include "gnss_satellite.h" -#include "gnss_synchro.h" -#include "gps_l5_telemetry_decoder_gs.h" -#include "telemetry_decoder_interface.h" -#include "tlm_conf.h" -#include // for basic_block_sptr, top_block_sptr -#include // for size_t +#include "telemetry_decoder_adapter_base.h" #include /** \addtogroup Telemetry_Decoder @@ -34,13 +28,10 @@ /** \addtogroup Telemetry_Decoder_adapters * \{ */ - -class ConfigurationInterface; - /*! * \brief This class implements a NAV data decoder for GPS L5 */ -class GpsL5TelemetryDecoder : public TelemetryDecoderInterface +class GpsL5TelemetryDecoder : public TelemetryDecoderAdapterBase { public: GpsL5TelemetryDecoder( @@ -49,44 +40,11 @@ public: unsigned int in_streams, unsigned int out_streams); - inline std::string role() override - { - return role_; - } - //! Returns "GPS_L5_Telemetry_Decoder" inline std::string implementation() override { return "GPS_L5_Telemetry_Decoder"; } - - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - void set_satellite(const Gnss_Satellite& satellite) override; - - inline void set_channel(int channel) override { telemetry_decoder_->set_channel(channel); } - - inline void reset() override - { - telemetry_decoder_->reset(); - } - - inline size_t item_size() override - { - return sizeof(Gnss_Synchro); - } - -private: - gps_l5_telemetry_decoder_gs_sptr telemetry_decoder_; - Gnss_Satellite satellite_; - Tlm_Conf tlm_parameters_; - std::string dump_filename_; - std::string role_; - unsigned int in_streams_; - unsigned int out_streams_; }; diff --git a/src/algorithms/telemetry_decoder/adapters/sbas_l1_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/sbas_l1_telemetry_decoder.cc index 4fdd9a18d..7e079b133 100644 --- a/src/algorithms/telemetry_decoder/adapters/sbas_l1_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/sbas_l1_telemetry_decoder.cc @@ -15,77 +15,19 @@ * ----------------------------------------------------------------------------- */ - #include "sbas_l1_telemetry_decoder.h" -#include "configuration_interface.h" -#include - -#if USE_GLOG_AND_GFLAGS -#include -#else -#include -#endif +#include "sbas_l1_telemetry_decoder_gs.h" SbasL1TelemetryDecoder::SbasL1TelemetryDecoder( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : role_(role), - in_streams_(in_streams), - out_streams_(out_streams), - dump_(configuration->property(role + ".dump", false)) + unsigned int out_streams) : TelemetryDecoderAdapterBase(configuration, + role, + in_streams, + out_streams), + dump_filename_(configuration != nullptr ? configuration->property(role + ".dump_filename", std::string("./navigation.dat")) : std::string("./navigation.dat")), + dump_(configuration != nullptr ? configuration->property(role + ".dump", false) : false) { - const std::string default_dump_filename("./navigation.dat"); - dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename); - // make telemetry decoder object - telemetry_decoder_ = sbas_l1_make_telemetry_decoder_gs(satellite_, dump_); // TODO fix me - DLOG(INFO) << "role " << role; - DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; - } -} - - -void SbasL1TelemetryDecoder::set_satellite(const Gnss_Satellite& satellite) -{ - satellite_ = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - telemetry_decoder_->set_satellite(satellite_); - DLOG(INFO) << "SBAS TELEMETRY DECODER: satellite set to " << satellite_; -} - - -void SbasL1TelemetryDecoder::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // Nothing to connect internally - DLOG(INFO) << "nothing to connect internally"; -} - - -void SbasL1TelemetryDecoder::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // Nothing to disconnect -} - - -gr::basic_block_sptr SbasL1TelemetryDecoder::get_left_block() -{ - return telemetry_decoder_; -} - - -gr::basic_block_sptr SbasL1TelemetryDecoder::get_right_block() -{ - return telemetry_decoder_; + InitializeDecoder(sbas_l1_make_telemetry_decoder_gs(satellite(), dump_)); } diff --git a/src/algorithms/telemetry_decoder/adapters/sbas_l1_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/sbas_l1_telemetry_decoder.h index a9c428077..a238b7e81 100644 --- a/src/algorithms/telemetry_decoder/adapters/sbas_l1_telemetry_decoder.h +++ b/src/algorithms/telemetry_decoder/adapters/sbas_l1_telemetry_decoder.h @@ -20,12 +20,7 @@ #define GNSS_SDR_SBAS_L1_TELEMETRY_DECODER_H -#include "gnss_satellite.h" // for Gnss_Satellite -#include "gnss_synchro.h" -#include "sbas_l1_telemetry_decoder_gs.h" -#include "telemetry_decoder_interface.h" -#include // for basic_block_sptr, top_block_sptr -#include // for size_t +#include "telemetry_decoder_adapter_base.h" #include /** \addtogroup Telemetry_Decoder @@ -33,12 +28,11 @@ /** \addtogroup Telemetry_Decoder_adapters * \{ */ -class ConfigurationInterface; /*! * \brief This class implements a NAV data decoder for SBAS frames in L1 radio link */ -class SbasL1TelemetryDecoder : public TelemetryDecoderInterface +class SbasL1TelemetryDecoder : public TelemetryDecoderAdapterBase { public: SbasL1TelemetryDecoder( @@ -47,11 +41,6 @@ public: unsigned int in_streams, unsigned int out_streams); - inline std::string role() override - { - return role_; - } - /*! * \brief Returns "SBAS_L1_Telemetry_Decoder" */ @@ -60,32 +49,8 @@ public: return "SBAS_L1_Telemetry_Decoder"; } - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - void set_satellite(const Gnss_Satellite& satellite) override; - - inline void set_channel(int channel) override { telemetry_decoder_->set_channel(channel); } - - inline void reset() override - { - telemetry_decoder_->reset(); - } - - inline size_t item_size() override - { - return sizeof(Gnss_Synchro); - } - private: - sbas_l1_telemetry_decoder_gs_sptr telemetry_decoder_; - Gnss_Satellite satellite_; std::string dump_filename_; - std::string role_; - unsigned int in_streams_; - unsigned int out_streams_; bool dump_; }; diff --git a/src/algorithms/telemetry_decoder/adapters/telemetry_decoder_adapter_base.cc b/src/algorithms/telemetry_decoder/adapters/telemetry_decoder_adapter_base.cc new file mode 100644 index 000000000..ee6a0271e --- /dev/null +++ b/src/algorithms/telemetry_decoder/adapters/telemetry_decoder_adapter_base.cc @@ -0,0 +1,135 @@ +/*! + * \file telemetry_decoder_adapter_base.cc + * \brief Common functionality for telemetry decoder adapters + * \author Carles Fernandez-Prades, 2025 cfernandez@cttc.es + * + * ----------------------------------------------------------------------------- + * + * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + * This file is part of GNSS-SDR. + * + * Copyright (C) 2010-2025 (see AUTHORS file for a list of contributors) + * SPDX-License-Identifier: GPL-3.0-or-later + * + * ----------------------------------------------------------------------------- + */ + + +#include "telemetry_decoder_adapter_base.h" +#include + +#if USE_GLOG_AND_GFLAGS +#include +#else +#include +#endif + + +TelemetryDecoderAdapterBase::TelemetryDecoderAdapterBase(const ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) +{ + DLOG(INFO) << "role " << role_; + if (configuration != nullptr) + { + tlm_parameters_.SetFromConfiguration(configuration, role_); + } + if (in_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one input stream (" + << in_streams_ << " provided)"; + } + if (out_streams_ > 1) + { + LOG(ERROR) << "This implementation only supports one output stream (" + << out_streams_ << " provided)"; + } +} + + +void TelemetryDecoderAdapterBase::InitializeDecoder(telemetry_impl_base_sptr decoder) +{ + telemetry_decoder_ = std::move(decoder); + DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; +} + + +void TelemetryDecoderAdapterBase::connect(gr::top_block_sptr top_block) +{ + if (top_block) + { + /* top_block is not null */ + } + DLOG(INFO) << "nothing to connect internally"; +} + + +void TelemetryDecoderAdapterBase::disconnect(gr::top_block_sptr top_block) +{ + if (top_block) + { + /* top_block is not null */ + } +} + + +gr::basic_block_sptr TelemetryDecoderAdapterBase::get_left_block() +{ + return telemetry_decoder_; +} + + +gr::basic_block_sptr TelemetryDecoderAdapterBase::get_right_block() +{ + return telemetry_decoder_; +} + + +void TelemetryDecoderAdapterBase::set_satellite(const Gnss_Satellite& satellite) +{ + satellite_ = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); + if (telemetry_decoder_) + { + telemetry_decoder_->set_satellite(satellite_); + DLOG(INFO) << "TELEMETRY DECODER: satellite set to " << satellite_; + } +} + + +std::string TelemetryDecoderAdapterBase::role() +{ + return role_; +} + + +void TelemetryDecoderAdapterBase::set_channel(int channel) +{ + if (telemetry_decoder_) + { + telemetry_decoder_->set_channel(channel); + } +} + + +void TelemetryDecoderAdapterBase::reset() +{ + if (telemetry_decoder_) + { + telemetry_decoder_->reset(); + } +} + + +size_t TelemetryDecoderAdapterBase::item_size() +{ + return sizeof(Gnss_Synchro); +} + + +const Gnss_Satellite& TelemetryDecoderAdapterBase::satellite() const +{ + return satellite_; +} \ No newline at end of file diff --git a/src/algorithms/telemetry_decoder/adapters/telemetry_decoder_adapter_base.h b/src/algorithms/telemetry_decoder/adapters/telemetry_decoder_adapter_base.h new file mode 100644 index 000000000..938b42b0b --- /dev/null +++ b/src/algorithms/telemetry_decoder/adapters/telemetry_decoder_adapter_base.h @@ -0,0 +1,88 @@ +/*! + * \file telemetry_decoder_adapter_base.h + * \brief Common functionality for telemetry decoder adapters + * \author Carles Fernandez-Prades, 2025 cfernandez@cttc.es + * + * ----------------------------------------------------------------------------- + * + * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + * This file is part of GNSS-SDR. + * + * Copyright (C) 2010-2025 (see AUTHORS file for a list of contributors) + * SPDX-License-Identifier: GPL-3.0-or-later + * + * ----------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_TELEMETRY_DECODER_ADAPTER_BASE_H +#define GNSS_SDR_TELEMETRY_DECODER_ADAPTER_BASE_H + +#include "configuration_interface.h" +#include "gnss_satellite.h" +#include "gnss_synchro.h" +#include "telemetry_decoder_interface.h" +#include "telemetry_impl_base.h" +#include "tlm_conf.h" +#include +#include +#include + +class ConfigurationInterface; + +/** \addtogroup Telemetry_Decoder + * \{ + */ +/** \addtogroup Telemetry_Decoder_adapters + * \{ + */ + +/*! + * \brief Base class for Telemetry Decoder adapters + */ +class TelemetryDecoderAdapterBase : public TelemetryDecoderInterface +{ +public: + TelemetryDecoderAdapterBase(const ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams); + + ~TelemetryDecoderAdapterBase() override = default; + + void connect(gr::top_block_sptr top_block) override; + + void disconnect(gr::top_block_sptr top_block) override; + + gr::basic_block_sptr get_left_block() override; + + gr::basic_block_sptr get_right_block() override; + + void set_satellite(const Gnss_Satellite& satellite) override; + + std::string role() override; + + void set_channel(int channel) override; + + void reset() override; + + size_t item_size() override; + +protected: + void InitializeDecoder(telemetry_impl_base_sptr decoder); + + const Gnss_Satellite& satellite() const; + + Tlm_Conf tlm_parameters_; + +private: + telemetry_impl_base_sptr telemetry_decoder_; + Gnss_Satellite satellite_; + std::string role_; + unsigned int in_streams_ = 0; + unsigned int out_streams_ = 0; +}; + +/** \} */ +/** \} */ + +#endif // GNSS_SDR_TELEMETRY_DECODER_ADAPTER_BASE_H diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt b/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt index 7c9ff7b83..7d1f580a5 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt @@ -18,6 +18,7 @@ set(TELEMETRY_DECODER_GR_BLOCKS_SOURCES ) set(TELEMETRY_DECODER_GR_BLOCKS_HEADERS + telemetry_impl_base.h gps_l1_ca_telemetry_decoder_gs.h gps_l2c_telemetry_decoder_gs.h gps_l5_telemetry_decoder_gs.h diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc index c7ecd7da4..1a5c94a62 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.cc @@ -55,7 +55,7 @@ beidou_b1i_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_ beidou_b1i_telemetry_decoder_gs::beidou_b1i_telemetry_decoder_gs( const Gnss_Satellite &satellite, - const Tlm_Conf &conf) : gr::block("beidou_b1i_telemetry_decoder_gs", + const Tlm_Conf &conf) : telemetry_impl_base("beidou_b1i_telemetry_decoder_gs", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))), d_dump_filename(conf.dump_filename), diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.h index 25ef1185e..0a7b8e978 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_gs.h @@ -24,6 +24,7 @@ #include "gnss_block_interface.h" #include "gnss_satellite.h" #include "nav_message_packet.h" +#include "telemetry_impl_base.h" #include "tlm_conf.h" #include "tlm_crc_stats.h" #include @@ -54,13 +55,13 @@ beidou_b1i_telemetry_decoder_gs_sptr beidou_b1i_make_telemetry_decoder_gs( * \brief This class implements a block that decodes the BeiDou DNAV data. * \note Code added as part of GSoC 2018 program */ -class beidou_b1i_telemetry_decoder_gs : public gr::block +class beidou_b1i_telemetry_decoder_gs : public telemetry_impl_base { public: - ~beidou_b1i_telemetry_decoder_gs() override; //!< Class destructor - void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN - void set_channel(int channel); //!< Set receiver's channel - void reset(); + ~beidou_b1i_telemetry_decoder_gs() override; //!< Class destructor + void set_satellite(const Gnss_Satellite &satellite) override; //!< Set satellite PRN + void set_channel(int channel) override; //!< Set receiver's channel + void reset() override; /*! * \brief This is where all signal processing takes place diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc index d27afa592..9f3f37fe3 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc @@ -54,7 +54,7 @@ beidou_b3i_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, beidou_b3i_telemetry_decoder_gs::beidou_b3i_telemetry_decoder_gs( const Gnss_Satellite &satellite, const Tlm_Conf &conf) - : gr::block("beidou_b3i_telemetry_decoder_gs", + : telemetry_impl_base("beidou_b3i_telemetry_decoder_gs", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))), d_dump_filename(conf.dump_filename), diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.h index eb7b14705..3f526991b 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.h @@ -21,6 +21,7 @@ #include "gnss_block_interface.h" #include "gnss_satellite.h" #include "nav_message_packet.h" +#include "telemetry_impl_base.h" #include "tlm_conf.h" #include "tlm_crc_stats.h" #include @@ -51,13 +52,13 @@ beidou_b3i_telemetry_decoder_gs_sptr beidou_b3i_make_telemetry_decoder_gs( /*! * \brief This class implements a block that decodes the BeiDou DNAV data. */ -class beidou_b3i_telemetry_decoder_gs : public gr::block +class beidou_b3i_telemetry_decoder_gs : public telemetry_impl_base { public: - ~beidou_b3i_telemetry_decoder_gs() override; //!< Class destructor - void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN - void set_channel(int channel); //!< Set receiver's channel - void reset(); + ~beidou_b3i_telemetry_decoder_gs() override; //!< Class destructor + void set_satellite(const Gnss_Satellite &satellite) override; //!< Set satellite PRN + void set_channel(int channel) override; //!< Set receiver's channel + void reset() override; /*! * \brief This is where all signal processing takes place diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.cc index f209fb913..793764c22 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.cc @@ -80,7 +80,8 @@ galileo_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Con galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs( const Gnss_Satellite &satellite, const Tlm_Conf &conf, - int frame_type) : gr::block("galileo_telemetry_decoder_gs", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), + int frame_type) : telemetry_impl_base("galileo_telemetry_decoder_gs", + gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))), d_dump_filename(conf.dump_filename), d_delta_t(0), diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.h index a6391a2e0..e3b5bdb69 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_gs.h @@ -21,13 +21,14 @@ #ifndef GNSS_SDR_GALILEO_TELEMETRY_DECODER_GS_H #define GNSS_SDR_GALILEO_TELEMETRY_DECODER_GS_H -#include "galileo_cnav_message.h" // for Galileo_Cnav_Message -#include "galileo_fnav_message.h" // for Galileo_Fnav_Message -#include "galileo_inav_message.h" // for Galileo_Inav_Message -#include "gnss_block_interface.h" // for gnss_shared_ptr (adapts smart pointer type to GNU Radio version) -#include "gnss_satellite.h" // for Gnss_Satellite -#include "gnss_time.h" // for GnssTime -#include "nav_message_packet.h" // for Nav_Message_Packet +#include "galileo_cnav_message.h" // for Galileo_Cnav_Message +#include "galileo_fnav_message.h" // for Galileo_Fnav_Message +#include "galileo_inav_message.h" // for Galileo_Inav_Message +#include "gnss_block_interface.h" // for gnss_shared_ptr (adapts smart pointer type to GNU Radio version) +#include "gnss_satellite.h" // for Gnss_Satellite +#include "gnss_time.h" // for GnssTime +#include "nav_message_packet.h" // for Nav_Message_Packet +#include "telemetry_impl_base.h" #include "tlm_conf.h" // for Tlm_Conf #include // for boost::circular_buffer #include // for block @@ -58,13 +59,13 @@ galileo_telemetry_decoder_gs_sptr galileo_make_telemetry_decoder_gs( /*! * \brief This class implements a block that decodes the INAV and FNAV data defined in Galileo ICD */ -class galileo_telemetry_decoder_gs : public gr::block +class galileo_telemetry_decoder_gs : public telemetry_impl_base { public: ~galileo_telemetry_decoder_gs() override; - void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN - void set_channel(int32_t channel); //!< Set receiver's channel - void reset(); + void set_satellite(const Gnss_Satellite &satellite) override; //!< Set satellite PRN + void set_channel(int32_t channel) override; //!< Set receiver's channel + void reset() override; /*! * \brief This is where all signal processing takes place diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.cc index b19c5eb02..9e99a2bb1 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.cc @@ -52,7 +52,8 @@ glonass_l1_ca_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, const T glonass_l1_ca_telemetry_decoder_gs::glonass_l1_ca_telemetry_decoder_gs( const Gnss_Satellite &satellite, - const Tlm_Conf &conf) : gr::block("glonass_l1_ca_telemetry_decoder_gs", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), + const Tlm_Conf &conf) : telemetry_impl_base("glonass_l1_ca_telemetry_decoder_gs", + gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))), d_dump_filename(conf.dump_filename), d_preamble_time_samples(0), diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.h index df679916e..7c58e2057 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_gs.h @@ -25,6 +25,7 @@ #include "gnss_satellite.h" #include "gnss_synchro.h" #include "nav_message_packet.h" +#include "telemetry_impl_base.h" #include "tlm_conf.h" #include "tlm_crc_stats.h" #include @@ -56,13 +57,13 @@ glonass_l1_ca_telemetry_decoder_gs_sptr glonass_l1_ca_make_telemetry_decoder_gs( * \see GLONASS ICD * */ -class glonass_l1_ca_telemetry_decoder_gs : public gr::block +class glonass_l1_ca_telemetry_decoder_gs : public telemetry_impl_base { public: - ~glonass_l1_ca_telemetry_decoder_gs() override; //!< Class destructor - void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN - void set_channel(int32_t channel); //!< Set receiver's channel - inline void reset() {}; + ~glonass_l1_ca_telemetry_decoder_gs() override; //!< Class destructor + void set_satellite(const Gnss_Satellite &satellite) override; //!< Set satellite PRN + void set_channel(int32_t channel) override; //!< Set receiver's channel + inline void reset() override {}; /*! * \brief This is where all signal processing takes place diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.cc index 9de17d33c..5b193b853 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.cc @@ -52,7 +52,8 @@ glonass_l2_ca_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, const T glonass_l2_ca_telemetry_decoder_gs::glonass_l2_ca_telemetry_decoder_gs( const Gnss_Satellite &satellite, - const Tlm_Conf &conf) : gr::block("glonass_l2_ca_telemetry_decoder_gs", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), + const Tlm_Conf &conf) : telemetry_impl_base("glonass_l2_ca_telemetry_decoder_gs", + gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))), d_dump_filename(conf.dump_filename), d_preamble_time_samples(0), diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.h index 3a0455d30..1d9017751 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_gs.h @@ -24,6 +24,7 @@ #include "gnss_satellite.h" #include "gnss_synchro.h" #include "nav_message_packet.h" +#include "telemetry_impl_base.h" #include "tlm_conf.h" #include "tlm_crc_stats.h" #include @@ -54,13 +55,13 @@ glonass_l2_ca_telemetry_decoder_gs_sptr glonass_l2_ca_make_telemetry_decoder_gs( * \see GLONASS ICD * */ -class glonass_l2_ca_telemetry_decoder_gs : public gr::block +class glonass_l2_ca_telemetry_decoder_gs : public telemetry_impl_base { public: - ~glonass_l2_ca_telemetry_decoder_gs() override; //!< Class destructor - void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN - void set_channel(int32_t channel); //!< Set receiver's channel - inline void reset() {}; + ~glonass_l2_ca_telemetry_decoder_gs() override; //!< Class destructor + void set_satellite(const Gnss_Satellite &satellite) override; //!< Set satellite PRN + void set_channel(int32_t channel) override; //!< Set receiver's channel + inline void reset() override {}; /*! * \brief This is where all signal processing takes place diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc index 932d7d68e..588ded670 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc @@ -76,7 +76,8 @@ gps_l1_ca_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_C gps_l1_ca_telemetry_decoder_gs::gps_l1_ca_telemetry_decoder_gs( const Gnss_Satellite &satellite, - const Tlm_Conf &conf) : gr::block("gps_navigation_gs", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), + const Tlm_Conf &conf) : telemetry_impl_base("gps_navigation_gs", + gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))), d_dump_filename(conf.dump_filename), d_sample_counter(0ULL), diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.h index 5939163bc..744b18cdb 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.h @@ -23,6 +23,7 @@ #include "gnss_time.h" // for timetags produced by Tracking #include "gps_navigation_message.h" #include "nav_message_packet.h" +#include "telemetry_impl_base.h" #include "tlm_conf.h" #include "tlm_crc_stats.h" #include @@ -52,13 +53,13 @@ gps_l1_ca_telemetry_decoder_gs_sptr gps_l1_ca_make_telemetry_decoder_gs( /*! * \brief This class implements a block that decodes the NAV data defined in IS-GPS-200M */ -class gps_l1_ca_telemetry_decoder_gs : public gr::block +class gps_l1_ca_telemetry_decoder_gs : public telemetry_impl_base { public: ~gps_l1_ca_telemetry_decoder_gs() override; - void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN - void set_channel(int channel); //!< Set receiver's channel - void reset(); + void set_satellite(const Gnss_Satellite &satellite) override; //!< Set satellite PRN + void set_channel(int channel) override; //!< Set receiver's channel + void reset() override; /*! * \brief This is where all signal processing takes place diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc index ea4f15585..bdb333976 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc @@ -51,7 +51,7 @@ gps_l2c_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Con gps_l2c_telemetry_decoder_gs::gps_l2c_telemetry_decoder_gs( const Gnss_Satellite &satellite, - const Tlm_Conf &conf) : gr::block("gps_l2c_telemetry_decoder_gs", + const Tlm_Conf &conf) : telemetry_impl_base("gps_l2c_telemetry_decoder_gs", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))), d_dump_filename(conf.dump_filename), diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.h index 28894353a..6e4ccccb4 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.h @@ -22,6 +22,7 @@ #include "gnss_satellite.h" #include "gps_cnav_navigation_message.h" #include "nav_message_packet.h" +#include "telemetry_impl_base.h" #include "tlm_conf.h" #include "tlm_crc_stats.h" #include @@ -53,13 +54,13 @@ gps_l2c_telemetry_decoder_gs_sptr gps_l2c_make_telemetry_decoder_gs( /*! * \brief This class implements a block that decodes CNAV data defined in IS-GPS-200M */ -class gps_l2c_telemetry_decoder_gs : public gr::block +class gps_l2c_telemetry_decoder_gs : public telemetry_impl_base { public: ~gps_l2c_telemetry_decoder_gs() override; - void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN - void set_channel(int32_t channel); //!< Set receiver's channel - void reset(); + void set_satellite(const Gnss_Satellite &satellite) override; //!< Set satellite PRN + void set_channel(int32_t channel) override; //!< Set receiver's channel + void reset() override; /*! * \brief This is where all signal processing takes place diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc index f6d95d2a5..1dfdfcee4 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc @@ -49,7 +49,7 @@ gps_l5_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, const Tlm_Conf gps_l5_telemetry_decoder_gs::gps_l5_telemetry_decoder_gs( const Gnss_Satellite &satellite, - const Tlm_Conf &conf) : gr::block("gps_l5_telemetry_decoder_gs", + const Tlm_Conf &conf) : telemetry_impl_base("gps_l5_telemetry_decoder_gs", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))), d_dump_filename(conf.dump_filename), diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.h index aba7da785..b7ae13349 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.h @@ -22,6 +22,7 @@ #include "gnss_satellite.h" // for Gnss_Satellite #include "gps_cnav_navigation_message.h" // for Gps_CNAV_Navigation_Message #include "nav_message_packet.h" +#include "telemetry_impl_base.h" #include "tlm_conf.h" #include "tlm_crc_stats.h" #include @@ -55,13 +56,13 @@ gps_l5_telemetry_decoder_gs_sptr gps_l5_make_telemetry_decoder_gs( * \brief This class implements a GPS L5 Telemetry decoder * */ -class gps_l5_telemetry_decoder_gs : public gr::block +class gps_l5_telemetry_decoder_gs : public telemetry_impl_base { public: ~gps_l5_telemetry_decoder_gs() override; - void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN - void set_channel(int32_t channel); //!< Set receiver's channel - void reset(); + void set_satellite(const Gnss_Satellite &satellite) override; //!< Set satellite PRN + void set_channel(int32_t channel) override; //!< Set receiver's channel + void reset() override; int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) override; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_gs.cc index 3da46865f..bce7b8c2b 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_gs.cc @@ -49,7 +49,7 @@ sbas_l1_telemetry_decoder_gs_sptr sbas_l1_make_telemetry_decoder_gs( sbas_l1_telemetry_decoder_gs::sbas_l1_telemetry_decoder_gs( const Gnss_Satellite &satellite, - bool dump) : gr::block("sbas_l1_telemetry_decoder_gs", + bool dump) : telemetry_impl_base("sbas_l1_telemetry_decoder_gs", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))), d_dump(dump), diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_gs.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_gs.h index 86fd2dfb6..4e0df86d6 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_gs.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_gs.h @@ -19,6 +19,7 @@ #include "gnss_block_interface.h" #include "gnss_satellite.h" +#include "telemetry_impl_base.h" #include // for crc_optimal #include #include // for gr_vector_const_void_star @@ -51,13 +52,13 @@ sbas_l1_telemetry_decoder_gs_sptr sbas_l1_make_telemetry_decoder_gs( * \brief This class implements a block that decodes the SBAS integrity and * corrections data defined in RTCA MOPS DO-229 */ -class sbas_l1_telemetry_decoder_gs : public gr::block +class sbas_l1_telemetry_decoder_gs : public telemetry_impl_base { public: ~sbas_l1_telemetry_decoder_gs() override; - void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN - void set_channel(int32_t channel); //!< Set receiver's channel - inline void reset() {}; + void set_satellite(const Gnss_Satellite &satellite) override; //!< Set satellite PRN + void set_channel(int32_t channel) override; //!< Set receiver's channel + inline void reset() override {}; /*! * \brief This is where all signal processing takes place diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/telemetry_impl_base.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/telemetry_impl_base.h new file mode 100644 index 000000000..48da71bfa --- /dev/null +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/telemetry_impl_base.h @@ -0,0 +1,59 @@ +/*! + * \file telemetry_impl_base.h + * \brief Base class for telemetry decoder GNU Radio blocks. + * \author Carles Fernandez-Prades, 2025 cfernandez@cttc.es + * + * ----------------------------------------------------------------------------- + * + * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + * This file is part of GNSS-SDR. + * + * Copyright (C) 2010-2024 (see AUTHORS file for a list of contributors) + * SPDX-License-Identifier: GPL-3.0-or-later + * + * ----------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_TELEMETRY_DECODER_TELEMETRY_IMPL_BASE_H +#define GNSS_SDR_TELEMETRY_DECODER_TELEMETRY_IMPL_BASE_H + +#include "gnss_block_interface.h" +#include "gnss_satellite.h" +#include +#include +#include + +/** \addtogroup Telemetry_Decoder + * \{ + */ +/** \addtogroup Telemetry_Decoder_gnuradio_blocks telemetry_decoder_gr_blocks + * \{ + */ + +class telemetry_impl_base; +using telemetry_impl_base_sptr = gnss_shared_ptr; + +/*! + * \brief Common base class for telemetry decoder GNU Radio implementations. + */ +class telemetry_impl_base : public gr::block +{ +public: + telemetry_impl_base(const std::string& name, + gr::io_signature::sptr input_signature, + gr::io_signature::sptr output_signature) + : gr::block(name, + std::move(input_signature), + std::move(output_signature)) {} + + ~telemetry_impl_base() override = default; + + virtual void set_satellite(const Gnss_Satellite& satellite) = 0; + virtual void set_channel(int channel) = 0; + virtual void reset() = 0; +}; + +/** \} */ +/** \} */ + +#endif // GNSS_SDR_TELEMETRY_DECODER_TELEMETRY_IMPL_BASE_H diff --git a/src/algorithms/tracking/adapters/CMakeLists.txt b/src/algorithms/tracking/adapters/CMakeLists.txt index b72ae96df..4c6524b80 100644 --- a/src/algorithms/tracking/adapters/CMakeLists.txt +++ b/src/algorithms/tracking/adapters/CMakeLists.txt @@ -18,6 +18,7 @@ endif() if(ENABLE_FPGA) set(OPT_TRACKING_ADAPTERS_SOURCES ${OPT_TRACKING_ADAPTERS_SOURCES} + base_dll_pll_tracking_fpga.cc gps_l1_ca_dll_pll_tracking_fpga.cc gps_l2_m_dll_pll_tracking_fpga.cc galileo_e1_dll_pll_veml_tracking_fpga.cc @@ -26,6 +27,7 @@ if(ENABLE_FPGA) ) set(OPT_TRACKING_ADAPTERS_HEADERS ${OPT_TRACKING_ADAPTERS_HEADERS} + base_dll_pll_tracking_fpga.h gps_l1_ca_dll_pll_tracking_fpga.h gps_l2_m_dll_pll_tracking_fpga.h galileo_e1_dll_pll_veml_tracking_fpga.h @@ -35,6 +37,7 @@ if(ENABLE_FPGA) endif() set(TRACKING_ADAPTER_SOURCES + base_dll_pll_tracking.cc galileo_e1_dll_pll_veml_tracking.cc galileo_e1_tcp_connector_tracking.cc gps_l1_ca_dll_pll_tracking.cc @@ -56,6 +59,7 @@ set(TRACKING_ADAPTER_SOURCES ) set(TRACKING_ADAPTER_HEADERS + base_dll_pll_tracking.h galileo_e1_dll_pll_veml_tracking.h galileo_e1_tcp_connector_tracking.h gps_l1_ca_dll_pll_tracking.h diff --git a/src/algorithms/tracking/adapters/base_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/base_dll_pll_tracking.cc new file mode 100644 index 000000000..957d3b968 --- /dev/null +++ b/src/algorithms/tracking/adapters/base_dll_pll_tracking.cc @@ -0,0 +1,98 @@ +/*! + * \file base_dll_pll_tracking.cc + * \brief Base class providing shared logic for DLL+PLL VEML tracking adapters. + * \authors Carles Fernandez, 2025. carles.fernandez(at)cttc.cat + * + * ----------------------------------------------------------------------------- + * + * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + * This file is part of GNSS-SDR. + * + * Copyright (C) 2010-2025 (see AUTHORS file for a list of contributors) + * SPDX-License-Identifier: GPL-3.0-or-later + * + * ----------------------------------------------------------------------------- + */ + +#include "base_dll_pll_tracking.h" +#include "configuration_interface.h" + +#if USE_GLOG_AND_GFLAGS +#include +#else +#include +#endif + +BaseDllPllTracking::BaseDllPllTracking( + const ConfigurationInterface* configuration, + std::string role, + unsigned int in_streams, + unsigned int out_streams) + : role_(std::move(role)), + item_size_(sizeof(gr_complex)) +{ + trk_params_.SetFromConfiguration(configuration, role_); + + if (in_streams > 1) + { + LOG(ERROR) << "Only one input stream is supported."; + } + if (out_streams > 1) + { + LOG(ERROR) << "Only one output stream is supported."; + } + + DLOG(INFO) << "role " << role_; +} + + +void BaseDllPllTracking::connect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* no connection needed */ + } +} + + +void BaseDllPllTracking::disconnect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* no disconnection needed */ + } +} + + +gr::basic_block_sptr BaseDllPllTracking::get_left_block() +{ + return tracking_sptr_; +} + + +gr::basic_block_sptr BaseDllPllTracking::get_right_block() +{ + return tracking_sptr_; +} + + +void BaseDllPllTracking::set_channel(unsigned int channel) +{ + tracking_sptr_->set_channel(channel); +} + + +void BaseDllPllTracking::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) +{ + tracking_sptr_->set_gnss_synchro(p_gnss_synchro); +} + + +void BaseDllPllTracking::start_tracking() +{ + tracking_sptr_->start_tracking(); +} + + +void BaseDllPllTracking::stop_tracking() +{ + tracking_sptr_->stop_tracking(); +} diff --git a/src/algorithms/tracking/adapters/base_dll_pll_tracking.h b/src/algorithms/tracking/adapters/base_dll_pll_tracking.h new file mode 100644 index 000000000..a3c277a18 --- /dev/null +++ b/src/algorithms/tracking/adapters/base_dll_pll_tracking.h @@ -0,0 +1,126 @@ +/*! + * \file base_dll_pll_tracking.h + * \brief Base class providing shared logic for DLL+PLL VEML tracking adapters. + * \authors Carles Fernandez, 2025. carles.fernandez(at)cttc.cat + * + * ----------------------------------------------------------------------------- + * + * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + * This file is part of GNSS-SDR. + * + * Copyright (C) 2010-2025 (see AUTHORS file for a list of contributors) + * SPDX-License-Identifier: GPL-3.0-or-later + * + * ----------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_BASE_DLL_PLL_TRACKING_H +#define GNSS_SDR_BASE_DLL_PLL_TRACKING_H + +#include "dll_pll_conf.h" +#include "dll_pll_veml_tracking.h" +#include "tracking_interface.h" +#include +#include + +/** \addtogroup Tracking + * Classes for GNSS signal tracking. + * \{ */ +/** \addtogroup Tracking_adapters tracking_adapters + * Wrap GNU Radio blocks for GNSS signal tracking with a TrackingInterface + * \{ */ + +class ConfigurationInterface; + +/*! + * \brief Base class providing shared logic for DLL+PLL tracking loop adapters + * for GNSS signals. + */ +class BaseDllPllTracking : public TrackingInterface +{ +public: + /*! + * \brief Base constructor of a Tracking block adapter + */ + explicit BaseDllPllTracking(const ConfigurationInterface* configuration, + std::string role, + unsigned int in_streams, + unsigned int out_streams); + + /*! + * \brief Default destructor of the Tracking block adapter + */ + ~BaseDllPllTracking() override = default; + + /*! + * \brief Get role from the Tracking block adapter + */ + inline std::string role() override final { return role_; } + + /*! + * \brief Get item_size from the Tracking block adapter + */ + inline size_t item_size() override final { return item_size_; } + + /*! + * \brief Connect the Tracking block adapter + */ + void connect(gr::top_block_sptr top_block) override final; + + /*! + * \brief Disconnect the sTracking block adapter + */ + void disconnect(gr::top_block_sptr top_block) override final; + + /*! + * \brief Get left block from the Tracking block adapter + */ + gr::basic_block_sptr get_left_block() override final; + + /*! + * \brief Get right block from the Tracking block adapter + */ + gr::basic_block_sptr get_right_block() override final; + + /*! + * \brief Set tracking channel unique ID + */ + void set_channel(unsigned int channel) override final; + + /*! + * \brief Set acquisition Gnss_Synchro object pointer + * to exchange synchronization data between acquisition and tracking blocks + */ + void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override final; + + /*! + * \brief Start the Tracking block + */ + void start_tracking() override final; + + /*! + * \brief Stop the Tracking block + */ + void stop_tracking() override final; + +protected: + // Can be used by each derived class + inline Dll_Pll_Conf& config_params() { return trk_params_; } + inline const Dll_Pll_Conf& config_params() const { return trk_params_; } + inline void set_item_size(size_t item_size) { item_size_ = item_size; } + + // Must be implemented / filled by each derived class + virtual void configure_tracking_parameters(const ConfigurationInterface* configuration) = 0; + virtual void create_tracking_block() = 0; + dll_pll_veml_tracking_sptr tracking_sptr_; + +private: + // Managed by the base class + Dll_Pll_Conf trk_params_; + const std::string role_; + size_t item_size_; +}; + +/** \} */ +/** \} */ +#endif // GNSS_SDR_BASE_DLL_PLL_TRACKING_H diff --git a/src/algorithms/tracking/adapters/base_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/base_dll_pll_tracking_fpga.cc new file mode 100644 index 000000000..a793f13b8 --- /dev/null +++ b/src/algorithms/tracking/adapters/base_dll_pll_tracking_fpga.cc @@ -0,0 +1,111 @@ +/*! + * \file base_dll_pll_tracking_fpga.cc + * \brief Base class providing shared logic for DLL+PLL VEML tracking adapters + * for FPGA-based devices + * \authors Carles Fernandez, 2025. carles.fernandez(at)cttc.cat + * + * ----------------------------------------------------------------------------- + * + * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + * This file is part of GNSS-SDR. + * + * Copyright (C) 2010-2025 (see AUTHORS file for a list of contributors) + * SPDX-License-Identifier: GPL-3.0-or-later + * + * ----------------------------------------------------------------------------- + */ + +#include "base_dll_pll_tracking_fpga.h" +#include "configuration_interface.h" +#include "uio_fpga.h" + +#if USE_GLOG_AND_GFLAGS +#include +#else +#include +#endif + +BaseDllPllTrackingFpga::BaseDllPllTrackingFpga( + const ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams) + : role_(role), + channel_(0), + num_prev_assigned_ch_(0) +{ + trk_params_.SetFromConfiguration(configuration, role_); + if (in_streams > 1) + { + LOG(ERROR) << "This implementation only supports one input stream"; + } + if (out_streams > 1) + { + LOG(ERROR) << "This implementation only supports one output stream"; + } + DLOG(INFO) << "role " << role_; +} + + +void BaseDllPllTrackingFpga::connect(gr::top_block_sptr top_block) +{ + if (top_block) + { + } +} + + +void BaseDllPllTrackingFpga::disconnect(gr::top_block_sptr top_block) +{ + if (top_block) + { + } +} + + +gr::basic_block_sptr BaseDllPllTrackingFpga::get_left_block() +{ + return tracking_fpga_sc_sptr_; +} + + +gr::basic_block_sptr BaseDllPllTrackingFpga::get_right_block() +{ + return tracking_fpga_sc_sptr_; +} + + +void BaseDllPllTrackingFpga::start_tracking() +{ + tracking_fpga_sc_sptr_->start_tracking(); +} + + +void BaseDllPllTrackingFpga::stop_tracking() +{ + tracking_fpga_sc_sptr_->stop_tracking(); +} + + +void BaseDllPllTrackingFpga::set_channel(unsigned int channel) +{ + channel_ = channel; + std::string device_io_name; + + if (find_uio_dev_file_name(device_io_name, device_name_, channel - num_prev_assigned_ch_) < 0) + { + if (!find_alternative_device(device_io_name)) + { + std::cout << "Cannot find FPGA UIO device file for " << device_name_ << std::endl; + throw std::runtime_error("UIO device not found"); + } + } + + tracking_fpga_sc_sptr_->set_channel(channel_, device_io_name); +} + + +void BaseDllPllTrackingFpga::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) +{ + tracking_fpga_sc_sptr_->set_gnss_synchro(p_gnss_synchro); +} diff --git a/src/algorithms/tracking/adapters/base_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/base_dll_pll_tracking_fpga.h new file mode 100644 index 000000000..6704db376 --- /dev/null +++ b/src/algorithms/tracking/adapters/base_dll_pll_tracking_fpga.h @@ -0,0 +1,135 @@ +/*! + * \file base_dll_pll_tracking_fpga.h + * \brief Base class providing shared logic for DLL+PLL VEML tracking adapters + * for FPGA-based devices + * \authors Carles Fernandez, 2025. carles.fernandez(at)cttc.cat + * + * ----------------------------------------------------------------------------- + * + * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + * This file is part of GNSS-SDR. + * + * Copyright (C) 2010-2025 (see AUTHORS file for a list of contributors) + * SPDX-License-Identifier: GPL-3.0-or-later + * + * ----------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_BASE_DLL_PLL_TRACKING_FPGA_H +#define GNSS_SDR_BASE_DLL_PLL_TRACKING_FPGA_H + +#include "dll_pll_conf_fpga.h" +#include "dll_pll_veml_tracking_fpga.h" +#include "tracking_interface.h" +#include +#include +#include + +// /** \addtogroup Tracking +// * \{ */ +// /** \addtogroup Tracking_adapters +// * \{ */ + +class ConfigurationInterface; + +class BaseDllPllTrackingFpga : public TrackingInterface +{ +public: + /*! + * \brief Base constructor of FPGA-based Tracking block adapters + */ + BaseDllPllTrackingFpga(const ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams); + /*! + * \brief Base destructor of FPGA-based Tracking block adapters + */ + virtual ~BaseDllPllTrackingFpga() = default; + + // Common TrackingInterface overrides + + /*! + * \brief Get role from the Tracking block adapter + */ + std::string role() override { return role_; } + + /*! + * \brief Get item_size from the Tracking block adapter + */ + size_t item_size() override { return sizeof(int16_t); } + + /*! + * \brief Connect the Tracking block adapter + */ + void connect(gr::top_block_sptr top_block) override; + + /*! + * \brief Disconnect the Tracking block adapter + */ + void disconnect(gr::top_block_sptr top_block) override; + + /*! + * \brief Get left block from the Tracking block adapter + */ + gr::basic_block_sptr get_left_block() override; + + /*! + * \brief Get right block from the Tracking block adapter + */ + gr::basic_block_sptr get_right_block() override; + + /*! + * \brief Start the tracking process in the FPGA + */ + void start_tracking() override; + + /*! + * \brief Stop the tracking process in the FPGA + */ + void stop_tracking() override; + + /*! + * \brief Set tracking channel unique ID + */ + void set_channel(unsigned int channel) override; + + /*! + * \brief Set acquisition/tracking common Gnss_Synchro object pointer + * to efficiently exchange synchronization data between acquisition and tracking blocks + */ + void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; + +protected: + // Can be used by each derived class + static const int32_t LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY = 0x0C000000; // flag that enables WE (Write Enable) of the local code FPGA + static const int32_t LOCAL_CODE_FPGA_CORRELATOR_SELECT_COUNT = 0x20000000; // flag that selects the writting of the pilot code in the FPGA (as opposed to the data code) + const std::string default_device_name_GPS_L1 = "multicorrelator_resampler_S00_AXI"; // Default FPGA device name for GPS L1 + const std::string default_device_name_Galileo_E1 = "multicorrelator_resampler_5_1_AXI"; // Default FPGA device name for Galileo L1 + const std::string default_device_name_GPS_L5 = "multicorrelator_resampler_3_1_AXI"; // Default FPGA device name for GPS L5 + const std::string default_device_name_GPS_L2 = "multicorrelator_resampler_S00_AXI"; // Default FPGA device name for GPS L2 + const std::string default_device_name_Galileo_E5a = "multicorrelator_resampler_3_1_AXI"; // Default FPGA device name for Galieo E5a + + inline Dll_Pll_Conf_Fpga& config_params_fpga() { return trk_params_; } + inline const Dll_Pll_Conf_Fpga& config_params_fpga() const { return trk_params_; } + inline void set_num_prev_assigned_ch(uint32_t num_prev_assigned_ch) { num_prev_assigned_ch_ = num_prev_assigned_ch; }; + inline uint32_t get_channel() { return channel_; }; + inline uint32_t get_num_prev_assigned_ch() { return num_prev_assigned_ch_; }; + + // Can be overriden by derived classes + bool find_alternative_device(std::string& device_io_name [[maybe_unused]]) { return false; }; + + // Must be set by each derived class + dll_pll_veml_tracking_fpga_sptr tracking_fpga_sc_sptr_; + std::string device_name_; + +private: + Dll_Pll_Conf_Fpga trk_params_; + const std::string role_; + uint32_t channel_; + uint32_t num_prev_assigned_ch_; +}; + +/** \} */ +/** \} */ +#endif // GNSS_SDR_BASE_DLL_PLL_TRACKING_FPGA_H diff --git a/src/algorithms/tracking/adapters/beidou_b1i_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/beidou_b1i_dll_pll_tracking.cc index 748d81967..5516f6228 100644 --- a/src/algorithms/tracking/adapters/beidou_b1i_dll_pll_tracking.cc +++ b/src/algorithms/tracking/adapters/beidou_b1i_dll_pll_tracking.cc @@ -24,8 +24,6 @@ #include "Beidou_B1I.h" #include "configuration_interface.h" #include "display.h" -#include "dll_pll_conf.h" -#include "gnss_sdr_flags.h" #include #include @@ -38,120 +36,57 @@ BeidouB1iDllPllTracking::BeidouB1iDllPllTracking( const ConfigurationInterface* configuration, const std::string& role, - unsigned int in_streams, unsigned int out_streams) - : role_(role), - item_size_(sizeof(gr_complex)), - channel_(0), - in_streams_(in_streams), - out_streams_(out_streams) + unsigned int in_streams, + unsigned int out_streams) + : BaseDllPllTracking(configuration, role, in_streams, out_streams) { - Dll_Pll_Conf trk_params = Dll_Pll_Conf(); - trk_params.SetFromConfiguration(configuration, role_); + configure_tracking_parameters(configuration); + create_tracking_block(); +} - const auto vector_length = static_cast(std::round(trk_params.fs_in / (BEIDOU_B1I_CODE_RATE_CPS / BEIDOU_B1I_CODE_LENGTH_CHIPS))); - trk_params.vector_length = vector_length; - if (trk_params.extend_correlation_symbols < 1) + +void BeidouB1iDllPllTracking::configure_tracking_parameters( + const ConfigurationInterface* configuration) +{ + const auto vector_length = static_cast(std::round(config_params().fs_in / (BEIDOU_B1I_CODE_RATE_CPS / BEIDOU_B1I_CODE_LENGTH_CHIPS))); + config_params().vector_length = vector_length; + config_params().system = 'C'; + const std::array sig{'B', '1', '\0'}; + std::copy_n(sig.data(), 3, config_params().signal); + if (config_params().extend_correlation_symbols < 1) { - trk_params.extend_correlation_symbols = 1; + config_params().extend_correlation_symbols = 1; std::cout << TEXT_RED << "WARNING: BEIDOU B1I. extend_correlation_symbols must be bigger than 1. Coherent integration has been set to 1 symbol (1 ms)" << TEXT_RESET << '\n'; } - else if (trk_params.extend_correlation_symbols > 20) + else if (config_params().extend_correlation_symbols > 20) { - trk_params.extend_correlation_symbols = 20; + config_params().extend_correlation_symbols = 20; std::cout << TEXT_RED << "WARNING: BEIDOU B1I. extend_correlation_symbols must be lower than 21. Coherent integration has been set to 20 symbols (20 ms)" << TEXT_RESET << '\n'; } - trk_params.track_pilot = configuration->property(role_ + ".track_pilot", false); - if (trk_params.track_pilot) + config_params().track_pilot = configuration->property(role() + ".track_pilot", false); + if (config_params().track_pilot) { std::cout << TEXT_RED << "WARNING: BEIDOU B1I does not have pilot signal. Data tracking has been enabled" << TEXT_RESET << '\n'; - trk_params.track_pilot = false; + config_params().track_pilot = false; } - if ((trk_params.extend_correlation_symbols > 1) && (trk_params.pll_bw_narrow_hz > trk_params.pll_bw_hz or trk_params.dll_bw_narrow_hz > trk_params.dll_bw_hz)) + if ((config_params().extend_correlation_symbols > 1) && (config_params().pll_bw_narrow_hz > config_params().pll_bw_hz or config_params().dll_bw_narrow_hz > config_params().dll_bw_hz)) { std::cout << TEXT_RED << "WARNING: BEIDOU B1I. PLL or DLL narrow tracking bandwidth is higher than wide tracking one" << TEXT_RESET << '\n'; } - trk_params.system = 'C'; - const std::array sig{'B', '1', '\0'}; - std::copy_n(sig.data(), 3, trk_params.signal); +} - // ################# Make a GNU Radio Tracking block object ################ - DLOG(INFO) << "role " << role_; - if (trk_params.item_type == "gr_complex") + +void BeidouB1iDllPllTracking::create_tracking_block() +{ + if (config_params().item_type == "gr_complex") { - tracking_sptr_ = dll_pll_veml_make_tracking(trk_params); + tracking_sptr_ = dll_pll_veml_make_tracking(config_params()); DLOG(INFO) << "tracking(" << tracking_sptr_->unique_id() << ")"; } else { - item_size_ = 0; + set_item_size(0); tracking_sptr_ = nullptr; - LOG(WARNING) << trk_params.item_type << " unknown tracking item type."; - } - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; + LOG(WARNING) << config_params().item_type << " unknown tracking item type."; } } - - -void BeidouB1iDllPllTracking::start_tracking() -{ - tracking_sptr_->start_tracking(); -} - - -void BeidouB1iDllPllTracking::stop_tracking() -{ - tracking_sptr_->stop_tracking(); -} - - -/* - * Set tracking channel unique ID - */ -void BeidouB1iDllPllTracking::set_channel(unsigned int channel) -{ - channel_ = channel; - tracking_sptr_->set_channel(channel); -} - - -void BeidouB1iDllPllTracking::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) -{ - tracking_sptr_->set_gnss_synchro(p_gnss_synchro); -} - - -void BeidouB1iDllPllTracking::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to connect, now the tracking uses gr_sync_decimator -} - - -void BeidouB1iDllPllTracking::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to disconnect, now the tracking uses gr_sync_decimator -} - - -gr::basic_block_sptr BeidouB1iDllPllTracking::get_left_block() -{ - return tracking_sptr_; -} - - -gr::basic_block_sptr BeidouB1iDllPllTracking::get_right_block() -{ - return tracking_sptr_; -} diff --git a/src/algorithms/tracking/adapters/beidou_b1i_dll_pll_tracking.h b/src/algorithms/tracking/adapters/beidou_b1i_dll_pll_tracking.h index 6ccb956f3..fb94898a6 100644 --- a/src/algorithms/tracking/adapters/beidou_b1i_dll_pll_tracking.h +++ b/src/algorithms/tracking/adapters/beidou_b1i_dll_pll_tracking.h @@ -23,77 +23,39 @@ #ifndef GNSS_SDR_BEIDOU_B1I_DLL_PLL_TRACKING_H #define GNSS_SDR_BEIDOU_B1I_DLL_PLL_TRACKING_H -#include "dll_pll_veml_tracking.h" -#include "tracking_interface.h" -#include +#include "base_dll_pll_tracking.h" /** \addtogroup Tracking + * Classes for GNSS signal tracking. * \{ */ -/** \addtogroup Tracking_adapters +/** \addtogroup Tracking_adapters tracking_adapters + * Wrap GNU Radio blocks for GNSS signal tracking with a TrackingInterface * \{ */ - class ConfigurationInterface; /*! - * \brief This class implements a code DLL + carrier PLL tracking loop + * \brief This class Adapts a DLL+PLL VEML (Very Early Minus Late) tracking + * loop block to a TrackingInterface for BeiDou B1I signals */ -class BeidouB1iDllPllTracking : public TrackingInterface +class BeidouB1iDllPllTracking : public BaseDllPllTracking { public: - BeidouB1iDllPllTracking( - const ConfigurationInterface* configuration, + //! Constructor + BeidouB1iDllPllTracking(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams); - ~BeidouB1iDllPllTracking() = default; - - inline std::string role() override - { - return role_; - } - + //! Returns "BEIDOU_B1I_DLL_PLL_Tracking" inline std::string implementation() override { return "BEIDOU_B1I_DLL_PLL_Tracking"; } - inline size_t item_size() override - { - return item_size_; - } - - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - /*! - * \brief Set tracking channel unique ID - */ - void set_channel(unsigned int channel) override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - - void start_tracking() override; - - /*! - * \brief Stop running tracking - */ - void stop_tracking() override; - private: - dll_pll_veml_tracking_sptr tracking_sptr_; - std::string role_; - size_t item_size_; - unsigned int channel_; - unsigned int in_streams_; - unsigned int out_streams_; + void configure_tracking_parameters(const ConfigurationInterface* configuration) override; + void create_tracking_block() override; }; diff --git a/src/algorithms/tracking/adapters/beidou_b3i_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/beidou_b3i_dll_pll_tracking.cc index 8408e1861..4d75667d4 100644 --- a/src/algorithms/tracking/adapters/beidou_b3i_dll_pll_tracking.cc +++ b/src/algorithms/tracking/adapters/beidou_b3i_dll_pll_tracking.cc @@ -24,8 +24,6 @@ #include "Beidou_B3I.h" #include "configuration_interface.h" #include "display.h" -#include "dll_pll_conf.h" -#include "gnss_sdr_flags.h" #include #include @@ -40,110 +38,46 @@ BeidouB3iDllPllTracking::BeidouB3iDllPllTracking( const std::string& role, unsigned int in_streams, unsigned int out_streams) - : role_(role), - item_size_(sizeof(gr_complex)), - channel_(0), - in_streams_(in_streams), - out_streams_(out_streams) + : BaseDllPllTracking(configuration, role, in_streams, out_streams) { - Dll_Pll_Conf trk_params = Dll_Pll_Conf(); - trk_params.SetFromConfiguration(configuration, role_); + configure_tracking_parameters(configuration); + create_tracking_block(); +} - const auto vector_length = static_cast(std::round(static_cast(trk_params.fs_in) / (BEIDOU_B3I_CODE_RATE_CPS / BEIDOU_B3I_CODE_LENGTH_CHIPS))); - trk_params.vector_length = vector_length; - trk_params.track_pilot = configuration->property(role_ + ".track_pilot", false); - if (trk_params.extend_correlation_symbols < 1) + +void BeidouB3iDllPllTracking::configure_tracking_parameters( + const ConfigurationInterface* configuration) +{ + const auto vector_length = static_cast(std::round(static_cast(config_params().fs_in) / (BEIDOU_B3I_CODE_RATE_CPS / BEIDOU_B3I_CODE_LENGTH_CHIPS))); + config_params().vector_length = vector_length; + config_params().system = 'C'; + const std::array sig{'B', '3', '\0'}; + std::copy_n(sig.data(), 3, config_params().signal); + config_params().track_pilot = configuration->property(role() + ".track_pilot", false); + if (config_params().extend_correlation_symbols < 1) { - trk_params.extend_correlation_symbols = 1; + config_params().extend_correlation_symbols = 1; std::cout << TEXT_RED << "WARNING: BEIDOU B3I. extend_correlation_symbols must be bigger than 1. Coherent integration has been set to 1 symbol (1 ms)" << TEXT_RESET << '\n'; } - else if (trk_params.extend_correlation_symbols > 20) + else if (config_params().extend_correlation_symbols > 20) { - trk_params.extend_correlation_symbols = 20; + config_params().extend_correlation_symbols = 20; std::cout << TEXT_RED << "WARNING: BEIDOU B3I. extend_correlation_symbols must be lower than 21. Coherent integration has been set to 20 symbols (20 ms)" << TEXT_RESET << '\n'; } - trk_params.system = 'C'; - const std::array sig{'B', '3', '\0'}; - std::copy_n(sig.data(), 3, trk_params.signal); +} - // ################# Make a GNU Radio Tracking block object ################ - DLOG(INFO) << "role " << role_; - if (trk_params.item_type == "gr_complex") + +void BeidouB3iDllPllTracking::create_tracking_block() +{ + if (config_params().item_type == "gr_complex") { - tracking_sptr_ = dll_pll_veml_make_tracking(trk_params); + tracking_sptr_ = dll_pll_veml_make_tracking(config_params()); DLOG(INFO) << "tracking(" << tracking_sptr_->unique_id() << ")"; } else { - item_size_ = 0; + set_item_size(0); tracking_sptr_ = nullptr; - LOG(WARNING) << trk_params.item_type << " unknown tracking item type."; - } - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; + LOG(WARNING) << config_params().item_type << " unknown tracking item type."; } } - - -void BeidouB3iDllPllTracking::start_tracking() -{ - tracking_sptr_->start_tracking(); -} - - -void BeidouB3iDllPllTracking::stop_tracking() -{ - tracking_sptr_->stop_tracking(); -} - - -/* - * Set tracking channel unique ID - */ -void BeidouB3iDllPllTracking::set_channel(unsigned int channel) -{ - channel_ = channel; - tracking_sptr_->set_channel(channel); -} - - -void BeidouB3iDllPllTracking::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) -{ - tracking_sptr_->set_gnss_synchro(p_gnss_synchro); -} - - -void BeidouB3iDllPllTracking::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to connect, now the tracking uses gr_sync_decimator -} - - -void BeidouB3iDllPllTracking::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to disconnect, now the tracking uses gr_sync_decimator -} - - -gr::basic_block_sptr BeidouB3iDllPllTracking::get_left_block() -{ - return tracking_sptr_; -} - - -gr::basic_block_sptr BeidouB3iDllPllTracking::get_right_block() -{ - return tracking_sptr_; -} diff --git a/src/algorithms/tracking/adapters/beidou_b3i_dll_pll_tracking.h b/src/algorithms/tracking/adapters/beidou_b3i_dll_pll_tracking.h index 26ff95de4..0e087e2f5 100644 --- a/src/algorithms/tracking/adapters/beidou_b3i_dll_pll_tracking.h +++ b/src/algorithms/tracking/adapters/beidou_b3i_dll_pll_tracking.h @@ -23,77 +23,39 @@ #ifndef GNSS_SDR_BEIDOU_B3I_DLL_PLL_TRACKING_H #define GNSS_SDR_BEIDOU_B3I_DLL_PLL_TRACKING_H -#include "dll_pll_veml_tracking.h" -#include "tracking_interface.h" -#include +#include "base_dll_pll_tracking.h" /** \addtogroup Tracking + * Classes for GNSS signal tracking. * \{ */ -/** \addtogroup Tracking_adapters +/** \addtogroup Tracking_adapters tracking_adapters + * Wrap GNU Radio blocks for GNSS signal tracking with a TrackingInterface * \{ */ - class ConfigurationInterface; /*! - * \brief This class implements a code DLL + carrier PLL tracking loop + * \brief This class Adapts a DLL+PLL VEML (Very Early Minus Late) tracking + * loop block to a TrackingInterface for BeiDou B3I signals */ -class BeidouB3iDllPllTracking : public TrackingInterface +class BeidouB3iDllPllTracking : public BaseDllPllTracking { public: - BeidouB3iDllPllTracking( - const ConfigurationInterface* configuration, + //! Constructor + BeidouB3iDllPllTracking(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams); - ~BeidouB3iDllPllTracking() = default; - - inline std::string role() override - { - return role_; - } - + //! Returns "BEIDOU_B3I_DLL_PLL_Tracking" inline std::string implementation() override { return "BEIDOU_B3I_DLL_PLL_Tracking"; } - inline size_t item_size() override - { - return item_size_; - } - - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - /*! - * \brief Set tracking channel unique ID - */ - void set_channel(unsigned int channel) override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - - void start_tracking() override; - - /*! - * \brief Stop running tracking - */ - void stop_tracking() override; - private: - dll_pll_veml_tracking_sptr tracking_sptr_; - std::string role_; - size_t item_size_; - unsigned int channel_; - unsigned int in_streams_; - unsigned int out_streams_; + void configure_tracking_parameters(const ConfigurationInterface* configuration) override; + void create_tracking_block() override; }; diff --git a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking.cc b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking.cc index 16c021217..6c417b4bb 100644 --- a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking.cc +++ b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking.cc @@ -24,8 +24,6 @@ #include "Galileo_E1.h" #include "configuration_interface.h" #include "display.h" -#include "dll_pll_conf.h" -#include "gnss_sdr_flags.h" #include #include @@ -40,113 +38,50 @@ GalileoE1DllPllVemlTracking::GalileoE1DllPllVemlTracking( const std::string& role, unsigned int in_streams, unsigned int out_streams) - : role_(role), - item_size_(sizeof(gr_complex)), - channel_(0), - in_streams_(in_streams), - out_streams_(out_streams) + : BaseDllPllTracking(configuration, role, in_streams, out_streams) { - Dll_Pll_Conf trk_params = Dll_Pll_Conf(); - trk_params.SetFromConfiguration(configuration, role_); + configure_tracking_parameters(configuration); + create_tracking_block(); +} - if (trk_params.extend_correlation_symbols < 1) + +void GalileoE1DllPllVemlTracking::configure_tracking_parameters( + const ConfigurationInterface* configuration [[maybe_unused]]) +{ + const auto vector_length = static_cast(std::round(config_params().fs_in / (GALILEO_E1_CODE_CHIP_RATE_CPS / GALILEO_E1_B_CODE_LENGTH_CHIPS))); + config_params().vector_length = vector_length; + config_params().system = 'E'; + const std::array sig{'1', 'B', '\0'}; + std::copy_n(sig.data(), 3, config_params().signal); + + if (config_params().extend_correlation_symbols < 1) { - trk_params.extend_correlation_symbols = 1; + config_params().extend_correlation_symbols = 1; std::cout << TEXT_RED << "WARNING: Galileo E1. extend_correlation_symbols must be bigger than 0. Coherent integration has been set to 1 symbol (4 ms)" << TEXT_RESET << '\n'; } - else if (!trk_params.track_pilot and trk_params.extend_correlation_symbols > 1) + else if (!config_params().track_pilot && config_params().extend_correlation_symbols > 1) { - trk_params.extend_correlation_symbols = 1; + config_params().extend_correlation_symbols = 1; std::cout << TEXT_RED << "WARNING: Galileo E1. Extended coherent integration is not allowed when tracking the data component. Coherent integration has been set to 4 ms (1 symbol)" << TEXT_RESET << '\n'; } - if ((trk_params.extend_correlation_symbols > 1) and (trk_params.pll_bw_narrow_hz > trk_params.pll_bw_hz or trk_params.dll_bw_narrow_hz > trk_params.dll_bw_hz)) + if ((config_params().extend_correlation_symbols > 1) and (config_params().pll_bw_narrow_hz > config_params().pll_bw_hz or config_params().dll_bw_narrow_hz > config_params().dll_bw_hz)) { std::cout << TEXT_RED << "WARNING: Galileo E1. PLL or DLL narrow tracking bandwidth is higher than wide tracking one" << TEXT_RESET << '\n'; } - const auto vector_length = static_cast(std::round(trk_params.fs_in / (GALILEO_E1_CODE_CHIP_RATE_CPS / GALILEO_E1_B_CODE_LENGTH_CHIPS))); - trk_params.vector_length = vector_length; - trk_params.system = 'E'; - const std::array sig{'1', 'B', '\0'}; - std::copy_n(sig.data(), 3, trk_params.signal); +} - // ################# Make a GNU Radio Tracking block object ################ - DLOG(INFO) << "role " << role_; - if (trk_params.item_type == "gr_complex") + +void GalileoE1DllPllVemlTracking::create_tracking_block() +{ + if (config_params().item_type == "gr_complex") { - tracking_sptr_ = dll_pll_veml_make_tracking(trk_params); + tracking_sptr_ = dll_pll_veml_make_tracking(config_params()); DLOG(INFO) << "tracking(" << tracking_sptr_->unique_id() << ")"; } else { - item_size_ = 0; + set_item_size(0); tracking_sptr_ = nullptr; - LOG(WARNING) << trk_params.item_type << " unknown tracking item type."; - } - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; + LOG(WARNING) << config_params().item_type << " unknown tracking item type."; } } - - -void GalileoE1DllPllVemlTracking::stop_tracking() -{ - tracking_sptr_->stop_tracking(); -} - - -void GalileoE1DllPllVemlTracking::start_tracking() -{ - tracking_sptr_->start_tracking(); -} - - -/* - * Set tracking channel unique ID - */ -void GalileoE1DllPllVemlTracking::set_channel(unsigned int channel) -{ - channel_ = channel; - tracking_sptr_->set_channel(channel); -} - - -void GalileoE1DllPllVemlTracking::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) -{ - tracking_sptr_->set_gnss_synchro(p_gnss_synchro); -} - - -void GalileoE1DllPllVemlTracking::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to connect, now the tracking uses gr_sync_decimator -} - - -void GalileoE1DllPllVemlTracking::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to disconnect, now the tracking uses gr_sync_decimator -} - - -gr::basic_block_sptr GalileoE1DllPllVemlTracking::get_left_block() -{ - return tracking_sptr_; -} - - -gr::basic_block_sptr GalileoE1DllPllVemlTracking::get_right_block() -{ - return tracking_sptr_; -} diff --git a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking.h b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking.h index 4f117b8fb..54cea7742 100644 --- a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking.h +++ b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking.h @@ -23,80 +23,39 @@ #ifndef GNSS_SDR_GALILEO_E1_DLL_PLL_VEML_TRACKING_H #define GNSS_SDR_GALILEO_E1_DLL_PLL_VEML_TRACKING_H -#include "dll_pll_veml_tracking.h" -#include "tracking_interface.h" -#include +#include "base_dll_pll_tracking.h" /** \addtogroup Tracking + * Classes for GNSS signal tracking. * \{ */ -/** \addtogroup Tracking_adapters +/** \addtogroup Tracking_adapters tracking_adapters + * Wrap GNU Radio blocks for GNSS signal tracking with a TrackingInterface * \{ */ - class ConfigurationInterface; /*! * \brief This class Adapts a DLL+PLL VEML (Very Early Minus Late) tracking * loop block to a TrackingInterface for Galileo E1 signals */ -class GalileoE1DllPllVemlTracking : public TrackingInterface +class GalileoE1DllPllVemlTracking : public BaseDllPllTracking { public: - GalileoE1DllPllVemlTracking( - const ConfigurationInterface* configuration, + //! Constructor + GalileoE1DllPllVemlTracking(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams); - ~GalileoE1DllPllVemlTracking() = default; - - inline std::string role() override - { - return role_; - } - //! Returns "Galileo_E1_DLL_PLL_VEML_Tracking" inline std::string implementation() override { return "Galileo_E1_DLL_PLL_VEML_Tracking"; } - inline size_t item_size() override - { - return item_size_; - } - - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - /*! - * \brief Set tracking channel unique ID - */ - void set_channel(unsigned int channel) override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and - * tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - - void start_tracking() override; - - /*! - * \brief Stop running tracking - */ - void stop_tracking() override; - private: - dll_pll_veml_tracking_sptr tracking_sptr_; - std::string role_; - size_t item_size_; - unsigned int channel_; - unsigned int in_streams_; - unsigned int out_streams_; + void configure_tracking_parameters(const ConfigurationInterface* configuration) override; + void create_tracking_block() override; }; diff --git a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc index 52c41c3d2..33d6838b7 100644 --- a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc @@ -20,14 +20,12 @@ * ----------------------------------------------------------------------------- */ + #include "galileo_e1_dll_pll_veml_tracking_fpga.h" #include "Galileo_E1.h" #include "configuration_interface.h" #include "display.h" -#include "dll_pll_conf_fpga.h" #include "galileo_e1_signal_replica.h" -#include "gnss_sdr_flags.h" -#include "uio_fpga.h" #include #include #include @@ -43,146 +41,116 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga( const std::string& role, unsigned int in_streams, unsigned int out_streams) - : role_(role), + : BaseDllPllTrackingFpga(configuration, role, in_streams, out_streams), data_codes_ptr_(nullptr), - channel_(0), - in_streams_(in_streams), - out_streams_(out_streams) + track_pilot_(config_params_fpga().track_pilot) { - Dll_Pll_Conf_Fpga trk_params_fpga = Dll_Pll_Conf_Fpga(); - trk_params_fpga.SetFromConfiguration(configuration, role_); + // ------------------------------------------------------------------------- + // Adjust configuration parameters + // ------------------------------------------------------------------------- + if (config_params_fpga().extend_correlation_symbols < 1) + { + config_params_fpga().extend_correlation_symbols = 1; + std::cout << TEXT_RED + << "WARNING: Galileo E1. extend_correlation_symbols must be >= 1. " + << "Set to 1 symbol (4 ms)." << TEXT_RESET << '\n'; + } + else if (!track_pilot_ && config_params_fpga().extend_correlation_symbols > 1) + { + config_params_fpga().extend_correlation_symbols = 1; + std::cout << TEXT_RED + << "WARNING: Galileo E1. Extended coherent integration is only supported " + << "when tracking the pilot component. Set to 4 ms (1 symbol)." + << TEXT_RESET << '\n'; + } - if (trk_params_fpga.extend_correlation_symbols < 1) + if ((config_params_fpga().extend_correlation_symbols > 1) && + (config_params_fpga().pll_bw_narrow_hz > config_params_fpga().pll_bw_hz || + config_params_fpga().dll_bw_narrow_hz > config_params_fpga().dll_bw_hz)) { - trk_params_fpga.extend_correlation_symbols = 1; - std::cout << TEXT_RED << "WARNING: Galileo E1. extend_correlation_symbols must be bigger than 0. Coherent integration has been set to 1 symbol (4 ms)" << TEXT_RESET << '\n'; + std::cout << TEXT_RED + << "WARNING: Galileo E1. Narrow tracking bandwidths are larger than wide ones." + << TEXT_RESET << '\n'; } - else if (!trk_params_fpga.track_pilot and trk_params_fpga.extend_correlation_symbols > 1) - { - trk_params_fpga.extend_correlation_symbols = 1; - std::cout << TEXT_RED << "WARNING: Galileo E1. Extended coherent integration is not allowed when tracking the data component. Coherent integration has been set to 4 ms (1 symbol)" << TEXT_RESET << '\n'; - } - if ((trk_params_fpga.extend_correlation_symbols > 1) and (trk_params_fpga.pll_bw_narrow_hz > trk_params_fpga.pll_bw_hz or trk_params_fpga.dll_bw_narrow_hz > trk_params_fpga.dll_bw_hz)) - { - std::cout << TEXT_RED << "WARNING: Galileo E1. PLL or DLL narrow tracking bandwidth is higher than wide tracking one" << TEXT_RESET << '\n'; - } - track_pilot_ = trk_params_fpga.track_pilot; - const auto vector_length = static_cast(std::round(trk_params_fpga.fs_in / (GALILEO_E1_CODE_CHIP_RATE_CPS / GALILEO_E1_B_CODE_LENGTH_CHIPS))); - trk_params_fpga.vector_length = vector_length; - trk_params_fpga.system = 'E'; + + config_params_fpga().system = 'E'; const std::array sig{'1', 'B', '\0'}; - std::copy_n(sig.data(), 3, trk_params_fpga.signal); + std::copy_n(sig.data(), 3, config_params_fpga().signal); - // UIO device file - device_name_ = configuration->property(role_ + ".devicename", default_device_name_Galileo_E1); + const auto vector_length = static_cast( + std::round(config_params_fpga().fs_in / + (GALILEO_E1_CODE_CHIP_RATE_CPS / GALILEO_E1_B_CODE_LENGTH_CHIPS))); + config_params_fpga().vector_length = vector_length; - // compute the number of tracking channels that have already been instantiated. The order in which - // GNSS-SDR instantiates the tracking channels i L1, L2, L5, E1, E5a + device_name_ = configuration->property(role + ".devicename", default_device_name_Galileo_E1); - uint32_t num_prev_assigned_ch_1C = 0; - std::string device_io_name; + // ------------------------------------------------------------------------- + // Precompute all local codes (pilot and/or data) + // ------------------------------------------------------------------------- + const uint32_t code_samples_per_chip = 2; + const uint32_t num_codes = GALILEO_E1_NUMBER_OF_CODES; + const uint32_t code_length = GALILEO_E1_B_CODE_LENGTH_CHIPS; - if (configuration->property("Tracking_1C.devicename", default_device_name_GPS_L1) == default_device_name_GPS_L1) - { - for (uint32_t k = 0; k < configuration->property("Channels_1C.count", 0U); k++) - { - if (find_uio_dev_file_name(device_io_name, default_device_name_GPS_L1, k) == 0) - { - num_prev_assigned_ch_1C = num_prev_assigned_ch_1C + 1; - } - } - } - else - { - if (configuration->property("Tracking_1C.devicename", std::string("")) != device_name_) - { - num_prev_assigned_ch_1C = configuration->property("Channels_1C.count", 0); - } - } + prn_codes_ptr_ = static_cast( + volk_gnsssdr_malloc(code_length * code_samples_per_chip * num_codes * sizeof(int32_t), + volk_gnsssdr_get_alignment())); - uint32_t num_prev_assigned_ch_2S = configuration->property("Channels_2S.count", 0); - uint32_t num_prev_assigned_ch_L5 = configuration->property("Channels_L5.count", 0); - num_prev_assigned_ch_ = num_prev_assigned_ch_1C + num_prev_assigned_ch_2S + num_prev_assigned_ch_L5; - - // ################# PRE-COMPUTE ALL THE CODES ################# - uint32_t code_samples_per_chip = 2; - prn_codes_ptr_ = static_cast(volk_gnsssdr_malloc(static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * code_samples_per_chip * GALILEO_E1_NUMBER_OF_CODES * sizeof(int32_t), volk_gnsssdr_get_alignment())); - volk_gnsssdr::vector ca_codes_f(static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * code_samples_per_chip); + volk_gnsssdr::vector ca_codes_f(code_length * code_samples_per_chip); volk_gnsssdr::vector data_codes_f; if (track_pilot_) { - data_codes_ptr_ = static_cast(volk_gnsssdr_malloc((static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS)) * code_samples_per_chip * GALILEO_E1_NUMBER_OF_CODES * sizeof(int32_t), volk_gnsssdr_get_alignment())); - data_codes_f.resize(static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * code_samples_per_chip, 0.0); + data_codes_ptr_ = static_cast( + volk_gnsssdr_malloc(code_length * code_samples_per_chip * num_codes * sizeof(int32_t), + volk_gnsssdr_get_alignment())); + data_codes_f.resize(code_length * code_samples_per_chip); } - for (uint32_t PRN = 1; PRN <= GALILEO_E1_NUMBER_OF_CODES; PRN++) + for (uint32_t prn = 1; prn <= num_codes; prn++) { - std::array data_signal = {'1', 'B', '\0'}; if (track_pilot_) { - std::array pilot_signal = {'1', 'C', '\0'}; - galileo_e1_code_gen_sinboc11_float(ca_codes_f, pilot_signal, PRN); - galileo_e1_code_gen_sinboc11_float(data_codes_f, data_signal, PRN); + galileo_e1_code_gen_sinboc11_float(ca_codes_f, {'1', 'C', '\0'}, prn); + galileo_e1_code_gen_sinboc11_float(data_codes_f, {'1', 'B', '\0'}, prn); - // The code is generated as a series of 1s and -1s. In order to store the values using only one bit, a -1 is stored as a 0 in the FPGA - for (uint32_t s = 0; s < 2 * GALILEO_E1_B_CODE_LENGTH_CHIPS; s++) + for (uint32_t s = 0; s < 2 * code_length; s++) { - auto tmp_value = static_cast(ca_codes_f[s]); - if (tmp_value < 0) - { - tmp_value = 0; - } - tmp_value = tmp_value | LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY; - prn_codes_ptr_[static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s] = tmp_value; - tmp_value = static_cast(data_codes_f[s]); - if (tmp_value < 0) - { - tmp_value = 0; - } - tmp_value = tmp_value | LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY | LOCAL_CODE_FPGA_CORRELATOR_SELECT_COUNT; - data_codes_ptr_[static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s] = tmp_value; + int32_t pilot = (ca_codes_f[s] < 0) ? 0 : 1; + pilot |= LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY; + prn_codes_ptr_[code_length * 2 * (prn - 1) + s] = pilot; + + int32_t data = (data_codes_f[s] < 0) ? 0 : 1; + data |= LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY | + LOCAL_CODE_FPGA_CORRELATOR_SELECT_COUNT; + data_codes_ptr_[code_length * 2 * (prn - 1) + s] = data; } } else { - galileo_e1_code_gen_sinboc11_float(ca_codes_f, data_signal, PRN); + galileo_e1_code_gen_sinboc11_float(ca_codes_f, {'1', 'B', '\0'}, prn); - // The code is generated as a series of 1s and -1s. In order to store the values using only one bit, a -1 is stored as a 0 in the FPGA - for (uint32_t s = 0; s < 2 * GALILEO_E1_B_CODE_LENGTH_CHIPS; s++) + for (uint32_t s = 0; s < 2 * code_length; s++) { - auto tmp_value = static_cast(ca_codes_f[s]); - if (tmp_value < 0) - { - tmp_value = 0; - } - tmp_value = tmp_value | LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY; - prn_codes_ptr_[static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s] = tmp_value; + int32_t tmp = (ca_codes_f[s] < 0) ? 0 : 1; + tmp |= LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY; + prn_codes_ptr_[code_length * 2 * (prn - 1) + s] = tmp; } } } - trk_params_fpga.ca_codes = prn_codes_ptr_; - trk_params_fpga.data_codes = data_codes_ptr_; - trk_params_fpga.code_length_chips = GALILEO_E1_B_CODE_LENGTH_CHIPS; - trk_params_fpga.code_samples_per_chip = code_samples_per_chip; // 2 sample per chip - trk_params_fpga.extended_correlation_in_fpga = false; - trk_params_fpga.extend_fpga_integration_periods = 1; // (number of FPGA integrations that are combined in the SW) - trk_params_fpga.fpga_integration_period = 1; // (number of symbols that are effectively integrated in the FPGA) + config_params_fpga().ca_codes = prn_codes_ptr_; + config_params_fpga().data_codes = data_codes_ptr_; + config_params_fpga().code_length_chips = code_length; + config_params_fpga().code_samples_per_chip = code_samples_per_chip; + config_params_fpga().extended_correlation_in_fpga = false; + config_params_fpga().extend_fpga_integration_periods = 1; + config_params_fpga().fpga_integration_period = 1; - // ################# MAKE TRACKING GNU Radio object ################### - DLOG(INFO) << "role " << role_; - tracking_fpga_sc_sptr_ = dll_pll_veml_make_tracking_fpga(trk_params_fpga); + // ------------------------------------------------------------------------- + // Create GNU Radio FPGA tracking block + // ------------------------------------------------------------------------- + tracking_fpga_sc_sptr_ = dll_pll_veml_make_tracking_fpga(config_params_fpga()); DLOG(INFO) << "tracking(" << tracking_fpga_sc_sptr_->unique_id() << ")"; - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; - } } @@ -194,70 +162,3 @@ GalileoE1DllPllVemlTrackingFpga::~GalileoE1DllPllVemlTrackingFpga() volk_gnsssdr_free(data_codes_ptr_); } } - - -void GalileoE1DllPllVemlTrackingFpga::stop_tracking() -{ - tracking_fpga_sc_sptr_->stop_tracking(); -} - - -void GalileoE1DllPllVemlTrackingFpga::start_tracking() -{ - tracking_fpga_sc_sptr_->start_tracking(); -} - - -/* - * Set tracking channel unique ID - */ -void GalileoE1DllPllVemlTrackingFpga::set_channel(unsigned int channel) -{ - channel_ = channel; - - // UIO device file - std::string device_io_name; - // find the uio device file corresponding to the tracking multicorrelator - if (find_uio_dev_file_name(device_io_name, device_name_, channel_ - num_prev_assigned_ch_) < 0) - { - std::cout << "Cannot find the FPGA uio device file corresponding to device name " << device_name_ << std::endl; - throw std::exception(); - } - tracking_fpga_sc_sptr_->set_channel(channel_, device_io_name); -} - - -void GalileoE1DllPllVemlTrackingFpga::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) -{ - tracking_fpga_sc_sptr_->set_gnss_synchro(p_gnss_synchro); -} - - -void GalileoE1DllPllVemlTrackingFpga::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to connect, now the tracking uses gr_sync_decimator -} - - -void GalileoE1DllPllVemlTrackingFpga::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to disconnect, now the tracking uses gr_sync_decimator -} - - -gr::basic_block_sptr GalileoE1DllPllVemlTrackingFpga::get_left_block() -{ - return tracking_fpga_sc_sptr_; -} - - -gr::basic_block_sptr GalileoE1DllPllVemlTrackingFpga::get_right_block() -{ - return tracking_fpga_sc_sptr_; -} diff --git a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.h b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.h index 8de75e087..83d095a3d 100644 --- a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.h @@ -23,127 +23,37 @@ #ifndef GNSS_SDR_GALILEO_E1_DLL_PLL_VEML_TRACKING_FPGA_H #define GNSS_SDR_GALILEO_E1_DLL_PLL_VEML_TRACKING_FPGA_H -#include "dll_pll_veml_tracking_fpga.h" -#include "tracking_interface.h" -#include +#include "base_dll_pll_tracking_fpga.h" /** \addtogroup Tracking * \{ */ /** \addtogroup Tracking_adapters * \{ */ - -class ConfigurationInterface; - /*! - * \brief This class Adapts a DLL+PLL VEML (Very Early Minus Late) tracking - * loop block to a TrackingInterface for Galileo E1 signals + * \brief Adapter for a Galileo E1 DLL+PLL VEML tracking loop block in FPGA */ -class GalileoE1DllPllVemlTrackingFpga : public TrackingInterface +class GalileoE1DllPllVemlTrackingFpga : public BaseDllPllTrackingFpga { public: - /*! - * \brief Constructor - */ - GalileoE1DllPllVemlTrackingFpga( - const ConfigurationInterface* configuration, + GalileoE1DllPllVemlTrackingFpga(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams); - /*! - * \brief Destructor - */ - virtual ~GalileoE1DllPllVemlTrackingFpga(); + ~GalileoE1DllPllVemlTrackingFpga() override; - /*! - * \brief Role - */ - inline std::string role() override - { - return role_; - } - - /*! - * \brief Returns "Galileo_E1_DLL_PLL_VEML_Tracking_FPGA" - */ - inline std::string implementation() override + std::string implementation() override { return "Galileo_E1_DLL_PLL_VEML_Tracking_FPGA"; } - /*! - * \brief Returns size of lv_16sc_t - */ - size_t item_size() override - { - return sizeof(int16_t); - } - - /*! - * \brief Connect - */ - void connect(gr::top_block_sptr top_block) override; - - /*! - * \brief Disconnect - */ - void disconnect(gr::top_block_sptr top_block) override; - - /*! - * \brief Get left block - */ - gr::basic_block_sptr get_left_block() override; - - /*! - * \brief Get right block - */ - gr::basic_block_sptr get_right_block() override; - - /*! - * \brief Set tracking channel unique ID - */ - void set_channel(unsigned int channel) override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and - * tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - - /*! - * \brief Start the tracking process in the FPGA - */ - void start_tracking() override; - - /*! - * \brief Stop the tracking process in the FPGA - */ - void stop_tracking() override; - private: - const std::string default_device_name_Galileo_E1 = "multicorrelator_resampler_5_1_AXI"; // UIO device name - const std::string default_device_name_GPS_L1 = "multicorrelator_resampler_S00_AXI"; // UIO device name - - // the following flags are FPGA-specific and they are using arrange the values of the local code in the way the FPGA - // expects. This arrangement is done in the initialisation to avoid consuming unnecessary clock cycles during tracking. - static const int32_t LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY = 0x0C000000; // flag that enables WE (Write Enable) of the local code FPGA - static const int32_t LOCAL_CODE_FPGA_CORRELATOR_SELECT_COUNT = 0x20000000; // flag that selects the writing of the pilot code in the FPGA (as opposed to the data code) - - dll_pll_veml_tracking_fpga_sptr tracking_fpga_sc_sptr_; - std::string role_; - std::string device_name_; int32_t* prn_codes_ptr_; int32_t* data_codes_ptr_; - uint32_t num_prev_assigned_ch_; - uint32_t channel_; - uint32_t in_streams_; - uint32_t out_streams_; bool track_pilot_; }; - -/** \} */ -/** \} */ +// /** \} */ +// /** \} */ #endif // GNSS_SDR_GALILEO_E1_DLL_PLL_VEML_TRACKING_FPGA_H diff --git a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking.cc index 876ff34c7..8dd56cafb 100644 --- a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking.cc +++ b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking.cc @@ -24,8 +24,6 @@ #include "Galileo_E5a.h" #include "configuration_interface.h" #include "display.h" -#include "dll_pll_conf.h" -#include "gnss_sdr_flags.h" #include #include @@ -35,118 +33,55 @@ #include #endif + GalileoE5aDllPllTracking::GalileoE5aDllPllTracking( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) - : role_(role), - item_size_(sizeof(gr_complex)), - channel_(0), - in_streams_(in_streams), - out_streams_(out_streams) + : BaseDllPllTracking(configuration, role, in_streams, out_streams) { - Dll_Pll_Conf trk_params = Dll_Pll_Conf(); - trk_params.SetFromConfiguration(configuration, role_); + configure_tracking_parameters(configuration); + create_tracking_block(); +} - const auto vector_length = static_cast(std::round(trk_params.fs_in / (GALILEO_E5A_CODE_CHIP_RATE_CPS / GALILEO_E5A_CODE_LENGTH_CHIPS))); - trk_params.vector_length = vector_length; - if (trk_params.extend_correlation_symbols < 1) + +void GalileoE5aDllPllTracking::configure_tracking_parameters( + const ConfigurationInterface* configuration [[maybe_unused]]) +{ + const auto vector_length = static_cast(std::round(config_params().fs_in / (GALILEO_E5A_CODE_CHIP_RATE_CPS / GALILEO_E5A_CODE_LENGTH_CHIPS))); + config_params().vector_length = vector_length; + config_params().system = 'E'; + const std::array sig{'5', 'X', '\0'}; + std::copy_n(sig.data(), 3, config_params().signal); + if (config_params().extend_correlation_symbols < 1) { - trk_params.extend_correlation_symbols = 1; + config_params().extend_correlation_symbols = 1; std::cout << TEXT_RED << "WARNING: Galileo E5a. extend_correlation_symbols must be bigger than 0. Coherent integration has been set to 1 symbol (1 ms)" << TEXT_RESET << '\n'; } - else if (!trk_params.track_pilot and trk_params.extend_correlation_symbols > GALILEO_E5A_I_SECONDARY_CODE_LENGTH) + else if (!config_params().track_pilot and config_params().extend_correlation_symbols > GALILEO_E5A_I_SECONDARY_CODE_LENGTH) { - trk_params.extend_correlation_symbols = GALILEO_E5A_I_SECONDARY_CODE_LENGTH; + config_params().extend_correlation_symbols = GALILEO_E5A_I_SECONDARY_CODE_LENGTH; std::cout << TEXT_RED << "WARNING: Galileo E5a. extend_correlation_symbols must be lower than 21 when tracking the data component. Coherent integration has been set to 20 symbols (20 ms)" << TEXT_RESET << '\n'; } - if ((trk_params.extend_correlation_symbols > 1) and (trk_params.pll_bw_narrow_hz > trk_params.pll_bw_hz or trk_params.dll_bw_narrow_hz > trk_params.dll_bw_hz)) + if ((config_params().extend_correlation_symbols > 1) and (config_params().pll_bw_narrow_hz > config_params().pll_bw_hz or config_params().dll_bw_narrow_hz > config_params().dll_bw_hz)) { std::cout << TEXT_RED << "WARNING: Galileo E5a. PLL or DLL narrow tracking bandwidth is higher than wide tracking one" << TEXT_RESET << '\n'; } - trk_params.system = 'E'; - const std::array sig{'5', 'X', '\0'}; - std::copy_n(sig.data(), 3, trk_params.signal); +} - // ################# Make a GNU Radio Tracking block object ################ - DLOG(INFO) << "role " << role; - if (trk_params.item_type == "gr_complex") + +void GalileoE5aDllPllTracking::create_tracking_block() +{ + if (config_params().item_type == "gr_complex") { - tracking_sptr_ = dll_pll_veml_make_tracking(trk_params); + tracking_sptr_ = dll_pll_veml_make_tracking(config_params()); DLOG(INFO) << "tracking(" << tracking_sptr_->unique_id() << ")"; } else { - item_size_ = 0; + set_item_size(0); tracking_sptr_ = nullptr; - LOG(WARNING) << trk_params.item_type << " unknown tracking item type."; - } - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; + LOG(WARNING) << config_params().item_type << " unknown tracking item type."; } } - - -void GalileoE5aDllPllTracking::stop_tracking() -{ - tracking_sptr_->stop_tracking(); -} - - -void GalileoE5aDllPllTracking::start_tracking() -{ - tracking_sptr_->start_tracking(); -} - - -/* - * Set tracking channel unique ID - */ -void GalileoE5aDllPllTracking::set_channel(unsigned int channel) -{ - channel_ = channel; - tracking_sptr_->set_channel(channel); -} - - -void GalileoE5aDllPllTracking::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) -{ - tracking_sptr_->set_gnss_synchro(p_gnss_synchro); -} - - -void GalileoE5aDllPllTracking::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to connect, now the tracking uses gr_sync_decimator -} - - -void GalileoE5aDllPllTracking::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to disconnect, now the tracking uses gr_sync_decimator -} - - -gr::basic_block_sptr GalileoE5aDllPllTracking::get_left_block() -{ - return tracking_sptr_; -} - - -gr::basic_block_sptr GalileoE5aDllPllTracking::get_right_block() -{ - return tracking_sptr_; -} diff --git a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking.h b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking.h index c739b5c47..6443a72e1 100644 --- a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking.h +++ b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking.h @@ -23,78 +23,39 @@ #ifndef GNSS_SDR_GALILEO_E5A_DLL_PLL_TRACKING_H #define GNSS_SDR_GALILEO_E5A_DLL_PLL_TRACKING_H -#include "dll_pll_veml_tracking.h" -#include "tracking_interface.h" -#include +#include "base_dll_pll_tracking.h" /** \addtogroup Tracking + * Classes for GNSS signal tracking. * \{ */ -/** \addtogroup Tracking_adapters +/** \addtogroup Tracking_adapters tracking_adapters + * Wrap GNU Radio blocks for GNSS signal tracking with a TrackingInterface * \{ */ - class ConfigurationInterface; /*! - * \brief This class implements a code DLL + carrier PLL tracking loop + * \brief This class Adapts a DLL+PLL VEML (Very Early Minus Late) tracking + * loop block to a TrackingInterface for Galileo E5a signals */ -class GalileoE5aDllPllTracking : public TrackingInterface +class GalileoE5aDllPllTracking : public BaseDllPllTracking { public: - GalileoE5aDllPllTracking( - const ConfigurationInterface* configuration, + //! Constructor + GalileoE5aDllPllTracking(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams); - ~GalileoE5aDllPllTracking() = default; - - inline std::string role() override - { - return role_; - } - //! Returns "Galileo_E5a_DLL_PLL_Tracking" inline std::string implementation() override { return "Galileo_E5a_DLL_PLL_Tracking"; } - inline size_t item_size() override - { - return item_size_; - } - - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - /*! - * \brief Set tracking channel unique ID - */ - void set_channel(unsigned int channel) override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - - void start_tracking() override; - - /*! - * \brief Stop running tracking - */ - void stop_tracking() override; - private: - dll_pll_veml_tracking_sptr tracking_sptr_; - std::string role_; - size_t item_size_; - unsigned int channel_; - unsigned int in_streams_; - unsigned int out_streams_; + void configure_tracking_parameters(const ConfigurationInterface* configuration) override; + void create_tracking_block() override; }; diff --git a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc index ddf843a3c..518c77eb6 100644 --- a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc @@ -19,13 +19,11 @@ #include "Galileo_E5a.h" #include "configuration_interface.h" #include "display.h" -#include "dll_pll_conf_fpga.h" #include "galileo_e5_signal_replica.h" -#include "gnss_sdr_flags.h" -#include "uio_fpga.h" #include #include #include +#include // for std::round #if USE_GLOG_AND_GFLAGS #include @@ -34,160 +32,154 @@ #endif GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga( - const ConfigurationInterface *configuration, - const std::string &role, + const ConfigurationInterface* configuration, + const std::string& role, unsigned int in_streams, unsigned int out_streams) - : role_(role), + : BaseDllPllTrackingFpga(configuration, role, in_streams, out_streams), data_codes_ptr_(nullptr), - channel_(0), - in_streams_(in_streams), - out_streams_(out_streams) + track_pilot_(config_params_fpga().track_pilot) { - Dll_Pll_Conf_Fpga trk_params_fpga = Dll_Pll_Conf_Fpga(); - trk_params_fpga.SetFromConfiguration(configuration, role_); + // ------------------------------------------------------------------------- + // Adjust configuration parameters + // ------------------------------------------------------------------------- + const auto vector_length = static_cast( + std::round(config_params_fpga().fs_in / + (GALILEO_E5A_CODE_CHIP_RATE_CPS / GALILEO_E5A_CODE_LENGTH_CHIPS))); + config_params_fpga().vector_length = vector_length; - const auto vector_length = static_cast(std::round(trk_params_fpga.fs_in / (GALILEO_E5A_CODE_CHIP_RATE_CPS / GALILEO_E5A_CODE_LENGTH_CHIPS))); - trk_params_fpga.vector_length = vector_length; - track_pilot_ = trk_params_fpga.track_pilot; - if (trk_params_fpga.extend_correlation_symbols < 1) + if (config_params_fpga().extend_correlation_symbols < 1) { - trk_params_fpga.extend_correlation_symbols = 1; - std::cout << TEXT_RED << "WARNING: Galileo E5a. extend_correlation_symbols must be bigger than 0. Coherent integration has been set to 1 symbol (1 ms)" << TEXT_RESET << '\n'; + config_params_fpga().extend_correlation_symbols = 1; + std::cout << TEXT_RED + << "WARNING: Galileo E5a. extend_correlation_symbols must be >= 1. " + << "Coherent integration set to 1 symbol (1 ms)." + << TEXT_RESET << '\n'; } - else if (!trk_params_fpga.track_pilot and trk_params_fpga.extend_correlation_symbols > GALILEO_E5A_I_SECONDARY_CODE_LENGTH) + else if (!config_params_fpga().track_pilot && + config_params_fpga().extend_correlation_symbols > GALILEO_E5A_I_SECONDARY_CODE_LENGTH) { - trk_params_fpga.extend_correlation_symbols = GALILEO_E5A_I_SECONDARY_CODE_LENGTH; - std::cout << TEXT_RED << "WARNING: Galileo E5a. extend_correlation_symbols must be lower than 21 when tracking the data component. Coherent integration has been set to 20 symbols (20 ms)" << TEXT_RESET << '\n'; + config_params_fpga().extend_correlation_symbols = GALILEO_E5A_I_SECONDARY_CODE_LENGTH; + std::cout << TEXT_RED + << "WARNING: Galileo E5a. extend_correlation_symbols cannot exceed 20 " + << "when tracking the data component. Set to 20 ms (20 symbols)." + << TEXT_RESET << '\n'; } - if ((trk_params_fpga.extend_correlation_symbols > 1) and (trk_params_fpga.pll_bw_narrow_hz > trk_params_fpga.pll_bw_hz or trk_params_fpga.dll_bw_narrow_hz > trk_params_fpga.dll_bw_hz)) + + if ((config_params_fpga().extend_correlation_symbols > 1) && + (config_params_fpga().pll_bw_narrow_hz > config_params_fpga().pll_bw_hz || + config_params_fpga().dll_bw_narrow_hz > config_params_fpga().dll_bw_hz)) { - std::cout << TEXT_RED << "WARNING: Galileo E5a. PLL or DLL narrow tracking bandwidth is higher than wide tracking one" << TEXT_RESET << '\n'; + std::cout << TEXT_RED + << "WARNING: Galileo E5a. PLL/DLL narrow bandwidth is greater than wide one." + << TEXT_RESET << '\n'; } - trk_params_fpga.system = 'E'; + + config_params_fpga().system = 'E'; const std::array sig{'5', 'X', '\0'}; - std::copy_n(sig.data(), 3, trk_params_fpga.signal); + std::copy_n(sig.data(), 3, config_params_fpga().signal); - // UIO device file - device_name_ = configuration->property(role_ + ".devicename", default_device_name_Galileo_E5a); + // ------------------------------------------------------------------------- + // Configure FPGA device name + // ------------------------------------------------------------------------- + device_name_ = configuration->property(role + ".devicename", default_device_name_Galileo_E5a); - // compute the number of tracking channels that have already been instantiated. The order in which - // GNSS-SDR instantiates the tracking channels i L1, L2, L5, E1, E5a - // However E5a can use the same tracking HW accelerators as L5 (but not simultaneously). - // Therefore for the proper assignment of the FPGA tracking device file numbers to the E5a tracking channels, - // the number of channels that have already been assigned to L5 must not be subtracted to this channel number, - // so they are not counted here. - - uint32_t num_prev_assigned_ch_1C = configuration->property("Channels_1C.count", 0); + // Compute number of previously assigned channels (L1 + L2 + L5) + const uint32_t num_prev_assigned_ch_1C = configuration->property("Channels_1C.count", 0); uint32_t num_prev_assigned_ch_2S = 0; if (configuration->property("Tracking_2S.devicename", std::string("")) != device_name_) { num_prev_assigned_ch_2S = configuration->property("Channels_2S.count", 0); } - uint32_t num_prev_assigned_ch_1B = configuration->property("Channels_1B.count", 0); - num_prev_assigned_ch_ = num_prev_assigned_ch_1C + num_prev_assigned_ch_2S + num_prev_assigned_ch_1B; + const uint32_t num_prev_assigned_ch_1B = configuration->property("Channels_1B.count", 0); + set_num_prev_assigned_ch(num_prev_assigned_ch_1C + num_prev_assigned_ch_2S + num_prev_assigned_ch_1B); - // ################# PRE-COMPUTE ALL THE CODES ################# - uint32_t code_samples_per_chip = 1; - auto code_length_chips = static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS); + // ------------------------------------------------------------------------- + // Precompute local PRN codes + // ------------------------------------------------------------------------- + const uint32_t code_samples_per_chip = 1; + const auto code_length_chips = static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS); - volk_gnsssdr::vector aux_code(code_length_chips * code_samples_per_chip, gr_complex(0.0, 0.0)); + volk_gnsssdr::vector aux_code(code_length_chips * code_samples_per_chip, gr_complex(0.0F, 0.0F)); - prn_codes_ptr_ = static_cast(volk_gnsssdr_malloc(static_cast(code_length_chips) * code_samples_per_chip * GALILEO_E5A_NUMBER_OF_CODES * sizeof(int32_t), volk_gnsssdr_get_alignment())); + prn_codes_ptr_ = static_cast( + volk_gnsssdr_malloc(code_length_chips * code_samples_per_chip * GALILEO_E5A_NUMBER_OF_CODES * sizeof(int32_t), + volk_gnsssdr_get_alignment())); - if (trk_params_fpga.track_pilot) + if (track_pilot_) { - data_codes_ptr_ = static_cast(volk_gnsssdr_malloc((static_cast(code_length_chips)) * code_samples_per_chip * GALILEO_E5A_NUMBER_OF_CODES * sizeof(int32_t), volk_gnsssdr_get_alignment())); + data_codes_ptr_ = static_cast( + volk_gnsssdr_malloc(code_length_chips * code_samples_per_chip * GALILEO_E5A_NUMBER_OF_CODES * sizeof(int32_t), + volk_gnsssdr_get_alignment())); } - for (uint32_t PRN = 1; PRN <= GALILEO_E5A_NUMBER_OF_CODES; PRN++) + for (uint32_t PRN = 1; PRN <= GALILEO_E5A_NUMBER_OF_CODES; ++PRN) { const std::array sig_a = {'5', 'X', '\0'}; galileo_e5_a_code_gen_complex_primary(aux_code, PRN, sig_a); - if (trk_params_fpga.track_pilot) + if (track_pilot_) { - // The code is generated as a series of 1s and -1s. In order to store the values using only one bit, a -1 is stored as a 0 in the FPGA - for (uint32_t s = 0; s < code_length_chips; s++) + for (uint32_t s = 0; s < code_length_chips; ++s) { - auto tmp_value = static_cast(aux_code[s].imag()); - if (tmp_value < 0) - { - tmp_value = 0; - } - tmp_value = tmp_value | LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY; - prn_codes_ptr_[static_cast(code_length_chips) * (PRN - 1) + s] = tmp_value; + int32_t imag_val = (aux_code[s].imag() < 0.0F) ? 0 : 1; + imag_val |= LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY; + prn_codes_ptr_[code_length_chips * (PRN - 1) + s] = imag_val; - tmp_value = static_cast(aux_code[s].real()); - if (tmp_value < 0) - { - tmp_value = 0; - } - tmp_value = tmp_value | LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY | LOCAL_CODE_FPGA_CORRELATOR_SELECT_COUNT; - data_codes_ptr_[static_cast(code_length_chips) * (PRN - 1) + s] = tmp_value; + int32_t real_val = (aux_code[s].real() < 0.0F) ? 0 : 1; + real_val |= LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY | + LOCAL_CODE_FPGA_CORRELATOR_SELECT_COUNT; + data_codes_ptr_[code_length_chips * (PRN - 1) + s] = real_val; } } else { - // The code is generated as a series of 1s and -1s. In order to store the values using only one bit, a -1 is stored as a 0 in the FPGA - for (uint32_t s = 0; s < code_length_chips; s++) + for (uint32_t s = 0; s < code_length_chips; ++s) { - auto tmp_value = static_cast(aux_code[s].real()); - if (tmp_value < 0) - { - tmp_value = 0; - } - tmp_value = tmp_value | LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY; - prn_codes_ptr_[static_cast(code_length_chips) * (PRN - 1) + s] = tmp_value; + int32_t val = (aux_code[s].real() < 0.0F) ? 0 : 1; + val |= LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY; + prn_codes_ptr_[code_length_chips * (PRN - 1) + s] = val; } } } - trk_params_fpga.ca_codes = prn_codes_ptr_; - trk_params_fpga.data_codes = data_codes_ptr_; - trk_params_fpga.code_length_chips = code_length_chips; - trk_params_fpga.code_samples_per_chip = code_samples_per_chip; // 2 sample per chip + // ------------------------------------------------------------------------- + // Assign FPGA tracking configuration + // ------------------------------------------------------------------------- + config_params_fpga().ca_codes = prn_codes_ptr_; + config_params_fpga().data_codes = data_codes_ptr_; + config_params_fpga().code_length_chips = code_length_chips; + config_params_fpga().code_samples_per_chip = code_samples_per_chip; + config_params_fpga().extended_correlation_in_fpga = false; + config_params_fpga().extend_fpga_integration_periods = 1; + config_params_fpga().fpga_integration_period = 1; - trk_params_fpga.extended_correlation_in_fpga = false; // by default - trk_params_fpga.extend_fpga_integration_periods = 1; // (number of FPGA integrations that are combined in the SW) - trk_params_fpga.fpga_integration_period = 1; // (number of symbols that are effectively integrated in the FPGA) if (track_pilot_) { - if (trk_params_fpga.extend_correlation_symbols > 1) + const auto extend = config_params_fpga().extend_correlation_symbols; + if (extend > 1) { - if (trk_params_fpga.extend_correlation_symbols <= GALILEO_E5A_I_SECONDARY_CODE_LENGTH) + if (extend <= GALILEO_E5A_I_SECONDARY_CODE_LENGTH && + (GALILEO_E5A_I_SECONDARY_CODE_LENGTH % extend) == 0) { - if ((GALILEO_E5A_I_SECONDARY_CODE_LENGTH % trk_params_fpga.extend_correlation_symbols) == 0) - { - trk_params_fpga.extended_correlation_in_fpga = true; - trk_params_fpga.fpga_integration_period = trk_params_fpga.extend_correlation_symbols; - } + config_params_fpga().extended_correlation_in_fpga = true; + config_params_fpga().fpga_integration_period = extend; } - else + else if (extend % GALILEO_E5A_I_SECONDARY_CODE_LENGTH == 0) { - if (trk_params_fpga.extend_correlation_symbols % GALILEO_E5A_I_SECONDARY_CODE_LENGTH == 0) - { - trk_params_fpga.extended_correlation_in_fpga = true; - trk_params_fpga.extend_fpga_integration_periods = trk_params_fpga.extend_correlation_symbols / GALILEO_E5A_I_SECONDARY_CODE_LENGTH; - trk_params_fpga.fpga_integration_period = GALILEO_E5A_I_SECONDARY_CODE_LENGTH; - } + config_params_fpga().extended_correlation_in_fpga = true; + config_params_fpga().extend_fpga_integration_periods = + extend / GALILEO_E5A_I_SECONDARY_CODE_LENGTH; + config_params_fpga().fpga_integration_period = GALILEO_E5A_I_SECONDARY_CODE_LENGTH; } } } - // ################# MAKE TRACKING GNURadio object ################### - DLOG(INFO) << "role " << role_; - tracking_fpga_sc_sptr_ = dll_pll_veml_make_tracking_fpga(trk_params_fpga); + // ------------------------------------------------------------------------- + // Create GNU Radio FPGA tracking block + // ------------------------------------------------------------------------- + tracking_fpga_sc_sptr_ = dll_pll_veml_make_tracking_fpga(config_params_fpga()); DLOG(INFO) << "tracking(" << tracking_fpga_sc_sptr_->unique_id() << ")"; - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; - } } @@ -199,70 +191,3 @@ GalileoE5aDllPllTrackingFpga::~GalileoE5aDllPllTrackingFpga() volk_gnsssdr_free(data_codes_ptr_); } } - - -void GalileoE5aDllPllTrackingFpga::start_tracking() -{ - tracking_fpga_sc_sptr_->start_tracking(); -} - - -void GalileoE5aDllPllTrackingFpga::stop_tracking() -{ - tracking_fpga_sc_sptr_->stop_tracking(); -} - - -/* - * Set tracking channel unique ID - */ -void GalileoE5aDllPllTrackingFpga::set_channel(unsigned int channel) -{ - channel_ = channel; - - // UIO device file - std::string device_io_name; - // find the uio device file corresponding to the tracking multicorrelator - if (find_uio_dev_file_name(device_io_name, device_name_, channel_ - num_prev_assigned_ch_) < 0) - { - std::cout << "Cannot find the FPGA uio device file corresponding to device name " << device_name_ << std::endl; - throw std::exception(); - } - tracking_fpga_sc_sptr_->set_channel(channel_, device_io_name); -} - - -void GalileoE5aDllPllTrackingFpga::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) -{ - tracking_fpga_sc_sptr_->set_gnss_synchro(p_gnss_synchro); -} - - -void GalileoE5aDllPllTrackingFpga::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to connect, now the tracking uses gr_sync_decimator -} - - -void GalileoE5aDllPllTrackingFpga::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to disconnect, now the tracking uses gr_sync_decimator -} - - -gr::basic_block_sptr GalileoE5aDllPllTrackingFpga::get_left_block() -{ - return tracking_fpga_sc_sptr_; -} - - -gr::basic_block_sptr GalileoE5aDllPllTrackingFpga::get_right_block() -{ - return tracking_fpga_sc_sptr_; -} diff --git a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.h index 1b3c8f52b..c7c09f4a4 100644 --- a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.h @@ -18,29 +18,23 @@ #ifndef GNSS_SDR_GALILEO_E5A_DLL_PLL_TRACKING_FPGA_H #define GNSS_SDR_GALILEO_E5A_DLL_PLL_TRACKING_FPGA_H -#include "dll_pll_veml_tracking_fpga.h" -#include "tracking_interface.h" -#include +#include "base_dll_pll_tracking_fpga.h" /** \addtogroup Tracking * \{ */ /** \addtogroup Tracking_adapters * \{ */ - -class ConfigurationInterface; - /*! - * \brief This class implements a code DLL + carrier PLL tracking loop + * \brief Adapter for a Galileo E5a DLL+PLL tracking loop implemented in FPGA */ -class GalileoE5aDllPllTrackingFpga : public TrackingInterface +class GalileoE5aDllPllTrackingFpga : public BaseDllPllTrackingFpga { public: /*! * \brief Constructor */ - GalileoE5aDllPllTrackingFpga( - const ConfigurationInterface* configuration, + GalileoE5aDllPllTrackingFpga(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams); @@ -48,94 +42,26 @@ public: /*! * \brief Destructor */ - virtual ~GalileoE5aDllPllTrackingFpga(); - - /*! - * \brief Role - */ - inline std::string role() override - { - return role_; - } + ~GalileoE5aDllPllTrackingFpga() override; /*! * \brief Returns "Galileo_E5a_DLL_PLL_Tracking_FPGA" */ - inline std::string implementation() override + std::string implementation() override { return "Galileo_E5a_DLL_PLL_Tracking_FPGA"; } - /*! - * \brief Returns size of lv_16sc_t - */ - size_t item_size() override - { - return sizeof(int16_t); - } - - /*! - * \brief Connect - */ - void connect(gr::top_block_sptr top_block) override; - - /*! - * \brief Disconnect - */ - void disconnect(gr::top_block_sptr top_block) override; - - /*! - * \brief Get left block - */ - gr::basic_block_sptr get_left_block() override; - - /*! - * \brief Get right block - */ - gr::basic_block_sptr get_right_block() override; - - /*! - * \brief Set tracking channel unique ID - */ - void set_channel(unsigned int channel) override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - - /*! - * \brief Start the tracking process in the FPGA - */ - void start_tracking() override; - - /*! - * \brief Stop the tracking process in the FPGA - */ - void stop_tracking() override; - private: - const std::string default_device_name_Galileo_E5a = "multicorrelator_resampler_3_1_AXI"; // UIO device name - - // the following flags are FPGA-specific and they are using arrange the values of the local code in the way the FPGA - // expects. This arrangement is done in the initialisation to avoid consuming unnecessary clock cycles during tracking. - static const int32_t LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY = 0x0C000000; // flag that enables WE (Write Enable) of the local code FPGA - static const int32_t LOCAL_CODE_FPGA_CORRELATOR_SELECT_COUNT = 0x20000000; // flag that selects the writing of the pilot code in the FPGA (as opposed to the data code) - - dll_pll_veml_tracking_fpga_sptr tracking_fpga_sc_sptr_; - std::string role_; - std::string device_name_; + // Pointer to local PRN codes (pilot/data) int32_t* prn_codes_ptr_; int32_t* data_codes_ptr_; - uint32_t num_prev_assigned_ch_; - uint32_t channel_; - uint32_t in_streams_; - uint32_t out_streams_; + + // Pilot tracking flag bool track_pilot_; }; -/** \} */ -/** \} */ +// /** \} */ +// /** \} */ #endif // GNSS_SDR_GALILEO_E5A_DLL_PLL_TRACKING_FPGA_H diff --git a/src/algorithms/tracking/adapters/galileo_e5b_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/galileo_e5b_dll_pll_tracking.cc index 6e7191958..015064e4e 100644 --- a/src/algorithms/tracking/adapters/galileo_e5b_dll_pll_tracking.cc +++ b/src/algorithms/tracking/adapters/galileo_e5b_dll_pll_tracking.cc @@ -25,8 +25,6 @@ #include "Galileo_E5b.h" #include "configuration_interface.h" #include "display.h" -#include "dll_pll_conf.h" -#include "gnss_sdr_flags.h" #include #include @@ -41,115 +39,49 @@ GalileoE5bDllPllTracking::GalileoE5bDllPllTracking( const std::string& role, unsigned int in_streams, unsigned int out_streams) - : role_(role), - item_size_(sizeof(gr_complex)), - channel_(0), - in_streams_(in_streams), - out_streams_(out_streams) + : BaseDllPllTracking(configuration, role, in_streams, out_streams) { - Dll_Pll_Conf trk_params = Dll_Pll_Conf(); - trk_params.SetFromConfiguration(configuration, role_); + configure_tracking_parameters(configuration); + create_tracking_block(); +} - const auto vector_length = static_cast(std::round(trk_params.fs_in / (GALILEO_E5B_CODE_CHIP_RATE_CPS / GALILEO_E5B_CODE_LENGTH_CHIPS))); - trk_params.vector_length = vector_length; - if (trk_params.extend_correlation_symbols < 1) + +void GalileoE5bDllPllTracking::configure_tracking_parameters( + const ConfigurationInterface* configuration [[maybe_unused]]) +{ + const auto vector_length = static_cast(std::round(config_params().fs_in / (GALILEO_E5B_CODE_CHIP_RATE_CPS / GALILEO_E5B_CODE_LENGTH_CHIPS))); + config_params().vector_length = vector_length; + if (config_params().extend_correlation_symbols < 1) { - trk_params.extend_correlation_symbols = 1; + config_params().extend_correlation_symbols = 1; std::cout << TEXT_RED << "WARNING: Galileo E5b. extend_correlation_symbols must be bigger than 0. Coherent integration has been set to 1 symbol (1 ms)" << TEXT_RESET << '\n'; } - else if (!trk_params.track_pilot and trk_params.extend_correlation_symbols > GALILEO_E5B_I_SECONDARY_CODE_LENGTH) + else if (!config_params().track_pilot and config_params().extend_correlation_symbols > GALILEO_E5B_I_SECONDARY_CODE_LENGTH) { - trk_params.extend_correlation_symbols = GALILEO_E5B_I_SECONDARY_CODE_LENGTH; + config_params().extend_correlation_symbols = GALILEO_E5B_I_SECONDARY_CODE_LENGTH; std::cout << TEXT_RED << "WARNING: Galileo E5b. extend_correlation_symbols must be lower than 5 when tracking the data component. Coherent integration has been set to 4 symbols (4 ms)" << TEXT_RESET << '\n'; } - if ((trk_params.extend_correlation_symbols > 1) and (trk_params.pll_bw_narrow_hz > trk_params.pll_bw_hz or trk_params.dll_bw_narrow_hz > trk_params.dll_bw_hz)) + if ((config_params().extend_correlation_symbols > 1) and (config_params().pll_bw_narrow_hz > config_params().pll_bw_hz or config_params().dll_bw_narrow_hz > config_params().dll_bw_hz)) { std::cout << TEXT_RED << "WARNING: Galileo E5b. PLL or DLL narrow tracking bandwidth is higher than wide tracking one" << TEXT_RESET << '\n'; } - trk_params.system = 'E'; + config_params().system = 'E'; const std::array sig{'7', 'X', '\0'}; - std::copy_n(sig.data(), 3, trk_params.signal); + std::copy_n(sig.data(), 3, config_params().signal); +} - // ################# Make a GNU Radio Tracking block object ################ - DLOG(INFO) << "role " << role_; - if (trk_params.item_type == "gr_complex") + +void GalileoE5bDllPllTracking::create_tracking_block() +{ + if (config_params().item_type == "gr_complex") { - tracking_sptr_ = dll_pll_veml_make_tracking(trk_params); + tracking_sptr_ = dll_pll_veml_make_tracking(config_params()); DLOG(INFO) << "tracking(" << tracking_sptr_->unique_id() << ")"; } else { - item_size_ = 0; + set_item_size(0); tracking_sptr_ = nullptr; - LOG(WARNING) << trk_params.item_type << " unknown tracking item type."; - } - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; + LOG(WARNING) << config_params().item_type << " unknown tracking item type."; } } - - -void GalileoE5bDllPllTracking::stop_tracking() -{ - tracking_sptr_->stop_tracking(); -} - - -void GalileoE5bDllPllTracking::start_tracking() -{ - tracking_sptr_->start_tracking(); -} - - -/* - * Set tracking channel unique ID - */ -void GalileoE5bDllPllTracking::set_channel(unsigned int channel) -{ - channel_ = channel; - tracking_sptr_->set_channel(channel); -} - - -void GalileoE5bDllPllTracking::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) -{ - tracking_sptr_->set_gnss_synchro(p_gnss_synchro); -} - - -void GalileoE5bDllPllTracking::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { - /* top_block is not null */ - }; - // nothing to connect, now the tracking uses gr_sync_decimator -} - - -void GalileoE5bDllPllTracking::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { - /* top_block is not null */ - }; - // nothing to disconnect, now the tracking uses gr_sync_decimator -} - - -gr::basic_block_sptr GalileoE5bDllPllTracking::get_left_block() -{ - return tracking_sptr_; -} - - -gr::basic_block_sptr GalileoE5bDllPllTracking::get_right_block() -{ - return tracking_sptr_; -} diff --git a/src/algorithms/tracking/adapters/galileo_e5b_dll_pll_tracking.h b/src/algorithms/tracking/adapters/galileo_e5b_dll_pll_tracking.h index dad64de44..2433e2294 100644 --- a/src/algorithms/tracking/adapters/galileo_e5b_dll_pll_tracking.h +++ b/src/algorithms/tracking/adapters/galileo_e5b_dll_pll_tracking.h @@ -24,93 +24,39 @@ #ifndef GNSS_SDR_GALILEO_E5B_DLL_PLL_TRACKING_H #define GNSS_SDR_GALILEO_E5B_DLL_PLL_TRACKING_H -#include "dll_pll_veml_tracking.h" -#include "tracking_interface.h" -#include +#include "base_dll_pll_tracking.h" /** \addtogroup Tracking + * Classes for GNSS signal tracking. * \{ */ -/** \addtogroup Tracking_adapters +/** \addtogroup Tracking_adapters tracking_adapters + * Wrap GNU Radio blocks for GNSS signal tracking with a TrackingInterface * \{ */ - class ConfigurationInterface; /*! - * \brief This class implements a code DLL + carrier PLL tracking loop + * \brief This class Adapts a DLL+PLL VEML (Very Early Minus Late) tracking + * loop block to a TrackingInterface for Galileo E5b signals */ -class GalileoE5bDllPllTracking : public TrackingInterface +class GalileoE5bDllPllTracking : public BaseDllPllTracking { public: - GalileoE5bDllPllTracking( - const ConfigurationInterface* configuration, + //! Constructor + GalileoE5bDllPllTracking(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams); - ~GalileoE5bDllPllTracking() = default; - - inline std::string role() override - { - return role_; - } - //! Returns "Galileo_E5b_DLL_PLL_Tracking" inline std::string implementation() override { return "Galileo_E5b_DLL_PLL_Tracking"; } - inline size_t item_size() override - { - return item_size_; - } - - /*! - * \brief Connect - */ - void connect(gr::top_block_sptr top_block) override; - - /*! - * \brief Disconnect - */ - void disconnect(gr::top_block_sptr top_block) override; - - /*! - * \brief Get left block - */ - gr::basic_block_sptr get_left_block() override; - - /*! - * \brief Get right block - */ - gr::basic_block_sptr get_right_block() override; - - /*! - * \brief Set tracking channel unique ID - */ - void set_channel(unsigned int channel) override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - - void start_tracking() override; - - /*! - * \brief Stop running tracking - */ - void stop_tracking() override; - private: - dll_pll_veml_tracking_sptr tracking_sptr_; - std::string role_; - size_t item_size_; - unsigned int channel_; - unsigned int in_streams_; - unsigned int out_streams_; + void configure_tracking_parameters(const ConfigurationInterface* configuration) override; + void create_tracking_block() override; }; diff --git a/src/algorithms/tracking/adapters/galileo_e6_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/galileo_e6_dll_pll_tracking.cc index 1d1c81e09..6324e36b9 100644 --- a/src/algorithms/tracking/adapters/galileo_e6_dll_pll_tracking.cc +++ b/src/algorithms/tracking/adapters/galileo_e6_dll_pll_tracking.cc @@ -20,8 +20,6 @@ #include "Galileo_E6.h" #include "configuration_interface.h" #include "display.h" -#include "dll_pll_conf.h" -#include "gnss_sdr_flags.h" #include #include @@ -31,120 +29,55 @@ #include #endif + GalileoE6DllPllTracking::GalileoE6DllPllTracking( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) - : role_(role), - item_size_(sizeof(gr_complex)), - channel_(0), - in_streams_(in_streams), - out_streams_(out_streams) + : BaseDllPllTracking(configuration, role, in_streams, out_streams) { - Dll_Pll_Conf trk_params = Dll_Pll_Conf(); - trk_params.SetFromConfiguration(configuration, role_); + configure_tracking_parameters(configuration); + create_tracking_block(); +} - const auto vector_length = static_cast(std::round(trk_params.fs_in / (GALILEO_E6_B_CODE_CHIP_RATE_CPS / GALILEO_E6_B_CODE_LENGTH_CHIPS))); - trk_params.vector_length = vector_length; - if (trk_params.extend_correlation_symbols < 1) + +void GalileoE6DllPllTracking::configure_tracking_parameters( + const ConfigurationInterface* configuration [[maybe_unused]]) +{ + const auto vector_length = static_cast(std::round(config_params().fs_in / (GALILEO_E6_B_CODE_CHIP_RATE_CPS / GALILEO_E6_B_CODE_LENGTH_CHIPS))); + config_params().vector_length = vector_length; + config_params().system = 'E'; + const std::array sig{'5', 'X', '\0'}; + std::copy_n(sig.data(), 3, config_params().signal); + if (config_params().extend_correlation_symbols < 1) { - trk_params.extend_correlation_symbols = 1; + config_params().extend_correlation_symbols = 1; std::cout << TEXT_RED << "WARNING: Galileo E6. extend_correlation_symbols must be bigger than 0. Coherent integration has been set to 1 symbol (1 ms)" << TEXT_RESET << '\n'; } - else if (!trk_params.track_pilot and trk_params.extend_correlation_symbols > 1) + else if (!config_params().track_pilot and config_params().extend_correlation_symbols > 1) { - trk_params.extend_correlation_symbols = 1; + config_params().extend_correlation_symbols = 1; std::cout << TEXT_RED << "WARNING: Galileo E6. Extended coherent integration is not allowed when tracking the data component. Coherent integration has been set to 1 ms (1 symbol)" << TEXT_RESET << '\n'; } - if ((trk_params.extend_correlation_symbols > 1) and (trk_params.pll_bw_narrow_hz > trk_params.pll_bw_hz or trk_params.dll_bw_narrow_hz > trk_params.dll_bw_hz)) + if ((config_params().extend_correlation_symbols > 1) and (config_params().pll_bw_narrow_hz > config_params().pll_bw_hz or config_params().dll_bw_narrow_hz > config_params().dll_bw_hz)) { std::cout << TEXT_RED << "WARNING: Galileo E5b. PLL or DLL narrow tracking bandwidth is higher than wide tracking one" << TEXT_RESET << '\n'; } - trk_params.system = 'E'; - const std::array sig{'E', '6', '\0'}; - std::copy_n(sig.data(), 3, trk_params.signal); +} - // ################# Make a GNU Radio Tracking block object ################ - DLOG(INFO) << "role " << role_; - if (trk_params.item_type == "gr_complex") + +void GalileoE6DllPllTracking::create_tracking_block() +{ + if (config_params().item_type == "gr_complex") { - tracking_sptr_ = dll_pll_veml_make_tracking(trk_params); + tracking_sptr_ = dll_pll_veml_make_tracking(config_params()); DLOG(INFO) << "tracking(" << tracking_sptr_->unique_id() << ")"; } else { - item_size_ = 0; + set_item_size(0); tracking_sptr_ = nullptr; - LOG(WARNING) << trk_params.item_type << " unknown tracking item type."; - } - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; + LOG(WARNING) << config_params().item_type << " unknown tracking item type."; } } - - -void GalileoE6DllPllTracking::stop_tracking() -{ - tracking_sptr_->stop_tracking(); -} - - -void GalileoE6DllPllTracking::start_tracking() -{ - tracking_sptr_->start_tracking(); -} - - -/* - * Set tracking channel unique ID - */ -void GalileoE6DllPllTracking::set_channel(unsigned int channel) -{ - channel_ = channel; - tracking_sptr_->set_channel(channel); -} - - -void GalileoE6DllPllTracking::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) -{ - tracking_sptr_->set_gnss_synchro(p_gnss_synchro); -} - - -void GalileoE6DllPllTracking::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { - /* top_block is not null */ - }; - // nothing to connect, now the tracking uses gr_sync_decimator -} - - -void GalileoE6DllPllTracking::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { - /* top_block is not null */ - }; - // nothing to disconnect, now the tracking uses gr_sync_decimator -} - - -gr::basic_block_sptr GalileoE6DllPllTracking::get_left_block() -{ - return tracking_sptr_; -} - - -gr::basic_block_sptr GalileoE6DllPllTracking::get_right_block() -{ - return tracking_sptr_; -} diff --git a/src/algorithms/tracking/adapters/galileo_e6_dll_pll_tracking.h b/src/algorithms/tracking/adapters/galileo_e6_dll_pll_tracking.h index 381711d5a..ed51a2cd6 100644 --- a/src/algorithms/tracking/adapters/galileo_e6_dll_pll_tracking.h +++ b/src/algorithms/tracking/adapters/galileo_e6_dll_pll_tracking.h @@ -19,96 +19,140 @@ #ifndef GNSS_SDR_GALILEO_E6_DLL_PLL_TRACKING_H #define GNSS_SDR_GALILEO_E6_DLL_PLL_TRACKING_H -#include "dll_pll_veml_tracking.h" -#include "tracking_interface.h" -#include +#include "base_dll_pll_tracking.h" /** \addtogroup Tracking + * Classes for GNSS signal tracking. * \{ */ -/** \addtogroup Tracking_adapters +/** \addtogroup Tracking_adapters tracking_adapters + * Wrap GNU Radio blocks for GNSS signal tracking with a TrackingInterface * \{ */ - class ConfigurationInterface; /*! - * \brief This class implements a code DLL + carrier PLL tracking loop + * \brief This class Adapts a DLL+PLL VEML (Very Early Minus Late) tracking + * loop block to a TrackingInterface for Galileo E5a signals */ -class GalileoE6DllPllTracking : public TrackingInterface +class GalileoE6DllPllTracking : public BaseDllPllTracking { public: - GalileoE6DllPllTracking( - const ConfigurationInterface* configuration, + //! Constructor + GalileoE6DllPllTracking(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams); - ~GalileoE6DllPllTracking() = default; - - inline std::string role() override - { - return role_; - } - //! Returns "Galileo_E6_DLL_PLL_Tracking" inline std::string implementation() override { return "Galileo_E6_DLL_PLL_Tracking"; } - inline size_t item_size() override - { - return item_size_; - } - - /*! - * \brief Connect - */ - void connect(gr::top_block_sptr top_block) override; - - /*! - * \brief Disconnect - */ - void disconnect(gr::top_block_sptr top_block) override; - - /*! - * \brief Get left block - */ - gr::basic_block_sptr get_left_block() override; - - /*! - * \brief Get right block - */ - gr::basic_block_sptr get_right_block() override; - - /*! - * \brief Set tracking channel unique ID - */ - void set_channel(unsigned int channel) override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - - void start_tracking() override; - - /*! - * \brief Stop running tracking - */ - void stop_tracking() override; - private: - dll_pll_veml_tracking_sptr tracking_sptr_; - std::string role_; - size_t item_size_; - unsigned int channel_; - unsigned int in_streams_; - unsigned int out_streams_; + void configure_tracking_parameters(const ConfigurationInterface* configuration) override; + void create_tracking_block() override; }; /** \} */ /** \} */ #endif // GNSS_SDR_GALILEO_E6_DLL_PLL_TRACKING_H + +// // +// src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking.h + +// src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking.h +// #include "dll_pll_veml_tracking.h" +// #include "tracking_interface.h" +// #include + +// /** \addtogroup Tracking +// * \{ */ +// /** \addtogroup Tracking_adapters +// * \{ */ + + +// class ConfigurationInterface; + +// /*! +// * \brief This class implements a code DLL + carrier PLL tracking loop +// */ +// class GalileoE6DllPllTracking : public TrackingInterface +// { +// public: +// GalileoE6DllPllTracking( +// const ConfigurationInterface* configuration, +// const std::string& role, +// unsigned int in_streams, +// unsigned int out_streams); + +// ~GalileoE6DllPllTracking() = default; + +// inline std::string role() override +// { +// return role_; +// } + +// //! Returns "Galileo_E6_DLL_PLL_Tracking" +// inline std::string implementation() override +// { +// return "Galileo_E6_DLL_PLL_Tracking"; +// } + +// inline size_t item_size() override +// { +// return item_size_; +// } + +// /*! +// * \brief Connect +// */ +// void connect(gr::top_block_sptr top_block) override; + +// /*! +// * \brief Disconnect +// */ +// void disconnect(gr::top_block_sptr top_block) override; + +// /*! +// * \brief Get left block +// */ +// gr::basic_block_sptr get_left_block() override; + +// /*! +// * \brief Get right block +// */ +// gr::basic_block_sptr get_right_block() override; + +// /*! +// * \brief Set tracking channel unique ID +// */ +// void set_channel(unsigned int channel) override; + +// /*! +// * \brief Set acquisition/tracking common Gnss_Synchro object pointer +// * to efficiently exchange synchronization data between acquisition and tracking blocks +// */ +// void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; + +// void start_tracking() override; + +// /*! +// * \brief Stop running tracking +// */ +// void stop_tracking() override; + +// private: +// dll_pll_veml_tracking_sptr tracking_sptr_; +// std::string role_; +// size_t item_size_; +// unsigned int channel_; +// unsigned int in_streams_; +// unsigned int out_streams_; +// }; + + +// /** \} */ +// /** \} */ +// #endif // GNSS_SDR_GALILEO_E6_DLL_PLL_TRACKING_H diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking.cc index 5d0f9973a..578d9dc3f 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking.cc +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking.cc @@ -1,6 +1,6 @@ /*! * \file gps_l1_ca_dll_pll_tracking.cc - * \brief Implementation of an adapter of a DLL+PLL tracking loop block + * \brief Interface of an adapter of a DLL+PLL tracking loop block * for GPS L1 C/A to a TrackingInterface * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com * Javier Arribas, 2011. jarribas(at)cttc.es @@ -25,10 +25,10 @@ #include "GPS_L1_CA.h" #include "configuration_interface.h" #include "display.h" -#include "dll_pll_conf.h" -#include "gnss_sdr_flags.h" #include #include +#include +#include #if USE_GLOG_AND_GFLAGS #include @@ -39,121 +39,78 @@ GpsL1CaDllPllTracking::GpsL1CaDllPllTracking( const ConfigurationInterface* configuration, const std::string& role, - unsigned int in_streams, unsigned int out_streams) - : role_(role), - item_size_(sizeof(gr_complex)), - channel_(0), - in_streams_(in_streams), - out_streams_(out_streams) + unsigned int in_streams, + unsigned int out_streams) + : BaseDllPllTracking(configuration, role, in_streams, out_streams) { - Dll_Pll_Conf trk_params = Dll_Pll_Conf(); - trk_params.SetFromConfiguration(configuration, role_); + configure_tracking_parameters(configuration); + create_tracking_block(); +} - const auto vector_length = static_cast(std::round(trk_params.fs_in / (GPS_L1_CA_CODE_RATE_CPS / GPS_L1_CA_CODE_LENGTH_CHIPS))); - trk_params.vector_length = vector_length; - if (trk_params.extend_correlation_symbols < 1) - { - trk_params.extend_correlation_symbols = 1; - std::cout << TEXT_RED << "WARNING: GPS L1 C/A. extend_correlation_symbols must be bigger than 1. Coherent integration has been set to 1 symbol (1 ms)" << TEXT_RESET << '\n'; - } - else if (trk_params.extend_correlation_symbols > 20) - { - trk_params.extend_correlation_symbols = 20; - std::cout << TEXT_RED << "WARNING: GPS L1 C/A. extend_correlation_symbols must be lower than 21. Coherent integration has been set to 20 symbols (20 ms)" << TEXT_RESET << '\n'; - } - trk_params.track_pilot = configuration->property(role_ + ".track_pilot", false); - if (trk_params.track_pilot) - { - trk_params.track_pilot = false; - std::cout << TEXT_RED << "WARNING: GPS L1 C/A does not have pilot signal. Data tracking has been enabled" << TEXT_RESET << '\n'; - } - if ((trk_params.extend_correlation_symbols > 1) and (trk_params.pll_bw_narrow_hz > trk_params.pll_bw_hz or trk_params.dll_bw_narrow_hz > trk_params.dll_bw_hz)) - { - std::cout << TEXT_RED << "WARNING: GPS L1 C/A. PLL or DLL narrow tracking bandwidth is higher than wide tracking one" << TEXT_RESET << '\n'; - } - trk_params.system = 'G'; +void GpsL1CaDllPllTracking::configure_tracking_parameters( + const ConfigurationInterface* configuration __attribute__((unused))) +{ + // Set basic signal identifiers + config_params().system = 'G'; const std::array sig{'1', 'C', '\0'}; - std::copy_n(sig.data(), 3, trk_params.signal); + std::copy_n(sig.data(), 3, config_params().signal); - // ################# Make a GNU Radio Tracking block object ################ - DLOG(INFO) << "role " << role_; - if (trk_params.item_type == "gr_complex") + const auto vector_length = static_cast(std::round(config_params().fs_in / (GPS_L1_CA_CODE_RATE_CPS / GPS_L1_CA_CODE_LENGTH_CHIPS))); + config_params().vector_length = vector_length; + + // Sanity checks and warnings + if (config_params().extend_correlation_symbols < 1) { - tracking_sptr_ = dll_pll_veml_make_tracking(trk_params); - DLOG(INFO) << "tracking(" << tracking_sptr_->unique_id() << ")"; + config_params().extend_correlation_symbols = 1; + std::cout << TEXT_RED + << "WARNING: GPS L1 C/A: extend_correlation_symbols must be > 0. " + << "Coherent integration set to 1 ms." + << TEXT_RESET << std::endl; + } + else if (config_params().extend_correlation_symbols > 20) + { + config_params().extend_correlation_symbols = 20; + std::cout << TEXT_RED + << "WARNING: GPS L1 C/A: extend_correlation_symbols limited to 20 (20 ms)." + << TEXT_RESET << std::endl; + } + + // GPS L1 C/A does not have a pilot component + config_params().track_pilot = configuration->property(this->role() + ".track_pilot", false); + if (config_params().track_pilot) + { + config_params().track_pilot = false; + std::cout << TEXT_RED + << "WARNING: GPS L1 C/A does not have pilot signal. " + << "Data tracking enabled instead." + << TEXT_RESET << std::endl; + } + + // Ensure bandwidth sanity when narrow-band is enabled + if ((config_params().extend_correlation_symbols > 1) && + (config_params().pll_bw_narrow_hz > config_params().pll_bw_hz || + config_params().dll_bw_narrow_hz > config_params().dll_bw_hz)) + { + std::cout << TEXT_RED + << "WARNING: GPS L1 C/A: Narrow tracking bandwidth is higher than wide bandwidth." + << TEXT_RESET << std::endl; + } +} + + +void GpsL1CaDllPllTracking::create_tracking_block() +{ + // Create GNU Radio block + if (config_params().item_type == "gr_complex") + { + tracking_sptr_ = dll_pll_veml_make_tracking(config_params()); + DLOG(INFO) << "Tracking block (" << tracking_sptr_->unique_id() << ")"; } else { - item_size_ = 0; + set_item_size(0); tracking_sptr_ = nullptr; - LOG(WARNING) << trk_params.item_type << " unknown tracking item type."; - } - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; + LOG(WARNING) << config_params().item_type << " unknown tracking item type."; } } - - -void GpsL1CaDllPllTracking::stop_tracking() -{ - tracking_sptr_->stop_tracking(); -} - - -void GpsL1CaDllPllTracking::start_tracking() -{ - tracking_sptr_->start_tracking(); -} - - -/* - * Set tracking channel unique ID - */ -void GpsL1CaDllPllTracking::set_channel(unsigned int channel) -{ - channel_ = channel; - tracking_sptr_->set_channel(channel); -} - - -void GpsL1CaDllPllTracking::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) -{ - tracking_sptr_->set_gnss_synchro(p_gnss_synchro); -} - - -void GpsL1CaDllPllTracking::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to connect, now the tracking uses gr_sync_decimator -} - - -void GpsL1CaDllPllTracking::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to disconnect, now the tracking uses gr_sync_decimator -} - - -gr::basic_block_sptr GpsL1CaDllPllTracking::get_left_block() -{ - return tracking_sptr_; -} - - -gr::basic_block_sptr GpsL1CaDllPllTracking::get_right_block() -{ - return tracking_sptr_; -} diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking.h b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking.h index 2e7cbce0f..482f697e0 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking.h +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking.h @@ -24,9 +24,7 @@ #ifndef GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_H #define GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_H -#include "dll_pll_veml_tracking.h" -#include "tracking_interface.h" -#include +#include "base_dll_pll_tracking.h" /** \addtogroup Tracking * Classes for GNSS signal tracking. @@ -36,71 +34,30 @@ * \{ */ -class ConfigurationInterface; - /*! * \brief This class implements a code DLL + carrier PLL tracking loop + * block adapter for GPS L1 C/A signals */ -class GpsL1CaDllPllTracking : public TrackingInterface +class GpsL1CaDllPllTracking : public BaseDllPllTracking { public: - GpsL1CaDllPllTracking( - const ConfigurationInterface* configuration, + //! Constructor + GpsL1CaDllPllTracking(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams); - ~GpsL1CaDllPllTracking() = default; - - inline std::string role() override - { - return role_; - } - //! Returns "GPS_L1_CA_DLL_PLL_Tracking" inline std::string implementation() override { return "GPS_L1_CA_DLL_PLL_Tracking"; } - inline size_t item_size() override - { - return item_size_; - } - - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - /*! - * \brief Set tracking channel unique ID - */ - void set_channel(unsigned int channel) override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - - void start_tracking() override; - - /*! - * \brief Stop running tracking - */ - void stop_tracking() override; - private: - dll_pll_veml_tracking_sptr tracking_sptr_; - std::string role_; - size_t item_size_; - unsigned int channel_; - unsigned int in_streams_; - unsigned int out_streams_; + void configure_tracking_parameters(const ConfigurationInterface* configuration) override; + void create_tracking_block() override; }; - /** \} */ /** \} */ #endif // GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_H diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc index 6d9981ed5..24fb78203 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc @@ -24,8 +24,6 @@ #include "GPS_L1_CA.h" #include "configuration_interface.h" #include "display.h" -#include "dll_pll_conf_fpga.h" -#include "gnss_sdr_flags.h" #include "gps_sdr_signal_replica.h" #include "uio_fpga.h" #include @@ -43,94 +41,77 @@ GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga( const std::string& role, unsigned int in_streams, unsigned int out_streams) - : role_(role), - num_prev_assigned_ch_(0), - channel_(0), - in_streams_(in_streams), - out_streams_(out_streams) + : BaseDllPllTrackingFpga(configuration, role, in_streams, out_streams) { - Dll_Pll_Conf_Fpga trk_params_fpga = Dll_Pll_Conf_Fpga(); - trk_params_fpga.SetFromConfiguration(configuration, role_); + const uint32_t NUM_PRNs = 32; + const int32_t GPS_CA_BIT_DURATION_MS = 20; + const auto vector_length = static_cast( + std::round(config_params_fpga().fs_in / (GPS_L1_CA_CODE_RATE_CPS / GPS_L1_CA_CODE_LENGTH_CHIPS))); + config_params_fpga().vector_length = vector_length; - const auto vector_length = static_cast(std::round(trk_params_fpga.fs_in / (GPS_L1_CA_CODE_RATE_CPS / GPS_L1_CA_CODE_LENGTH_CHIPS))); - trk_params_fpga.vector_length = vector_length; - if (trk_params_fpga.extend_correlation_symbols < 1) + if (config_params_fpga().extend_correlation_symbols < 1) { - trk_params_fpga.extend_correlation_symbols = 1; - std::cout << TEXT_RED << "WARNING: GPS L1 C/A. extend_correlation_symbols must be bigger than 1. Coherent integration has been set to 1 symbol (1 ms)" << TEXT_RESET << '\n'; + config_params_fpga().extend_correlation_symbols = 1; + std::cout << TEXT_RED + << "WARNING: GPS L1 C/A. extend_correlation_symbols must be >= 1. Set to 1 ms." + << TEXT_RESET << '\n'; } - else if (trk_params_fpga.extend_correlation_symbols > GPS_CA_BIT_DURATION_MS) + else if (config_params_fpga().extend_correlation_symbols > GPS_CA_BIT_DURATION_MS) { - trk_params_fpga.extend_correlation_symbols = GPS_CA_BIT_DURATION_MS; - std::cout << TEXT_RED << "WARNING: GPS L1 C/A. extend_correlation_symbols must be lower than 21. Coherent integration has been set to 20 symbols (20 ms)" << TEXT_RESET << '\n'; + config_params_fpga().extend_correlation_symbols = GPS_CA_BIT_DURATION_MS; + std::cout << TEXT_RED + << "WARNING: GPS L1 C/A. extend_correlation_symbols limited to 20 ms." + << TEXT_RESET << '\n'; } - trk_params_fpga.track_pilot = configuration->property(role_ + ".track_pilot", false); - if (trk_params_fpga.track_pilot) - { - trk_params_fpga.track_pilot = false; - std::cout << TEXT_RED << "WARNING: GPS L1 C/A does not have pilot signal. Data tracking has been enabled" << TEXT_RESET << '\n'; - } - if ((trk_params_fpga.extend_correlation_symbols > 1) and (trk_params_fpga.pll_bw_narrow_hz > trk_params_fpga.pll_bw_hz or trk_params_fpga.dll_bw_narrow_hz > trk_params_fpga.dll_bw_hz)) - { - std::cout << TEXT_RED << "WARNING: GPS L1 C/A. PLL or DLL narrow tracking bandwidth is higher than wide tracking one" << TEXT_RESET << '\n'; - } - trk_params_fpga.system = 'G'; + + config_params_fpga().track_pilot = false; // GPS L1 has no pilot + + config_params_fpga().system = 'G'; const std::array sig{'1', 'C', '\0'}; - std::copy_n(sig.data(), 3, trk_params_fpga.signal); + std::copy_n(sig.data(), 3, config_params_fpga().signal); - // UIO device file - device_name_ = configuration->property(role_ + ".devicename", default_device_name_GPS_L1); + device_name_ = configuration->property(role + ".devicename", default_device_name_GPS_L1); - // ################# PRE-COMPUTE ALL THE CODES ################# - ca_codes_ptr_ = static_cast(volk_gnsssdr_malloc(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS * NUM_PRNs) * sizeof(int32_t), volk_gnsssdr_get_alignment())); - for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++) + // Precompute CA codes + ca_codes_ptr_ = static_cast( + volk_gnsssdr_malloc(GPS_L1_CA_CODE_LENGTH_CHIPS * NUM_PRNs * sizeof(int32_t), + volk_gnsssdr_get_alignment())); + + for (uint32_t prn = 1; prn <= NUM_PRNs; ++prn) { - gps_l1_ca_code_gen_int(own::span(&ca_codes_ptr_[static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS) * (PRN - 1)], &ca_codes_ptr_[static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS) * (PRN)]), PRN, 0); + gps_l1_ca_code_gen_int( + own::span(&ca_codes_ptr_[static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS) * (prn - 1)], + &ca_codes_ptr_[static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS * prn)]), + prn, 0); - // The code is generated as a series of 1s and -1s. In order to store the values using only one bit, a -1 is stored as a 0 in the FPGA - for (uint32_t k = 0; k < GPS_L1_CA_CODE_LENGTH_CHIPS; k++) + for (uint32_t k = 0; k < GPS_L1_CA_CODE_LENGTH_CHIPS; ++k) { - int32_t tmp_value = ca_codes_ptr_[(int32_t(GPS_L1_CA_CODE_LENGTH_CHIPS)) * (PRN - 1) + k]; - if (tmp_value < 0) + int32_t tmp = ca_codes_ptr_[static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS) * (prn - 1) + k]; + if (tmp < 0) { - tmp_value = 0; - } - tmp_value = tmp_value | LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY; - ca_codes_ptr_[(int32_t(GPS_L1_CA_CODE_LENGTH_CHIPS)) * (PRN - 1) + k] = tmp_value; - } - } - trk_params_fpga.ca_codes = ca_codes_ptr_; - trk_params_fpga.code_length_chips = GPS_L1_CA_CODE_LENGTH_CHIPS; - trk_params_fpga.code_samples_per_chip = 1; // 1 sample per chip - - trk_params_fpga.extended_correlation_in_fpga = false; // by default - trk_params_fpga.extend_fpga_integration_periods = 1; // (number of FPGA integrations that are combined in the SW) - trk_params_fpga.fpga_integration_period = 1; // (number of symbols that are effectively integrated in the FPGA) - if (trk_params_fpga.extend_correlation_symbols > 1) - { - if (trk_params_fpga.extend_correlation_symbols <= GPS_CA_BIT_DURATION_MS) - { - if ((GPS_CA_BIT_DURATION_MS % trk_params_fpga.extend_correlation_symbols) == 0) - { - trk_params_fpga.extended_correlation_in_fpga = true; - trk_params_fpga.fpga_integration_period = trk_params_fpga.extend_correlation_symbols; + tmp = 0; } + tmp |= LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY; + ca_codes_ptr_[static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS) * (prn - 1) + k] = tmp; } } - // ################# MAKE TRACKING GNU Radio object ################### - DLOG(INFO) << "role " << role_; - tracking_fpga_sc_sptr_ = dll_pll_veml_make_tracking_fpga(trk_params_fpga); - DLOG(INFO) << "tracking(" << tracking_fpga_sc_sptr_->unique_id() << ")"; + config_params_fpga().ca_codes = ca_codes_ptr_; + config_params_fpga().code_length_chips = GPS_L1_CA_CODE_LENGTH_CHIPS; + config_params_fpga().code_samples_per_chip = 1; + config_params_fpga().extended_correlation_in_fpga = false; + config_params_fpga().extend_fpga_integration_periods = 1; + config_params_fpga().fpga_integration_period = 1; - if (in_streams_ > 1) + if (config_params_fpga().extend_correlation_symbols > 1 && + config_params_fpga().extend_correlation_symbols <= GPS_CA_BIT_DURATION_MS && + (GPS_CA_BIT_DURATION_MS % config_params_fpga().extend_correlation_symbols) == 0) { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; + config_params_fpga().extended_correlation_in_fpga = true; + config_params_fpga().fpga_integration_period = config_params_fpga().extend_correlation_symbols; } + + tracking_fpga_sc_sptr_ = dll_pll_veml_make_tracking_fpga(config_params_fpga()); } @@ -140,89 +121,22 @@ GpsL1CaDllPllTrackingFpga::~GpsL1CaDllPllTrackingFpga() } -void GpsL1CaDllPllTrackingFpga::start_tracking() +bool GpsL1CaDllPllTrackingFpga::find_alternative_device(std::string& device_io_name) { - tracking_fpga_sc_sptr_->start_tracking(); -} - - -void GpsL1CaDllPllTrackingFpga::stop_tracking() -{ - tracking_fpga_sc_sptr_->stop_tracking(); -} - - -/* - * Set tracking channel unique ID - */ -void GpsL1CaDllPllTrackingFpga::set_channel(unsigned int channel) -{ - channel_ = channel; - - // UIO device file - std::string device_io_name; - - // find the uio device file corresponding to the tracking multicorrelator - if (find_uio_dev_file_name(device_io_name, device_name_, channel_ - num_prev_assigned_ch_) < 0) + // Only try Galileo fallback if using the default GPS device + if (device_name_ == default_device_name_GPS_L1) { - bool alt_device_found = false; // alternative compatible HW accelerator device not found by default - - // If the HW accelerator is the default one in the L1 band then look for an alternative hardware accelerator - if (device_name_ == default_device_name_GPS_L1) + if (find_uio_dev_file_name(device_io_name, default_device_name_Galileo_E1, + get_channel() - get_num_prev_assigned_ch()) >= 0) { - if (find_uio_dev_file_name(device_io_name, default_device_name_Galileo_E1, channel_ - num_prev_assigned_ch_) < 0) - { - std::cout << "Cannot find the FPGA uio device file corresponding to device names " << device_name_ << " or " << default_device_name_Galileo_E1 << std::endl; - throw std::exception(); - } - else - { - alt_device_found = true; // alternative compatible HW accelerator device has been found - } - } - - if (!alt_device_found) - { - std::cout << "Cannot find the FPGA uio device file corresponding to device name " << device_name_ << std::endl; - throw std::exception(); + return true; // alternative found } + std::cout << "Cannot find FPGA UIO device file for " + << device_name_ << " or " << default_device_name_Galileo_E1 << std::endl; } - - tracking_fpga_sc_sptr_->set_channel(channel_, device_io_name); -} - - -void GpsL1CaDllPllTrackingFpga::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) -{ - tracking_fpga_sc_sptr_->set_gnss_synchro(p_gnss_synchro); -} - - -void GpsL1CaDllPllTrackingFpga::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to connect -} - - -void GpsL1CaDllPllTrackingFpga::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to disconnect -} - - -gr::basic_block_sptr GpsL1CaDllPllTrackingFpga::get_left_block() -{ - return tracking_fpga_sc_sptr_; -} - - -gr::basic_block_sptr GpsL1CaDllPllTrackingFpga::get_right_block() -{ - return tracking_fpga_sc_sptr_; + else + { + std::cout << "Cannot find FPGA UIO device file for " << device_name_ << std::endl; + } + return false; } diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h index ed3b23f4a..2d5efc96d 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h @@ -23,121 +23,40 @@ #ifndef GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_FPGA_H #define GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_FPGA_H -#include "dll_pll_veml_tracking_fpga.h" -#include "tracking_interface.h" -#include -/** \addtogroup Tracking - * \{ */ -/** \addtogroup Tracking_adapters - * \{ */ +#include "base_dll_pll_tracking_fpga.h" +// /** \addtogroup Tracking +// * \{ */ +// /** \addtogroup Tracking_adapters +// * \{ */ class ConfigurationInterface; /*! - * \brief This class implements a code DLL + carrier PLL tracking loop + * \brief Adapter for a GPS L1 C/A DLL+PLL tracking loop for FPGA */ -class GpsL1CaDllPllTrackingFpga : public TrackingInterface +class GpsL1CaDllPllTrackingFpga : public BaseDllPllTrackingFpga { public: - /*! - * \brief Constructor - */ - GpsL1CaDllPllTrackingFpga( - const ConfigurationInterface* configuration, + GpsL1CaDllPllTrackingFpga(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams); - /*! - * \brief Destructor - */ - virtual ~GpsL1CaDllPllTrackingFpga(); - - /*! - * \brief Role - */ - inline std::string role() override - { - return role_; - } + ~GpsL1CaDllPllTrackingFpga() override; /*! * \brief Returns "GPS_L1_CA_DLL_PLL_Tracking_FPGA" */ - inline std::string implementation() override + std::string implementation() override { return "GPS_L1_CA_DLL_PLL_Tracking_FPGA"; } - /*! - * \brief Returns size of lv_16sc_t - */ - size_t item_size() override - { - return sizeof(int16_t); - } - - /*! - * \brief Connect - */ - void connect(gr::top_block_sptr top_block) override; - - /*! - * \brief Disconnect - */ - void disconnect(gr::top_block_sptr top_block) override; - - /*! - * \brief Get left block - */ - gr::basic_block_sptr get_left_block() override; - - /*! - * \brief Get right block - */ - gr::basic_block_sptr get_right_block() override; - - /*! - * \brief Set tracking channel unique ID - */ - void set_channel(unsigned int channel) override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - - /*! - * \brief Start the tracking process in the FPGA - */ - void start_tracking() override; - - /*! - * \brief Stop the tracking process in the FPGA - */ - void stop_tracking() override; - private: - const std::string default_device_name_GPS_L1 = "multicorrelator_resampler_S00_AXI"; // UIO device name - const std::string default_device_name_Galileo_E1 = "multicorrelator_resampler_5_1_AXI"; // UIO alternative device name - - static const uint32_t NUM_PRNs = 32; // total number of PRNs - static const int32_t GPS_CA_BIT_DURATION_MS = 20; - // the following flag is FPGA-specific and they are using arrange the values of the local code in the way the FPGA - // expects. This arrangement is done in the initialisation to avoid consuming unnecessary clock cycles during tracking. - static const int32_t LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY = 0x0C000000; // flag that enables WE (Write Enable) of the local code FPGA - - dll_pll_veml_tracking_fpga_sptr tracking_fpga_sc_sptr_; - std::string role_; - std::string device_name_; + bool find_alternative_device(std::string& device_io_name); int32_t* ca_codes_ptr_; - uint32_t num_prev_assigned_ch_; - uint32_t channel_; - uint32_t in_streams_; - uint32_t out_streams_; }; diff --git a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking.cc index c048686c9..38e706427 100644 --- a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking.cc +++ b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking.cc @@ -1,7 +1,7 @@ /*! * \file gps_l2_m_dll_pll_tracking.cc * \brief Implementation of an adapter of a DLL+PLL tracking loop block - * for GPS L1 C/A to a TrackingInterface + * for GPS L2C(M) to a TrackingInterface * \author Javier Arribas, 2015. jarribas(at)cttc.es * * Code DLL + carrier PLL according to the algorithms described in: @@ -24,8 +24,6 @@ #include "GPS_L2C.h" #include "configuration_interface.h" #include "display.h" -#include "dll_pll_conf.h" -#include "gnss_sdr_flags.h" #include #include @@ -40,110 +38,47 @@ GpsL2MDllPllTracking::GpsL2MDllPllTracking( const std::string& role, unsigned int in_streams, unsigned int out_streams) - : role_(role), - item_size_(sizeof(gr_complex)), - channel_(0), - in_streams_(in_streams), - out_streams_(out_streams) + : BaseDllPllTracking(configuration, role, in_streams, out_streams) { - Dll_Pll_Conf trk_params = Dll_Pll_Conf(); - trk_params.SetFromConfiguration(configuration, role_); + configure_tracking_parameters(configuration); + create_tracking_block(); +} - const auto vector_length = static_cast(std::round(static_cast(trk_params.fs_in) / (static_cast(GPS_L2_M_CODE_RATE_CPS) / static_cast(GPS_L2_M_CODE_LENGTH_CHIPS)))); - trk_params.vector_length = vector_length; - if (trk_params.extend_correlation_symbols != 1) + +void GpsL2MDllPllTracking::configure_tracking_parameters( + const ConfigurationInterface* configuration) +{ + const auto vector_length = static_cast(std::round(static_cast(config_params().fs_in) / (static_cast(GPS_L2_M_CODE_RATE_CPS) / static_cast(GPS_L2_M_CODE_LENGTH_CHIPS)))); + config_params().vector_length = vector_length; + if (config_params().extend_correlation_symbols != 1) { - trk_params.extend_correlation_symbols = 1; + config_params().extend_correlation_symbols = 1; std::cout << TEXT_RED << "WARNING: Extended coherent integration is not allowed in GPS L2. Coherent integration has been set to 20 ms (1 symbol)" << TEXT_RESET << '\n'; } - trk_params.track_pilot = configuration->property(role_ + ".track_pilot", false); - if (trk_params.track_pilot) + config_params().track_pilot = configuration->property(role() + ".track_pilot", false); + if (config_params().track_pilot) { - trk_params.track_pilot = false; + config_params().track_pilot = false; std::cout << TEXT_RED << "WARNING: GPS L2 does not have pilot signal. Data tracking has been enabled" << TEXT_RESET << '\n'; } - trk_params.system = 'G'; + config_params().system = 'G'; const std::array sig{'2', 'S', '\0'}; - std::copy_n(sig.data(), 3, trk_params.signal); + std::copy_n(sig.data(), 3, config_params().signal); +} + +void GpsL2MDllPllTracking::create_tracking_block() +{ // ################# Make a GNU Radio Tracking block object ################ - DLOG(INFO) << "role " << role_; - if (trk_params.item_type == "gr_complex") + if (config_params().item_type == "gr_complex") { - tracking_sptr_ = dll_pll_veml_make_tracking(trk_params); + tracking_sptr_ = dll_pll_veml_make_tracking(config_params()); DLOG(INFO) << "tracking(" << tracking_sptr_->unique_id() << ")"; } else { - item_size_ = 0; + set_item_size(0); tracking_sptr_ = nullptr; - LOG(WARNING) << trk_params.item_type << " unknown tracking item type."; - } - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; + LOG(WARNING) << config_params().item_type << " unknown tracking item type."; } } - - -void GpsL2MDllPllTracking::stop_tracking() -{ - tracking_sptr_->stop_tracking(); -} - - -void GpsL2MDllPllTracking::start_tracking() -{ - tracking_sptr_->start_tracking(); -} - - -/* - * Set tracking channel unique ID - */ -void GpsL2MDllPllTracking::set_channel(unsigned int channel) -{ - channel_ = channel; - tracking_sptr_->set_channel(channel); -} - - -void GpsL2MDllPllTracking::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) -{ - tracking_sptr_->set_gnss_synchro(p_gnss_synchro); -} - - -void GpsL2MDllPllTracking::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to connect, now the tracking uses gr_sync_decimator -} - - -void GpsL2MDllPllTracking::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to disconnect, now the tracking uses gr_sync_decimator -} - - -gr::basic_block_sptr GpsL2MDllPllTracking::get_left_block() -{ - return tracking_sptr_; -} - - -gr::basic_block_sptr GpsL2MDllPllTracking::get_right_block() -{ - return tracking_sptr_; -} diff --git a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking.h b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking.h index 9edf23fd0..0b2eda166 100644 --- a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking.h +++ b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking.h @@ -1,7 +1,7 @@ /*! * \file gps_l2_m_dll_pll_tracking.h * \brief Interface of an adapter of a DLL+PLL tracking loop block - * for GPS L1 C/A to a TrackingInterface + * for GPS L2C(M) to a TrackingInterface * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com * Javier Arribas, 2011. jarribas(at)cttc.es * @@ -24,78 +24,37 @@ #ifndef GNSS_SDR_GPS_L2_M_DLL_PLL_TRACKING_H #define GNSS_SDR_GPS_L2_M_DLL_PLL_TRACKING_H -#include "dll_pll_veml_tracking.h" -#include "tracking_interface.h" -#include +#include "base_dll_pll_tracking.h" /** \addtogroup Tracking + * Classes for GNSS signal tracking. * \{ */ -/** \addtogroup Tracking_adapters +/** \addtogroup Tracking_adapters tracking_adapters + * Wrap GNU Radio blocks for GNSS signal tracking with a TrackingInterface * \{ */ - -class ConfigurationInterface; - /*! * \brief This class implements a code DLL + carrier PLL tracking loop + * block adapter for GPS L2C(M) signals */ -class GpsL2MDllPllTracking : public TrackingInterface +class GpsL2MDllPllTracking : public BaseDllPllTracking { public: - GpsL2MDllPllTracking( - const ConfigurationInterface* configuration, + //! Constructor + GpsL2MDllPllTracking(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams); - ~GpsL2MDllPllTracking() = default; - - inline std::string role() override - { - return role_; - } - //! Returns "GPS_L2_M_DLL_PLL_Tracking" inline std::string implementation() override { return "GPS_L2_M_DLL_PLL_Tracking"; } - inline size_t item_size() override - { - return item_size_; - } - - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - /*! - * \brief Set tracking channel unique ID - */ - void set_channel(unsigned int channel) override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - - void start_tracking() override; - - /*! - * \brief Stop running tracking - */ - void stop_tracking() override; - private: - dll_pll_veml_tracking_sptr tracking_sptr_; - std::string role_; - size_t item_size_; - unsigned int channel_; - unsigned int in_streams_; - unsigned int out_streams_; + void configure_tracking_parameters(const ConfigurationInterface* configuration) override; + void create_tracking_block() override; }; diff --git a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.cc index 0d0fa843a..0d308bea5 100644 --- a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.cc @@ -25,11 +25,7 @@ #include "GPS_L2C.h" #include "configuration_interface.h" #include "display.h" -#include "dll_pll_conf_fpga.h" -#include "gnss_sdr_flags.h" -#include "gnss_synchro.h" #include "gps_l2c_signal_replica.h" -#include "uio_fpga.h" #include #include #include @@ -47,69 +43,89 @@ GpsL2MDllPllTrackingFpga::GpsL2MDllPllTrackingFpga( const std::string& role, unsigned int in_streams, unsigned int out_streams) - : role_(role), - channel_(0), - in_streams_(in_streams), - out_streams_(out_streams) + : BaseDllPllTrackingFpga(configuration, role, in_streams, out_streams) { - Dll_Pll_Conf_Fpga trk_params_fpga = Dll_Pll_Conf_Fpga(); - trk_params_fpga.SetFromConfiguration(configuration, role_); + // ------------------------------------------------------------------------- + // Adjust configuration parameters + // ------------------------------------------------------------------------- + const auto vector_length = static_cast( + std::round(static_cast(config_params_fpga().fs_in) / + (static_cast(GPS_L2_M_CODE_RATE_CPS) / + static_cast(GPS_L2_M_CODE_LENGTH_CHIPS)))); + config_params_fpga().vector_length = vector_length; - const auto vector_length = static_cast(std::round(static_cast(trk_params_fpga.fs_in) / (static_cast(GPS_L2_M_CODE_RATE_CPS) / static_cast(GPS_L2_M_CODE_LENGTH_CHIPS)))); - trk_params_fpga.vector_length = vector_length; - trk_params_fpga.extend_correlation_symbols = configuration->property(role_ + ".extend_correlation_symbols", 1); - if (trk_params_fpga.extend_correlation_symbols != 1) + config_params_fpga().extend_correlation_symbols = + configuration->property(role + ".extend_correlation_symbols", 1); + + if (config_params_fpga().extend_correlation_symbols != 1) { - trk_params_fpga.extend_correlation_symbols = 1; - std::cout << TEXT_RED << "WARNING: Extended coherent integration is not allowed in GPS L2. Coherent integration has been set to 20 ms (1 symbol)" << TEXT_RESET << '\n'; + config_params_fpga().extend_correlation_symbols = 1; + std::cout << TEXT_RED + << "WARNING: Extended coherent integration is not supported in GPS L2. " + << "Coherent integration set to 20 ms (1 symbol)." + << TEXT_RESET << '\n'; } - trk_params_fpga.track_pilot = configuration->property(role_ + ".track_pilot", false); - if (trk_params_fpga.track_pilot) + config_params_fpga().track_pilot = + configuration->property(role + ".track_pilot", false); + if (config_params_fpga().track_pilot) { - trk_params_fpga.track_pilot = false; - std::cout << TEXT_RED << "WARNING: GPS L2 does not have pilot signal. Data tracking has been enabled" << TEXT_RESET << '\n'; + config_params_fpga().track_pilot = false; + std::cout << TEXT_RED + << "WARNING: GPS L2M does not have a pilot signal. Data tracking enabled." + << TEXT_RESET << '\n'; } - trk_params_fpga.system = 'G'; + + config_params_fpga().system = 'G'; const std::array sig{'2', 'S', '\0'}; - std::copy_n(sig.data(), 3, trk_params_fpga.signal); + std::copy_n(sig.data(), 3, config_params_fpga().signal); - // UIO device file - device_name_ = configuration->property(role_ + ".devicename", default_device_name_GPS_L2); + // ------------------------------------------------------------------------- + // Configure FPGA device name + // ------------------------------------------------------------------------- + device_name_ = configuration->property(role + ".devicename", default_device_name_GPS_L2); - // compute the number of tracking channels that have already been instantiated. The order in which - // GNSS-SDR instantiates the tracking channels i L1, L2, L5, E1, E5a - num_prev_assigned_ch_ = configuration->property("Channels_1C.count", 0); + // Compute number of previously assigned channels (L1) + set_num_prev_assigned_ch(configuration->property("Channels_1C.count", 0)); - // ################# PRE-COMPUTE ALL THE CODES ################# - volk_gnsssdr::vector ca_codes_f(static_cast(GPS_L2_M_CODE_LENGTH_CHIPS), 0.0); - prn_codes_ptr_ = static_cast(volk_gnsssdr_malloc(static_cast(GPS_L2_M_CODE_LENGTH_CHIPS * NUM_PRNs) * sizeof(int), volk_gnsssdr_get_alignment())); - for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++) + // ------------------------------------------------------------------------- + // Precompute local PRN codes + // ------------------------------------------------------------------------- + const uint32_t NUM_PRNs = 32; + const auto code_length_chips = static_cast(GPS_L2_M_CODE_LENGTH_CHIPS); + + volk_gnsssdr::vector ca_codes_f(code_length_chips, 0.0F); + prn_codes_ptr_ = static_cast( + volk_gnsssdr_malloc(code_length_chips * NUM_PRNs * sizeof(int32_t), + volk_gnsssdr_get_alignment())); + + for (uint32_t prn = 1; prn <= NUM_PRNs; ++prn) { - gps_l2c_m_code_gen_float(ca_codes_f, PRN); - for (unsigned int s = 0; s < 2 * static_cast(GPS_L2_M_CODE_LENGTH_CHIPS); s++) + gps_l2c_m_code_gen_float(ca_codes_f, prn); + for (uint32_t s = 0; s < code_length_chips; ++s) { - prn_codes_ptr_[static_cast(GPS_L2_M_CODE_LENGTH_CHIPS) * (PRN - 1) + s] = static_cast(ca_codes_f[s]); + int32_t bit_val = (ca_codes_f[s] < 0.0F) ? 0 : 1; + bit_val |= LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY; + prn_codes_ptr_[code_length_chips * (prn - 1) + s] = bit_val; } } - trk_params_fpga.ca_codes = prn_codes_ptr_; - trk_params_fpga.code_length_chips = GPS_L2_M_CODE_LENGTH_CHIPS; - trk_params_fpga.code_samples_per_chip = 1; // 1 sample per chip + // ------------------------------------------------------------------------- + // Assign FPGA tracking configuration + // ------------------------------------------------------------------------- + config_params_fpga().ca_codes = prn_codes_ptr_; + config_params_fpga().data_codes = nullptr; + config_params_fpga().code_length_chips = GPS_L2_M_CODE_LENGTH_CHIPS; + config_params_fpga().code_samples_per_chip = 1; + config_params_fpga().extended_correlation_in_fpga = false; + config_params_fpga().extend_fpga_integration_periods = 1; + config_params_fpga().fpga_integration_period = 1; - // ################# MAKE TRACKING GNU Radio object ################### - DLOG(INFO) << "role " << role_; - tracking_fpga_sc_sptr_ = dll_pll_veml_make_tracking_fpga(trk_params_fpga); + // ------------------------------------------------------------------------- + // Create GNU Radio FPGA tracking block + // ------------------------------------------------------------------------- + tracking_fpga_sc_sptr_ = dll_pll_veml_make_tracking_fpga(config_params_fpga()); DLOG(INFO) << "tracking(" << tracking_fpga_sc_sptr_->unique_id() << ")"; - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; - } } @@ -117,71 +133,3 @@ GpsL2MDllPllTrackingFpga::~GpsL2MDllPllTrackingFpga() { volk_gnsssdr_free(prn_codes_ptr_); } - - -void GpsL2MDllPllTrackingFpga::start_tracking() -{ - tracking_fpga_sc_sptr_->start_tracking(); -} - - -void GpsL2MDllPllTrackingFpga::stop_tracking() -{ - tracking_fpga_sc_sptr_->stop_tracking(); -} - - -/* - * Set tracking channel unique ID - */ -void GpsL2MDllPllTrackingFpga::set_channel(unsigned int channel) -{ - channel_ = channel; - - // UIO device file - std::string device_io_name; - // find the uio device file corresponding to the tracking multicorrelator - if (find_uio_dev_file_name(device_io_name, device_name_, channel_ - num_prev_assigned_ch_) < 0) - { - std::cout << "Cannot find the FPGA uio device file corresponding to device name " << device_name_ << std::endl; - throw std::exception(); - } - - tracking_fpga_sc_sptr_->set_channel(channel_, device_io_name); -} - - -void GpsL2MDllPllTrackingFpga::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) -{ - tracking_fpga_sc_sptr_->set_gnss_synchro(p_gnss_synchro); -} - - -void GpsL2MDllPllTrackingFpga::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to connect -} - - -void GpsL2MDllPllTrackingFpga::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to disconnect -} - - -gr::basic_block_sptr GpsL2MDllPllTrackingFpga::get_left_block() -{ - return tracking_fpga_sc_sptr_; -} - - -gr::basic_block_sptr GpsL2MDllPllTrackingFpga::get_right_block() -{ - return tracking_fpga_sc_sptr_; -} diff --git a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.h index a89dd5d55..02fd31947 100644 --- a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.h @@ -23,89 +23,44 @@ #ifndef GNSS_SDR_GPS_L2_M_DLL_PLL_TRACKING_FPGA_H #define GNSS_SDR_GPS_L2_M_DLL_PLL_TRACKING_FPGA_H -#include "dll_pll_veml_tracking_fpga.h" -#include "tracking_interface.h" -#include -#include -#include +#include "base_dll_pll_tracking_fpga.h" -/** \addtogroup Tracking - * \{ */ -/** \addtogroup Tracking_adapters - * \{ */ - - -class Gnss_Synchro; -class ConfigurationInterface; +//** \addtogroup Tracking +// * \{ */ +// /** \addtogroup Tracking_adapters +// * \{ */ /*! - * \brief This class implements a code DLL + carrier PLL tracking loop + * \brief Adapter for a GPS L2M DLL+PLL tracking loop implemented in FPGA */ -class GpsL2MDllPllTrackingFpga : public TrackingInterface +class GpsL2MDllPllTrackingFpga : public BaseDllPllTrackingFpga { public: - GpsL2MDllPllTrackingFpga( - const ConfigurationInterface* configuration, + /*! + * \brief Constructor + */ + GpsL2MDllPllTrackingFpga(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams); - virtual ~GpsL2MDllPllTrackingFpga(); + /*! + * \brief Destructor + */ + ~GpsL2MDllPllTrackingFpga() override; - inline std::string role() override - { - return role_; - } - - //! Returns "GPS_L2_M_DLL_PLL_Tracking_FPGA" - inline std::string implementation() override + /*! + * \brief Returns "GPS_L2_M_DLL_PLL_Tracking_FPGA" + */ + std::string implementation() override { return "GPS_L2_M_DLL_PLL_Tracking_FPGA"; } - inline size_t item_size() override - { - return sizeof(int); - } - - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - /*! - * \brief Set tracking channel unique ID - */ - void set_channel(unsigned int channel) override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - - void start_tracking() override; - - /*! - * \brief Stop running tracking - */ - void stop_tracking() override; - private: - const std::string default_device_name_GPS_L2 = "multicorrelator_resampler_S00_AXI"; // UIO device name - static const uint32_t NUM_PRNs = 32; - - dll_pll_veml_tracking_fpga_sptr tracking_fpga_sc_sptr_; - std::string role_; - std::string device_name_; - int* prn_codes_ptr_; - uint32_t num_prev_assigned_ch_; - unsigned int channel_; - unsigned int in_streams_; - unsigned int out_streams_; + int32_t* prn_codes_ptr_; // Pointer to local PRN codes }; - -/** \} */ -/** \} */ +// /** \} */ +// /** \} */ #endif // GNSS_SDR_GPS_L2_M_DLL_PLL_TRACKING_FPGA_H diff --git a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking.cc index fddc9d8c2..e9e98783c 100644 --- a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking.cc +++ b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking.cc @@ -24,8 +24,6 @@ #include "GPS_L5.h" #include "configuration_interface.h" #include "display.h" -#include "dll_pll_conf.h" -#include "gnss_sdr_flags.h" #include #include @@ -40,113 +38,50 @@ GpsL5DllPllTracking::GpsL5DllPllTracking( const std::string& role, unsigned int in_streams, unsigned int out_streams) - : role_(role), - item_size_(sizeof(gr_complex)), - channel_(0), - in_streams_(in_streams), - out_streams_(out_streams) + : BaseDllPllTracking(configuration, role, in_streams, out_streams) { - Dll_Pll_Conf trk_params = Dll_Pll_Conf(); - trk_params.SetFromConfiguration(configuration, role_); + configure_tracking_parameters(configuration); + create_tracking_block(); +} - const auto vector_length = static_cast(std::round(static_cast(trk_params.fs_in) / (static_cast(GPS_L5I_CODE_RATE_CPS) / static_cast(GPS_L5I_CODE_LENGTH_CHIPS)))); - trk_params.vector_length = vector_length; - if (trk_params.extend_correlation_symbols < 1) + +void GpsL5DllPllTracking::configure_tracking_parameters( + const ConfigurationInterface* configuration __attribute__((unused))) +{ + const auto vector_length = static_cast(std::round(static_cast(config_params().fs_in) / (static_cast(GPS_L5I_CODE_RATE_CPS) / static_cast(GPS_L5I_CODE_LENGTH_CHIPS)))); + config_params().vector_length = vector_length; + if (config_params().extend_correlation_symbols < 1) { - trk_params.extend_correlation_symbols = 1; + config_params().extend_correlation_symbols = 1; std::cout << TEXT_RED << "WARNING: GPS L5. extend_correlation_symbols must be bigger than 0. Coherent integration has been set to 1 symbol (1 ms)" << TEXT_RESET << '\n'; } - else if (!trk_params.track_pilot and trk_params.extend_correlation_symbols > GPS_L5I_NH_CODE_LENGTH) + else if (!config_params().track_pilot and config_params().extend_correlation_symbols > GPS_L5I_NH_CODE_LENGTH) { - trk_params.extend_correlation_symbols = GPS_L5I_NH_CODE_LENGTH; + config_params().extend_correlation_symbols = GPS_L5I_NH_CODE_LENGTH; std::cout << TEXT_RED << "WARNING: GPS L5. extend_correlation_symbols must be lower than 11 when tracking the data component. Coherent integration has been set to 10 symbols (10 ms)" << TEXT_RESET << '\n'; } - if ((trk_params.extend_correlation_symbols > 1) and (trk_params.pll_bw_narrow_hz > trk_params.pll_bw_hz or trk_params.dll_bw_narrow_hz > trk_params.dll_bw_hz)) + if ((config_params().extend_correlation_symbols > 1) and (config_params().pll_bw_narrow_hz > config_params().pll_bw_hz or config_params().dll_bw_narrow_hz > config_params().dll_bw_hz)) { std::cout << TEXT_RED << "WARNING: GPS L5. PLL or DLL narrow tracking bandwidth is higher than wide tracking one" << TEXT_RESET << '\n'; } - trk_params.system = 'G'; + config_params().system = 'G'; const std::array sig{'L', '5', '\0'}; - std::copy_n(sig.data(), 3, trk_params.signal); + std::copy_n(sig.data(), 3, config_params().signal); +} + +void GpsL5DllPllTracking::create_tracking_block() +{ // ################# Make a GNU Radio Tracking block object ################ - DLOG(INFO) << "role " << role_; - if (trk_params.item_type == "gr_complex") + if (config_params().item_type == "gr_complex") { - tracking_sptr_ = dll_pll_veml_make_tracking(trk_params); + tracking_sptr_ = dll_pll_veml_make_tracking(config_params()); DLOG(INFO) << "tracking(" << tracking_sptr_->unique_id() << ")"; } else { - item_size_ = 0; + set_item_size(0); tracking_sptr_ = nullptr; - LOG(WARNING) << trk_params.item_type << " unknown tracking item type."; - } - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; + LOG(WARNING) << config_params().item_type << " unknown tracking item type."; } } - - -void GpsL5DllPllTracking::stop_tracking() -{ - tracking_sptr_->stop_tracking(); -} - - -void GpsL5DllPllTracking::start_tracking() -{ - tracking_sptr_->start_tracking(); -} - - -/* - * Set tracking channel unique ID - */ -void GpsL5DllPllTracking::set_channel(unsigned int channel) -{ - channel_ = channel; - tracking_sptr_->set_channel(channel); -} - - -void GpsL5DllPllTracking::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) -{ - tracking_sptr_->set_gnss_synchro(p_gnss_synchro); -} - - -void GpsL5DllPllTracking::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to connect, now the tracking uses gr_sync_decimator -} - - -void GpsL5DllPllTracking::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to disconnect, now the tracking uses gr_sync_decimator -} - - -gr::basic_block_sptr GpsL5DllPllTracking::get_left_block() -{ - return tracking_sptr_; -} - - -gr::basic_block_sptr GpsL5DllPllTracking::get_right_block() -{ - return tracking_sptr_; -} diff --git a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking.h b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking.h index 6aad72305..110fe4c1f 100644 --- a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking.h +++ b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking.h @@ -23,81 +23,40 @@ #ifndef GNSS_SDR_GPS_L5_DLL_PLL_TRACKING_H #define GNSS_SDR_GPS_L5_DLL_PLL_TRACKING_H -#include "dll_pll_veml_tracking.h" -#include "tracking_interface.h" -#include +#include "base_dll_pll_tracking.h" /** \addtogroup Tracking + * Classes for GNSS signal tracking. * \{ */ -/** \addtogroup Tracking_adapters +/** \addtogroup Tracking_adapters tracking_adapters + * Wrap GNU Radio blocks for GNSS signal tracking with a TrackingInterface * \{ */ -class ConfigurationInterface; - /*! * \brief This class implements a code DLL + carrier PLL tracking loop + * block adapter for GPS L5 signals */ -class GpsL5DllPllTracking : public TrackingInterface +class GpsL5DllPllTracking : public BaseDllPllTracking { public: - GpsL5DllPllTracking( - const ConfigurationInterface* configuration, + //! Constructor + GpsL5DllPllTracking(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams); - ~GpsL5DllPllTracking() = default; - - inline std::string role() override - { - return role_; - } - //! Returns "GPS_L5_DLL_PLL_Tracking" inline std::string implementation() override { return "GPS_L5_DLL_PLL_Tracking"; } - inline size_t item_size() override - { - return item_size_; - } - - void connect(gr::top_block_sptr top_block) override; - void disconnect(gr::top_block_sptr top_block) override; - gr::basic_block_sptr get_left_block() override; - gr::basic_block_sptr get_right_block() override; - - /*! - * \brief Set tracking channel unique ID - */ - void set_channel(unsigned int channel) override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - - void start_tracking() override; - - /*! - * \brief Stop running tracking - */ - void stop_tracking() override; - private: - dll_pll_veml_tracking_sptr tracking_sptr_; - std::string role_; - size_t item_size_; - unsigned int channel_; - unsigned int in_streams_; - unsigned int out_streams_; + void configure_tracking_parameters(const ConfigurationInterface* configuration) override; + void create_tracking_block() override; }; - /** \} */ /** \} */ #endif // GNSS_SDR_GPS_L5_DLL_PLL_TRACKING_H diff --git a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc index 2020ef042..adf29a6cf 100644 --- a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc @@ -26,10 +26,7 @@ #include "GPS_L5.h" #include "configuration_interface.h" #include "display.h" -#include "dll_pll_conf_fpga.h" -#include "gnss_sdr_flags.h" #include "gps_l5_signal_replica.h" -#include "uio_fpga.h" #include #include #include @@ -40,164 +37,164 @@ #include #endif + GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( - const ConfigurationInterface *configuration, - const std::string &role, + const ConfigurationInterface* configuration, + const std::string& role, unsigned int in_streams, unsigned int out_streams) - : role_(role), + : BaseDllPllTrackingFpga(configuration, role, in_streams, out_streams), data_codes_ptr_(nullptr), - channel_(0), - in_streams_(in_streams), - out_streams_(out_streams) + track_pilot_(false) { - Dll_Pll_Conf_Fpga trk_params_fpga = Dll_Pll_Conf_Fpga(); - trk_params_fpga.SetFromConfiguration(configuration, role_); + // ------------------------------------------------------------------------- + // Adjust configuration parameters + // ------------------------------------------------------------------------- + const auto vector_length = static_cast( + std::round(static_cast(config_params_fpga().fs_in) / + (static_cast(GPS_L5I_CODE_RATE_CPS) / + static_cast(GPS_L5I_CODE_LENGTH_CHIPS)))); + config_params_fpga().vector_length = vector_length; - const auto vector_length = static_cast(std::round(static_cast(trk_params_fpga.fs_in) / (static_cast(GPS_L5I_CODE_RATE_CPS) / static_cast(GPS_L5I_CODE_LENGTH_CHIPS)))); - trk_params_fpga.vector_length = vector_length; - if (trk_params_fpga.extend_correlation_symbols < 1) + if (config_params_fpga().extend_correlation_symbols < 1) { - trk_params_fpga.extend_correlation_symbols = 1; - std::cout << TEXT_RED << "WARNING: GPS L5. extend_correlation_symbols must be bigger than 0. Coherent integration has been set to 1 symbol (1 ms)" << TEXT_RESET << '\n'; + config_params_fpga().extend_correlation_symbols = 1; + std::cout << TEXT_RED + << "WARNING: GPS L5. extend_correlation_symbols must be >= 1. " + << "Coherent integration set to 1 symbol (1 ms)." + << TEXT_RESET << '\n'; } - else if (!trk_params_fpga.track_pilot and trk_params_fpga.extend_correlation_symbols > GPS_L5I_NH_CODE_LENGTH) + else if (!config_params_fpga().track_pilot && + config_params_fpga().extend_correlation_symbols > GPS_L5I_NH_CODE_LENGTH) { - trk_params_fpga.extend_correlation_symbols = GPS_L5I_NH_CODE_LENGTH; - std::cout << TEXT_RED << "WARNING: GPS L5. extend_correlation_symbols must be lower than 11 when tracking the data component. Coherent integration has been set to 10 symbols (10 ms)" << TEXT_RESET << '\n'; + config_params_fpga().extend_correlation_symbols = GPS_L5I_NH_CODE_LENGTH; + std::cout << TEXT_RED + << "WARNING: GPS L5. extend_correlation_symbols must be <= 10 when tracking " + << "the data component. Set to 10 symbols (10 ms)." + << TEXT_RESET << '\n'; } - if ((trk_params_fpga.extend_correlation_symbols > 1) and (trk_params_fpga.pll_bw_narrow_hz > trk_params_fpga.pll_bw_hz or trk_params_fpga.dll_bw_narrow_hz > trk_params_fpga.dll_bw_hz)) + + if ((config_params_fpga().extend_correlation_symbols > 1) && + (config_params_fpga().pll_bw_narrow_hz > config_params_fpga().pll_bw_hz || + config_params_fpga().dll_bw_narrow_hz > config_params_fpga().dll_bw_hz)) { - std::cout << TEXT_RED << "WARNING: GPS L5. PLL or DLL narrow tracking bandwidth is higher than wide tracking one" << TEXT_RESET << '\n'; + std::cout << TEXT_RED + << "WARNING: GPS L5. PLL/DLL narrow bandwidth larger than wide one." + << TEXT_RESET << '\n'; } - track_pilot_ = trk_params_fpga.track_pilot; - trk_params_fpga.system = 'G'; + + track_pilot_ = config_params_fpga().track_pilot; + config_params_fpga().system = 'G'; const std::array sig{'L', '5', '\0'}; - std::copy_n(sig.data(), 3, trk_params_fpga.signal); + std::copy_n(sig.data(), 3, config_params_fpga().signal); - // UIO device file - device_name_ = configuration->property(role_ + ".devicename", default_device_name_GPS_L5_); + // ------------------------------------------------------------------------- + // Configure FPGA device name + // ------------------------------------------------------------------------- + device_name_ = configuration->property(role + ".devicename", default_device_name_GPS_L5); - // compute the number of tracking channels that have already been instantiated. The order in which - // GNSS-SDR instantiates the tracking channels i L1, L2, L5, E1, E5a - - uint32_t num_prev_assigned_ch_1C = configuration->property("Channels_1C.count", 0); + // Compute number of previously assigned channels (L1 + L2) + const uint32_t num_prev_assigned_ch_1C = configuration->property("Channels_1C.count", 0); uint32_t num_prev_assigned_ch_2S = 0; if (configuration->property("Tracking_2S.devicename", std::string("")) != device_name_) { num_prev_assigned_ch_2S = configuration->property("Channels_2S.count", 0); } - num_prev_assigned_ch_ = num_prev_assigned_ch_1C + num_prev_assigned_ch_2S; + set_num_prev_assigned_ch(num_prev_assigned_ch_1C + num_prev_assigned_ch_2S); - // ################# PRE-COMPUTE ALL THE CODES ################# - uint32_t code_samples_per_chip = 1; - auto code_length_chips = static_cast(GPS_L5I_CODE_LENGTH_CHIPS); + // ------------------------------------------------------------------------- + // Precompute local PRN codes (pilot/data) + // ------------------------------------------------------------------------- + const uint32_t NUM_PRNs = 32; + const auto code_length_chips = static_cast(GPS_L5I_CODE_LENGTH_CHIPS); + volk_gnsssdr::vector tracking_code(code_length_chips, 0.0F); volk_gnsssdr::vector data_code; - volk_gnsssdr::vector tracking_code(code_length_chips, 0.0); if (track_pilot_) { - data_code.resize(code_length_chips, 0.0); + data_code.resize(code_length_chips, 0.0F); } - prn_codes_ptr_ = static_cast(volk_gnsssdr_malloc(static_cast(code_length_chips * NUM_PRNs) * sizeof(int32_t), volk_gnsssdr_get_alignment())); + prn_codes_ptr_ = static_cast( + volk_gnsssdr_malloc(code_length_chips * NUM_PRNs * sizeof(int32_t), + volk_gnsssdr_get_alignment())); if (track_pilot_) { - data_codes_ptr_ = static_cast(volk_gnsssdr_malloc((static_cast(code_length_chips)) * NUM_PRNs * sizeof(int32_t), volk_gnsssdr_get_alignment())); + data_codes_ptr_ = static_cast( + volk_gnsssdr_malloc(code_length_chips * NUM_PRNs * sizeof(int32_t), + volk_gnsssdr_get_alignment())); } - for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++) + for (uint32_t prn = 1; prn <= NUM_PRNs; ++prn) { if (track_pilot_) { - gps_l5q_code_gen_float(tracking_code, PRN); - gps_l5i_code_gen_float(data_code, PRN); + gps_l5q_code_gen_float(tracking_code, prn); + gps_l5i_code_gen_float(data_code, prn); - // The code is generated as a series of 1s and -1s. In order to store the values using only one bit, a -1 is stored as a 0 in the FPGA - for (uint32_t s = 0; s < code_length_chips; s++) + for (uint32_t s = 0; s < code_length_chips; ++s) { - auto tmp_value = static_cast(tracking_code[s]); - if (tmp_value < 0) - { - tmp_value = 0; - } - tmp_value = tmp_value | LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY; - prn_codes_ptr_[static_cast(code_length_chips) * (PRN - 1) + s] = tmp_value; + int32_t pilot_val = (tracking_code[s] < 0.0F) ? 0 : 1; + pilot_val |= LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY; + prn_codes_ptr_[code_length_chips * (prn - 1) + s] = pilot_val; - tmp_value = static_cast(data_code[s]); - if (tmp_value < 0) - { - tmp_value = 0; - } - tmp_value = tmp_value | LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY | LOCAL_CODE_FPGA_CORRELATOR_SELECT_COUNT; - data_codes_ptr_[static_cast(code_length_chips) * (PRN - 1) + s] = tmp_value; + int32_t data_val = (data_code[s] < 0.0F) ? 0 : 1; + data_val |= LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY | + LOCAL_CODE_FPGA_CORRELATOR_SELECT_COUNT; + data_codes_ptr_[code_length_chips * (prn - 1) + s] = data_val; } } else { - gps_l5i_code_gen_float(tracking_code, PRN); - - // The code is generated as a series of 1s and -1s. In order to store the values using only one bit, a -1 is stored as a 0 in the FPGA - for (uint32_t s = 0; s < code_length_chips; s++) + gps_l5i_code_gen_float(tracking_code, prn); + for (uint32_t s = 0; s < code_length_chips; ++s) { - auto tmp_value = static_cast(tracking_code[s]); - if (tmp_value < 0) - { - tmp_value = 0; - } - tmp_value = tmp_value | LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY; - prn_codes_ptr_[static_cast(code_length_chips) * (PRN - 1) + s] = tmp_value; + int32_t tmp_val = (tracking_code[s] < 0.0F) ? 0 : 1; + tmp_val |= LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY; + prn_codes_ptr_[code_length_chips * (prn - 1) + s] = tmp_val; } } } - trk_params_fpga.ca_codes = prn_codes_ptr_; - trk_params_fpga.data_codes = data_codes_ptr_; - trk_params_fpga.code_length_chips = code_length_chips; - trk_params_fpga.code_samples_per_chip = code_samples_per_chip; // 2 sample per chip + // ------------------------------------------------------------------------- + // Assign FPGA tracking configuration + // ------------------------------------------------------------------------- + config_params_fpga().ca_codes = prn_codes_ptr_; + config_params_fpga().data_codes = data_codes_ptr_; + config_params_fpga().code_length_chips = code_length_chips; + config_params_fpga().code_samples_per_chip = 1; + config_params_fpga().extended_correlation_in_fpga = false; + config_params_fpga().extend_fpga_integration_periods = 1; + config_params_fpga().fpga_integration_period = 1; - trk_params_fpga.extended_correlation_in_fpga = false; // by default - trk_params_fpga.extend_fpga_integration_periods = 1; // (number of FPGA integrations that are combined in the SW) - trk_params_fpga.fpga_integration_period = 1; // (number of symbols that are effectively integrated in the FPGA) if (track_pilot_) { - if (trk_params_fpga.extend_correlation_symbols > 1) + const auto extend = config_params_fpga().extend_correlation_symbols; + if (extend > 1) { - if (trk_params_fpga.extend_correlation_symbols <= GPS_L5I_NH_CODE_LENGTH) + if (extend <= GPS_L5I_NH_CODE_LENGTH && + (GPS_L5I_NH_CODE_LENGTH % extend) == 0) { - if ((GPS_L5I_NH_CODE_LENGTH % trk_params_fpga.extend_correlation_symbols) == 0) - { - trk_params_fpga.extended_correlation_in_fpga = true; - trk_params_fpga.fpga_integration_period = trk_params_fpga.extend_correlation_symbols; - } + config_params_fpga().extended_correlation_in_fpga = true; + config_params_fpga().fpga_integration_period = extend; } - else + else if (extend % GPS_L5I_NH_CODE_LENGTH == 0) { - if (trk_params_fpga.extend_correlation_symbols % GPS_L5I_NH_CODE_LENGTH == 0) - { - trk_params_fpga.extended_correlation_in_fpga = true; - trk_params_fpga.extend_fpga_integration_periods = trk_params_fpga.extend_correlation_symbols / GPS_L5I_NH_CODE_LENGTH; - trk_params_fpga.fpga_integration_period = GPS_L5I_NH_CODE_LENGTH; - } + config_params_fpga().extended_correlation_in_fpga = true; + config_params_fpga().extend_fpga_integration_periods = + extend / GPS_L5I_NH_CODE_LENGTH; + config_params_fpga().fpga_integration_period = GPS_L5I_NH_CODE_LENGTH; } } } - // ################# MAKE TRACKING GNU Radio object ################### - DLOG(INFO) << "role " << role_; - tracking_fpga_sc_sptr_ = dll_pll_veml_make_tracking_fpga(trk_params_fpga); + // ------------------------------------------------------------------------- + // Create GNU Radio FPGA tracking block + // ------------------------------------------------------------------------- + tracking_fpga_sc_sptr_ = dll_pll_veml_make_tracking_fpga(config_params_fpga()); DLOG(INFO) << "tracking(" << tracking_fpga_sc_sptr_->unique_id() << ")"; - - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; - } } @@ -209,71 +206,3 @@ GpsL5DllPllTrackingFpga::~GpsL5DllPllTrackingFpga() volk_gnsssdr_free(data_codes_ptr_); } } - - -void GpsL5DllPllTrackingFpga::start_tracking() -{ - tracking_fpga_sc_sptr_->start_tracking(); -} - - -void GpsL5DllPllTrackingFpga::stop_tracking() -{ - tracking_fpga_sc_sptr_->stop_tracking(); -} - - -/* - * Set tracking channel unique ID - */ -void GpsL5DllPllTrackingFpga::set_channel(unsigned int channel) -{ - channel_ = channel; - - // UIO device file - std::string device_io_name; - // find the uio device file corresponding to the tracking multicorrelator - if (find_uio_dev_file_name(device_io_name, device_name_, channel_ - num_prev_assigned_ch_) < 0) - { - std::cout << "Cannot find the FPGA uio device file corresponding to device name " << device_name_ << std::endl; - throw std::exception(); - } - - tracking_fpga_sc_sptr_->set_channel(channel_, device_io_name); -} - - -void GpsL5DllPllTrackingFpga::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) -{ - tracking_fpga_sc_sptr_->set_gnss_synchro(p_gnss_synchro); -} - - -void GpsL5DllPllTrackingFpga::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to connect, now the tracking uses gr_sync_decimator -} - - -void GpsL5DllPllTrackingFpga::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to disconnect, now the tracking uses gr_sync_decimator -} - - -gr::basic_block_sptr GpsL5DllPllTrackingFpga::get_left_block() -{ - return tracking_fpga_sc_sptr_; -} - - -gr::basic_block_sptr GpsL5DllPllTrackingFpga::get_right_block() -{ - return tracking_fpga_sc_sptr_; -} diff --git a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.h index ed85735b2..084587ae5 100644 --- a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.h @@ -24,29 +24,23 @@ #ifndef GNSS_SDR_GPS_L5_DLL_PLL_TRACKING_FPGA_H #define GNSS_SDR_GPS_L5_DLL_PLL_TRACKING_FPGA_H -#include "dll_pll_veml_tracking_fpga.h" -#include "tracking_interface.h" -#include +#include "base_dll_pll_tracking_fpga.h" -/** \addtogroup Tracking - * \{ */ -/** \addtogroup Tracking_adapters - * \{ */ - - -class ConfigurationInterface; +// /** \addtogroup Tracking +// * \{ */ +// /** \addtogroup Tracking_adapters +// * \{ */ /*! - * \brief This class implements a code DLL + carrier PLL tracking loop + * \brief Adapter for a GPS L5 DLL+PLL tracking loop for FPGA devices */ -class GpsL5DllPllTrackingFpga : public TrackingInterface +class GpsL5DllPllTrackingFpga : public BaseDllPllTrackingFpga { public: /*! * \brief Constructor */ - GpsL5DllPllTrackingFpga( - const ConfigurationInterface* configuration, + GpsL5DllPllTrackingFpga(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams); @@ -54,96 +48,25 @@ public: /*! * \brief Destructor */ - virtual ~GpsL5DllPllTrackingFpga(); - - /*! - * \brief Role - */ - inline std::string role() override - { - return role_; - } + ~GpsL5DllPllTrackingFpga() override; /*! * \brief Returns "GPS_L5_DLL_PLL_Tracking_FPGA" */ - inline std::string implementation() override + std::string implementation() override { return "GPS_L5_DLL_PLL_Tracking_FPGA"; } - /*! - * \brief Returns size of lv_16sc_t - */ - size_t item_size() override - { - return sizeof(int16_t); - } - - /*! - * \brief Connect - */ - void connect(gr::top_block_sptr top_block) override; - - /*! - * \brief Disconnect - */ - void disconnect(gr::top_block_sptr top_block) override; - - /*! - * \brief Get left block - */ - gr::basic_block_sptr get_left_block() override; - - /*! - * \brief Get right block - */ - gr::basic_block_sptr get_right_block() override; - - /*! - * \brief Set tracking channel unique ID - */ - void set_channel(unsigned int channel) override; - - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; - - /*! - * \brief Start the tracking process in the FPGA - */ - void start_tracking() override; - - /*! - * \brief Stop the tracking process in the FPGA - */ - void stop_tracking() override; - private: - const std::string default_device_name_GPS_L5_ = "multicorrelator_resampler_3_1_AXI"; // UIO device name - - static const uint32_t NUM_PRNs = 32; // total number of PRNs - - // the following flags are FPGA-specific and they are using arrange the values of the local code in the way the FPGA - // expects. This arrangement is done in the initialisation to avoid consuming unnecessary clock cycles during tracking. - static const int32_t LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY = 0x0C000000; // flag that enables WE (Write Enable) of the local code FPGA - static const int32_t LOCAL_CODE_FPGA_CORRELATOR_SELECT_COUNT = 0x20000000; // flag that selects the writing of the pilot code in the FPGA (as opposed to the data code) - - dll_pll_veml_tracking_fpga_sptr tracking_fpga_sc_sptr_; - std::string role_; - std::string device_name_; + // Pointer to local PRN codes (pilot/data) int32_t* prn_codes_ptr_; int32_t* data_codes_ptr_; - uint32_t channel_; - uint32_t num_prev_assigned_ch_; - uint32_t in_streams_; - uint32_t out_streams_; + + // Pilot tracking flag bool track_pilot_; }; - -/** \} */ -/** \} */ -#endif // GNSS_SDR_GPS_L5_DLL_PLL_TRACKING_FPGA_H +// /** \} */ +// /** \} */ +#endif // GNSS_SDR_GPS_L5_DLL_PLL_TRACKING_FPGA_H \ No newline at end of file diff --git a/src/core/interfaces/acquisition_interface.h b/src/core/interfaces/acquisition_interface.h index f72aabce3..618eb9344 100644 --- a/src/core/interfaces/acquisition_interface.h +++ b/src/core/interfaces/acquisition_interface.h @@ -54,15 +54,8 @@ public: virtual void set_channel(unsigned int channel_id) = 0; virtual void set_channel_fsm(std::weak_ptr channel_fsm) = 0; virtual void set_threshold(float threshold) = 0; - virtual void set_doppler_max(unsigned int doppler_max) = 0; - virtual void set_doppler_step(unsigned int doppler_step) = 0; - virtual void set_doppler_center(int doppler_center __attribute__((unused))) - { - return; - } - virtual void init() = 0; + virtual void set_doppler_center(int /*doppler_center*/) {} virtual void set_local_code() = 0; - virtual void set_state(int state) = 0; virtual signed int mag() = 0; virtual void reset() = 0; virtual void stop_acquisition() = 0; diff --git a/src/core/system_parameters/Beidou_B1I.h b/src/core/system_parameters/Beidou_B1I.h index 70f098ed7..748b82463 100644 --- a/src/core/system_parameters/Beidou_B1I.h +++ b/src/core/system_parameters/Beidou_B1I.h @@ -34,6 +34,7 @@ constexpr double BEIDOU_B1I_CODE_RATE_CPS = 2.046e6; //!< Beidou B1I code ra constexpr double BEIDOU_B1I_CODE_LENGTH_CHIPS = 2046.0; //!< Beidou B1I code length [chips] constexpr double BEIDOU_B1I_CODE_PERIOD_S = 0.001; //!< Beidou B1I code period [seconds] constexpr double BEIDOU_B1I_PREAMBLE_DURATION_S = 0.220; +constexpr double BEIDOU_B1I_OPT_ACQ_FS_SPS = 10e6; constexpr uint32_t BEIDOU_B1I_CODE_PERIOD_MS = 1; //!< Beidou B1I code period [ms] constexpr uint32_t BEIDOU_B1I_PREAMBLE_LENGTH_BITS = 11; constexpr uint32_t BEIDOU_B1I_PREAMBLE_LENGTH_SYMBOLS = 220; diff --git a/src/core/system_parameters/Beidou_B3I.h b/src/core/system_parameters/Beidou_B3I.h index d890c095e..6849645c5 100644 --- a/src/core/system_parameters/Beidou_B3I.h +++ b/src/core/system_parameters/Beidou_B3I.h @@ -33,6 +33,7 @@ constexpr double BEIDOU_B3I_CODE_RATE_CPS = 10.23e6; //!< BeiDou B3I code r constexpr double BEIDOU_B3I_CODE_LENGTH_CHIPS = 10230.0; //!< BeiDou B3I code length [chips] constexpr double BEIDOU_B3I_CODE_PERIOD_S = 0.001; //!< BeiDou B3I code period [seconds] constexpr double BEIDOU_B3I_PREAMBLE_DURATION_S = 0.220; +constexpr double BEIDOU_B3I_OPT_ACQ_FS_SPS = 10e6; constexpr uint32_t BEIDOU_B3I_CODE_PERIOD_MS = 1; //!< BeiDou B3I code period [ms] constexpr uint32_t BEIDOU_B3I_PREAMBLE_LENGTH_BITS = 11; constexpr uint32_t BEIDOU_B3I_PREAMBLE_LENGTH_SYMBOLS = 220; // ************** diff --git a/src/core/system_parameters/GLONASS_L1_L2_CA.h b/src/core/system_parameters/GLONASS_L1_L2_CA.h index 0194e78db..5106fe27d 100644 --- a/src/core/system_parameters/GLONASS_L1_L2_CA.h +++ b/src/core/system_parameters/GLONASS_L1_L2_CA.h @@ -81,6 +81,8 @@ constexpr double GLONASS_L1_CA_CODE_PERIOD_S = 0.001; //!< GLONASS L1 C/A constexpr double GLONASS_L1_CA_CHIP_PERIOD_S = 1.9569e-06; //!< GLONASS L1 C/A chip period [seconds] constexpr double GLONASS_L1_CA_SYMBOL_RATE_BPS = 1000.0; +constexpr uint32_t GLONASS_L1_CA_CODE_PEROD_MS = 1; +constexpr uint32_t GLONASS_L2_CA_CODE_PEROD_MS = 1; constexpr int32_t GLONASS_CA_NBR_SATS = 24; // STRING DATA WITHOUT PREAMBLE // OBSERVABLE HISTORY DEEP FOR INTERPOLATION diff --git a/src/core/system_parameters/GPS_L2C.h b/src/core/system_parameters/GPS_L2C.h index 88e2609fd..f9a2732d8 100644 --- a/src/core/system_parameters/GPS_L2C.h +++ b/src/core/system_parameters/GPS_L2C.h @@ -37,6 +37,7 @@ constexpr double GPS_L2_L_PERIOD_S = 1.5; //!< GPS L2 L code perio constexpr double GPS_L2_M_CODE_RATE_CPS = 0.5115e6; //!< GPS L2 M code rate [chips/s] constexpr double GPS_L2_M_PERIOD_S = 0.02; //!< GPS L2 M code period [seconds] constexpr double GPS_L2_L_CODE_RATE_CPS = 0.5115e6; //!< GPS L2 L code rate [chips/s] +constexpr uint32_t GPS_L2_M_CODE_PERIOD_MS = 20; //!< GPS L2 L code period [ms] constexpr int32_t GPS_L2_M_CODE_LENGTH_CHIPS = 10230; //!< GPS L2 M code length [chips] constexpr int32_t GPS_L2_L_CODE_LENGTH_CHIPS = 767250; //!< GPS L2 L code length [chips] constexpr int32_t GPS_L2_CNAV_DATA_PAGE_BITS = 300; //!< GPS L2 CNAV page length, including preamble and CRC [bits] diff --git a/src/core/system_parameters/glonass_gnav_navigation_message.cc b/src/core/system_parameters/glonass_gnav_navigation_message.cc index d30f6057f..9d3510fdf 100644 --- a/src/core/system_parameters/glonass_gnav_navigation_message.cc +++ b/src/core/system_parameters/glonass_gnav_navigation_message.cc @@ -29,18 +29,6 @@ #endif -Glonass_Gnav_Navigation_Message::Glonass_Gnav_Navigation_Message() -{ - auto gnss_sat = Gnss_Satellite(); - std::string _system("GLONASS"); - // TODO SHould number of channels be hardcoded? - for (uint32_t i = 1; i < 14; i++) - { - satelliteBlock[i] = gnss_sat.what_block(_system, i); - } -} - - bool Glonass_Gnav_Navigation_Message::CRC_test(std::bitset& bits) const { uint32_t sum_bits = 0; diff --git a/src/core/system_parameters/glonass_gnav_navigation_message.h b/src/core/system_parameters/glonass_gnav_navigation_message.h index c51264ad8..29b0ae2b2 100644 --- a/src/core/system_parameters/glonass_gnav_navigation_message.h +++ b/src/core/system_parameters/glonass_gnav_navigation_message.h @@ -27,7 +27,6 @@ #include "glonass_gnav_utc_model.h" #include #include -#include #include #include // for pair #include // for vector @@ -49,7 +48,7 @@ public: /*! * Default constructor */ - Glonass_Gnav_Navigation_Message(); + Glonass_Gnav_Navigation_Message() = default; /*! * \brief Compute CRC for GLONASS GNAV strings @@ -178,8 +177,6 @@ private: Glonass_Gnav_Utc_Model gnav_utc_model{}; // UTC model information Glonass_Gnav_Almanac gnav_almanac[GLONASS_CA_NBR_SATS]{}; // Almanac information for all 24 satellites - std::map satelliteBlock; // Map that stores to which block the PRN belongs - double d_previous_tb{}; // Previous iode for the Glonass_Gnav_Ephemeris object. Used to determine when new data arrives double d_previous_Na[GLONASS_CA_NBR_SATS]{}; // Previous time for almanac of the Glonass_Gnav_Almanac object diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 89fe4e1d9..a929ee5dc 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1046,9 +1046,10 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA) xcode_remove_warning_duplicates(flowgraph_test) - add_test(flowgraph_test flowgraph_test) - - set_property(TEST flowgraph_test PROPERTY TIMEOUT 30) + if(NOT ENABLE_UNIT_TESTING_MINIMAL) + add_test(flowgraph_test flowgraph_test) + set_property(TEST flowgraph_test PROPERTY TIMEOUT 30) + endif() endif() @@ -1108,9 +1109,10 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA) xcode_remove_warning_duplicates(gnss_block_test) - add_test(gnss_block_test gnss_block_test) - - set_property(TEST gnss_block_test PROPERTY TIMEOUT 60) + if(NOT ENABLE_UNIT_TESTING_MINIMAL) + add_test(gnss_block_test gnss_block_test) + set_property(TEST gnss_block_test PROPERTY TIMEOUT 60) + endif() endif() @@ -1250,7 +1252,10 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA) xcode_remove_warning_duplicates(acq_test) - add_test(acq_test acq_test) + if(NOT ENABLE_UNIT_TESTING_MINIMAL) + add_test(acq_test acq_test) + set_property(TEST acq_test PROPERTY TIMEOUT 30) + endif() if(USE_GENERIC_LAMBDAS) set(has_generic_lambdas HAS_GENERIC_LAMBDA=1) @@ -1272,7 +1277,6 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA) -DUSE_BOOST_BIND_PLACEHOLDERS=1 ) endif() - set_property(TEST acq_test PROPERTY TIMEOUT 30) endif() @@ -1353,9 +1357,10 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA) xcode_remove_warning_duplicates(trk_test) - add_test(trk_test trk_test) - - set_property(TEST trk_test PROPERTY TIMEOUT 30) + if(NOT ENABLE_UNIT_TESTING_MINIMAL) + add_test(trk_test trk_test) + set_property(TEST trk_test PROPERTY TIMEOUT 30) + endif() endif() ######################################################### @@ -1391,9 +1396,10 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA) xcode_remove_warning_duplicates(control_thread_test) - add_test(control_thread_test control_thread_test) - - set_property(TEST control_thread_test PROPERTY TIMEOUT 30) + if(NOT ENABLE_UNIT_TESTING_MINIMAL) + add_test(control_thread_test control_thread_test) + set_property(TEST control_thread_test PROPERTY TIMEOUT 30) + endif() endif() ######################################################### @@ -1404,15 +1410,22 @@ else() if(ENABLE_FPGA) add_dependencies(check matio_test) else() - add_dependencies(check - control_thread_test - flowgraph_test - gnss_block_test - gnuradio_block_test - acq_test - trk_test - matio_test - ) + if(ENABLE_UNIT_TESTING_MINIMAL) + add_dependencies(check + gnuradio_block_test + matio_test + ) + else() + add_dependencies(check + control_thread_test + flowgraph_test + gnss_block_test + gnuradio_block_test + acq_test + trk_test + matio_test + ) + endif() endif() endif() diff --git a/tests/unit-tests/control-plane/gnss_flowgraph_test.cc b/tests/unit-tests/control-plane/gnss_flowgraph_test.cc index 158f0ee27..a2e33cdea 100644 --- a/tests/unit-tests/control-plane/gnss_flowgraph_test.cc +++ b/tests/unit-tests/control-plane/gnss_flowgraph_test.cc @@ -152,90 +152,20 @@ TEST(GNSSFlowgraph /*unused*/, InstantiateConnectStartStopHybrid /*unused*/) config->set_property("Channels_1B.count", "8"); config->set_property("Channels.in_acquisition", "1"); - config->set_property("Acquisition_1C0.implementation", "GPS_L1_CA_PCPS_Acquisition"); - config->set_property("Acquisition_1C0.threshold", "1"); - config->set_property("Acquisition_1C0.doppler_max", "5000"); - config->set_property("Acquisition_1C1.implementation", "GPS_L1_CA_PCPS_Acquisition"); - config->set_property("Acquisition_1C1.threshold", "1"); - config->set_property("Acquisition_1C1.doppler_max", "5000"); - config->set_property("Acquisition_1C2.implementation", "GPS_L1_CA_PCPS_Acquisition"); - config->set_property("Acquisition_1C2.threshold", "1"); - config->set_property("Acquisition_1C2.doppler_max", "5000"); - config->set_property("Acquisition_1C3.implementation", "GPS_L1_CA_PCPS_Acquisition"); - config->set_property("Acquisition_1C3.threshold", "1"); - config->set_property("Acquisition_1C3.doppler_max", "5000"); - config->set_property("Acquisition_1C4.implementation", "GPS_L1_CA_PCPS_Acquisition"); - config->set_property("Acquisition_1C4.threshold", "1"); - config->set_property("Acquisition_1C4.doppler_max", "5000"); - config->set_property("Acquisition_1C5.implementation", "GPS_L1_CA_PCPS_Acquisition"); - config->set_property("Acquisition_1C5.threshold", "1"); - config->set_property("Acquisition_1C5.doppler_max", "5000"); - config->set_property("Acquisition_1C6.implementation", "GPS_L1_CA_PCPS_Acquisition"); - config->set_property("Acquisition_1C6.threshold", "1"); - config->set_property("Acquisition_1C6.doppler_max", "5000"); - config->set_property("Acquisition_1C7.implementation", "GPS_L1_CA_PCPS_Acquisition"); - config->set_property("Acquisition_1C7.threshold", "1"); - config->set_property("Acquisition_1C7.doppler_max", "5000"); + config->set_property("Acquisition_1C.implementation", "GPS_L1_CA_PCPS_Acquisition"); + config->set_property("Acquisition_1C.threshold", "1"); + config->set_property("Acquisition_1C.doppler_max", "5000"); - config->set_property("Acquisition_1B8.implementation", "Galileo_E1_PCPS_Ambiguous_Acquisition"); - config->set_property("Acquisition_1B8.threshold", "1"); - config->set_property("Acquisition_1B8.doppler_max", "5000"); - config->set_property("Acquisition_1B9.implementation", "Galileo_E1_PCPS_Ambiguous_Acquisition"); - config->set_property("Acquisition_1B9.threshold", "1"); - config->set_property("Acquisition_1B9.doppler_max", "5000"); - config->set_property("Acquisition_1B10.implementation", "Galileo_E1_PCPS_Ambiguous_Acquisition"); - config->set_property("Acquisition_1B10.threshold", "1"); - config->set_property("Acquisition_1B10.doppler_max", "5000"); - config->set_property("Acquisition_1B11.implementation", "Galileo_E1_PCPS_Ambiguous_Acquisition"); - config->set_property("Acquisition_1B11.threshold", "1"); - config->set_property("Acquisition_1B11.doppler_max", "5000"); - config->set_property("Acquisition_1B12.implementation", "Galileo_E1_PCPS_Ambiguous_Acquisition"); - config->set_property("Acquisition_1B12.threshold", "1"); - config->set_property("Acquisition_1B12.doppler_max", "5000"); - config->set_property("Acquisition_1B13.implementation", "Galileo_E1_PCPS_Ambiguous_Acquisition"); - config->set_property("Acquisition_1B13.threshold", "1"); - config->set_property("Acquisition_1B13.doppler_max", "5000"); - config->set_property("Acquisition_1B14.implementation", "Galileo_E1_PCPS_Ambiguous_Acquisition"); - config->set_property("Acquisition_1B14.threshold", "1"); - config->set_property("Acquisition_1B14.doppler_max", "5000"); - config->set_property("Acquisition_1B15.implementation", "Galileo_E1_PCPS_Ambiguous_Acquisition"); - config->set_property("Acquisition_1B15.threshold", "1"); - config->set_property("Acquisition_1B15.doppler_max", "5000"); - config->set_property("Tracking_1C0.implementation", "GPS_L1_CA_DLL_PLL_Tracking"); - config->set_property("Tracking_1C1.implementation", "GPS_L1_CA_DLL_PLL_Tracking"); - config->set_property("Tracking_1C2.implementation", "GPS_L1_CA_DLL_PLL_Tracking"); - config->set_property("Tracking_1C3.implementation", "GPS_L1_CA_DLL_PLL_Tracking"); - config->set_property("Tracking_1C4.implementation", "GPS_L1_CA_DLL_PLL_Tracking"); - config->set_property("Tracking_1C5.implementation", "GPS_L1_CA_DLL_PLL_Tracking"); - config->set_property("Tracking_1C6.implementation", "GPS_L1_CA_DLL_PLL_Tracking"); - config->set_property("Tracking_1C7.implementation", "GPS_L1_CA_DLL_PLL_Tracking"); - config->set_property("Tracking_1B8.implementation", "Galileo_E1_DLL_PLL_VEML_Tracking"); - config->set_property("Tracking_1B9.implementation", "Galileo_E1_DLL_PLL_VEML_Tracking"); - config->set_property("Tracking_1B10.implementation", "Galileo_E1_DLL_PLL_VEML_Tracking"); - config->set_property("Tracking_1B11.implementation", "Galileo_E1_DLL_PLL_VEML_Tracking"); - config->set_property("Tracking_1B12.implementation", "Galileo_E1_DLL_PLL_VEML_Tracking"); - config->set_property("Tracking_1B13.implementation", "Galileo_E1_DLL_PLL_VEML_Tracking"); - config->set_property("Tracking_1B14.implementation", "Galileo_E1_DLL_PLL_VEML_Tracking"); - config->set_property("Tracking_1B15.implementation", "Galileo_E1_DLL_PLL_VEML_Tracking"); + config->set_property("Acquisition_1B.implementation", "Galileo_E1_PCPS_Ambiguous_Acquisition"); + config->set_property("Acquisition_1B.threshold", "1"); + config->set_property("Acquisition_1B.doppler_max", "5000"); - config->set_property("TelemetryDecoder_1C0.implementation", "GPS_L1_CA_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1C1.implementation", "GPS_L1_CA_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1C2.implementation", "GPS_L1_CA_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1C3.implementation", "GPS_L1_CA_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1C4.implementation", "GPS_L1_CA_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1C5.implementation", "GPS_L1_CA_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1C6.implementation", "GPS_L1_CA_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1C7.implementation", "GPS_L1_CA_Telemetry_Decoder"); + config->set_property("Tracking_1C.implementation", "GPS_L1_CA_DLL_PLL_Tracking"); + config->set_property("Tracking_1B.implementation", "Galileo_E1_DLL_PLL_VEML_Tracking"); - config->set_property("TelemetryDecoder_1B8.implementation", "Galileo_E1B_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1B9.implementation", "Galileo_E1B_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1B10.implementation", "Galileo_E1B_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1B11.implementation", "Galileo_E1B_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1B12.implementation", "Galileo_E1B_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1B13.implementation", "Galileo_E1B_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1B14.implementation", "Galileo_E1B_Telemetry_Decoder"); - config->set_property("TelemetryDecoder_1B15.implementation", "Galileo_E1B_Telemetry_Decoder"); + config->set_property("TelemetryDecoder_1C.implementation", "GPS_L1_CA_Telemetry_Decoder"); + config->set_property("TelemetryDecoder_1B.implementation", "Galileo_E1B_Telemetry_Decoder"); config->set_property("Observables.implementation", "Hybrid_Observables"); config->set_property("PVT.implementation", "RTKLIB_PVT"); diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc b/tests/unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc index 6406f42b2..c35f06f92 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc @@ -593,7 +593,6 @@ void AcquisitionPerformanceTest::process_message() { measurement_counter++; acquisition->reset(); - acquisition->set_state(1); std::cout << "Progress: " << round(static_cast(measurement_counter) / static_cast(num_of_measurements) * 100.0) << "% \r" << std::flush; if (measurement_counter == num_of_measurements) { @@ -854,16 +853,11 @@ int AcquisitionPerformanceTest::run_receiver() acquisition->set_gnss_synchro(&gnss_synchro); acquisition->set_channel(0); - acquisition->set_doppler_max(config->property("Acquisition.doppler_max", 10000)); - acquisition->set_doppler_step(config->property("Acquisition.doppler_step", 500)); acquisition->set_threshold(config->property("Acquisition.threshold", 0.0)); - acquisition->init(); acquisition->set_local_code(); - - acquisition->set_state(1); // Ensure that acquisition starts at the first sample + acquisition->reset(); acquisition->connect(top_block); - acquisition->reset(); top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); top_block->connect(gr_interleaved_char_to_complex, 0, skiphead, 0); top_block->connect(skiphead, 0, valve, 0); diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/beidou_b1i_pcps_acquisition_test.cc b/tests/unit-tests/signal-processing-blocks/acquisition/beidou_b1i_pcps_acquisition_test.cc index 2ba96d9b1..d732bd971 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/beidou_b1i_pcps_acquisition_test.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/beidou_b1i_pcps_acquisition_test.cc @@ -249,7 +249,7 @@ void BeidouB1iPcpsAcquisitionTest::plot_grid() TEST_F(BeidouB1iPcpsAcquisitionTest, Instantiate) { init(); - std::shared_ptr acquisition = boost::make_shared(config.get(), "Acquisition_B1", 1, 0); + std::shared_ptr acquisition = std::make_shared(config.get(), "Acquisition_B1", 1, 0); } @@ -263,7 +263,7 @@ TEST_F(BeidouB1iPcpsAcquisitionTest, ConnectAndRun) top_block = gr::make_top_block("Acquisition test"); init(); - std::shared_ptr acquisition = boost::make_shared(config.get(), "Acquisition_B1", 1, 0); + std::shared_ptr acquisition = std::make_shared(config.get(), "Acquisition_B1", 1, 0); std::shared_ptr msg_rx = BeidouB1iPcpsAcquisitionTest_msg_rx_make(); ASSERT_NO_THROW({ @@ -322,14 +322,6 @@ TEST_F(BeidouB1iPcpsAcquisitionTest, ValidationOfResults) acquisition->set_threshold(0.0038); }) << "Failure setting threshold."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(doppler_max); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(doppler_step); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; @@ -344,8 +336,7 @@ TEST_F(BeidouB1iPcpsAcquisitionTest, ValidationOfResults) }) << "Failure connecting the blocks of acquisition test."; acquisition->set_local_code(); - acquisition->set_state(1); // Ensure that acquisition starts at the first sample - acquisition->init(); + acquisition->reset(); EXPECT_NO_THROW({ start = std::chrono::system_clock::now(); diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/beidou_b3i_pcps_acquisition_test.cc b/tests/unit-tests/signal-processing-blocks/acquisition/beidou_b3i_pcps_acquisition_test.cc index b96f9427d..fa94a04ce 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/beidou_b3i_pcps_acquisition_test.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/beidou_b3i_pcps_acquisition_test.cc @@ -247,7 +247,7 @@ void BeidouB3iPcpsAcquisitionTest::plot_grid() TEST_F(BeidouB3iPcpsAcquisitionTest, Instantiate) { init(); - std::shared_ptr acquisition = boost::make_shared(config.get(), "Acquisition_B3", 1, 0); + std::shared_ptr acquisition = std::make_shared(config.get(), "Acquisition_B3", 1, 0); } @@ -261,7 +261,7 @@ TEST_F(BeidouB3iPcpsAcquisitionTest, ConnectAndRun) top_block = gr::make_top_block("Acquisition test"); init(); - std::shared_ptr acquisition = boost::make_shared(config.get(), "Acquisition_B3", 1, 0); + std::shared_ptr acquisition = std::make_shared(config.get(), "Acquisition_B3", 1, 0); std::shared_ptr msg_rx = BeidouB3iPcpsAcquisitionTest_msg_rx_make(); ASSERT_NO_THROW({ @@ -320,14 +320,6 @@ TEST_F(BeidouB3iPcpsAcquisitionTest, ValidationOfResults) acquisition->set_threshold(0.0002); }) << "Failure setting threshold."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(doppler_max); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(doppler_step); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; @@ -342,8 +334,7 @@ TEST_F(BeidouB3iPcpsAcquisitionTest, ValidationOfResults) }) << "Failure connecting the blocks of acquisition test."; acquisition->set_local_code(); - acquisition->set_state(1); // Ensure that acquisition starts at the first sample - acquisition->init(); + acquisition->reset(); EXPECT_NO_THROW({ start = std::chrono::system_clock::now(); diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc b/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc index b32ffd73f..72a443d74 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc @@ -456,14 +456,6 @@ TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ConnectAndRun) acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(config->property("Acquisition_1B.doppler_max", 10000)); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(config->property("Acquisition_1B.doppler_step", 500)); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->set_threshold(config->property("Acquisition_1B.threshold", 0.0)); }) << "Failure setting threshold."; @@ -506,14 +498,6 @@ TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ValidationOfResults) acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(config->property("Acquisition_1B.doppler_max", 10000)); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(config->property("Acquisition_1B.doppler_step", 500)); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->set_threshold(config->property("Acquisition_1B.threshold", 0.0)); }) << "Failure setting threshold."; @@ -522,8 +506,6 @@ TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ValidationOfResults) acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; - acquisition->init(); - ASSERT_NO_THROW({ std::shared_ptr signal_generator = std::make_shared(config.get(), "SignalSource", 0, 1, queue.get()); std::shared_ptr filter = std::make_shared(config.get(), "InputFilter", 1, 1); @@ -549,7 +531,7 @@ TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ValidationOfResults) } acquisition->set_local_code(); - // acquisition->set_state(1); + acquisition->reset(); start_queue(); EXPECT_NO_THROW({ @@ -593,14 +575,6 @@ TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ValidationOfResultsProb acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(config->property("Acquisition_1B.doppler_max", 10000)); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(config->property("Acquisition_1B.doppler_step", 500)); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->set_threshold(config->property("Acquisition_1B.threshold", 0.0)); }) << "Failure setting threshold."; @@ -609,8 +583,6 @@ TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ValidationOfResultsProb acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; - acquisition->init(); - ASSERT_NO_THROW({ std::shared_ptr signal_generator = std::make_shared(config.get(), "SignalSource", 0, 1, queue.get()); std::shared_ptr filter = std::make_shared(config.get(), "InputFilter", 1, 1); @@ -638,7 +610,7 @@ TEST_F(GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test, ValidationOfResultsProb } acquisition->set_local_code(); - // acquisition->set_state(1); + acquisition->reset(); start_queue(); EXPECT_NO_THROW({ diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc b/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc index 0c85d0edd..3bccb08d0 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc @@ -484,20 +484,10 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test, ValidationOfResults) acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(config->property("Acquisition_1B.doppler_max", 10000)); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(config->property("Acquisition_1B.doppler_step", 500)); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; - acquisition->init(); - ASSERT_NO_THROW({ std::shared_ptr signal_generator = std::make_shared(config.get(), "SignalSource", 0, 1, queue.get()); std::shared_ptr filter = std::make_shared(config.get(), "InputFilter", 1, 1); @@ -523,7 +513,7 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test, ValidationOfResults) } acquisition->set_local_code(); - acquisition->set_state(1); + acquisition->reset(); start_queue(); EXPECT_NO_THROW({ @@ -564,20 +554,10 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test, ValidationOfResultsProbabi acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(config->property("Acquisition_1B.doppler_max", 10000)); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(config->property("Acquisition_1B.doppler_step", 500)); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; - acquisition->init(); - ASSERT_NO_THROW({ std::shared_ptr signal_generator = std::make_shared(config.get(), "SignalSource", 0, 1, queue.get()); std::shared_ptr filter = std::make_shared(config.get(), "InputFilter", 1, 1); @@ -605,7 +585,7 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test, ValidationOfResultsProbabi } acquisition->set_local_code(); - acquisition->set_state(1); + acquisition->reset(); start_queue(); EXPECT_NO_THROW({ diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc_test.cc b/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc_test.cc index 3d94da8a1..a4b157d19 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc_test.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc_test.cc @@ -174,7 +174,7 @@ void GalileoE1PcpsAmbiguousAcquisitionGSoCTest::init() // config->set_property("Acquisition_1B.threshold", "2.5"); config->set_property("Acquisition_1B.pfa", "0.001"); config->set_property("Acquisition_1B.doppler_max", "10000"); - config->set_property("Acquisition_1B.doppler_step", "125"); + config->set_property("Acquisition_1B.doppler_step", "250"); config->set_property("Acquisition_1B.repeat_satellite", "false"); config->set_property("Acquisition_1B.cboc", "true"); } @@ -275,14 +275,6 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoCTest, ValidationOfResults) acquisition->set_threshold(config->property("Acquisition_1B.threshold", 0.00001)); }) << "Failure setting threshold."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(config->property("Acquisition_1B.doppler_max", 10000)); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(config->property("Acquisition_1B.doppler_step", 250)); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; @@ -300,9 +292,7 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionGSoCTest, ValidationOfResults) ASSERT_NO_THROW({ start_queue(); acquisition->set_local_code(); - acquisition->init(); acquisition->reset(); - acquisition->set_state(1); }) << "Failure starting acquisition"; EXPECT_NO_THROW({ diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test.cc b/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test.cc index dab5dd729..4e2841ef7 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test.cc @@ -336,14 +336,6 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, ValidationOfResults) acquisition->set_threshold(config->property("Acquisition_1B.threshold", 1e-9)); }) << "Failure setting threshold."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(config->property("Acquisition_1B.doppler_max", doppler_max)); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(config->property("Acquisition_1B.doppler_step", doppler_step)); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; @@ -358,9 +350,7 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, ValidationOfResults) }) << "Failure connecting the blocks of acquisition test."; acquisition->set_local_code(); - acquisition->init(); acquisition->reset(); - acquisition->set_state(1); EXPECT_NO_THROW({ start = std::chrono::system_clock::now(); diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test_fpga.cc b/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test_fpga.cc index 4d68363f8..74f746c54 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test_fpga.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test_fpga.cc @@ -335,8 +335,6 @@ bool GalileoE1PcpsAmbiguousAcquisitionTestFpga::acquire_signal() acquisition->set_gnss_synchro(&tmp_gnss_synchro); acquisition->set_channel_fsm(channel_fsm_); acquisition->set_channel(1); - acquisition->set_doppler_max(doppler_max); - acquisition->set_doppler_step(doppler_step); acquisition->set_doppler_center(0); acquisition->set_threshold(0.001); @@ -345,7 +343,6 @@ bool GalileoE1PcpsAmbiguousAcquisitionTestFpga::acquire_signal() channel_fsm_->Event_clear_test_result(); acquisition->stop_acquisition(); // reset the whole system including the sample counters - acquisition->init(); acquisition->set_local_code(); args.skip_used_samples = 0; diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc b/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc index 665de9628..9bcd7c805 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc @@ -487,14 +487,6 @@ TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, ValidationOfResults) acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(config->property("Acquisition_1B.doppler_max", 10000)); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(config->property("Acquisition_1B.doppler_step", 500)); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->set_threshold(config->property("Acquisition_1B.threshold", 0.00001)); }) << "Failure setting threshold."; @@ -503,7 +495,6 @@ TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, ValidationOfResults) acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; - acquisition->init(); acquisition->reset(); ASSERT_NO_THROW({ @@ -532,7 +523,6 @@ TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, ValidationOfResults) acquisition->set_gnss_synchro(&gnss_synchro); acquisition->set_local_code(); acquisition->reset(); - acquisition->set_state(1); start_queue(); EXPECT_NO_THROW({ @@ -579,14 +569,6 @@ TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, ValidationOfResultsProbabili acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(config->property("Acquisition_1B.doppler_max", 10000)); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(config->property("Acquisition_1B.doppler_step", 500)); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->set_threshold(config->property("Acquisition_1B.threshold", 0.00215)); }) << "Failure setting threshold."; @@ -595,7 +577,6 @@ TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, ValidationOfResultsProbabili acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; - acquisition->init(); acquisition->reset(); ASSERT_NO_THROW({ @@ -625,10 +606,8 @@ TEST_F(GalileoE1PcpsCccwsrAmbiguousAcquisitionTest, ValidationOfResultsProbabili } acquisition->set_gnss_synchro(&gnss_synchro); - acquisition->init(); acquisition->reset(); acquisition->set_local_code(); - acquisition->set_state(1); start_queue(); EXPECT_NO_THROW({ diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc b/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc index 9f17437c0..0febe9e8c 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc @@ -479,7 +479,7 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test::config_3() config->set_property("Acquisition_1B.bit_transition_flag", "false"); config->set_property("Acquisition_1B.threshold", "0.2"); config->set_property("Acquisition_1B.doppler_max", "10000"); - config->set_property("Acquisition_1B.doppler_step", "125"); + config->set_property("Acquisition_1B.doppler_step", "50"); config->set_property("Acquisition_1B.folding_factor", "4"); config->set_property("Acquisition_1B.dump", "false"); } @@ -638,14 +638,6 @@ TEST_F(GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test, ValidationOfResul acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(config->property("Acquisition_1B.doppler_max", 10000)); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(config->property("Acquisition_1B.doppler_step", 125)); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->set_threshold(1); }) << "Failure setting threshold."; @@ -654,7 +646,6 @@ TEST_F(GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test, ValidationOfResul acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; - acquisition->init(); acquisition->reset(); ASSERT_NO_THROW({ @@ -684,7 +675,6 @@ TEST_F(GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test, ValidationOfResul acquisition->set_gnss_synchro(&gnss_synchro); acquisition->set_local_code(); acquisition->reset(); - acquisition->set_state(1); start_queue(); EXPECT_NO_THROW({ @@ -728,14 +718,6 @@ TEST_F(GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test, ValidationOfResul acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(config->property("Acquisition_1B.doppler_max", 10000)); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(50); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->set_threshold(5); }) << "Failure setting threshold."; @@ -744,7 +726,6 @@ TEST_F(GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test, ValidationOfResul acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; - acquisition->init(); acquisition->reset(); ASSERT_NO_THROW({ @@ -774,7 +755,6 @@ TEST_F(GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test, ValidationOfResul acquisition->set_gnss_synchro(&gnss_synchro); acquisition->set_local_code(); acquisition->reset(); - acquisition->set_state(1); start_queue(); EXPECT_NO_THROW({ @@ -815,14 +795,6 @@ TEST_F(GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test, ValidationOfResul acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(config->property("Acquisition_1B.doppler_max", 10000)); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(config->property("Acquisition_1B.doppler_step", 500)); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->set_threshold(config->property("Acquisition_1B.threshold", 0.0)); }) << "Failure setting threshold."; @@ -831,8 +803,6 @@ TEST_F(GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test, ValidationOfResul acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; - acquisition->init(); - ASSERT_NO_THROW({ std::shared_ptr signal_generator = std::make_shared(config.get(), "SignalSource", 0, 1, queue.get()); std::shared_ptr filter = std::make_shared(config.get(), "InputFilter", 1, 1); @@ -862,7 +832,6 @@ TEST_F(GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test, ValidationOfResul acquisition->set_gnss_synchro(&gnss_synchro); acquisition->set_local_code(); acquisition->reset(); - acquisition->set_state(1); start_queue(); EXPECT_NO_THROW({ diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc b/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc index 410788d2e..48ece6a38 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc @@ -258,7 +258,7 @@ void GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test::config_1() config->set_property("Acquisition_1B.tong_max_val", "8"); config->set_property("Acquisition_1B.threshold", "0.3"); config->set_property("Acquisition_1B.doppler_max", "10000"); - config->set_property("Acquisition_1B.doppler_step", "250"); + config->set_property("Acquisition_1B.doppler_step", "100"); config->set_property("Acquisition_1B.dump", "false"); } @@ -485,14 +485,6 @@ TEST_F(GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test, ValidationOfResults) acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(5000); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(100); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->set_threshold(0.01); }) << "Failure setting threshold."; @@ -502,7 +494,6 @@ TEST_F(GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test, ValidationOfResults) }) << "Failure connecting acquisition to the top_block."; acquisition->reset(); - acquisition->init(); ASSERT_NO_THROW({ std::shared_ptr signal_generator = std::make_shared(config.get(), "SignalSource", 0, 1, queue.get()); @@ -530,7 +521,6 @@ TEST_F(GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test, ValidationOfResults) acquisition->reset(); acquisition->set_gnss_synchro(&gnss_synchro); acquisition->set_local_code(); - acquisition->set_state(1); start_queue(); EXPECT_NO_THROW({ @@ -573,14 +563,6 @@ TEST_F(GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test, ValidationOfResultsPro acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(config->property("Acquisition_1B.doppler_max", 10000)); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(config->property("Acquisition_1B.doppler_step", 500)); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->set_threshold(config->property("Acquisition_1B.threshold", 0.00028)); }) << "Failure setting threshold."; @@ -589,8 +571,6 @@ TEST_F(GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test, ValidationOfResultsPro acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; - acquisition->init(); - ASSERT_NO_THROW({ std::shared_ptr signal_generator = std::make_shared(config.get(), "SignalSource", 0, 1, queue.get()); std::shared_ptr filter = std::make_shared(config.get(), "InputFilter", 1, 1); @@ -618,7 +598,7 @@ TEST_F(GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test, ValidationOfResultsPro } acquisition->set_local_code(); - acquisition->set_state(1); + acquisition->reset(); start_queue(); EXPECT_NO_THROW({ diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc b/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc index 44b7d3ef5..6869d4290 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc @@ -585,14 +585,6 @@ TEST_F(GalileoE5aPcpsAcquisitionGSoC2014GensourceTest, ValidationOfSIM) acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(config->property("Acquisition_5X.doppler_max", 5000)); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(config->property("Acquisition_5X.doppler_step", 100)); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->set_threshold(config->property("Acquisition_5X.threshold", 0.0001)); }) << "Failure setting threshold."; @@ -614,7 +606,6 @@ TEST_F(GalileoE5aPcpsAcquisitionGSoC2014GensourceTest, ValidationOfSIM) }) << "Failure connecting the blocks of acquisition test."; acquisition->reset(); - acquisition->init(); // i = 0 --> satellite in acquisition is visible // i = 1 --> satellite in acquisition is not visible @@ -638,7 +629,7 @@ TEST_F(GalileoE5aPcpsAcquisitionGSoC2014GensourceTest, ValidationOfSIM) acquisition->set_gnss_synchro(&gnss_synchro); acquisition->set_local_code(); - acquisition->set_state(1); + acquisition->reset(); start_queue(); EXPECT_NO_THROW({ diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5b_pcps_acquisition_test.cc b/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5b_pcps_acquisition_test.cc index 66bc9cf3c..117aab164 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5b_pcps_acquisition_test.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5b_pcps_acquisition_test.cc @@ -377,14 +377,6 @@ TEST_F(GalileoE5bPcpsAcquisitionTest, ValidationOfResults) acquisition->set_threshold(0.0001); }) << "Failure setting threshold."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(5000); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(100); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; @@ -400,7 +392,6 @@ TEST_F(GalileoE5bPcpsAcquisitionTest, ValidationOfResults) }) << "Failure connecting the blocks of acquisition test."; acquisition->reset(); - acquisition->init(); // i = 0 --> satellite in acquisition is visible // i = 1 --> satellite in acquisition is not visible @@ -424,7 +415,7 @@ TEST_F(GalileoE5bPcpsAcquisitionTest, ValidationOfResults) acquisition->set_gnss_synchro(&gnss_synchro); acquisition->set_local_code(); - acquisition->set_state(1); + acquisition->reset(); start_queue(); EXPECT_NO_THROW({ diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e6_pcps_acquisition_test.cc b/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e6_pcps_acquisition_test.cc index f503967bf..c3dde2b85 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e6_pcps_acquisition_test.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e6_pcps_acquisition_test.cc @@ -372,14 +372,6 @@ TEST_F(GalileoE6PcpsAcquisitionTest, ValidationOfResults) acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(5000); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(100); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; @@ -395,7 +387,6 @@ TEST_F(GalileoE6PcpsAcquisitionTest, ValidationOfResults) }) << "Failure connecting the blocks of acquisition test."; acquisition->reset(); - acquisition->init(); // i = 0 --> satellite in acquisition is visible // i = 1 --> satellite in acquisition is not visible @@ -419,7 +410,7 @@ TEST_F(GalileoE6PcpsAcquisitionTest, ValidationOfResults) acquisition->set_gnss_synchro(&gnss_synchro); acquisition->set_local_code(); - acquisition->set_state(1); + acquisition->reset(); start_queue(); EXPECT_NO_THROW({ diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_gsoc2017_test.cc b/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_gsoc2017_test.cc index 334e1baae..497c36237 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_gsoc2017_test.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_gsoc2017_test.cc @@ -491,21 +491,11 @@ TEST_F(GlonassL1CaPcpsAcquisitionGSoC2017Test, ValidationOfResults) acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(10000); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(500); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->connect(top_block); top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); }) << "Failure connecting acquisition to the top_block."; - acquisition->init(); - ASSERT_NO_THROW({ std::shared_ptr signal_generator = std::make_shared(config.get(), "SignalSource", 0, 1, queue.get()); std::shared_ptr filter = std::make_shared(config.get(), "InputFilter", 1, 1); @@ -530,7 +520,7 @@ TEST_F(GlonassL1CaPcpsAcquisitionGSoC2017Test, ValidationOfResults) } acquisition->set_local_code(); - acquisition->set_state(1); // Ensure that acquisition starts at the first sample + acquisition->reset(); start_queue(); EXPECT_NO_THROW({ @@ -573,21 +563,11 @@ TEST_F(GlonassL1CaPcpsAcquisitionGSoC2017Test, ValidationOfResultsProbabilities) acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(config->property("Acquisition.doppler_max", 10000)); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(config->property("Acquisition.doppler_step", 500)); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->connect(top_block); top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); }) << "Failure connecting acquisition to the top_block."; - acquisition->init(); - ASSERT_NO_THROW({ std::shared_ptr signal_generator = std::make_shared(config.get(), "SignalSource", 0, 1, queue.get()); std::shared_ptr filter = std::make_shared(config.get(), "InputFilter", 1, 1); diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_test.cc b/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_test.cc index 235ec87cd..59c2e58cb 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_test.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_test.cc @@ -238,21 +238,12 @@ TEST_F(GlonassL1CaPcpsAcquisitionTest, ValidationOfResults) acquisition->set_threshold(0.005); }) << "Failure setting threshold."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(10000); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(500); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; acquisition->set_local_code(); - acquisition->set_state(1); // Ensure that acquisition starts at the first sample - acquisition->init(); + acquisition->reset(); ASSERT_NO_THROW({ std::string path = std::string(TEST_PATH); diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l2_ca_pcps_acquisition_test.cc b/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l2_ca_pcps_acquisition_test.cc index 35d1e4c8c..34e9dff0a 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l2_ca_pcps_acquisition_test.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l2_ca_pcps_acquisition_test.cc @@ -489,14 +489,6 @@ TEST_F(GlonassL2CaPcpsAcquisitionTest, ValidationOfResults) acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(10000); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(500); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->set_threshold(0.0005); }) << "Failure setting threshold."; @@ -506,8 +498,6 @@ TEST_F(GlonassL2CaPcpsAcquisitionTest, ValidationOfResults) top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); }) << "Failure connecting acquisition to the top_block."; - acquisition->init(); - ASSERT_NO_THROW({ std::shared_ptr signal_generator = std::make_shared(config.get(), "SignalSource", 0, 1, queue.get()); std::shared_ptr filter = std::make_shared(config.get(), "InputFilter", 1, 1); @@ -532,7 +522,7 @@ TEST_F(GlonassL2CaPcpsAcquisitionTest, ValidationOfResults) } acquisition->set_local_code(); - acquisition->set_state(1); // Ensure that acquisition starts at the first sample + acquisition->reset(); start_queue(); EXPECT_NO_THROW({ @@ -575,14 +565,6 @@ TEST_F(GlonassL2CaPcpsAcquisitionTest, ValidationOfResultsProbabilities) acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(config->property("Acquisition_2G.doppler_max", 10000)); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(config->property("Acquisition_2G.doppler_step", 500)); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->set_threshold(config->property("Acquisition_2G.threshold", 0.0)); }) << "Failure setting threshold."; @@ -592,8 +574,6 @@ TEST_F(GlonassL2CaPcpsAcquisitionTest, ValidationOfResultsProbabilities) top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); }) << "Failure connecting acquisition to the top_block."; - acquisition->init(); - ASSERT_NO_THROW({ std::shared_ptr signal_generator = std::make_shared(config.get(), "SignalSource", 0, 1, queue.get()); std::shared_ptr filter = std::make_shared(config.get(), "InputFilter", 1, 1); diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc b/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc index 2d0e4f04f..5136ab179 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc @@ -483,21 +483,11 @@ TEST_F(GpsL1CaPcpsAcquisitionGSoC2013Test, ValidationOfResults) acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(10000); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(500); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->connect(top_block); top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); }) << "Failure connecting acquisition to the top_block."; - acquisition->init(); - ASSERT_NO_THROW({ std::shared_ptr signal_generator = std::make_shared(config.get(), "SignalSource", 0, 1, queue.get()); std::shared_ptr filter = std::make_shared(config.get(), "InputFilter", 1, 1); @@ -522,7 +512,7 @@ TEST_F(GpsL1CaPcpsAcquisitionGSoC2013Test, ValidationOfResults) } acquisition->set_local_code(); - acquisition->set_state(1); // Ensure that acquisition starts at the first sample + acquisition->reset(); start_queue(); EXPECT_NO_THROW({ @@ -565,21 +555,11 @@ TEST_F(GpsL1CaPcpsAcquisitionGSoC2013Test, ValidationOfResultsProbabilities) acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(config->property("Acquisition_1C.doppler_max", 10000)); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(config->property("Acquisition_1C.doppler_step", 500)); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->connect(top_block); top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); }) << "Failure connecting acquisition to the top_block."; - acquisition->init(); - ASSERT_NO_THROW({ std::shared_ptr signal_generator = std::make_shared(config.get(), "SignalSource", 0, 1, queue.get()); std::shared_ptr filter = std::make_shared(config.get(), "InputFilter", 1, 1); diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc b/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc index 3aeff2872..f5620e15c 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc @@ -333,14 +333,6 @@ TEST_F(GpsL1CaPcpsAcquisitionTest /*unused*/, ValidationOfResults /*unused*/) acquisition->set_threshold(0.001); }) << "Failure setting threshold."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(doppler_max); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(doppler_step); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; @@ -355,8 +347,7 @@ TEST_F(GpsL1CaPcpsAcquisitionTest /*unused*/, ValidationOfResults /*unused*/) }) << "Failure connecting the blocks of acquisition test."; acquisition->set_local_code(); - acquisition->set_state(1); // Ensure that acquisition starts at the first sample - acquisition->init(); + acquisition->reset(); EXPECT_NO_THROW({ start = std::chrono::system_clock::now(); diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc b/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc index 47ddc54aa..4608d9305 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc @@ -334,8 +334,6 @@ bool GpsL1CaPcpsAcquisitionTestFpga::acquire_signal() acquisition->set_gnss_synchro(&tmp_gnss_synchro); acquisition->set_channel_fsm(channel_fsm_); acquisition->set_channel(1); - acquisition->set_doppler_max(doppler_max); - acquisition->set_doppler_step(doppler_step); acquisition->set_doppler_center(0); acquisition->set_threshold(0.001); @@ -344,7 +342,6 @@ bool GpsL1CaPcpsAcquisitionTestFpga::acquire_signal() channel_fsm_->Event_clear_test_result(); acquisition->stop_acquisition(); // reset the whole system including the sample counters - acquisition->init(); acquisition->set_local_code(); args.skip_used_samples = 0; diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc b/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc index 77a57303b..2657b0008 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc @@ -482,14 +482,6 @@ TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ValidationOfResults) acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(config->property("Acquisition_1C.doppler_max", 10000)); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(config->property("Acquisition_1C.doppler_step", 500)); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->set_threshold(config->property("Acquisition_1C.threshold", 0.0)); }) << "Failure setting threshold."; @@ -498,8 +490,6 @@ TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ValidationOfResults) acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; - acquisition->init(); - if (!acquisition->opencl_ready()) { std::cout << "OpenCL Platform is not ready.\n"; @@ -570,14 +560,6 @@ TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ValidationOfResultsProbabilitie acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(config->property("Acquisition_1C.doppler_max", 10000)); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(config->property("Acquisition_1C.doppler_step", 500)); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->set_threshold(config->property("Acquisition_1C.threshold", 0.0)); }) << "Failure setting threshold."; @@ -586,7 +568,6 @@ TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ValidationOfResultsProbabilitie acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; - acquisition->init(); if (!acquisition->opencl_ready()) { std::cout << "OpenCL Platform is not ready.\n"; diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc b/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc index e4f140b5b..cb3b56b8f 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc @@ -610,14 +610,6 @@ TEST_F(GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test, ValidationOfResults) acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(10000); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(250); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->set_threshold(100); }) << "Failure setting threshold."; @@ -626,7 +618,6 @@ TEST_F(GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test, ValidationOfResults) acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; - acquisition->init(); acquisition->reset(); ASSERT_NO_THROW({ @@ -657,7 +648,6 @@ TEST_F(GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test, ValidationOfResults) acquisition->reset(); acquisition->set_gnss_synchro(&gnss_synchro); acquisition->set_local_code(); - acquisition->set_state(1); start_queue(); EXPECT_NO_THROW({ @@ -703,14 +693,6 @@ TEST_F(GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test, ValidationOfResultsWithNoise acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(10000); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(250); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->set_threshold(100); }) << "Failure setting threshold."; @@ -719,7 +701,6 @@ TEST_F(GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test, ValidationOfResultsWithNoise acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; - acquisition->init(); acquisition->reset(); ASSERT_NO_THROW({ @@ -750,7 +731,6 @@ TEST_F(GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test, ValidationOfResultsWithNoise acquisition->reset(); acquisition->set_gnss_synchro(&gnss_synchro); acquisition->set_local_code(); - acquisition->set_state(1); start_queue(); EXPECT_NO_THROW({ @@ -797,7 +777,6 @@ TEST_F(GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test, ValidationOfResultsProbabili acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; - acquisition->init(); acquisition->reset(); ASSERT_NO_THROW({ @@ -829,7 +808,6 @@ TEST_F(GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test, ValidationOfResultsProbabili acquisition->reset(); acquisition->set_gnss_synchro(&gnss_synchro); acquisition->set_local_code(); - acquisition->set_state(1); start_queue(); EXPECT_NO_THROW({ diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc b/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc index 07825fae9..048a00857 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc @@ -479,14 +479,6 @@ TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ValidationOfResults) acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(config->property("Acquisition_1C.doppler_max", 10000)); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(config->property("Acquisition_1C.doppler_step", 500)); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->set_threshold(config->property("Acquisition_1C.threshold", 0.0)); }) << "Failure setting threshold."; @@ -495,8 +487,6 @@ TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ValidationOfResults) acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; - acquisition->init(); - ASSERT_NO_THROW({ std::shared_ptr signal_generator = std::make_shared(config.get(), "SignalSource", 0, 1, queue.get()); std::shared_ptr filter = std::make_shared(config.get(), "InputFilter", 1, 1); @@ -522,7 +512,7 @@ TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ValidationOfResults) } acquisition->set_local_code(); - acquisition->set_state(1); + acquisition->reset(); start_queue(); @@ -566,14 +556,6 @@ TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ValidationOfResultsProbabilities) acquisition->set_gnss_synchro(&gnss_synchro); }) << "Failure setting gnss_synchro."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(config->property("Acquisition_1C.doppler_max", 10000)); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(config->property("Acquisition_1C.doppler_step", 500)); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->set_threshold(config->property("Acquisition_1C.threshold", 0.0)); }) << "Failure setting threshold."; @@ -582,8 +564,6 @@ TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ValidationOfResultsProbabilities) acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; - acquisition->init(); - ASSERT_NO_THROW({ std::shared_ptr signal_generator = std::make_shared(config.get(), "SignalSource", 0, 1, queue.get()); std::shared_ptr filter = std::make_shared(config.get(), "InputFilter", 1, 1); @@ -611,7 +591,7 @@ TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ValidationOfResultsProbabilities) } acquisition->set_local_code(); - acquisition->set_state(1); + acquisition->reset(); start_queue(); EXPECT_NO_THROW({ diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/gps_l2_m_pcps_acquisition_test.cc b/tests/unit-tests/signal-processing-blocks/acquisition/gps_l2_m_pcps_acquisition_test.cc index 78bbeb715..0180af90c 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/gps_l2_m_pcps_acquisition_test.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/gps_l2_m_pcps_acquisition_test.cc @@ -332,14 +332,6 @@ TEST_F(GpsL2MPcpsAcquisitionTest, ValidationOfResults) acquisition->set_threshold(0.001); }) << "Failure setting threshold."; - ASSERT_NO_THROW({ - acquisition->set_doppler_max(doppler_max); - }) << "Failure setting doppler_max."; - - ASSERT_NO_THROW({ - acquisition->set_doppler_step(doppler_step); - }) << "Failure setting doppler_step."; - ASSERT_NO_THROW({ acquisition->connect(top_block); }) << "Failure connecting acquisition to the top_block."; @@ -363,8 +355,7 @@ TEST_F(GpsL2MPcpsAcquisitionTest, ValidationOfResults) ASSERT_NO_THROW({ acquisition->set_local_code(); - acquisition->set_state(1); // Ensure that acquisition starts at the first sample - acquisition->init(); + acquisition->reset(); }) << "Failure set_state and init acquisition test"; EXPECT_NO_THROW({ diff --git a/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc b/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc index b28545e75..a5fb4eb3e 100644 --- a/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc +++ b/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc @@ -543,17 +543,12 @@ bool HybridObservablesTest::acquire_signal() acquisition->set_gnss_synchro(&tmp_gnss_synchro); acquisition->set_channel(0); #if USE_GLOG_AND_GFLAGS - acquisition->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); - acquisition->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); acquisition->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); #else - acquisition->set_doppler_max(config->property("Acquisition.doppler_max", absl::GetFlag(FLAGS_external_signal_acquisition_doppler_max_hz))); - acquisition->set_doppler_step(config->property("Acquisition.doppler_step", absl::GetFlag(FLAGS_external_signal_acquisition_doppler_step_hz))); acquisition->set_threshold(config->property("Acquisition.threshold", absl::GetFlag(FLAGS_external_signal_acquisition_threshold))); #endif - acquisition->init(); acquisition->set_local_code(); - acquisition->set_state(1); // Ensure that acquisition starts at the first sample + acquisition->reset(); acquisition->connect(top_block_acq); gr::blocks::file_source::sptr file_source; @@ -696,10 +691,8 @@ bool HybridObservablesTest::acquire_signal() { tmp_gnss_synchro.PRN = PRN; acquisition->set_gnss_synchro(&tmp_gnss_synchro); - acquisition->init(); acquisition->set_local_code(); acquisition->reset(); - acquisition->set_state(1); msg_rx->rx_message = 0; top_block_acq->run(); if (start_msg == true) diff --git a/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc b/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc index add79d187..ebd83210c 100644 --- a/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc +++ b/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc @@ -700,13 +700,9 @@ bool HybridObservablesTestFpga::acquire_signal() acquisition->set_channel_fsm(channel_fsm_); acquisition->set_channel(0); #if USE_GLOG_AND_GFLAGS - acquisition->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); - acquisition->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); acquisition->set_doppler_center(0); acquisition->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); #else - acquisition->set_doppler_max(config->property("Acquisition.doppler_max", absl::GetFlag(FLAGS_external_signal_acquisition_doppler_max_hz))); - acquisition->set_doppler_step(config->property("Acquisition.doppler_step", absl::GetFlag(FLAGS_external_signal_acquisition_doppler_step_hz))); acquisition->set_doppler_center(0); acquisition->set_threshold(config->property("Acquisition.threshold", absl::GetFlag(FLAGS_external_signal_acquisition_threshold))); #endif @@ -759,7 +755,6 @@ bool HybridObservablesTestFpga::acquire_signal() channel_fsm_->Event_clear_test_result(); acquisition->stop_acquisition(); // reset the whole system including the sample counters - acquisition->init(); acquisition->set_local_code(); if ((implementation == "GPS_L1_CA_DLL_PLL_Tracking_FPGA") or (implementation == "Galileo_E1_DLL_PLL_VEML_Tracking_FPGA")) diff --git a/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test.cc b/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test.cc index d46d0e802..4200fb2bc 100644 --- a/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test.cc +++ b/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test.cc @@ -536,17 +536,12 @@ bool TrackingPullInTest::acquire_signal(int SV_ID) acquisition->set_gnss_synchro(&tmp_gnss_synchro); acquisition->set_channel(0); #if USE_GLOG_AND_GFLAGS - acquisition->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); - acquisition->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); acquisition->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); #else - acquisition->set_doppler_max(config->property("Acquisition.doppler_max", absl::GetFlag(FLAGS_external_signal_acquisition_doppler_max_hz))); - acquisition->set_doppler_step(config->property("Acquisition.doppler_step", absl::GetFlag(FLAGS_external_signal_acquisition_doppler_step_hz))); acquisition->set_threshold(config->property("Acquisition.threshold", absl::GetFlag(FLAGS_external_signal_acquisition_threshold))); #endif - acquisition->init(); acquisition->set_local_code(); - acquisition->set_state(1); // Ensure that acquisition starts at the first sample + acquisition->reset(); acquisition->connect(top_block_acq); gr::blocks::file_source::sptr file_source; @@ -692,10 +687,8 @@ bool TrackingPullInTest::acquire_signal(int SV_ID) { tmp_gnss_synchro.PRN = PRN; acquisition->set_gnss_synchro(&tmp_gnss_synchro); - acquisition->init(); acquisition->set_local_code(); acquisition->reset(); - acquisition->set_state(1); msg_rx->rx_message = 0; top_block_acq->run(); if (start_msg == true) diff --git a/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index 8bc477c75..718d7784a 100644 --- a/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -696,13 +696,9 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) acquisition->set_channel_fsm(channel_fsm_); acquisition->set_channel(0); #if USE_GLOG_AND_GFLAGS - acquisition->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); - acquisition->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); acquisition->set_doppler_center(0); acquisition->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); #else - acquisition->set_doppler_max(config->property("Acquisition.doppler_max", absl::GetFlag(FLAGS_external_signal_acquisition_doppler_max_hz))); - acquisition->set_doppler_step(config->property("Acquisition.doppler_step", absl::GetFlag(FLAGS_external_signal_acquisition_doppler_step_hz))); acquisition->set_doppler_center(0); acquisition->set_threshold(config->property("Acquisition.threshold", absl::GetFlag(FLAGS_external_signal_acquisition_threshold))); #endif @@ -759,7 +755,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) channel_fsm_->Event_clear_test_result(); acquisition->stop_acquisition(); // reset the whole system including the sample counters - acquisition->init(); acquisition->set_local_code(); if ((implementation == "GPS_L1_CA_DLL_PLL_Tracking_FPGA") or (implementation == "Galileo_E1_DLL_PLL_VEML_Tracking_FPGA")) diff --git a/utils/front-end-cal/main.cc b/utils/front-end-cal/main.cc index db0bd3888..0bf3dc93c 100644 --- a/utils/front-end-cal/main.cc +++ b/utils/front-end-cal/main.cc @@ -473,14 +473,13 @@ int main(int argc, char** argv) int64_t fs_in_ = configuration->property("GNSS-SDR.internal_fs_sps", 2048000); configuration->set_property("Acquisition.max_dwells", "10"); + configuration->set_property("Acquisition.doppler_max", "10000"); auto acquisition = std::make_shared(configuration.get(), "Acquisition", 1, 1); acquisition->set_channel(1); acquisition->set_gnss_synchro(&gnss_synchro); acquisition->set_threshold(configuration->property("Acquisition.threshold", 2.0)); - acquisition->set_doppler_max(configuration->property("Acquisition.doppler_max", 10000)); - acquisition->set_doppler_step(configuration->property("Acquisition.doppler_step", 250)); gr::block_sptr source; source = gr::blocks::file_source::make(sizeof(gr_complex), "tmp_capture.dat"); @@ -532,7 +531,6 @@ int main(int argc, char** argv) { gnss_synchro.PRN = PRN; acquisition->set_gnss_synchro(&gnss_synchro); - acquisition->init(); acquisition->set_local_code(); acquisition->reset(); stop = false; diff --git a/utils/nav-listener/CMakeLists.txt b/utils/nav-listener/CMakeLists.txt index 824c8dccf..e778366a3 100644 --- a/utils/nav-listener/CMakeLists.txt +++ b/utils/nav-listener/CMakeLists.txt @@ -4,7 +4,7 @@ # SPDX-FileCopyrightText: 2021 C. Fernandez-Prades cfernandez(at)cttc.es # SPDX-License-Identifier: BSD-3-Clause -cmake_minimum_required(VERSION 3.9...4.1) +cmake_minimum_required(VERSION 3.9...4.2) project(nav-msg-listener CXX) set(CMAKE_CXX_STANDARD 11)