GNSS-SDR  0.0.19
An Open Source GNSS Software Defined Receiver
pcps_acquisition_fine_doppler_cc.h
Go to the documentation of this file.
1 /*!
2  * \file pcps_acquisition_fine_doppler_cc.h
3  * \brief This class implements a Parallel Code Phase Search Acquisition with multi-dwells and fine Doppler estimation
4  * for GPS L1 C/A signal
5  *
6  * Acquisition strategy (Kay Borre book).
7  * <ol>
8  * <li> Compute the input signal power estimation
9  * <li> Doppler serial search loop
10  * <li> Perform the FFT-based circular convolution (parallel time search)
11  * <li> Record the maximum peak and the associated synchronization parameters
12  * <li> Compute the test statistics and compare to the threshold
13  * <li> Declare positive or negative acquisition using a message port
14  * </ol>
15  *
16  * Kay Borre book: K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen,
17  * "A Software-Defined GPS and Galileo Receiver. A Single-Frequency
18  * Approach", Birkhauser, 2007. pp 81-84
19  *
20  * \authors <ul>
21  * <li> Javier Arribas, 2013. jarribas(at)cttc.es
22  * </ul>
23  *
24  * -----------------------------------------------------------------------------
25  *
26  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
27  * This file is part of GNSS-SDR.
28  *
29  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
30  * SPDX-License-Identifier: GPL-3.0-or-later
31  *
32  * -----------------------------------------------------------------------------
33  */
34 
35 #ifndef GNSS_SDR_PCPS_ACQUISITION_FINE_DOPPLER_CC_H
36 #define GNSS_SDR_PCPS_ACQUISITION_FINE_DOPPLER_CC_H
37 
38 #if ARMA_NO_BOUND_CHECKING
39 #define ARMA_NO_DEBUG 1
40 #endif
41 
42 #include "acq_conf.h"
43 #include "channel_fsm.h"
44 #include "gnss_sdr_fft.h"
45 #include "gnss_synchro.h"
46 #include <armadillo>
47 #include <gnuradio/block.h>
48 #include <gnuradio/gr_complex.h>
49 #include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
50 #include <cstdint>
51 #include <fstream>
52 #include <memory>
53 #include <string>
54 #include <utility>
55 
56 
57 /** \addtogroup Acquisition
58  * \{ */
59 /** \addtogroup Acq_gnuradio_blocks
60  * \{ */
61 
62 
64 
65 using pcps_acquisition_fine_doppler_cc_sptr = gnss_shared_ptr<pcps_acquisition_fine_doppler_cc>;
66 
67 pcps_acquisition_fine_doppler_cc_sptr pcps_make_acquisition_fine_doppler_cc(const Acq_Conf& conf_);
68 
69 /*!
70  * \brief This class implements a Parallel Code Phase Search Acquisition.
71  *
72  */
73 class pcps_acquisition_fine_doppler_cc : public gr::block
74 {
75 public:
76  /*!
77  * \brief Default destructor.
78  */
80 
81  /*!
82  * \brief Set acquisition/tracking common Gnss_Synchro object pointer
83  * to exchange synchronization data between acquisition and tracking blocks.
84  * \param p_gnss_synchro Satellite information shared by the processing blocks.
85  */
86  inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro)
87  {
88  d_gnss_synchro = p_gnss_synchro;
89  }
90 
91  /*!
92  * \brief Returns the maximum peak of grid search.
93  */
94  inline unsigned int mag() const
95  {
96  return d_test_statistics;
97  }
98 
99  /*!
100  * \brief Initializes acquisition algorithm.
101  */
102  void init();
103 
104  /*!
105  * \brief Sets local code for PCPS acquisition algorithm.
106  * \param code - Pointer to the PRN code.
107  */
108  void set_local_code(std::complex<float>* code);
109 
110  /*!
111  * \brief Starts acquisition algorithm, turning from standby mode to
112  * active mode
113  * \param active - bool that activates/deactivates the block.
114  */
115  inline void set_active(bool active)
116  {
117  d_active = active;
118  }
119 
120  /*!
121  * \brief Set acquisition channel unique ID
122  * \param channel - receiver channel.
123  */
124  inline void set_channel(unsigned int channel)
125  {
126  d_channel = channel;
127  d_dump_channel = d_channel;
128  }
129 
130  /*!
131  * \brief Set channel fsm associated to this acquisition instance
132  */
133  inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm)
134  {
135  d_channel_fsm = std::move(channel_fsm);
136  }
137 
138  /*!
139  * \brief Set statistics threshold of PCPS algorithm.
140  * \param threshold - Threshold for signal detection (check \ref Navitec2012,
141  * Algorithm 1, for a definition of this threshold).
142  */
143  inline void set_threshold(float threshold)
144  {
145  d_threshold = threshold;
146  }
147 
148  /*!
149  * \brief Set maximum Doppler grid search
150  * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz].
151  */
152  inline void set_doppler_max(unsigned int doppler_max)
153  {
154  d_config_doppler_max = doppler_max;
155  }
156 
157  /*!
158  * \brief Set Doppler steps for the grid search
159  * \param doppler_step - Frequency bin of the search grid [Hz].
160  */
161  void set_doppler_step(unsigned int doppler_step);
162 
163  /*!
164  * \brief If set to 1, ensures that acquisition starts at the
165  * first available sample.
166  * \param state - int=1 forces start of acquisition
167  */
168  void set_state(int state);
169 
170  /*!
171  * \brief Obtains the next power of 2 greater or equal to the input parameter
172  * \param n - Integer value to obtain the next power of 2.
173  */
174  unsigned int nextPowerOf2(unsigned int n);
175 
176  void dump_results(int effective_fft_size);
177 
178  void forecast(int noutput_items, gr_vector_int& ninput_items_required);
179 
180  /*!
181  * \brief Parallel Code Phase Search Acquisition signal processing.
182  */
183  int general_work(int noutput_items, gr_vector_int& ninput_items,
184  gr_vector_const_void_star& input_items,
185  gr_vector_void_star& output_items);
186 
187 private:
188  friend pcps_acquisition_fine_doppler_cc_sptr pcps_make_acquisition_fine_doppler_cc(const Acq_Conf& conf_);
189  explicit pcps_acquisition_fine_doppler_cc(const Acq_Conf& conf_);
190 
191  int compute_and_accumulate_grid(gr_vector_const_void_star& input_items);
192  int estimate_Doppler();
193  float estimate_input_power(gr_vector_const_void_star& input_items);
194  float compute_CAF();
195  void reset_grid();
196  void update_carrier_wipeoff();
197  bool start();
198 
199  std::weak_ptr<ChannelFsm> d_channel_fsm;
200  std::unique_ptr<gnss_fft_complex_fwd> d_fft_if;
201  std::unique_ptr<gnss_fft_complex_rev> d_ifft;
202 
203  volk_gnsssdr::vector<volk_gnsssdr::vector<std::complex<float>>> d_grid_doppler_wipeoffs;
204  volk_gnsssdr::vector<volk_gnsssdr::vector<float>> d_grid_data;
205  volk_gnsssdr::vector<gr_complex> d_fft_codes;
206  volk_gnsssdr::vector<gr_complex> d_10_ms_buffer;
207  volk_gnsssdr::vector<float> d_magnitude;
208 
209  arma::fmat grid_;
210 
211  std::string d_satellite_str;
212  std::string d_dump_filename;
213 
214  Gnss_Synchro* d_gnss_synchro;
215 
216  Acq_Conf acq_parameters;
217 
218  int64_t d_fs_in;
219  int64_t d_dump_number;
220  uint64_t d_sample_counter;
221 
222  float d_threshold;
223  float d_test_statistics;
224 
225  int d_positive_acq;
226  int d_state;
227  int d_samples_per_ms;
228  int d_max_dwells;
229  int d_config_doppler_max;
230  int d_num_doppler_points;
231  int d_well_count;
232  int d_n_samples_in_buffer;
233  int d_fft_size;
234  int d_gnuradio_forecast_samples;
235  unsigned int d_doppler_step;
236  unsigned int d_channel;
237  unsigned int d_dump_channel;
238 
239  bool d_active;
240  bool d_dump;
241 };
242 
243 
244 /** \} */
245 /** \} */
246 #endif // GNSS_SDR_PCPS_ACQUISITION_FINE_DOPPLER_CC_H
This class implements a Parallel Code Phase Search Acquisition.
void set_channel(unsigned int channel)
Set acquisition channel unique ID.
Helper file for FFT interface.
void set_doppler_step(unsigned int doppler_step)
Set Doppler steps for the grid search.
void init()
Initializes acquisition algorithm.
int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
Parallel Code Phase Search Acquisition signal processing.
void set_local_code(std::complex< float > *code)
Sets local code for PCPS acquisition algorithm.
Class that contains all the configuration parameters for generic acquisition block based on the PCPS ...
Interface of the State Machine for channel.
This is the class that contains the information that is shared by the processing blocks.
Definition: gnss_synchro.h:38
void set_gnss_synchro(Gnss_Synchro *p_gnss_synchro)
Set acquisition/tracking common Gnss_Synchro object pointer to exchange synchronization data between ...
void set_threshold(float threshold)
Set statistics threshold of PCPS algorithm.
unsigned int mag() const
Returns the maximum peak of grid search.
unsigned int nextPowerOf2(unsigned int n)
Obtains the next power of 2 greater or equal to the input parameter.
void set_doppler_max(unsigned int doppler_max)
Set maximum Doppler grid search.
void set_active(bool active)
Starts acquisition algorithm, turning from standby mode to active mode.
~pcps_acquisition_fine_doppler_cc()=default
Default destructor.
void set_channel_fsm(std::weak_ptr< ChannelFsm > channel_fsm)
Set channel fsm associated to this acquisition instance.
void set_state(int state)
If set to 1, ensures that acquisition starts at the first available sample.
Interface of the Gnss_Synchro class.