GNSS-SDR  0.0.19
An Open Source GNSS Software Defined Receiver
dll_pll_veml_tracking.h
Go to the documentation of this file.
1 /*!
2  * \file dll_pll_veml_tracking.h
3  * \brief Implementation of a code DLL + carrier PLL tracking block.
4  * \author Javier Arribas, 2018. jarribas(at)cttc.es
5  * \author Antonio Ramos, 2018 antonio.ramosdet(at)gmail.com
6  *
7  * -----------------------------------------------------------------------------
8  *
9  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
10  * This file is part of GNSS-SDR.
11  *
12  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
13  * SPDX-License-Identifier: GPL-3.0-or-later
14  *
15  * -----------------------------------------------------------------------------
16  */
17 
18 #ifndef GNSS_SDR_DLL_PLL_VEML_TRACKING_H
19 #define GNSS_SDR_DLL_PLL_VEML_TRACKING_H
20 
22 #include "dll_pll_conf.h"
23 #include "exponential_smoother.h"
24 #include "gnss_block_interface.h"
25 #include "gnss_time.h" // for timetags produced by File_Timestamp_Signal_Source
26 #include "tracking_FLL_PLL_filter.h" // for PLL/FLL filter
27 #include "tracking_loop_filter.h" // for DLL filter
28 #include <boost/circular_buffer.hpp>
29 #include <gnuradio/block.h> // for block
30 #include <gnuradio/gr_complex.h> // for gr_complex
31 #include <gnuradio/types.h> // for gr_vector_int, gr_vector...
32 #include <pmt/pmt.h> // for pmt_t
33 #include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
34 #include <cstddef> // for size_t
35 #include <cstdint> // for int32_t
36 #include <fstream> // for ofstream
37 #include <string> // for string
38 #include <typeinfo> // for typeid
39 #include <utility> // for pair
40 
41 /** \addtogroup Tracking
42  * \{ */
43 /** \addtogroup Tracking_gnuradio_blocks tracking_gr_blocks
44  * GNU Radio blocks for GNSS signal tracking.
45  * \{ */
46 
47 
48 class Gnss_Synchro;
50 
51 using dll_pll_veml_tracking_sptr = gnss_shared_ptr<dll_pll_veml_tracking>;
52 
53 dll_pll_veml_tracking_sptr dll_pll_veml_make_tracking(const Dll_Pll_Conf &conf_);
54 
55 /*!
56  * \brief This class implements a code DLL + carrier PLL tracking block.
57  */
58 class dll_pll_veml_tracking : public gr::block
59 {
60 public:
61  ~dll_pll_veml_tracking() override;
62 
63  void set_channel(uint32_t channel);
64  void set_gnss_synchro(Gnss_Synchro *p_gnss_synchro);
65  void start_tracking();
66  void stop_tracking();
67 
68  int general_work(int noutput_items, gr_vector_int &ninput_items,
69  gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) override;
70 
71  void forecast(int noutput_items, gr_vector_int &ninput_items_required) override;
72 
73 private:
74  friend dll_pll_veml_tracking_sptr dll_pll_veml_make_tracking(const Dll_Pll_Conf &conf_);
75  explicit dll_pll_veml_tracking(const Dll_Pll_Conf &conf_);
76 
77  void msg_handler_telemetry_to_trk(const pmt::pmt_t &msg);
78  void do_correlation_step(const gr_complex *input_samples);
79  void run_dll_pll();
80  void check_carrier_phase_coherent_initialization();
81  void update_tracking_vars();
82  void clear_tracking_vars();
83  void save_correlation_results();
84  void log_data();
85  bool cn0_and_tracking_lock_status(double coh_integration_time_s);
86  bool acquire_secondary();
87  int64_t uint64diff(uint64_t first, uint64_t second);
88  int32_t save_matfile() const;
89 
90  Cpu_Multicorrelator_Real_Codes d_multicorrelator_cpu;
91  Cpu_Multicorrelator_Real_Codes d_correlator_data_cpu; // for data channel
92 
93  Dll_Pll_Conf d_trk_parameters;
94 
95  Exponential_Smoother d_cn0_smoother;
96  Exponential_Smoother d_carrier_lock_test_smoother;
97 
98  Tracking_loop_filter d_code_loop_filter;
99  Tracking_FLL_PLL_filter d_carrier_loop_filter;
100 
101  Gnss_Synchro *d_acquisition_gnss_synchro;
102 
103  volk_gnsssdr::vector<float> d_tracking_code;
104  volk_gnsssdr::vector<float> d_data_code;
105  volk_gnsssdr::vector<float> d_local_code_shift_chips;
106  volk_gnsssdr::vector<gr_complex> d_correlator_outs;
107  volk_gnsssdr::vector<gr_complex> d_Prompt_Data;
108  volk_gnsssdr::vector<gr_complex> d_Prompt_buffer;
109 
110  boost::circular_buffer<float> d_dll_filt_history;
111  boost::circular_buffer<std::pair<double, double>> d_code_ph_history;
112  boost::circular_buffer<std::pair<double, double>> d_carr_ph_history;
113  boost::circular_buffer<gr_complex> d_Prompt_circular_buffer;
114 
115  const size_t int_type_hash_code = typeid(int).hash_code();
116 
117  double d_signal_carrier_freq;
118  double d_code_period;
119  double d_code_chip_rate;
120  double d_acq_code_phase_samples;
121  double d_acq_carrier_doppler_hz;
122  double d_current_correlation_time_s;
123  double d_carr_phase_error_hz;
124  double d_carr_freq_error_hz;
125  double d_carr_error_filt_hz;
126  double d_code_error_chips;
127  double d_code_error_filt_chips;
128  double d_code_freq_chips;
129  double d_carrier_doppler_hz;
130  double d_acc_carrier_phase_rad;
131  double d_rem_code_phase_chips;
132  double d_T_chip_seconds;
133  double d_T_prn_seconds;
134  double d_T_prn_samples;
135  double d_K_blk_samples;
136  double d_carrier_lock_test;
137  double d_CN0_SNV_dB_Hz;
138  double d_carrier_lock_threshold;
139  double d_carrier_phase_step_rad;
140  double d_carrier_phase_rate_step_rad;
141  double d_code_phase_step_chips;
142  double d_code_phase_rate_step_chips;
143  double d_rem_code_phase_samples;
144 
145  gr_complex *d_Very_Early;
146  gr_complex *d_Early;
147  gr_complex *d_Prompt;
148  gr_complex *d_Late;
149  gr_complex *d_Very_Late;
150 
151  gr_complex d_VE_accu;
152  gr_complex d_E_accu;
153  gr_complex d_P_accu;
154  gr_complex d_P_accu_old;
155  gr_complex d_L_accu;
156  gr_complex d_VL_accu;
157  gr_complex d_P_data_accu;
158 
159  std::string d_secondary_code_string;
160  std::string d_data_secondary_code_string;
161  std::string d_systemName;
162  std::string d_signal_type;
163  std::string d_signal_pretty_name;
164  std::string d_dump_filename;
165 
166  std::ofstream d_dump_file;
167 
168  // uint64_t d_sample_counter;
169  uint64_t d_acq_sample_stamp;
170  GnssTime d_last_timetag{};
171  uint64_t d_last_timetag_samplecounter;
172  bool d_timetag_waiting;
173 
174  float *d_prompt_data_shift;
175  float d_rem_carr_phase_rad;
176 
177  int32_t d_symbols_per_bit;
178  int32_t d_state;
179  int32_t d_correlation_length_ms;
180  int32_t d_n_correlator_taps;
181  int32_t d_current_prn_length_samples;
182  int32_t d_extend_correlation_symbols_count;
183  int32_t d_extend_correlation_symbols;
184  int32_t d_current_symbol;
185  int32_t d_current_data_symbol;
186  int32_t d_cn0_estimation_counter;
187  int32_t d_carrier_lock_fail_counter;
188  int32_t d_code_lock_fail_counter;
189  int32_t d_code_samples_per_chip; // All signals have 1 sample per chip code except Gal. E1 which has 2 (CBOC disabled) or 12 (CBOC enabled)
190  int32_t d_code_length_chips;
191 
192  uint32_t d_channel;
193  uint32_t d_secondary_code_length;
194  uint32_t d_data_secondary_code_length;
195 
196  bool d_pull_in_transitory;
197  bool d_corrected_doppler;
198  bool d_interchange_iq;
199  bool d_veml;
200  bool d_cloop;
201  bool d_secondary;
202  bool d_dump;
203  bool d_dump_mat;
204  bool d_acc_carrier_phase_initialized;
205  bool d_enable_extended_integration;
206  bool d_Flag_PLL_180_deg_phase_locked;
207 };
208 
209 
210 /** \} */
211 /** \} */
212 #endif // GNSS_SDR_DLL_PLL_VEML_TRACKING_H
class that stores both the receiver time, relative to the receiver start and the GNSS time (absolute)...
This class implements a hybrid FLL and PLL filter for tracking carrier loop.
This is the class that contains the information that is shared by the processing blocks.
Definition: gnss_synchro.h:38
This interface represents a GNSS block.
Highly optimized CPU vector multiTAP correlator class using real-valued local codes.
Class that implements a first-order exponential smoother.
Class that implements carrier wipe-off and correlators.
This class implements a code DLL + carrier PLL tracking block.
Class that contains all the configuration parameters for generic tracking block based on a DLL and a ...
Generic 1st to 3rd order loop filter implementation.
This class implements a generic 1st, 2nd or 3rd order loop filter.
Interface of a hybrid FLL and PLL filter for tracking carrier loop.
Class that implements an exponential smoother.