2018-03-13 09:51:33 +00:00
|
|
|
|
/*!
|
2018-10-29 23:48:59 +00:00
|
|
|
|
* \file gps_l1_ca_kf_tracking_cc.h
|
2018-04-10 08:52:19 +00:00
|
|
|
|
* \brief Interface of a processing block of a DLL + Kalman carrier
|
|
|
|
|
* tracking loop for GPS L1 C/A signals
|
|
|
|
|
* \author Javier Arribas, 2018. jarribas(at)cttc.es
|
|
|
|
|
* \author Jordi Vila-Valls 2018. jvila(at)cttc.es
|
|
|
|
|
* \author Carles Fernandez-Prades 2018. cfernandez(at)cttc.es
|
2018-03-13 09:51:33 +00:00
|
|
|
|
*
|
2018-04-10 08:52:19 +00:00
|
|
|
|
* Reference:
|
|
|
|
|
* J. Vila-Valls, P. Closas, M. Navarro and C. Fernandez-Prades,
|
|
|
|
|
* "Are PLLs Dead? A Tutorial on Kalman Filter-based Techniques for Digital
|
|
|
|
|
* Carrier Synchronization", IEEE Aerospace and Electronic Systems Magazine,
|
|
|
|
|
* Vol. 32, No. 7, pp. 28–45, July 2017. DOI: 10.1109/MAES.2017.150260
|
2018-03-13 09:51:33 +00:00
|
|
|
|
*
|
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
|
*
|
2019-07-26 10:38:20 +00:00
|
|
|
|
* Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors)
|
2018-03-13 09:51:33 +00:00
|
|
|
|
*
|
|
|
|
|
* GNSS-SDR is a software defined Global Navigation
|
|
|
|
|
* Satellite Systems receiver
|
|
|
|
|
*
|
|
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
|
*
|
|
|
|
|
* GNSS-SDR is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* GNSS-SDR is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2020-02-05 20:24:46 +00:00
|
|
|
|
* along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
|
2018-03-13 09:51:33 +00:00
|
|
|
|
*
|
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
2019-09-13 06:56:37 +00:00
|
|
|
|
#ifndef GNSS_SDR_GPS_L1_CA_KF_TRACKING_CC_H_
|
|
|
|
|
#define GNSS_SDR_GPS_L1_CA_KF_TRACKING_CC_H_
|
2018-03-13 09:51:33 +00:00
|
|
|
|
|
2019-07-29 19:22:44 +00:00
|
|
|
|
#if ARMA_NO_BOUND_CHECKING
|
|
|
|
|
#define ARMA_NO_DEBUG 1
|
|
|
|
|
#endif
|
|
|
|
|
|
2018-12-09 21:00:09 +00:00
|
|
|
|
#include "bayesian_estimation.h"
|
|
|
|
|
#include "cpu_multicorrelator_real_codes.h"
|
2018-03-13 09:51:33 +00:00
|
|
|
|
#include "gnss_synchro.h"
|
|
|
|
|
#include "tracking_2nd_DLL_filter.h"
|
|
|
|
|
#include "tracking_2nd_PLL_filter.h"
|
2018-08-21 13:00:57 +00:00
|
|
|
|
#include <armadillo>
|
|
|
|
|
#include <gnuradio/block.h>
|
2019-11-05 13:45:41 +00:00
|
|
|
|
#include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
|
2018-08-21 13:00:57 +00:00
|
|
|
|
#include <fstream>
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <string>
|
2018-03-13 09:51:33 +00:00
|
|
|
|
|
|
|
|
|
class Gps_L1_Ca_Kf_Tracking_cc;
|
|
|
|
|
|
2019-02-11 12:02:18 +00:00
|
|
|
|
using gps_l1_ca_kf_tracking_cc_sptr = boost::shared_ptr<Gps_L1_Ca_Kf_Tracking_cc>;
|
2018-03-13 09:51:33 +00:00
|
|
|
|
|
|
|
|
|
gps_l1_ca_kf_tracking_cc_sptr
|
2018-08-21 13:00:57 +00:00
|
|
|
|
gps_l1_ca_kf_make_tracking_cc(uint32_t order,
|
|
|
|
|
int64_t if_freq,
|
|
|
|
|
int64_t fs_in, uint32_t vector_length,
|
2018-03-15 17:56:29 +00:00
|
|
|
|
bool dump,
|
2019-09-11 22:31:34 +00:00
|
|
|
|
const std::string& dump_filename,
|
2019-02-21 09:33:20 +00:00
|
|
|
|
float dll_bw_hz,
|
2018-08-14 01:18:01 +00:00
|
|
|
|
float early_late_space_chips,
|
|
|
|
|
bool bce_run,
|
2018-08-21 13:00:57 +00:00
|
|
|
|
uint32_t bce_ptrans,
|
|
|
|
|
uint32_t bce_strans,
|
|
|
|
|
int32_t bce_nu,
|
|
|
|
|
int32_t bce_kappa);
|
2018-03-13 09:51:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief This class implements a DLL + PLL tracking loop block
|
|
|
|
|
*/
|
2018-03-15 17:56:29 +00:00
|
|
|
|
class Gps_L1_Ca_Kf_Tracking_cc : public gr::block
|
2018-03-13 09:51:33 +00:00
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
~Gps_L1_Ca_Kf_Tracking_cc();
|
|
|
|
|
|
2018-08-21 13:00:57 +00:00
|
|
|
|
void set_channel(uint32_t channel);
|
2018-03-13 09:51:33 +00:00
|
|
|
|
void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro);
|
|
|
|
|
void start_tracking();
|
|
|
|
|
|
2018-03-15 17:56:29 +00:00
|
|
|
|
int general_work(int noutput_items, gr_vector_int& ninput_items,
|
|
|
|
|
gr_vector_const_void_star& input_items, gr_vector_void_star& output_items);
|
2018-03-13 09:51:33 +00:00
|
|
|
|
|
2018-03-15 17:56:29 +00:00
|
|
|
|
void forecast(int noutput_items, gr_vector_int& ninput_items_required);
|
2018-03-13 09:51:33 +00:00
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
friend gps_l1_ca_kf_tracking_cc_sptr
|
2018-08-21 13:00:57 +00:00
|
|
|
|
gps_l1_ca_kf_make_tracking_cc(uint32_t order,
|
|
|
|
|
int64_t if_freq,
|
|
|
|
|
int64_t fs_in, uint32_t vector_length,
|
2018-03-15 17:56:29 +00:00
|
|
|
|
bool dump,
|
2019-09-11 22:31:34 +00:00
|
|
|
|
const std::string& dump_filename,
|
2018-03-15 17:56:29 +00:00
|
|
|
|
float dll_bw_hz,
|
2018-08-14 01:18:01 +00:00
|
|
|
|
float early_late_space_chips,
|
|
|
|
|
bool bce_run,
|
2018-08-21 13:00:57 +00:00
|
|
|
|
uint32_t bce_ptrans,
|
|
|
|
|
uint32_t bce_strans,
|
|
|
|
|
int32_t bce_nu,
|
|
|
|
|
int32_t bce_kappa);
|
|
|
|
|
|
|
|
|
|
Gps_L1_Ca_Kf_Tracking_cc(uint32_t order,
|
|
|
|
|
int64_t if_freq,
|
|
|
|
|
int64_t fs_in, uint32_t vector_length,
|
2018-03-15 17:56:29 +00:00
|
|
|
|
bool dump,
|
2019-09-11 22:31:34 +00:00
|
|
|
|
const std::string& dump_filename,
|
2018-03-15 17:56:29 +00:00
|
|
|
|
float dll_bw_hz,
|
2018-08-14 01:18:01 +00:00
|
|
|
|
float early_late_space_chips,
|
|
|
|
|
bool bce_run,
|
2018-08-21 13:00:57 +00:00
|
|
|
|
uint32_t bce_ptrans,
|
|
|
|
|
uint32_t bce_strans,
|
|
|
|
|
int32_t bce_nu,
|
|
|
|
|
int32_t bce_kappa);
|
2018-03-13 09:51:33 +00:00
|
|
|
|
|
|
|
|
|
// tracking configuration vars
|
2018-08-21 13:00:57 +00:00
|
|
|
|
uint32_t d_order;
|
|
|
|
|
uint32_t d_vector_length;
|
2018-03-13 09:51:33 +00:00
|
|
|
|
bool d_dump;
|
|
|
|
|
|
|
|
|
|
Gnss_Synchro* d_acquisition_gnss_synchro;
|
2018-08-21 13:00:57 +00:00
|
|
|
|
uint32_t d_channel;
|
2018-03-13 09:51:33 +00:00
|
|
|
|
|
2018-08-21 13:00:57 +00:00
|
|
|
|
int64_t d_if_freq;
|
|
|
|
|
int64_t d_fs_in;
|
2018-03-13 09:51:33 +00:00
|
|
|
|
|
|
|
|
|
double d_early_late_spc_chips;
|
|
|
|
|
|
|
|
|
|
// remaining code phase and carrier phase between tracking loops
|
|
|
|
|
double d_rem_code_phase_samples;
|
|
|
|
|
double d_rem_code_phase_chips;
|
|
|
|
|
double d_rem_carr_phase_rad;
|
|
|
|
|
|
|
|
|
|
// Kalman filter variables
|
2018-08-21 13:00:57 +00:00
|
|
|
|
arma::mat kf_P_x_ini; // initial state error covariance matrix
|
|
|
|
|
arma::mat kf_P_x; // state error covariance matrix
|
|
|
|
|
arma::mat kf_P_x_pre; // Predicted state error covariance matrix
|
|
|
|
|
arma::mat kf_P_y; // innovation covariance matrix
|
2018-08-14 01:18:01 +00:00
|
|
|
|
|
2018-08-21 13:00:57 +00:00
|
|
|
|
arma::mat kf_F; // state transition matrix
|
|
|
|
|
arma::mat kf_H; // system matrix
|
|
|
|
|
arma::mat kf_R; // measurement error covariance matrix
|
|
|
|
|
arma::mat kf_Q; // system error covariance matrix
|
2018-08-14 01:18:01 +00:00
|
|
|
|
|
2018-08-21 13:00:57 +00:00
|
|
|
|
arma::colvec kf_x; // state vector
|
|
|
|
|
arma::colvec kf_x_pre; // predicted state vector
|
|
|
|
|
arma::colvec kf_y; // measurement vector
|
|
|
|
|
arma::mat kf_K; // Kalman gain matrix
|
2018-03-13 09:51:33 +00:00
|
|
|
|
|
2018-07-09 15:46:34 +00:00
|
|
|
|
// Bayesian estimator
|
2018-08-14 01:18:01 +00:00
|
|
|
|
Bayesian_estimator bayes_estimator;
|
2018-08-21 13:00:57 +00:00
|
|
|
|
arma::mat kf_R_est; // measurement error covariance
|
|
|
|
|
uint32_t bayes_ptrans;
|
|
|
|
|
uint32_t bayes_strans;
|
|
|
|
|
int32_t bayes_nu;
|
|
|
|
|
int32_t bayes_kappa;
|
2018-07-09 15:46:34 +00:00
|
|
|
|
|
2018-08-14 01:18:01 +00:00
|
|
|
|
bool bayes_run;
|
2018-08-21 13:00:57 +00:00
|
|
|
|
uint32_t kf_iter;
|
2018-03-13 09:51:33 +00:00
|
|
|
|
|
|
|
|
|
// PLL and DLL filter library
|
|
|
|
|
Tracking_2nd_DLL_filter d_code_loop_filter;
|
2018-08-21 13:00:57 +00:00
|
|
|
|
// Tracking_2nd_PLL_filter d_carrier_loop_filter;
|
2018-03-13 09:51:33 +00:00
|
|
|
|
|
|
|
|
|
// acquisition
|
2019-07-20 09:13:28 +00:00
|
|
|
|
double d_acq_carrier_doppler_step_hz{};
|
2018-03-13 09:51:33 +00:00
|
|
|
|
double d_acq_code_phase_samples;
|
|
|
|
|
double d_acq_carrier_doppler_hz;
|
|
|
|
|
// correlator
|
2018-08-21 13:00:57 +00:00
|
|
|
|
int32_t d_n_correlator_taps;
|
2019-10-26 20:24:42 +00:00
|
|
|
|
volk_gnsssdr::vector<float> d_ca_code;
|
|
|
|
|
volk_gnsssdr::vector<float> d_local_code_shift_chips;
|
|
|
|
|
volk_gnsssdr::vector<gr_complex> d_correlator_outs;
|
2019-02-22 09:47:24 +00:00
|
|
|
|
Cpu_Multicorrelator_Real_Codes multicorrelator_cpu;
|
2018-03-13 09:51:33 +00:00
|
|
|
|
|
|
|
|
|
// tracking vars
|
|
|
|
|
double d_code_freq_chips;
|
|
|
|
|
double d_code_phase_step_chips;
|
2018-08-22 15:44:52 +00:00
|
|
|
|
double d_code_phase_rate_step_chips;
|
2018-03-13 09:51:33 +00:00
|
|
|
|
double d_carrier_doppler_hz;
|
2018-08-14 01:15:58 +00:00
|
|
|
|
double d_carrier_dopplerrate_hz2;
|
2018-03-13 09:51:33 +00:00
|
|
|
|
double d_carrier_phase_step_rad;
|
|
|
|
|
double d_acc_carrier_phase_rad;
|
2019-07-20 09:13:28 +00:00
|
|
|
|
double d_carr_phase_error_rad{};
|
2018-08-14 01:18:01 +00:00
|
|
|
|
double d_carr_phase_sigma2;
|
2018-03-13 09:51:33 +00:00
|
|
|
|
double d_code_phase_samples;
|
2018-04-03 14:37:36 +00:00
|
|
|
|
double code_error_chips;
|
|
|
|
|
double code_error_filt_chips;
|
2018-03-13 09:51:33 +00:00
|
|
|
|
|
2018-08-21 13:00:57 +00:00
|
|
|
|
// PRN period in samples
|
|
|
|
|
int32_t d_current_prn_length_samples;
|
2018-03-13 09:51:33 +00:00
|
|
|
|
|
2018-08-21 13:00:57 +00:00
|
|
|
|
// processing samples counters
|
|
|
|
|
uint64_t d_sample_counter;
|
|
|
|
|
uint64_t d_acq_sample_stamp;
|
2018-03-13 09:51:33 +00:00
|
|
|
|
|
|
|
|
|
// CN0 estimation and lock detector
|
2018-08-21 13:00:57 +00:00
|
|
|
|
int32_t d_cn0_estimation_counter;
|
2019-10-26 20:24:42 +00:00
|
|
|
|
volk_gnsssdr::vector<gr_complex> d_Prompt_buffer;
|
2018-03-13 09:51:33 +00:00
|
|
|
|
double d_carrier_lock_test;
|
|
|
|
|
double d_CN0_SNV_dB_Hz;
|
|
|
|
|
double d_carrier_lock_threshold;
|
2018-08-21 13:00:57 +00:00
|
|
|
|
int32_t d_carrier_lock_fail_counter;
|
2018-03-13 09:51:33 +00:00
|
|
|
|
|
|
|
|
|
// control vars
|
|
|
|
|
bool d_enable_tracking;
|
|
|
|
|
bool d_pull_in;
|
|
|
|
|
|
|
|
|
|
// file dump
|
|
|
|
|
std::string d_dump_filename;
|
|
|
|
|
std::ofstream d_dump_file;
|
|
|
|
|
|
|
|
|
|
std::map<std::string, std::string> systemName;
|
|
|
|
|
std::string sys;
|
2018-03-15 17:56:29 +00:00
|
|
|
|
|
2018-08-21 13:00:57 +00:00
|
|
|
|
int32_t save_matfile();
|
2018-03-13 09:51:33 +00:00
|
|
|
|
};
|
|
|
|
|
|
2019-09-13 06:56:37 +00:00
|
|
|
|
#endif // GNSS_SDR_GPS_L1_CA_KF_TRACKING_CC_H_
|