GNSS-SDR  0.0.13
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  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
18  *
19  * GNSS-SDR is a software defined Global Navigation
20  * Satellite Systems receiver
21  *
22  * This file is part of GNSS-SDR.
23  *
24  * SPDX-License-Identifier: GPL-3.0-or-later
25  *
26  * -----------------------------------------------------------------------------
27  */
28 
29 #ifndef GNSS_SDR_GPS_L1_CA_KF_TRACKING_CC_H
30 #define GNSS_SDR_GPS_L1_CA_KF_TRACKING_CC_H
31 
32 #if ARMA_NO_BOUND_CHECKING
33 #define ARMA_NO_DEBUG 1
34 #endif
35 
36 #include "bayesian_estimation.h"
38 #include "gnss_synchro.h"
41 #include <armadillo>
42 #include <gnuradio/block.h>
43 #include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
44 #include <fstream>
45 #include <map>
46 #include <string>
47 #if GNURADIO_USES_STD_POINTERS
48 #include <memory>
49 #else
50 #include <boost/shared_ptr.hpp>
51 #endif
52 
54 
55 #if GNURADIO_USES_STD_POINTERS
56 using gps_l1_ca_kf_tracking_cc_sptr = std::shared_ptr<Gps_L1_Ca_Kf_Tracking_cc>;
57 #else
58 using gps_l1_ca_kf_tracking_cc_sptr = boost::shared_ptr<Gps_L1_Ca_Kf_Tracking_cc>;
59 #endif
60 
61 gps_l1_ca_kf_tracking_cc_sptr
62 gps_l1_ca_kf_make_tracking_cc(uint32_t order,
63  int64_t if_freq,
64  int64_t fs_in, uint32_t vector_length,
65  bool dump,
66  const std::string& dump_filename,
67  float dll_bw_hz,
68  float early_late_space_chips,
69  bool bce_run,
70  uint32_t bce_ptrans,
71  uint32_t bce_strans,
72  int32_t bce_nu,
73  int32_t bce_kappa);
74 
75 
76 /*!
77  * \brief This class implements a DLL + PLL tracking loop block
78  */
79 class Gps_L1_Ca_Kf_Tracking_cc : public gr::block
80 {
81 public:
83 
84  void set_channel(uint32_t channel);
85  void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro);
86  void start_tracking();
87 
88  int general_work(int noutput_items, gr_vector_int& ninput_items,
89  gr_vector_const_void_star& input_items, gr_vector_void_star& output_items);
90 
91  void forecast(int noutput_items, gr_vector_int& ninput_items_required);
92 
93 private:
94  friend gps_l1_ca_kf_tracking_cc_sptr
95  gps_l1_ca_kf_make_tracking_cc(uint32_t order,
96  int64_t if_freq,
97  int64_t fs_in, uint32_t vector_length,
98  bool dump,
99  const std::string& dump_filename,
100  float dll_bw_hz,
101  float early_late_space_chips,
102  bool bce_run,
103  uint32_t bce_ptrans,
104  uint32_t bce_strans,
105  int32_t bce_nu,
106  int32_t bce_kappa);
107 
108  Gps_L1_Ca_Kf_Tracking_cc(uint32_t order,
109  int64_t if_freq,
110  int64_t fs_in, uint32_t vector_length,
111  bool dump,
112  const std::string& dump_filename,
113  float dll_bw_hz,
114  float early_late_space_chips,
115  bool bce_run,
116  uint32_t bce_ptrans,
117  uint32_t bce_strans,
118  int32_t bce_nu,
119  int32_t bce_kappa);
120 
121  // tracking configuration vars
122  uint32_t d_order;
123  uint32_t d_vector_length;
124  bool d_dump;
125 
126  Gnss_Synchro* d_acquisition_gnss_synchro;
127  uint32_t d_channel;
128 
129  int64_t d_if_freq;
130  int64_t d_fs_in;
131 
132  double d_early_late_spc_chips;
133 
134  // remaining code phase and carrier phase between tracking loops
135  double d_rem_code_phase_samples;
136  double d_rem_code_phase_chips;
137  float d_rem_carr_phase_rad;
138 
139  // Kalman filter variables
140  arma::mat kf_P_x_ini; // initial state error covariance matrix
141  arma::mat kf_P_x; // state error covariance matrix
142  arma::mat kf_P_x_pre; // Predicted state error covariance matrix
143  arma::mat kf_P_y; // innovation covariance matrix
144 
145  arma::mat kf_F; // state transition matrix
146  arma::mat kf_H; // system matrix
147  arma::mat kf_R; // measurement error covariance matrix
148  arma::mat kf_Q; // system error covariance matrix
149 
150  arma::colvec kf_x; // state vector
151  arma::colvec kf_x_pre; // predicted state vector
152  arma::colvec kf_y; // measurement vector
153  arma::mat kf_K; // Kalman gain matrix
154 
155  // Bayesian estimator
156  Bayesian_estimator bayes_estimator;
157  arma::mat kf_R_est; // measurement error covariance
158  uint32_t bayes_ptrans;
159  uint32_t bayes_strans;
160  int32_t bayes_nu;
161  int32_t bayes_kappa;
162 
163  bool bayes_run;
164  uint32_t kf_iter;
165 
166  // PLL and DLL filter library
167  Tracking_2nd_DLL_filter d_code_loop_filter;
168  // Tracking_2nd_PLL_filter d_carrier_loop_filter;
169 
170  // acquisition
171  double d_acq_carrier_doppler_step_hz{};
172  double d_acq_code_phase_samples;
173  double d_acq_carrier_doppler_hz;
174  // correlator
175  int32_t d_n_correlator_taps;
176  volk_gnsssdr::vector<float> d_ca_code;
177  volk_gnsssdr::vector<float> d_local_code_shift_chips;
178  volk_gnsssdr::vector<gr_complex> d_correlator_outs;
179  Cpu_Multicorrelator_Real_Codes multicorrelator_cpu;
180 
181  // tracking vars
182  double d_code_freq_chips;
183  double d_code_phase_step_chips;
184  double d_code_phase_rate_step_chips;
185  double d_carrier_doppler_hz;
186  double d_carrier_dopplerrate_hz2;
187  double d_carrier_phase_step_rad;
188  double d_acc_carrier_phase_rad;
189  double d_carr_phase_error_rad{};
190  double d_carr_phase_sigma2;
191  double d_code_phase_samples;
192  double code_error_chips;
193  double code_error_filt_chips;
194 
195  // PRN period in samples
196  int32_t d_current_prn_length_samples;
197 
198  // processing samples counters
199  uint64_t d_sample_counter;
200  uint64_t d_acq_sample_stamp;
201 
202  // CN0 estimation and lock detector
203  int32_t d_cn0_estimation_counter;
204  volk_gnsssdr::vector<gr_complex> d_Prompt_buffer;
205  double d_carrier_lock_test;
206  double d_CN0_SNV_dB_Hz;
207  double d_carrier_lock_threshold;
208  int32_t d_carrier_lock_fail_counter;
209 
210  // control vars
211  bool d_enable_tracking;
212  bool d_pull_in;
213 
214  // file dump
215  std::string d_dump_filename;
216  std::ofstream d_dump_file;
217 
218  std::map<std::string, std::string> systemName;
219  std::string sys;
220 
221  int32_t save_matfile();
222 };
223 
224 #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:33
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.