GNSS-SDR  0.0.13
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  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
27  *
28  * GNSS-SDR is a software defined Global Navigation
29  * Satellite Systems receiver
30  *
31  * This file is part of GNSS-SDR.
32  *
33  * SPDX-License-Identifier: GPL-3.0-or-later
34  *
35  * -----------------------------------------------------------------------------
36  */
37 
38 #ifndef GNSS_SDR_PCPS_ACQUISITION_FINE_DOPPLER_CC_H
39 #define GNSS_SDR_PCPS_ACQUISITION_FINE_DOPPLER_CC_H
40 
41 #if ARMA_NO_BOUND_CHECKING
42 #define ARMA_NO_DEBUG 1
43 #endif
44 
45 #include "acq_conf.h"
46 #include "channel_fsm.h"
47 #include "gnss_synchro.h"
48 #include <armadillo>
49 #include <gnuradio/block.h>
50 #include <gnuradio/fft/fft.h>
51 #include <gnuradio/gr_complex.h>
52 #include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
53 #include <cstdint>
54 #include <fstream>
55 #include <memory>
56 #include <string>
57 #include <utility>
58 #if GNURADIO_USES_STD_POINTERS
59 #else
60 #include <boost/shared_ptr.hpp>
61 #endif
62 
64 
65 #if GNURADIO_USES_STD_POINTERS
66 using pcps_acquisition_fine_doppler_cc_sptr = std::shared_ptr<pcps_acquisition_fine_doppler_cc>;
67 #else
68 using pcps_acquisition_fine_doppler_cc_sptr = boost::shared_ptr<pcps_acquisition_fine_doppler_cc>;
69 #endif
70 
71 pcps_acquisition_fine_doppler_cc_sptr pcps_make_acquisition_fine_doppler_cc(const Acq_Conf& conf_);
72 
73 /*!
74  * \brief This class implements a Parallel Code Phase Search Acquisition.
75  *
76  */
77 class pcps_acquisition_fine_doppler_cc : public gr::block
78 {
79 public:
80  /*!
81  * \brief Default destructor.
82  */
84 
85  /*!
86  * \brief Set acquisition/tracking common Gnss_Synchro object pointer
87  * to exchange synchronization data between acquisition and tracking blocks.
88  * \param p_gnss_synchro Satellite information shared by the processing blocks.
89  */
90  inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro)
91  {
92  d_gnss_synchro = p_gnss_synchro;
93  }
94 
95  /*!
96  * \brief Returns the maximum peak of grid search.
97  */
98  inline unsigned int mag() const
99  {
100  return d_test_statistics;
101  }
102 
103  /*!
104  * \brief Initializes acquisition algorithm.
105  */
106  void init();
107 
108  /*!
109  * \brief Sets local code for PCPS acquisition algorithm.
110  * \param code - Pointer to the PRN code.
111  */
112  void set_local_code(std::complex<float>* code);
113 
114  /*!
115  * \brief Starts acquisition algorithm, turning from standby mode to
116  * active mode
117  * \param active - bool that activates/deactivates the block.
118  */
119  inline void set_active(bool active)
120  {
121  d_active = active;
122  }
123 
124  /*!
125  * \brief Set acquisition channel unique ID
126  * \param channel - receiver channel.
127  */
128  inline void set_channel(unsigned int channel)
129  {
130  d_channel = channel;
131  d_dump_channel = d_channel;
132  }
133 
134  /*!
135  * \brief Set channel fsm associated to this acquisition instance
136  */
137  inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm)
138  {
139  d_channel_fsm = std::move(channel_fsm);
140  }
141 
142  /*!
143  * \brief Set statistics threshold of PCPS algorithm.
144  * \param threshold - Threshold for signal detection (check \ref Navitec2012,
145  * Algorithm 1, for a definition of this threshold).
146  */
147  inline void set_threshold(float threshold)
148  {
149  d_threshold = threshold;
150  }
151 
152  /*!
153  * \brief Set maximum Doppler grid search
154  * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz].
155  */
156  inline void set_doppler_max(unsigned int doppler_max)
157  {
158  d_config_doppler_max = doppler_max;
159  }
160 
161  /*!
162  * \brief Set Doppler steps for the grid search
163  * \param doppler_step - Frequency bin of the search grid [Hz].
164  */
165  void set_doppler_step(unsigned int doppler_step);
166 
167  /*!
168  * \brief If set to 1, ensures that acquisition starts at the
169  * first available sample.
170  * \param state - int=1 forces start of acquisition
171  */
172  void set_state(int state);
173 
174  /*!
175  * \brief Obtains the next power of 2 greater or equal to the input parameter
176  * \param n - Integer value to obtain the next power of 2.
177  */
178  unsigned int nextPowerOf2(unsigned int n);
179 
180  void dump_results(int effective_fft_size);
181 
182  void forecast(int noutput_items, gr_vector_int& ninput_items_required);
183 
184  /*!
185  * \brief Parallel Code Phase Search Acquisition signal processing.
186  */
187  int general_work(int noutput_items, gr_vector_int& ninput_items,
188  gr_vector_const_void_star& input_items,
189  gr_vector_void_star& output_items);
190 
191 private:
192  friend pcps_acquisition_fine_doppler_cc_sptr pcps_make_acquisition_fine_doppler_cc(const Acq_Conf& conf_);
193  explicit pcps_acquisition_fine_doppler_cc(const Acq_Conf& conf_);
194 
195  int compute_and_accumulate_grid(gr_vector_const_void_star& input_items);
196  int estimate_Doppler();
197  float estimate_input_power(gr_vector_const_void_star& input_items);
198  float compute_CAF();
199  void reset_grid();
200  void update_carrier_wipeoff();
201  bool start();
202 
203  std::weak_ptr<ChannelFsm> d_channel_fsm;
204  std::unique_ptr<gr::fft::fft_complex> d_fft_if;
205  std::unique_ptr<gr::fft::fft_complex> d_ifft;
206 
207  volk_gnsssdr::vector<volk_gnsssdr::vector<std::complex<float>>> d_grid_doppler_wipeoffs;
208  volk_gnsssdr::vector<volk_gnsssdr::vector<float>> d_grid_data;
209  volk_gnsssdr::vector<gr_complex> d_fft_codes;
210  volk_gnsssdr::vector<gr_complex> d_10_ms_buffer;
211  volk_gnsssdr::vector<float> d_magnitude;
212 
213  arma::fmat grid_;
214 
215  std::string d_satellite_str;
216  std::string d_dump_filename;
217 
218  Gnss_Synchro* d_gnss_synchro;
219 
220  Acq_Conf acq_parameters;
221 
222  int64_t d_fs_in;
223  int64_t d_dump_number;
224  uint64_t d_sample_counter;
225 
226  float d_doppler_freq;
227  float d_threshold;
228  float d_test_statistics;
229 
230  int d_positive_acq;
231  int d_state;
232  int d_samples_per_ms;
233  int d_max_dwells;
234  int d_gnuradio_forecast_samples;
235  int d_config_doppler_max;
236  int d_num_doppler_points;
237  int d_well_count;
238  int d_n_samples_in_buffer;
239  int d_fft_size;
240  unsigned int d_doppler_step;
241  unsigned int d_channel;
242  unsigned int d_code_phase;
243  unsigned int d_dump_channel;
244 
245  bool d_active;
246  bool d_dump;
247 };
248 
249 #endif /* pcps_acquisition_fine_doppler_cc*/
This class implements a Parallel Code Phase Search Acquisition.
void set_channel(unsigned int channel)
Set acquisition channel unique ID.
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:33
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.