From 16a1797c6d0236fb3482011c5326e2912cd8a3cc Mon Sep 17 00:00:00 2001 From: Javier Arribas Date: Fri, 3 Feb 2012 11:50:51 +0000 Subject: [PATCH] Telemetry decoder module now uses the Gnss_Synchro class to communicate the block with the observables block git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@154 64b25241-fba3-4117-9849-534c7e92360d --- conf/gnss-sdr.conf | 5 +- .../gps_l1_ca_observables_cc.cc | 47 ++++++++++--------- .../gps_l1_ca_telemetry_decoder_cc.cc | 47 +++++++++---------- .../gps_l1_ca_telemetry_decoder_cc.h | 2 +- 4 files changed, 49 insertions(+), 52 deletions(-) diff --git a/conf/gnss-sdr.conf b/conf/gnss-sdr.conf index 4d332000c..e62d94253 100644 --- a/conf/gnss-sdr.conf +++ b/conf/gnss-sdr.conf @@ -17,7 +17,7 @@ ControlThread.wait_for_flowgraph=false SignalSource.implementation=File_Signal_Source ;#filename: path to file with the captured GNSS signal samples to be processed -SignalSource.filename=/home/javier/signals/Agilent/cap2/agilent_cap2.dat +SignalSource.filename=/media/DATALOGGER/signals/Agilent GPS Generator/cap2/agilent_cap2.dat ;#item_type: Type and resolution for each of the signal samples. Use only gr_complex in this version. SignalSource.item_type=gr_complex @@ -226,8 +226,7 @@ Acquisition7.doppler_step=250 ;######### TRACKING GLOBAL CONFIG ############ ;#implementatiion: Selected tracking algorithm: [GPS_L1_CA_DLL_PLL_Tracking] or [GPS_L1_CA_DLL_FLL_PLL_Tracking] -Tracking.implementation=GPS_L1_CA_DLL_PLL_Tracking - +Tracking.implementation=GPS_L1_CA_DLL_FLL_PLL_Tracking ;#item_type: Type and resolution for each of the signal samples. Use only [gr_complex] in this version. Tracking.item_type=gr_complex diff --git a/src/algorithms/observables/gnuradio_blocks/gps_l1_ca_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/gps_l1_ca_observables_cc.cc index fd82c96f6..8105549fe 100644 --- a/src/algorithms/observables/gnuradio_blocks/gps_l1_ca_observables_cc.cc +++ b/src/algorithms/observables/gnuradio_blocks/gps_l1_ca_observables_cc.cc @@ -41,6 +41,9 @@ #include #include +#include "gnss_synchro.h" + + using google::LogMessage; @@ -54,7 +57,7 @@ gps_l1_ca_make_observables_cc(unsigned int nchannels, gr_msg_queue_sptr queue, b gps_l1_ca_observables_cc::gps_l1_ca_observables_cc(unsigned int nchannels, gr_msg_queue_sptr queue, bool dump, std::string dump_filename, int output_rate_ms, bool flag_averaging) : - gr_block ("gps_l1_ca_observables_cc", gr_make_io_signature (nchannels, nchannels, sizeof(gnss_synchro)), + gr_block ("gps_l1_ca_observables_cc", gr_make_io_signature (nchannels, nchannels, sizeof(Gnss_Synchro)), gr_make_io_signature(nchannels, nchannels, sizeof(gnss_pseudorange))) { // initialize internal vars @@ -97,9 +100,9 @@ gps_l1_ca_observables_cc::~gps_l1_ca_observables_cc() -bool pairCompare_gnss_synchro( std::pair a, std::pair b) +bool pairCompare_gnss_synchro( std::pair a, std::pair b) { - return (a.second.preamble_delay_ms) < (b.second.preamble_delay_ms); + return (a.second.Preamble_delay_ms) < (b.second.Preamble_delay_ms); } @@ -129,13 +132,13 @@ void clearQueue( std::deque &q ) int gps_l1_ca_observables_cc::general_work (int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - gnss_synchro **in = (gnss_synchro **) &input_items[0]; //Get the input pointer + Gnss_Synchro **in = (Gnss_Synchro **) &input_items[0]; //Get the input pointer gnss_pseudorange **out = (gnss_pseudorange **) &output_items[0]; //Get the output pointer gnss_pseudorange current_gnss_pseudorange; - std::map gps_words; - std::map::iterator gps_words_iter; + std::map gps_words; + std::map::iterator gps_words_iter; std::map::iterator current_prn_timestamps_ms_iter; std::map current_prn_timestamps_ms; @@ -161,20 +164,20 @@ int gps_l1_ca_observables_cc::general_work (int noutput_items, gr_vector_int &ni */ for (unsigned int i=0; i(in[i][0].channel_ID, in[i][0])); //record the word structure in a map for pseudoranges + gps_words.insert(std::pair(in[i][0].Channel_ID, in[i][0])); //record the word structure in a map for pseudoranges // RECORD PRN start timestamps history if (d_history_prn_delay_ms[i].size()second.preamble_delay_ms; //[ms] + min_preamble_delay_ms = gps_words_iter->second.Preamble_delay_ms; //[ms] - pseudoranges_reference_sat_ID = gps_words_iter->second.satellite_PRN; // it is the reference! - pseudoranges_reference_sat_channel_ID = gps_words_iter->second.channel_ID; + pseudoranges_reference_sat_ID = gps_words_iter->second.PRN; // it is the reference! + pseudoranges_reference_sat_channel_ID = gps_words_iter->second.Channel_ID; // The farthest satellite, last preamble to arrive gps_words_iter = max_element(gps_words.begin(), gps_words.end(), pairCompare_gnss_synchro); - max_preamble_delay_ms = gps_words_iter->second.preamble_delay_ms; - min_delta_timestamp_ms = gps_words_iter->second.prn_delay_ms - max_preamble_delay_ms; //[ms] + max_preamble_delay_ms = gps_words_iter->second.Preamble_delay_ms; + min_delta_timestamp_ms = gps_words_iter->second.Prn_delay_ms - max_preamble_delay_ms; //[ms] // check if this is a valid set of observations if ((max_preamble_delay_ms - min_preamble_delay_ms) < MAX_TOA_DELAY_MS) @@ -221,10 +224,10 @@ int gps_l1_ca_observables_cc::general_work (int noutput_items, gr_vector_int &ni // find again the minimum CURRENT minimum preamble time, taking into account the preamble timeshift for(gps_words_iter = gps_words.begin(); gps_words_iter != gps_words.end(); gps_words_iter++) { - delta_timestamp_ms = (gps_words_iter->second.prn_delay_ms - gps_words_iter->second.preamble_delay_ms) - min_delta_timestamp_ms; + delta_timestamp_ms = (gps_words_iter->second.Prn_delay_ms - gps_words_iter->second.Preamble_delay_ms) - min_delta_timestamp_ms; history_shift = round(delta_timestamp_ms); //std::cout<<"history_shift="<(gps_words_iter->second.channel_ID, d_history_prn_delay_ms[gps_words_iter->second.channel_ID][history_shift])); + current_prn_timestamps_ms.insert(std::pair(gps_words_iter->second.Channel_ID, d_history_prn_delay_ms[gps_words_iter->second.Channel_ID][history_shift])); // debug: preamble position test //if ((d_history_prn_delay_ms[gps_words_iter->second.channel_ID][history_shift]-gps_words_iter->second.preamble_delay_ms)<0.1) //{std::cout<<"ch "<second.channel_ID<<" current_prn_time-last_preamble_prn_time="<< @@ -252,7 +255,7 @@ int gps_l1_ca_observables_cc::general_work (int noutput_items, gr_vector_int &ni { // #### compute the pseudorange for this satellite ### - current_prn_delay_ms = current_prn_timestamps_ms.at(gps_words_iter->second.channel_ID); + current_prn_delay_ms = current_prn_timestamps_ms.at(gps_words_iter->second.Channel_ID); traveltime_ms = current_prn_delay_ms - actual_min_prn_delay_ms + GPS_STARTOFFSET_ms; //[ms] //std::cout<<"delta_time_ms="<second.satellite_PRN; + current_gnss_pseudorange.SV_ID = gps_words_iter->second.PRN; current_gnss_pseudorange.valid = true; // #### write the pseudorrange block output for this satellite ### - *out[gps_words_iter->second.channel_ID] = current_gnss_pseudorange; + *out[gps_words_iter->second.Channel_ID] = current_gnss_pseudorange; } } } @@ -276,9 +279,9 @@ int gps_l1_ca_observables_cc::general_work (int noutput_items, gr_vector_int &ni double tmp_double; for (unsigned int i=0; i #include "control_message_factory.h" +#include "gnss_synchro.h" + #define _lrotl(X,N) ((X << N) ^ (X >> (32-N))) // Used in the parity check algorithm @@ -80,7 +82,7 @@ gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc( gr_msg_queue_sptr queue, bool dump) : gr_block ("gps_navigation_cc", gr_make_io_signature (1, 1, sizeof(Gnss_Synchro)), - gr_make_io_signature(1, 1, sizeof(gnss_synchro))) + gr_make_io_signature(1, 1, sizeof(Gnss_Synchro))) { // initialize internal vars d_queue = queue; @@ -175,28 +177,15 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_i int corr_value = 0; int preamble_diff; - gnss_synchro gps_synchro; //structure to save the synchronization information - - - gnss_synchro **out = (gnss_synchro **) &output_items[0]; + Gnss_Synchro **out = (Gnss_Synchro **) &output_items[0]; d_sample_counter++; //count for the processed samples DLOG(INFO) << "Sample counter: " << d_sample_counter; - const Gnss_Synchro **in = (const Gnss_Synchro **) &input_items[0]; //Get the input samples pointer // ########### Output the tracking data to navigation and PVT ########## - // Output channel 0: Prompt correlator output Q - // *out[0]=(double)d_Prompt.real(); - // // Output channel 1: Prompt correlator output I - // *out[1]=(double)d_Prompt.imag(); - // // Output channel 2: PRN absolute delay [s] - // *out[2]=d_sample_counter_seconds; - // // Output channel 3: d_acc_carrier_phase_rad [rad] - // *out[3]=(double)d_acc_carrier_phase_rad; - // // Output channel 4: PRN code phase [s] - // *out[4]=(double)d_code_phase_samples*(1/(float)d_fs_in); + const Gnss_Synchro **in = (const Gnss_Synchro **) &input_items[0]; //Get the input samples pointer /*! * \todo Check the HOW GPS time computation, taking into account that the preamble correlation last 160 symbols, which is 160 ms in GPS CA L1 @@ -337,16 +326,22 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_i consume_each(1); //one by one DLOG(INFO) << "TELEMETRY PROCESSED for satellite " << this->d_satellite; - //! \todo This has to be documented!!!! - gps_synchro.valid_word = (d_flag_frame_sync == true and d_flag_parity == true); - gps_synchro.flag_preamble = d_flag_preamble; - gps_synchro.preamble_delay_ms = d_preamble_time_seconds*1000.0; - gps_synchro.prn_delay_ms = (in[0][0].Tracking_timestamp_secs - d_preamble_duration_seconds)*1000.0; - gps_synchro.preamble_code_phase_ms = d_preamble_code_phase_seconds*1000.0; - gps_synchro.preamble_code_phase_correction_ms = (in[0][0].Code_phase_secs - d_preamble_code_phase_seconds)*1000.0; - gps_synchro.satellite_PRN = this->d_satellite.get_PRN(); - gps_synchro.channel_ID = d_channel; - *out[0] = gps_synchro; + 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 + current_synchro_data.Flag_valid_word=(d_flag_frame_sync == true and d_flag_parity == true); + current_synchro_data.Flag_preamble= d_flag_preamble; + current_synchro_data.Preamble_delay_ms= d_preamble_time_seconds*1000.0; + current_synchro_data.Prn_delay_ms = (in[0][0].Tracking_timestamp_secs - d_preamble_duration_seconds)*1000.0; + current_synchro_data.Preamble_code_phase_ms = d_preamble_code_phase_seconds*1000.0; + current_synchro_data.Preamble_code_phase_correction_ms = (in[0][0].Code_phase_secs - d_preamble_code_phase_seconds)*1000.0; + //gps_synchro.satellite_PRN = this->d_satellite.get_PRN(); //is already filled... + //gps_synchro.channel_ID = d_channel; + + //3. Make the output (copy the object contents to the GNURadio reserved memory) + *out[0] = current_synchro_data; return 1; } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h index 7c8c557a0..952d7b5b9 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h @@ -88,7 +88,7 @@ private: bool gps_word_parityCheck(unsigned int gpsword); // constants - unsigned short int d_preambles_bits[8]; + unsigned short int d_preambles_bits[GPS_CA_PREAMBLE_LENGTH_BITS]; // class private vars