2012-07-12 21:17:37 +00:00
|
|
|
/*!
|
2018-02-07 07:43:44 +00:00
|
|
|
* \file pcps_acquisition.h
|
2012-09-12 15:03:38 +00:00
|
|
|
* \brief This class implements a Parallel Code Phase Search Acquisition
|
2012-07-12 21:17:37 +00:00
|
|
|
*
|
2012-09-12 15:03:38 +00:00
|
|
|
* Acquisition strategy (Kay Borre book + CFAR threshold).
|
|
|
|
* <ol>
|
|
|
|
* <li> Compute the input signal power estimation
|
|
|
|
* <li> Doppler serial search loop
|
|
|
|
* <li> Perform the FFT-based circular convolution (parallel time search)
|
|
|
|
* <li> Record the maximum peak and the associated synchronization parameters
|
|
|
|
* <li> Compute the test statistics and compare to the threshold
|
|
|
|
* <li> Declare positive or negative acquisition using a message queue
|
|
|
|
* </ol>
|
2012-07-12 21:17:37 +00:00
|
|
|
*
|
2012-09-12 15:03:38 +00:00
|
|
|
* Kay Borre book: K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen,
|
|
|
|
* "A Software-Defined GPS and Galileo Receiver. A Single-Frequency
|
2017-08-21 09:45:12 +00:00
|
|
|
* Approach", Birkhauser, 2007. pp 81-84
|
2012-09-12 15:03:38 +00:00
|
|
|
*
|
|
|
|
* \authors <ul>
|
|
|
|
* <li> Javier Arribas, 2011. jarribas(at)cttc.es
|
|
|
|
* <li> Luis Esteve, 2012. luis(at)epsilon-formacion.com
|
2013-07-23 18:03:07 +00:00
|
|
|
* <li> Marc Molina, 2013. marc.molina.pena@gmail.com
|
2017-10-03 11:47:55 +00:00
|
|
|
* <li> Cillian O'Driscoll, 2017. cillian(at)ieee.org
|
2018-01-09 15:43:38 +00:00
|
|
|
* <li> Antonio Ramos, 2017. antonio.ramos@cttc.es
|
2012-09-12 15:03:38 +00:00
|
|
|
* </ul>
|
2012-07-12 21:17:37 +00:00
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2012-07-12 21:17:37 +00:00
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
|
2012-07-12 21:17:37 +00:00
|
|
|
*
|
|
|
|
* GNSS-SDR is a software defined Global Navigation
|
|
|
|
* Satellite Systems receiver
|
|
|
|
*
|
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2012-07-12 21:17:37 +00:00
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2012-07-12 21:17:37 +00:00
|
|
|
*/
|
|
|
|
|
2020-02-08 09:10:46 +00:00
|
|
|
#ifndef GNSS_SDR_PCPS_ACQUISITION_H
|
|
|
|
#define GNSS_SDR_PCPS_ACQUISITION_H
|
2012-07-12 21:17:37 +00:00
|
|
|
|
2019-07-29 19:22:44 +00:00
|
|
|
#if ARMA_NO_BOUND_CHECKING
|
|
|
|
#define ARMA_NO_DEBUG 1
|
|
|
|
#endif
|
|
|
|
|
2018-06-19 10:59:54 +00:00
|
|
|
#include "acq_conf.h"
|
2019-03-20 14:13:17 +00:00
|
|
|
#include "channel_fsm.h"
|
2018-02-05 06:31:34 +00:00
|
|
|
#include <armadillo>
|
2019-07-23 15:56:02 +00:00
|
|
|
#include <glog/logging.h>
|
2013-07-04 13:47:40 +00:00
|
|
|
#include <gnuradio/block.h>
|
2012-11-25 11:15:11 +00:00
|
|
|
#include <gnuradio/fft/fft.h>
|
2019-10-26 20:24:42 +00:00
|
|
|
#include <gnuradio/gr_complex.h> // for gr_complex
|
|
|
|
#include <gnuradio/thread/thread.h> // for scoped_lock
|
|
|
|
#include <gnuradio/types.h> // for gr_vector_const_void_star
|
|
|
|
#include <volk/volk_complex.h> // for lv_16sc_t
|
|
|
|
#include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
|
2019-07-01 19:54:52 +00:00
|
|
|
#include <complex>
|
2019-03-06 15:10:18 +00:00
|
|
|
#include <cstdint>
|
2019-06-30 10:51:23 +00:00
|
|
|
#include <memory>
|
2018-02-26 02:15:53 +00:00
|
|
|
#include <string>
|
2019-04-22 11:03:01 +00:00
|
|
|
#include <utility>
|
2020-10-09 18:55:31 +00:00
|
|
|
#include <queue>
|
2020-05-07 19:47:45 +00:00
|
|
|
|
|
|
|
#if HAS_STD_SPAN
|
|
|
|
#include <span>
|
2020-05-07 21:11:11 +00:00
|
|
|
namespace own = std;
|
2020-05-07 19:47:45 +00:00
|
|
|
#else
|
|
|
|
#include <gsl/gsl>
|
2020-05-07 21:11:11 +00:00
|
|
|
namespace own = gsl;
|
2020-05-07 19:47:45 +00:00
|
|
|
#endif
|
|
|
|
|
2020-04-02 21:59:35 +00:00
|
|
|
#if GNURADIO_USES_STD_POINTERS
|
|
|
|
#else
|
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
#endif
|
2018-02-05 06:31:34 +00:00
|
|
|
|
2019-03-06 15:10:18 +00:00
|
|
|
class Gnss_Synchro;
|
2018-02-07 07:43:44 +00:00
|
|
|
class pcps_acquisition;
|
2013-07-04 13:47:40 +00:00
|
|
|
|
2020-04-02 21:59:35 +00:00
|
|
|
#if GNURADIO_USES_STD_POINTERS
|
2020-04-02 11:23:20 +00:00
|
|
|
using pcps_acquisition_sptr = std::shared_ptr<pcps_acquisition>;
|
2020-04-02 21:59:35 +00:00
|
|
|
#else
|
|
|
|
using pcps_acquisition_sptr = boost::shared_ptr<pcps_acquisition>;
|
|
|
|
#endif
|
2013-07-04 13:47:40 +00:00
|
|
|
|
2019-07-01 19:54:52 +00:00
|
|
|
pcps_acquisition_sptr pcps_make_acquisition(const Acq_Conf& conf_);
|
2012-07-12 21:17:37 +00:00
|
|
|
|
2012-09-12 15:03:38 +00:00
|
|
|
/*!
|
2013-01-25 19:24:17 +00:00
|
|
|
* \brief This class implements a Parallel Code Phase Search Acquisition.
|
|
|
|
*
|
|
|
|
* Check \ref Navitec2012 "An Open Source Galileo E1 Software Receiver",
|
|
|
|
* Algorithm 1, for a pseudocode description of this implementation.
|
2012-09-12 15:03:38 +00:00
|
|
|
*/
|
2018-03-03 01:03:39 +00:00
|
|
|
class pcps_acquisition : public gr::block
|
2012-11-25 11:15:11 +00:00
|
|
|
{
|
2012-07-12 21:17:37 +00:00
|
|
|
public:
|
2019-07-21 17:32:52 +00:00
|
|
|
~pcps_acquisition() = default;
|
2013-11-29 08:38:22 +00:00
|
|
|
|
2020-06-25 00:50:07 +00:00
|
|
|
/*!
|
|
|
|
* \brief Initializes acquisition algorithm and reserves memory.
|
|
|
|
*/
|
|
|
|
void init();
|
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
/*!
|
2019-04-22 11:03:01 +00:00
|
|
|
* \brief Set acquisition/tracking common Gnss_Synchro object pointer
|
|
|
|
* to exchange synchronization data between acquisition and tracking blocks.
|
|
|
|
* \param p_gnss_synchro Satellite information shared by the processing blocks.
|
|
|
|
*/
|
2018-01-23 11:28:29 +00:00
|
|
|
inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro)
|
|
|
|
{
|
2018-03-03 01:03:39 +00:00
|
|
|
gr::thread::scoped_lock lock(d_setlock); // require mutex with work function called by the scheduler
|
2018-01-23 11:28:29 +00:00
|
|
|
d_gnss_synchro = p_gnss_synchro;
|
|
|
|
}
|
2013-11-29 08:38:22 +00:00
|
|
|
|
2018-01-23 11:28:29 +00:00
|
|
|
/*!
|
2020-06-25 00:50:07 +00:00
|
|
|
* \brief Sets local code for PCPS acquisition algorithm.
|
|
|
|
* \param code - Pointer to the PRN code.
|
2018-01-23 11:28:29 +00:00
|
|
|
*/
|
2020-06-25 00:50:07 +00:00
|
|
|
void set_local_code(std::complex<float>* code);
|
2013-11-29 08:38:22 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
/*!
|
2020-06-25 00:50:07 +00:00
|
|
|
* \brief If set to 1, ensures that acquisition starts at the
|
|
|
|
* first available sample.
|
|
|
|
* \param state - int=1 forces start of acquisition
|
2019-04-22 11:03:01 +00:00
|
|
|
*/
|
2020-06-25 00:50:07 +00:00
|
|
|
void set_state(int32_t state);
|
|
|
|
|
|
|
|
void set_resampler_latency(uint32_t latency_samples);
|
2013-11-29 08:38:22 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
/*!
|
2020-06-25 00:50:07 +00:00
|
|
|
* \brief Returns the maximum peak of grid search.
|
2019-04-22 11:03:01 +00:00
|
|
|
*/
|
2020-06-25 00:50:07 +00:00
|
|
|
inline uint32_t mag() const
|
|
|
|
{
|
|
|
|
return d_mag;
|
|
|
|
}
|
2013-11-29 08:38:22 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
/*!
|
2019-04-22 11:03:01 +00:00
|
|
|
* \brief Starts acquisition algorithm, turning from standby mode to
|
|
|
|
* active mode
|
|
|
|
* \param active - bool that activates/deactivates the block.
|
|
|
|
*/
|
2018-01-23 11:28:29 +00:00
|
|
|
inline void set_active(bool active)
|
|
|
|
{
|
2018-03-03 01:03:39 +00:00
|
|
|
gr::thread::scoped_lock lock(d_setlock); // require mutex with work function called by the scheduler
|
2018-01-23 11:28:29 +00:00
|
|
|
d_active = active;
|
|
|
|
}
|
2013-11-29 08:38:22 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
/*!
|
2019-04-22 11:03:01 +00:00
|
|
|
* \brief Set acquisition channel unique ID
|
|
|
|
* \param channel - receiver channel.
|
|
|
|
*/
|
2018-08-10 18:34:03 +00:00
|
|
|
inline void set_channel(uint32_t channel)
|
2018-01-23 11:28:29 +00:00
|
|
|
{
|
|
|
|
d_channel = channel;
|
|
|
|
}
|
2013-11-29 08:38:22 +00:00
|
|
|
|
2019-03-20 14:13:17 +00:00
|
|
|
/*!
|
2019-04-22 11:03:01 +00:00
|
|
|
* \brief Set channel fsm associated to this acquisition instance
|
|
|
|
*/
|
2019-04-09 15:39:48 +00:00
|
|
|
inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm)
|
2019-03-20 14:13:17 +00:00
|
|
|
{
|
2019-04-22 11:03:01 +00:00
|
|
|
d_channel_fsm = std::move(channel_fsm);
|
2019-03-20 14:13:17 +00:00
|
|
|
}
|
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
/*!
|
2019-04-22 11:03:01 +00:00
|
|
|
* \brief Set statistics threshold of PCPS algorithm.
|
|
|
|
* \param threshold - Threshold for signal detection (check \ref Navitec2012,
|
|
|
|
* Algorithm 1, for a definition of this threshold).
|
|
|
|
*/
|
2018-01-23 11:28:29 +00:00
|
|
|
inline void set_threshold(float threshold)
|
|
|
|
{
|
2018-03-03 01:03:39 +00:00
|
|
|
gr::thread::scoped_lock lock(d_setlock); // require mutex with work function called by the scheduler
|
2018-01-23 11:28:29 +00:00
|
|
|
d_threshold = threshold;
|
|
|
|
}
|
2013-11-29 08:38:22 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
/*!
|
2019-04-22 11:03:01 +00:00
|
|
|
* \brief Set maximum Doppler grid search
|
|
|
|
* \param doppler_max - Maximum Doppler shift considered in the grid search [Hz].
|
|
|
|
*/
|
2018-08-10 18:34:03 +00:00
|
|
|
inline void set_doppler_max(uint32_t doppler_max)
|
2018-01-23 11:28:29 +00:00
|
|
|
{
|
2018-03-03 01:03:39 +00:00
|
|
|
gr::thread::scoped_lock lock(d_setlock); // require mutex with work function called by the scheduler
|
2020-06-19 01:51:50 +00:00
|
|
|
d_acq_parameters.doppler_max = doppler_max;
|
2018-01-23 11:28:29 +00:00
|
|
|
}
|
2013-11-29 08:38:22 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
/*!
|
2019-04-22 11:03:01 +00:00
|
|
|
* \brief Set Doppler steps for the grid search
|
|
|
|
* \param doppler_step - Frequency bin of the search grid [Hz].
|
|
|
|
*/
|
2018-08-10 18:34:03 +00:00
|
|
|
inline void set_doppler_step(uint32_t doppler_step)
|
2018-01-23 11:28:29 +00:00
|
|
|
{
|
2018-03-03 01:03:39 +00:00
|
|
|
gr::thread::scoped_lock lock(d_setlock); // require mutex with work function called by the scheduler
|
2018-01-23 11:28:29 +00:00
|
|
|
d_doppler_step = doppler_step;
|
|
|
|
}
|
2013-11-29 08:38:22 +00:00
|
|
|
|
2019-07-23 15:56:02 +00:00
|
|
|
/*!
|
|
|
|
* \brief Set Doppler center frequency for the grid search. It will refresh the Doppler grid.
|
|
|
|
* \param doppler_center - Frequency center of the search grid [Hz].
|
|
|
|
*/
|
|
|
|
inline void set_doppler_center(int32_t doppler_center)
|
|
|
|
{
|
|
|
|
gr::thread::scoped_lock lock(d_setlock); // require mutex with work function called by the scheduler
|
|
|
|
if (doppler_center != d_doppler_center)
|
|
|
|
{
|
|
|
|
DLOG(INFO) << " Doppler assistance for Channel: " << d_channel << " => Doppler: " << doppler_center << "[Hz]";
|
|
|
|
d_doppler_center = doppler_center;
|
|
|
|
update_grid_doppler_wipeoffs();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
/*!
|
2019-04-22 11:03:01 +00:00
|
|
|
* \brief Parallel Code Phase Search Acquisition signal processing.
|
|
|
|
*/
|
2018-03-03 01:03:39 +00:00
|
|
|
int general_work(int noutput_items, gr_vector_int& ninput_items,
|
|
|
|
gr_vector_const_void_star& input_items,
|
|
|
|
gr_vector_void_star& output_items);
|
2019-07-01 19:54:52 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend pcps_acquisition_sptr pcps_make_acquisition(const Acq_Conf& conf_);
|
2019-08-23 19:25:44 +00:00
|
|
|
explicit pcps_acquisition(const Acq_Conf& conf_);
|
2020-06-19 10:39:28 +00:00
|
|
|
|
|
|
|
void update_local_carrier(own::span<gr_complex> carrier_vector, float freq);
|
|
|
|
void update_grid_doppler_wipeoffs();
|
|
|
|
void update_grid_doppler_wipeoffs_step2();
|
|
|
|
void acquisition_core(uint64_t samp_count);
|
|
|
|
void send_negative_acquisition();
|
|
|
|
void send_positive_acquisition();
|
|
|
|
void dump_results(int32_t effective_fft_size);
|
|
|
|
bool is_fdma();
|
|
|
|
bool start();
|
|
|
|
void calculate_threshold(void);
|
|
|
|
float first_vs_second_peak_statistic(uint32_t& indext, int32_t& doppler, uint32_t num_doppler_bins, int32_t doppler_max, int32_t doppler_step);
|
|
|
|
float max_to_input_power_statistic(uint32_t& indext, int32_t& doppler, uint32_t num_doppler_bins, int32_t doppler_max, int32_t doppler_step);
|
|
|
|
|
2019-10-26 20:24:42 +00:00
|
|
|
volk_gnsssdr::vector<volk_gnsssdr::vector<float>> d_magnitude_grid;
|
|
|
|
volk_gnsssdr::vector<float> d_tmp_buffer;
|
|
|
|
volk_gnsssdr::vector<std::complex<float>> d_input_signal;
|
|
|
|
volk_gnsssdr::vector<volk_gnsssdr::vector<std::complex<float>>> d_grid_doppler_wipeoffs;
|
|
|
|
volk_gnsssdr::vector<volk_gnsssdr::vector<std::complex<float>>> d_grid_doppler_wipeoffs_step_two;
|
|
|
|
volk_gnsssdr::vector<std::complex<float>> d_fft_codes;
|
|
|
|
volk_gnsssdr::vector<std::complex<float>> d_data_buffer;
|
|
|
|
volk_gnsssdr::vector<lv_16sc_t> d_data_buffer_sc;
|
2020-06-23 07:47:58 +00:00
|
|
|
|
|
|
|
std::unique_ptr<gr::fft::fft_complex> d_fft_if;
|
|
|
|
std::unique_ptr<gr::fft::fft_complex> d_ifft;
|
|
|
|
std::weak_ptr<ChannelFsm> d_channel_fsm;
|
|
|
|
|
2020-06-19 01:51:50 +00:00
|
|
|
Acq_Conf d_acq_parameters;
|
2019-07-01 19:54:52 +00:00
|
|
|
Gnss_Synchro* d_gnss_synchro;
|
2020-06-19 01:51:50 +00:00
|
|
|
arma::fmat d_grid;
|
|
|
|
arma::fmat d_narrow_grid;
|
2020-06-23 07:47:58 +00:00
|
|
|
|
2020-06-25 00:50:07 +00:00
|
|
|
std::string d_dump_filename;
|
|
|
|
|
2020-06-23 07:47:58 +00:00
|
|
|
int64_t d_dump_number;
|
|
|
|
uint64_t d_sample_counter;
|
|
|
|
|
|
|
|
float d_threshold;
|
|
|
|
float d_mag;
|
|
|
|
float d_input_power;
|
|
|
|
float d_test_statistics;
|
|
|
|
float d_doppler_center_step_two;
|
|
|
|
|
|
|
|
int32_t d_state;
|
|
|
|
int32_t d_positive_acq;
|
|
|
|
int32_t d_doppler_center;
|
|
|
|
int32_t d_doppler_bias;
|
|
|
|
uint32_t d_channel;
|
|
|
|
uint32_t d_samplesPerChip;
|
|
|
|
uint32_t d_doppler_step;
|
|
|
|
uint32_t d_num_noncoherent_integrations_counter;
|
|
|
|
uint32_t d_fft_size;
|
|
|
|
uint32_t d_consumed_samples;
|
|
|
|
uint32_t d_num_doppler_bins;
|
|
|
|
uint32_t d_num_doppler_bins_step2;
|
|
|
|
uint32_t d_dump_channel;
|
|
|
|
uint32_t d_buffer_count;
|
|
|
|
|
|
|
|
bool d_active;
|
|
|
|
bool d_worker_active;
|
|
|
|
bool d_cshort;
|
|
|
|
bool d_step_two;
|
|
|
|
bool d_use_CFAR_algorithm_flag;
|
|
|
|
bool d_dump;
|
2020-10-09 18:55:31 +00:00
|
|
|
|
|
|
|
std::queue<Gnss_Synchro> d_monitor_queue;
|
2012-07-12 21:17:37 +00:00
|
|
|
};
|
|
|
|
|
2020-02-08 09:10:46 +00:00
|
|
|
#endif // GNSS_SDR_PCPS_ACQUISITION_H
|