diff --git a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.cc index 74765ccd9..51d142f6c 100644 --- a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.cc @@ -11,7 +11,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -38,7 +38,7 @@ #include "galileo_e1_dll_pll_veml_tracking_cc.h" #include "galileo_e1_signal_processing.h" #include "tracking_discriminators.h" -#include "CN_estimators.h" +#include "lock_detectors.h" #include "GPS_L1_CA.h" #include "Galileo_E1.h" #include "control_message_factory.h" @@ -188,6 +188,8 @@ galileo_e1_dll_pll_veml_tracking_cc::galileo_e1_dll_pll_veml_tracking_cc( //systemName["C"] = std::string("Compass"); } + + void galileo_e1_dll_pll_veml_tracking_cc::start_tracking() { d_acq_code_phase_samples = d_acquisition_gnss_synchro->Acq_delay_samples; @@ -315,6 +317,7 @@ galileo_e1_dll_pll_veml_tracking_cc::~galileo_e1_dll_pll_veml_tracking_cc() } + int galileo_e1_dll_pll_veml_tracking_cc::general_work (int noutput_items,gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { @@ -423,7 +426,7 @@ int galileo_e1_dll_pll_veml_tracking_cc::general_work (int noutput_items,gr_vect d_cn0_estimation_counter = 0; // Code lock indicator - d_CN0_SNV_dB_Hz = galileo_e1_CN0_SNV(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES, d_fs_in); + d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES, d_fs_in, Galileo_E1_B_CODE_LENGTH_CHIPS); // Carrier lock indicator d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES); @@ -599,6 +602,8 @@ void galileo_e1_dll_pll_veml_tracking_cc::set_channel_queue(concurrent_queue @@ -507,8 +507,9 @@ int Gps_L1_Ca_Dll_Pll_Optim_Tracking_cc::general_work (int noutput_items, gr_vec else { d_cn0_estimation_counter = 0; - d_CN0_SNV_dB_Hz = gps_l1_ca_CN0_SNV(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES, d_fs_in); + d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES, d_fs_in, GPS_L1_CA_CODE_LENGTH_CHIPS); d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES); + // ###### TRACKING UNLOCK NOTIFICATION ##### if (d_carrier_lock_test < d_carrier_lock_threshold or d_CN0_SNV_dB_Hz < MINIMUM_VALID_CN0) { @@ -524,7 +525,8 @@ int Gps_L1_Ca_Dll_Pll_Optim_Tracking_cc::general_work (int noutput_items, gr_vec //tracking_message = 3; //loss of lock //d_channel_internal_queue->push(tracking_message); ControlMessageFactory* cmf = new ControlMessageFactory(); - if (d_queue != gr_msg_queue_sptr()) { + if (d_queue != gr_msg_queue_sptr()) + { d_queue->handle(cmf->GetQueueMessage(d_channel, 2)); } delete cmf; @@ -540,9 +542,11 @@ int Gps_L1_Ca_Dll_Pll_Optim_Tracking_cc::general_work (int noutput_items, gr_vec current_synchro_data.Prompt_I = (double)(*d_Prompt).real(); current_synchro_data.Prompt_Q = (double)(*d_Prompt).imag(); // Tracking_timestamp_secs is aligned with the PRN start sample - current_synchro_data.Tracking_timestamp_secs=((double)d_sample_counter+(double)d_next_prn_length_samples+(double)d_next_rem_code_phase_samples)/(double)d_fs_in; - // This tracking block aligns the Tracking_timestamp_secs with the start sample of the PRN, thus, Code_phase_secs=0 - current_synchro_data.Code_phase_secs=0; + current_synchro_data.Tracking_timestamp_secs = ((double)d_sample_counter + + (double)d_next_prn_length_samples + (double)d_next_rem_code_phase_samples) / (double)d_fs_in; + // This tracking block aligns the Tracking_timestamp_secs with the start sample of the PRN, + // thus, Code_phase_secs = 0 + current_synchro_data.Code_phase_secs = 0; current_synchro_data.Carrier_phase_rads = (double)d_acc_carrier_phase_rad; current_synchro_data.CN0_dB_hz = (double)d_CN0_SNV_dB_Hz; *out[0] = current_synchro_data; diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.cc index 5018e9e75..31676f7ba 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.cc @@ -38,7 +38,7 @@ #include "gps_l1_ca_dll_pll_tracking_cc.h" #include "gps_sdr_signal_processing.h" #include "tracking_discriminators.h" -#include "CN_estimators.h" +#include "lock_detectors.h" #include "GPS_L1_CA.h" #include "control_message_factory.h" #include @@ -467,8 +467,9 @@ int Gps_L1_Ca_Dll_Pll_Tracking_cc::general_work (int noutput_items, gr_vector_in else { d_cn0_estimation_counter = 0; - d_CN0_SNV_dB_Hz = gps_l1_ca_CN0_SNV(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES, d_fs_in); + d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES, d_fs_in, GPS_L1_CA_CODE_LENGTH_CHIPS); d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES); + // ###### TRACKING UNLOCK NOTIFICATION ##### if (d_carrier_lock_test < d_carrier_lock_threshold or d_CN0_SNV_dB_Hz < MINIMUM_VALID_CN0) { diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc index 2ccc00062..d804618b3 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc @@ -39,7 +39,7 @@ #include "gps_l1_ca_tcp_connector_tracking_cc.h" #include "gps_sdr_signal_processing.h" #include "tracking_discriminators.h" -#include "CN_estimators.h" +#include "lock_detectors.h" #include "GPS_L1_CA.h" #include "control_message_factory.h" #include "tcp_communication.h" @@ -51,7 +51,6 @@ #include #include #include - #include #include "tcp_packet_data.h" @@ -503,8 +502,9 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work (int noutput_items, gr_vec else { d_cn0_estimation_counter = 0; - d_CN0_SNV_dB_Hz = gps_l1_ca_CN0_SNV(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES, d_fs_in); + d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES, d_fs_in, GPS_L1_CA_CODE_LENGTH_CHIPS); d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES); + // ###### TRACKING UNLOCK NOTIFICATION ##### if (d_carrier_lock_test < d_carrier_lock_threshold or d_CN0_SNV_dB_Hz < MINIMUM_VALID_CN0) { diff --git a/src/algorithms/tracking/libs/jamfile.jam b/src/algorithms/tracking/libs/jamfile.jam index 84f333bad..5db6cd1f4 100644 --- a/src/algorithms/tracking/libs/jamfile.jam +++ b/src/algorithms/tracking/libs/jamfile.jam @@ -1,7 +1,7 @@ project : build-dir ../../../../build ; obj tracking_discriminators : tracking_discriminators.cc ; -obj CN_estimators : CN_estimators.cc ; +obj lock_detectors : lock_detectors.cc ; obj tracking_FLL_PLL_filter : tracking_FLL_PLL_filter.cc ; obj tracking_2nd_PLL_filter : tracking_2nd_PLL_filter.cc ; obj tracking_2nd_DLL_filter : tracking_2nd_DLL_filter.cc ; diff --git a/src/algorithms/tracking/libs/CN_estimators.cc b/src/algorithms/tracking/libs/lock_detectors.cc similarity index 58% rename from src/algorithms/tracking/libs/CN_estimators.cc rename to src/algorithms/tracking/libs/lock_detectors.cc index 026be3f15..abc510cc5 100644 --- a/src/algorithms/tracking/libs/CN_estimators.cc +++ b/src/algorithms/tracking/libs/lock_detectors.cc @@ -1,7 +1,6 @@ /*! - * \file CN_estimators.cc - * \brief Implementation of a library with a set of Carrier to Noise - * estimators and lock detectors. + * \file lock_detectors.cc + * \brief Implementation of a library with a set of code and carrier phase lock detectors. * * SNV_CN0 is a Carrier-to-Noise (CN0) estimator * based on the Signal-to-Noise Variance (SNV) estimator [1]. @@ -46,7 +45,8 @@ * * ------------------------------------------------------------------------- */ -#include "CN_estimators.h" + +#include "lock_detectors.h" #include "GPS_L1_CA.h" #include "Galileo_E1.h" #include @@ -68,73 +68,28 @@ * where \f$f_s\f$ is the sampling frequency and \f$L_{PRN}\f$ is the PRN sequence length. * */ -float gps_l1_ca_CN0_SNV(gr_complex* Prompt_buffer, int length, long fs_in) +float cn0_svn_estimator(gr_complex* Prompt_buffer, int length, long fs_in, double code_length) { - // estimate CN0 using buffered values - // MATLAB CODE - // SNR_SNV(count)=Psig/(Ptot-Psig); - // CN0_SNV_dB=10*log10(SNR_SNV)+10*log10(BW)-10*log10(PRN_length); - float SNR, SNR_dB_Hz; - float tmp_abs_real; - float Psig, Ptot; - Psig = 0; - Ptot = 0; + float SNR = 0; + float SNR_dB_Hz = 0; + float Psig = 0; + float Ptot = 0; for (int i=0; i * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -46,33 +45,12 @@ * ------------------------------------------------------------------------- */ -#ifndef GNSS_SDR_CN_ESTIMATORS_H_ -#define GNSS_SDR_CN_ESTIMATORS_H_ +#ifndef GNSS_SDR_LOCK_DETECTORS_H_ +#define GNSS_SDR_LOCK_DETECTORS_H_ #include -/*! \brief CN0_SNV is a Carrier-to-Noise (CN0) estimator - * based on the Signal-to-Noise Variance (SNV) estimator - * - * Signal-to-Noise (SNR) (\f$\rho\f$) estimator using the Signal-to-Noise Variance (SNV) estimator: - * \f{equation} - * \hat{\rho}=\frac{\hat{P}_s}{\hat{P}_n}=\frac{\hat{P}_s}{\hat{P}_{tot}-\hat{P}_s}, - * \f} - * where \f$\hat{P}_s=\left(\frac{1}{N}\sum^{N-1}_{i=0}|Re(Pc(i))|\right)^2\f$ is the estimation of the signal power, - * \f$\hat{P}_{tot}=\frac{1}{N}\sum^{N-1}_{i=0}|Pc(i)|^2\f$ is the estimator of the total power, \f$|\cdot|\f$ is the absolute value, - * \f$Re(\cdot)\f$ stands for the real part of the value, and \f$Pc(i)\f$ is the prompt correlator output for the sample index i. - * - * The SNR value is converted to CN0 [dB-Hz], taking to account the receiver bandwidth and the PRN code gain, using the following formula: - * \f{equation} - * CN0_{dB}=10*log(\hat{\rho})+10*log(\frac{f_s}{2})-10*log(L_{PRN}), - * \f} - * where \f$f_s\f$ is the sampling frequency and \f$L_{PRN}\f$ is the PRN sequence length. - * Ref: Marco Pini, Emanuela Falletti and Maurizio Fantino, "Performance - * Evaluation of C/N0 Estimators using a Real Time GNSS Software Receiver," - * IEEE 10th International Symposium on Spread Spectrum Techniques and - * Applications, pp.28-30, August 2008. - */ -float gps_l1_ca_CN0_SNV(gr_complex* Prompt_buffer, int length, long fs_in); + /*! \brief CN0_SNV is a Carrier-to-Noise (CN0) estimator * based on the Signal-to-Noise Variance (SNV) estimator * @@ -94,11 +72,13 @@ float gps_l1_ca_CN0_SNV(gr_complex* Prompt_buffer, int length, long fs_in); * IEEE 10th International Symposium on Spread Spectrum Techniques and * Applications, pp.28-30, August 2008. */ -float galileo_e1_CN0_SNV(gr_complex* Prompt_buffer, int length, long fs_in); +float cn0_svn_estimator(gr_complex* Prompt_buffer, int length, long fs_in, double code_length); + + /*! \brief A carrier lock detector * - * The Carrier Phase Lock Detector block uses the normalised estimate of the cosine of twice the carrier phase error is given by + * The Carrier Phase Lock Detector block uses the estimate of the cosine of twice the carrier phase error is given by * \f{equation} * C2\phi=\frac{NBD}{NBP}, * \f} diff --git a/src/main/jamfile.jam b/src/main/jamfile.jam index 2e11ecf61..b3dc5e2f6 100644 --- a/src/main/jamfile.jam +++ b/src/main/jamfile.jam @@ -63,7 +63,7 @@ exe gnss-sdr : main.cc ../algorithms/tracking/gnuradio_blocks//galileo_e1_dll_pll_veml_tracking_cc ../algorithms/tracking/gnuradio_blocks//galileo_e1_tcp_connector_tracking_cc ../algorithms/tracking/libs//tracking_discriminators -../algorithms/tracking/libs//CN_estimators +../algorithms/tracking/libs//lock_detectors ../algorithms/tracking/libs//tracking_FLL_PLL_filter ../algorithms/tracking/libs//tracking_2nd_PLL_filter ../algorithms/tracking/libs//tracking_2nd_DLL_filter diff --git a/src/tests/jamfile.jam b/src/tests/jamfile.jam index 86aa58978..dc6545b0c 100644 --- a/src/tests/jamfile.jam +++ b/src/tests/jamfile.jam @@ -60,7 +60,7 @@ exe run_tests : test_main.cc ../algorithms/tracking/gnuradio_blocks//galileo_e1_dll_pll_veml_tracking_cc ../algorithms/tracking/gnuradio_blocks//galileo_e1_tcp_connector_tracking_cc ../algorithms/tracking/libs//tracking_discriminators -../algorithms/tracking/libs//CN_estimators +../algorithms/tracking/libs//lock_detectors ../algorithms/tracking/libs//tracking_FLL_PLL_filter ../algorithms/tracking/libs//tracking_2nd_PLL_filter ../algorithms/tracking/libs//tracking_2nd_DLL_filter