GNSS-SDR  0.0.19
An Open Source GNSS Software Defined Receiver
pcps_quicksync_acquisition_cc.h
Go to the documentation of this file.
1 /*!
2  * \file pcps_quicksync_acquisition_cc.h
3  * \brief This class implements a Parallel Code Phase Search Acquisition with the
4  * QuickSync Algorithm
5  *
6  * Acquisition strategy (Kay Borre book CFAR + threshold).
7  * <ol>
8  * <li> Compute the input signal power estimation
9  * <li> Doppler serial search loop
10  * <li> Perform folding of the incoming signal and local generated code
11  * <li> Perform the FFT-based circular convolution (parallel time search)
12  * <li> Record the maximum peak and the associated synchronization parameters
13  * <li> Compute the test statistics and compare to the threshold
14  * <li> Declare positive or negative acquisition using a message port
15  * <li> Obtain the adequate acquisition parameters by correlating the incoming
16  * signal shifted by the possible folded delays
17  * </ol>
18  *
19  * Kay Borre book: K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen,
20  * "A Software-Defined GPS and Galileo Receiver. A Single-Frequency
21  * Approach", Birkha user, 2007. pp 81-84
22  *
23  * \date Jun2 2014
24  * \author Damian Miralles Sanchez, dmiralles2009@gmail.com
25  *
26  * -----------------------------------------------------------------------------
27  *
28  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
29  * This file is part of GNSS-SDR.
30  *
31  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
32  * SPDX-License-Identifier: GPL-3.0-or-later
33  *
34  * -----------------------------------------------------------------------------
35  */
36 
37 #ifndef GNSS_SDR_PCPS_QUICKSYNC_ACQUISITION_CC_H
38 #define GNSS_SDR_PCPS_QUICKSYNC_ACQUISITION_CC_H
39 
40 #include "channel_fsm.h"
41 #include "gnss_sdr_fft.h"
42 #include "gnss_synchro.h"
43 #include <gnuradio/block.h>
44 #include <gnuradio/gr_complex.h>
45 #include <algorithm>
46 #include <cassert>
47 #include <fstream>
48 #include <functional>
49 #include <memory> // for weak_ptr
50 #include <string>
51 #include <utility>
52 #include <vector>
53 
54 /** \addtogroup Acquisition
55  * \{ */
56 /** \addtogroup Acq_gnuradio_blocks
57  * \{ */
58 
59 
61 
62 using pcps_quicksync_acquisition_cc_sptr = gnss_shared_ptr<pcps_quicksync_acquisition_cc>;
63 
64 pcps_quicksync_acquisition_cc_sptr pcps_quicksync_make_acquisition_cc(
65  uint32_t folding_factor,
66  uint32_t sampled_ms,
67  uint32_t max_dwells,
68  uint32_t doppler_max,
69  int64_t fs_in,
70  int32_t samples_per_ms,
71  int32_t samples_per_code,
72  bool bit_transition_flag,
73  bool dump,
74  const std::string& dump_filename,
75  bool enable_monitor_output);
76 
77 /*!
78  * \brief This class implements a Parallel Code Phase Search Acquisition with
79  * the implementation of the Sparse QuickSync Algorithm.
80  *
81  * Check \ref Navitec2012 "Faster GPS via the Sparse Fourier Transform",
82  * for details of its implementation and functionality.
83  */
84 class pcps_quicksync_acquisition_cc : public gr::block
85 {
86 public:
87  /*!
88  * \brief Default destructor.
89  */
91 
92  /*!
93  * \brief Set acquisition/tracking common Gnss_Synchro object pointer
94  * to exchange synchronization data between acquisition and tracking blocks.
95  * \param p_gnss_synchro Satellite information shared by the processing blocks.
96  */
97  inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro)
98  {
99  d_gnss_synchro = p_gnss_synchro;
100  }
101 
102  /*!
103  * \brief Returns the maximum peak of grid search.
104  */
105  inline uint32_t mag() const
106  {
107  return d_mag;
108  }
109 
110  /*!
111  * \brief Initializes acquisition algorithm.
112  */
113  void init();
114 
115  /*!
116  * \brief Sets local code for PCPS acquisition algorithm.
117  * \param code - Pointer to the PRN code.
118  */
119  void set_local_code(std::complex<float>* code);
120 
121  /*!
122  * \brief Starts acquisition algorithm, turning from standby mode to
123  * active mode
124  * \param active - bool that activates/deactivates the block.
125  */
126  inline void set_active(bool active)
127  {
128  d_active = active;
129  }
130 
131  /*!
132  * \brief If set to 1, ensures that acquisition starts at the
133  * first available sample.
134  * \param state - int=1 forces start of acquisition
135  */
136  void set_state(int32_t state);
137 
138  /*!
139  * \brief Set acquisition channel unique ID
140  * \param channel - receiver channel.
141  */
142  inline void set_channel(uint32_t channel)
143  {
144  d_channel = channel;
145  }
146 
147  /*!
148  * \brief Set channel fsm associated to this acquisition instance
149  */
150  inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm)
151  {
152  d_channel_fsm = std::move(channel_fsm);
153  }
154 
155  /*!
156  * \brief Set statistics threshold of PCPS algorithm.
157  * \param threshold - Threshold for signal detection (check \ref Navitec2012,
158  * Algorithm 1, for a definition of this threshold).
159  */
160  inline void set_threshold(float threshold)
161  {
162  d_threshold = threshold;
163  }
164 
165  /*!
166  * \brief Set maximum Doppler grid search
167  * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz].
168  */
169  inline void set_doppler_max(uint32_t doppler_max)
170  {
171  d_doppler_max = doppler_max;
172  }
173 
174  /*!
175  * \brief Set Doppler steps for the grid search
176  * \param doppler_step - Frequency bin of the search grid [Hz].
177  */
178  inline void set_doppler_step(uint32_t doppler_step)
179  {
180  d_doppler_step = doppler_step;
181  }
182 
183  /*!
184  * \brief Parallel Code Phase Search Acquisition signal processing.
185  */
186  int general_work(int noutput_items, gr_vector_int& ninput_items,
187  gr_vector_const_void_star& input_items,
188  gr_vector_void_star& output_items);
189 
190 private:
191  friend pcps_quicksync_acquisition_cc_sptr
192  pcps_quicksync_make_acquisition_cc(uint32_t folding_factor,
193  uint32_t sampled_ms, uint32_t max_dwells,
194  uint32_t doppler_max, int64_t fs_in,
195  int32_t samples_per_ms, int32_t samples_per_code,
196  bool bit_transition_flag,
197  bool dump,
198  const std::string& dump_filename,
199  bool enable_monitor_output);
200 
201  pcps_quicksync_acquisition_cc(uint32_t folding_factor,
202  uint32_t sampled_ms, uint32_t max_dwells,
203  uint32_t doppler_max, int64_t fs_in,
204  int32_t samples_per_ms, int32_t samples_per_code,
205  bool bit_transition_flag,
206  bool dump,
207  const std::string& dump_filename,
208  bool enable_monitor_output);
209 
210  void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift,
211  int32_t doppler_offset);
212 
213  std::weak_ptr<ChannelFsm> d_channel_fsm;
214 
215  std::unique_ptr<gnss_fft_complex_fwd> d_fft_if;
216  std::unique_ptr<gnss_fft_complex_rev> d_ifft;
217 
218  std::vector<std::vector<gr_complex>> d_grid_doppler_wipeoffs;
219  std::vector<gr_complex> d_code;
220  std::vector<gr_complex> d_fft_codes;
221  std::vector<gr_complex> d_signal_folded;
222  std::vector<gr_complex> d_code_folded;
223  std::vector<float> d_magnitude;
224  std::vector<float> d_corr_output_f;
225  std::vector<float> d_magnitude_folded;
226  std::vector<uint32_t> d_possible_delay;
227 
228  std::string d_dump_filename;
229  std::string d_satellite_str;
230 
231  std::ofstream d_dump_file;
232 
233  Gnss_Synchro* d_gnss_synchro;
234 
235  int64_t d_fs_in;
236  uint64_t d_sample_counter;
237 
238  float d_noise_floor_power;
239  float d_threshold;
240  float d_doppler_freq;
241  float d_mag;
242  float d_input_power;
243  float d_test_statistics;
244  int32_t d_samples_per_ms;
245  int32_t d_samples_per_code;
246  int32_t d_state;
247  uint32_t d_channel;
248  uint32_t d_folding_factor; // also referred in the paper as 'p'
249  uint32_t d_doppler_resolution;
250  uint32_t d_doppler_max;
251  uint32_t d_doppler_step;
252  uint32_t d_sampled_ms;
253  uint32_t d_max_dwells;
254  uint32_t d_well_count;
255  uint32_t d_fft_size;
256  uint32_t d_num_doppler_bins;
257  uint32_t d_code_phase;
258 
259  bool d_bit_transition_flag;
260  bool d_active;
261  bool d_dump;
262  bool d_enable_monitor_output;
263 };
264 
265 
266 /** \} */
267 /** \} */
268 #endif // GNSS_SDR_PCPS_QUICKSYNC_ACQUISITION_CC_H
Helper file for FFT interface.
void set_channel_fsm(std::weak_ptr< ChannelFsm > channel_fsm)
Set channel fsm associated to this acquisition instance.
void set_channel(uint32_t channel)
Set acquisition channel unique ID.
void set_local_code(std::complex< float > *code)
Sets local code for PCPS acquisition algorithm.
uint32_t mag() const
Returns the maximum peak of grid search.
void set_state(int32_t state)
If set to 1, ensures that acquisition starts at the first available sample.
void init()
Initializes acquisition algorithm.
void set_doppler_step(uint32_t doppler_step)
Set Doppler steps for the grid search.
This class implements a Parallel Code Phase Search Acquisition with the implementation of the Sparse ...
Interface of the State Machine for channel.
void set_threshold(float threshold)
Set statistics threshold of PCPS algorithm.
This is the class that contains the information that is shared by the processing blocks.
Definition: gnss_synchro.h:38
void set_doppler_max(uint32_t doppler_max)
Set maximum Doppler grid search.
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_gnss_synchro(Gnss_Synchro *p_gnss_synchro)
Set acquisition/tracking common Gnss_Synchro object pointer to exchange synchronization data between ...
void set_active(bool active)
Starts acquisition algorithm, turning from standby mode to active mode.
~pcps_quicksync_acquisition_cc()
Default destructor.
Interface of the Gnss_Synchro class.