GNSS-SDR  0.0.19
An Open Source GNSS Software Defined Receiver
gps_l1_ca_gaussian_tracking_cc.h
Go to the documentation of this file.
1 /*!
2  * \file gps_l1_ca_gaussian_tracking_cc.h
3  * \brief Interface of a processing block of a DLL + Kalman carrier
4  * tracking loop for GPS L1 C/A signals
5  * \author Javier Arribas, 2018. jarribas(at)cttc.es
6  * \author Jordi Vila-Valls 2018. jvila(at)cttc.es
7  * \author Carles Fernandez-Prades 2018. cfernandez(at)cttc.es
8  *
9  * Reference:
10  * J. Vila-Valls, P. Closas, M. Navarro and C. Fernandez-Prades,
11  * "Are PLLs Dead? A Tutorial on Kalman Filter-based Techniques for Digital
12  * Carrier Synchronization", IEEE Aerospace and Electronic Systems Magazine,
13  * Vol. 32, No. 7, pp. 28–45, July 2017. DOI: 10.1109/MAES.2017.150260
14  *
15  * -----------------------------------------------------------------------------
16  *
17  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
18  * This file is part of GNSS-SDR.
19  *
20  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
21  * SPDX-License-Identifier: GPL-3.0-or-later
22  *
23  * -----------------------------------------------------------------------------
24  */
25 
26 #ifndef GNSS_SDR_GPS_L1_CA_GAUSSIAN_TRACKING_CC_H
27 #define GNSS_SDR_GPS_L1_CA_GAUSSIAN_TRACKING_CC_H
28 
29 #if ARMA_NO_BOUND_CHECKING
30 #define ARMA_NO_DEBUG 1
31 #endif
32 
33 #include "bayesian_estimation.h"
35 #include "gnss_block_interface.h"
36 #include "gnss_synchro.h"
39 #include <armadillo>
40 #include <gnuradio/block.h>
41 #include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
42 #include <fstream>
43 #include <map>
44 #include <string>
45 
46 /** \addtogroup Tracking
47  * \{ */
48 /** \addtogroup Tracking_gnuradio_blocks
49  * \{ */
50 
51 
53 
54 using gps_l1_ca_gaussian_tracking_cc_sptr = gnss_shared_ptr<Gps_L1_Ca_Gaussian_Tracking_cc>;
55 
56 gps_l1_ca_gaussian_tracking_cc_sptr
57 gps_l1_ca_gaussian_make_tracking_cc(uint32_t order,
58  int64_t fs_in,
59  uint32_t vector_length,
60  bool dump,
61  const std::string& dump_filename,
62  float dll_bw_hz,
63  float early_late_space_chips,
64  bool bce_run,
65  uint32_t bce_ptrans,
66  uint32_t bce_strans,
67  int32_t bce_nu,
68  int32_t bce_kappa);
69 
70 
71 /*!
72  * \brief This class implements a DLL + PLL tracking loop block
73  */
74 class Gps_L1_Ca_Gaussian_Tracking_cc : public gr::block
75 {
76 public:
78 
79  void set_channel(uint32_t channel);
80  void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro);
81  void start_tracking();
82 
83  int general_work(int noutput_items, gr_vector_int& ninput_items,
84  gr_vector_const_void_star& input_items, gr_vector_void_star& output_items);
85 
86  void forecast(int noutput_items, gr_vector_int& ninput_items_required);
87 
88 private:
89  friend gps_l1_ca_gaussian_tracking_cc_sptr
90  gps_l1_ca_gaussian_make_tracking_cc(uint32_t order,
91  int64_t fs_in,
92  uint32_t vector_length,
93  bool dump,
94  const std::string& dump_filename,
95  float dll_bw_hz,
96  float early_late_space_chips,
97  bool bce_run,
98  uint32_t bce_ptrans,
99  uint32_t bce_strans,
100  int32_t bce_nu,
101  int32_t bce_kappa);
102 
103  Gps_L1_Ca_Gaussian_Tracking_cc(uint32_t order,
104  int64_t fs_in,
105  uint32_t vector_length,
106  bool dump,
107  const std::string& dump_filename,
108  float dll_bw_hz,
109  float early_late_space_chips,
110  bool bce_run,
111  uint32_t bce_ptrans,
112  uint32_t bce_strans,
113  int32_t bce_nu,
114  int32_t bce_kappa);
115 
116  int32_t save_matfile();
117 
118  // tracking configuration vars
119  uint32_t d_order;
120  uint32_t d_vector_length;
121  bool d_dump;
122 
123  Gnss_Synchro* d_acquisition_gnss_synchro;
124  uint32_t d_channel;
125 
126  int64_t d_fs_in;
127 
128  double d_early_late_spc_chips;
129 
130  // remaining code phase and carrier phase between tracking loops
131  double d_rem_code_phase_samples;
132  double d_rem_code_phase_chips;
133  float d_rem_carr_phase_rad;
134 
135  // Kalman filter variables
136  arma::mat kf_P_x_ini; // initial state error covariance matrix
137  arma::mat kf_P_x; // state error covariance matrix
138  arma::mat kf_P_x_pre; // Predicted state error covariance matrix
139  arma::mat kf_P_y; // innovation covariance matrix
140 
141  arma::mat kf_F; // state transition matrix
142  arma::mat kf_H; // system matrix
143  arma::mat kf_R; // measurement error covariance matrix
144  arma::mat kf_Q; // system error covariance matrix
145 
146  arma::colvec kf_x; // state vector
147  arma::colvec kf_x_pre; // predicted state vector
148  arma::colvec kf_y; // measurement vector
149  arma::mat kf_K; // Kalman gain matrix
150 
151  // Gaussian estimator
152  Bayesian_estimator bayes_estimator;
153  arma::mat kf_R_est; // measurement error covariance
154  uint32_t bayes_ptrans;
155  uint32_t bayes_strans;
156  int32_t bayes_nu;
157  int32_t bayes_kappa;
158 
159  bool bayes_run;
160  uint32_t kf_iter;
161 
162  // PLL and DLL filter library
163  Tracking_2nd_DLL_filter d_code_loop_filter;
164  // Tracking_2nd_PLL_filter d_carrier_loop_filter;
165 
166  // acquisition
167  double d_acq_carrier_doppler_step_hz{};
168  double d_acq_code_phase_samples;
169  double d_acq_carrier_doppler_hz;
170  // correlator
171  int32_t d_n_correlator_taps;
172  volk_gnsssdr::vector<float> d_ca_code;
173  volk_gnsssdr::vector<float> d_local_code_shift_chips;
174  volk_gnsssdr::vector<gr_complex> d_correlator_outs;
175  Cpu_Multicorrelator_Real_Codes multicorrelator_cpu;
176 
177  // tracking vars
178  double d_code_freq_chips;
179  double d_code_phase_step_chips;
180  double d_code_phase_rate_step_chips;
181  double d_carrier_doppler_hz;
182  double d_carrier_dopplerrate_hz2;
183  double d_carrier_phase_step_rad;
184  double d_acc_carrier_phase_rad;
185  double d_carr_phase_error_rad{};
186  double d_carr_phase_sigma2;
187  double d_code_phase_samples;
188  double code_error_chips;
189  double code_error_filt_chips;
190 
191  // PRN period in samples
192  int32_t d_current_prn_length_samples;
193 
194  // processing samples counters
195  uint64_t d_sample_counter;
196  uint64_t d_acq_sample_stamp;
197 
198  // CN0 estimation and lock detector
199  int32_t d_cn0_estimation_counter;
200  volk_gnsssdr::vector<gr_complex> d_Prompt_buffer;
201  double d_carrier_lock_test;
202  double d_CN0_SNV_dB_Hz;
203  double d_carrier_lock_threshold;
204  int32_t d_carrier_lock_fail_counter;
205 
206  // control vars
207  bool d_enable_tracking;
208  bool d_pull_in;
209 
210  // file dump
211  std::string d_dump_filename;
212  std::ofstream d_dump_file;
213 
214  std::map<std::string, std::string> systemName;
215  std::string sys;
216 };
217 
218 
219 /** \} */
220 /** \} */
221 #endif // GNSS_SDR_GPS_L1_CA_GAUSSIAN_TRACKING_CC_H
Bayesian_estimator is an estimator of noise characteristics (i.e. mean, covariance) ...
Interface of a 2nd order PLL filter for carrier tracking loop.
This class implements a 2nd order DLL filter for code tracking 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.
Interface of a 2nd order DLL filter for code tracking loop.
Class that implements carrier wipe-off and correlators.
This class implements a DLL + PLL tracking loop block.
Interface of a library with Bayesian noise statistic estimation.
Interface of the Gnss_Synchro class.