mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2026-11-24 16:17:22 +00:00
Fix tracking blocks
This commit is contained in:
6 files changed
+302
-89
No files matched your search
@@ -25,6 +25,7 @@
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <cuda_profiler_api.h>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
@@ -170,6 +171,12 @@ Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc(
|
||||
d_carrier_phase_step_rad = 0.0;
|
||||
|
||||
d_acc_carrier_phase_initialized = false;
|
||||
|
||||
d_Prompt_I_history.set_capacity(GPS_CA_PREAMBLE_LENGTH_SYMBOLS);
|
||||
d_P_bit_accu = gr_complex(0.0, 0.0);
|
||||
d_current_bit_symbol = 0;
|
||||
d_bit_synchronized = false;
|
||||
d_Flag_PLL_180_deg_phase_locked = false;
|
||||
// set_min_output_buffer((int64_t)300);
|
||||
}
|
||||
|
||||
@@ -238,6 +245,13 @@ void Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::start_tracking()
|
||||
d_pll_to_dll_assist_secs_Ti = 0.0;
|
||||
d_code_phase_samples = d_acq_code_phase_samples;
|
||||
|
||||
// navigation data bit synchronization starts over
|
||||
d_Prompt_I_history.clear();
|
||||
d_P_bit_accu = gr_complex(0.0, 0.0);
|
||||
d_current_bit_symbol = 0;
|
||||
d_bit_synchronized = false;
|
||||
d_Flag_PLL_180_deg_phase_locked = false;
|
||||
|
||||
sys = std::string(1, d_acquisition_gnss_synchro->System);
|
||||
|
||||
// DEBUG OUTPUT
|
||||
@@ -326,6 +340,29 @@ void Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::check_carrier_phase_coherent_initializat
|
||||
}
|
||||
|
||||
|
||||
bool Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::acquire_bit_sync()
|
||||
{
|
||||
// ******* preamble correlation at the 1 ms prompt rate ********
|
||||
if (d_Prompt_I_history.size() < static_cast<size_t>(GPS_CA_PREAMBLE_LENGTH_SYMBOLS))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int32_t corr_value = 0;
|
||||
for (int32_t i = 0; i < GPS_CA_PREAMBLE_LENGTH_SYMBOLS; i++)
|
||||
{
|
||||
const bool symbol_is_one = d_Prompt_I_history[i] >= 0.0F; // symbols clipping
|
||||
corr_value += (symbol_is_one == (GPS_CA_PREAMBLE_SYMBOLS_STR[i] == '1')) ? 1 : -1;
|
||||
}
|
||||
if (std::abs(corr_value) == GPS_CA_PREAMBLE_LENGTH_SYMBOLS)
|
||||
{
|
||||
// The last prompt closes a bit, so the next one opens a new bit
|
||||
d_Flag_PLL_180_deg_phase_locked = (corr_value < 0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int Gps_L1_Ca_Dll_Pll_Tracking_GPU_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)
|
||||
{
|
||||
@@ -345,6 +382,7 @@ int Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::general_work(int noutput_items __attribut
|
||||
double dll_code_error_secs_Ti = 0.0;
|
||||
double carr_phase_error_secs_Ti = 0.0;
|
||||
bool loss_of_lock = false;
|
||||
int produced = 0;
|
||||
|
||||
if (d_enable_tracking == true)
|
||||
{
|
||||
@@ -356,14 +394,10 @@ int Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::general_work(int noutput_items __attribut
|
||||
const int32_t acq_to_trk_delay_samples = d_sample_counter - d_acq_sample_stamp;
|
||||
const double acq_trk_shif_correction_samples = d_correlation_length_samples - fmod(static_cast<double>(acq_to_trk_delay_samples), static_cast<double>(d_correlation_length_samples));
|
||||
const int32_t samples_offset = round(d_acq_code_phase_samples + acq_trk_shif_correction_samples);
|
||||
current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast<uint64_t>(samples_offset);
|
||||
current_synchro_data.fs = d_fs_in;
|
||||
current_synchro_data.correlation_length_ms = 1;
|
||||
*out[0] = std::move(current_synchro_data);
|
||||
d_sample_counter += static_cast<uint64_t>(samples_offset); // count for the processed samples
|
||||
d_pull_in = false;
|
||||
consume_each(samples_offset); // shift input to perform alignment with local replica
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ################# CARRIER WIPEOFF AND CORRELATORS ##############################
|
||||
@@ -439,7 +473,7 @@ int Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::general_work(int noutput_items __attribut
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
if (d_cn0_estimation_counter < FLAGS_cn0_samples)
|
||||
#else
|
||||
if (d_cn0_estimation_counter < absl::getFlag(FLAGS_cn0_samples))
|
||||
if (d_cn0_estimation_counter < absl::GetFlag(FLAGS_cn0_samples))
|
||||
#endif
|
||||
{
|
||||
// fill buffer with prompt correlator output values
|
||||
@@ -485,16 +519,55 @@ int Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::general_work(int noutput_items __attribut
|
||||
check_carrier_phase_coherent_initialization();
|
||||
}
|
||||
|
||||
// ########### NAVIGATION DATA BIT SYNCHRONIZATION ##########
|
||||
// The telemetry decoder takes one symbol per navigation data bit
|
||||
bool bit_completed = false;
|
||||
if (!loss_of_lock)
|
||||
{
|
||||
if (d_bit_synchronized)
|
||||
{
|
||||
d_P_bit_accu += d_correlator_outs[1];
|
||||
d_current_bit_symbol++;
|
||||
if (d_current_bit_symbol == GPS_CA_TELEMETRY_SYMBOLS_PER_BIT)
|
||||
{
|
||||
d_current_bit_symbol = 0;
|
||||
bit_completed = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
d_Prompt_I_history.push_back(d_correlator_outs[1].real());
|
||||
if (acquire_bit_sync())
|
||||
{
|
||||
d_bit_synchronized = true;
|
||||
d_Prompt_I_history.clear();
|
||||
d_P_bit_accu = gr_complex(0.0, 0.0);
|
||||
d_current_bit_symbol = 0;
|
||||
LOG(INFO) << "GPS L1 C/A tracking bit synchronization locked in channel " << d_channel
|
||||
<< " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ########### Output the tracking data to navigation and PVT ##########
|
||||
current_synchro_data.Prompt_I = static_cast<double>((d_correlator_outs[1]).real());
|
||||
current_synchro_data.Prompt_Q = static_cast<double>((d_correlator_outs[1]).imag());
|
||||
current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast<uint64_t>(d_correlation_length_samples);
|
||||
current_synchro_data.Code_phase_samples = d_rem_code_phase_samples;
|
||||
current_synchro_data.Carrier_phase_rads = TWO_PI * d_acc_carrier_phase_cycles;
|
||||
current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz;
|
||||
current_synchro_data.CN0_dB_hz = d_CN0_SNV_dB_Hz;
|
||||
current_synchro_data.Flag_valid_symbol_output = !loss_of_lock;
|
||||
current_synchro_data.correlation_length_ms = 1;
|
||||
if (bit_completed || loss_of_lock)
|
||||
{
|
||||
const gr_complex prompt = bit_completed ? d_P_bit_accu : d_correlator_outs[1];
|
||||
current_synchro_data.Prompt_I = static_cast<double>(prompt.real());
|
||||
current_synchro_data.Prompt_Q = static_cast<double>(prompt.imag());
|
||||
current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast<uint64_t>(d_correlation_length_samples);
|
||||
current_synchro_data.Code_phase_samples = d_rem_code_phase_samples;
|
||||
current_synchro_data.Carrier_phase_rads = TWO_PI * d_acc_carrier_phase_cycles;
|
||||
current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz;
|
||||
current_synchro_data.CN0_dB_hz = d_CN0_SNV_dB_Hz;
|
||||
current_synchro_data.Flag_valid_symbol_output = !loss_of_lock;
|
||||
current_synchro_data.Flag_PLL_180_deg_phase_locked = d_Flag_PLL_180_deg_phase_locked;
|
||||
current_synchro_data.correlation_length_ms = 1;
|
||||
current_synchro_data.fs = d_fs_in;
|
||||
*out[0] = std::move(current_synchro_data);
|
||||
d_P_bit_accu = gr_complex(0.0, 0.0);
|
||||
produced = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -502,16 +575,8 @@ int Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::general_work(int noutput_items __attribut
|
||||
{
|
||||
d_correlator_outs[n] = gr_complex(0, 0);
|
||||
}
|
||||
|
||||
current_synchro_data.System = {'G'};
|
||||
current_synchro_data.correlation_length_ms = 1;
|
||||
current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast<uint64_t>(d_correlation_length_samples);
|
||||
}
|
||||
|
||||
// assign the GNU Radio block output data
|
||||
current_synchro_data.fs = d_fs_in;
|
||||
*out[0] = std::move(current_synchro_data);
|
||||
|
||||
if (d_dump)
|
||||
{
|
||||
// MULTIPLEXED FILE RECORDING - Record results to file
|
||||
@@ -581,12 +646,5 @@ int Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::general_work(int noutput_items __attribut
|
||||
consume_each(d_correlation_length_samples); // this is necessary in gr::block derivates
|
||||
d_sample_counter += d_correlation_length_samples; // count for the processed samples
|
||||
|
||||
if (d_enable_tracking || loss_of_lock)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return produced; // one item per navigation data bit, plus the loss of lock indication
|
||||
}
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "gnss_synchro.h"
|
||||
#include "tracking_2nd_DLL_filter.h"
|
||||
#include "tracking_FLL_PLL_filter.h"
|
||||
#include <boost/circular_buffer.hpp>
|
||||
#include <gnuradio/block.h>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
@@ -93,6 +94,7 @@ private:
|
||||
void update_local_code();
|
||||
void update_local_carrier();
|
||||
void check_carrier_phase_coherent_initialization();
|
||||
bool acquire_bit_sync();
|
||||
|
||||
// PLL and DLL filter library
|
||||
Tracking_2nd_DLL_filter d_code_loop_filter;
|
||||
@@ -160,6 +162,13 @@ private:
|
||||
int32_t d_carrier_lock_fail_counter;
|
||||
int32_t d_cn0_estimation_counter;
|
||||
|
||||
// navigation data bit synchronization (the telemetry decoder takes 20 ms bits)
|
||||
boost::circular_buffer<float> d_Prompt_I_history;
|
||||
gr_complex d_P_bit_accu;
|
||||
int32_t d_current_bit_symbol;
|
||||
bool d_bit_synchronized;
|
||||
bool d_Flag_PLL_180_deg_phase_locked;
|
||||
|
||||
// control vars
|
||||
bool d_acc_carrier_phase_initialized;
|
||||
bool d_enable_tracking;
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
@@ -136,6 +137,11 @@ Gps_L1_Ca_Gaussian_Tracking_cc::Gps_L1_Ca_Gaussian_Tracking_cc(
|
||||
d_carrier_lock_threshold(absl::GetFlag(FLAGS_carrier_lock_th)),
|
||||
#endif
|
||||
d_carrier_lock_fail_counter(0),
|
||||
d_Prompt_I_history(GPS_CA_PREAMBLE_LENGTH_SYMBOLS),
|
||||
d_P_bit_accu(0.0, 0.0),
|
||||
d_current_bit_symbol(0),
|
||||
d_bit_synchronized(false),
|
||||
d_Flag_PLL_180_deg_phase_locked(false),
|
||||
d_enable_tracking(false),
|
||||
d_pull_in(false),
|
||||
d_dump_filename(dump_filename)
|
||||
@@ -324,6 +330,13 @@ void Gps_L1_Ca_Gaussian_Tracking_cc::start_tracking()
|
||||
|
||||
d_code_phase_samples = d_acq_code_phase_samples;
|
||||
|
||||
// navigation data bit synchronization starts over
|
||||
d_Prompt_I_history.clear();
|
||||
d_P_bit_accu = gr_complex(0.0, 0.0);
|
||||
d_current_bit_symbol = 0;
|
||||
d_bit_synchronized = false;
|
||||
d_Flag_PLL_180_deg_phase_locked = false;
|
||||
|
||||
sys = std::string(1, d_acquisition_gnss_synchro->System);
|
||||
|
||||
// enable tracking
|
||||
@@ -512,6 +525,29 @@ int32_t Gps_L1_Ca_Gaussian_Tracking_cc::save_matfile()
|
||||
}
|
||||
|
||||
|
||||
bool Gps_L1_Ca_Gaussian_Tracking_cc::acquire_bit_sync()
|
||||
{
|
||||
// ******* preamble correlation at the 1 ms prompt rate ********
|
||||
if (d_Prompt_I_history.size() < static_cast<size_t>(GPS_CA_PREAMBLE_LENGTH_SYMBOLS))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int32_t corr_value = 0;
|
||||
for (int32_t i = 0; i < GPS_CA_PREAMBLE_LENGTH_SYMBOLS; i++)
|
||||
{
|
||||
const bool symbol_is_one = d_Prompt_I_history[i] >= 0.0F; // symbols clipping
|
||||
corr_value += (symbol_is_one == (GPS_CA_PREAMBLE_SYMBOLS_STR[i] == '1')) ? 1 : -1;
|
||||
}
|
||||
if (std::abs(corr_value) == GPS_CA_PREAMBLE_LENGTH_SYMBOLS)
|
||||
{
|
||||
// The last prompt closes a bit, so the next one opens a new bit
|
||||
d_Flag_PLL_180_deg_phase_locked = (corr_value < 0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void Gps_L1_Ca_Gaussian_Tracking_cc::set_channel(uint32_t channel)
|
||||
{
|
||||
gr::thread::scoped_lock l(d_setlock);
|
||||
@@ -567,6 +603,7 @@ int Gps_L1_Ca_Gaussian_Tracking_cc::process_input(int noutput_items __attribute_
|
||||
code_error_chips = 0.0;
|
||||
code_error_filt_chips = 0.0;
|
||||
bool loss_of_lock = false;
|
||||
int produced = 0;
|
||||
|
||||
// Block input data and block output stream pointers
|
||||
const auto *in = reinterpret_cast<const gr_complex *>(input_items[0]);
|
||||
@@ -604,12 +641,6 @@ int Gps_L1_Ca_Gaussian_Tracking_cc::process_input(int noutput_items __attribute_
|
||||
d_sample_counter += samples_offset; // count for the processed samples
|
||||
d_pull_in = false;
|
||||
|
||||
current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_rad;
|
||||
current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz;
|
||||
current_synchro_data.fs = d_fs_in;
|
||||
current_synchro_data.correlation_length_ms = 1;
|
||||
d_det.record_output(this->nitems_written(0), d_sample_counter);
|
||||
*out[0] = std::move(current_synchro_data);
|
||||
// Kalman filter initialization reset
|
||||
kf_P_x = kf_P_x_ini;
|
||||
// Update Kalman states based on acquisition information
|
||||
@@ -625,7 +656,7 @@ int Gps_L1_Ca_Gaussian_Tracking_cc::process_input(int noutput_items __attribute_
|
||||
bayes_estimator.init(arma::zeros(1, 1), bayes_kappa, bayes_nu, (kf_H * kf_P_x_ini * kf_H.t() + kf_R) * (bayes_nu + 2));
|
||||
|
||||
consume_each(samples_offset); // shift input to perform alignment with local replica
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ################# CARRIER WIPEOFF AND CORRELATORS ##############################
|
||||
@@ -785,16 +816,56 @@ int Gps_L1_Ca_Gaussian_Tracking_cc::process_input(int noutput_items __attribute_
|
||||
loss_of_lock = true;
|
||||
}
|
||||
}
|
||||
// ########### NAVIGATION DATA BIT SYNCHRONIZATION ##########
|
||||
// The telemetry decoder takes one symbol per navigation data bit
|
||||
bool bit_completed = false;
|
||||
if (!loss_of_lock)
|
||||
{
|
||||
if (d_bit_synchronized)
|
||||
{
|
||||
d_P_bit_accu += d_correlator_outs[1];
|
||||
d_current_bit_symbol++;
|
||||
if (d_current_bit_symbol == GPS_CA_TELEMETRY_SYMBOLS_PER_BIT)
|
||||
{
|
||||
d_current_bit_symbol = 0;
|
||||
bit_completed = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
d_Prompt_I_history.push_back(d_correlator_outs[1].real());
|
||||
if (acquire_bit_sync())
|
||||
{
|
||||
d_bit_synchronized = true;
|
||||
d_Prompt_I_history.clear();
|
||||
d_P_bit_accu = gr_complex(0.0, 0.0);
|
||||
d_current_bit_symbol = 0;
|
||||
LOG(INFO) << "GPS L1 C/A tracking bit synchronization locked in channel " << d_channel
|
||||
<< " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ########### Output the tracking data to navigation and PVT ##########
|
||||
current_synchro_data.Prompt_I = static_cast<double>((d_correlator_outs[1]).real());
|
||||
current_synchro_data.Prompt_Q = static_cast<double>((d_correlator_outs[1]).imag());
|
||||
current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast<uint64_t>(d_current_prn_length_samples);
|
||||
current_synchro_data.Code_phase_samples = d_rem_code_phase_samples;
|
||||
current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_rad;
|
||||
current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz;
|
||||
current_synchro_data.CN0_dB_hz = d_CN0_SNV_dB_Hz;
|
||||
current_synchro_data.Flag_valid_symbol_output = !loss_of_lock;
|
||||
current_synchro_data.correlation_length_ms = 1;
|
||||
if (bit_completed || loss_of_lock)
|
||||
{
|
||||
const gr_complex prompt = bit_completed ? d_P_bit_accu : d_correlator_outs[1];
|
||||
current_synchro_data.Prompt_I = static_cast<double>(prompt.real());
|
||||
current_synchro_data.Prompt_Q = static_cast<double>(prompt.imag());
|
||||
current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast<uint64_t>(d_current_prn_length_samples);
|
||||
current_synchro_data.Code_phase_samples = d_rem_code_phase_samples;
|
||||
current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_rad;
|
||||
current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz;
|
||||
current_synchro_data.CN0_dB_hz = d_CN0_SNV_dB_Hz;
|
||||
current_synchro_data.Flag_valid_symbol_output = !loss_of_lock;
|
||||
current_synchro_data.Flag_PLL_180_deg_phase_locked = d_Flag_PLL_180_deg_phase_locked;
|
||||
current_synchro_data.correlation_length_ms = 1;
|
||||
current_synchro_data.fs = d_fs_in;
|
||||
d_det.record_output(this->nitems_written(0), current_synchro_data.Tracking_sample_counter);
|
||||
*out[0] = std::move(current_synchro_data);
|
||||
d_P_bit_accu = gr_complex(0.0, 0.0);
|
||||
produced = 1;
|
||||
}
|
||||
|
||||
kf_iter++;
|
||||
}
|
||||
@@ -804,17 +875,8 @@ int Gps_L1_Ca_Gaussian_Tracking_cc::process_input(int noutput_items __attribute_
|
||||
{
|
||||
d_correlator_outs[n] = gr_complex(0, 0);
|
||||
}
|
||||
|
||||
current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast<uint64_t>(d_current_prn_length_samples);
|
||||
current_synchro_data.System = {'G'};
|
||||
current_synchro_data.correlation_length_ms = 1;
|
||||
}
|
||||
|
||||
// assign the GNU Radio block output data
|
||||
current_synchro_data.fs = d_fs_in;
|
||||
d_det.record_output(this->nitems_written(0), current_synchro_data.Tracking_sample_counter);
|
||||
*out[0] = std::move(current_synchro_data);
|
||||
|
||||
if (d_dump)
|
||||
{
|
||||
// MULTIPLEXED FILE RECORDING - Record results to file
|
||||
@@ -889,5 +951,5 @@ int Gps_L1_Ca_Gaussian_Tracking_cc::process_input(int noutput_items __attribute_
|
||||
|
||||
consume_each(d_current_prn_length_samples); // this is necessary in gr::block derivates
|
||||
d_sample_counter += d_current_prn_length_samples; // count for the processed samples
|
||||
return 1; // output tracking result ALWAYS even in the case of d_enable_tracking==false
|
||||
return produced; // one item per navigation data bit, plus the loss of lock indication
|
||||
}
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "tracking_2nd_DLL_filter.h"
|
||||
#include "tracking_2nd_PLL_filter.h"
|
||||
#include <armadillo>
|
||||
#include <boost/circular_buffer.hpp>
|
||||
#include <gnuradio/block.h>
|
||||
#include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
|
||||
#include <fstream>
|
||||
@@ -117,6 +118,7 @@ private:
|
||||
int32_t bce_kappa);
|
||||
|
||||
int32_t save_matfile();
|
||||
bool acquire_bit_sync();
|
||||
|
||||
// tracking configuration vars
|
||||
uint32_t d_order;
|
||||
@@ -207,6 +209,13 @@ private:
|
||||
double d_carrier_lock_threshold;
|
||||
int32_t d_carrier_lock_fail_counter;
|
||||
|
||||
// navigation data bit synchronization (the telemetry decoder takes 20 ms bits)
|
||||
boost::circular_buffer<float> d_Prompt_I_history;
|
||||
gr_complex d_P_bit_accu;
|
||||
int32_t d_current_bit_symbol;
|
||||
bool d_bit_synchronized;
|
||||
bool d_Flag_PLL_180_deg_phase_locked;
|
||||
|
||||
// control vars
|
||||
bool d_enable_tracking;
|
||||
bool d_pull_in;
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
@@ -113,6 +114,11 @@ Gps_L1_Ca_Tcp_Connector_Tracking_cc::Gps_L1_Ca_Tcp_Connector_Tracking_cc(
|
||||
d_carrier_lock_threshold(static_cast<float>(absl::GetFlag(FLAGS_carrier_lock_th))),
|
||||
#endif
|
||||
d_control_id(0),
|
||||
d_Prompt_I_history(GPS_CA_PREAMBLE_LENGTH_SYMBOLS),
|
||||
d_P_bit_accu(0.0, 0.0),
|
||||
d_current_bit_symbol(0),
|
||||
d_bit_synchronized(false),
|
||||
d_Flag_PLL_180_deg_phase_locked(false),
|
||||
d_enable_tracking(false),
|
||||
d_pull_in(false),
|
||||
d_dump(dump)
|
||||
@@ -215,6 +221,13 @@ void Gps_L1_Ca_Tcp_Connector_Tracking_cc::start_tracking()
|
||||
|
||||
d_code_phase_samples = d_acq_code_phase_samples;
|
||||
|
||||
// navigation data bit synchronization starts over
|
||||
d_Prompt_I_history.clear();
|
||||
d_P_bit_accu = gr_complex(0.0, 0.0);
|
||||
d_current_bit_symbol = 0;
|
||||
d_bit_synchronized = false;
|
||||
d_Flag_PLL_180_deg_phase_locked = false;
|
||||
|
||||
sys = std::string(1, d_acquisition_gnss_synchro->System);
|
||||
|
||||
// DEBUG OUTPUT
|
||||
@@ -256,6 +269,29 @@ Gps_L1_Ca_Tcp_Connector_Tracking_cc::~Gps_L1_Ca_Tcp_Connector_Tracking_cc()
|
||||
}
|
||||
|
||||
|
||||
bool Gps_L1_Ca_Tcp_Connector_Tracking_cc::acquire_bit_sync()
|
||||
{
|
||||
// ******* preamble correlation at the 1 ms prompt rate ********
|
||||
if (d_Prompt_I_history.size() < static_cast<size_t>(GPS_CA_PREAMBLE_LENGTH_SYMBOLS))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int32_t corr_value = 0;
|
||||
for (int32_t i = 0; i < GPS_CA_PREAMBLE_LENGTH_SYMBOLS; i++)
|
||||
{
|
||||
const bool symbol_is_one = d_Prompt_I_history[i] >= 0.0F; // symbols clipping
|
||||
corr_value += (symbol_is_one == (GPS_CA_PREAMBLE_SYMBOLS_STR[i] == '1')) ? 1 : -1;
|
||||
}
|
||||
if (std::abs(corr_value) == GPS_CA_PREAMBLE_LENGTH_SYMBOLS)
|
||||
{
|
||||
// The last prompt closes a bit, so the next one opens a new bit
|
||||
d_Flag_PLL_180_deg_phase_locked = (corr_value < 0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void Gps_L1_Ca_Tcp_Connector_Tracking_cc::set_channel(uint32_t channel)
|
||||
{
|
||||
d_channel = channel;
|
||||
@@ -303,6 +339,7 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attrib
|
||||
float code_error = 0.0;
|
||||
float code_nco = 0.0;
|
||||
bool loss_of_lock = false;
|
||||
int produced = 0;
|
||||
|
||||
Tcp_Packet_Data tcp_data;
|
||||
// GNSS_SYNCHRO OBJECT to interchange data between tracking->telemetry_decoder
|
||||
@@ -329,14 +366,11 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attrib
|
||||
acq_to_trk_delay_samples = d_sample_counter - d_acq_sample_stamp;
|
||||
acq_trk_shif_correction_samples = d_next_prn_length_samples - std::fmod(static_cast<float>(acq_to_trk_delay_samples), static_cast<float>(d_next_prn_length_samples));
|
||||
samples_offset = std::round(d_acq_code_phase_samples + acq_trk_shif_correction_samples);
|
||||
current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast<uint64_t>(samples_offset);
|
||||
current_synchro_data.fs = d_fs_in;
|
||||
*out[0] = std::move(current_synchro_data);
|
||||
d_sample_counter_seconds = d_sample_counter_seconds + (static_cast<double>(samples_offset) / static_cast<double>(d_fs_in));
|
||||
d_sample_counter = d_sample_counter + static_cast<uint64_t>(samples_offset); // count for the processed samples
|
||||
d_pull_in = false;
|
||||
consume_each(samples_offset); // shift input to perform alignment with local replica
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Update the prn length based on code freq (variable) and
|
||||
@@ -357,6 +391,10 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attrib
|
||||
static_cast<float>(d_code_phase_step_chips),
|
||||
d_current_prn_length_samples);
|
||||
|
||||
// carrier phase at the end of this block, so that the next one starts where this one ended
|
||||
d_rem_carr_phase_rad = static_cast<float>(std::fmod(static_cast<double>(d_rem_carr_phase_rad) + carr_phase_step_rad * static_cast<double>(d_current_prn_length_samples), TWO_PI));
|
||||
d_acc_carrier_phase_rad -= carr_phase_step_rad * static_cast<double>(d_current_prn_length_samples);
|
||||
|
||||
// Variable used for control
|
||||
d_control_id++;
|
||||
|
||||
@@ -464,41 +502,73 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attrib
|
||||
}
|
||||
}
|
||||
|
||||
// ########### Output the tracking data to navigation and PVT ##########
|
||||
|
||||
current_synchro_data.Prompt_I = static_cast<double>((*d_Prompt).real());
|
||||
current_synchro_data.Prompt_Q = static_cast<double>((*d_Prompt).imag());
|
||||
// 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
|
||||
current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast<uint64_t>(d_current_prn_length_samples);
|
||||
current_synchro_data.Code_phase_samples = d_rem_code_phase_samples;
|
||||
current_synchro_data.Carrier_phase_rads = static_cast<double>(d_acc_carrier_phase_rad);
|
||||
current_synchro_data.Carrier_Doppler_hz = static_cast<double>(d_carrier_doppler_hz);
|
||||
current_synchro_data.CN0_dB_hz = static_cast<double>(d_CN0_SNV_dB_Hz);
|
||||
current_synchro_data.Flag_valid_symbol_output = !loss_of_lock;
|
||||
current_synchro_data.correlation_length_ms = 1;
|
||||
|
||||
// ########### NAVIGATION DATA BIT SYNCHRONIZATION ##########
|
||||
// The telemetry decoder takes one symbol per navigation data bit
|
||||
bool bit_completed = false;
|
||||
if (!loss_of_lock)
|
||||
{
|
||||
if (d_bit_synchronized)
|
||||
{
|
||||
d_P_bit_accu += *d_Prompt;
|
||||
d_current_bit_symbol++;
|
||||
if (d_current_bit_symbol == GPS_CA_TELEMETRY_SYMBOLS_PER_BIT)
|
||||
{
|
||||
d_current_bit_symbol = 0;
|
||||
bit_completed = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
d_Prompt_I_history.push_back((*d_Prompt).real());
|
||||
if (acquire_bit_sync())
|
||||
{
|
||||
d_bit_synchronized = true;
|
||||
d_Prompt_I_history.clear();
|
||||
d_P_bit_accu = gr_complex(0.0, 0.0);
|
||||
d_current_bit_symbol = 0;
|
||||
LOG(INFO) << "GPS L1 C/A tracking bit synchronization locked in channel " << d_channel
|
||||
<< " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ########### Output the tracking data to navigation and PVT ##########
|
||||
if (bit_completed || loss_of_lock)
|
||||
{
|
||||
const gr_complex prompt = bit_completed ? d_P_bit_accu : *d_Prompt;
|
||||
current_synchro_data.Prompt_I = static_cast<double>(prompt.real());
|
||||
current_synchro_data.Prompt_Q = static_cast<double>(prompt.imag());
|
||||
current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast<uint64_t>(d_current_prn_length_samples);
|
||||
current_synchro_data.Code_phase_samples = d_rem_code_phase_samples;
|
||||
current_synchro_data.Carrier_phase_rads = static_cast<double>(d_acc_carrier_phase_rad);
|
||||
current_synchro_data.Carrier_Doppler_hz = static_cast<double>(d_carrier_doppler_hz);
|
||||
current_synchro_data.CN0_dB_hz = static_cast<double>(d_CN0_SNV_dB_Hz);
|
||||
current_synchro_data.Flag_valid_symbol_output = !loss_of_lock;
|
||||
current_synchro_data.Flag_PLL_180_deg_phase_locked = d_Flag_PLL_180_deg_phase_locked;
|
||||
current_synchro_data.correlation_length_ms = 1;
|
||||
current_synchro_data.System = {'G'};
|
||||
current_synchro_data.Signal[0] = '1';
|
||||
current_synchro_data.Signal[1] = 'C';
|
||||
current_synchro_data.Signal[2] = '\0';
|
||||
current_synchro_data.fs = d_fs_in;
|
||||
*out[0] = std::move(current_synchro_data);
|
||||
d_P_bit_accu = gr_complex(0.0, 0.0);
|
||||
produced = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*d_Early = gr_complex(0.0, 0.0);
|
||||
*d_Prompt = gr_complex(0.0, 0.0);
|
||||
*d_Late = gr_complex(0.0, 0.0);
|
||||
// GNSS_SYNCHRO OBJECT to interchange data between tracking->telemetry_decoder
|
||||
current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast<uint64_t>(d_correlation_length_samples);
|
||||
// When tracking is disabled an array of 1's is sent to maintain the TCP connection
|
||||
boost::array<float, NUM_TX_VARIABLES_GPS_L1_CA> tx_variables_array = {{1, 1, 1, 1, 1, 1, 1, 1, 0}};
|
||||
d_tcp_com.send_receive_tcp_packet_gps_l1_ca(tx_variables_array, &tcp_data);
|
||||
}
|
||||
|
||||
// assign the GNU Radio block output data
|
||||
current_synchro_data.System = {'G'};
|
||||
current_synchro_data.Signal[0] = '1';
|
||||
current_synchro_data.Signal[1] = 'C';
|
||||
current_synchro_data.Signal[2] = '\0';
|
||||
|
||||
current_synchro_data.fs = d_fs_in;
|
||||
*out[0] = std::move(current_synchro_data);
|
||||
|
||||
if (d_dump)
|
||||
{
|
||||
// MULTIPLEXED FILE RECORDING - Record results to file
|
||||
@@ -571,10 +641,5 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attrib
|
||||
d_sample_counter_seconds = d_sample_counter_seconds + (static_cast<double>(d_current_prn_length_samples) / static_cast<double>(d_fs_in));
|
||||
d_sample_counter += d_current_prn_length_samples; // count for the processed samples
|
||||
|
||||
if (d_enable_tracking || loss_of_lock)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return produced; // one item per navigation data bit, plus the loss of lock indication
|
||||
}
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "gnss_block_interface.h"
|
||||
#include "gnss_synchro.h"
|
||||
#include "tcp_communication.h"
|
||||
#include <boost/circular_buffer.hpp>
|
||||
#include <gnuradio/block.h>
|
||||
#include <volk_gnsssdr/volk_gnsssdr_alloc.h> // for volk_gnsssdr::vector
|
||||
#include <fstream>
|
||||
@@ -90,6 +91,8 @@ private:
|
||||
float early_late_space_chips,
|
||||
size_t port_ch0);
|
||||
|
||||
bool acquire_bit_sync();
|
||||
|
||||
volk_gnsssdr::vector<gr_complex> d_ca_code;
|
||||
// correlator
|
||||
volk_gnsssdr::vector<float> d_local_code_shift_chips;
|
||||
@@ -147,6 +150,13 @@ private:
|
||||
float d_carrier_lock_threshold;
|
||||
float d_control_id;
|
||||
|
||||
// navigation data bit synchronization (the telemetry decoder takes 20 ms bits)
|
||||
boost::circular_buffer<float> d_Prompt_I_history;
|
||||
gr_complex d_P_bit_accu;
|
||||
int32_t d_current_bit_symbol;
|
||||
bool d_bit_synchronized;
|
||||
bool d_Flag_PLL_180_deg_phase_locked;
|
||||
|
||||
bool d_enable_tracking;
|
||||
bool d_pull_in;
|
||||
bool d_dump;
|
||||
|
||||
Reference in new issue
Block a user