GNSS-SDR  0.0.14
An Open Source GNSS Software Defined Receiver
gps_l1_ca_kf_tracking_cc.h
Go to the documentation of this file.
1 /*!
2  * \file gps_l1_ca_kf_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_KF_TRACKING_CC_H
27 #define GNSS_SDR_GPS_L1_CA_KF_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_kf_tracking_cc_sptr = gnss_shared_ptr<Gps_L1_Ca_Kf_Tracking_cc>;
55 
56 gps_l1_ca_kf_tracking_cc_sptr
57 gps_l1_ca_kf_make_tracking_cc(uint32_t order,
58  int64_t if_freq,
59  int64_t fs_in, 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_Kf_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_kf_tracking_cc_sptr
90  gps_l1_ca_kf_make_tracking_cc(uint32_t order,
91  int64_t if_freq,
92  int64_t fs_in, 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_Kf_Tracking_cc(uint32_t order,
104  int64_t if_freq,
105  int64_t fs_in, 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  // tracking configuration vars
117  uint32_t d_order;
118  uint32_t d_vector_length;
119  bool d_dump;
120 
121  Gnss_Synchro* d_acquisition_gnss_synchro;
122  uint32_t d_channel;
123 
124  int64_t d_if_freq;
125  int64_t d_fs_in;
126 
127  double d_early_late_spc_chips;
128 
129  // remaining code phase and carrier phase between tracking loops
130  double d_rem_code_phase_samples;
131  double d_rem_code_phase_chips;
132  float d_rem_carr_phase_rad;
133 
134  // Kalman filter variables
135  arma::mat kf_P_x_ini; // initial state error covariance matrix
136  arma::mat kf_P_x; // state error covariance matrix
137  arma::mat kf_P_x_pre; // Predicted state error covariance matrix
138  arma::mat kf_P_y; // innovation covariance matrix
139 
140  arma::mat kf_F; // state transition matrix
141  arma::mat kf_H; // system matrix
142  arma::mat kf_R; // measurement error covariance matrix
143  arma::mat kf_Q; // system error covariance matrix
144 
145  arma::colvec kf_x; // state vector
146  arma::colvec kf_x_pre; // predicted state vector
147  arma::colvec kf_y; // measurement vector
148  arma::mat kf_K; // Kalman gain matrix
149 
150  // Bayesian estimator
151  Bayesian_estimator bayes_estimator;
152  arma::mat kf_R_est; // measurement error covariance
153  uint32_t bayes_ptrans;
154  uint32_t bayes_strans;
155  int32_t bayes_nu;
156  int32_t bayes_kappa;
157 
158  bool bayes_run;
159  uint32_t kf_iter;
160 
161  // PLL and DLL filter library
162  Tracking_2nd_DLL_filter d_code_loop_filter;
163  // Tracking_2nd_PLL_filter d_carrier_loop_filter;
164 
165  // acquisition
166  double d_acq_carrier_doppler_step_hz{};
167  double d_acq_code_phase_samples;
168  double d_acq_carrier_doppler_hz;
169  // correlator
170  int32_t d_n_correlator_taps;
171  volk_gnsssdr::vector<float> d_ca_code;
172  volk_gnsssdr::vector<float> d_local_code_shift_chips;
173  volk_gnsssdr::vector<gr_complex> d_correlator_outs;
174  Cpu_Multicorrelator_Real_Codes multicorrelator_cpu;
175 
176  // tracking vars
177  double d_code_freq_chips;
178  double d_code_phase_step_chips;
179  double d_code_phase_rate_step_chips;
180  double d_carrier_doppler_hz;
181  double d_carrier_dopplerrate_hz2;
182  double d_carrier_phase_step_rad;
183  double d_acc_carrier_phase_rad;
184  double d_carr_phase_error_rad{};
185  double d_carr_phase_sigma2;
186  double d_code_phase_samples;
187  double code_error_chips;
188  double code_error_filt_chips;
189 
190  // PRN period in samples
191  int32_t d_current_prn_length_samples;
192 
193  // processing samples counters
194  uint64_t d_sample_counter;
195  uint64_t d_acq_sample_stamp;
196 
197  // CN0 estimation and lock detector
198  int32_t d_cn0_estimation_counter;
199  volk_gnsssdr::vector<gr_complex> d_Prompt_buffer;
200  double d_carrier_lock_test;
201  double d_CN0_SNV_dB_Hz;
202  double d_carrier_lock_threshold;
203  int32_t d_carrier_lock_fail_counter;
204 
205  // control vars
206  bool d_enable_tracking;
207  bool d_pull_in;
208 
209  // file dump
210  std::string d_dump_filename;
211  std::ofstream d_dump_file;
212 
213  std::map<std::string, std::string> systemName;
214  std::string sys;
215 
216  int32_t save_matfile();
217 };
218 
219 
220 /** \} */
221 /** \} */
222 #endif // GNSS_SDR_GPS_L1_CA_KF_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 class implements a DLL + PLL tracking loop block.
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.
Interface of a library with Bayesian noise statistic estimation.
Interface of the Gnss_Synchro class.