1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-14 04:00:34 +00:00

Removing the sample forecast requirements on Galileo E1 telemetry decoder

This commit is contained in:
Javier Arribas 2017-05-16 18:26:29 +02:00
parent 4c7a176d96
commit e1873a408d
2 changed files with 48 additions and 69 deletions

View File

@ -54,16 +54,6 @@ galileo_e1b_make_telemetry_decoder_cc(Gnss_Satellite satellite, bool dump)
} }
void galileo_e1b_telemetry_decoder_cc::forecast (int noutput_items, gr_vector_int &ninput_items_required)
{
if(noutput_items != 0)
{
ninput_items_required[0] = GALILEO_INAV_PAGE_SYMBOLS; // set the required sample history
}
}
void galileo_e1b_telemetry_decoder_cc::viterbi_decoder(double *page_part_symbols, int *page_part_bits) void galileo_e1b_telemetry_decoder_cc::viterbi_decoder(double *page_part_symbols, int *page_part_bits)
{ {
int CodeLength = 240; int CodeLength = 240;
@ -161,7 +151,6 @@ galileo_e1b_telemetry_decoder_cc::galileo_e1b_telemetry_decoder_cc(
d_flag_frame_sync = false; d_flag_frame_sync = false;
d_flag_parity = false; d_flag_parity = false;
d_TOW_at_Preamble = 0;
d_TOW_at_current_symbol = 0; d_TOW_at_current_symbol = 0;
delta_t = 0; delta_t = 0;
d_CRC_error_counter = 0; d_CRC_error_counter = 0;
@ -286,25 +275,34 @@ int galileo_e1b_telemetry_decoder_cc::general_work (int noutput_items __attribut
int preamble_diff = 0; int preamble_diff = 0;
Gnss_Synchro **out = (Gnss_Synchro **) &output_items[0]; Gnss_Synchro **out = (Gnss_Synchro **) &output_items[0];
d_sample_counter++; //count for the processed samples
// ########### Output the tracking data to navigation and PVT ##########
const Gnss_Synchro **in = (const Gnss_Synchro **) &input_items[0]; //Get the input samples pointer const Gnss_Synchro **in = (const Gnss_Synchro **) &input_items[0]; //Get the input samples pointer
// TODO Optimize me! Gnss_Synchro current_symbol; //structure to save the synchronization information and send the output object to the next block
//******* preamble correlation ******** //1. Copy the current tracking output
for (int i = 0; i < d_symbols_per_preamble; i++) current_symbol = in[0][0];
{ d_symbol_history.push_back(current_symbol); //add new symbol to the symbol queue
if (in[0][i].Prompt_I < 0) // symbols clipping d_sample_counter++; //count for the processed samples
{ consume_each(1);
corr_value -= d_preambles_symbols[i];
}
else
{
corr_value += d_preambles_symbols[i];
}
}
d_flag_preamble = false; d_flag_preamble = false;
unsigned int required_symbols=GALILEO_INAV_PAGE_SYMBOLS+d_symbols_per_preamble;
if (d_symbol_history.size()>required_symbols)
{
// TODO Optimize me!
//******* preamble correlation ********
for (int i = 0; i < d_symbols_per_preamble; i++)
{
if (d_symbol_history.at(i).Prompt_I < 0) // symbols clipping
{
corr_value -= d_preambles_symbols[i];
}
else
{
corr_value += d_preambles_symbols[i];
}
}
}
//******* frame sync ****************** //******* frame sync ******************
if (d_stat == 0) //no preamble information if (d_stat == 0) //no preamble information
@ -351,12 +349,12 @@ int galileo_e1b_telemetry_decoder_cc::general_work (int noutput_items __attribut
{ {
if (corr_value > 0) if (corr_value > 0)
{ {
page_part_symbols[i] = in[0][i + d_symbols_per_preamble].Prompt_I; // because last symbol of the preamble is just received now! page_part_symbols[i] = d_symbol_history.at(i + d_symbols_per_preamble).Prompt_I; // because last symbol of the preamble is just received now!
} }
else else
{ {
page_part_symbols[i] = -in[0][i + d_symbols_per_preamble].Prompt_I; // because last symbol of the preamble is just received now! page_part_symbols[i] = -d_symbol_history.at(i + d_symbols_per_preamble).Prompt_I; // because last symbol of the preamble is just received now!
} }
} }
@ -371,7 +369,7 @@ int galileo_e1b_telemetry_decoder_cc::general_work (int noutput_items __attribut
{ {
d_flag_frame_sync = true; d_flag_frame_sync = true;
DLOG(INFO) << " Frame sync SAT " << this->d_satellite << " with preamble start at " DLOG(INFO) << " Frame sync SAT " << this->d_satellite << " with preamble start at "
<< in[0][0].Tracking_sample_counter << " [samples]"; << d_symbol_history.at(0).Tracking_sample_counter << " [samples]";
} }
} }
else else
@ -388,47 +386,27 @@ int galileo_e1b_telemetry_decoder_cc::general_work (int noutput_items __attribut
} }
} }
consume_each(1); //one by one
// UPDATE GNSS SYNCHRO DATA // UPDATE GNSS SYNCHRO DATA
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];
//2. Add the telemetry decoder information //2. Add the telemetry decoder information
if (this->d_flag_preamble == true and d_nav.flag_TOW_set == true) if (this->d_flag_preamble == true and d_nav.flag_TOW_set == true)
//update TOW at the preamble instant //update TOW at the preamble instant
// JAVI: 30/06/2014
// TOW, in Galileo, is referred to the START of the PAGE PART, that is, THE FIRST SYMBOL OF THAT PAGE, NOT THE PREAMBLE.
// thus, no correction should be done. d_TOW_at_Preamble should be renamed to d_TOW_at_page_start.
// Since we detected the preamble, then, we are in the last symbol of that preamble, or just at the start of the first page symbol.
//flag preamble is true after the all page (even and odd) is received. I/NAV page period is 2 SECONDS
{ {
if(d_nav.flag_TOW_5 == true) //page 5 arrived and decoded, so we are in the odd page (since Tow refers to the even page, we have to add 1 sec) if(d_nav.flag_TOW_5 == true) //page 5 arrived and decoded, so we are in the odd page (since Tow refers to the even page, we have to add 1 sec)
{ {
//std::cout<< "Using TOW_5 for timestamping" << std::endl; //TOW_5 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later plus the decoding delay
d_TOW_at_Preamble = d_nav.TOW_5 + GALILEO_INAV_PAGE_PART_SECONDS; //TOW_5 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later d_TOW_at_current_symbol = d_nav.TOW_5 + GALILEO_INAV_PAGE_PART_SECONDS+((double)required_symbols)*GALILEO_E1_CODE_PERIOD; //-GALILEO_E1_CODE_PERIOD;//+ (double)GALILEO_INAV_PREAMBLE_LENGTH_BITS/(double)GALILEO_TELEMETRY_RATE_BITS_SECOND;
/* 1 sec (GALILEO_INAV_PAGE_PART_SYMBOLS*GALILEO_E1_CODE_PERIOD) is added because
* if we have a TOW value it means that we are at the beginning of the last page part
* (GNU Radio history keeps in a buffer the rest of the incoming frame part)*/
d_TOW_at_current_symbol = d_TOW_at_Preamble;//-GALILEO_E1_CODE_PERIOD;//+ (double)GALILEO_INAV_PREAMBLE_LENGTH_BITS/(double)GALILEO_TELEMETRY_RATE_BITS_SECOND;
d_nav.flag_TOW_5 = false; d_nav.flag_TOW_5 = false;
} }
else if(d_nav.flag_TOW_6 == true) //page 6 arrived and decoded, so we are in the odd page (since Tow refers to the even page, we have to add 1 sec) else if(d_nav.flag_TOW_6 == true) //page 6 arrived and decoded, so we are in the odd page (since Tow refers to the even page, we have to add 1 sec)
{ {
//std::cout<< "Using TOW_6 for timestamping" << std::endl; //TOW_6 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later plus the decoding delay
d_TOW_at_Preamble = d_nav.TOW_6 + GALILEO_INAV_PAGE_PART_SECONDS; d_TOW_at_current_symbol = d_nav.TOW_6 + GALILEO_INAV_PAGE_PART_SECONDS+((double)required_symbols)*GALILEO_E1_CODE_PERIOD;//-GALILEO_E1_CODE_PERIOD;//+ (double)GALILEO_INAV_PREAMBLE_LENGTH_BITS/(double)GALILEO_TELEMETRY_RATE_BITS_SECOND;
//TOW_6 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later
/* 1 sec (GALILEO_INAV_PAGE_PART_SYMBOLS*GALILEO_E1_CODE_PERIOD) is added because
* if we have a TOW value it means that we are at the beginning of the last page part
* (GNU Radio history keeps in a buffer the rest of the incoming frame part)*/
d_TOW_at_current_symbol = d_TOW_at_Preamble;//-GALILEO_E1_CODE_PERIOD;//+ (double)GALILEO_INAV_PREAMBLE_LENGTH_BITS/(double)GALILEO_TELEMETRY_RATE_BITS_SECOND;
d_nav.flag_TOW_6 = false; d_nav.flag_TOW_6 = false;
} }
else else
{ {
//this page has no timing information //this page has no timing information
d_TOW_at_Preamble = d_TOW_at_Preamble + GALILEO_INAV_PAGE_SECONDS;
d_TOW_at_current_symbol = d_TOW_at_current_symbol + GALILEO_E1_CODE_PERIOD;// + GALILEO_INAV_PAGE_PART_SYMBOLS*GALILEO_E1_CODE_PERIOD; d_TOW_at_current_symbol = d_TOW_at_current_symbol + GALILEO_E1_CODE_PERIOD;// + GALILEO_INAV_PAGE_PART_SYMBOLS*GALILEO_E1_CODE_PERIOD;
} }
} }
@ -446,15 +424,15 @@ int galileo_e1b_telemetry_decoder_cc::general_work (int noutput_items __attribut
if (d_flag_frame_sync == true and d_nav.flag_TOW_set == true) if (d_flag_frame_sync == true and d_nav.flag_TOW_set == true)
{ {
current_synchro_data.Flag_valid_word = true; current_symbol.Flag_valid_word = true;
} }
else else
{ {
current_synchro_data.Flag_valid_word = false; current_symbol.Flag_valid_word = false;
} }
current_synchro_data.TOW_at_current_symbol_s = floor(d_TOW_at_current_symbol*1000.0)/1000.0; current_symbol.TOW_at_current_symbol_s = floor(d_TOW_at_current_symbol*1000.0)/1000.0;
current_synchro_data.TOW_at_current_symbol_s -=delta_t; //Galileo to GPS TOW current_symbol.TOW_at_current_symbol_s -=delta_t; //Galileo to GPS TOW
if(d_dump == true) if(d_dump == true)
{ {
@ -465,9 +443,9 @@ int galileo_e1b_telemetry_decoder_cc::general_work (int noutput_items __attribut
unsigned long int tmp_ulong_int; unsigned long int tmp_ulong_int;
tmp_double = d_TOW_at_current_symbol; tmp_double = d_TOW_at_current_symbol;
d_dump_file.write((char*)&tmp_double, sizeof(double)); d_dump_file.write((char*)&tmp_double, sizeof(double));
tmp_ulong_int = current_synchro_data.Tracking_sample_counter; tmp_ulong_int = current_symbol.Tracking_sample_counter;
d_dump_file.write((char*)&tmp_ulong_int, sizeof(unsigned long int)); d_dump_file.write((char*)&tmp_ulong_int, sizeof(unsigned long int));
tmp_double = d_TOW_at_Preamble; tmp_double = 0;
d_dump_file.write((char*)&tmp_double, sizeof(double)); d_dump_file.write((char*)&tmp_double, sizeof(double));
} }
catch (const std::ifstream::failure & e) catch (const std::ifstream::failure & e)
@ -475,11 +453,16 @@ int galileo_e1b_telemetry_decoder_cc::general_work (int noutput_items __attribut
LOG(WARNING) << "Exception writing observables dump file " << e.what(); LOG(WARNING) << "Exception writing observables dump file " << e.what();
} }
} }
// remove used symbols from history
if (d_symbol_history.size()>required_symbols)
{
d_symbol_history.pop_front();
}
//3. Make the output (copy the object contents to the GNURadio reserved memory) //3. Make the output (copy the object contents to the GNURadio reserved memory)
*out[0] = current_synchro_data; *out[0] = current_symbol;
//std::cout<<"GPS L1 TLM output on CH="<<this->d_channel << " SAMPLE STAMP="<<d_sample_counter/d_decimation_output_factor<<std::endl; //std::cout<<"GPS L1 TLM output on CH="<<this->d_channel << " SAMPLE STAMP="<<d_sample_counter/d_decimation_output_factor<<std::endl;
return 1; return 1;
} }

View File

@ -43,6 +43,7 @@
#include "galileo_almanac.h" #include "galileo_almanac.h"
#include "galileo_iono.h" #include "galileo_iono.h"
#include "galileo_utc_model.h" #include "galileo_utc_model.h"
#include "gnss_synchro.h"
@ -70,12 +71,6 @@ public:
int general_work (int noutput_items, gr_vector_int &ninput_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); gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
/*!
* \brief Function which tells the scheduler how many input items
* are required to produce noutput_items output items.
*/
void forecast (int noutput_items, gr_vector_int &ninput_items_required);
private: private:
friend galileo_e1b_telemetry_decoder_cc_sptr friend galileo_e1b_telemetry_decoder_cc_sptr
galileo_e1b_make_telemetry_decoder_cc(Gnss_Satellite satellite, bool dump); galileo_e1b_make_telemetry_decoder_cc(Gnss_Satellite satellite, bool dump);
@ -93,6 +88,8 @@ private:
unsigned int d_samples_per_symbol; unsigned int d_samples_per_symbol;
int d_symbols_per_preamble; int d_symbols_per_preamble;
std::deque<Gnss_Synchro> d_symbol_history;
long unsigned int d_sample_counter; long unsigned int d_sample_counter;
long unsigned int d_preamble_index; long unsigned int d_preamble_index;
unsigned int d_stat; unsigned int d_stat;
@ -109,7 +106,6 @@ private:
Gnss_Satellite d_satellite; Gnss_Satellite d_satellite;
int d_channel; int d_channel;
double d_TOW_at_Preamble;
double d_TOW_at_current_symbol; double d_TOW_at_current_symbol;
bool flag_TOW_set; bool flag_TOW_set;