From 818d9e14b50047fffc8f849ee5fa3eff4cc6d6ab Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 25 Nov 2012 11:15:11 +0000 Subject: [PATCH] Start migration to GNU Radio 3.7 new C++ API. This commit replaces some components of gnuradio-core by the new components gr-blocks, gr-fft and gr-filter. git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@282 64b25241-fba3-4117-9849-534c7e92360d --- jamroot.jam | 7 +- src/algorithms/PVT/libs/gps_l1_ca_ls_pvt.cc | 2 +- .../galileo_e1_pcps_ambiguous_acquisition.cc | 9 +- .../galileo_e1_pcps_ambiguous_acquisition.h | 5 +- .../adapters/gps_l1_ca_pcps_acquisition.cc | 9 +- .../adapters/gps_l1_ca_pcps_acquisition.h | 6 +- .../gnuradio_blocks/pcps_acquisition_cc.cc | 4 +- .../gnuradio_blocks/pcps_acquisition_cc.h | 229 ++++++++--------- .../channel/libs/gps_l1_ca_channel_fsm.cc | 4 +- .../adapters/ishort_to_complex.cc | 4 +- .../adapters/ishort_to_complex.h | 4 +- .../input_filter/adapters/fir_filter.cc | 8 +- .../input_filter/adapters/fir_filter.h | 13 +- .../adapters/freq_xlating_fir_filter.cc | 10 +- .../adapters/freq_xlating_fir_filter.h | 9 +- src/algorithms/libs/nco_lib.h | 4 +- .../adapters/gps_l1_ca_observables.cc | 4 +- .../gps_l1_ca_observables_cc.cc | 8 +- .../adapters/file_signal_source.cc | 239 +++++++++--------- .../adapters/gps_l1_ca_telemetry_decoder.cc | 4 +- .../gps_l1_ca_telemetry_decoder_cc.cc | 8 +- .../gps_l1_ca_dll_pll_tracking_cc.cc | 27 +- 22 files changed, 306 insertions(+), 311 deletions(-) diff --git a/jamroot.jam b/jamroot.jam index d75fc88b2..9f4bad1ee 100644 --- a/jamroot.jam +++ b/jamroot.jam @@ -46,7 +46,7 @@ project project : requirements OMNITHREAD_POSIX "-msse2 -mfpmath=sse -std=c++0x -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free" -"-larmadillo -lboost_system -lboost_filesystem -lboost_thread -lboost_date_time -llapack -lblas -lprofiler -ltcmalloc -lvolk" +"-lgnuradio-blocks -lgnuradio-fft -lgnuradio-filter -larmadillo -lboost_system -lboost_filesystem -lboost_thread -lboost_date_time -llapack -lblas -lprofiler -ltcmalloc -lvolk" src/algorithms/acquisition/adapters src/algorithms/acquisition/gnuradio_blocks src/algorithms/channel/adapters @@ -85,7 +85,10 @@ project : requirements $GNURADIO_ROOT/gnuradio-core/src/lib/general $GNURADIO_ROOT/gnuradio-core/src/lib/gengen $GNURADIO_ROOT/gr-uhd/include -$GNURADIO_ROOT/volk/lib +$GNURADIO_ROOT/gr-blocks/include +$GNURADIO_ROOT/gr-fft/include +$GNURADIO_ROOT/gr-filter/include +#$GNURADIO_ROOT/volk/lib $OSMOSDR_ROOT/include/osmosdr $(GTEST_DIR)/include multi diff --git a/src/algorithms/PVT/libs/gps_l1_ca_ls_pvt.cc b/src/algorithms/PVT/libs/gps_l1_ca_ls_pvt.cc index d11c255aa..b8b509a54 100644 --- a/src/algorithms/PVT/libs/gps_l1_ca_ls_pvt.cc +++ b/src/algorithms/PVT/libs/gps_l1_ca_ls_pvt.cc @@ -588,7 +588,7 @@ void gps_l1_ca_ls_pvt::togeod(double *dphi, double *dlambda, double *h, double a } if (i == (maxit-1)) { - DLOG(INFO) << "The computation of geodetic coordinates did not converged" << std::endl; + DLOG(INFO) << "The computation of geodetic coordinates did not converge"; } } *dphi = (*dphi) * rtd; diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc index 3dc5f0bfe..08aa92d28 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc @@ -37,10 +37,6 @@ #include #include #include -#include -#include -#include -#include #include #include @@ -86,8 +82,9 @@ GalileoE1PcpsAmbiguousAcquisition::GalileoE1PcpsAmbiguousAcquisition( acquisition_cc_ = pcps_make_acquisition_cc(sampled_ms_, shift_resolution_, if_, fs_in_, samples_per_ms, queue_, dump_, dump_filename_); - stream_to_vector_ = gr_make_stream_to_vector(item_size_, - vector_length_); + //stream_to_vector_ = gr_make_stream_to_vector(item_size_, + // vector_length_); + stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); DLOG(INFO) << "stream_to_vector(" << stream_to_vector_->unique_id() << ")"; DLOG(INFO) << "acquisition(" << acquisition_cc_->unique_id() diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.h index 663cec539..d98dcb9f5 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.h @@ -37,6 +37,7 @@ #include "acquisition_interface.h" #include "pcps_acquisition_cc.h" #include +#include class ConfigurationInterface; @@ -121,9 +122,7 @@ public: private: ConfigurationInterface* configuration_; pcps_acquisition_cc_sptr acquisition_cc_; - gr_block_sptr stream_to_vector_; - gr_block_sptr complex_to_short_; - gr_block_sptr short_to_complex_; + gr::blocks::stream_to_vector::sptr stream_to_vector_; size_t item_size_; std::string item_type_; unsigned int vector_length_; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc index ae0ae27fe..256a46a4b 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc @@ -38,10 +38,6 @@ #include "configuration_interface.h" #include #include -#include -#include -#include -#include #include #include @@ -83,8 +79,9 @@ GpsL1CaPcpsAcquisition::GpsL1CaPcpsAcquisition( acquisition_cc_ = pcps_make_acquisition_cc(sampled_ms_, shift_resolution_, if_, fs_in_, vector_length_, queue_, dump_, dump_filename_); - stream_to_vector_ = gr_make_stream_to_vector(item_size_, - vector_length_); + + stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); + DLOG(INFO) << "stream_to_vector(" << stream_to_vector_->unique_id() << ")"; DLOG(INFO) << "acquisition(" << acquisition_cc_->unique_id() diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.h index b168cfd9c..85bf9b775 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.h @@ -39,6 +39,8 @@ #include "acquisition_interface.h" #include "pcps_acquisition_cc.h" #include +#include + class ConfigurationInterface; @@ -122,9 +124,7 @@ public: private: pcps_acquisition_cc_sptr acquisition_cc_; - gr_block_sptr stream_to_vector_; - gr_block_sptr complex_to_short_; - gr_block_sptr short_to_complex_; + gr::blocks::stream_to_vector::sptr stream_to_vector_; size_t item_size_; std::string item_type_; unsigned int vector_length_; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.cc index 59db86b9d..f9423d8aa 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.cc @@ -80,10 +80,10 @@ pcps_acquisition_cc::pcps_acquisition_cc( if (posix_memalign((void**)&d_fft_codes, 16, d_fft_size * sizeof(gr_complex)) == 0){}; // Direct FFT - d_fft_if = new gri_fft_complex(d_fft_size, true); + d_fft_if = new gr::fft::fft_complex(d_fft_size, true); // Inverse FFT - d_ifft = new gri_fft_complex(d_fft_size, false); + d_ifft = new gr::fft::fft_complex(d_fft_size, false); // For dumping samples into a file d_dump = dump; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.h index fbe8935f3..35ab86a5b 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.h @@ -53,7 +53,7 @@ #include #include #include -#include +#include #include #include #include @@ -72,137 +72,138 @@ pcps_make_acquisition_cc(unsigned int sampled_ms, * \brief This class implements a Parallel Code Phase Search Acquisition */ -class pcps_acquisition_cc: public gr_block { +class pcps_acquisition_cc: public gr_block +{ private: - friend pcps_acquisition_cc_sptr - pcps_make_acquisition_cc(unsigned int sampled_ms, - unsigned int doppler_max, long freq, long fs_in, - int samples_per_ms, gr_msg_queue_sptr queue, bool dump, - std::string dump_filename); + friend pcps_acquisition_cc_sptr + pcps_make_acquisition_cc(unsigned int sampled_ms, + unsigned int doppler_max, long freq, long fs_in, + int samples_per_ms, gr_msg_queue_sptr queue, bool dump, + std::string dump_filename); - pcps_acquisition_cc(unsigned int sampled_ms, - unsigned int doppler_max, long freq, long fs_in, - int samples_per_ms, gr_msg_queue_sptr queue, bool dump, - std::string dump_filename); + pcps_acquisition_cc(unsigned int sampled_ms, + unsigned int doppler_max, long freq, long fs_in, + int samples_per_ms, gr_msg_queue_sptr queue, bool dump, + std::string dump_filename); - void calculate_magnitudes(gr_complex* fft_begin, int doppler_shift, - int doppler_offset); + void calculate_magnitudes(gr_complex* fft_begin, int doppler_shift, + int doppler_offset); - long d_fs_in; - long d_freq; - int d_samples_per_ms; - unsigned int d_doppler_resolution; - float d_threshold; - std::string d_satellite_str; - unsigned int d_doppler_max; - unsigned int d_doppler_step; - unsigned int d_sampled_ms; - unsigned int d_fft_size; - unsigned long int d_sample_counter; - gr_complex* d_carrier; - gr_complex* d_fft_codes; - gri_fft_complex* d_fft_if; - gri_fft_complex* d_ifft; - Gnss_Synchro *d_gnss_synchro; - unsigned int d_code_phase; - float d_doppler_freq; - float d_mag; - float d_input_power; - float d_test_statistics; - gr_msg_queue_sptr d_queue; - concurrent_queue *d_channel_internal_queue; - std::ofstream d_dump_file; - bool d_active; - bool d_dump; - unsigned int d_channel; - std::string d_dump_filename; + long d_fs_in; + long d_freq; + int d_samples_per_ms; + unsigned int d_doppler_resolution; + float d_threshold; + std::string d_satellite_str; + unsigned int d_doppler_max; + unsigned int d_doppler_step; + unsigned int d_sampled_ms; + unsigned int d_fft_size; + unsigned long int d_sample_counter; + gr_complex* d_carrier; + gr_complex* d_fft_codes; + gr::fft::fft_complex* d_fft_if; + gr::fft::fft_complex* d_ifft; + Gnss_Synchro *d_gnss_synchro; + unsigned int d_code_phase; + float d_doppler_freq; + float d_mag; + float d_input_power; + float d_test_statistics; + gr_msg_queue_sptr d_queue; + concurrent_queue *d_channel_internal_queue; + std::ofstream d_dump_file; + bool d_active; + bool d_dump; + unsigned int d_channel; + std::string d_dump_filename; public: - /*! - * \brief Default destructor - */ - ~pcps_acquisition_cc(); + /*! + * \brief Default destructor + */ + ~pcps_acquisition_cc(); - /*! - * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to exchange synchronization data between acquisition and tracking blocks - */ - void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) - { - d_gnss_synchro = p_gnss_synchro; - } + /*! + * \brief Set acquisition/tracking common Gnss_Synchro object pointer + * to exchange synchronization data between acquisition and tracking blocks + */ + void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) + { + d_gnss_synchro = p_gnss_synchro; + } - /*! - * \brief Returns the maximum peak of grid search - */ - unsigned int mag() - { - return d_mag; - } + /*! + * \brief Returns the maximum peak of grid search + */ + unsigned int mag() + { + return d_mag; + } - /*! - * \brief Initializes acquisition algorithm. - */ - void init(); + /*! + * \brief Initializes acquisition algorithm. + */ + void init(); - /*! - * \brief Sets local code for PCPS acquisition algorithm. - */ - void set_local_code(std::complex * code); + /*! + * \brief Sets local code for PCPS acquisition algorithm. + */ + void set_local_code(std::complex * code); - /*! - * \brief Starts acquisition algorithm, turning from standby mode to - * active mode - */ - void set_active(bool active) - { - d_active = active; - } + /*! + * \brief Starts acquisition algorithm, turning from standby mode to + * active mode + */ + void set_active(bool active) + { + d_active = active; + } - /*! - * \brief Set acquisition channel unique ID - */ - void set_channel(unsigned int channel) - { - d_channel = channel; - } + /*! + * \brief Set acquisition channel unique ID + */ + void set_channel(unsigned int channel) + { + d_channel = channel; + } - /*! - * \brief Set statistics threshold of PCPS algorithm - */ - void set_threshold(float threshold) - { - d_threshold = threshold; - } + /*! + * \brief Set statistics threshold of PCPS algorithm + */ + void set_threshold(float threshold) + { + d_threshold = threshold; + } - /*! - * \brief Set maximum Doppler off grid search - */ - void set_doppler_max(unsigned int doppler_max) - { - d_doppler_max = doppler_max; - } + /*! + * \brief Set maximum Doppler off grid search + */ + void set_doppler_max(unsigned int doppler_max) + { + d_doppler_max = doppler_max; + } - /*! - * \brief Set Doppler steps for the grid search - */ - void set_doppler_step(unsigned int doppler_step) - { - d_doppler_step = doppler_step; - } + /*! + * \brief Set Doppler steps for the grid search + */ + void set_doppler_step(unsigned int doppler_step) + { + d_doppler_step = doppler_step; + } - /*! - * \brief Set tracking channel internal queue - */ - void set_channel_queue(concurrent_queue *channel_internal_queue) - { - d_channel_internal_queue = channel_internal_queue; - } + /*! + * \brief Set tracking channel internal queue + */ + void set_channel_queue(concurrent_queue *channel_internal_queue) + { + d_channel_internal_queue = channel_internal_queue; + } - int general_work(int noutput_items, gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_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); }; #endif /* GNSS_SDR_PCPS_ACQUISITION_CC_H_*/ diff --git a/src/algorithms/channel/libs/gps_l1_ca_channel_fsm.cc b/src/algorithms/channel/libs/gps_l1_ca_channel_fsm.cc index a75eeea1b..7e0959ad7 100644 --- a/src/algorithms/channel/libs/gps_l1_ca_channel_fsm.cc +++ b/src/algorithms/channel/libs/gps_l1_ca_channel_fsm.cc @@ -69,7 +69,7 @@ public: }; struct gps_channel_acquiring_fsm_S1: public sc::state< - gps_channel_acquiring_fsm_S1, GpsL1CaChannelFsm> { +gps_channel_acquiring_fsm_S1, GpsL1CaChannelFsm> { public: typedef mpl::list, sc::transition< Ev_gps_channel_valid_acquisition, gps_channel_tracking_fsm_S2> > - reactions; + reactions; gps_channel_acquiring_fsm_S1(my_context ctx) : my_base(ctx) { diff --git a/src/algorithms/data_type_adapter/adapters/ishort_to_complex.cc b/src/algorithms/data_type_adapter/adapters/ishort_to_complex.cc index 9bd837afd..a406320b7 100644 --- a/src/algorithms/data_type_adapter/adapters/ishort_to_complex.cc +++ b/src/algorithms/data_type_adapter/adapters/ishort_to_complex.cc @@ -29,7 +29,6 @@ */ #include "ishort_to_complex.h" -#include #include "configuration_interface.h" #include #include @@ -60,7 +59,8 @@ IshortToComplex::IshortToComplex(ConfigurationInterface* configuration, std::str size_t item_size=sizeof(gr_complex); - gr_interleaved_short_to_complex_ = gr_make_interleaved_short_to_complex(); + gr_interleaved_short_to_complex_ = gr::blocks::interleaved_short_to_complex::make(); + DLOG(INFO) << "data_type_adapter_(" << gr_interleaved_short_to_complex_->unique_id() << ")"; if (dump_) diff --git a/src/algorithms/data_type_adapter/adapters/ishort_to_complex.h b/src/algorithms/data_type_adapter/adapters/ishort_to_complex.h index 93e68b1ec..dccd75538 100644 --- a/src/algorithms/data_type_adapter/adapters/ishort_to_complex.h +++ b/src/algorithms/data_type_adapter/adapters/ishort_to_complex.h @@ -33,7 +33,7 @@ #include "gnss_synchro.h" #include "gnss_block_interface.h" -#include +#include #include class ConfigurationInterface; @@ -70,7 +70,7 @@ public: gr_basic_block_sptr get_right_block(); private: - gr_interleaved_short_to_complex_sptr gr_interleaved_short_to_complex_; + gr::blocks::interleaved_short_to_complex::sptr gr_interleaved_short_to_complex_; ConfigurationInterface* config_; bool dump_; std::string dump_filename_; diff --git a/src/algorithms/input_filter/adapters/fir_filter.cc b/src/algorithms/input_filter/adapters/fir_filter.cc index 302c33240..b9dff6675 100644 --- a/src/algorithms/input_filter/adapters/fir_filter.cc +++ b/src/algorithms/input_filter/adapters/fir_filter.cc @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include @@ -52,7 +52,7 @@ FirFilter::FirFilter(ConfigurationInterface* configuration, std::string role, && (output_item_type_.compare("gr_complex") == 0)) { item_size = sizeof(gr_complex); - fir_filter_ccf_ = gr_make_fir_filter_ccf(1, taps_); + fir_filter_ccf_ = gr::filter::fir_filter_ccf::make(1, taps_); DLOG(INFO) << "input_filter(" << fir_filter_ccf_->unique_id() << ")"; } else @@ -165,11 +165,11 @@ void FirFilter::init() std::string filter_type = config_->property(role_ + ".filter_type", default_filter_type); int grid_density = config_->property(role_ + ".grid_density", default_grid_density); - // gr_remez implements the Parks-McClellan FIR filter design. + // pm_remez implements the Parks-McClellan FIR filter design. // It calculates the optimal (in the Chebyshev/minimax sense) FIR filter // impulse response given a set of band edges, the desired response on // those bands, and the weight given to the error in those bands. - std::vector taps_d = gr_remez(number_of_taps - 1, bands, ampl, error_w, filter_type, grid_density); + std::vector taps_d = gr::filter::pm_remez(number_of_taps - 1, bands, ampl, error_w, filter_type, grid_density); taps_.reserve(taps_d.size()); for (std::vector::iterator it = taps_d.begin(); it != taps_d.end(); it++) { diff --git a/src/algorithms/input_filter/adapters/fir_filter.h b/src/algorithms/input_filter/adapters/fir_filter.h index d8073515e..988ba95e3 100644 --- a/src/algorithms/input_filter/adapters/fir_filter.h +++ b/src/algorithms/input_filter/adapters/fir_filter.h @@ -1,6 +1,6 @@ /*! * \file fir_filter.h - * \brief Adapts a gnuradio gr_fir_filter designed with gr_remez + * \brief Adapts a gnuradio gr_fir_filter designed with pm_remez * \author Luis Esteve, 2012. luis(at)epsilon-formacion.com * * Detailed description of the file here if needed. @@ -35,18 +35,13 @@ #include "gnss_synchro.h" #include "gnss_block_interface.h" -#include -#include -#include -#include -#include -#include +#include #include class ConfigurationInterface; /*! - * \brief This class adapts a GNU Radio gr_fir_filter designed with gr_remez + * \brief This class adapts a GNU Radio gr_fir_filter designed with pm_remez * * See Parks-McClellan FIR filter design, http://en.wikipedia.org/wiki/Parks-McClellan_filter_design_algorithm * Calculates the optimal (in the Chebyshev/minimax sense) FIR filter impulse response @@ -79,7 +74,7 @@ public: gr_basic_block_sptr get_right_block(); private: - gr_fir_filter_ccf_sptr fir_filter_ccf_; + gr::filter::fir_filter_ccf::sptr fir_filter_ccf_; ConfigurationInterface* config_; bool dump_; std::string dump_filename_; diff --git a/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc b/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc index efa5432e7..e9b42e53f 100644 --- a/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc +++ b/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include @@ -56,7 +56,7 @@ FreqXlatingFirFilter::FreqXlatingFirFilter(ConfigurationInterface* configuration && (output_item_type_.compare("gr_complex") == 0)) { item_size = sizeof(gr_complex); - freq_xlating_fir_filter_ccf_ = gr_make_freq_xlating_fir_filter_ccf(decimation_factor, taps_, intermediate_freq_, sampling_freq_); + freq_xlating_fir_filter_ccf_ = gr::filter::freq_xlating_fir_filter_ccf::make(decimation_factor, taps_, intermediate_freq_, sampling_freq_); DLOG(INFO) << "input_filter(" << freq_xlating_fir_filter_ccf_->unique_id() << ")"; } else @@ -172,8 +172,10 @@ void FreqXlatingFirFilter::init() std::string filter_type = config_->property(role_ + ".filter_type", default_filter_type); int grid_density = config_->property(role_ + ".grid_density", default_grid_density); - std::vector taps_d = gr_remez(number_of_taps - 1, bands, ampl, - error_w, filter_type, grid_density); + + std::vector taps_d = gr::filter::pm_remez(number_of_taps - 1, bands, ampl, + error_w, filter_type, grid_density); + taps_.reserve(taps_d.size()); for (std::vector::iterator it = taps_d.begin(); it != taps_d.end(); it++) { diff --git a/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.h b/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.h index 7840e77cb..1a2173401 100644 --- a/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.h +++ b/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.h @@ -35,16 +35,13 @@ #include "gnss_synchro.h" #include "gnss_block_interface.h" -#include -#include -#include -#include +#include #include class ConfigurationInterface; /*! - * \brief This class adapts a gnuradio gr_freq_xlating_fir_filter designed with gr_remez + * \brief This class adapts a gnuradio gr_freq_xlating_fir_filter designed with pm_remez * * Construct a FIR filter with the given taps and a composite frequency * translation that shifts intermediate_freq_ down to zero Hz. The frequency @@ -81,7 +78,7 @@ public: gr_basic_block_sptr get_right_block(); private: - gr_freq_xlating_fir_filter_ccf_sptr freq_xlating_fir_filter_ccf_; + gr::filter::freq_xlating_fir_filter_ccf::sptr freq_xlating_fir_filter_ccf_; ConfigurationInterface* config_; bool dump_; std::string dump_filename_; diff --git a/src/algorithms/libs/nco_lib.h b/src/algorithms/libs/nco_lib.h index 934f8bc94..1ff7d02a6 100644 --- a/src/algorithms/libs/nco_lib.h +++ b/src/algorithms/libs/nco_lib.h @@ -38,8 +38,8 @@ * */ -#ifndef NCO_LIB_CC_H -#define NCO_LIB_CC_H +#ifndef GNSS_SDR_NCO_LIB_CC_H_ +#define GNSS_SDR_NCO_LIB_CC_H_ #include #include diff --git a/src/algorithms/observables/adapters/gps_l1_ca_observables.cc b/src/algorithms/observables/adapters/gps_l1_ca_observables.cc index 7ddba8fdd..27eb94a4b 100644 --- a/src/algorithms/observables/adapters/gps_l1_ca_observables.cc +++ b/src/algorithms/observables/adapters/gps_l1_ca_observables.cc @@ -34,8 +34,8 @@ #include "configuration_interface.h" #include "gps_l1_ca_observables_cc.h" #include -#include -#include +//#include +//#include #include #include 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 ce133a755..aeeb7ba09 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 @@ -182,7 +182,7 @@ int gps_l1_ca_observables_cc::general_work (int noutput_items, gr_vector_int &ni current_gnss_synchro[i].Pseudorange_symbol_shift = 0.0; } /* - * 2. Compute RAW pseudorranges: Use only the valid channels (channels that are tracking a satellite) + * 2. Compute RAW pseudoranges: Use only the valid channels (channels that are tracking a satellite) */ if(current_gnss_synchro_map.size() > 0 and flag_history_ok == true) { @@ -219,18 +219,18 @@ int gps_l1_ca_observables_cc::general_work (int noutput_items, gr_vector_int &ni if (reference_channel != gnss_synchro_iter->second.Channel_ID) { // compute the required symbol history shift in order to match the reference symbol - history_shift = gnss_synchro_iter->second.Preamble_symbol_counter-current_symbol; + history_shift = gnss_synchro_iter->second.Preamble_symbol_counter - current_symbol; if (history_shift < (int)MAX_TOA_DELAY_MS ) // and history_shift>=0) { tmp_gnss_synchro= d_history_gnss_synchro_deque[gnss_synchro_iter->second.Channel_ID][history_shift]; - gnss_synchro_aligned_map.insert(std::pair(gnss_synchro_iter->second.Channel_ID,tmp_gnss_synchro)); + gnss_synchro_aligned_map.insert(std::pair(gnss_synchro_iter->second.Channel_ID, tmp_gnss_synchro)); } } } } /* - * 3 Compute the pseudorranges using the aligned data map + * 3 Compute the pseudoranges using the aligned data map */ double min_symbol_timestamp_ms; double max_symbol_timestamp_ms; diff --git a/src/algorithms/signal_source/adapters/file_signal_source.cc b/src/algorithms/signal_source/adapters/file_signal_source.cc index b8df8f524..29a386794 100644 --- a/src/algorithms/signal_source/adapters/file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/file_signal_source.cc @@ -46,132 +46,139 @@ using google::LogMessage; DEFINE_string(signal_source, "-", - "If defined, path to the file containing the signal samples (overrides the configuration file)"); + "If defined, path to the file containing the signal samples (overrides the configuration file)"); FileSignalSource::FileSignalSource(ConfigurationInterface* configuration, - std::string role, unsigned int in_streams, unsigned int out_streams, - gr_msg_queue_sptr queue) : - role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(queue) + std::string role, unsigned int in_streams, unsigned int out_streams, + gr_msg_queue_sptr queue) : + role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(queue) { + std::string default_filename = "../data/sc2_d16.dat"; + std::string default_item_type = "short"; + std::string default_dump_filename = "../data/sc2_d16.dat"; - std::string default_filename = "../data/sc2_d16.dat"; - std::string default_item_type = "short"; - std::string default_dump_filename = "../data/sc2_d16.dat"; + samples_ = configuration->property(role + ".samples", 0); + sampling_frequency_ = configuration->property(role + ".sampling_frequency", 0); + filename_ = configuration->property(role + ".filename", default_filename); - samples_ = configuration->property(role + ".samples", 0); - sampling_frequency_ = configuration->property(role + ".sampling_frequency", 0); - filename_ = configuration->property(role + ".filename", default_filename); + // override value with commandline flag, if present + if (FLAGS_signal_source.compare("-") != 0) filename_= FLAGS_signal_source; - // override value with commandline flag, if present - if (FLAGS_signal_source.compare("-") != 0) filename_= FLAGS_signal_source; + item_type_ = configuration->property(role + ".item_type", default_item_type); + repeat_ = configuration->property(role + ".repeat", false); + dump_ = configuration->property(role + ".dump", false); + dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename); + enable_throttle_control_ = configuration->property(role + ".enable_throttle_control", false); - item_type_ = configuration->property(role + ".item_type", default_item_type); - repeat_ = configuration->property(role + ".repeat", false); - dump_ = configuration->property(role + ".dump", false); - dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename); - enable_throttle_control_ = configuration->property(role + ".enable_throttle_control", false); + if (item_type_.compare("gr_complex") == 0) + { + item_size_ = sizeof(gr_complex); + } + else if (item_type_.compare("float") == 0) + { + item_size_ = sizeof(float); + } + else if (item_type_.compare("short") == 0) + { + item_size_ = sizeof(short int); + } + else + { + LOG_AT_LEVEL(WARNING) << item_type_ + << " unrecognized item type. Using gr_complex."; + item_size_ = sizeof(gr_complex); + } + try + { + file_source_ = gr_make_file_source(item_size_, filename_.c_str(), repeat_); + } + catch (const std::exception &e) + { + std::cerr + << "The receiver was configured to work with a file signal source " + << std::endl + << "but the specified file is unreachable by GNSS-SDR." + << std::endl + << "Please modify the configuration at " + << "conf/gnss-sdr.conf (the default configuration file)" + << std::endl + << "and point SignalSource.filename to a valid file," + << std::endl + << "or specify your own receiver and source with the flag" + << std::endl + <<"gnss-sdr --config_file=my_GNSS_SDR_configuration.conf" + << std::endl; + LOG_AT_LEVEL(INFO) << "file_signal_source: Unable to open the samples file " + << filename_.c_str() << ", exiting the program."; + throw(e); + } - if (item_type_.compare("gr_complex") == 0) - { - item_size_ = sizeof(gr_complex); - } - else if (item_type_.compare("float") == 0) - { - item_size_ = sizeof(float); - } - else if (item_type_.compare("short") == 0) - { - item_size_ = sizeof(short int); - } - else - { - LOG_AT_LEVEL(WARNING) << item_type_ - << " unrecognized item type. Using gr_complex."; - item_size_ = sizeof(gr_complex); - } - try - { - file_source_ = gr_make_file_source(item_size_, filename_.c_str(), repeat_); - } - catch (const std::exception &e) - { - std::cerr - << "The receiver was configured to work with a file signal source " - << std::endl - << "but the specified file is unreachable by GNSS-SDR." - << std::endl - << "Please modify the configuration at " - << "conf/gnss-sdr.conf (the default configuration file)" - << std::endl - << "and point SignalSource.filename to a valid file," - << std::endl - << "or specify your own receiver and source with the flag" - << std::endl - <<"gnss-sdr --config_file=my_GNSS_SDR_configuration.conf" - << std::endl; - LOG_AT_LEVEL(INFO) << "file_signal_source: Unable to open the samples file " - << filename_.c_str() << ", exiting the program."; - throw(e); - } + DLOG(INFO) << "file_source(" << file_source_->unique_id() << ")"; - DLOG(INFO) << "file_source(" << file_source_->unique_id() << ")"; + if (samples_ == 0) // read all file + { + /*! + * BUG workaround: The GNURadio file source does not stop the receiver after reaching the End of File. + * A possible solution is to compute the file length in samples using file size, excluding the last 100 milliseconds, and enable always the + * valve block + */ + std::ifstream file (filename_.c_str(), std::ios::in | std::ios::binary | std::ios::ate); + std::ifstream::pos_type size; + if (file.is_open()) + { + size = file.tellg(); + } + else + { + std::cout << "file_signal_source: Unable to open the samples file " << filename_.c_str() << std::endl; + LOG_AT_LEVEL(ERROR) << "file_signal_source: Unable to open the samples file " << filename_.c_str(); + } + std::cout << std::setprecision(16); + std::cout << "Processing file " << filename_ << ", which contains " << (double)size << " [bytes]" << std::endl; + if (size > 0) + { + samples_ = floor((double)size / (double)item_size()) - ceil(0.1 * (double)sampling_frequency_); //process all the samples available in the file excluding the last 100 ms + } + } + CHECK(samples_ > 0) << "File does not contain enough samples to process."; + double signal_duration_s; + signal_duration_s = (double)samples_ * ( 1 /(double)sampling_frequency_); + DLOG(INFO) << "Total samples to be processed= " << samples_ << " GNSS signal duration= " << signal_duration_s << " [s]"; + std::cout << "GNSS signal recorded time to be processed: " << signal_duration_s << " [s]" << std::endl; + // if samples_ > 0 then enable a flow valve to stop the process after n samples + //if (samples_ > 0) + //{ + valve_ = gnss_sdr_make_valve(item_size_, samples_, queue_); + DLOG(INFO) << "valve(" << valve_->unique_id() << ")"; + //} + //else + //{ + // std::cout << "Not enough samples to process." << std::endl; + // here we should exit the program + //throw; + //LOG(FATAL) - if (samples_ == 0) - { - /*! - * BUG workaround: The GNURadio file source does not stop the receiver after reaching the End of File. - * A possible solution is to compute the file length in samples using file size, excluding the last 100 milliseconds, and enable always the - * valve block - */ - std::ifstream file (filename_.c_str(), std::ios::in | std::ios::binary | std::ios::ate); - std::ifstream::pos_type size; - if (file.is_open()) - { - size = file.tellg(); - } - else - { - std::cout << "file_signal_source: Unable to open the samples file " << filename_.c_str() << std::endl; - LOG_AT_LEVEL(ERROR) << "file_signal_source: Unable to open the samples file " << filename_.c_str(); - } - std::cout << std::setprecision(16); - std::cout <<"Processing file " << filename_ << ", which contains " << (double)size << " [bytes]" << std::endl; - if (size > 0) - { - samples_ = floor((double)size / (double)item_size()) - ceil(0.1 * (double)sampling_frequency_); //process all the samples available in the file excluding the last 100 ms + //} - } - } - double signal_duration_s; - signal_duration_s = (double)samples_ * ( 1 /(double)sampling_frequency_); - DLOG(INFO) << "Total samples to be processed= "<< samples_ << " GNSS signal duration= " << signal_duration_s << " [s]"; - std::cout << "GNSS signal recorded time to be processed: " << signal_duration_s << " [s]" << std::endl; - // if samples != 0 then enable a flow valve to stop the process after n samples - if (samples_ != 0) - { - valve_ = gnss_sdr_make_valve(item_size_, samples_, queue_); - DLOG(INFO) << "valve(" << valve_->unique_id() << ")"; - } + if (dump_) + { + sink_ = gr_make_file_sink(item_size_, dump_filename_.c_str()); + DLOG(INFO) << "file_sink(" << sink_->unique_id() << ")"; + } - if (dump_) - { - sink_ = gr_make_file_sink(item_size_, dump_filename_.c_str()); - DLOG(INFO) << "file_sink(" << sink_->unique_id() << ")"; - } - - if (enable_throttle_control_) - { - throttle_ = gr_make_throttle(item_size_, sampling_frequency_); - } - DLOG(INFO) << "File source filename " << filename_; - DLOG(INFO) << "Samples " << samples_; - DLOG(INFO) << "Sampling frequency " << sampling_frequency_; - DLOG(INFO) << "Item type " << item_type_; - DLOG(INFO) << "Item size " << item_size_; - DLOG(INFO) << "Repeat " << repeat_; - DLOG(INFO) << "Dump " << dump_; - DLOG(INFO) << "Dump filename " << dump_filename_; + if (enable_throttle_control_) + { + throttle_ = gr_make_throttle(item_size_, sampling_frequency_); + } + DLOG(INFO) << "File source filename " << filename_; + DLOG(INFO) << "Samples " << samples_; + DLOG(INFO) << "Sampling frequency " << sampling_frequency_; + DLOG(INFO) << "Item type " << item_type_; + DLOG(INFO) << "Item size " << item_size_; + DLOG(INFO) << "Repeat " << repeat_; + DLOG(INFO) << "Dump " << dump_; + DLOG(INFO) << "Dump filename " << dump_filename_; } @@ -185,7 +192,7 @@ FileSignalSource::~FileSignalSource() void FileSignalSource::connect(gr_top_block_sptr top_block) { - if (samples_ != 0) + if (samples_ > 0) { if (enable_throttle_control_ == true) { @@ -240,7 +247,7 @@ void FileSignalSource::connect(gr_top_block_sptr top_block) void FileSignalSource::disconnect(gr_top_block_sptr top_block) { - if (samples_ != 0) + if (samples_ > 0) { if (enable_throttle_control_ == true) { @@ -305,7 +312,7 @@ gr_basic_block_sptr FileSignalSource::get_left_block() gr_basic_block_sptr FileSignalSource::get_right_block() { - if (samples_ != 0) + if (samples_ > 0) { return valve_; } diff --git a/src/algorithms/telemetry_decoder/adapters/gps_l1_ca_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/gps_l1_ca_telemetry_decoder.cc index 63f737880..7c83e218c 100644 --- a/src/algorithms/telemetry_decoder/adapters/gps_l1_ca_telemetry_decoder.cc +++ b/src/algorithms/telemetry_decoder/adapters/gps_l1_ca_telemetry_decoder.cc @@ -34,8 +34,8 @@ #include "configuration_interface.h" #include "gps_l1_ca_telemetry_decoder_cc.h" #include -#include -#include +//#include +//#include #include #include diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc index 7590c55a3..fca03653b 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc @@ -191,7 +191,8 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_i corr_value += d_preambles_symbols[i]; } } - d_flag_preamble=false; + d_flag_preamble = false; + //******* frame sync ****************** if (abs(corr_value) >= 160) { @@ -206,7 +207,7 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_i d_frame_bit_index = 8; d_stat = 1; // enter into frame pre-detection status } - else if (d_stat == 1) //check 6 seconds of preample separation + else if (d_stat == 1) //check 6 seconds of preamble separation { preamble_diff = abs(d_sample_counter - d_preamble_index); if (abs(preamble_diff - 6000) < 1) @@ -238,6 +239,7 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_i } } } + //******* SYMBOL TO BIT ******* d_symbol_accumulator += in[0][d_samples_per_bit*8 - 1].Prompt_I; // accumulate the input value in d_symbol_accumulator d_symbol_accumulator_counter++; @@ -245,7 +247,7 @@ int gps_l1_ca_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_i { if (d_symbol_accumulator > 0) { //symbol to bit - d_GPS_frame_4bytes +=1; //insert the telemetry bit in LSB + d_GPS_frame_4bytes += 1; //insert the telemetry bit in LSB } d_symbol_accumulator = 0; d_symbol_accumulator_counter = 0; diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.cc index 5e8ea0e57..340f42336 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.cc @@ -275,8 +275,8 @@ void Gps_L1_Ca_Dll_Pll_Tracking_cc::update_local_code() tcode_chips = -rem_code_phase_chips; // Alternative EPL code generation (40% of speed improvement!) - early_late_spc_samples=round(d_early_late_spc_chips/code_phase_step_chips); - epl_loop_length_samples=d_current_prn_length_samples+early_late_spc_samples*2; + early_late_spc_samples = round(d_early_late_spc_chips / code_phase_step_chips); + epl_loop_length_samples = d_current_prn_length_samples + early_late_spc_samples*2; for (int i=0; i *cha d_channel_internal_queue = channel_internal_queue; } + void Gps_L1_Ca_Dll_Pll_Tracking_cc::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) { d_acquisition_gnss_synchro = p_gnss_synchro; - - // Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - //DLOG(INFO) << "Tracking code phase set to " << d_acq_code_phase_samples; - //DLOG(INFO) << "Tracking carrier doppler set to " << d_acq_carrier_doppler_hz; - //DLOG(INFO) << "Tracking Satellite set to " << d_satellite; - }