GNSS-SDR 0.0.21
An Open Source GNSS Software Defined Receiver
Loading...
Searching...
No Matches
kf_tracking.h
1/*!
2 * \file kf_tracking.cc
3 * \brief Implementation of a Kalman filter based tracking with optional Vector
4 * Tracking Loop message receiver block.
5 * \author Javier Arribas, 2020. jarribas(at)cttc.es
6 *
7 * -----------------------------------------------------------------------------
8 *
9 * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
10 *
11 * GNSS-SDR is a software defined Global Navigation
12 * Satellite Systems receiver
13 *
14 * This file is part of GNSS-SDR.
15 *
16 * SPDX-License-Identifier: GPL-3.0-or-later
17 *
18 * -----------------------------------------------------------------------------
19 */
20
21#ifndef GNSS_SDR_KF_TRACKING_H
22#define GNSS_SDR_KF_TRACKING_H
23
24#if ARMA_NO_BOUND_CHECKING
25#define ARMA_NO_DEBUG 1
26#endif
27
31#include "gnss_time.h" // for timetags produced by File_Timestamp_Signal_Source
32#include "kf_conf.h"
33#include "tracking_FLL_PLL_filter.h" // for PLL/FLL filter
34#include "tracking_loop_filter.h" // for DLL filter
35#include <armadillo>
36#include <boost/circular_buffer.hpp>
37#include <gnuradio/block.h> // for block
38#include <gnuradio/gr_complex.h> // for gr_complex
39#include <gnuradio/types.h> // for gr_vector_int, gr_vector...
40#include <pmt/pmt.h> // for pmt_t
41#include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
42#include <cstddef> // for size_t
43#include <cstdint> // for int32_t
44#include <fstream> // for ofstream
45#include <memory>
46#include <string> // for string
47#include <typeinfo> // for typeid
48#include <utility> // for pair
49
50class Gnss_Synchro;
51class kf_tracking;
52
53using kf_tracking_sptr = gnss_shared_ptr<kf_tracking>;
54
55kf_tracking_sptr kf_make_tracking(const Kf_Conf &conf_);
56
57/*!
58 * \brief This class implements a code DLL + carrier PLL tracking block.
59 */
60class kf_tracking : public gr::block
61{
62public:
63 ~kf_tracking();
64
65 void set_channel(uint32_t channel);
66 void set_gnss_synchro(Gnss_Synchro *p_gnss_synchro);
67 void start_tracking();
68 void stop_tracking();
69
70 int general_work(int noutput_items, gr_vector_int &ninput_items,
71 gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
72
73 void forecast(int noutput_items, gr_vector_int &ninput_items_required);
74
75private:
76 friend kf_tracking_sptr kf_make_tracking(const Kf_Conf &conf_);
77 explicit kf_tracking(const Kf_Conf &conf_);
78
79 void init_kf(double acq_code_phase_chips, double acq_doppler_hz);
80 void update_kf_narrow_integration_time();
81 void update_kf_cn0(double current_cn0_dbhz);
82 void run_Kf();
83
84 void msg_handler_telemetry_to_trk(const pmt::pmt_t &msg);
85 void msg_handler_pvt_to_trk(const pmt::pmt_t &msg);
86 void do_correlation_step(const gr_complex *input_samples);
87
88 void check_carrier_phase_coherent_initialization();
89 void update_tracking_vars();
90 void clear_tracking_vars();
91 void save_correlation_results();
92 void log_data();
93 bool cn0_and_tracking_lock_status(double coh_integration_time_s);
94 bool acquire_secondary();
95 int32_t save_matfile() const;
96
97 Cpu_Multicorrelator_Real_Codes d_multicorrelator_cpu;
98 Cpu_Multicorrelator_Real_Codes d_correlator_data_cpu; // for data channel
99
100 Kf_Conf d_trk_parameters;
101
102 Exponential_Smoother d_cn0_smoother;
103 Exponential_Smoother d_carrier_lock_test_smoother;
104
105 Gnss_Synchro *d_acquisition_gnss_synchro;
106
107 volk_gnsssdr::vector<float> d_tracking_code;
108 volk_gnsssdr::vector<float> d_data_code;
109 volk_gnsssdr::vector<float> d_local_code_shift_chips;
110 volk_gnsssdr::vector<gr_complex> d_correlator_outs;
111 volk_gnsssdr::vector<gr_complex> d_Prompt_Data;
112 volk_gnsssdr::vector<gr_complex> d_Prompt_buffer;
113
114 boost::circular_buffer<gr_complex> d_Prompt_circular_buffer;
115 boost::circular_buffer<std::pair<double, double>> d_code_ph_history;
116 boost::circular_buffer<std::pair<double, double>> d_carr_ph_history;
117
118 const size_t d_int_type_hash_code = typeid(int).hash_code();
119
120 // Kalman Filter class variables
121 arma::mat d_F;
122 arma::mat d_H;
123 arma::mat d_R;
124 arma::mat d_Q;
125 arma::mat d_P_old_old;
126 arma::mat d_P_new_old;
127 arma::mat d_P_new_new;
128 arma::vec d_x_old_old;
129 arma::vec d_x_new_old;
130 arma::vec d_x_new_new;
131
132 std::string d_secondary_code_string;
133 std::string d_data_secondary_code_string;
134 std::string d_systemName;
135 std::string d_signal_type;
136 std::string d_signal_pretty_name;
137 std::string d_dump_filename;
138
139 std::ofstream d_dump_file;
140
141 gr_complex *d_Very_Early;
142 gr_complex *d_Early;
143 gr_complex *d_Prompt;
144 gr_complex *d_Late;
145 gr_complex *d_Very_Late;
146
147 gr_complex d_VE_accu;
148 gr_complex d_E_accu;
149 gr_complex d_P_accu;
150 gr_complex d_P_accu_old;
151 gr_complex d_L_accu;
152 gr_complex d_VL_accu;
153 gr_complex d_P_data_accu;
154
155 // nominal signal parameters
156 double d_signal_carrier_freq;
157 double d_code_period;
158 double d_code_chip_rate;
159
160 // acquisition
161 double d_acq_code_phase_samples;
162 double d_acq_carrier_doppler_hz;
163 double d_current_correlation_time_s;
164
165 // carrier and code discriminators output
166 double d_carr_phase_error_disc_hz;
167 double d_code_error_disc_chips;
168
169 // estimated parameters
170 // code
171 double d_code_error_kf_chips;
172 double d_code_freq_kf_chips_s;
173 // carrier
174 double d_carrier_phase_kf_rad;
175 double d_carrier_doppler_kf_hz;
176 double d_carrier_doppler_rate_kf_hz_s;
177
178 double d_acc_carrier_phase_rad;
179
180 double d_T_chip_seconds;
181 double d_T_prn_seconds;
182 double d_T_prn_samples;
183 double d_K_blk_samples;
184 double d_carrier_lock_test;
185 double d_CN0_SNV_dB_Hz;
186 double d_carrier_lock_threshold;
187
188 // carrier NCO
189 double d_carrier_phase_step_rad;
190 double d_carrier_phase_rate_step_rad;
191
192 // code NCO
193 double d_code_phase_step_chips;
194 double d_code_phase_rate_step_chips;
195 double d_rem_code_phase_chips;
196 double d_rem_code_phase_samples;
197
198 double d_beta;
199
200 uint64_t d_sample_counter;
201 uint64_t d_acq_sample_stamp;
202
203 float *d_prompt_data_shift;
204 float d_rem_carr_phase_rad;
205
206 uint32_t d_channel;
207 uint32_t d_secondary_code_length;
208 uint32_t d_data_secondary_code_length;
209
210 int32_t d_symbols_per_bit;
211 int32_t d_state;
212 int32_t d_correlation_length_ms;
213 int32_t d_n_correlator_taps;
214 int32_t d_current_prn_length_samples;
215 int32_t d_extend_correlation_symbols_count;
216 int32_t d_current_symbol;
217 int32_t d_current_data_symbol;
218 int32_t d_cn0_estimation_counter;
219 int32_t d_carrier_lock_fail_counter;
220 int32_t d_code_lock_fail_counter;
221 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)
222 int32_t d_code_length_chips;
223
224 bool d_pull_in_transitory;
225 bool d_corrected_doppler;
226 bool d_interchange_iq;
227 bool d_veml;
228 bool d_cloop;
229 bool d_secondary;
230 bool d_dump;
231 bool d_dump_mat;
232 bool d_acc_carrier_phase_initialized;
233 bool d_enable_extended_integration;
234};
235
236#endif // GNSS_SDR_KF_TRACKING_H
Class that implements carrier wipe-off and correlators.
Class that implements a first-order exponential smoother.
This is the class that contains the information that is shared by the processing blocks.
This class implements a code DLL + carrier PLL tracking block.
Definition kf_tracking.h:61
Highly optimized CPU vector multiTAP correlator class using real-valued local codes.
Class that implements an exponential smoother.
This interface represents a GNSS block.
class that stores both the receiver time, relative to the receiver start and the GNSS time (absolute)
Interface of a hybrid FLL and PLL filter for tracking carrier loop.
Generic 1st to 3rd order loop filter implementation.