mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-12 19:20:32 +00:00
Refactoring of GPS L1 CA telemetry decoder. PVT is not yet fully tested
This commit is contained in:
parent
840bb1b9a3
commit
083350bd61
@ -240,14 +240,20 @@ Tracking_1C.dump=true
|
||||
;#dump_filename: Log path and filename. Notice that the tracking channel will add "x.dat" where x is the channel number.
|
||||
Tracking_1C.dump_filename=../data/epl_tracking_ch_
|
||||
|
||||
;# Extended correlation after telemetry bit synchronization
|
||||
;# Valid values are: [1,2,4,5,10,20] (integer divisors of the GPS L1 CA bit period (20 ms) )
|
||||
;# Longer integration period require more stable front-end LO
|
||||
|
||||
Tracking_1C.extend_correlation_ms=5
|
||||
|
||||
;#pll_bw_hz: PLL loop filter bandwidth [Hz]
|
||||
Tracking_1C.pll_bw_hz=20;
|
||||
Tracking_1C.pll_bw_narrow_hz=5;
|
||||
Tracking_1C.pll_bw_narrow_hz=10;
|
||||
|
||||
;#dll_bw_hz: DLL loop filter bandwidth [Hz]
|
||||
Tracking_1C.dll_bw_hz=4.0;
|
||||
Tracking_1C.dll_bw_hz=3.0;
|
||||
|
||||
Tracking_1C.dll_bw_narrow_hz=1.5;
|
||||
Tracking_1C.dll_bw_narrow_hz=2.0;
|
||||
|
||||
;#fll_bw_hz: FLL loop filter bandwidth [Hz]
|
||||
Tracking_1C.fll_bw_hz=2.0;
|
||||
|
@ -195,11 +195,11 @@ Acquisition_1C.sampled_ms=1
|
||||
Acquisition_1C.implementation=GPS_L1_CA_PCPS_Acquisition
|
||||
Acquisition_1C.use_CFAR_algorithm=false;
|
||||
;#threshold: Acquisition threshold
|
||||
Acquisition_1C.threshold=40
|
||||
Acquisition_1C.threshold=10
|
||||
;#pfa: Acquisition false alarm probability. This option overrides the threshold option. Only use with implementations: [GPS_L1_CA_PCPS_Acquisition] or [Galileo_E1_PCPS_Ambiguous_Acquisition]
|
||||
;Acquisition_1C.pfa=0.01
|
||||
;#doppler_max: Maximum expected Doppler shift [Hz]
|
||||
Acquisition_1C.doppler_max=10000
|
||||
Acquisition_1C.doppler_max=5000
|
||||
;#doppler_max: Doppler step in the grid search [Hz]
|
||||
Acquisition_1C.doppler_step=250
|
||||
|
||||
@ -243,11 +243,20 @@ Tracking_1C.dump=true
|
||||
;#dump_filename: Log path and filename. Notice that the tracking channel will add "x.dat" where x is the channel number.
|
||||
Tracking_1C.dump_filename=../data/epl_tracking_ch_
|
||||
|
||||
;# Extended correlation after telemetry bit synchronization
|
||||
;# Valid values are: [1,2,4,5,10,20] (integer divisors of the GPS L1 CA bit period (20 ms) )
|
||||
;# Longer integration period require more stable front-end LO
|
||||
|
||||
Tracking_1C.extend_correlation_ms=1
|
||||
|
||||
;#pll_bw_hz: PLL loop filter bandwidth [Hz]
|
||||
Tracking_1C.pll_bw_hz=40;
|
||||
Tracking_1C.pll_bw_narrow_hz=20;
|
||||
|
||||
;#dll_bw_hz: DLL loop filter bandwidth [Hz]
|
||||
Tracking_1C.dll_bw_hz=2.5;
|
||||
Tracking_1C.dll_bw_hz=2.0;
|
||||
|
||||
Tracking_1C.dll_bw_narrow_hz=2.0;
|
||||
|
||||
;#fll_bw_hz: FLL loop filter bandwidth [Hz]
|
||||
Tracking_1C.fll_bw_hz=2.0;
|
||||
|
@ -36,6 +36,7 @@
|
||||
|
||||
#include "gps_l1_ca_telemetry_decoder_cc.h"
|
||||
#include <iostream>
|
||||
#include <bitset>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include <pmt/pmt.h>
|
||||
@ -58,20 +59,6 @@ gps_l1_ca_make_telemetry_decoder_cc(Gnss_Satellite satellite, boost::shared_ptr<
|
||||
}
|
||||
|
||||
|
||||
|
||||
//void gps_l1_ca_telemetry_decoder_cc::forecast (int noutput_items, gr_vector_int &ninput_items_required)
|
||||
//{
|
||||
// if (noutput_items != 0)
|
||||
// {
|
||||
// for (unsigned i = 0; i < 3; i++)
|
||||
// {
|
||||
// ninput_items_required[i] = d_samples_per_bit * 8; //set the required sample history
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc(
|
||||
Gnss_Satellite satellite,
|
||||
boost::shared_ptr<gr::msg_queue> queue,
|
||||
@ -94,14 +81,14 @@ gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc(
|
||||
|
||||
memcpy((unsigned short int*)this->d_preambles_bits, (unsigned short int*)preambles_bits, GPS_CA_PREAMBLE_LENGTH_BITS*sizeof(unsigned short int));
|
||||
|
||||
// preamble bits to sampled symbols
|
||||
// preamble bits to sampled symbols (reversed)
|
||||
d_preambles_symbols = (signed int*)malloc(sizeof(signed int) * GPS_CA_PREAMBLE_LENGTH_BITS * d_samples_per_bit);
|
||||
int n = 0;
|
||||
for (int i = 0; i < GPS_CA_PREAMBLE_LENGTH_BITS; i++)
|
||||
{
|
||||
for (unsigned int j = 0; j < d_samples_per_bit; j++)
|
||||
{
|
||||
if (d_preambles_bits[i] == 1)
|
||||
if (d_preambles_bits[GPS_CA_PREAMBLE_LENGTH_BITS-i-1] == 1)
|
||||
{
|
||||
d_preambles_symbols[n] = 1;
|
||||
}
|
||||
@ -181,39 +168,44 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_i
|
||||
// ########### Output the tracking data to navigation and PVT ##########
|
||||
const Gnss_Synchro **in = (const Gnss_Synchro **) &input_items[0]; //Get the input samples pointer
|
||||
|
||||
// keep the last valid symbols
|
||||
// record last symbols (clipped to +1,-1) and its correlation length to perform preamble correlation
|
||||
if (in[0]->Flag_valid_symbol_output==true)
|
||||
{
|
||||
d_symbol_history.push_back(in[0]->Prompt_I);
|
||||
d_symbol_history.push_front(in[0]->Prompt_I);
|
||||
d_correlation_length_ms_history.push_front(in[0]->correlation_length_ms);
|
||||
if (static_cast<int>(d_symbol_history.size())>GPS_CA_PREAMBLE_LENGTH_SYMBOLS)
|
||||
{
|
||||
d_symbol_history.pop_front();
|
||||
d_symbol_history.pop_back();
|
||||
d_correlation_length_ms_history.pop_back();
|
||||
}
|
||||
|
||||
if (d_symbol_history.size()==GPS_CA_PREAMBLE_LENGTH_SYMBOLS)
|
||||
{
|
||||
//******* preamble correlation ********
|
||||
int current_symbol_index=0;
|
||||
for (int i = 0; i < GPS_CA_PREAMBLE_LENGTH_SYMBOLS/in[0]->correlation_length_ms; i++)
|
||||
{
|
||||
current_symbol_index=i*in[0]->correlation_length_ms;//+static_cast<int>(floor(in[0]->correlation_length_ms/2));
|
||||
if (d_symbol_history.at(i) < 0) // symbols clipping
|
||||
{
|
||||
//symbol weight expansion using the current tracking correlation length
|
||||
corr_value -= d_preambles_symbols[current_symbol_index]*in[0]->correlation_length_ms;
|
||||
}
|
||||
else
|
||||
{
|
||||
//symbol weight expansion using the current tracking correlation length
|
||||
corr_value += d_preambles_symbols[current_symbol_index]*in[0]->correlation_length_ms;
|
||||
}
|
||||
}
|
||||
|
||||
//******* preamble correlation (in reverse order due to the variable correlator length)
|
||||
int input_symbol_index=0;
|
||||
int preamble_index=0;
|
||||
do{
|
||||
if (d_symbol_history.at(input_symbol_index) < 0) // symbols clipping
|
||||
{
|
||||
//symbol weight expansion using its tracking correlation length
|
||||
corr_value -= d_preambles_symbols[preamble_index]*d_correlation_length_ms_history.at(input_symbol_index);
|
||||
}
|
||||
else
|
||||
{
|
||||
//symbol weight expansion using its tracking correlation length
|
||||
corr_value += d_preambles_symbols[preamble_index]*d_correlation_length_ms_history.at(input_symbol_index);
|
||||
}
|
||||
preamble_index+=d_correlation_length_ms_history.at(input_symbol_index);
|
||||
input_symbol_index++;
|
||||
}while(preamble_index<GPS_CA_PREAMBLE_LENGTH_SYMBOLS);
|
||||
|
||||
}
|
||||
if (abs(corr_value)>120)
|
||||
{
|
||||
std::cout<<abs(corr_value)<<std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
consume_each(1); //always consume one by one tracking output
|
||||
|
||||
d_flag_preamble = false;
|
||||
|
||||
//******* frame sync ******************
|
||||
@ -223,45 +215,46 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_i
|
||||
{
|
||||
d_GPS_FSM.Event_gps_word_preamble();
|
||||
d_preamble_index = d_sample_counter;//record the preamble sample stamp
|
||||
std::cout << "Preamble detection for SAT " << this->d_satellite;
|
||||
DLOG(INFO) << "Preamble detection for SAT " << this->d_satellite <<" d_sample_counter="<<d_sample_counter<<std::endl;
|
||||
d_symbol_accumulator = 0; //sync the symbol to bits integrator
|
||||
d_symbol_accumulator_counter = 0;
|
||||
d_symbol_accumulator_counter = GPS_CA_TELEMETRY_SYMBOLS_PER_BIT-in[0]->correlation_length_ms;
|
||||
d_frame_bit_index = 7;
|
||||
d_stat = 1; // enter into frame pre-detection status
|
||||
}
|
||||
else if (d_stat == 1) //check 6 seconds of preamble separation
|
||||
{
|
||||
preamble_diff = d_sample_counter - d_preamble_index;
|
||||
if (abs(preamble_diff - 6000) < 1)
|
||||
if (abs(preamble_diff - GPS_SUBFRAME_MS) < 1)
|
||||
{
|
||||
std::cout <<"preamble! corr lenght="<<in[0]->correlation_length_ms<<std::endl;
|
||||
//DLOG(INFO)<<"preamble! corr lenght="<<in[0]->correlation_length_ms<<" d_sample_counter="<<d_sample_counter<<std::endl;
|
||||
d_GPS_FSM.Event_gps_word_preamble();
|
||||
d_flag_preamble = true;
|
||||
d_preamble_index = d_sample_counter; //record the preamble sample stamp (t_P)
|
||||
d_preamble_time_seconds = in[0][0].Tracking_timestamp_secs;// - d_preamble_duration_seconds; //record the PRN start sample index associated to the preamble
|
||||
d_symbol_accumulator_counter = GPS_CA_TELEMETRY_SYMBOLS_PER_BIT-in[0]->correlation_length_ms;
|
||||
d_frame_bit_index = 7;
|
||||
if (!d_flag_frame_sync)
|
||||
{
|
||||
//send asynchronous message to tracking to inform of frame sync and extend correlation time
|
||||
pmt::pmt_t value = pmt::from_long(d_preamble_index-2);
|
||||
pmt::pmt_t value = pmt::from_long(d_preamble_index-1);
|
||||
this->message_port_pub(pmt::mp("preamble_index"),value);
|
||||
|
||||
d_flag_frame_sync = true;
|
||||
if (corr_value < 0)
|
||||
{
|
||||
flag_PLL_180_deg_phase_locked = true; //PLL is locked to opposite phase!
|
||||
std::cout << " PLL in opposite phase for Sat "<< this->d_satellite.get_PRN();
|
||||
DLOG(INFO) << " PLL in opposite phase for Sat "<< this->d_satellite.get_PRN();
|
||||
}
|
||||
else
|
||||
{
|
||||
flag_PLL_180_deg_phase_locked = false;
|
||||
}
|
||||
std::cout << " Frame sync SAT " << this->d_satellite << " with preamble start at " << d_preamble_time_seconds << " [s]";
|
||||
DLOG(INFO) << " Frame sync SAT " << this->d_satellite << " with preamble start at " << d_preamble_time_seconds << " [s]";
|
||||
}
|
||||
}else{
|
||||
if (preamble_diff > 6001)
|
||||
if (preamble_diff > GPS_SUBFRAME_MS+1)
|
||||
{
|
||||
std::cout << "Lost of frame sync SAT " << this->d_satellite << " preamble_diff= " << preamble_diff;
|
||||
DLOG(INFO) << "Lost of frame sync SAT " << this->d_satellite << " preamble_diff= " << preamble_diff<<" d_sample_counter="<<d_sample_counter<<std::endl;
|
||||
d_stat = 0; //lost of frame sync
|
||||
d_flag_frame_sync = false;
|
||||
flag_TOW_set = false;
|
||||
@ -278,7 +271,7 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_i
|
||||
d_symbol_accumulator_counter+=in[0]->correlation_length_ms;
|
||||
}
|
||||
|
||||
if (d_symbol_accumulator_counter == 20 )
|
||||
if (d_symbol_accumulator_counter >= GPS_CA_TELEMETRY_SYMBOLS_PER_BIT )
|
||||
{
|
||||
if (d_symbol_accumulator > 0)
|
||||
{ //symbol to bit
|
||||
@ -288,8 +281,9 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_i
|
||||
d_symbol_accumulator_counter = 0;
|
||||
//******* bits to words ******
|
||||
d_frame_bit_index++;
|
||||
if (d_frame_bit_index == 30)
|
||||
if (d_frame_bit_index == GPS_WORD_BITS)
|
||||
{
|
||||
//std::cout<<"word bits = "<<std::bitset<32>(d_GPS_frame_4bytes)<<std::endl;
|
||||
d_frame_bit_index = 0;
|
||||
// parity check
|
||||
// Each word in wordbuff is composed of:
|
||||
@ -331,7 +325,6 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_i
|
||||
}
|
||||
}
|
||||
// output the frame
|
||||
consume_each(1); //one by one
|
||||
Gnss_Synchro current_synchro_data; //structure to save the synchronization information and send the output object to the next block
|
||||
//1. Copy the current tracking output
|
||||
current_synchro_data = in[0][0];
|
||||
@ -419,7 +412,7 @@ void gps_l1_ca_telemetry_decoder_cc::set_decimation(int decimation)
|
||||
void gps_l1_ca_telemetry_decoder_cc::set_satellite(Gnss_Satellite satellite)
|
||||
{
|
||||
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
|
||||
LOG(INFO) << "Setting decoder Finite State Machine to satellite " << d_satellite;
|
||||
DLOG(INFO) << "Setting decoder Finite State Machine to satellite " << d_satellite;
|
||||
d_GPS_FSM.i_satellite_PRN = d_satellite.get_PRN();
|
||||
DLOG(INFO) << "Navigation Satellite set to " << d_satellite;
|
||||
}
|
||||
@ -442,7 +435,7 @@ void gps_l1_ca_telemetry_decoder_cc::set_channel(int channel)
|
||||
d_dump_filename.append(".dat");
|
||||
d_dump_file.exceptions ( std::ifstream::failbit | std::ifstream::badbit );
|
||||
d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary);
|
||||
LOG(INFO) << "Telemetry decoder dump enabled on channel " << d_channel
|
||||
DLOG(INFO) << "Telemetry decoder dump enabled on channel " << d_channel
|
||||
<< " Log file: " << d_dump_filename.c_str();
|
||||
}
|
||||
catch (std::ifstream::failure e)
|
||||
|
@ -108,6 +108,7 @@ private:
|
||||
|
||||
// symbols
|
||||
std::deque<double> d_symbol_history;
|
||||
std::deque<int> d_correlation_length_ms_history;
|
||||
double d_symbol_accumulator;
|
||||
short int d_symbol_accumulator_counter;
|
||||
|
||||
|
@ -90,7 +90,7 @@ void gps_l1_ca_dll_pll_c_aid_tracking_cc::forecast (int noutput_items,
|
||||
void gps_l1_ca_dll_pll_c_aid_tracking_cc::msg_handler_preamble_index(pmt::pmt_t msg)
|
||||
{
|
||||
//pmt::print(msg);
|
||||
DLOG(INFO) << "Extended correlation for Tracking CH " << d_channel << ": Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN)<< std::endl;
|
||||
DLOG(INFO) << "Extended correlation enabled for Tracking CH " << d_channel << ": Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN)<< std::endl;
|
||||
if (d_enable_extended_integration==false) //avoid re-setting preamble indicator
|
||||
{
|
||||
d_preamble_index=pmt::to_long(msg);
|
||||
@ -380,7 +380,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work (int noutput_items, gr_vec
|
||||
if (d_enable_extended_integration==true)
|
||||
{
|
||||
long int symbol_diff=d_symbol_counter-d_preamble_index;
|
||||
if (symbol_diff % d_extend_correlation_ms == 0)
|
||||
if (symbol_diff>0 and symbol_diff % d_extend_correlation_ms == 0)
|
||||
{
|
||||
// compute coherent integration and enable tracking loop
|
||||
// perform coherent integration using correlator output history
|
||||
@ -400,7 +400,8 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work (int noutput_items, gr_vec
|
||||
d_code_loop_filter.set_DLL_BW(d_dll_bw_narrow_hz);
|
||||
d_carrier_loop_filter.set_params(10.0, d_pll_bw_narrow_hz,2);
|
||||
d_preamble_synchronized=true;
|
||||
std::cout<<"dll="<<d_dll_bw_hz<<" dll_n="<<d_dll_bw_narrow_hz<<" pll="<<d_pll_bw_hz<<" pll_n="<<d_pll_bw_narrow_hz<<std::endl;
|
||||
std::cout<<"Enabled extended correlator for CH "<< d_channel <<" : Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN)
|
||||
<<" dll_narrow_bw="<<d_dll_bw_narrow_hz<<" pll_narrow_bw="<<d_pll_bw_narrow_hz<<std::endl;
|
||||
|
||||
}
|
||||
// UPDATE INTEGRATION TIME
|
||||
@ -411,8 +412,6 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work (int noutput_items, gr_vec
|
||||
if(d_preamble_synchronized==true)
|
||||
{
|
||||
// continue extended coherent correlation
|
||||
//TODO: Take into account the extended correlation to update the accumulated carrier phase for carrier phase observables!!
|
||||
|
||||
//remnant carrier phase [rads]
|
||||
d_rem_carrier_phase_rad = fmod(d_rem_carrier_phase_rad + d_carrier_phase_step_rad * static_cast<double>(d_correlation_length_samples), GPS_TWO_PI);
|
||||
|
||||
@ -572,8 +571,6 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work (int noutput_items, gr_vec
|
||||
}
|
||||
*out[0] = current_synchro_data;
|
||||
}else{
|
||||
//todo: fill synchronization data to produce output while coherent integration is running
|
||||
current_synchro_data.Flag_valid_symbol_output = false;
|
||||
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());
|
||||
// Tracking_timestamp_secs is aligned with the CURRENT PRN start sample (Hybridization OK!)
|
||||
@ -584,12 +581,8 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work (int noutput_items, gr_vec
|
||||
current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz;// todo: project the carrier doppler
|
||||
current_synchro_data.CN0_dB_hz = d_CN0_SNV_dB_Hz;
|
||||
current_synchro_data.Flag_valid_pseudorange = false;
|
||||
if (d_preamble_synchronized==true)
|
||||
{
|
||||
current_synchro_data.correlation_length_ms=d_extend_correlation_ms;
|
||||
}else{
|
||||
current_synchro_data.correlation_length_ms=1;
|
||||
}
|
||||
current_synchro_data.Flag_valid_symbol_output = false;
|
||||
current_synchro_data.correlation_length_ms=1;
|
||||
*out[0] = current_synchro_data;
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,7 @@ const int GPS_WORD_LENGTH = 4; //!< CRC + GPS WORD (-2 -1 0
|
||||
const int GPS_SUBFRAME_LENGTH = 40; //!< GPS_WORD_LENGTH x 10 = 40 bytes
|
||||
const int GPS_SUBFRAME_BITS = 300; //!< Number of bits per subframe in the NAV message [bits]
|
||||
const int GPS_SUBFRAME_SECONDS = 6; //!< Subframe duration [seconds]
|
||||
const int GPS_SUBFRAME_MS = 6000; //!< Subframe duration [seconds]
|
||||
const int GPS_WORD_BITS = 30; //!< Number of bits per word in the NAV message [bits]
|
||||
|
||||
// GPS NAVIGATION MESSAGE STRUCTURE
|
||||
|
Loading…
Reference in New Issue
Block a user