GNSS-SDR  0.0.19
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  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
26  * This file is part of GNSS-SDR.
27  *
28  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
29  * SPDX-License-Identifier: GPL-3.0-or-later
30  *
31  * -----------------------------------------------------------------------------
32  */
33 
34 #ifndef GNSS_SDR_PCPS_ASSISTED_ACQUISITION_CC_H
35 #define GNSS_SDR_PCPS_ASSISTED_ACQUISITION_CC_H
36 
37 #include "channel_fsm.h"
38 #include "gnss_sdr_fft.h"
39 #include "gnss_synchro.h"
40 #include <gnuradio/block.h>
41 #include <gnuradio/gr_complex.h>
42 #include <fstream>
43 #include <memory>
44 #include <string>
45 #include <utility>
46 #include <vector>
47 
48 /** \addtogroup Acquisition
49  * \{ */
50 /** \addtogroup Acq_gnuradio_blocks
51  * \{ */
52 
53 
55 
56 using pcps_assisted_acquisition_cc_sptr = gnss_shared_ptr<pcps_assisted_acquisition_cc>;
57 
58 pcps_assisted_acquisition_cc_sptr pcps_make_assisted_acquisition_cc(
59  int32_t max_dwells,
60  uint32_t sampled_ms,
61  int32_t doppler_max,
62  int32_t doppler_min,
63  int64_t fs_in,
64  int32_t samples_per_ms,
65  bool dump,
66  const std::string& dump_filename,
67  bool enable_monitor_output);
68 
69 /*!
70  * \brief This class implements a Parallel Code Phase Search Acquisition.
71  *
72  * Check \ref Navitec2012 "An Open Source Galileo E1 Software Receiver",
73  * Algorithm 1, for a pseudocode description of this implementation.
74  */
75 class pcps_assisted_acquisition_cc : public gr::block
76 {
77 public:
78  /*!
79  * \brief Default destructor.
80  */
82 
83  /*!
84  * \brief Set acquisition/tracking common Gnss_Synchro object pointer
85  * to exchange synchronization data between acquisition and tracking blocks.
86  * \param p_gnss_synchro Satellite information shared by the processing blocks.
87  */
88  inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro)
89  {
90  d_gnss_synchro = p_gnss_synchro;
91  }
92 
93  /*!
94  * \brief Returns the maximum peak of grid search.
95  */
96  inline uint32_t mag() const
97  {
98  return d_test_statistics;
99  }
100 
101  /*!
102  * \brief Initializes acquisition algorithm.
103  */
104  void init();
105 
106  /*!
107  * \brief Sets local code for PCPS acquisition algorithm.
108  * \param code - Pointer to the PRN code.
109  */
110  void set_local_code(std::complex<float>* code);
111 
112  /*!
113  * \brief Starts acquisition algorithm, turning from standby mode to
114  * active mode
115  * \param active - bool that activates/deactivates the block.
116  */
117  inline void set_active(bool active)
118  {
119  d_active = active;
120  }
121 
122  /*!
123  * \brief Set acquisition channel unique ID
124  * \param channel - receiver channel.
125  */
126  inline void set_channel(uint32_t channel)
127  {
128  d_channel = channel;
129  }
130 
131  /*!
132  * \brief Set channel fsm associated to this acquisition instance
133  */
134  inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm)
135  {
136  d_channel_fsm = std::move(channel_fsm);
137  }
138 
139  /*!
140  * \brief Set statistics threshold of PCPS algorithm.
141  * \param threshold - Threshold for signal detection (check \ref Navitec2012,
142  * Algorithm 1, for a definition of this threshold).
143  */
144  inline void set_threshold(float threshold)
145  {
146  d_threshold = threshold;
147  }
148 
149  inline void set_state(int32_t state)
150  {
151  d_state = state;
152  }
153 
154  /*!
155  * \brief Set maximum Doppler grid search
156  * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz].
157  */
158  inline void set_doppler_max(uint32_t doppler_max)
159  {
160  d_doppler_max = doppler_max;
161  }
162 
163  /*!
164  * \brief Set Doppler steps for the grid search
165  * \param doppler_step - Frequency bin of the search grid [Hz].
166  */
167  void set_doppler_step(uint32_t doppler_step);
168 
169  /*!
170  * \brief Parallel Code Phase Search Acquisition signal processing.
171  */
172  int general_work(int noutput_items, gr_vector_int& ninput_items,
173  gr_vector_const_void_star& input_items,
174  gr_vector_void_star& output_items);
175 
176  void forecast(int noutput_items, gr_vector_int& ninput_items_required);
177 
178 private:
179  friend pcps_assisted_acquisition_cc_sptr
180  pcps_make_assisted_acquisition_cc(int32_t max_dwells, uint32_t sampled_ms,
181  int32_t doppler_max, int32_t doppler_min, int64_t fs_in,
182  int32_t samples_per_ms, bool dump,
183  const std::string& dump_filename, bool enable_monitor_output);
184 
185  pcps_assisted_acquisition_cc(int32_t max_dwells, uint32_t sampled_ms,
186  int32_t doppler_max, int32_t doppler_min, int64_t fs_in,
187  int32_t samples_per_ms, bool dump,
188  const std::string& dump_filename, bool enable_monitor_output);
189 
190  void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift,
191  int32_t doppler_offset);
192 
193  int32_t compute_and_accumulate_grid(gr_vector_const_void_star& input_items);
194  float estimate_input_power(gr_vector_const_void_star& input_items) const;
195  float search_maximum();
196  void get_assistance();
197  void reset_grid();
198  void redefine_grid();
199 
200  std::weak_ptr<ChannelFsm> d_channel_fsm;
201  std::unique_ptr<gnss_fft_complex_fwd> d_fft_if;
202  std::unique_ptr<gnss_fft_complex_rev> d_ifft;
203 
204  std::vector<std::vector<std::complex<float>>> d_grid_doppler_wipeoffs;
205  std::vector<std::vector<float>> d_grid_data;
206  std::vector<gr_complex> d_fft_codes;
207 
208  std::string d_satellite_str;
209  std::string d_dump_filename;
210 
211  std::ofstream d_dump_file;
212 
213  Gnss_Synchro* d_gnss_synchro;
214 
215  int64_t d_fs_in;
216  uint64_t d_sample_counter;
217 
218  float d_threshold;
219  float d_doppler_freq;
220  float d_input_power;
221  float d_test_statistics;
222 
223  uint32_t d_doppler_resolution;
224  uint32_t d_channel;
225  uint32_t d_sampled_ms;
226  uint32_t d_code_phase;
227 
228  int32_t d_samples_per_ms;
229 
230  uint32_t d_fft_size;
231 
232  int32_t d_max_dwells;
233  int32_t d_gnuradio_forecast_samples;
234  int32_t d_doppler_max;
235  int32_t d_doppler_min;
236  int32_t d_config_doppler_max;
237  int32_t d_config_doppler_min;
238  int32_t d_num_doppler_points;
239  int32_t d_doppler_step;
240  int32_t d_state;
241  int32_t d_well_count;
242 
243  bool d_active;
244  bool d_disable_assist;
245  bool d_dump;
246  bool d_enable_monitor_output;
247 };
248 
249 
250 /** \} */
251 /** \} */
252 #endif // GNSS_SDR_PCPS_ASSISTED_ACQUISITION_CC_H
void set_doppler_max(uint32_t doppler_max)
Set maximum Doppler grid search.
Helper file for FFT interface.
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:38
~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.