GNSS-SDR  0.0.21
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 "acq_conf.h"
42 #include "channel_fsm.h"
43 #include "gnss_sdr_fft.h"
44 #include "gnss_synchro.h"
45 #include <gnuradio/block.h>
46 #include <gnuradio/gr_complex.h>
47 #include <cassert>
48 #include <fstream>
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(const Acq_Conf& conf, uint32_t folding_factor, uint32_t max_dwells);
65 
66 /*!
67  * \brief This class implements a Parallel Code Phase Search Acquisition with
68  * the implementation of the Sparse QuickSync Algorithm.
69  *
70  * Check \ref Navitec2012 "Faster GPS via the Sparse Fourier Transform",
71  * for details of its implementation and functionality.
72  */
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) override
87  {
88  d_gnss_synchro = p_gnss_synchro;
89  }
90 
91  /*!
92  * \brief Returns the maximum peak of grid search.
93  */
94  inline uint32_t mag() const override
95  {
96  return d_mag;
97  }
98 
99  /*!
100  * \brief Sets local code for PCPS acquisition algorithm.
101  * \param code - Pointer to the PRN code.
102  */
103  void set_local_code(std::complex<float>* code) override;
104 
105  /*!
106  * \brief Starts acquisition algorithm, turning from standby mode to
107  * active mode
108  * \param active - bool that activates/deactivates the block.
109  */
110  inline void set_active(bool active) override
111  {
112  if (!active)
113  {
114  d_state = 0;
115  }
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(uint32_t channel) override
125  {
126  d_channel = channel;
127  }
128 
129  /*!
130  * \brief Set channel fsm associated to this acquisition instance
131  */
132  inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override
133  {
134  d_channel_fsm = std::move(channel_fsm);
135  }
136 
137  /*!
138  * \brief Parallel Code Phase Search Acquisition signal processing.
139  */
140  int general_work(int noutput_items, gr_vector_int& ninput_items,
141  gr_vector_const_void_star& input_items,
142  gr_vector_void_star& output_items) override;
143 
144 private:
145  friend pcps_quicksync_acquisition_cc_sptr
146  pcps_quicksync_make_acquisition_cc(const Acq_Conf& conf, uint32_t folding_factor, uint32_t max_dwells);
147 
148  explicit pcps_quicksync_acquisition_cc(const Acq_Conf& conf, uint32_t folding_factor, uint32_t max_dwells);
149 
150  void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift, int32_t doppler_offset);
151 
152  std::string d_satellite_str;
153  const Acq_Conf d_acq_params;
154 
155  std::ofstream d_dump_file;
156 
157  Gnss_Synchro* d_gnss_synchro;
158 
159  uint64_t d_sample_counter;
160 
161  float d_noise_floor_power;
162  float d_mag;
163  float d_input_power;
164  float d_test_statistics;
165  const int32_t d_vector_length;
166  const int32_t d_samples_per_code;
167  int32_t d_state;
168  uint32_t d_channel;
169  const uint32_t d_folding_factor; // also referred in the paper as 'p'
170  const uint32_t d_max_dwells;
171  uint32_t d_well_count;
172  const uint32_t d_fft_size;
173  uint32_t d_num_doppler_bins;
174  uint32_t d_code_phase;
175 
176  bool d_active;
177 
178  std::weak_ptr<ChannelFsm> d_channel_fsm;
179 
180  std::unique_ptr<gnss_fft_complex_fwd> d_fft_if;
181  std::unique_ptr<gnss_fft_complex_rev> d_ifft;
182 
183  std::vector<std::vector<gr_complex>> d_grid_doppler_wipeoffs;
184  std::vector<gr_complex> d_code;
185  std::vector<gr_complex> d_fft_codes;
186  std::vector<gr_complex> d_signal_folded;
187  std::vector<gr_complex> d_code_folded;
188  std::vector<float> d_magnitude;
189  std::vector<float> d_corr_output_f;
190  std::vector<float> d_magnitude_folded;
191  std::vector<uint32_t> d_possible_delay;
192 };
193 
194 
195 /** \} */
196 /** \} */
197 #endif // GNSS_SDR_PCPS_QUICKSYNC_ACQUISITION_CC_H
void set_active(bool active) override
Starts acquisition algorithm, turning from standby mode to active mode.
Helper file for FFT interface.
Header file of the interface to an acquisition implementation GNSS block.
Class that contains all the configuration parameters for generic acquisition block based on the PCPS ...
This class implements a Parallel Code Phase Search Acquisition with the implementation of the Sparse ...
Interface of the State Machine for channel.
void set_channel_fsm(std::weak_ptr< ChannelFsm > channel_fsm) override
Set channel fsm associated to this acquisition instance.
void set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) override
Set acquisition/tracking common Gnss_Synchro object pointer to exchange synchronization data between ...
int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) override
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
uint32_t mag() const override
Returns the maximum peak of grid search.
void set_channel(uint32_t channel) override
Set acquisition channel unique ID.
void set_local_code(std::complex< float > *code) override
Sets local code for PCPS acquisition algorithm.
~pcps_quicksync_acquisition_cc()
Default destructor.
This abstract class represents an interface to an acquisition GNSS block.
Interface of the Gnss_Synchro class.