GNSS-SDR  0.0.21
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-2025. jarribas(at)cttc.es
5  * \author Carles Fernandez-Prades, 2018-2025 carles.fernandez(at)cttc.es
6  * \author Antonio Ramos, 2018 antonio.ramosdet(at)gmail.com
7  *
8  * -----------------------------------------------------------------------------
9  *
10  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
11  * This file is part of GNSS-SDR.
12  *
13  * Copyright (C) 2010-2025 (see AUTHORS file for a list of contributors)
14  * SPDX-License-Identifier: GPL-3.0-or-later
15  *
16  * -----------------------------------------------------------------------------
17  */
18 
19 #ifndef GNSS_SDR_DLL_PLL_VEML_TRACKING_H
20 #define GNSS_SDR_DLL_PLL_VEML_TRACKING_H
21 
22 #include "bit_synchronizer.h"
24 #include "dll_pll_conf.h"
25 #include "exponential_smoother.h"
26 #include "gnss_block_interface.h"
27 #include "gnss_time.h" // for timetags produced by File_Timestamp_Signal_Source
28 #include "tow_to_trk.h"
29 #include "tracking_FLL_PLL_filter.h" // for PLL/FLL filter
30 #include "tracking_loop_filter.h" // for DLL filter
31 #include <boost/circular_buffer.hpp>
32 #include <gnuradio/block.h> // for block
33 #include <gnuradio/gr_complex.h> // for gr_complex
34 #include <gnuradio/types.h> // for gr_vector_int, gr_vector...
35 #include <pmt/pmt.h> // for pmt_t
36 #include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
37 #include <cstddef> // for size_t
38 #include <cstdint> // for int32_t
39 #include <fstream> // for ofstream
40 #include <string> // for string
41 #include <typeinfo> // for typeid
42 #include <utility> // for pair
43 
44 /** \addtogroup Tracking
45  * \{ */
46 /** \addtogroup Tracking_gnuradio_blocks tracking_gr_blocks
47  * GNU Radio blocks for GNSS signal tracking.
48  * \{ */
49 
50 
51 class Gnss_Synchro;
53 
54 using dll_pll_veml_tracking_sptr = gnss_shared_ptr<dll_pll_veml_tracking>;
55 
56 dll_pll_veml_tracking_sptr dll_pll_veml_make_tracking(const Dll_Pll_Conf &conf_);
57 
58 /*!
59  * \brief This class implements a code DLL + carrier PLL tracking block.
60  */
61 class dll_pll_veml_tracking : public gr::block
62 {
63 public:
64  ~dll_pll_veml_tracking() override;
65 
66  void set_channel(uint32_t channel);
67  void set_gnss_synchro(Gnss_Synchro *p_gnss_synchro);
68  void start_tracking();
69  void stop_tracking();
70 
71  int general_work(int noutput_items, gr_vector_int &ninput_items,
72  gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) override;
73 
74  void forecast(int noutput_items, gr_vector_int &ninput_items_required) override;
75 
76 private:
77  friend dll_pll_veml_tracking_sptr dll_pll_veml_make_tracking(const Dll_Pll_Conf &conf_);
78  explicit dll_pll_veml_tracking(const Dll_Pll_Conf &conf_);
79 
80  void msg_handler_telemetry_to_trk(const pmt::pmt_t &msg);
81  void do_correlation_step(const gr_complex *input_samples);
82  void run_dll_pll();
83  void check_carrier_phase_coherent_initialization();
84  void update_tracking_vars();
85  void clear_tracking_vars();
86  void save_correlation_results();
87  void log_data();
88  void configure_bit_synchronizer();
89  bool cn0_and_tracking_lock_status(double coh_integration_time_s);
90  bool acquire_secondary();
91  int64_t uint64diff(uint64_t first, uint64_t second);
92  int32_t save_matfile() const;
93 
94  Cpu_Multicorrelator_Real_Codes d_multicorrelator_cpu;
95  Cpu_Multicorrelator_Real_Codes d_correlator_data_cpu; // for data channel
96 
97  Dll_Pll_Conf d_trk_parameters;
98 
99  Exponential_Smoother d_cn0_smoother;
100  Exponential_Smoother d_carrier_lock_test_smoother;
101 
102  Tracking_loop_filter d_code_loop_filter;
103  Tracking_FLL_PLL_filter d_carrier_loop_filter;
104 
105  HistogramBitSynchronizer d_bit_sync;
106 
107  Gnss_Synchro *d_acquisition_gnss_synchro;
108 
109  volk_gnsssdr::vector<float> d_tracking_code;
110  volk_gnsssdr::vector<float> d_data_code;
111  volk_gnsssdr::vector<float> d_local_code_shift_chips;
112  volk_gnsssdr::vector<gr_complex> d_correlator_outs;
113  volk_gnsssdr::vector<gr_complex> d_Prompt_Data;
114  volk_gnsssdr::vector<gr_complex> d_Prompt_buffer;
115 
116  boost::circular_buffer<float> d_dll_filt_history;
117  boost::circular_buffer<std::pair<double, double>> d_code_ph_history;
118  boost::circular_buffer<std::pair<double, double>> d_carr_ph_history;
119  boost::circular_buffer<gr_complex> d_Prompt_circular_buffer;
120 
121  const size_t d_int_type_hash_code = typeid(int).hash_code();
122  const size_t d_tow_to_trk_type_hash_code = typeid(std::shared_ptr<TOW_to_trk>).hash_code();
123 
124  double d_signal_carrier_freq;
125  double d_code_period;
126  double d_code_chip_rate;
127  double d_acq_code_phase_samples;
128  double d_acq_carrier_doppler_hz;
129  double d_current_correlation_time_s;
130  double d_carr_phase_error_hz;
131  double d_carr_freq_error_hz;
132  double d_carr_error_filt_hz;
133  double d_code_error_chips;
134  double d_code_error_filt_chips;
135  double d_code_freq_chips;
136  double d_cfo_frequency_hz;
137  double d_carrier_doppler_hz;
138  double d_acc_carrier_phase_rad;
139  double d_rem_code_phase_chips;
140  double d_T_chip_seconds;
141  double d_T_prn_seconds;
142  double d_T_prn_samples;
143  double d_K_blk_samples;
144  double d_carrier_lock_test;
145  double d_CN0_SNV_dB_Hz;
146  double d_carrier_lock_threshold;
147  double d_carrier_phase_step_rad;
148  double d_carrier_phase_rate_step_rad;
149  double d_code_phase_step_chips;
150  double d_code_phase_rate_step_chips;
151  double d_rem_code_phase_samples;
152 
153  gr_complex *d_Very_Early;
154  gr_complex *d_Early;
155  gr_complex *d_Prompt;
156  gr_complex *d_Late;
157  gr_complex *d_Very_Late;
158 
159  gr_complex d_VE_accu;
160  gr_complex d_E_accu;
161  gr_complex d_P_accu;
162  gr_complex d_P_accu_old;
163  gr_complex d_L_accu;
164  gr_complex d_VL_accu;
165  gr_complex d_P_data_accu;
166 
167  std::string d_secondary_code_string;
168  std::string d_data_secondary_code_string;
169  std::string d_systemName;
170  std::string d_signal_type;
171  std::string d_signal_pretty_name;
172  std::string d_dump_filename;
173 
174  std::ofstream d_dump_file;
175 
176  // uint64_t d_sample_counter;
177  uint64_t d_acq_sample_stamp;
178  GnssTime d_last_timetag{};
179  std::shared_ptr<TOW_to_trk> d_last_tow_received;
180  uint64_t d_last_timetag_samplecounter;
181  bool d_timetag_waiting;
182 
183  float *d_prompt_data_shift;
184  float d_rem_carr_phase_rad;
185 
186  uint64_t d_tow_from_telemetry_ms{};
187  int64_t d_bit_sync_target_epoch{};
188  int32_t d_wn_from_telemetry{};
189 
190  int32_t d_symbols_per_bit;
191  int32_t d_state;
192  int32_t d_correlation_length_ms;
193  int32_t d_n_correlator_taps;
194  int32_t d_current_prn_length_samples;
195  int32_t d_extend_correlation_symbols_count;
196  int32_t d_extend_correlation_symbols;
197  int32_t d_current_symbol;
198  int32_t d_current_data_symbol;
199  int32_t d_cn0_estimation_counter;
200  int32_t d_carrier_lock_fail_counter;
201  int32_t d_code_lock_fail_counter;
202  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)
203  int32_t d_code_length_chips;
204 
205  uint32_t d_channel;
206  uint32_t d_secondary_code_length;
207  uint32_t d_data_secondary_code_length;
208 
209  bool d_pull_in_transitory;
210  bool d_corrected_doppler;
211  bool d_interchange_iq;
212  bool d_veml;
213  bool d_cloop;
214  bool d_secondary;
215  bool d_dump;
216  bool d_dump_mat;
217  bool d_acc_carrier_phase_initialized;
218  bool d_enable_extended_integration;
219  bool d_Flag_PLL_180_deg_phase_locked;
220  bool d_use_histogram_bit_sync;
221  bool d_wait_for_bit_edge{false};
222 };
223 
224 
225 /** \} */
226 /** \} */
227 #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)...
Histogram-based navigation data bit synchronizer.
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 to inform about TOW from Telemetry to Tracking blocks.
Class that implements carrier wipe-off and correlators.
This class implements a code DLL + carrier PLL tracking block.
Histogram-based bit-edge synchronizer for GNSS prompt correlator outputs.
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.