Minor changes

This commit is contained in:
Antonio Ramos 2018-03-12 15:16:39 +01:00
parent 026f2eea84
commit 74e8af01f9
11 changed files with 777 additions and 741 deletions

View File

@ -39,7 +39,6 @@
#include <fstream>
#include <string>
#include <map>
#include <gnuradio/block.h>
#include "gnss_synchro.h"
#include "tracking_2nd_DLL_filter.h"
@ -51,26 +50,26 @@ class dll_pll_veml_tracking;
typedef boost::shared_ptr<dll_pll_veml_tracking> dll_pll_veml_tracking_sptr;
dll_pll_veml_tracking_sptr dll_pll_veml_make_tracking(double fs_in, unsigned int vector_length,
bool dump, std::string dump_filename,
float pll_bw_hz, float dll_bw_hz,
float pll_bw_narrow_hz, float dll_bw_narrow_hz,
float early_late_space_chips, float very_early_late_space_chips,
float early_late_space_narrow_chips,
float very_early_late_space_narrow_chips,
int extend_correlation_symbols, bool track_pilot,
char system, char signal[3], bool veml);
bool dump, std::string dump_filename,
float pll_bw_hz, float dll_bw_hz,
float pll_bw_narrow_hz, float dll_bw_narrow_hz,
float early_late_space_chips, float very_early_late_space_chips,
float early_late_space_narrow_chips,
float very_early_late_space_narrow_chips,
int extend_correlation_symbols, bool track_pilot,
char system, char signal[3], bool veml);
/*!
* \brief This class implements a code DLL + carrier PLL VEML (Very Early
* Minus Late) tracking block for Galileo E1 signals
*/
class dll_pll_veml_tracking: public gr::block
class dll_pll_veml_tracking : public gr::block
{
public:
~dll_pll_veml_tracking();
void set_channel(unsigned int channel);
void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro);
void set_gnss_synchro(Gnss_Synchro *p_gnss_synchro);
void start_tracking();
/*!
@ -79,38 +78,38 @@ public:
* A Software-Defined GPS and Galileo Receiver. A Single-Frequency Approach,
* Birkhauser, 2007
*/
int general_work (int noutput_items, gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
int general_work(int noutput_items, gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
void forecast(int noutput_items, gr_vector_int &ninput_items_required);
void forecast (int noutput_items, gr_vector_int &ninput_items_required);
private:
friend dll_pll_veml_tracking_sptr dll_pll_veml_make_tracking(double fs_in, unsigned int vector_length,
bool dump, std::string dump_filename,
float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz,
float dll_bw_narrow_hz, float early_late_space_chips,
float very_early_late_space_chips, float early_late_space_narrow_chips,
float very_early_late_space_narrow_chips,
int extend_correlation_symbols, bool track_pilot,
char system, char signal[3], bool veml);
bool dump, std::string dump_filename,
float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz,
float dll_bw_narrow_hz, float early_late_space_chips,
float very_early_late_space_chips, float early_late_space_narrow_chips,
float very_early_late_space_narrow_chips,
int extend_correlation_symbols, bool track_pilot,
char system, char signal[3], bool veml);
dll_pll_veml_tracking(double fs_in, unsigned
int vector_length,
bool dump,
std::string dump_filename,
float pll_bw_hz,
float dll_bw_hz,
float pll_bw_narrow_hz,
float dll_bw_narrow_hz,
float early_late_space_chips,
float very_early_late_space_chips,
float early_late_space_narrow_chips,
float very_early_late_space_narrow_chips,
int extend_correlation_symbols,
bool track_pilot,
char system, char signal[3], bool veml);
dll_pll_veml_tracking(double fs_in, unsigned int vector_length,
bool dump,
std::string dump_filename,
float pll_bw_hz,
float dll_bw_hz,
float pll_bw_narrow_hz,
float dll_bw_narrow_hz,
float early_late_space_chips,
float very_early_late_space_chips,
float early_late_space_narrow_chips,
float very_early_late_space_narrow_chips,
int extend_correlation_symbols,
bool track_pilot,
char system, char signal[3], bool veml);
bool cn0_and_tracking_lock_status();
void do_correlation_step(const gr_complex* input_samples);
void do_correlation_step(const gr_complex *input_samples);
void run_dll_pll(bool disable_costas_loop);
void update_local_code();
void update_local_carrier();
@ -121,10 +120,13 @@ private:
void log_data();
// tracking configuration vars
unsigned int d_vector_length;
bool d_dump;
bool d_veml;
Gnss_Synchro* d_acquisition_gnss_synchro;
bool d_secondary;
unsigned int d_secondary_code_length;
std::string *d_secondary_code_string;
Gnss_Synchro *d_acquisition_gnss_synchro;
unsigned int d_vector_length;
unsigned int d_channel;
// long d_fs_in;
double d_fs_in;
@ -141,24 +143,24 @@ private:
//Integration period in samples
int d_correlation_length_samples;
int d_correlation_length_ms;
int d_n_correlator_taps;
double d_early_late_spc_chips;
double d_very_early_late_spc_chips;
double d_early_late_spc_narrow_chips;
double d_very_early_late_spc_narrow_chips;
float* d_tracking_code;
float* d_data_code;
float* d_local_code_shift_chips;
gr_complex* d_correlator_outs;
float *d_tracking_code;
float *d_data_code;
float *d_local_code_shift_chips;
float *d_null_shift;
gr_complex *d_correlator_outs;
cpu_multicorrelator_real_codes multicorrelator_cpu;
//todo: currently the multicorrelator does not support adding extra correlator
//TODO: currently the multicorrelator does not support adding extra correlator
//with different local code, thus we need extra multicorrelator instance.
//Implement this functionality inside multicorrelator class
//as an enhancement to increase the performance
float* d_local_code_data_shift_chips;
cpu_multicorrelator_real_codes correlator_data_cpu; //for data channel
cpu_multicorrelator_real_codes correlator_data_cpu; //for data channel
gr_complex *d_Very_Early;
gr_complex *d_Early;
@ -166,9 +168,9 @@ private:
gr_complex *d_Late;
gr_complex *d_Very_Late;
bool d_enable_extended_integration;
int d_extend_correlation_symbols;
int d_extend_correlation_symbols_count;
bool d_enable_extended_integration;
int d_current_symbol;
gr_complex d_VE_accu;
@ -223,7 +225,7 @@ private:
// CN0 estimation and lock detector
int d_cn0_estimation_counter;
std::deque<gr_complex> d_Prompt_buffer_deque;
gr_complex* d_Prompt_buffer;
gr_complex *d_Prompt_buffer;
double d_carrier_lock_test;
double d_CN0_SNV_dB_Hz;
double d_carrier_lock_threshold;
@ -233,10 +235,10 @@ private:
std::string d_dump_filename;
std::ofstream d_dump_file;
std::map<std::string, std::string> systemName;
std::string sys;
std::string systemName;
std::string signal_type;
int save_matfile();
};
#endif //GNSS_SDR_DLL_PLL_VEML_TRACKING_H
#endif //GNSS_SDR_DLL_PLL_VEML_TRACKING_H

View File

@ -122,7 +122,7 @@ bool cpu_multicorrelator_real_codes::Carrier_wipeoff_multicorrelator_resampler(
lv_32fc_t phase_offset_as_complex[1];
phase_offset_as_complex[0] = lv_cmake(std::cos(rem_carrier_phase_in_rad), -std::sin(rem_carrier_phase_in_rad));
// call VOLK_GNSSSDR kernel
volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn(d_corr_out, d_sig_in, std::exp(lv_32fc_t(0, -phase_step_rad)), phase_offset_as_complex, (const float**)d_local_codes_resampled, d_n_correlators, signal_length_samples);
volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn(d_corr_out, d_sig_in, std::exp(lv_32fc_t(0.0, -phase_step_rad)), phase_offset_as_complex, (const float**)d_local_codes_resampled, d_n_correlators, signal_length_samples);
return true;
}

View File

@ -67,20 +67,20 @@
*/
float cn0_svn_estimator(gr_complex* Prompt_buffer, int length, long fs_in, double code_length)
{
double SNR = 0;
double SNR_dB_Hz = 0;
double Psig = 0;
double Ptot = 0;
double SNR = 0.0;
double SNR_dB_Hz = 0.0;
double Psig = 0.0;
double Ptot = 0.0;
for (int i = 0; i < length; i++)
{
Psig += std::abs(static_cast<double>(Prompt_buffer[i].real()));
Ptot += static_cast<double>(Prompt_buffer[i].imag()) * static_cast<double>(Prompt_buffer[i].imag()) + static_cast<double>(Prompt_buffer[i].real()) * static_cast<double>(Prompt_buffer[i].real());
}
Psig = Psig / static_cast<double>(length);
Psig /= static_cast<double>(length);
Psig = Psig * Psig;
Ptot = Ptot / static_cast<double>(length);
Ptot /= static_cast<double>(length);
SNR = Psig / (Ptot - Psig);
SNR_dB_Hz = 10 * log10(SNR) + 10 * log10(static_cast<double>(fs_in) / 2) - 10 * log10(code_length);
SNR_dB_Hz = 10.0 * log10(SNR) + 10.0 * log10(static_cast<double>(fs_in) / 2.0) - 10.0 * log10(code_length);
return static_cast<float>(SNR_dB_Hz);
}
@ -96,10 +96,10 @@ float cn0_svn_estimator(gr_complex* Prompt_buffer, int length, long fs_in, doubl
*/
float carrier_lock_detector(gr_complex* Prompt_buffer, int length)
{
float tmp_sum_I = 0;
float tmp_sum_Q = 0;
float NBD = 0;
float NBP = 0;
float tmp_sum_I = 0.0;
float tmp_sum_Q = 0.0;
float NBD = 0.0;
float NBP = 0.0;
for (int i = 0; i < length; i++)
{
tmp_sum_I += Prompt_buffer[i].real();

View File

@ -41,11 +41,10 @@
void Tracking_2nd_DLL_filter::calculate_lopp_coef(float* tau1, float* tau2, float lbw, float zeta, float k)
{
// Solve natural frequency
float Wn;
Wn = lbw * 8 * zeta / (4 * zeta * zeta + 1);
float Wn = lbw * 8.0 * zeta / (4.0 * zeta * zeta + 1.0);
// solve for t1 & t2
*tau1 = k / (Wn * Wn);
*tau2 = (2.0 * zeta) / Wn;
*tau2 = 2.0 * zeta / Wn;
}
@ -67,9 +66,7 @@ void Tracking_2nd_DLL_filter::initialize()
float Tracking_2nd_DLL_filter::get_code_nco(float DLL_discriminator)
{
float code_nco;
code_nco = d_old_code_nco + (d_tau2_code / d_tau1_code) * (DLL_discriminator - d_old_code_error) + (DLL_discriminator + d_old_code_error) * (d_pdi_code / (2 * d_tau1_code));
//code_nco = d_old_code_nco + (d_tau2_code/d_tau1_code)*(DLL_discriminator - d_old_code_error) + DLL_discriminator * (d_pdi_code/d_tau1_code);
float code_nco = d_old_code_nco + (d_tau2_code / d_tau1_code) * (DLL_discriminator - d_old_code_error) + (DLL_discriminator + d_old_code_error) * (d_pdi_code / (2.0 * d_tau1_code));
d_old_code_nco = code_nco;
d_old_code_error = DLL_discriminator; //[chips]
return code_nco;

View File

@ -49,13 +49,13 @@ class Tracking_2nd_DLL_filter
{
private:
// PLL filter parameters
float d_tau1_code = 0;
float d_tau2_code = 0;
float d_pdi_code = 0;
float d_dllnoisebandwidth = 0;
float d_dlldampingratio = 0;
float d_old_code_error = 0;
float d_old_code_nco = 0;
float d_tau1_code = 0.0;
float d_tau2_code = 0.0;
float d_pdi_code = 0.0;
float d_dllnoisebandwidth = 0.0;
float d_dlldampingratio = 0.0;
float d_old_code_error = 0.0;
float d_old_code_nco = 0.0;
void calculate_lopp_coef(float* tau1, float* tau2, float lbw, float zeta, float k);
public:

View File

@ -40,11 +40,10 @@
void Tracking_2nd_PLL_filter::calculate_lopp_coef(float* tau1, float* tau2, float lbw, float zeta, float k)
{
// Solve natural frequency
float Wn;
Wn = lbw * 8 * zeta / (4 * zeta * zeta + 1);
float Wn = lbw * 8.0 * zeta / (4.0 * zeta * zeta + 1.0);
// solve for t1 & t2
*tau1 = k / (Wn * Wn);
*tau2 = (2.0 * zeta) / Wn;
*tau2 = 2.0 * zeta / Wn;
}
@ -71,8 +70,7 @@ void Tracking_2nd_PLL_filter::initialize()
*/
float Tracking_2nd_PLL_filter::get_carrier_nco(float PLL_discriminator)
{
float carr_nco;
carr_nco = d_old_carr_nco + (d_tau2_carr / d_tau1_carr) * (PLL_discriminator - d_old_carr_error) + (PLL_discriminator + d_old_carr_error) * (d_pdi_carr / (2 * d_tau1_carr));
float carr_nco = d_old_carr_nco + (d_tau2_carr / d_tau1_carr) * (PLL_discriminator - d_old_carr_error) + (PLL_discriminator + d_old_carr_error) * (d_pdi_carr / (2.0 * d_tau1_carr));
//carr_nco = d_old_carr_nco + (d_tau2_carr/d_tau1_carr)*(PLL_discriminator - d_old_carr_error) + PLL_discriminator * (d_pdi_carr/d_tau1_carr);
d_old_carr_nco = carr_nco;
d_old_carr_error = PLL_discriminator;

View File

@ -48,15 +48,15 @@ class Tracking_2nd_PLL_filter
{
private:
// PLL filter parameters
float d_tau1_carr = 0;
float d_tau2_carr = 0;
float d_pdi_carr = 0;
float d_tau1_carr = 0.0;
float d_tau2_carr = 0.0;
float d_pdi_carr = 0.0;
float d_pllnoisebandwidth = 0;
float d_plldampingratio = 0;
float d_pllnoisebandwidth = 0.0;
float d_plldampingratio = 0.0;
float d_old_carr_error = 0;
float d_old_carr_nco = 0;
float d_old_carr_error = 0.0;
float d_old_carr_nco = 0.0;
void calculate_lopp_coef(float* tau1, float* tau2, float lbw, float zeta, float k);

View File

@ -83,7 +83,7 @@ double pll_cloop_two_quadrant_atan(gr_complex prompt_s1)
}
else
{
return 0;
return 0.0;
}
}
@ -107,7 +107,7 @@ double dll_nc_e_minus_l_normalized(gr_complex early_s1, gr_complex late_s1)
}
else
{
return 0.5 * (P_early - P_late) / ((P_early + P_late));
return 0.5 * (P_early - P_late) / (P_early + P_late);
}
}
@ -131,6 +131,6 @@ double dll_nc_vemlp_normalized(gr_complex very_early_s1, gr_complex early_s1, gr
}
else
{
return (P_early - P_late) / ((P_early + P_late));
return (P_early - P_late) / (P_early + P_late);
}
}

View File

@ -37,9 +37,6 @@
#include <glog/logging.h>
#define MAX_LOOP_ORDER 3
#define MAX_HISTORY_LENGTH 4
Tracking_loop_filter::Tracking_loop_filter(float update_interval,
float noise_bandwidth,
int loop_order,
@ -50,8 +47,8 @@ Tracking_loop_filter::Tracking_loop_filter(float update_interval,
d_noise_bandwidth(noise_bandwidth),
d_update_interval(update_interval)
{
d_inputs.resize(MAX_HISTORY_LENGTH, 0.0);
d_outputs.resize(MAX_HISTORY_LENGTH, 0.0);
d_inputs.resize(MAX_LOOP_HISTORY_LENGTH, 0.0);
d_outputs.resize(MAX_LOOP_HISTORY_LENGTH, 0.0);
update_coefficients();
}
@ -62,8 +59,8 @@ Tracking_loop_filter::Tracking_loop_filter()
d_noise_bandwidth(15.0),
d_update_interval(0.001)
{
d_inputs.resize(MAX_HISTORY_LENGTH, 0.0);
d_outputs.resize(MAX_HISTORY_LENGTH, 0.0);
d_inputs.resize(MAX_LOOP_HISTORY_LENGTH, 0.0);
d_outputs.resize(MAX_LOOP_HISTORY_LENGTH, 0.0);
update_coefficients();
}
@ -75,12 +72,12 @@ Tracking_loop_filter::~Tracking_loop_filter()
float Tracking_loop_filter::apply(float current_input)
{
// Now apply the filter coefficients:
float result = 0;
float result = 0.0;
// Hanlde the old outputs first:
for (unsigned int ii = 0; ii < d_output_coefficients.size(); ++ii)
{
result += d_output_coefficients[ii] * d_outputs[(d_current_index + ii) % MAX_HISTORY_LENGTH];
result += d_output_coefficients[ii] * d_outputs[(d_current_index + ii) % MAX_LOOP_HISTORY_LENGTH];
}
// Now update the index to handle the inputs.
@ -93,7 +90,7 @@ float Tracking_loop_filter::apply(float current_input)
d_current_index--;
if (d_current_index < 0)
{
d_current_index += MAX_HISTORY_LENGTH;
d_current_index += MAX_LOOP_HISTORY_LENGTH;
}
d_inputs[d_current_index] = current_input;
@ -101,7 +98,7 @@ float Tracking_loop_filter::apply(float current_input)
for (unsigned int ii = 0; ii < d_input_coefficients.size(); ++ii)
{
result += d_input_coefficients[ii] * d_inputs[(d_current_index + ii) % MAX_HISTORY_LENGTH];
result += d_input_coefficients[ii] * d_inputs[(d_current_index + ii) % MAX_LOOP_HISTORY_LENGTH];
}
@ -122,7 +119,7 @@ void Tracking_loop_filter::update_coefficients(void)
float wn;
float T = d_update_interval;
float zeta = 1 / std::sqrt(2);
float zeta = 1.0 / std::sqrt(2.0);
// The following is based on the bilinear transform approximation of
// the analog integrator. The loop format is from Kaplan & Hegarty
@ -146,7 +143,7 @@ void Tracking_loop_filter::update_coefficients(void)
d_input_coefficients[1] = g1 * T / 2.0;
d_output_coefficients.resize(1);
d_output_coefficients[0] = 1;
d_output_coefficients[0] = 1.0;
}
else
{
@ -157,28 +154,28 @@ void Tracking_loop_filter::update_coefficients(void)
}
break;
case 2:
wn = d_noise_bandwidth * (8 * zeta) / (4 * zeta * zeta + 1);
wn = d_noise_bandwidth * (8.0 * zeta) / (4.0 * zeta * zeta + 1.0);
g1 = wn * wn;
g2 = wn * 2 * zeta;
g2 = wn * 2.0 * zeta;
if (d_include_last_integrator)
{
d_input_coefficients.resize(3);
d_input_coefficients[0] = T / 2 * (g1 * T / 2 + g2);
d_input_coefficients[1] = T * T / 2 * g1;
d_input_coefficients[2] = T / 2 * (g1 * T / 2 - g2);
d_input_coefficients[0] = T / 2.0 * (g1 * T / 2.0 + g2);
d_input_coefficients[1] = T * T / 2.0 * g1;
d_input_coefficients[2] = T / 2.0 * (g1 * T / 2.0 - g2);
d_output_coefficients.resize(2);
d_output_coefficients[0] = 2;
d_output_coefficients[1] = -1;
d_output_coefficients[0] = 2.0;
d_output_coefficients[1] = -1.0;
}
else
{
d_input_coefficients.resize(2);
d_input_coefficients[0] = (g1 * T / 2.0 + g2);
d_input_coefficients[1] = g1 * T / 2 - g2;
d_input_coefficients[1] = g1 * T / 2.0 - g2;
d_output_coefficients.resize(1);
d_output_coefficients[0] = 1;
d_output_coefficients[0] = 1.0;
}
break;
@ -193,27 +190,27 @@ void Tracking_loop_filter::update_coefficients(void)
if (d_include_last_integrator)
{
d_input_coefficients.resize(4);
d_input_coefficients[0] = T / 2 * (g3 + T / 2 * (g2 + T / 2 * g1));
d_input_coefficients[1] = T / 2 * (-g3 + T / 2 * (g2 + 3 * T / 2 * g1));
d_input_coefficients[2] = T / 2 * (-g3 - T / 2 * (g2 - 3 * T / 2 * g1));
d_input_coefficients[3] = T / 2 * (g3 - T / 2 * (g2 - T / 2 * g1));
d_input_coefficients[0] = T / 2.0 * (g3 + T / 2.0 * (g2 + T / 2.0 * g1));
d_input_coefficients[1] = T / 2.0 * (-g3 + T / 2.0 * (g2 + 3.0 * T / 2.0 * g1));
d_input_coefficients[2] = T / 2.0 * (-g3 - T / 2.0 * (g2 - 3.0 * T / 2.0 * g1));
d_input_coefficients[3] = T / 2.0 * (g3 - T / 2.0 * (g2 - T / 2.0 * g1));
d_output_coefficients.resize(3);
d_output_coefficients[0] = 3;
d_output_coefficients[1] = -3;
d_output_coefficients[2] = 1;
d_output_coefficients[0] = 3.0;
d_output_coefficients[1] = -3.0;
d_output_coefficients[2] = 1.0;
}
else
{
d_input_coefficients.resize(3);
d_input_coefficients[0] = g3 + T / 2 * (g2 + T / 2 * g1);
d_input_coefficients[1] = g1 * T * T / 2 - 2 * g3;
d_input_coefficients[2] = g3 + T / 2 * (-g2 + T / 2 * g1);
d_input_coefficients[0] = g3 + T / 2.0 * (g2 + T / 2.0 * g1);
d_input_coefficients[1] = g1 * T * T / 2.0 - 2.0 * g3;
d_input_coefficients[2] = g3 + T / 2.0 * (-g2 + T / 2.0 * g1);
d_output_coefficients.resize(2);
d_output_coefficients[0] = 2;
d_output_coefficients[1] = -1;
d_output_coefficients[0] = 2.0;
d_output_coefficients[1] = -1.0;
}
break;
};
@ -254,7 +251,7 @@ bool Tracking_loop_filter::get_include_last_integrator(void) const
void Tracking_loop_filter::set_order(int loop_order)
{
if (loop_order < 1 || loop_order > MAX_LOOP_ORDER)
if (loop_order < 1 or loop_order > MAX_LOOP_ORDER)
{
LOG(ERROR) << "Ignoring attempt to set loop order to " << loop_order
<< ". Maximum allowed order is: " << MAX_LOOP_ORDER
@ -274,7 +271,7 @@ int Tracking_loop_filter::get_order(void) const
void Tracking_loop_filter::initialize(float initial_output)
{
d_inputs.assign(MAX_HISTORY_LENGTH, 0.0);
d_outputs.assign(MAX_HISTORY_LENGTH, initial_output);
d_current_index = MAX_HISTORY_LENGTH - 1;
d_inputs.assign(MAX_LOOP_HISTORY_LENGTH, 0.0);
d_outputs.assign(MAX_LOOP_HISTORY_LENGTH, initial_output);
d_current_index = MAX_LOOP_HISTORY_LENGTH - 1;
}

View File

@ -33,6 +33,8 @@
#ifndef GNSS_SDR_TRACKING_LOOP_FILTER_H_
#define GNSS_SDR_TRACKING_LOOP_FILTER_H_
#define MAX_LOOP_ORDER 3
#define MAX_LOOP_HISTORY_LENGTH 4
#include <vector>