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