GNSS-SDR  0.0.13
An Open Source GNSS Software Defined Receiver
pcps_assisted_acquisition_cc.h
Go to the documentation of this file.
1 /*!
2  * \file pcps_assisted_acquisition_cc.h
3  * \brief This class implements a Parallel Code Phase Search Acquisition with assistance and multi-dwells
4  *
5  * Acquisition strategy (Kay Borre book + CFAR threshold).
6  * <ol>
7  * <li> Compute the input signal power estimation
8  * <li> Doppler serial search loop
9  * <li> Perform the FFT-based circular convolution (parallel time search)
10  * <li> Record the maximum peak and the associated synchronization parameters
11  * <li> Compute the test statistics and compare to the threshold
12  * <li> Declare positive or negative acquisition using a message queue
13  * </ol>
14  *
15  * Kay Borre book: K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen,
16  * "A Software-Defined GPS and Galileo Receiver. A Single-Frequency
17  * Approach", Birkhauser, 2007. pp 81-84
18  *
19  * \authors <ul>
20  * <li> Javier Arribas, 2013. jarribas(at)cttc.es
21  * </ul>
22  *
23  * -----------------------------------------------------------------------------
24  *
25  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
26  *
27  * GNSS-SDR is a software defined Global Navigation
28  * Satellite Systems receiver
29  *
30  * This file is part of GNSS-SDR.
31  *
32  * SPDX-License-Identifier: GPL-3.0-or-later
33  *
34  * -----------------------------------------------------------------------------
35  */
36 
37 #ifndef GNSS_SDR_PCPS_ASSISTED_ACQUISITION_CC_H
38 #define GNSS_SDR_PCPS_ASSISTED_ACQUISITION_CC_H
39 
40 #include "channel_fsm.h"
41 #include "gnss_synchro.h"
42 #include <gnuradio/block.h>
43 #include <gnuradio/fft/fft.h>
44 #include <gnuradio/gr_complex.h>
45 #include <fstream>
46 #include <memory>
47 #include <string>
48 #include <utility>
49 #include <vector>
50 #if GNURADIO_USES_STD_POINTERS
51 #else
52 #include <boost/shared_ptr.hpp>
53 #endif
54 
56 
57 #if GNURADIO_USES_STD_POINTERS
58 using pcps_assisted_acquisition_cc_sptr = std::shared_ptr<pcps_assisted_acquisition_cc>;
59 #else
60 using pcps_assisted_acquisition_cc_sptr = boost::shared_ptr<pcps_assisted_acquisition_cc>;
61 #endif
62 
63 pcps_assisted_acquisition_cc_sptr pcps_make_assisted_acquisition_cc(
64  int32_t max_dwells,
65  uint32_t sampled_ms,
66  int32_t doppler_max,
67  int32_t doppler_min,
68  int64_t fs_in,
69  int32_t samples_per_ms,
70  bool dump, const std::string& dump_filename);
71 
72 /*!
73  * \brief This class implements a Parallel Code Phase Search Acquisition.
74  *
75  * Check \ref Navitec2012 "An Open Source Galileo E1 Software Receiver",
76  * Algorithm 1, for a pseudocode description of this implementation.
77  */
78 class pcps_assisted_acquisition_cc : public gr::block
79 {
80 public:
81  /*!
82  * \brief Default destructor.
83  */
85 
86  /*!
87  * \brief Set acquisition/tracking common Gnss_Synchro object pointer
88  * to exchange synchronization data between acquisition and tracking blocks.
89  * \param p_gnss_synchro Satellite information shared by the processing blocks.
90  */
91  inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro)
92  {
93  d_gnss_synchro = p_gnss_synchro;
94  }
95 
96  /*!
97  * \brief Returns the maximum peak of grid search.
98  */
99  inline uint32_t mag() const
100  {
101  return d_test_statistics;
102  }
103 
104  /*!
105  * \brief Initializes acquisition algorithm.
106  */
107  void init();
108 
109  /*!
110  * \brief Sets local code for PCPS acquisition algorithm.
111  * \param code - Pointer to the PRN code.
112  */
113  void set_local_code(std::complex<float>* code);
114 
115  /*!
116  * \brief Starts acquisition algorithm, turning from standby mode to
117  * active mode
118  * \param active - bool that activates/deactivates the block.
119  */
120  inline void set_active(bool active)
121  {
122  d_active = active;
123  }
124 
125  /*!
126  * \brief Set acquisition channel unique ID
127  * \param channel - receiver channel.
128  */
129  inline void set_channel(uint32_t channel)
130  {
131  d_channel = 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  inline void set_state(int32_t state)
153  {
154  d_state = state;
155  }
156 
157  /*!
158  * \brief Set maximum Doppler grid search
159  * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz].
160  */
161  inline void set_doppler_max(uint32_t doppler_max)
162  {
163  d_doppler_max = doppler_max;
164  }
165 
166  /*!
167  * \brief Set Doppler steps for the grid search
168  * \param doppler_step - Frequency bin of the search grid [Hz].
169  */
170  void set_doppler_step(uint32_t doppler_step);
171 
172  /*!
173  * \brief Parallel Code Phase Search Acquisition signal processing.
174  */
175  int general_work(int noutput_items, gr_vector_int& ninput_items,
176  gr_vector_const_void_star& input_items,
177  gr_vector_void_star& output_items);
178 
179  void forecast(int noutput_items, gr_vector_int& ninput_items_required);
180 
181 private:
182  friend pcps_assisted_acquisition_cc_sptr
183  pcps_make_assisted_acquisition_cc(int32_t max_dwells, uint32_t sampled_ms,
184  int32_t doppler_max, int32_t doppler_min, int64_t fs_in,
185  int32_t samples_per_ms, bool dump,
186  const std::string& dump_filename);
187 
188  pcps_assisted_acquisition_cc(int32_t max_dwells, uint32_t sampled_ms,
189  int32_t doppler_max, int32_t doppler_min, int64_t fs_in,
190  int32_t samples_per_ms, bool dump,
191  const std::string& dump_filename);
192 
193  void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift,
194  int32_t doppler_offset);
195 
196  int32_t compute_and_accumulate_grid(gr_vector_const_void_star& input_items);
197  float estimate_input_power(gr_vector_const_void_star& input_items);
198  float search_maximum();
199  void get_assistance();
200  void reset_grid();
201  void redefine_grid();
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  std::vector<std::vector<std::complex<float>>> d_grid_doppler_wipeoffs;
208  std::vector<std::vector<float>> d_grid_data;
209  std::vector<gr_complex> d_fft_codes;
210 
211  std::string d_satellite_str;
212  std::string d_dump_filename;
213 
214  std::ofstream d_dump_file;
215 
216  Gnss_Synchro* d_gnss_synchro;
217 
218  int64_t d_fs_in;
219  uint64_t d_sample_counter;
220 
221  float d_threshold;
222  float d_doppler_freq;
223  float d_input_power;
224  float d_test_statistics;
225  int32_t d_samples_per_ms;
226  int32_t d_max_dwells;
227  int32_t d_gnuradio_forecast_samples;
228  int32_t d_doppler_max;
229  int32_t d_doppler_min;
230  int32_t d_config_doppler_max;
231  int32_t d_config_doppler_min;
232  int32_t d_num_doppler_points;
233  int32_t d_doppler_step;
234  int32_t d_state;
235  int32_t d_well_count;
236  uint32_t d_doppler_resolution;
237  uint32_t d_channel;
238  uint32_t d_sampled_ms;
239  uint32_t d_fft_size;
240  uint32_t d_code_phase;
241 
242  bool d_active;
243  bool d_disable_assist;
244  bool d_dump;
245 };
246 
247 #endif // GNSS_SDR_PCPS_ASSISTED_ACQUISITION_CC_H
void set_doppler_max(uint32_t doppler_max)
Set maximum Doppler grid search.
void set_doppler_step(uint32_t doppler_step)
Set Doppler steps for the grid search.
void init()
Initializes acquisition algorithm.
void set_channel(uint32_t channel)
Set acquisition channel unique ID.
Interface of the State Machine for channel.
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.
This is the class that contains the information that is shared by the processing blocks.
Definition: gnss_synchro.h:33
~pcps_assisted_acquisition_cc()
Default destructor.
This class implements a Parallel Code Phase Search Acquisition.
void set_local_code(std::complex< float > *code)
Sets local code for PCPS acquisition algorithm.
void set_gnss_synchro(Gnss_Synchro *p_gnss_synchro)
Set acquisition/tracking common Gnss_Synchro object pointer to exchange synchronization data between ...
void set_channel_fsm(std::weak_ptr< ChannelFsm > channel_fsm)
Set channel fsm associated to this acquisition instance.
uint32_t mag() const
Returns the maximum peak of grid search.
void set_threshold(float threshold)
Set statistics threshold of PCPS algorithm.
void set_active(bool active)
Starts acquisition algorithm, turning from standby mode to active mode.
Interface of the Gnss_Synchro class.