1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-15 20:50:33 +00:00

Apply coding style

This commit is contained in:
Carles Fernandez 2018-01-17 08:42:50 +01:00
parent 6af8527518
commit 27baa7e45d
3 changed files with 457 additions and 437 deletions

View File

@ -81,7 +81,7 @@ GalileoE1DllPllVemlTracking::GalileoE1DllPllVemlTracking(
early_late_space_narrow_chips = configuration->property(role + ".early_late_space_narrow_chips", 0.15); early_late_space_narrow_chips = configuration->property(role + ".early_late_space_narrow_chips", 0.15);
very_early_late_space_narrow_chips = configuration->property(role + ".very_early_late_space_narrow_chips", 0.6); very_early_late_space_narrow_chips = configuration->property(role + ".very_early_late_space_narrow_chips", 0.6);
bool track_pilot=configuration->property(role + ".track_pilot", false); bool track_pilot = configuration->property(role + ".track_pilot", false);
std::string default_dump_filename = "./track_ch"; std::string default_dump_filename = "./track_ch";
dump_filename = configuration->property(role + ".dump_filename", dump_filename = configuration->property(role + ".dump_filename",
@ -108,16 +108,6 @@ GalileoE1DllPllVemlTracking::GalileoE1DllPllVemlTracking(
very_early_late_space_narrow_chips, very_early_late_space_narrow_chips,
extend_correlation_symbols, extend_correlation_symbols,
track_pilot); track_pilot);
// tracking_ = galileo_e1_dll_pll_veml_make_tracking_cc(
// f_if,
// fs_in,
// vector_length,
// dump,
// dump_filename,
// pll_bw_hz,
// dll_bw_hz,
// early_late_space_chips,
// very_early_late_space_chips);
} }
else else
{ {
@ -130,14 +120,17 @@ GalileoE1DllPllVemlTracking::GalileoE1DllPllVemlTracking(
DLOG(INFO) << "tracking(" << tracking_->unique_id() << ")"; DLOG(INFO) << "tracking(" << tracking_->unique_id() << ")";
} }
GalileoE1DllPllVemlTracking::~GalileoE1DllPllVemlTracking() GalileoE1DllPllVemlTracking::~GalileoE1DllPllVemlTracking()
{} {}
void GalileoE1DllPllVemlTracking::start_tracking() void GalileoE1DllPllVemlTracking::start_tracking()
{ {
tracking_->start_tracking(); tracking_->start_tracking();
} }
/* /*
* Set tracking channel unique ID * Set tracking channel unique ID
*/ */
@ -153,23 +146,27 @@ void GalileoE1DllPllVemlTracking::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro)
tracking_->set_gnss_synchro(p_gnss_synchro); tracking_->set_gnss_synchro(p_gnss_synchro);
} }
void GalileoE1DllPllVemlTracking::connect(gr::top_block_sptr top_block) void GalileoE1DllPllVemlTracking::connect(gr::top_block_sptr top_block)
{ {
if(top_block) { /* top_block is not null */}; if(top_block) { /* top_block is not null */};
//nothing to connect, now the tracking uses gr_sync_decimator //nothing to connect, now the tracking uses gr_sync_decimator
} }
void GalileoE1DllPllVemlTracking::disconnect(gr::top_block_sptr top_block) void GalileoE1DllPllVemlTracking::disconnect(gr::top_block_sptr top_block)
{ {
if(top_block) { /* top_block is not null */}; if(top_block) { /* top_block is not null */};
//nothing to disconnect, now the tracking uses gr_sync_decimator //nothing to disconnect, now the tracking uses gr_sync_decimator
} }
gr::basic_block_sptr GalileoE1DllPllVemlTracking::get_left_block() gr::basic_block_sptr GalileoE1DllPllVemlTracking::get_left_block()
{ {
return tracking_; return tracking_;
} }
gr::basic_block_sptr GalileoE1DllPllVemlTracking::get_right_block() gr::basic_block_sptr GalileoE1DllPllVemlTracking::get_right_block()
{ {
return tracking_; return tracking_;

View File

@ -146,10 +146,10 @@ galileo_e1_dll_pll_veml_tracking_cc::galileo_e1_dll_pll_veml_tracking_cc(
// Initialize tracking ========================================== // Initialize tracking ==========================================
// Set bandwidth of code and carrier loop filters // Set bandwidth of code and carrier loop filters
d_dll_bw_hz=dll_bw_hz; d_dll_bw_hz = dll_bw_hz;
d_pll_bw_hz=pll_bw_hz; d_pll_bw_hz = pll_bw_hz;
d_dll_bw_narrow_hz=dll_bw_narrow_hz; d_dll_bw_narrow_hz = dll_bw_narrow_hz;
d_pll_bw_narrow_hz=pll_bw_narrow_hz; d_pll_bw_narrow_hz = pll_bw_narrow_hz;
d_code_loop_filter.set_DLL_BW(d_dll_bw_hz); d_code_loop_filter.set_DLL_BW(d_dll_bw_hz);
d_carrier_loop_filter.set_PLL_BW(d_pll_bw_hz); d_carrier_loop_filter.set_PLL_BW(d_pll_bw_hz);
@ -189,28 +189,32 @@ galileo_e1_dll_pll_veml_tracking_cc::galileo_e1_dll_pll_veml_tracking_cc(
d_correlation_length_samples = d_vector_length; d_correlation_length_samples = d_vector_length;
multicorrelator_cpu.init(2 * d_correlation_length_samples, d_n_correlator_taps); multicorrelator_cpu.init(2 * d_correlation_length_samples, d_n_correlator_taps);
d_extend_correlation_symbols=extend_correlation_symbols; d_extend_correlation_symbols = extend_correlation_symbols;
// Enable Data component prompt correlator (slave to Pilot prompt) if tracking uses Pilot signal // Enable Data component prompt correlator (slave to Pilot prompt) if tracking uses Pilot signal
d_track_pilot=track_pilot; d_track_pilot = track_pilot;
if (d_track_pilot) if (d_track_pilot)
{ {
//extended integration control //extended integration control
if (d_extend_correlation_symbols>1) if (d_extend_correlation_symbols > 1)
{ {
d_enable_extended_integration=true; d_enable_extended_integration = true;
}else{ }
d_enable_extended_integration=false; else
{
d_enable_extended_integration = false;
} }
//Extra correlator for the data component //Extra correlator for the data component
d_local_code_data_shift_chips=static_cast<float*>(volk_gnsssdr_malloc(sizeof(float), volk_gnsssdr_get_alignment())); d_local_code_data_shift_chips = static_cast<float*>(volk_gnsssdr_malloc(sizeof(float), volk_gnsssdr_get_alignment()));
d_local_code_data_shift_chips[0]=0.0; d_local_code_data_shift_chips[0] = 0.0;
correlator_data_cpu.init(2 * d_correlation_length_samples, 1); correlator_data_cpu.init(2 * d_correlation_length_samples, 1);
d_Prompt_Data = static_cast<gr_complex*>(volk_gnsssdr_malloc(sizeof(gr_complex), volk_gnsssdr_get_alignment())); d_Prompt_Data = static_cast<gr_complex*>(volk_gnsssdr_malloc(sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_Prompt_Data[0] = gr_complex(0,0); d_Prompt_Data[0] = gr_complex(0,0);
d_data_code = static_cast<float*>(volk_gnsssdr_malloc((2 * Galileo_E1_B_CODE_LENGTH_CHIPS) * sizeof(float), volk_gnsssdr_get_alignment())); d_data_code = static_cast<float*>(volk_gnsssdr_malloc((2 * Galileo_E1_B_CODE_LENGTH_CHIPS) * sizeof(float), volk_gnsssdr_get_alignment()));
}else{ }
else
{
// Disable extended integration if data component tracking is selected // Disable extended integration if data component tracking is selected
d_enable_extended_integration=false; d_enable_extended_integration = false;
} }
//--- Initializations ------------------------------ //--- Initializations ------------------------------
@ -247,7 +251,7 @@ galileo_e1_dll_pll_veml_tracking_cc::galileo_e1_dll_pll_veml_tracking_cc(
d_carrier_doppler_hz = 0.0; d_carrier_doppler_hz = 0.0;
d_acc_carrier_phase_rad = 0.0; d_acc_carrier_phase_rad = 0.0;
d_state=0;// intial state: stanby d_state = 0;// intial state: stanby
} }
@ -301,10 +305,9 @@ void galileo_e1_dll_pll_veml_tracking_cc::start_tracking()
d_carrier_loop_filter.initialize(); // initialize the carrier filter d_carrier_loop_filter.initialize(); // initialize the carrier filter
d_code_loop_filter.initialize(); // initialize the code filter d_code_loop_filter.initialize(); // initialize the code filter
if (d_track_pilot) if (d_track_pilot)
{ {
char pilot_signal[3]="1C"; char pilot_signal[3] = "1C";
galileo_e1_code_gen_float_sampled(d_tracking_code, galileo_e1_code_gen_float_sampled(d_tracking_code,
pilot_signal, pilot_signal,
false, false,
@ -317,11 +320,13 @@ void galileo_e1_dll_pll_veml_tracking_cc::start_tracking()
d_acquisition_gnss_synchro->PRN, d_acquisition_gnss_synchro->PRN,
Galileo_E1_CODE_CHIP_RATE_HZ, Galileo_E1_CODE_CHIP_RATE_HZ,
0); 0);
d_Prompt_Data[0]=gr_complex(0,0); //clean data correlator output d_Prompt_Data[0] = gr_complex(0,0); //clean data correlator output
correlator_data_cpu.set_local_code_and_taps(static_cast<int>(Galileo_E1_B_CODE_LENGTH_CHIPS), correlator_data_cpu.set_local_code_and_taps(static_cast<int>(Galileo_E1_B_CODE_LENGTH_CHIPS),
d_data_code, d_data_code,
d_local_code_shift_chips); d_local_code_shift_chips);
}else{ }
else
{
galileo_e1_code_gen_float_sampled(d_tracking_code, galileo_e1_code_gen_float_sampled(d_tracking_code,
d_acquisition_gnss_synchro->Signal, d_acquisition_gnss_synchro->Signal,
false, false,
@ -352,13 +357,11 @@ void galileo_e1_dll_pll_veml_tracking_cc::start_tracking()
LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel;
// enable tracking pull-in // enable tracking pull-in
d_state=1; d_state = 1;
LOG(INFO) << "PULL-IN Doppler [Hz]=" << d_carrier_doppler_hz LOG(INFO) << "PULL-IN Doppler [Hz]=" << d_carrier_doppler_hz
<< " Code Phase correction [samples]=" << delay_correction_samples << " Code Phase correction [samples]=" << delay_correction_samples
<< " PULL-IN Code Phase [samples]=" << d_acq_code_phase_samples; << " PULL-IN Code Phase [samples]=" << d_acq_code_phase_samples;
} }
@ -408,10 +411,11 @@ galileo_e1_dll_pll_veml_tracking_cc::~galileo_e1_dll_pll_veml_tracking_cc()
} }
} }
bool galileo_e1_dll_pll_veml_tracking_cc::acquire_secondary() bool galileo_e1_dll_pll_veml_tracking_cc::acquire_secondary()
{ {
//******* preamble correlation ******** //******* preamble correlation ********
int corr_value=0; int corr_value = 0;
for (unsigned int i = 0; i < Galileo_E1_C_SECONDARY_CODE_LENGTH; i++) for (unsigned int i = 0; i < Galileo_E1_C_SECONDARY_CODE_LENGTH; i++)
{ {
if (d_Prompt_buffer_deque.at(i).real() < 0) // symbols clipping if (d_Prompt_buffer_deque.at(i).real() < 0) // symbols clipping
@ -441,12 +445,14 @@ bool galileo_e1_dll_pll_veml_tracking_cc::acquire_secondary()
if (abs(corr_value) == Galileo_E1_C_SECONDARY_CODE_LENGTH) if (abs(corr_value) == Galileo_E1_C_SECONDARY_CODE_LENGTH)
{ {
return true; return true;
}else }
else
{ {
return false; return false;
} }
} }
bool galileo_e1_dll_pll_veml_tracking_cc::cn0_and_tracking_lock_status() bool galileo_e1_dll_pll_veml_tracking_cc::cn0_and_tracking_lock_status()
{ {
// ####### CN0 ESTIMATION AND LOCK DETECTORS ###### // ####### CN0 ESTIMATION AND LOCK DETECTORS ######
@ -477,14 +483,18 @@ bool galileo_e1_dll_pll_veml_tracking_cc::cn0_and_tracking_lock_status()
{ {
std::cout << "Loss of lock in channel " << d_channel << "!" << std::endl; std::cout << "Loss of lock in channel " << d_channel << "!" << std::endl;
LOG(INFO) << "Loss of lock in channel " << d_channel << "!"; LOG(INFO) << "Loss of lock in channel " << d_channel << "!";
this->message_port_pub(pmt::mp("events"), pmt::from_long(3));//3 -> loss of lock this->message_port_pub(pmt::mp("events"), pmt::from_long(3)); // 3 -> loss of lock
d_carrier_lock_fail_counter = 0; d_carrier_lock_fail_counter = 0;
return false; return false;
}else{ }
else
{
return true; return true;
} }
} }
} }
// correlation requires: // correlation requires:
// - updated remnant carrier phase in radians (rem_carr_phase_rad) // - updated remnant carrier phase in radians (rem_carr_phase_rad)
// - updated remnant code phase in samples (d_rem_code_phase_samples) // - updated remnant code phase in samples (d_rem_code_phase_samples)
@ -515,15 +525,18 @@ void galileo_e1_dll_pll_veml_tracking_cc::do_correlation_step(const gr_complex*
} }
} }
void galileo_e1_dll_pll_veml_tracking_cc::run_dll_pll(bool disable_costas_loop) void galileo_e1_dll_pll_veml_tracking_cc::run_dll_pll(bool disable_costas_loop)
{ {
// ################## PLL ########################################################## // ################## PLL ##########################################################
// PLL discriminator // PLL discriminator
if (disable_costas_loop==true) if (disable_costas_loop == true)
{ {
//Secondary code acquired. No symbols transition should be present in the signal // Secondary code acquired. No symbols transition should be present in the signal
d_carr_error_hz = pll_four_quadrant_atan(d_P_accu) / GALILEO_TWO_PI; d_carr_error_hz = pll_four_quadrant_atan(d_P_accu) / GALILEO_TWO_PI;
}else{ }
else
{
// Costas loop discriminator, insensitive to 180 deg phase transitions // Costas loop discriminator, insensitive to 180 deg phase transitions
d_carr_error_hz = pll_cloop_two_quadrant_atan(d_P_accu) / GALILEO_TWO_PI; d_carr_error_hz = pll_cloop_two_quadrant_atan(d_P_accu) / GALILEO_TWO_PI;
} }
@ -537,12 +550,12 @@ void galileo_e1_dll_pll_veml_tracking_cc::run_dll_pll(bool disable_costas_loop)
// ################## DLL ########################################################## // ################## DLL ##########################################################
// DLL discriminator // DLL discriminator
d_code_error_chips = dll_nc_vemlp_normalized(d_VE_accu, d_E_accu, d_L_accu, d_VL_accu); //[chips/Ti] d_code_error_chips = dll_nc_vemlp_normalized(d_VE_accu, d_E_accu, d_L_accu, d_VL_accu); // [chips/Ti]
// Code discriminator filter // Code discriminator filter
d_code_error_filt_chips = d_code_loop_filter.get_code_nco(d_code_error_chips); //[chips/second] d_code_error_filt_chips = d_code_loop_filter.get_code_nco(d_code_error_chips); // [chips/second]
} }
void galileo_e1_dll_pll_veml_tracking_cc::clear_tracking_vars() void galileo_e1_dll_pll_veml_tracking_cc::clear_tracking_vars()
{ {
*d_Very_Early = gr_complex(0,0); *d_Very_Early = gr_complex(0,0);
@ -550,13 +563,14 @@ void galileo_e1_dll_pll_veml_tracking_cc::clear_tracking_vars()
*d_Prompt = gr_complex(0,0); *d_Prompt = gr_complex(0,0);
*d_Late = gr_complex(0,0); *d_Late = gr_complex(0,0);
*d_Very_Late= gr_complex(0,0); *d_Very_Late= gr_complex(0,0);
d_carr_error_hz =0.0; d_carr_error_hz = 0.0;
d_carr_error_filt_hz =0.0; d_carr_error_filt_hz = 0.0;
d_code_error_chips =0.0; d_code_error_chips = 0.0;
d_code_error_filt_chips =0.0; d_code_error_filt_chips = 0.0;
d_current_symbol=0; d_current_symbol = 0;
} }
void galileo_e1_dll_pll_veml_tracking_cc::log_data() void galileo_e1_dll_pll_veml_tracking_cc::log_data()
{ {
if(d_dump) if(d_dump)
@ -598,12 +612,12 @@ void galileo_e1_dll_pll_veml_tracking_cc::log_data()
d_dump_file.write(reinterpret_cast<char*>(&tmp_float), sizeof(float)); d_dump_file.write(reinterpret_cast<char*>(&tmp_float), sizeof(float));
tmp_float = d_code_freq_chips; tmp_float = d_code_freq_chips;
d_dump_file.write(reinterpret_cast<char*>(&tmp_float), sizeof(float)); d_dump_file.write(reinterpret_cast<char*>(&tmp_float), sizeof(float));
//PLL commands // PLL commands
tmp_float = d_carr_error_hz; tmp_float = d_carr_error_hz;
d_dump_file.write(reinterpret_cast<char*>(&tmp_float), sizeof(float)); d_dump_file.write(reinterpret_cast<char*>(&tmp_float), sizeof(float));
tmp_float = d_carr_error_filt_hz; tmp_float = d_carr_error_filt_hz;
d_dump_file.write(reinterpret_cast<char*>(&tmp_float), sizeof(float)); d_dump_file.write(reinterpret_cast<char*>(&tmp_float), sizeof(float));
//DLL commands // DLL commands
tmp_float = d_code_error_chips; tmp_float = d_code_error_chips;
d_dump_file.write(reinterpret_cast<char*>(&tmp_float), sizeof(float)); d_dump_file.write(reinterpret_cast<char*>(&tmp_float), sizeof(float));
tmp_float = d_code_error_filt_chips; tmp_float = d_code_error_filt_chips;
@ -628,10 +642,11 @@ void galileo_e1_dll_pll_veml_tracking_cc::log_data()
} }
} }
} }
int galileo_e1_dll_pll_veml_tracking_cc::general_work (int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), int galileo_e1_dll_pll_veml_tracking_cc::general_work (int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)),
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
{ {
// Block input data and block output stream pointers // Block input data and block output stream pointers
const gr_complex* in = reinterpret_cast<const gr_complex *>(input_items[0]); const gr_complex* in = reinterpret_cast<const gr_complex *>(input_items[0]);
Gnss_Synchro **out = reinterpret_cast<Gnss_Synchro **>(&output_items[0]); Gnss_Synchro **out = reinterpret_cast<Gnss_Synchro **>(&output_items[0]);
@ -640,7 +655,7 @@ int galileo_e1_dll_pll_veml_tracking_cc::general_work (int noutput_items __attri
switch(d_state) switch(d_state)
{ {
case 0: //standby - bypass case 0: // standby - bypass
{ {
current_synchro_data.Tracking_sample_counter = d_sample_counter; current_synchro_data.Tracking_sample_counter = d_sample_counter;
break; break;
@ -661,9 +676,9 @@ int galileo_e1_dll_pll_veml_tracking_cc::general_work (int noutput_items __attri
current_synchro_data.Tracking_sample_counter = d_sample_counter; current_synchro_data.Tracking_sample_counter = d_sample_counter;
current_synchro_data.fs = d_fs_in; current_synchro_data.fs = d_fs_in;
*out[0] = current_synchro_data; *out[0] = current_synchro_data;
d_sample_counter = d_sample_counter + samples_offset; //count for the processed samples d_sample_counter = d_sample_counter + samples_offset; // count for the processed samples
consume_each(samples_offset); //shift input to perform alignment with local replica consume_each(samples_offset); // shift input to perform alignment with local replica
d_state=2; //next state is the symbol synchronization d_state = 2; // next state is the symbol synchronization
return 0; return 0;
} }
case 2: // wide tracking and symbol synchronization case 2: // wide tracking and symbol synchronization
@ -677,33 +692,33 @@ int galileo_e1_dll_pll_veml_tracking_cc::general_work (int noutput_items __attri
// perform a correlation step // perform a correlation step
do_correlation_step(in); do_correlation_step(in);
// save single correlation step variables // save single correlation step variables
d_VE_accu=*d_Very_Early; d_VE_accu = *d_Very_Early;
d_E_accu=*d_Early; d_E_accu = *d_Early;
d_P_accu=*d_Prompt; d_P_accu = *d_Prompt;
d_L_accu=*d_Late; d_L_accu = *d_Late;
d_VL_accu=*d_Very_Late; d_VL_accu = *d_Very_Late;
//check lock status //check lock status
if (cn0_and_tracking_lock_status()==false) if (cn0_and_tracking_lock_status() == false)
{ {
clear_tracking_vars(); clear_tracking_vars();
d_state=0; //loss-of-lock detected d_state = 0; // loss-of-lock detected
}else{ }
else
//perform DLL/PLL tracking loop computations {
// perform DLL/PLL tracking loop computations
run_dll_pll(false); run_dll_pll(false);
// ################## PLL COMMANDS ################################################# // ################## PLL COMMANDS #################################################
//carrier phase accumulator for (K) Doppler estimation- // carrier phase accumulator for (K) Doppler estimation-
d_acc_carrier_phase_rad -= GALILEO_TWO_PI * d_carrier_doppler_hz * static_cast<double>(d_current_prn_length_samples) / static_cast<double>(d_fs_in); d_acc_carrier_phase_rad -= GALILEO_TWO_PI * d_carrier_doppler_hz * static_cast<double>(d_current_prn_length_samples) / static_cast<double>(d_fs_in);
//remnant carrier phase to prevent overflow in the code NCO // remnant carrier phase to prevent overflow in the code NCO
d_rem_carr_phase_rad = d_rem_carr_phase_rad + GALILEO_TWO_PI * d_carrier_doppler_hz * static_cast<double>(d_current_prn_length_samples) / static_cast<double>(d_fs_in); d_rem_carr_phase_rad = d_rem_carr_phase_rad + GALILEO_TWO_PI * d_carrier_doppler_hz * static_cast<double>(d_current_prn_length_samples) / static_cast<double>(d_fs_in);
d_rem_carr_phase_rad = std::fmod(d_rem_carr_phase_rad, GALILEO_TWO_PI); d_rem_carr_phase_rad = std::fmod(d_rem_carr_phase_rad, GALILEO_TWO_PI);
// ################## DLL COMMANDS ################################################# // ################## DLL COMMANDS #################################################
// Code error from DLL
//Code error from DLL
double code_error_filt_secs; double code_error_filt_secs;
code_error_filt_secs = (Galileo_E1_CODE_PERIOD * d_code_error_filt_chips) / Galileo_E1_CODE_CHIP_RATE_HZ; //[seconds] code_error_filt_secs = (Galileo_E1_CODE_PERIOD * d_code_error_filt_chips) / Galileo_E1_CODE_CHIP_RATE_HZ; // [seconds]
// ################## CARRIER AND CODE NCO BUFFER ALIGNEMENT ####################### // ################## CARRIER AND CODE NCO BUFFER ALIGNEMENT #######################
// keep alignment parameters for the next input buffer // keep alignment parameters for the next input buffer
@ -712,28 +727,30 @@ int galileo_e1_dll_pll_veml_tracking_cc::general_work (int noutput_items __attri
double T_prn_seconds = T_chip_seconds * Galileo_E1_B_CODE_LENGTH_CHIPS; double T_prn_seconds = T_chip_seconds * Galileo_E1_B_CODE_LENGTH_CHIPS;
double T_prn_samples = T_prn_seconds * static_cast<double>(d_fs_in); double T_prn_samples = T_prn_seconds * static_cast<double>(d_fs_in);
double K_blk_samples = T_prn_samples + d_rem_code_phase_samples + code_error_filt_secs * static_cast<double>(d_fs_in); double K_blk_samples = T_prn_samples + d_rem_code_phase_samples + code_error_filt_secs * static_cast<double>(d_fs_in);
d_current_prn_length_samples = round(K_blk_samples); //round to a discrete samples d_current_prn_length_samples = round(K_blk_samples); // round to a discrete samples
// ########### Output the tracking results to Telemetry block ########## // ########### Output the tracking results to Telemetry block ##########
if (d_track_pilot) if (d_track_pilot)
{ {
current_synchro_data.Prompt_I = static_cast<double>((*d_Prompt_Data).real()); current_synchro_data.Prompt_I = static_cast<double>((*d_Prompt_Data).real());
current_synchro_data.Prompt_Q = static_cast<double>((*d_Prompt_Data).imag()); current_synchro_data.Prompt_Q = static_cast<double>((*d_Prompt_Data).imag());
}else{ }
else
{
current_synchro_data.Prompt_I = static_cast<double>((*d_Prompt).real()); current_synchro_data.Prompt_I = static_cast<double>((*d_Prompt).real());
current_synchro_data.Prompt_Q = static_cast<double>((*d_Prompt).imag()); current_synchro_data.Prompt_Q = static_cast<double>((*d_Prompt).imag());
} }
current_synchro_data.Tracking_sample_counter = d_sample_counter; current_synchro_data.Tracking_sample_counter = d_sample_counter;
current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; current_synchro_data.Code_phase_samples = d_rem_code_phase_samples;
//compute remnant code phase samples AFTER the Tracking timestamp // compute remnant code phase samples AFTER the Tracking timestamp
d_rem_code_phase_samples = K_blk_samples - d_current_prn_length_samples; //rounding error < 1 sample d_rem_code_phase_samples = K_blk_samples - d_current_prn_length_samples; // rounding error < 1 sample
current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_rad; current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_rad;
current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz;
current_synchro_data.CN0_dB_hz = d_CN0_SNV_dB_Hz; current_synchro_data.CN0_dB_hz = d_CN0_SNV_dB_Hz;
current_synchro_data.Flag_valid_symbol_output = true; current_synchro_data.Flag_valid_symbol_output = true;
current_synchro_data.correlation_length_ms = Galileo_E1_CODE_PERIOD_MS; current_synchro_data.correlation_length_ms = Galileo_E1_CODE_PERIOD_MS;
//enable write dump file this cycle (valid DLL/PLL cycle) // enable write dump file this cycle (valid DLL/PLL cycle)
log_data(); log_data();
//std::cout<<(d_Prompt->real()>0); //std::cout<<(d_Prompt->real()>0);
@ -741,19 +758,19 @@ int galileo_e1_dll_pll_veml_tracking_cc::general_work (int noutput_items __attri
{ {
// ####### SECONDARY CODE LOCK ##### // ####### SECONDARY CODE LOCK #####
d_Prompt_buffer_deque.push_back(*d_Prompt); d_Prompt_buffer_deque.push_back(*d_Prompt);
if (d_Prompt_buffer_deque.size()==Galileo_E1_C_SECONDARY_CODE_LENGTH) if (d_Prompt_buffer_deque.size() == Galileo_E1_C_SECONDARY_CODE_LENGTH)
{ {
if (acquire_secondary()==true) if (acquire_secondary() == true)
{ {
d_extend_correlation_symbols_count=0; d_extend_correlation_symbols_count = 0;
//reset extended correlator //reset extended correlator
d_VE_accu=gr_complex(0,0); d_VE_accu = gr_complex(0,0);
d_E_accu=gr_complex(0,0); d_E_accu = gr_complex(0,0);
d_P_accu=gr_complex(0,0); d_P_accu = gr_complex(0,0);
d_L_accu=gr_complex(0,0); d_L_accu = gr_complex(0,0);
d_VL_accu=gr_complex(0,0); d_VL_accu = gr_complex(0,0);
d_Prompt_buffer_deque.clear(); d_Prompt_buffer_deque.clear();
d_current_symbol=0; d_current_symbol = 0;
d_code_loop_filter.set_DLL_BW(d_dll_bw_narrow_hz); d_code_loop_filter.set_DLL_BW(d_dll_bw_narrow_hz);
d_carrier_loop_filter.set_PLL_BW(d_pll_bw_narrow_hz); d_carrier_loop_filter.set_PLL_BW(d_pll_bw_narrow_hz);
@ -764,22 +781,21 @@ int galileo_e1_dll_pll_veml_tracking_cc::general_work (int noutput_items __attri
d_local_code_shift_chips[3] = d_early_late_spc_narrow_chips; d_local_code_shift_chips[3] = d_early_late_spc_narrow_chips;
d_local_code_shift_chips[4] = d_very_early_late_spc_narrow_chips; d_local_code_shift_chips[4] = d_very_early_late_spc_narrow_chips;
LOG(INFO) << "Enabled " << d_extend_correlation_symbols << " [symbols] extended correlator for CH " LOG(INFO) << "Enabled " << d_extend_correlation_symbols << " [symbols] extended correlator for CH "
<< d_channel << d_channel
<< " : Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN); << " : Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN);
std::cout<< "Enabled " << d_extend_correlation_symbols << " [symbols] extended correlator for CH " std::cout << "Enabled " << d_extend_correlation_symbols << " [symbols] extended correlator for CH "
<< d_channel << d_channel
<< " : Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN)<<std::endl; << " : Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl;
//std::cout << " pll_bw = " << d_pll_bw_hz << " [Hz], pll_narrow_bw = " << d_pll_bw_narrow_hz << " [Hz]" << std::endl; //std::cout << " pll_bw = " << d_pll_bw_hz << " [Hz], pll_narrow_bw = " << d_pll_bw_narrow_hz << " [Hz]" << std::endl;
//std::cout << " dll_bw = " << d_dll_bw_hz << " [Hz], dll_narrow_bw = " << d_dll_bw_narrow_hz << " [Hz]" << std::endl; //std::cout << " dll_bw = " << d_dll_bw_hz << " [Hz], dll_narrow_bw = " << d_dll_bw_narrow_hz << " [Hz]" << std::endl;
// UPDATE INTEGRATION TIME // UPDATE INTEGRATION TIME
double new_correlation_time_s=static_cast<double>(d_extend_correlation_symbols) * Galileo_E1_CODE_PERIOD; double new_correlation_time_s = static_cast<double>(d_extend_correlation_symbols) * Galileo_E1_CODE_PERIOD;
d_carrier_loop_filter.set_pdi(new_correlation_time_s); d_carrier_loop_filter.set_pdi(new_correlation_time_s);
d_code_loop_filter.set_pdi(new_correlation_time_s); d_code_loop_filter.set_pdi(new_correlation_time_s);
d_state=3; // next state is the extended correlator integrator d_state = 3; // next state is the extended correlator integrator
} }
d_Prompt_buffer_deque.pop_front(); d_Prompt_buffer_deque.pop_front();
@ -792,39 +808,41 @@ int galileo_e1_dll_pll_veml_tracking_cc::general_work (int noutput_items __attri
{ {
// Fill the acquisition data // Fill the acquisition data
current_synchro_data = *d_acquisition_gnss_synchro; current_synchro_data = *d_acquisition_gnss_synchro;
//Current NCO and code generator parameters // Current NCO and code generator parameters
d_carrier_phase_step_rad = GALILEO_TWO_PI * d_carrier_doppler_hz / static_cast<double>(d_fs_in); d_carrier_phase_step_rad = GALILEO_TWO_PI * d_carrier_doppler_hz / static_cast<double>(d_fs_in);
d_code_phase_step_chips = d_code_freq_chips / static_cast<double>(d_fs_in); d_code_phase_step_chips = d_code_freq_chips / static_cast<double>(d_fs_in);
d_rem_code_phase_chips = d_rem_code_phase_samples * d_code_freq_chips / d_fs_in; d_rem_code_phase_chips = d_rem_code_phase_samples * d_code_freq_chips / d_fs_in;
// perform a correlation step // perform a correlation step
do_correlation_step(in); do_correlation_step(in);
//correct the integration sign using the current symbol of the secondary code // correct the integration sign using the current symbol of the secondary code
if (Galileo_E1_C_SECONDARY_CODE.at(d_current_symbol) == '0') if (Galileo_E1_C_SECONDARY_CODE.at(d_current_symbol) == '0')
{ {
d_VE_accu+=*d_Very_Early; d_VE_accu += *d_Very_Early;
d_E_accu+=*d_Early; d_E_accu += *d_Early;
d_P_accu+=*d_Prompt; d_P_accu += *d_Prompt;
d_L_accu+=*d_Late; d_L_accu += *d_Late;
d_VL_accu+=*d_Very_Late; d_VL_accu += *d_Very_Late;
}else{ }
d_VE_accu-=*d_Very_Early; else
d_E_accu-=*d_Early; {
d_P_accu-=*d_Prompt; d_VE_accu -= *d_Very_Early;
d_L_accu-=*d_Late; d_E_accu -= *d_Early;
d_VL_accu-=*d_Very_Late; d_P_accu -= *d_Prompt;
d_L_accu -= *d_Late;
d_VL_accu -= *d_Very_Late;
} }
d_current_symbol++; d_current_symbol++;
//secondary code roll-up // secondary code roll-up
d_current_symbol=d_current_symbol%Galileo_E1_C_SECONDARY_CODE_LENGTH; d_current_symbol = d_current_symbol % Galileo_E1_C_SECONDARY_CODE_LENGTH;
// PLL/DLL not enabled, we are in the middle of a coherent integration // PLL/DLL not enabled, we are in the middle of a coherent integration
// keep alignment parameters for the next input buffer // keep alignment parameters for the next input buffer
// Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation
// ################## PLL ########################################################## // ################## PLL ##########################################################
//carrier phase accumulator for (K) Doppler estimation- // carrier phase accumulator for (K) Doppler estimation-
d_acc_carrier_phase_rad -= GALILEO_TWO_PI * d_carrier_doppler_hz * static_cast<double>(d_current_prn_length_samples) / static_cast<double>(d_fs_in); d_acc_carrier_phase_rad -= GALILEO_TWO_PI * d_carrier_doppler_hz * static_cast<double>(d_current_prn_length_samples) / static_cast<double>(d_fs_in);
//remnant carrier phase to prevent overflow in the code NCO // remnant carrier phase to prevent overflow in the code NCO
d_rem_carr_phase_rad = d_rem_carr_phase_rad + GALILEO_TWO_PI * d_carrier_doppler_hz * static_cast<double>(d_current_prn_length_samples) / static_cast<double>(d_fs_in); d_rem_carr_phase_rad = d_rem_carr_phase_rad + GALILEO_TWO_PI * d_carrier_doppler_hz * static_cast<double>(d_current_prn_length_samples) / static_cast<double>(d_fs_in);
d_rem_carr_phase_rad = std::fmod(d_rem_carr_phase_rad, GALILEO_TWO_PI); d_rem_carr_phase_rad = std::fmod(d_rem_carr_phase_rad, GALILEO_TWO_PI);
@ -842,7 +860,7 @@ int galileo_e1_dll_pll_veml_tracking_cc::general_work (int noutput_items __attri
current_synchro_data.Prompt_Q = static_cast<double>((*d_Prompt_Data).imag()); current_synchro_data.Prompt_Q = static_cast<double>((*d_Prompt_Data).imag());
current_synchro_data.Tracking_sample_counter = d_sample_counter; current_synchro_data.Tracking_sample_counter = d_sample_counter;
current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; current_synchro_data.Code_phase_samples = d_rem_code_phase_samples;
//compute remnant code phase samples AFTER the Tracking timestamp // compute remnant code phase samples AFTER the Tracking timestamp
d_rem_code_phase_samples = K_blk_samples - d_current_prn_length_samples; //rounding error < 1 sample d_rem_code_phase_samples = K_blk_samples - d_current_prn_length_samples; //rounding error < 1 sample
current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_rad; current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_rad;
current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz;
@ -851,10 +869,10 @@ int galileo_e1_dll_pll_veml_tracking_cc::general_work (int noutput_items __attri
current_synchro_data.correlation_length_ms = Galileo_E1_CODE_PERIOD_MS; current_synchro_data.correlation_length_ms = Galileo_E1_CODE_PERIOD_MS;
d_extend_correlation_symbols_count++; d_extend_correlation_symbols_count++;
if (d_extend_correlation_symbols_count>=(d_extend_correlation_symbols-1)) if (d_extend_correlation_symbols_count >= (d_extend_correlation_symbols - 1))
{ {
d_extend_correlation_symbols_count=0; d_extend_correlation_symbols_count = 0;
d_state=4; d_state = 4;
} }
break; break;
} }
@ -865,43 +883,46 @@ int galileo_e1_dll_pll_veml_tracking_cc::general_work (int noutput_items __attri
// perform a correlation step // perform a correlation step
do_correlation_step(in); do_correlation_step(in);
//correct the integration using the current symbol // correct the integration using the current symbol
if (Galileo_E1_C_SECONDARY_CODE.at(d_current_symbol) == '0') if (Galileo_E1_C_SECONDARY_CODE.at(d_current_symbol) == '0')
{ {
d_VE_accu+=*d_Very_Early; d_VE_accu += *d_Very_Early;
d_E_accu+=*d_Early; d_E_accu += *d_Early;
d_P_accu+=*d_Prompt; d_P_accu += *d_Prompt;
d_L_accu+=*d_Late; d_L_accu += *d_Late;
d_VL_accu+=*d_Very_Late; d_VL_accu += *d_Very_Late;
}else{ }
d_VE_accu-=*d_Very_Early; else
d_E_accu-=*d_Early; {
d_P_accu-=*d_Prompt; d_VE_accu -= *d_Very_Early;
d_L_accu-=*d_Late; d_E_accu -= *d_Early;
d_VL_accu-=*d_Very_Late; d_P_accu -= *d_Prompt;
d_L_accu -= *d_Late;
d_VL_accu -= *d_Very_Late;
} }
d_current_symbol++; d_current_symbol++;
//secondary code roll-up // secondary code roll-up
d_current_symbol=d_current_symbol%Galileo_E1_C_SECONDARY_CODE_LENGTH; d_current_symbol = d_current_symbol % Galileo_E1_C_SECONDARY_CODE_LENGTH;
//check lock status // check lock status
if (cn0_and_tracking_lock_status()==false) if (cn0_and_tracking_lock_status() == false)
{ {
clear_tracking_vars(); clear_tracking_vars();
d_state=0; //loss-of-lock detected d_state = 0; // loss-of-lock detected
}else{ }
run_dll_pll(true);//Costas loop disabled, use four quadrant atan else
{
run_dll_pll(true); // Costas loop disabled, use four quadrant atan
// ################## PLL ########################################################## // ################## PLL ##########################################################
//carrier phase accumulator for (K) Doppler estimation- // carrier phase accumulator for (K) Doppler estimation-
d_acc_carrier_phase_rad -= GALILEO_TWO_PI * d_carrier_doppler_hz * static_cast<double>(d_current_prn_length_samples) / static_cast<double>(d_fs_in); d_acc_carrier_phase_rad -= GALILEO_TWO_PI * d_carrier_doppler_hz * static_cast<double>(d_current_prn_length_samples) / static_cast<double>(d_fs_in);
//remnant carrier phase to prevent overflow in the code NCO // remnant carrier phase to prevent overflow in the code NCO
d_rem_carr_phase_rad = d_rem_carr_phase_rad + GALILEO_TWO_PI * d_carrier_doppler_hz * static_cast<double>(d_current_prn_length_samples) / static_cast<double>(d_fs_in); d_rem_carr_phase_rad = d_rem_carr_phase_rad + GALILEO_TWO_PI * d_carrier_doppler_hz * static_cast<double>(d_current_prn_length_samples) / static_cast<double>(d_fs_in);
d_rem_carr_phase_rad = std::fmod(d_rem_carr_phase_rad, GALILEO_TWO_PI); d_rem_carr_phase_rad = std::fmod(d_rem_carr_phase_rad, GALILEO_TWO_PI);
// ################## DLL ########################################################## // ################## DLL ##########################################################
// Code phase accumulator
//Code phase accumulator
double code_error_filt_secs; double code_error_filt_secs;
code_error_filt_secs = (Galileo_E1_CODE_PERIOD * d_code_error_filt_chips) / Galileo_E1_CODE_CHIP_RATE_HZ; //[seconds] code_error_filt_secs = (Galileo_E1_CODE_PERIOD * d_code_error_filt_chips) / Galileo_E1_CODE_CHIP_RATE_HZ; //[seconds]
@ -912,49 +933,51 @@ int galileo_e1_dll_pll_veml_tracking_cc::general_work (int noutput_items __attri
double T_prn_seconds = T_chip_seconds * Galileo_E1_B_CODE_LENGTH_CHIPS; double T_prn_seconds = T_chip_seconds * Galileo_E1_B_CODE_LENGTH_CHIPS;
double T_prn_samples = T_prn_seconds * static_cast<double>(d_fs_in); double T_prn_samples = T_prn_seconds * static_cast<double>(d_fs_in);
double K_blk_samples = T_prn_samples + d_rem_code_phase_samples + code_error_filt_secs * static_cast<double>(d_fs_in); double K_blk_samples = T_prn_samples + d_rem_code_phase_samples + code_error_filt_secs * static_cast<double>(d_fs_in);
d_current_prn_length_samples = round(K_blk_samples); //round to a discrete samples d_current_prn_length_samples = round(K_blk_samples); // round to a discrete number of samples
// ########### Output the tracking results to Telemetry block ########## // ########### Output the tracking results to Telemetry block ##########
current_synchro_data.Prompt_I = static_cast<double>((*d_Prompt_Data).real()); current_synchro_data.Prompt_I = static_cast<double>((*d_Prompt_Data).real());
current_synchro_data.Prompt_Q = static_cast<double>((*d_Prompt_Data).imag()); current_synchro_data.Prompt_Q = static_cast<double>((*d_Prompt_Data).imag());
current_synchro_data.Tracking_sample_counter = d_sample_counter; current_synchro_data.Tracking_sample_counter = d_sample_counter;
current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; current_synchro_data.Code_phase_samples = d_rem_code_phase_samples;
//compute remnant code phase samples AFTER the Tracking timestamp // compute remnant code phase samples AFTER the Tracking timestamp
d_rem_code_phase_samples = K_blk_samples - d_current_prn_length_samples; //rounding error < 1 sample d_rem_code_phase_samples = K_blk_samples - d_current_prn_length_samples; //rounding error < 1 sample
current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_rad; current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_rad;
current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz;
current_synchro_data.CN0_dB_hz = d_CN0_SNV_dB_Hz; current_synchro_data.CN0_dB_hz = d_CN0_SNV_dB_Hz;
current_synchro_data.Flag_valid_symbol_output = true; current_synchro_data.Flag_valid_symbol_output = true;
current_synchro_data.correlation_length_ms = Galileo_E1_CODE_PERIOD_MS; current_synchro_data.correlation_length_ms = Galileo_E1_CODE_PERIOD_MS;
//enable write dump file this cycle (valid DLL/PLL cycle) // enable write dump file this cycle (valid DLL/PLL cycle)
log_data(); log_data();
//reset extended correlator // reset extended correlator
d_VE_accu=gr_complex(0,0); d_VE_accu = gr_complex(0,0);
d_E_accu=gr_complex(0,0); d_E_accu = gr_complex(0,0);
d_P_accu=gr_complex(0,0); d_P_accu = gr_complex(0,0);
d_L_accu=gr_complex(0,0); d_L_accu = gr_complex(0,0);
d_VL_accu=gr_complex(0,0); d_VL_accu = gr_complex(0,0);
d_state=3; //new coherent integration (correlation time extension) cycle d_state = 3; //new coherent integration (correlation time extension) cycle
} }
} }
} }
//assign the GNURadio block output data //assign the GNURadio block output data
// current_synchro_data.System = {'E'}; // current_synchro_data.System = {'E'};
// std::string str_aux = "1B"; // std::string str_aux = "1B";
// const char * str = str_aux.c_str(); // get a C style null terminated string // const char * str = str_aux.c_str(); // get a C style null terminated string
// std::memcpy(static_cast<void*>(current_synchro_data.Signal), str, 3); // std::memcpy(static_cast<void*>(current_synchro_data.Signal), str, 3);
current_synchro_data.fs = d_fs_in; current_synchro_data.fs = d_fs_in;
*out[0] = current_synchro_data; *out[0] = current_synchro_data;
consume_each(d_current_prn_length_samples); // this is required for gr_block derivates consume_each(d_current_prn_length_samples); // this is required for gr_block derivates
d_sample_counter += d_current_prn_length_samples; //count for the processed samples d_sample_counter += d_current_prn_length_samples; // count for the processed samples
if (current_synchro_data.Flag_valid_symbol_output) if (current_synchro_data.Flag_valid_symbol_output)
{ {
return 1; return 1;
}else{ }
else
{
return 0; return 0;
} }
} }
@ -1209,8 +1232,6 @@ void galileo_e1_dll_pll_veml_tracking_cc::set_channel(unsigned int channel)
} }
void galileo_e1_dll_pll_veml_tracking_cc::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) void galileo_e1_dll_pll_veml_tracking_cc::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro)
{ {
d_acquisition_gnss_synchro = p_gnss_synchro; d_acquisition_gnss_synchro = p_gnss_synchro;

View File

@ -732,7 +732,9 @@ int gps_l5i_dll_pll_tracking_cc::general_work (int noutput_items __attribute__((
if (d_enable_tracking) if (d_enable_tracking)
{ {
return 1; return 1;
}else{ }
else
{
return 0; return 0;
} }
} }