GNSS-SDR  0.0.13
An Open Source GNSS Software Defined Receiver
pcps_cccwsr_acquisition_cc.h
Go to the documentation of this file.
1 /*!
2  * \file pcps_cccwsr_acquisition_cc.h
3  * \brief This class implements a Parallel Code Phase Search acquisition
4  * with Coherent Channel Combining With Sign Recovery scheme.
5  * \author Marc Molina, 2013. marc.molina.pena(at)gmail.com
6  *
7  * D.Borio, C.O'Driscoll, G.Lachapelle, "Coherent, Noncoherent and
8  * Differentially Coherent Combining Techniques for Acquisition of
9  * New Composite GNSS Signals", IEEE Transactions On Aerospace and
10  * Electronic Systems vol. 45 no. 3, July 2009, section IV
11  *
12  * -----------------------------------------------------------------------------
13  *
14  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
15  *
16  * GNSS-SDR is a software defined Global Navigation
17  * Satellite Systems receiver
18  *
19  * This file is part of GNSS-SDR.
20  *
21  * SPDX-License-Identifier: GPL-3.0-or-later
22  *
23  * -----------------------------------------------------------------------------
24  */
25 
26 #ifndef GNSS_SDR_PCPS_CCCWSR_ACQUISITION_CC_H
27 #define GNSS_SDR_PCPS_CCCWSR_ACQUISITION_CC_H
28 
29 #include "channel_fsm.h"
30 #include "gnss_synchro.h"
31 #include <gnuradio/block.h>
32 #include <gnuradio/fft/fft.h>
33 #include <gnuradio/gr_complex.h>
34 #include <fstream>
35 #include <memory>
36 #include <string>
37 #include <utility>
38 #include <vector>
39 #if GNURADIO_USES_STD_POINTERS
40 #else
41 #include <boost/shared_ptr.hpp>
42 #endif
43 
44 
46 
47 #if GNURADIO_USES_STD_POINTERS
48 using pcps_cccwsr_acquisition_cc_sptr = std::shared_ptr<pcps_cccwsr_acquisition_cc>;
49 #else
50 using pcps_cccwsr_acquisition_cc_sptr = boost::shared_ptr<pcps_cccwsr_acquisition_cc>;
51 #endif
52 
53 pcps_cccwsr_acquisition_cc_sptr pcps_cccwsr_make_acquisition_cc(
54  uint32_t sampled_ms,
55  uint32_t max_dwells,
56  uint32_t doppler_max,
57  int64_t fs_in,
58  int32_t samples_per_ms,
59  int32_t samples_per_code,
60  bool dump,
61  const std::string& dump_filename);
62 
63 /*!
64  * \brief This class implements a Parallel Code Phase Search Acquisition with
65  * Coherent Channel Combining With Sign Recovery scheme.
66  */
67 class pcps_cccwsr_acquisition_cc : public gr::block
68 {
69 public:
70  /*!
71  * \brief Default destructor.
72  */
74 
75  /*!
76  * \brief Set acquisition/tracking common Gnss_Synchro object pointer
77  * to exchange synchronization data between acquisition and tracking blocks.
78  * \param p_gnss_synchro Satellite information shared by the processing blocks.
79  */
80  inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro)
81  {
82  d_gnss_synchro = p_gnss_synchro;
83  }
84 
85  /*!
86  * \brief Returns the maximum peak of grid search.
87  */
88  inline uint32_t mag() const
89  {
90  return d_mag;
91  }
92 
93  /*!
94  * \brief Initializes acquisition algorithm.
95  */
96  void init();
97 
98  /*!
99  * \brief Sets local code for CCCWSR acquisition algorithm.
100  * \param data_code - Pointer to the data PRN code.
101  * \param pilot_code - Pointer to the pilot PRN code.
102  */
103  void set_local_code(std::complex<float>* code_data, std::complex<float>* code_pilot);
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)
111  {
112  d_active = active;
113  }
114 
115  /*!
116  * \brief If set to 1, ensures that acquisition starts at the
117  * first available sample.
118  * \param state - int=1 forces start of acquisition
119  */
120  void set_state(int32_t state);
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 CCCWSR 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  /*!
150  * \brief Set maximum Doppler grid search
151  * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz].
152  */
153  inline void set_doppler_max(uint32_t doppler_max)
154  {
155  d_doppler_max = doppler_max;
156  }
157 
158  /*!
159  * \brief Set Doppler steps for the grid search
160  * \param doppler_step - Frequency bin of the search grid [Hz].
161  */
162  inline void set_doppler_step(uint32_t doppler_step)
163  {
164  d_doppler_step = doppler_step;
165  }
166 
167  /*!
168  * \brief Coherent Channel Combining With Sign Recovery Acquisition signal processing.
169  */
170  int general_work(int noutput_items, gr_vector_int& ninput_items,
171  gr_vector_const_void_star& input_items,
172  gr_vector_void_star& output_items);
173 
174 private:
175  friend pcps_cccwsr_acquisition_cc_sptr
176  pcps_cccwsr_make_acquisition_cc(uint32_t sampled_ms, uint32_t max_dwells,
177  uint32_t doppler_max, int64_t fs_in,
178  int32_t samples_per_ms, int32_t samples_per_code,
179  bool dump, const std::string& dump_filename);
180 
181  pcps_cccwsr_acquisition_cc(uint32_t sampled_ms, uint32_t max_dwells,
182  uint32_t doppler_max, int64_t fs_in,
183  int32_t samples_per_ms, int32_t samples_per_code,
184  bool dump, const std::string& dump_filename);
185 
186  void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift,
187  int32_t doppler_offset);
188 
189  std::weak_ptr<ChannelFsm> d_channel_fsm;
190 
191  std::unique_ptr<gr::fft::fft_complex> d_fft_if;
192  std::unique_ptr<gr::fft::fft_complex> d_ifft;
193 
194  std::vector<std::vector<gr_complex>> d_grid_doppler_wipeoffs;
195  std::vector<gr_complex> d_fft_code_data;
196  std::vector<gr_complex> d_fft_code_pilot;
197  std::vector<gr_complex> d_data_correlation;
198  std::vector<gr_complex> d_pilot_correlation;
199  std::vector<gr_complex> d_correlation_plus;
200  std::vector<gr_complex> d_correlation_minus;
201  std::vector<float> d_magnitude;
202 
203  std::ofstream d_dump_file;
204  std::string d_satellite_str;
205  std::string d_dump_filename;
206 
207  Gnss_Synchro* d_gnss_synchro;
208 
209  int64_t d_fs_in;
210  uint64_t d_sample_counter;
211 
212  float d_threshold;
213  float d_doppler_freq;
214  float d_mag;
215  float d_input_power;
216  float d_test_statistics;
217 
218  int32_t d_state;
219  int32_t d_samples_per_ms;
220  int32_t d_samples_per_code;
221  uint32_t d_doppler_resolution;
222  uint32_t d_doppler_max;
223  uint32_t d_doppler_step;
224  uint32_t d_sampled_ms;
225  uint32_t d_max_dwells;
226  uint32_t d_well_count;
227  uint32_t d_fft_size;
228  uint32_t d_num_doppler_bins;
229  uint32_t d_code_phase;
230  uint32_t d_channel;
231 
232  bool d_active;
233  bool d_dump;
234 };
235 
236 #endif // GNSS_SDR_PCPS_CCCWSR_ACQUISITION_CC_H
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(uint32_t channel)
Set acquisition channel unique ID.
void set_local_code(std::complex< float > *code_data, std::complex< float > *code_pilot)
Sets local code for CCCWSR acquisition algorithm.
void set_doppler_step(uint32_t doppler_step)
Set Doppler steps for the grid search.
Interface of the State Machine for channel.
void set_active(bool active)
Starts acquisition algorithm, turning from standby mode to active mode.
This is the class that contains the information that is shared by the processing blocks.
Definition: gnss_synchro.h:33
This class implements a Parallel Code Phase Search Acquisition with Coherent Channel Combining With S...
void set_channel_fsm(std::weak_ptr< ChannelFsm > channel_fsm)
Set channel fsm associated to this acquisition instance.
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)
Coherent Channel Combining With Sign Recovery Acquisition signal processing.
void init()
Initializes acquisition algorithm.
~pcps_cccwsr_acquisition_cc()
Default destructor.
void set_state(int32_t state)
If set to 1, ensures that acquisition starts at the first available sample.
void set_threshold(float threshold)
Set statistics threshold of CCCWSR algorithm.
uint32_t mag() const
Returns the maximum peak of grid search.
Interface of the Gnss_Synchro class.