mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-30 23:03:05 +00:00 
			
		
		
		
	Trim CN0 smoother parameters. Add it to the FPGA block
This commit is contained in:
		| @@ -440,7 +440,10 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(const Dll_Pll_Conf &conf_) : gr::bl | |||||||
|     d_carrier_lock_threshold = trk_parameters.carrier_lock_th; |     d_carrier_lock_threshold = trk_parameters.carrier_lock_th; | ||||||
|     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_cn0_smoother = Exponential_Smoother(); |     d_cn0_smoother = Exponential_Smoother(); | ||||||
|  |     if (d_code_period > 0.0) | ||||||
|  |         { | ||||||
|  |             d_cn0_smoother.set_samples_for_initialization(200 / static_cast<int>(d_code_period * 1000.0)); | ||||||
|  |         } | ||||||
|     d_acquisition_gnss_synchro = nullptr; |     d_acquisition_gnss_synchro = nullptr; | ||||||
|     d_channel = 0; |     d_channel = 0; | ||||||
|     d_acq_code_phase_samples = 0.0; |     d_acq_code_phase_samples = 0.0; | ||||||
| @@ -853,7 +856,7 @@ bool dll_pll_veml_tracking::cn0_and_tracking_lock_status(double coh_integration_ | |||||||
|     d_Prompt_buffer[d_cn0_estimation_counter % trk_parameters.cn0_samples] = d_P_accu; |     d_Prompt_buffer[d_cn0_estimation_counter % trk_parameters.cn0_samples] = d_P_accu; | ||||||
|     d_cn0_estimation_counter++; |     d_cn0_estimation_counter++; | ||||||
|     // Code lock indicator |     // Code lock indicator | ||||||
|     double d_CN0_SNV_dB_Hz_raw = cn0_svn_estimator(d_Prompt_buffer, trk_parameters.cn0_samples, coh_integration_time_s); |     float d_CN0_SNV_dB_Hz_raw = cn0_svn_estimator(d_Prompt_buffer, trk_parameters.cn0_samples, static_cast<float>(coh_integration_time_s)); | ||||||
|     d_CN0_SNV_dB_Hz = d_cn0_smoother.smooth(d_CN0_SNV_dB_Hz_raw); |     d_CN0_SNV_dB_Hz = d_cn0_smoother.smooth(d_CN0_SNV_dB_Hz_raw); | ||||||
|     // Carrier lock indicator |     // Carrier lock indicator | ||||||
|     d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, trk_parameters.cn0_samples); |     d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, trk_parameters.cn0_samples); | ||||||
| @@ -1593,11 +1596,12 @@ int dll_pll_veml_tracking::general_work(int noutput_items __attribute__((unused) | |||||||
|                 d_acc_carrier_phase_rad -= d_carrier_phase_step_rad * static_cast<double>(samples_offset); |                 d_acc_carrier_phase_rad -= d_carrier_phase_step_rad * static_cast<double>(samples_offset); | ||||||
|                 d_state = 2; |                 d_state = 2; | ||||||
|                 d_sample_counter += samples_offset;  // count for the processed samples |                 d_sample_counter += samples_offset;  // count for the processed samples | ||||||
|  |                 d_cn0_smoother.reset(); | ||||||
|  |  | ||||||
|                 DLOG(INFO) << "Number of samples between Acquisition and Tracking = " << acq_trk_diff_samples << " ( " << acq_trk_diff_seconds << " s)"; |                 DLOG(INFO) << "Number of samples between Acquisition and Tracking = " << acq_trk_diff_samples << " ( " << acq_trk_diff_seconds << " s)"; | ||||||
|                 DLOG(INFO) << "PULL-IN Doppler [Hz] = " << d_carrier_doppler_hz |                 DLOG(INFO) << "PULL-IN Doppler [Hz] = " << d_carrier_doppler_hz | ||||||
|                            << ". PULL-IN Code Phase [samples] = " << d_acq_code_phase_samples; |                            << ". PULL-IN Code Phase [samples] = " << d_acq_code_phase_samples; | ||||||
|                 d_cn0_smoother.reset(); |  | ||||||
|                 consume_each(samples_offset);  // shift input to perform alignment with local replica |                 consume_each(samples_offset);  // shift input to perform alignment with local replica | ||||||
|                 return 0; |                 return 0; | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -350,6 +350,11 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & | |||||||
|     d_Prompt_buffer = new gr_complex[trk_parameters.cn0_samples]; |     d_Prompt_buffer = new gr_complex[trk_parameters.cn0_samples]; | ||||||
|     d_carrier_lock_test = 1.0; |     d_carrier_lock_test = 1.0; | ||||||
|     d_CN0_SNV_dB_Hz = 0.0; |     d_CN0_SNV_dB_Hz = 0.0; | ||||||
|  |     d_cn0_smoother = Exponential_Smoother(); | ||||||
|  |     if (d_code_period > 0.0) | ||||||
|  |         { | ||||||
|  |             d_cn0_smoother.set_samples_for_initialization(200 / static_cast<int>(d_code_period * 1000.0)); | ||||||
|  |         } | ||||||
|     d_carrier_lock_fail_counter = 0; |     d_carrier_lock_fail_counter = 0; | ||||||
|     d_carrier_lock_threshold = trk_parameters.carrier_lock_th; |     d_carrier_lock_threshold = trk_parameters.carrier_lock_th; | ||||||
|     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())); | ||||||
| @@ -582,7 +587,8 @@ bool dll_pll_veml_tracking_fpga::cn0_and_tracking_lock_status(double coh_integra | |||||||
|         { |         { | ||||||
|             d_cn0_estimation_counter = 0; |             d_cn0_estimation_counter = 0; | ||||||
|             // Code lock indicator |             // Code lock indicator | ||||||
|             d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, trk_parameters.cn0_samples, coh_integration_time_s); |             float d_CN0_SNV_dB_Hz_raw = cn0_svn_estimator(d_Prompt_buffer, trk_parameters.cn0_samples, static_cast<float>(coh_integration_time_s)); | ||||||
|  |             d_CN0_SNV_dB_Hz = d_cn0_smoother.smooth(d_CN0_SNV_dB_Hz_raw); | ||||||
|             // Carrier lock indicator |             // Carrier lock indicator | ||||||
|             d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, trk_parameters.cn0_samples); |             d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, trk_parameters.cn0_samples); | ||||||
|             // Loss of lock detection |             // Loss of lock detection | ||||||
| @@ -1437,6 +1443,7 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un | |||||||
|                 int32_t samples_offset = round(d_acq_code_phase_samples); |                 int32_t samples_offset = round(d_acq_code_phase_samples); | ||||||
|                 d_acc_carrier_phase_rad -= d_carrier_phase_step_rad * static_cast<double>(samples_offset); |                 d_acc_carrier_phase_rad -= d_carrier_phase_step_rad * static_cast<double>(samples_offset); | ||||||
|                 d_state = 2; |                 d_state = 2; | ||||||
|  |                 d_cn0_smoother.reset(); | ||||||
|  |  | ||||||
|                 // DEBUG OUTPUT |                 // DEBUG OUTPUT | ||||||
|                 std::cout << "Tracking of " << systemName << " " << signal_pretty_name << " signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; |                 std::cout << "Tracking of " << systemName << " " << signal_pretty_name << " signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; | ||||||
|   | |||||||
| @@ -33,6 +33,7 @@ | |||||||
| #define GNSS_SDR_DLL_PLL_VEML_TRACKING_FPGA_H | #define GNSS_SDR_DLL_PLL_VEML_TRACKING_FPGA_H | ||||||
|  |  | ||||||
| #include "dll_pll_conf_fpga.h" | #include "dll_pll_conf_fpga.h" | ||||||
|  | #include "exponential_smoother.h" | ||||||
| #include "tracking_FLL_PLL_filter.h"  // for PLL/FLL filter | #include "tracking_FLL_PLL_filter.h"  // for PLL/FLL filter | ||||||
| #include "tracking_loop_filter.h"     // for DLL filter | #include "tracking_loop_filter.h"     // for DLL filter | ||||||
| #include <boost/circular_buffer.hpp> | #include <boost/circular_buffer.hpp> | ||||||
| @@ -201,6 +202,7 @@ private: | |||||||
|     boost::circular_buffer<gr_complex> d_Prompt_circular_buffer; |     boost::circular_buffer<gr_complex> d_Prompt_circular_buffer; | ||||||
|     //std::deque<gr_complex> d_Prompt_buffer_deque; |     //std::deque<gr_complex> d_Prompt_buffer_deque; | ||||||
|     gr_complex *d_Prompt_buffer; |     gr_complex *d_Prompt_buffer; | ||||||
|  |     Exponential_Smoother d_cn0_smoother; | ||||||
|  |  | ||||||
|     // file dump |     // file dump | ||||||
|     std::ofstream d_dump_file; |     std::ofstream d_dump_file; | ||||||
|   | |||||||
| @@ -31,7 +31,6 @@ | |||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include "exponential_smoother.h" | #include "exponential_smoother.h" | ||||||
| #include <iostream>  /////////////// |  | ||||||
| #include <iterator> | #include <iterator> | ||||||
| #include <numeric> | #include <numeric> | ||||||
|  |  | ||||||
| @@ -40,11 +39,11 @@ Exponential_Smoother::Exponential_Smoother() | |||||||
|     alpha_ = 0.001; |     alpha_ = 0.001; | ||||||
|     old_value_ = 0.0; |     old_value_ = 0.0; | ||||||
|     one_minus_alpha_ = 1.0 - alpha_; |     one_minus_alpha_ = 1.0 - alpha_; | ||||||
|     samples_for_initialization_ = 500; |     samples_for_initialization_ = 200; | ||||||
|     initializing_ = true; |     initializing_ = true; | ||||||
|     init_counter_ = 0; |     init_counter_ = 0; | ||||||
|     min_value_ = 25; |     min_value_ = 25.0; | ||||||
|     offset_ = 9.0; |     offset_ = 12.0; | ||||||
|     init_buffer_.reserve(samples_for_initialization_); |     init_buffer_.reserve(samples_for_initialization_); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -117,7 +116,7 @@ float Exponential_Smoother::smooth(float raw) | |||||||
|             init_buffer_.push_back(smoothed_value); |             init_buffer_.push_back(smoothed_value); | ||||||
|             if (init_counter_ == samples_for_initialization_) |             if (init_counter_ == samples_for_initialization_) | ||||||
|                 { |                 { | ||||||
|                     old_value_ = std::accumulate(std::begin(init_buffer_), std::end(init_buffer_), 0.0) / static_cast<float>(init_buffer_.size()); |                     old_value_ = std::accumulate(std::begin(init_buffer_), std::end(init_buffer_), 0.0f) / static_cast<float>(init_buffer_.size()); | ||||||
|                     if (old_value_ < (min_value_ + offset_)) |                     if (old_value_ < (min_value_ + offset_)) | ||||||
|                         { |                         { | ||||||
|                             // flush buffer and start again |                             // flush buffer and start again | ||||||
|   | |||||||
| @@ -49,8 +49,8 @@ class Exponential_Smoother | |||||||
| public: | public: | ||||||
|     Exponential_Smoother();   //!< Constructor |     Exponential_Smoother();   //!< Constructor | ||||||
|     ~Exponential_Smoother();  //!< Destructor |     ~Exponential_Smoother();  //!< Destructor | ||||||
|     void set_alpha(float alpha); //!< 0 < alpha < 1. The higher, the most responsive, but more variance. Default value: 0.0001 |     void set_alpha(float alpha); //!< 0 < alpha < 1. The higher, the most responsive, but more variance. Default value: 0.001 | ||||||
|     void set_samples_for_initialization(int num_samples); //!< Number of samples averaged for initialization. Default value: |     void set_samples_for_initialization(int num_samples); //!< Number of samples averaged for initialization. Default value: 200 | ||||||
|     void reset(); |     void reset(); | ||||||
|     void set_min_value(float value); |     void set_min_value(float value); | ||||||
|     void set_offset(float offset); |     void set_offset(float offset); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Carles Fernandez
					Carles Fernandez