GNSS-SDR  0.0.21
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  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
27  * This file is part of GNSS-SDR.
28  *
29  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
30  * SPDX-License-Identifier: GPL-3.0-or-later
31  *
32  * -----------------------------------------------------------------------------
33  */
34 
35 #ifndef GNSS_SDR_PCPS_ACQUISITION_FINE_DOPPLER_CC_H
36 #define GNSS_SDR_PCPS_ACQUISITION_FINE_DOPPLER_CC_H
37 
39 #if ARMA_NO_BOUND_CHECKING
40 #define ARMA_NO_DEBUG 1
41 #endif
42 
43 #include "acq_conf.h"
44 #include "channel_fsm.h"
45 #include "gnss_sdr_fft.h"
46 #include "gnss_synchro.h"
47 #include <armadillo>
48 #include <gnuradio/block.h>
49 #include <gnuradio/gr_complex.h>
50 #include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
51 #include <cstdint>
52 #include <fstream>
53 #include <memory>
54 #include <string>
55 #include <utility>
56 
57 
58 /** \addtogroup Acquisition
59  * \{ */
60 /** \addtogroup Acq_gnuradio_blocks
61  * \{ */
62 
63 
65 
66 using pcps_acquisition_fine_doppler_cc_sptr = gnss_shared_ptr<pcps_acquisition_fine_doppler_cc>;
67 
68 pcps_acquisition_fine_doppler_cc_sptr pcps_make_acquisition_fine_doppler_cc(const Acq_Conf& conf_);
69 
70 /*!
71  * \brief This class implements a Parallel Code Phase Search Acquisition.
72  *
73  */
75 {
76 public:
77  /*!
78  * \brief Default destructor.
79  */
81 
82  /*!
83  * \brief Set acquisition/tracking common Gnss_Synchro object pointer
84  * to exchange synchronization data between acquisition and tracking blocks.
85  * \param p_gnss_synchro Satellite information shared by the processing blocks.
86  */
87  inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override
88  {
89  d_gnss_synchro = p_gnss_synchro;
90  }
91 
92  /*!
93  * \brief Returns the maximum peak of grid search.
94  */
95  inline unsigned int mag() const override
96  {
97  return d_test_statistics;
98  }
99 
100  /*!
101  * \brief Sets local code for PCPS acquisition algorithm.
102  * \param code - Pointer to the PRN code.
103  */
104  void set_local_code(std::complex<float>* code) override;
105 
106  /*!
107  * \brief Starts acquisition algorithm, turning from standby mode to
108  * active mode
109  * \param active - bool that activates/deactivates the block.
110  */
111  inline void set_active(bool active) override
112  {
113  if (!active)
114  {
115  d_state = 0;
116  }
117 
118  d_active = active;
119  }
120 
121  /*!
122  * \brief Set acquisition channel unique ID
123  * \param channel - receiver channel.
124  */
125  inline void set_channel(unsigned int channel) override
126  {
127  d_channel = channel;
128  d_dump_channel = d_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) override
135  {
136  d_channel_fsm = std::move(channel_fsm);
137  }
138 
139  /*!
140  * \brief Parallel Code Phase Search Acquisition signal processing.
141  */
142  int general_work(int noutput_items, gr_vector_int& ninput_items,
143  gr_vector_const_void_star& input_items,
144  gr_vector_void_star& output_items) override;
145 
146 private:
147  /*!
148  * \brief Obtains the next power of 2 greater or equal to the input parameter
149  * \param n - Integer value to obtain the next power of 2.
150  */
151  unsigned int nextPowerOf2(unsigned int n);
152 
153  void dump_results(int effective_fft_size);
154 
155  void forecast(int noutput_items, gr_vector_int& ninput_items_required) override;
156 
157  friend pcps_acquisition_fine_doppler_cc_sptr pcps_make_acquisition_fine_doppler_cc(const Acq_Conf& conf_);
158  explicit pcps_acquisition_fine_doppler_cc(const Acq_Conf& conf_);
159 
160  int compute_and_accumulate_grid(gr_vector_const_void_star& input_items);
161  int estimate_Doppler();
162  float estimate_input_power(gr_vector_const_void_star& input_items);
163  float compute_CAF();
164  void reset_grid();
165  void update_carrier_wipeoff();
166  bool start() override;
167 
168  arma::fmat grid_;
169 
170  std::string d_satellite_str;
171 
172  const Acq_Conf d_acq_params;
173  std::string d_dump_filename;
174 
175  Gnss_Synchro* d_gnss_synchro;
176 
177  int64_t d_dump_number;
178  uint64_t d_sample_counter;
179 
180  float d_test_statistics;
181 
182  int d_positive_acq;
183  int d_state;
184  const int d_num_doppler_points;
185  int d_well_count;
186  int d_n_samples_in_buffer;
187  const int d_fft_size;
188  int d_gnuradio_forecast_samples;
189  unsigned int d_channel;
190  unsigned int d_dump_channel;
191 
192  bool d_active;
193  bool d_dump;
194 
195  std::weak_ptr<ChannelFsm> d_channel_fsm;
196  std::unique_ptr<gnss_fft_complex_fwd> d_fft_if;
197  std::unique_ptr<gnss_fft_complex_rev> d_ifft;
198 
199  volk_gnsssdr::vector<volk_gnsssdr::vector<std::complex<float>>> d_grid_doppler_wipeoffs;
200  volk_gnsssdr::vector<volk_gnsssdr::vector<float>> d_grid_data;
201  volk_gnsssdr::vector<gr_complex> d_fft_codes;
202  volk_gnsssdr::vector<gr_complex> d_10_ms_buffer;
203  volk_gnsssdr::vector<float> d_magnitude;
204 };
205 
206 
207 /** \} */
208 /** \} */
209 #endif // GNSS_SDR_PCPS_ACQUISITION_FINE_DOPPLER_CC_H
void set_active(bool active) override
Starts acquisition algorithm, turning from standby mode to active mode.
This class implements a Parallel Code Phase Search Acquisition.
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.
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 ...
Interface of the State Machine for channel.
void set_local_code(std::complex< float > *code) override
Sets local code for PCPS acquisition algorithm.
unsigned int mag() const override
Returns the maximum peak of grid search.
This is the class that contains the information that is shared by the processing blocks.
Definition: gnss_synchro.h:38
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 ...
void set_channel(unsigned int channel) override
Set acquisition channel unique ID.
~pcps_acquisition_fine_doppler_cc()=default
Default destructor.
This abstract class represents an interface to an acquisition GNSS block.
Interface of the Gnss_Synchro class.