diff --git a/src/algorithms/acquisition/adapters/CMakeLists.txt b/src/algorithms/acquisition/adapters/CMakeLists.txt index 85eb8672e..6bd9958b1 100644 --- a/src/algorithms/acquisition/adapters/CMakeLists.txt +++ b/src/algorithms/acquisition/adapters/CMakeLists.txt @@ -6,6 +6,7 @@ set(ACQ_ADAPTER_SOURCES + base_pcps_acquisition.cc gps_l1_ca_pcps_acquisition.cc gps_l1_ca_pcps_assisted_acquisition.cc gps_l1_ca_pcps_acquisition_fine_doppler.cc @@ -29,6 +30,7 @@ set(ACQ_ADAPTER_SOURCES ) set(ACQ_ADAPTER_HEADERS + base_pcps_acquisition.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 new file mode 100644 index 000000000..09b5c89f0 --- /dev/null +++ b/src/algorithms/acquisition/adapters/base_pcps_acquisition.cc @@ -0,0 +1,245 @@ +/*! + * \file gps_l1_ca_pcps_acquisition.cc + * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for + * GPS L1 C/A signals + * \authors + * + * ----------------------------------------------------------------------------- + * + * 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) + * SPDX-License-Identifier: GPL-3.0-or-later + * + * ----------------------------------------------------------------------------- + */ + +#include "base_pcps_acquisition.h" +#include "acq_conf.h" +#include "configuration_interface.h" +#include "gnss_sdr_flags.h" + +#if USE_GLOG_AND_GFLAGS +#include +#else +#include +#endif + +#if HAS_STD_SPAN +#include +namespace own = std; +#else +#include +namespace own = gsl_lite; +#endif + +namespace +{ +Acq_Conf get_acq_conf(const ConfigurationInterface* configuration, const std::string& role, double chip_rate, double opt_freq, uint32_t ms_per_code) +{ + Acq_Conf acq_parameters; + acq_parameters.ms_per_code = ms_per_code; + 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; + } +#else + if (absl::GetFlag(FLAGS_doppler_max) != 0) + { + acq_parameters.doppler_max = absl::GetFlag(FLAGS_doppler_max); + } +#endif + + return acq_parameters; +} +} // namespace + +BasePcpsAcquisition::BasePcpsAcquisition( + const ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams, + double chip_rate, + 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)), + 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)))), + code_(vector_length_), + acquisition_(pcps_make_acquisition(acq_parameters_)) +{ + DLOG(INFO) << "role " << role; + DLOG(INFO) << "acquisition(" << acquisition_->unique_id() << ")"; + + if (acq_parameters_.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 BasePcpsAcquisition::stop_acquisition() +{ + acquisition_->set_active(false); +} + + +void BasePcpsAcquisition::set_threshold(float threshold) +{ + acquisition_->set_threshold(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); +} + + +void BasePcpsAcquisition::set_gnss_synchro(Gnss_Synchro* gnss_synchro) +{ + gnss_synchro_ = gnss_synchro; + acquisition_->set_gnss_synchro(gnss_synchro_); +} + + +signed int BasePcpsAcquisition::mag() +{ + return acquisition_->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") + { + // nothing to connect + } + else if (acq_parameters_.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) << acq_parameters_.item_type << " unknown acquisition item type"; + } +} + + +void BasePcpsAcquisition::disconnect(gr::top_block_sptr top_block) +{ + if (acq_parameters_.item_type == "gr_complex" || acq_parameters_.item_type == "cshort") + { + // nothing to disconnect + } + else if (acq_parameters_.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) << acq_parameters_.item_type << " unknown acquisition item type"; + } +} + + +gr::basic_block_sptr BasePcpsAcquisition::get_left_block() +{ + if (acq_parameters_.item_type == "gr_complex" || acq_parameters_.item_type == "cshort") + { + return acquisition_; + } + if (acq_parameters_.item_type == "cbyte") + { + return cbyte_to_float_x2_; + } + + LOG(WARNING) << acq_parameters_.item_type << " unknown acquisition item type"; + return nullptr; +} + + +gr::basic_block_sptr BasePcpsAcquisition::get_right_block() +{ + return acquisition_; +} + + +void BasePcpsAcquisition::set_resampler_latency(uint32_t latency_samples) +{ + acquisition_->set_resampler_latency(latency_samples); +} + + +void BasePcpsAcquisition::set_local_code() +{ + volk_gnsssdr::vector> code(code_length_); + + const auto sampling_freq = acq_parameters_.use_automatic_resampler ? acq_parameters_.resampled_fs : acq_parameters_.fs_in; + code_gen_complex_sampled(code, gnss_synchro_->PRN, sampling_freq); + + const auto num_codes = acq_parameters_.sampled_ms / acq_parameters_.ms_per_code; + + 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_->set_local_code(code_.data()); +} diff --git a/src/algorithms/acquisition/adapters/base_pcps_acquisition.h b/src/algorithms/acquisition/adapters/base_pcps_acquisition.h new file mode 100644 index 000000000..e1da2523b --- /dev/null +++ b/src/algorithms/acquisition/adapters/base_pcps_acquisition.h @@ -0,0 +1,171 @@ +/*! + * \file base_ca_pcps_acquisition.h + * \brief Adapts a PCPS acquisition block to an AcquisitionInterface + * \authors
    + *
  • Mathieu Favreau, 2011. 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_H +#define GNSS_SDR_BASE_PCPS_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 + +/** \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 BasePcpsAcquisition : public AcquisitionInterface +{ +public: + BasePcpsAcquisition( + const ConfigurationInterface* configuration, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams, + double chip_rate, + double opt_freq, + double code_length_chips, + uint32_t ms_per_code); + + ~BasePcpsAcquisition() = default; + + inline std::string role() override + { + return role_; + } + + inline size_t item_size() override + { + return acq_parameters_.it_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 + { + acquisition_->set_channel(channel); + } + + /*! + * \brief Set channel fsm associated to this acquisition instance + */ + inline void set_channel_fsm(std::weak_ptr channel_fsm) override + { + acquisition_->set_channel_fsm(std::move(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 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; + + /*! + * \brief Sets local code + */ + void set_local_code() override; + +private: + /*! + * \brief Generate code + */ + virtual void code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) = 0; + + const Acq_Conf acq_parameters_; + gr::blocks::float_to_complex::sptr float_to_complex_; + complex_byte_to_float_x2_sptr cbyte_to_float_x2_; + Gnss_Synchro* gnss_synchro_; + const std::string role_; + const unsigned int vector_length_; + const unsigned int code_length_; + volk_gnsssdr::vector> code_; + pcps_acquisition_sptr acquisition_; +}; + + +/** \} */ +/** \} */ +#endif // GNSS_SDR_BASE_PCPS_ACQUISITION_H diff --git a/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.cc index 06ca206ee..a5d1e7e4e 100644 --- a/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.cc @@ -19,230 +19,19 @@ #include "beidou_b1i_pcps_acquisition.h" #include "Beidou_B1I.h" -#include "acq_conf.h" #include "beidou_b1i_signal_replica.h" -#include "configuration_interface.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 BeidouB1iPcpsAcquisition::BeidouB1iPcpsAcquisition( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : gnss_synchro_(nullptr), - role_(role), - threshold_(0.0), - channel_(0), - in_streams_(in_streams), - out_streams_(out_streams) + unsigned int out_streams) : BasePcpsAcquisition(configuration, role, in_streams, out_streams, BEIDOU_B1I_CODE_RATE_CPS, 10e6, BEIDOU_B1I_CODE_LENGTH_CHIPS, 1) { - acq_parameters_.ms_per_code = 1; - acq_parameters_.SetFromConfiguration(configuration, role, BEIDOU_B1I_CODE_RATE_CPS, 10e6); - - LOG(INFO) << "role " << role; - -#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); - fs_in_ = acq_parameters_.fs_in; - item_type_ = acq_parameters_.item_type; - item_size_ = acq_parameters_.it_size; - - num_codes_ = acq_parameters_.sampled_ms; - code_length_ = static_cast(std::floor(static_cast(fs_in_) / (BEIDOU_B1I_CODE_RATE_CPS / BEIDOU_B1I_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_); - - 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 BeidouB1iPcpsAcquisition::stop_acquisition() +void BeidouB1iPcpsAcquisition::code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) { - acquisition_->set_active(false); -} - - -void BeidouB1iPcpsAcquisition::set_threshold(float threshold) -{ - threshold_ = threshold; - - acquisition_->set_threshold(threshold_); -} - - -void BeidouB1iPcpsAcquisition::set_doppler_max(uint32_t doppler_max) -{ - doppler_max_ = doppler_max; - - acquisition_->set_doppler_max(doppler_max_); -} - - -void BeidouB1iPcpsAcquisition::set_doppler_step(uint32_t doppler_step) -{ - doppler_step_ = doppler_step; - - acquisition_->set_doppler_step(doppler_step_); -} - - -void BeidouB1iPcpsAcquisition::set_gnss_synchro(Gnss_Synchro* gnss_synchro) -{ - gnss_synchro_ = gnss_synchro; - - acquisition_->set_gnss_synchro(gnss_synchro_); -} - - -signed int BeidouB1iPcpsAcquisition::mag() -{ - return acquisition_->mag(); -} - - -void BeidouB1iPcpsAcquisition::init() -{ - acquisition_->init(); - set_local_code(); -} - - -void BeidouB1iPcpsAcquisition::set_local_code() -{ - volk_gnsssdr::vector> code(code_length_); - - beidou_b1i_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 < num_codes_; i++) - { - std::copy_n(code.data(), code_length_, code_span.subspan(i * code_length_, code_length_).data()); - } - - acquisition_->set_local_code(code_.data()); -} - - -void BeidouB1iPcpsAcquisition::reset() -{ - acquisition_->set_active(true); -} - - -void BeidouB1iPcpsAcquisition::set_state(int state) -{ - acquisition_->set_state(state); -} - - -void BeidouB1iPcpsAcquisition::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"; - } -} - - -void BeidouB1iPcpsAcquisition::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 BeidouB1iPcpsAcquisition::get_left_block() -{ - if (item_type_ == "gr_complex" || item_type_ == "cshort") - { - return acquisition_; - } - if (item_type_ == "cbyte") - { - return cbyte_to_float_x2_; - } - else - { - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - return nullptr; - } -} - - -gr::basic_block_sptr BeidouB1iPcpsAcquisition::get_right_block() -{ - return acquisition_; -} - - -void BeidouB1iPcpsAcquisition::set_resampler_latency(uint32_t latency_samples) -{ - acquisition_->set_resampler_latency(latency_samples); + beidou_b1i_code_gen_complex_sampled(dest, prn, sampling_freq, 0); } diff --git a/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h b/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h index 9e0a37ac7..ac04886bb 100644 --- a/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h @@ -20,17 +20,7 @@ #ifndef GNSS_SDR_BEIDOU_B1I_PCPS_ACQUISITION_H #define GNSS_SDR_BEIDOU_B1I_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 -#include -#include +#include "base_pcps_acquisition.h" /** \addtogroup Acquisition * \{ */ @@ -44,7 +34,7 @@ class ConfigurationInterface; * \brief This class adapts a PCPS acquisition block to an AcquisitionInterface * for GPS L1 C/A signals */ -class BeidouB1iPcpsAcquisition : public AcquisitionInterface +class BeidouB1iPcpsAcquisition : public BasePcpsAcquisition { public: BeidouB1iPcpsAcquisition(const ConfigurationInterface* configuration, @@ -53,11 +43,6 @@ public: ~BeidouB1iPcpsAcquisition() = default; - inline std::string role() override - { - return role_; - } - /*! * \brief Returns "BEIDOU_B1I_PCPS_Acquisition" */ @@ -66,113 +51,8 @@ public: return "BEIDOU_B1I_PCPS_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_->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(uint32_t doppler_max) override; - - /*! - * \brief Set Doppler steps for the grid search - */ - void set_doppler_step(uint32_t 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; - - /*! - * \brief Sets the resampler latency to account it in the acquisition code delay estimation - */ - void set_resampler_latency(uint32_t latency_samples) 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_; - Gnss_Synchro* gnss_synchro_; - Acq_Conf acq_parameters_; - std::string item_type_; - std::string role_; - std::string dump_filename_; - size_t item_size_; - int64_t fs_in_; - float threshold_; - unsigned int vector_length_; - unsigned int code_length_; - unsigned int channel_; - unsigned int doppler_max_; - unsigned int doppler_step_; - unsigned int num_codes_; - unsigned int in_streams_; - unsigned int out_streams_; + void code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) override; }; diff --git a/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.cc index a8a524cfa..36f447072 100644 --- a/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.cc @@ -17,227 +17,19 @@ #include "beidou_b3i_pcps_acquisition.h" #include "Beidou_B3I.h" -#include "acq_conf.h" #include "beidou_b3i_signal_replica.h" -#include "configuration_interface.h" -#include "gnss_sdr_flags.h" -#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 BeidouB3iPcpsAcquisition::BeidouB3iPcpsAcquisition( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : gnss_synchro_(nullptr), - role_(role), - threshold_(0.0), - channel_(0), - in_streams_(in_streams), - out_streams_(out_streams) + unsigned int out_streams) : BasePcpsAcquisition(configuration, role, in_streams, out_streams, BEIDOU_B3I_CODE_RATE_CPS, 100e6, BEIDOU_B3I_CODE_LENGTH_CHIPS, 1) { - acq_parameters_.ms_per_code = 1; - acq_parameters_.SetFromConfiguration(configuration, role, BEIDOU_B3I_CODE_RATE_CPS, 100e6); - - LOG(INFO) << "role " << role; - -#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; - - num_codes_ = acq_parameters_.sampled_ms; - code_length_ = static_cast(std::floor(static_cast(fs_in_) / (BEIDOU_B3I_CODE_RATE_CPS / BEIDOU_B3I_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_); - - 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 BeidouB3iPcpsAcquisition::stop_acquisition() +void BeidouB3iPcpsAcquisition::code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) { - acquisition_->set_active(false); -} - - -void BeidouB3iPcpsAcquisition::set_threshold(float threshold) -{ - threshold_ = threshold; - - acquisition_->set_threshold(threshold_); -} - - -void BeidouB3iPcpsAcquisition::set_doppler_max(unsigned int doppler_max) -{ - doppler_max_ = doppler_max; - - acquisition_->set_doppler_max(doppler_max_); -} - - -void BeidouB3iPcpsAcquisition::set_doppler_step(unsigned int doppler_step) -{ - doppler_step_ = doppler_step; - - acquisition_->set_doppler_step(doppler_step_); -} - - -void BeidouB3iPcpsAcquisition::set_gnss_synchro(Gnss_Synchro* gnss_synchro) -{ - gnss_synchro_ = gnss_synchro; - - acquisition_->set_gnss_synchro(gnss_synchro_); -} - - -signed int BeidouB3iPcpsAcquisition::mag() -{ - return acquisition_->mag(); -} - - -void BeidouB3iPcpsAcquisition::init() -{ - acquisition_->init(); -} - - -void BeidouB3iPcpsAcquisition::set_local_code() -{ - volk_gnsssdr::vector> code(code_length_); - - beidou_b3i_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 < num_codes_; i++) - { - std::copy_n(code.data(), code_length_, code_span.subspan(i * code_length_, code_length_).data()); - } - - acquisition_->set_local_code(code_.data()); -} - - -void BeidouB3iPcpsAcquisition::reset() -{ - acquisition_->set_active(true); -} - - -void BeidouB3iPcpsAcquisition::set_state(int state) -{ - acquisition_->set_state(state); -} - - -void BeidouB3iPcpsAcquisition::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"; - } -} - - -void BeidouB3iPcpsAcquisition::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 BeidouB3iPcpsAcquisition::get_left_block() -{ - if (item_type_ == "gr_complex" || item_type_ == "cshort") - { - return acquisition_; - } - if (item_type_ == "cbyte") - { - return cbyte_to_float_x2_; - } - else - { - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - return nullptr; - } -} - - -gr::basic_block_sptr BeidouB3iPcpsAcquisition::get_right_block() -{ - return acquisition_; -} - - -void BeidouB3iPcpsAcquisition::set_resampler_latency(uint32_t latency_samples) -{ - acquisition_->set_resampler_latency(latency_samples); + beidou_b3i_code_gen_complex_sampled(dest, prn, sampling_freq, 0); } diff --git a/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.h b/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.h index 105f3e45c..30da657e5 100644 --- a/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/beidou_b3i_pcps_acquisition.h @@ -18,18 +18,7 @@ #ifndef GNSS_SDR_BEIDOU_B3I_PCPS_ACQUISITION_H #define GNSS_SDR_BEIDOU_B3I_PCPS_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 -#include +#include "base_pcps_acquisition.h" /** \addtogroup Acquisition * \{ */ @@ -43,7 +32,7 @@ class ConfigurationInterface; * \brief This class adapts a PCPS acquisition block to an AcquisitionInterface * for BeiDou B3I signals */ -class BeidouB3iPcpsAcquisition : public AcquisitionInterface +class BeidouB3iPcpsAcquisition : public BasePcpsAcquisition { public: BeidouB3iPcpsAcquisition(const ConfigurationInterface* configuration, @@ -52,11 +41,6 @@ public: ~BeidouB3iPcpsAcquisition() = default; - inline std::string role() override - { - return role_; - } - /*! * \brief Returns "BEIDOU_B1I_PCPS_Acquisition" */ @@ -65,113 +49,8 @@ public: return "BEIDOU_B3I_PCPS_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_->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 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; - - /*! - * \brief Sets the resampler latency to account it in the acquisition code delay estimation - */ - void set_resampler_latency(uint32_t latency_samples) 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_; - Gnss_Synchro* gnss_synchro_; - Acq_Conf acq_parameters_; - std::string item_type_; - std::string role_; - std::string dump_filename_; - size_t item_size_; - int64_t fs_in_; - float threshold_; - unsigned int vector_length_; - unsigned int code_length_; - unsigned int channel_; - unsigned int doppler_max_; - unsigned int doppler_step_; - unsigned int num_codes_; - unsigned int in_streams_; - unsigned int out_streams_; + void code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) override; }; diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.cc index f2bca0108..c4a45cab7 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.cc @@ -43,120 +43,19 @@ GalileoE5aPcpsAcquisition::GalileoE5aPcpsAcquisition( const std::string& role, unsigned int in_streams, unsigned int out_streams) - : gnss_synchro_(nullptr), - role_(role), - threshold_(0.0), - doppler_center_(0), - channel_(0), - in_streams_(in_streams), - out_streams_(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), acq_pilot_(configuration->property(role + ".acquire_pilot", false)), acq_iq_(configuration->property(role + ".acquire_iq", false)) { - acq_parameters_.ms_per_code = 1; - acq_parameters_.SetFromConfiguration(configuration, role_, GALILEO_E5A_CODE_CHIP_RATE_CPS, GALILEO_E5A_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_E5A_CODE_CHIP_RATE_CPS / GALILEO_E5A_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 (acq_iq_) { acq_pilot_ = false; } - - 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 GalileoE5aPcpsAcquisition::stop_acquisition() +void GalileoE5aPcpsAcquisition::code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) { - acquisition_->set_active(false); -} - - -void GalileoE5aPcpsAcquisition::set_threshold(float threshold) -{ - threshold_ = threshold; - - acquisition_->set_threshold(threshold_); -} - - -void GalileoE5aPcpsAcquisition::set_doppler_max(unsigned int doppler_max) -{ - doppler_max_ = doppler_max; - acquisition_->set_doppler_max(doppler_max_); -} - - -void GalileoE5aPcpsAcquisition::set_doppler_step(unsigned int doppler_step) -{ - doppler_step_ = doppler_step; - acquisition_->set_doppler_step(doppler_step_); -} - - -void GalileoE5aPcpsAcquisition::set_doppler_center(int doppler_center) -{ - doppler_center_ = doppler_center; - - acquisition_->set_doppler_center(doppler_center_); -} - - -void GalileoE5aPcpsAcquisition::set_gnss_synchro(Gnss_Synchro* gnss_synchro) -{ - gnss_synchro_ = gnss_synchro; - acquisition_->set_gnss_synchro(gnss_synchro_); -} - - -signed int GalileoE5aPcpsAcquisition::mag() -{ - return acquisition_->mag(); -} - - -void GalileoE5aPcpsAcquisition::init() -{ - acquisition_->init(); -} - - -void GalileoE5aPcpsAcquisition::set_local_code() -{ - volk_gnsssdr::vector> code(code_length_); std::array signal_{}; signal_[0] = '5'; signal_[2] = '\0'; @@ -174,75 +73,5 @@ void GalileoE5aPcpsAcquisition::set_local_code() signal_[1] = 'I'; } - if (acq_parameters_.use_automatic_resampler) - { - galileo_e5_a_code_gen_complex_sampled(code, gnss_synchro_->PRN, signal_, acq_parameters_.resampled_fs, 0); - } - else - { - galileo_e5_a_code_gen_complex_sampled(code, gnss_synchro_->PRN, signal_, 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_->set_local_code(code_.data()); -} - - -void GalileoE5aPcpsAcquisition::reset() -{ - acquisition_->set_active(true); -} - - -void GalileoE5aPcpsAcquisition::set_state(int state) -{ - acquisition_->set_state(state); -} - - -void GalileoE5aPcpsAcquisition::connect(gr::top_block_sptr top_block __attribute__((unused))) -{ - if (item_type_ == "gr_complex" || item_type_ == "cshort") - { - // nothing to connect - } - else - { - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - } -} - - -void GalileoE5aPcpsAcquisition::disconnect(gr::top_block_sptr top_block __attribute__((unused))) -{ - if (item_type_ == "gr_complex" || item_type_ == "cshort") - { - // nothing to disconnect - } - else - { - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - } -} - - -gr::basic_block_sptr GalileoE5aPcpsAcquisition::get_left_block() -{ - return acquisition_; -} - - -gr::basic_block_sptr GalileoE5aPcpsAcquisition::get_right_block() -{ - return acquisition_; -} - - -void GalileoE5aPcpsAcquisition::set_resampler_latency(uint32_t latency_samples) -{ - acquisition_->set_resampler_latency(latency_samples); + galileo_e5_a_code_gen_complex_sampled(dest, prn, signal_, sampling_freq, 0); } diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.h index a2194a729..f238dfd5e 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.h @@ -19,13 +19,7 @@ #define GNSS_SDR_GALILEO_E5A_PCPS_ACQUISITION_H -#include "channel_fsm.h" -#include "gnss_synchro.h" -#include "pcps_acquisition.h" -#include -#include -#include -#include +#include "base_pcps_acquisition.h" /** \addtogroup Acquisition * \{ */ @@ -33,9 +27,7 @@ * \{ */ -class ConfigurationInterface; - -class GalileoE5aPcpsAcquisition : public AcquisitionInterface +class GalileoE5aPcpsAcquisition : public BasePcpsAcquisition { public: GalileoE5aPcpsAcquisition( @@ -46,131 +38,16 @@ public: ~GalileoE5aPcpsAcquisition() = default; - inline std::string role() override - { - return role_; - } - inline std::string implementation() override { return "Galileo_E5a_Pcps_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_->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 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; - - /*! - * \brief Sets the resampler latency to account it in the acquisition code delay estimation - */ - void set_resampler_latency(uint32_t latency_samples) override; - private: - pcps_acquisition_sptr acquisition_; - volk_gnsssdr::vector> code_; - std::weak_ptr channel_fsm_; - Gnss_Synchro* gnss_synchro_; - 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_; + void code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) override; + bool acq_pilot_; - bool acq_iq_; + const bool acq_iq_; }; diff --git a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition.cc index 45b3f7ac6..6be32df12 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition.cc @@ -18,143 +18,25 @@ #include "galileo_e5b_pcps_acquisition.h" #include "Galileo_E5b.h" -#include "acq_conf.h" -#include "configuration_interface.h" #include "galileo_e5_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 GalileoE5bPcpsAcquisition::GalileoE5bPcpsAcquisition(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) - : gnss_synchro_(nullptr), - role_(role), - threshold_(0.0), - doppler_center_(0), - channel_(0), - in_streams_(in_streams), - out_streams_(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), acq_pilot_(configuration->property(role + ".acquire_pilot", false)), acq_iq_(configuration->property(role + ".acquire_iq", false)) { - acq_parameters_.ms_per_code = 1; - acq_parameters_.SetFromConfiguration(configuration, role_, GALILEO_E5B_CODE_CHIP_RATE_CPS, GALILEO_E5B_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_E5B_CODE_CHIP_RATE_CPS / GALILEO_E5B_CODE_LENGTH_CHIPS))); - vector_length_ = static_cast(std::floor(acq_parameters_.sampled_ms * acq_parameters_.samples_per_ms) * (acq_parameters_.bit_transition_flag ? 2.0F : 1.0F)); - 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 (acq_iq_) { acq_pilot_ = false; } - - 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 GalileoE5bPcpsAcquisition::stop_acquisition() +void GalileoE5bPcpsAcquisition::code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) { - acquisition_->set_active(false); -} - - -void GalileoE5bPcpsAcquisition::set_threshold(float threshold) -{ - threshold_ = threshold; - acquisition_->set_threshold(threshold_); -} - - -void GalileoE5bPcpsAcquisition::set_doppler_max(unsigned int doppler_max) -{ - doppler_max_ = doppler_max; - acquisition_->set_doppler_max(doppler_max_); -} - - -void GalileoE5bPcpsAcquisition::set_doppler_step(unsigned int doppler_step) -{ - doppler_step_ = doppler_step; - acquisition_->set_doppler_step(doppler_step_); -} - - -void GalileoE5bPcpsAcquisition::set_doppler_center(int doppler_center) -{ - doppler_center_ = doppler_center; - acquisition_->set_doppler_center(doppler_center_); -} - - -void GalileoE5bPcpsAcquisition::set_gnss_synchro(Gnss_Synchro* gnss_synchro) -{ - gnss_synchro_ = gnss_synchro; - acquisition_->set_gnss_synchro(gnss_synchro_); -} - - -signed int GalileoE5bPcpsAcquisition::mag() -{ - return acquisition_->mag(); -} - - -void GalileoE5bPcpsAcquisition::init() -{ - acquisition_->init(); -} - - -void GalileoE5bPcpsAcquisition::set_local_code() -{ - volk_gnsssdr::vector> code(code_length_); std::array signal_{}; signal_[0] = '7'; signal_[2] = '\0'; @@ -172,75 +54,5 @@ void GalileoE5bPcpsAcquisition::set_local_code() signal_[1] = 'I'; } - if (acq_parameters_.use_automatic_resampler) - { - galileo_e5_b_code_gen_complex_sampled(code, gnss_synchro_->PRN, signal_, acq_parameters_.resampled_fs, 0); - } - else - { - galileo_e5_b_code_gen_complex_sampled(code, gnss_synchro_->PRN, signal_, 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_->set_local_code(code_.data()); -} - - -void GalileoE5bPcpsAcquisition::reset() -{ - acquisition_->set_active(true); -} - - -void GalileoE5bPcpsAcquisition::set_state(int state) -{ - acquisition_->set_state(state); -} - - -void GalileoE5bPcpsAcquisition::connect(gr::top_block_sptr top_block __attribute__((unused))) -{ - if ((item_type_ == "gr_complex") || (item_type_ == "cshort")) - { - // nothing to connect - } - else - { - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - } -} - - -void GalileoE5bPcpsAcquisition::disconnect(gr::top_block_sptr top_block __attribute__((unused))) -{ - if ((item_type_ == "gr_complex") || (item_type_ == "cshort")) - { - // nothing to disconnect - } - else - { - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - } -} - - -gr::basic_block_sptr GalileoE5bPcpsAcquisition::get_left_block() -{ - return acquisition_; -} - - -gr::basic_block_sptr GalileoE5bPcpsAcquisition::get_right_block() -{ - return acquisition_; -} - - -void GalileoE5bPcpsAcquisition::set_resampler_latency(uint32_t latency_samples) -{ - acquisition_->set_resampler_latency(latency_samples); + galileo_e5_b_code_gen_complex_sampled(dest, prn, signal_, sampling_freq, 0); } diff --git a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition.h index 940dac140..8f99d5f69 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e5b_pcps_acquisition.h @@ -20,13 +20,7 @@ #define GNSS_SDR_GALILEO_E5B_PCPS_ACQUISITION_H -#include "channel_fsm.h" -#include "gnss_synchro.h" -#include "pcps_acquisition.h" -#include -#include -#include -#include +#include "base_pcps_acquisition.h" /** \addtogroup Acquisition * \{ */ @@ -36,7 +30,7 @@ class ConfigurationInterface; -class GalileoE5bPcpsAcquisition : public AcquisitionInterface +class GalileoE5bPcpsAcquisition : public BasePcpsAcquisition { public: /*! @@ -52,14 +46,6 @@ public: */ ~GalileoE5bPcpsAcquisition() = default; - /*! - * \brief Role - */ - inline std::string role() override - { - return role_; - } - /*! * \brief Returns "GALILEO_E5b_PCPS_Acquisition" */ @@ -69,145 +55,11 @@ public: return "Galileo_E5b_PCPS_Acquisition"; } - /*! - * \brief Returns size of lv_16sc_t - */ - inline 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 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 Galileo E5b 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; - - /*! - * \brief Sets the resampler latency to account it in the acquisition code delay estimation - */ - void set_resampler_latency(uint32_t latency_samples) override; - private: - pcps_acquisition_sptr acquisition_; - - volk_gnsssdr::vector> code_; - std::weak_ptr channel_fsm_; - - Gnss_Synchro* gnss_synchro_; - Acq_Conf acq_parameters_; - - std::string item_type_; - std::string dump_filename_; - std::string role_; - - size_t item_size_; - int64_t fs_in_; - - 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_; + void code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) override; 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 41affc4a2..d456ab3b5 100644 --- a/src/algorithms/acquisition/adapters/galileo_e6_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e6_pcps_acquisition.cc @@ -17,246 +17,19 @@ #include "galileo_e6_pcps_acquisition.h" #include "Galileo_E6.h" -#include "acq_conf.h" -#include "configuration_interface.h" #include "galileo_e6_signal_replica.h" -#include "gnss_sdr_flags.h" -#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 GalileoE6PcpsAcquisition::GalileoE6PcpsAcquisition( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : gnss_synchro_(nullptr), - configuration_(configuration), - role_(role), - threshold_(0), - doppler_center_(0), - channel_(0), - doppler_step_(0), - in_streams_(in_streams), - out_streams_(out_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) { - acq_parameters_.ms_per_code = 1; - acq_parameters_.SetFromConfiguration(configuration_, role, GALILEO_E6_B_CODE_CHIP_RATE_CPS, GALILEO_E6_OPT_ACQ_FS_SPS); - - DLOG(INFO) << "role " << role; - -#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_E6_B_CODE_CHIP_RATE_CPS / GALILEO_E6_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; - - 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 GalileoE6PcpsAcquisition::stop_acquisition() +void GalileoE6PcpsAcquisition::code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) { - acquisition_->set_active(false); -} - - -void GalileoE6PcpsAcquisition::set_threshold(float threshold) -{ - threshold_ = threshold; - - acquisition_->set_threshold(threshold_); -} - - -void GalileoE6PcpsAcquisition::set_doppler_max(unsigned int doppler_max) -{ - doppler_max_ = doppler_max; - - acquisition_->set_doppler_max(doppler_max_); -} - - -void GalileoE6PcpsAcquisition::set_doppler_step(unsigned int doppler_step) -{ - doppler_step_ = doppler_step; - - acquisition_->set_doppler_step(doppler_step_); -} - - -void GalileoE6PcpsAcquisition::set_doppler_center(int doppler_center) -{ - doppler_center_ = doppler_center; - - acquisition_->set_doppler_center(doppler_center_); -} - - -void GalileoE6PcpsAcquisition::set_gnss_synchro(Gnss_Synchro* gnss_synchro) -{ - gnss_synchro_ = gnss_synchro; - - acquisition_->set_gnss_synchro(gnss_synchro_); -} - - -signed int GalileoE6PcpsAcquisition::mag() -{ - return acquisition_->mag(); -} - - -void GalileoE6PcpsAcquisition::init() -{ - acquisition_->init(); -} - - -void GalileoE6PcpsAcquisition::set_local_code() -{ - volk_gnsssdr::vector> code(code_length_); - - if (acq_parameters_.use_automatic_resampler) - { - galileo_e6_b_code_gen_complex_sampled(code, - gnss_synchro_->PRN, acq_parameters_.resampled_fs, 0); - } - else - { - galileo_e6_b_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_->set_local_code(code_.data()); -} - - -void GalileoE6PcpsAcquisition::reset() -{ - acquisition_->set_active(true); -} - - -void GalileoE6PcpsAcquisition::set_state(int state) -{ - acquisition_->set_state(state); -} - - -void GalileoE6PcpsAcquisition::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"; - } -} - - -void GalileoE6PcpsAcquisition::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 GalileoE6PcpsAcquisition::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 GalileoE6PcpsAcquisition::get_right_block() -{ - return acquisition_; -} - - -void GalileoE6PcpsAcquisition::set_resampler_latency(uint32_t latency_samples) -{ - acquisition_->set_resampler_latency(latency_samples); + galileo_e6_b_code_gen_complex_sampled(dest, prn, sampling_freq, 0); } diff --git a/src/algorithms/acquisition/adapters/galileo_e6_pcps_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e6_pcps_acquisition.h index a3fe58ca2..eb2705da6 100644 --- a/src/algorithms/acquisition/adapters/galileo_e6_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e6_pcps_acquisition.h @@ -18,16 +18,7 @@ #ifndef GNSS_SDR_GALILEO_E6_PCPS_ACQUISITION_H #define GNSS_SDR_GALILEO_E6_PCPS_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 E6 Signals */ -class GalileoE6PcpsAcquisition : public AcquisitionInterface +class GalileoE6PcpsAcquisition : public BasePcpsAcquisition { public: GalileoE6PcpsAcquisition( @@ -52,11 +41,6 @@ public: ~GalileoE6PcpsAcquisition() = default; - inline std::string role() override - { - return role_; - } - /*! * \brief Returns "Galileo_E6_PCPS_Acquisition" */ @@ -65,120 +49,8 @@ public: return "Galileo_E6_PCPS_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; - 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_; - 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_; + void code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) override; }; 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 78903a000..ad6494f73 100644 --- a/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.cc @@ -19,223 +19,19 @@ #include "glonass_l1_ca_pcps_acquisition.h" #include "GLONASS_L1_L2_CA.h" -#include "acq_conf.h" -#include "configuration_interface.h" #include "glonass_l1_signal_replica.h" -#include "gnss_sdr_flags.h" -#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 GlonassL1CaPcpsAcquisition::GlonassL1CaPcpsAcquisition( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : gnss_synchro_(nullptr), - role_(role), - threshold_(0), - channel_(0), - doppler_step_(0), - in_streams_(in_streams), - out_streams_(out_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) { - acq_parameters_.ms_per_code = 1; - acq_parameters_.SetFromConfiguration(configuration, role, GLONASS_L1_CA_CODE_RATE_CPS, 100e6); - - DLOG(INFO) << "role " << role; - -#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) / (GLONASS_L1_CA_CODE_RATE_CPS / GLONASS_L1_CA_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; - - 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 GlonassL1CaPcpsAcquisition::stop_acquisition() +void GlonassL1CaPcpsAcquisition::code_gen_complex_sampled(own::span> dest, uint32_t /*prn*/, int32_t sampling_freq) { - acquisition_->set_active(false); -} - - -void GlonassL1CaPcpsAcquisition::set_threshold(float threshold) -{ - threshold_ = threshold; - - acquisition_->set_threshold(threshold_); -} - - -void GlonassL1CaPcpsAcquisition::set_doppler_max(unsigned int doppler_max) -{ - doppler_max_ = doppler_max; - - acquisition_->set_doppler_max(doppler_max_); -} - - -void GlonassL1CaPcpsAcquisition::set_doppler_step(unsigned int doppler_step) -{ - doppler_step_ = doppler_step; - - acquisition_->set_doppler_step(doppler_step_); -} - - -void GlonassL1CaPcpsAcquisition::set_gnss_synchro(Gnss_Synchro* gnss_synchro) -{ - gnss_synchro_ = gnss_synchro; - - acquisition_->set_gnss_synchro(gnss_synchro_); -} - - -signed int GlonassL1CaPcpsAcquisition::mag() -{ - return acquisition_->mag(); -} - - -void GlonassL1CaPcpsAcquisition::init() -{ - acquisition_->init(); - - set_local_code(); -} - - -void GlonassL1CaPcpsAcquisition::set_local_code() -{ - volk_gnsssdr::vector> code(code_length_); - - glonass_l1_ca_code_gen_complex_sampled(code, 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_->set_local_code(code_.data()); -} - - -void GlonassL1CaPcpsAcquisition::reset() -{ - acquisition_->set_active(true); -} - - -void GlonassL1CaPcpsAcquisition::set_state(int state) -{ - acquisition_->set_state(state); -} - - -void GlonassL1CaPcpsAcquisition::connect(gr::top_block_sptr top_block) -{ - if (item_type_ == "gr_complex" || item_type_ == "cshort") - { - // nothing to connect - } - else if (item_type_ == "cbyte") - { - 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"; - } -} - - -void GlonassL1CaPcpsAcquisition::disconnect(gr::top_block_sptr top_block) -{ - if (item_type_ == "gr_complex" || item_type_ == "cshort") - { - // nothing to disconnect - } - else if (item_type_ == "cbyte") - { - // Since a byte-based acq implementation is not available, - // we just convert cshorts to gr_complex - 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 GlonassL1CaPcpsAcquisition::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 GlonassL1CaPcpsAcquisition::get_right_block() -{ - return acquisition_; + glonass_l1_ca_code_gen_complex_sampled(dest, sampling_freq, 0); } 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 533508fd7..7478d294c 100644 --- a/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.h @@ -20,16 +20,7 @@ #ifndef GNSS_SDR_GLONASS_L1_CA_PCPS_ACQUISITION_H #define GNSS_SDR_GLONASS_L1_CA_PCPS_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 * \{ */ @@ -43,7 +34,7 @@ class ConfigurationInterface; * \brief This class adapts a PCPS acquisition block to an AcquisitionInterface * for GPS L1 C/A signals */ -class GlonassL1CaPcpsAcquisition : public AcquisitionInterface +class GlonassL1CaPcpsAcquisition : public BasePcpsAcquisition { public: GlonassL1CaPcpsAcquisition( @@ -54,11 +45,6 @@ public: ~GlonassL1CaPcpsAcquisition() = default; - inline std::string role() override - { - return role_; - } - /*! * \brief Returns "GLONASS_L1_CA_PCPS_Acquisition" */ @@ -67,110 +53,8 @@ public: return "GLONASS_L1_CA_PCPS_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_->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 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: - 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_; - Gnss_Synchro* gnss_synchro_; - 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_; - 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_; + void code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) override; }; 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 ac2260c0a..ba78a1760 100644 --- a/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc @@ -18,223 +18,19 @@ #include "glonass_l2_ca_pcps_acquisition.h" #include "GLONASS_L1_L2_CA.h" -#include "acq_conf.h" -#include "configuration_interface.h" #include "glonass_l2_signal_replica.h" -#include "gnss_sdr_flags.h" -#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 GlonassL2CaPcpsAcquisition::GlonassL2CaPcpsAcquisition( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : gnss_synchro_(nullptr), - role_(role), - threshold_(0), - channel_(0), - doppler_step_(0), - in_streams_(in_streams), - out_streams_(out_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) { - acq_parameters_.ms_per_code = 1; - acq_parameters_.SetFromConfiguration(configuration, role, GLONASS_L2_CA_CODE_RATE_CPS, 100e6); - - DLOG(INFO) << "role " << role; - -#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) / (GLONASS_L2_CA_CODE_RATE_CPS / GLONASS_L2_CA_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; - - 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 GlonassL2CaPcpsAcquisition::stop_acquisition() +void GlonassL2CaPcpsAcquisition::code_gen_complex_sampled(own::span> dest, uint32_t /*prn*/, int32_t sampling_freq) { - acquisition_->set_active(false); -} - - -void GlonassL2CaPcpsAcquisition::set_threshold(float threshold) -{ - threshold_ = threshold; - - acquisition_->set_threshold(threshold_); -} - - -void GlonassL2CaPcpsAcquisition::set_doppler_max(unsigned int doppler_max) -{ - doppler_max_ = doppler_max; - - acquisition_->set_doppler_max(doppler_max_); -} - - -void GlonassL2CaPcpsAcquisition::set_doppler_step(unsigned int doppler_step) -{ - doppler_step_ = doppler_step; - - acquisition_->set_doppler_step(doppler_step_); -} - - -void GlonassL2CaPcpsAcquisition::set_gnss_synchro(Gnss_Synchro* gnss_synchro) -{ - gnss_synchro_ = gnss_synchro; - - acquisition_->set_gnss_synchro(gnss_synchro_); -} - - -signed int GlonassL2CaPcpsAcquisition::mag() -{ - return acquisition_->mag(); -} - - -void GlonassL2CaPcpsAcquisition::init() -{ - acquisition_->init(); - - set_local_code(); -} - - -void GlonassL2CaPcpsAcquisition::set_local_code() -{ - volk_gnsssdr::vector> code(code_length_); - - glonass_l2_ca_code_gen_complex_sampled(code, 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_->set_local_code(code_.data()); -} - - -void GlonassL2CaPcpsAcquisition::reset() -{ - acquisition_->set_active(true); -} - - -void GlonassL2CaPcpsAcquisition::set_state(int state) -{ - acquisition_->set_state(state); -} - - -void GlonassL2CaPcpsAcquisition::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"; - } -} - - -void GlonassL2CaPcpsAcquisition::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 GlonassL2CaPcpsAcquisition::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 GlonassL2CaPcpsAcquisition::get_right_block() -{ - return acquisition_; + glonass_l2_ca_code_gen_complex_sampled(dest, sampling_freq, 0); } 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 b8a6adf45..b9d91337e 100644 --- a/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.h @@ -20,6 +20,7 @@ #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" @@ -42,7 +43,7 @@ class ConfigurationInterface; * \brief This class adapts a PCPS acquisition block to an AcquisitionInterface * for GLONASS L2 C/A signals */ -class GlonassL2CaPcpsAcquisition : public AcquisitionInterface +class GlonassL2CaPcpsAcquisition : public BasePcpsAcquisition { public: GlonassL2CaPcpsAcquisition( @@ -53,11 +54,6 @@ public: ~GlonassL2CaPcpsAcquisition() = default; - inline std::string role() override - { - return role_; - } - /*! * \brief Returns "GLONASS_L2_CA_PCPS_Acquisition" */ @@ -66,110 +62,8 @@ public: return "GLONASS_L2_CA_PCPS_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_->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 Initializes acquisition algorithm. - */ - void init() override; - - /*! - * \brief Sets local code for GLONASS L2/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: - 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_; - Gnss_Synchro* gnss_synchro_; - 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_; - 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_; + 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.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc index 193239030..846861a6a 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc @@ -21,242 +21,19 @@ #include "gps_l1_ca_pcps_acquisition.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 -#if USE_GLOG_AND_GFLAGS -#include -#else -#include -#endif - -#if HAS_STD_SPAN -#include -namespace own = std; -#else -#include -namespace own = gsl_lite; -#endif GpsL1CaPcpsAcquisition::GpsL1CaPcpsAcquisition( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : gnss_synchro_(nullptr), - role_(role), - threshold_(0.0), - doppler_center_(0), - channel_(0), - doppler_step_(0), - in_streams_(in_streams), - out_streams_(out_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) { - acq_parameters_.ms_per_code = 1; - acq_parameters_.SetFromConfiguration(configuration, role, GPS_L1_CA_CODE_RATE_CPS, GPS_L1_CA_OPT_ACQ_FS_SPS); - - DLOG(INFO) << "role " << role; - -#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; - - code_length_ = static_cast(std::floor(static_cast(acq_parameters_.resampled_fs) / (GPS_L1_CA_CODE_RATE_CPS / GPS_L1_CA_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; - - 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 GpsL1CaPcpsAcquisition::stop_acquisition() +void GpsL1CaPcpsAcquisition::code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) { - acquisition_->set_active(false); -} - - -void GpsL1CaPcpsAcquisition::set_threshold(float threshold) -{ - threshold_ = threshold; - - acquisition_->set_threshold(threshold_); -} - - -void GpsL1CaPcpsAcquisition::set_doppler_max(unsigned int doppler_max) -{ - doppler_max_ = doppler_max; - - acquisition_->set_doppler_max(doppler_max_); -} - - -void GpsL1CaPcpsAcquisition::set_doppler_step(unsigned int doppler_step) -{ - doppler_step_ = doppler_step; - - acquisition_->set_doppler_step(doppler_step_); -} - - -void GpsL1CaPcpsAcquisition::set_doppler_center(int doppler_center) -{ - doppler_center_ = doppler_center; - - acquisition_->set_doppler_center(doppler_center_); -} - - -void GpsL1CaPcpsAcquisition::set_gnss_synchro(Gnss_Synchro* gnss_synchro) -{ - gnss_synchro_ = gnss_synchro; - - acquisition_->set_gnss_synchro(gnss_synchro_); -} - - -signed int GpsL1CaPcpsAcquisition::mag() -{ - return acquisition_->mag(); -} - - -void GpsL1CaPcpsAcquisition::init() -{ - acquisition_->init(); -} - - -void GpsL1CaPcpsAcquisition::set_local_code() -{ - volk_gnsssdr::vector> code(code_length_); - - if (acq_parameters_.use_automatic_resampler) - { - gps_l1_ca_code_gen_complex_sampled(code, gnss_synchro_->PRN, acq_parameters_.resampled_fs, 0); - } - else - { - gps_l1_ca_code_gen_complex_sampled(code, gnss_synchro_->PRN, acq_parameters_.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_->set_local_code(code_.data()); -} - - -void GpsL1CaPcpsAcquisition::reset() -{ - acquisition_->set_active(true); -} - - -void GpsL1CaPcpsAcquisition::set_state(int state) -{ - acquisition_->set_state(state); -} - - -void GpsL1CaPcpsAcquisition::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: " << item_type_; - } -} - - -void GpsL1CaPcpsAcquisition::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" << item_type_; - } -} - - -gr::basic_block_sptr GpsL1CaPcpsAcquisition::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" << item_type_; - return nullptr; -} - - -gr::basic_block_sptr GpsL1CaPcpsAcquisition::get_right_block() -{ - return acquisition_; -} - - -void GpsL1CaPcpsAcquisition::set_resampler_latency(uint32_t latency_samples) -{ - acquisition_->set_resampler_latency(latency_samples); + gps_l1_ca_code_gen_complex_sampled(dest, prn, sampling_freq, 0); } 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 0fd769bce..7e0c55f23 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.h @@ -22,16 +22,7 @@ #ifndef GNSS_SDR_GPS_L1_CA_PCPS_ACQUISITION_H #define GNSS_SDR_GPS_L1_CA_PCPS_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 * Classes for GNSS signal acquisition @@ -47,7 +38,7 @@ class ConfigurationInterface; * \brief This class adapts a PCPS acquisition block to an AcquisitionInterface * for GPS L1 C/A signals */ -class GpsL1CaPcpsAcquisition : public AcquisitionInterface +class GpsL1CaPcpsAcquisition : public BasePcpsAcquisition { public: GpsL1CaPcpsAcquisition( @@ -58,11 +49,6 @@ public: ~GpsL1CaPcpsAcquisition() = default; - inline std::string role() override - { - return role_; - } - /*! * \brief Returns "GPS_L1_CA_PCPS_Acquisition" */ @@ -71,118 +57,8 @@ public: return "GPS_L1_CA_PCPS_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_->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 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; - - /*! - * \brief Sets the resampler latency to account it in the acquisition code delay estimation - */ - void set_resampler_latency(uint32_t latency_samples) 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_; - Gnss_Synchro* gnss_synchro_; - Acq_Conf acq_parameters_; - std::string item_type_; - std::string dump_filename_; - std::string role_; - 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_; + 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 7ff8ae26a..118d668f5 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.cc @@ -19,244 +19,19 @@ #include "gps_l2_m_pcps_acquisition.h" #include "GPS_L2C.h" -#include "acq_conf.h" -#include "configuration_interface.h" -#include "gnss_sdr_flags.h" #include "gps_l2c_signal_replica.h" -#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 GpsL2MPcpsAcquisition::GpsL2MPcpsAcquisition( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : gnss_synchro_(nullptr), - role_(role), - threshold_(0), - doppler_center_(0), - channel_(0), - doppler_step_(0), - in_streams_(in_streams), - out_streams_(out_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) { - acq_parameters_.ms_per_code = 20; - acq_parameters_.SetFromConfiguration(configuration, role, GPS_L2_M_CODE_RATE_CPS, GPS_L2C_OPT_ACQ_FS_SPS); - - DLOG(INFO) << "Role " << role; - -#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) / (GPS_L2_M_CODE_RATE_CPS / GPS_L2_M_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_); - - 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(); - } - - num_codes_ = acq_parameters_.sampled_ms / acq_parameters_.ms_per_code; - 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 GpsL2MPcpsAcquisition::stop_acquisition() +void GpsL2MPcpsAcquisition::code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) { - acquisition_->set_active(false); -} - - -void GpsL2MPcpsAcquisition::set_threshold(float threshold) -{ - threshold_ = threshold; - - acquisition_->set_threshold(threshold_); -} - - -void GpsL2MPcpsAcquisition::set_doppler_max(unsigned int doppler_max) -{ - doppler_max_ = doppler_max; - - acquisition_->set_doppler_max(doppler_max_); -} - - -// Be aware that Doppler step should be set to 2/(3T) Hz, where T is the coherent integration time (GPS L2 period is 0.02s) -// Doppler bin minimum size= 33 Hz -void GpsL2MPcpsAcquisition::set_doppler_step(unsigned int doppler_step) -{ - doppler_step_ = doppler_step; - - acquisition_->set_doppler_step(doppler_step_); -} - - -void GpsL2MPcpsAcquisition::set_doppler_center(int doppler_center) -{ - doppler_center_ = doppler_center; - - acquisition_->set_doppler_center(doppler_center_); -} - - -void GpsL2MPcpsAcquisition::set_gnss_synchro(Gnss_Synchro* gnss_synchro) -{ - gnss_synchro_ = gnss_synchro; - - acquisition_->set_gnss_synchro(gnss_synchro_); -} - - -signed int GpsL2MPcpsAcquisition::mag() -{ - return acquisition_->mag(); -} - - -void GpsL2MPcpsAcquisition::init() -{ - acquisition_->init(); -} - - -void GpsL2MPcpsAcquisition::set_local_code() -{ - volk_gnsssdr::vector> code(code_length_); - - if (acq_parameters_.use_automatic_resampler) - { - gps_l2c_m_code_gen_complex_sampled(code, gnss_synchro_->PRN, acq_parameters_.resampled_fs); - } - else - { - gps_l2c_m_code_gen_complex_sampled(code, gnss_synchro_->PRN, 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_->set_local_code(code_.data()); -} - - -void GpsL2MPcpsAcquisition::reset() -{ - acquisition_->set_active(true); -} - - -void GpsL2MPcpsAcquisition::set_state(int state) -{ - acquisition_->set_state(state); -} - - -void GpsL2MPcpsAcquisition::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"; - } -} - - -void GpsL2MPcpsAcquisition::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 GpsL2MPcpsAcquisition::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 GpsL2MPcpsAcquisition::get_right_block() -{ - return acquisition_; -} - - -void GpsL2MPcpsAcquisition::set_resampler_latency(uint32_t latency_samples) -{ - acquisition_->set_resampler_latency(latency_samples); + gps_l2c_m_code_gen_complex_sampled(dest, prn, sampling_freq); } 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 f485ccd1b..10a5ff8fc 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.h @@ -20,16 +20,7 @@ #ifndef GNSS_SDR_GPS_L2_M_PCPS_ACQUISITION_H #define GNSS_SDR_GPS_L2_M_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 -#include +#include "base_pcps_acquisition.h" /** \addtogroup Acquisition * \{ */ @@ -43,7 +34,7 @@ class ConfigurationInterface; * \brief This class adapts a PCPS acquisition block to an AcquisitionInterface * for GPS L2 M signals */ -class GpsL2MPcpsAcquisition : public AcquisitionInterface +class GpsL2MPcpsAcquisition : public BasePcpsAcquisition { public: GpsL2MPcpsAcquisition( @@ -54,11 +45,6 @@ public: ~GpsL2MPcpsAcquisition() = default; - inline std::string role() override - { - return role_; - } - /*! * \brief Returns "GPS_L2_M_PCPS_Acquisition" */ @@ -67,119 +53,8 @@ public: return "GPS_L2_M_PCPS_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_->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 GPS L2/M 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; - private: - pcps_acquisition_sptr acquisition_; - volk_gnsssdr::vector> code_; - gr::blocks::float_to_complex::sptr float_to_complex_; - complex_byte_to_float_x2_sptr cbyte_to_float_x2_; - std::weak_ptr channel_fsm_; - Gnss_Synchro* gnss_synchro_; - Acq_Conf acq_parameters_; - std::string item_type_; - std::string dump_filename_; - std::string role_; - size_t item_size_; - int64_t fs_in_; - 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 in_streams_; - unsigned int out_streams_; - unsigned int num_codes_; + void code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) override; }; diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.cc index 8a94303e0..eecd5d478 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.cc @@ -19,246 +19,19 @@ #include "gps_l5i_pcps_acquisition.h" #include "GPS_L5.h" -#include "acq_conf.h" -#include "configuration_interface.h" -#include "gnss_sdr_flags.h" #include "gps_l5_signal_replica.h" -#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 GpsL5iPcpsAcquisition::GpsL5iPcpsAcquisition( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, - unsigned int out_streams) : gnss_synchro_(nullptr), - role_(role), - threshold_(0.0), - doppler_center_(0), - channel_(0), - doppler_step_(0), - in_streams_(in_streams), - out_streams_(out_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) { - acq_parameters_.ms_per_code = 1; - acq_parameters_.SetFromConfiguration(configuration, role, GPS_L5I_CODE_RATE_CPS, GPS_L5_OPT_ACQ_FS_SPS); - - DLOG(INFO) << "role " << role; - -#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; - - code_length_ = static_cast(std::floor(static_cast(acq_parameters_.resampled_fs) / (GPS_L5I_CODE_RATE_CPS / GPS_L5I_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_); - fs_in_ = acq_parameters_.fs_in; - - num_codes_ = acq_parameters_.sampled_ms; - - 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 GpsL5iPcpsAcquisition::stop_acquisition() +void GpsL5iPcpsAcquisition::code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) { - acquisition_->set_active(false); -} - - -void GpsL5iPcpsAcquisition::set_threshold(float threshold) -{ - threshold_ = threshold; - - acquisition_->set_threshold(threshold_); -} - - -void GpsL5iPcpsAcquisition::set_doppler_max(unsigned int doppler_max) -{ - doppler_max_ = doppler_max; - - acquisition_->set_doppler_max(doppler_max_); -} - - -// Be aware that Doppler step should be set to 2/(3T) Hz, where T is the coherent integration time (GPS L2 period is 0.02s) -// Doppler bin minimum size= 33 Hz -void GpsL5iPcpsAcquisition::set_doppler_step(unsigned int doppler_step) -{ - doppler_step_ = doppler_step; - - acquisition_->set_doppler_step(doppler_step_); -} - - -void GpsL5iPcpsAcquisition::set_doppler_center(int doppler_center) -{ - doppler_center_ = doppler_center; - - acquisition_->set_doppler_center(doppler_center_); -} - - -void GpsL5iPcpsAcquisition::set_gnss_synchro(Gnss_Synchro* gnss_synchro) -{ - gnss_synchro_ = gnss_synchro; - - acquisition_->set_gnss_synchro(gnss_synchro_); -} - - -signed int GpsL5iPcpsAcquisition::mag() -{ - return acquisition_->mag(); -} - - -void GpsL5iPcpsAcquisition::init() -{ - acquisition_->init(); -} - - -void GpsL5iPcpsAcquisition::set_local_code() -{ - volk_gnsssdr::vector> code(code_length_); - - if (acq_parameters_.use_automatic_resampler) - { - gps_l5i_code_gen_complex_sampled(code, gnss_synchro_->PRN, acq_parameters_.resampled_fs); - } - else - { - gps_l5i_code_gen_complex_sampled(code, gnss_synchro_->PRN, 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_->set_local_code(code_.data()); -} - - -void GpsL5iPcpsAcquisition::reset() -{ - acquisition_->set_active(true); -} - - -void GpsL5iPcpsAcquisition::set_state(int state) -{ - acquisition_->set_state(state); -} - - -void GpsL5iPcpsAcquisition::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: " << item_type_; - } -} - - -void GpsL5iPcpsAcquisition::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" << item_type_; - } -} - - -gr::basic_block_sptr GpsL5iPcpsAcquisition::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" << item_type_; - return nullptr; -} - - -gr::basic_block_sptr GpsL5iPcpsAcquisition::get_right_block() -{ - return acquisition_; -} - - -void GpsL5iPcpsAcquisition::set_resampler_latency(uint32_t latency_samples) -{ - acquisition_->set_resampler_latency(latency_samples); + gps_l5i_code_gen_complex_sampled(dest, prn, sampling_freq); } diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.h b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.h index 6230e7a57..7fad5c612 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.h @@ -20,15 +20,7 @@ #ifndef GNSS_SDR_GPS_L5I_PCPS_ACQUISITION_H #define GNSS_SDR_GPS_L5I_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 +#include "base_pcps_acquisition.h" /** \addtogroup Acquisition * \{ */ @@ -42,7 +34,7 @@ class ConfigurationInterface; * \brief This class adapts a PCPS acquisition block to an AcquisitionInterface * for GPS L5i signals */ -class GpsL5iPcpsAcquisition : public AcquisitionInterface +class GpsL5iPcpsAcquisition : public BasePcpsAcquisition { public: GpsL5iPcpsAcquisition( @@ -53,11 +45,6 @@ public: ~GpsL5iPcpsAcquisition() = default; - inline std::string role() override - { - return role_; - } - /*! * \brief Returns "GPS_L5i_PCPS_Acquisition" */ @@ -66,119 +53,8 @@ public: return "GPS_L5i_PCPS_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_->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 GPS L2/M 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; - private: - pcps_acquisition_sptr acquisition_; - volk_gnsssdr::vector> code_; - gr::blocks::float_to_complex::sptr float_to_complex_; - complex_byte_to_float_x2_sptr cbyte_to_float_x2_; - std::weak_ptr channel_fsm_; - Gnss_Synchro* gnss_synchro_; - Acq_Conf acq_parameters_; - std::string item_type_; - std::string dump_filename_; - std::string role_; - size_t item_size_; - int64_t fs_in_; - 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 in_streams_; - unsigned int out_streams_; - unsigned int num_codes_; + void code_gen_complex_sampled(own::span> dest, uint32_t prn, int32_t sampling_freq) override; };