diff --git a/conf/gnss-sdr-kalman-bayes.conf b/conf/gnss-sdr-L1-gaussian.conf similarity index 97% rename from conf/gnss-sdr-kalman-bayes.conf rename to conf/gnss-sdr-L1-gaussian.conf index bc6cbf631..a208366e5 100644 --- a/conf/gnss-sdr-kalman-bayes.conf +++ b/conf/gnss-sdr-L1-gaussian.conf @@ -42,7 +42,7 @@ Acquisition_1C.dump=false Acquisition_1C.dump_filename=../data/kalman/acq_dump ;######### TRACKING GLOBAL CONFIG ############ -Tracking_1C.implementation=GPS_L1_CA_KF_Tracking +Tracking_1C.implementation=GPS_L1_CA_Gaussian_Tracking Tracking_1C.item_type=gr_complex Tracking_1C.pll_bw_hz=40.0; Tracking_1C.dll_bw_hz=4.0; diff --git a/conf/gnss-sdr_GPS_L1_nsr_kf.conf b/conf/gnss-sdr_GPS_L1_nsr_gauss.conf similarity index 99% rename from conf/gnss-sdr_GPS_L1_nsr_kf.conf rename to conf/gnss-sdr_GPS_L1_nsr_gauss.conf index 91015fc9b..a127a5870 100644 --- a/conf/gnss-sdr_GPS_L1_nsr_kf.conf +++ b/conf/gnss-sdr_GPS_L1_nsr_gauss.conf @@ -165,7 +165,7 @@ Acquisition_1C.doppler_step=100 ;######### TRACKING GPS CONFIG ############ -Tracking_1C.implementation=GPS_L1_CA_KF_Tracking +Tracking_1C.implementation=GPS_L1_CA_Gaussian_Tracking Tracking_1C.item_type=gr_complex Tracking_1C.if=0 Tracking_1C.dump=true diff --git a/conf/gnss-sdr_labsat_kf_vtl.conf b/conf/gnss-sdr_labsat_kf.conf similarity index 78% rename from conf/gnss-sdr_labsat_kf_vtl.conf rename to conf/gnss-sdr_labsat_kf.conf index b5f8ce879..31787abab 100644 --- a/conf/gnss-sdr_labsat_kf_vtl.conf +++ b/conf/gnss-sdr_labsat_kf.conf @@ -7,7 +7,6 @@ ;######### GLOBAL OPTIONS ################## GNSS-SDR.internal_fs_sps=5456000 -;GNSS-SDR.internal_fs_sps=16368000 GNSS-SDR.use_acquisition_resampler=true ;######### SIGNAL_SOURCE CONFIG ############ @@ -17,9 +16,7 @@ SignalSource.selected_channel=1 ;# Labsat sile source automatically increments the file name when the signal is split in several files ;# the adapter adds "_0000.LS3" to this base path and filename. Next file will be "_0001.LS3" and so on ;# in this example, the first file complete path will be ../signals/GPS_025_ -;SignalSource.filename=/media/javier/WDNASNTFS/satgen_30mins/output/output SignalSource.filename=/home/javier/signals/satgen_30mins/output/output -;SignalSource.filename=/home/javier/signals/dupli/dupli/dupli SignalSource.item_type=gr_complex SignalSource.sampling_frequency=16368000 SignalSource.samples=0 @@ -75,18 +72,6 @@ Channels_5X.count=0 Channels.in_acquisition=1 -;Channel0.satellite=3 - - -;#signal: -;# "1C" GPS L1 C/A -;# "1B" GALILEO E1 B (I/NAV OS/CS/SoL) -;# "1G" GLONASS L1 C/A -;# "2S" GPS L2 L2C (M) -;# "5X" GALILEO E5a I+Q -;# "L5" GPS L5 - - ;######### GPS ACQUISITION CONFIG ############ Acquisition_1C.implementation=GPS_L1_CA_PCPS_Acquisition Acquisition_1C.item_type=gr_complex @@ -112,49 +97,26 @@ Acquisition_1B.dump_filename=./acq_dump.dat ;######### TRACKING GPS CONFIG ############ -;Tracking_1C.implementation=GPS_L1_CA_DLL_PLL_Tracking -;Tracking_1C.item_type=gr_complex -;Tracking_1C.dump=false -;Tracking_1C.dump_filename=./tracking_ch_ -;Tracking_1C.pll_bw_hz=35.0; -;Tracking_1C.dll_bw_hz=1.5; -;Tracking_1C.pll_bw_narrow_hz=2.5; -;Tracking_1C.dll_bw_narrow_hz=0.2; -;Tracking_1C.extend_correlation_symbols=1; -;Tracking_1C.dll_filter_order=2; -;Tracking_1C.pll_filter_order=3; -;Tracking_1C.early_late_space_chips=0.5; -;Tracking_1C.early_late_space_narrow_chips=0.15 - -;### KF tracking -Tracking_1C.implementation=GPS_L1_CA_KF_VTL_Tracking +Tracking_1C.implementation=GPS_L1_CA_KF_Tracking Tracking_1C.item_type=gr_complex Tracking_1C.dump=true Tracking_1C.dump_filename=./tracking_ch_ -Tracking_1C.extend_correlation_symbols=1; +Tracking_1C.extend_correlation_symbols=20; Tracking_1C.early_late_space_chips=0.5; Tracking_1C.early_late_space_narrow_chips=0.15 -Tracking_1C.expected_cn0_dbhz=45.0; -Tracking_1C.enable_dynamic_measurement_covariance=false; -Tracking_1C.use_estimated_cn0=false; -Tracking_1C.carrier_aiding=true; +;Tracking_1C.code_disc_sd_chips=0.2; // Initial R +;Tracking_1C.carrier_disc_sd_rads=0.3; // Initial R +;Tracking_1C.init_code_phase_sd_chips=0.5; // Initial P_0_0 +;Tracking_1C.init_carrier_phase_sd_rad=0.7; +;Tracking_1C.init_carrier_freq_sd_hz=5; +;Tracking_1C.init_carrier_freq_rate_sd_hz_s=1; -Tracking_1C.code_phase_sd_chips=0.01; -Tracking_1C.code_rate_sd_chips_s=0.001; - -Tracking_1C.carrier_phase_sd_rad=0.001; -Tracking_1C.carrier_freq_sd_hz=0.01; -Tracking_1C.carrier_freq_rate_sd_hz_s=0.1; - - -Tracking_1C.init_code_phase_sd_chips=1; -Tracking_1C.init_code_rate_sd_chips_s=10; - -Tracking_1C.init_carrier_phase_sd_rad=1; -Tracking_1C.init_carrier_freq_sd_hz=10; -Tracking_1C.init_carrier_freq_rate_sd_hz_s=10; +;Tracking_1C.code_phase_sd_chips=0.15; // Initial Q +;Tracking_1C.carrier_phase_sd_rad=0.25; +;Tracking_1C.carrier_freq_sd_hz=0.6; +;Tracking_1C.carrier_freq_rate_sd_hz_s=0.01; ;######### TRACKING GALILEO CONFIG ############ @@ -221,5 +183,3 @@ Monitor.enable_monitor=false Monitor.decimation_factor=1 Monitor.client_addresses=127.0.0.1 Monitor.udp_port=1234 - - diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e93a5309e..96932a2d8 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -69,18 +69,19 @@ All notable changes to GNSS-SDR will be documented in this file. - Fixed large GLONASS velocity errors and the extended correlator when using the `GLONASS_L1_CA_DLL_PLL_C_Aid_Tracking` and `GLONASS_L2_CA_DLL_PLL_C_Aid_Tracking` implementations. -- Added a over-the-wire sample format (that is, the format used between the - device and the UHD) configuration parameter for the `UHD_Signal_Source`, thus - allowing to select the `sc8` format instead of the default `sc16`. This would - reduce the dynamic range and increase quantization noise, but also reduce the - load on the data link and thus allow more bandwidth. +- The `UHD_Signal_Source` learned a new parameter `otw_format` for setting the + [over-the-wire data format](https://files.ettus.com/manual/page_configuration.html#config_stream_args_otw_format) + (that is, the format used between the device and the UHD) in some devices, + thus allowing to select the `sc8` format instead of the default `sc16`. This + would reduce the dynamic range and increase quantization noise, but also + reduce the load on the data link and thus allow more bandwidth. +- The `UHD_Signal_Source` learned another two optional parameters: + `device_recv_frame_size` and `device_num_recv_frames` for overriding + [transport layer defaults](https://files.ettus.com/manual/page_transport.html). - Added gain setting and reading for the XTRX board when using the `Osmosdr_Signal_Source` implementation of a `SignalSource`. - The `Osmosdr_Signal_Source` implementation learned a new parameter `if_bw` to manually set the bandwidth of the bandpass filter on the radio frontend. -- The `UHD_Signal_Source` learned two new optional parameters - `device_recv_frame_size` and `device_num_recv_frames` for overriding - [transport layer defaults](https://files.ettus.com/manual/page_transport.html). - The new configuration parameter `Channels_XX.RF_channel_ID` allows to specify the signal source per channel group. - Allowed the CMake project to be a sub-project. diff --git a/src/algorithms/tracking/adapters/CMakeLists.txt b/src/algorithms/tracking/adapters/CMakeLists.txt index 863fcba8e..f37824a3e 100644 --- a/src/algorithms/tracking/adapters/CMakeLists.txt +++ b/src/algorithms/tracking/adapters/CMakeLists.txt @@ -45,13 +45,13 @@ set(TRACKING_ADAPTER_SOURCES gps_l2_m_dll_pll_tracking.cc glonass_l1_ca_dll_pll_tracking.cc glonass_l1_ca_dll_pll_c_aid_tracking.cc - gps_l1_ca_kf_tracking.cc + gps_l1_ca_gaussian_tracking.cc gps_l5_dll_pll_tracking.cc glonass_l2_ca_dll_pll_tracking.cc glonass_l2_ca_dll_pll_c_aid_tracking.cc beidou_b1i_dll_pll_tracking.cc beidou_b3i_dll_pll_tracking.cc - gps_l1_ca_kf_vtl_tracking.cc + gps_l1_ca_kf_tracking.cc ${OPT_TRACKING_ADAPTERS_SOURCES} ) @@ -66,13 +66,13 @@ set(TRACKING_ADAPTER_HEADERS gps_l2_m_dll_pll_tracking.h glonass_l1_ca_dll_pll_tracking.h glonass_l1_ca_dll_pll_c_aid_tracking.h - gps_l1_ca_kf_tracking.h + gps_l1_ca_gaussian_tracking.h gps_l5_dll_pll_tracking.h glonass_l2_ca_dll_pll_tracking.h glonass_l2_ca_dll_pll_c_aid_tracking.h beidou_b1i_dll_pll_tracking.h beidou_b3i_dll_pll_tracking.h - gps_l1_ca_kf_vtl_tracking.h + gps_l1_ca_kf_tracking.h ${OPT_TRACKING_ADAPTERS_HEADERS} ) diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_gaussian_tracking.cc b/src/algorithms/tracking/adapters/gps_l1_ca_gaussian_tracking.cc new file mode 100644 index 000000000..bedab47b4 --- /dev/null +++ b/src/algorithms/tracking/adapters/gps_l1_ca_gaussian_tracking.cc @@ -0,0 +1,154 @@ +/*! + * \file gps_l1_ca_gaussian_tracking.cc + * \brief Implementation of an adapter of a DLL + Kalman carrier + * tracking loop block for GPS L1 C/A signals + * \author Javier Arribas, 2018. jarribas(at)cttc.es + * \author Jordi Vila-Valls 2018. jvila(at)cttc.es + * \author Carles Fernandez-Prades 2018. cfernandez(at)cttc.es + * + * Reference: + * J. Vila-Valls, P. Closas, M. Navarro and C. Fernández-Prades, + * "Are PLLs Dead? A Tutorial on Kalman Filter-based Techniques for Digital + * Carrier Synchronization", IEEE Aerospace and Electronic Systems Magazine, + * Vol. 32, No. 7, pp. 28–45, July 2017. DOI: 10.1109/MAES.2017.150260 + * + * ----------------------------------------------------------------------------- + * + * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + * This file is part of GNSS-SDR. + * + * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * SPDX-License-Identifier: GPL-3.0-or-later + * + * ----------------------------------------------------------------------------- + */ + + +#include "gps_l1_ca_gaussian_tracking.h" +#include "GPS_L1_CA.h" +#include "configuration_interface.h" +#include "gnss_sdr_flags.h" +#include + + +GpsL1CaGaussianTracking::GpsL1CaGaussianTracking( + const ConfigurationInterface* configuration, const std::string& role, + unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) +{ + DLOG(INFO) << "role " << role; + // ################# CONFIGURATION PARAMETERS ######################## + const std::string default_item_type("gr_complex"); + std::string item_type = configuration->property(role + ".item_type", default_item_type); + int order = configuration->property(role + ".order", 2); + int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); + int fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + bool dump = configuration->property(role + ".dump", false); + float dll_bw_hz = configuration->property(role + ".dll_bw_hz", static_cast(2.0)); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } + float early_late_space_chips = configuration->property(role + ".early_late_space_chips", static_cast(0.5)); + const std::string default_dump_filename("./track_ch"); + std::string dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); + const auto vector_length = static_cast(std::round(fs_in / (GPS_L1_CA_CODE_RATE_CPS / GPS_L1_CA_CODE_LENGTH_CHIPS))); + + bool bce_run = configuration->property(role + ".bce_run", false); + unsigned int bce_ptrans = configuration->property(role + ".p_transient", 0); + unsigned int bce_strans = configuration->property(role + ".s_transient", 0); + int bce_nu = configuration->property(role + ".bce_nu", 0); + int bce_kappa = configuration->property(role + ".bce_kappa", 0); + + // ################# MAKE TRACKING GNURadio object ################### + if (item_type == "gr_complex") + { + item_size_ = sizeof(gr_complex); + tracking_ = gps_l1_ca_gaussian_make_tracking_cc( + order, + fs_in, + vector_length, + dump, + dump_filename, + dll_bw_hz, + early_late_space_chips, + bce_run, + bce_ptrans, + bce_strans, + bce_nu, + bce_kappa); + } + else + { + item_size_ = 0; + LOG(WARNING) << item_type << " unknown tracking item type."; + } + channel_ = 0; + DLOG(INFO) << "tracking(" << tracking_->unique_id() << ")"; + if (in_streams_ == 0) + { + in_streams_ = 1; + // Avoid compiler warning + } + if (out_streams_ == 0) + { + out_streams_ = 1; + // Avoid compiler warning + } +} + + +void GpsL1CaGaussianTracking::stop_tracking() +{ +} + + +void GpsL1CaGaussianTracking::start_tracking() +{ + tracking_->start_tracking(); +} + + +/* + * Set tracking channel unique ID + */ +void GpsL1CaGaussianTracking::set_channel(unsigned int channel) +{ + channel_ = channel; + tracking_->set_channel(channel); +} + + +void GpsL1CaGaussianTracking::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) +{ + tracking_->set_gnss_synchro(p_gnss_synchro); +} + + +void GpsL1CaGaussianTracking::connect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* top_block is not null */ + }; + // nothing to connect, now the tracking uses gr_sync_decimator +} + + +void GpsL1CaGaussianTracking::disconnect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* top_block is not null */ + }; + // nothing to disconnect, now the tracking uses gr_sync_decimator +} + + +gr::basic_block_sptr GpsL1CaGaussianTracking::get_left_block() +{ + return tracking_; +} + + +gr::basic_block_sptr GpsL1CaGaussianTracking::get_right_block() +{ + return tracking_; +} diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_kf_vtl_tracking.h b/src/algorithms/tracking/adapters/gps_l1_ca_gaussian_tracking.h similarity index 55% rename from src/algorithms/tracking/adapters/gps_l1_ca_kf_vtl_tracking.h rename to src/algorithms/tracking/adapters/gps_l1_ca_gaussian_tracking.h index af011e917..2b04fa6b5 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_kf_vtl_tracking.h +++ b/src/algorithms/tracking/adapters/gps_l1_ca_gaussian_tracking.h @@ -1,56 +1,66 @@ /*! - * \file gps_l1_ca_kf_vtl_tracking.h - * \brief Interface of an adapter of a code + carrier Kalman Filter tracking loop with VTL capabilities block - * for GPS L1 C/A to a TrackingInterface - * \author Javier Arribas, 2020. jarribas(at)cttc.es + * \file gps_l1_ca_gaussian_tracking.h + * \brief Interface of an adapter of a DLL + Kalman carrier + * tracking loop block for GPS L1 C/A signals + * \author Javier Arribas, 2018. jarribas(at)cttc.es + * \author Jordi Vila-Valls 2018. jvila(at)cttc.es + * \author Carles Fernandez-Prades 2018. cfernandez(at)cttc.es * + * Reference: + * J. Vila-Valls, P. Closas, M. Navarro and C. Fernandez-Prades, + * "Are PLLs Dead? A Tutorial on Kalman Filter-based Techniques for Digital + * Carrier Synchronization", IEEE Aerospace and Electronic Systems Magazine, + * Vol. 32, No. 7, pp. 28–45, July 2017. DOI: 10.1109/MAES.2017.150260 * * ----------------------------------------------------------------------------- * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) - * - * GNSS-SDR is a software defined Global Navigation - * Satellite Systems receiver - * + * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * + * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- */ -#ifndef GNSS_SDR_GPS_L1_CA_kf_vtl_TRACKING_H -#define GNSS_SDR_GPS_L1_CA_kf_vtl_TRACKING_H +#ifndef GNSS_SDR_GPS_L1_CA_GAUSSIAN_TRACKING_H +#define GNSS_SDR_GPS_L1_CA_GAUSSIAN_TRACKING_H -#include "kf_vtl_tracking.h" +#include "gps_l1_ca_gaussian_tracking_cc.h" #include "tracking_interface.h" #include +/** \addtogroup Tracking + * \{ */ +/** \addtogroup Tracking_adapters + * \{ */ + + class ConfigurationInterface; /*! - * \brief This class implements a code + carrier Kalman Filter tracking loop with VTL capabilities + * \brief This class implements a code DLL + carrier PLL tracking loop */ -class GpsL1CaKfVtlTracking : public TrackingInterface +class GpsL1CaGaussianTracking : public TrackingInterface { public: - GpsL1CaKfVtlTracking( + GpsL1CaGaussianTracking( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams); - ~GpsL1CaKfVtlTracking() = default; + ~GpsL1CaGaussianTracking() = default; inline std::string role() override { return role_; } - //! Returns "GPS_L1_CA_kf_vtl_Tracking" + //! Returns "GPS_L1_CA_Gaussian_Tracking" inline std::string implementation() override { - return "GPS_L1_CA_KF_VTL_Tracking"; + return "GPS_L1_CA_Gaussian_Tracking"; } inline size_t item_size() override @@ -82,7 +92,7 @@ public: void stop_tracking() override; private: - kf_vtl_tracking_sptr tracking_; + gps_l1_ca_gaussian_tracking_cc_sptr tracking_; size_t item_size_; unsigned int channel_; std::string role_; @@ -90,4 +100,7 @@ private: unsigned int out_streams_; }; -#endif // GNSS_SDR_GPS_L1_CA_kf_vtl_TRACKING_H + +/** \} */ +/** \} */ +#endif // GNSS_SDR_GPS_L1_CA_GAUSSIAN_TRACKING_H diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_kf_tracking.cc b/src/algorithms/tracking/adapters/gps_l1_ca_kf_tracking.cc index 2cffdf478..9cf7dc1b4 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_kf_tracking.cc +++ b/src/algorithms/tracking/adapters/gps_l1_ca_kf_tracking.cc @@ -1,104 +1,94 @@ /*! - * \file gps_l1_ca_kf_tracking.cc - * \brief Implementation of an adapter of a DLL + Kalman carrier - * tracking loop block for GPS L1 C/A signals - * \author Javier Arribas, 2018. jarribas(at)cttc.es - * \author Jordi Vila-Valls 2018. jvila(at)cttc.es - * \author Carles Fernandez-Prades 2018. cfernandez(at)cttc.es + * \file gps_l1_ca_kf_tracking.h + * \brief Interface of an adapter of a code + carrier Kalman Filter tracking + * loop with VTL capabilities block + * for GPS L1 C/A to a TrackingInterface + * \author Javier Arribas, 2020. jarribas(at)cttc.es + * * - * Reference: - * J. Vila-Valls, P. Closas, M. Navarro and C. Fernández-Prades, - * "Are PLLs Dead? A Tutorial on Kalman Filter-based Techniques for Digital - * Carrier Synchronization", IEEE Aerospace and Electronic Systems Magazine, - * Vol. 32, No. 7, pp. 28–45, July 2017. DOI: 10.1109/MAES.2017.150260 * * ----------------------------------------------------------------------------- * - * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- */ - #include "gps_l1_ca_kf_tracking.h" #include "GPS_L1_CA.h" #include "configuration_interface.h" +#include "display.h" #include "gnss_sdr_flags.h" +#include "kf_conf.h" #include - +#include +#include GpsL1CaKfTracking::GpsL1CaKfTracking( const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { + Kf_Conf trk_params = Kf_Conf(); DLOG(INFO) << "role " << role; - // ################# CONFIGURATION PARAMETERS ######################## - const std::string default_item_type("gr_complex"); - std::string item_type = configuration->property(role + ".item_type", default_item_type); - int order = configuration->property(role + ".order", 2); - int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); - int fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - bool dump = configuration->property(role + ".dump", false); - float dll_bw_hz = configuration->property(role + ".dll_bw_hz", static_cast(2.0)); - if (FLAGS_dll_bw_hz != 0.0) + trk_params.SetFromConfiguration(configuration, role); + + const auto vector_length = static_cast(std::round(trk_params.fs_in / (GPS_L1_CA_CODE_RATE_CPS / GPS_L1_CA_CODE_LENGTH_CHIPS))); + trk_params.vector_length = vector_length; + if (trk_params.extend_correlation_symbols < 1) { - dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + trk_params.extend_correlation_symbols = 1; + std::cout << TEXT_RED << "WARNING: GPS L1 C/A. extend_correlation_symbols must be bigger than 1. Coherent integration has been set to 1 symbol (1 ms)" << TEXT_RESET << '\n'; + } + else if (trk_params.extend_correlation_symbols > 20) + { + trk_params.extend_correlation_symbols = 20; + std::cout << TEXT_RED << "WARNING: GPS L1 C/A. extend_correlation_symbols must be lower than 21. Coherent integration has been set to 20 symbols (20 ms)" << TEXT_RESET << '\n'; + } + trk_params.track_pilot = configuration->property(role + ".track_pilot", false); + if (trk_params.track_pilot) + { + trk_params.track_pilot = false; + std::cout << TEXT_RED << "WARNING: GPS L1 C/A does not have pilot signal. Data tracking has been enabled" << TEXT_RESET << '\n'; } - float early_late_space_chips = configuration->property(role + ".early_late_space_chips", static_cast(0.5)); - const std::string default_dump_filename("./track_ch"); - std::string dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); - const auto vector_length = static_cast(std::round(fs_in / (GPS_L1_CA_CODE_RATE_CPS / GPS_L1_CA_CODE_LENGTH_CHIPS))); - bool bce_run = configuration->property(role + ".bce_run", false); - unsigned int bce_ptrans = configuration->property(role + ".p_transient", 0); - unsigned int bce_strans = configuration->property(role + ".s_transient", 0); - int bce_nu = configuration->property(role + ".bce_nu", 0); - int bce_kappa = configuration->property(role + ".bce_kappa", 0); + trk_params.system = 'G'; + const std::array sig_{'1', 'C', '\0'}; + std::copy_n(sig_.data(), 3, trk_params.signal); - // ################# MAKE TRACKING GNURadio object ################### - if (item_type == "gr_complex") + // ################# Make a GNU Radio Tracking block object ################ + if (trk_params.item_type == "gr_complex") { item_size_ = sizeof(gr_complex); - tracking_ = gps_l1_ca_kf_make_tracking_cc( - order, - fs_in, - vector_length, - dump, - dump_filename, - dll_bw_hz, - early_late_space_chips, - bce_run, - bce_ptrans, - bce_strans, - bce_nu, - bce_kappa); + tracking_ = kf_make_tracking(trk_params); } else { - item_size_ = 0; - LOG(WARNING) << item_type << " unknown tracking item type."; + item_size_ = sizeof(gr_complex); + LOG(WARNING) << trk_params.item_type << " unknown tracking item type."; } channel_ = 0; DLOG(INFO) << "tracking(" << tracking_->unique_id() << ")"; - if (in_streams_ == 0) + if (in_streams_ > 1) { - in_streams_ = 1; - // Avoid compiler warning + LOG(ERROR) << "This implementation only supports one input stream"; } - if (out_streams_ == 0) + if (out_streams_ > 1) { - out_streams_ = 1; - // Avoid compiler warning + LOG(ERROR) << "This implementation only supports one output stream"; } } void GpsL1CaKfTracking::stop_tracking() { + tracking_->stop_tracking(); } diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_kf_tracking.h b/src/algorithms/tracking/adapters/gps_l1_ca_kf_tracking.h index a0c886bde..7e2daaea8 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_kf_tracking.h +++ b/src/algorithms/tracking/adapters/gps_l1_ca_kf_tracking.h @@ -1,23 +1,20 @@ /*! * \file gps_l1_ca_kf_tracking.h - * \brief Interface of an adapter of a DLL + Kalman carrier - * tracking loop block for GPS L1 C/A signals - * \author Javier Arribas, 2018. jarribas(at)cttc.es - * \author Jordi Vila-Valls 2018. jvila(at)cttc.es - * \author Carles Fernandez-Prades 2018. cfernandez(at)cttc.es + * \brief Interface of an adapter of a code + carrier Kalman Filter tracking + * loop with VTL capabilities block + * for GPS L1 C/A to a TrackingInterface + * \author Javier Arribas, 2020. jarribas(at)cttc.es * - * Reference: - * J. Vila-Valls, P. Closas, M. Navarro and C. Fernandez-Prades, - * "Are PLLs Dead? A Tutorial on Kalman Filter-based Techniques for Digital - * Carrier Synchronization", IEEE Aerospace and Electronic Systems Magazine, - * Vol. 32, No. 7, pp. 28–45, July 2017. DOI: 10.1109/MAES.2017.150260 * * ----------------------------------------------------------------------------- * - * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. + * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -26,20 +23,15 @@ #ifndef GNSS_SDR_GPS_L1_CA_KF_TRACKING_H #define GNSS_SDR_GPS_L1_CA_KF_TRACKING_H -#include "gps_l1_ca_kf_tracking_cc.h" +#include "kf_tracking.h" #include "tracking_interface.h" #include -/** \addtogroup Tracking - * \{ */ -/** \addtogroup Tracking_adapters - * \{ */ - - class ConfigurationInterface; /*! - * \brief This class implements a code DLL + carrier PLL tracking loop + * \brief This class implements a code + carrier Kalman Filter tracking loop + * with VTL capabilities */ class GpsL1CaKfTracking : public TrackingInterface { @@ -80,7 +72,8 @@ public: /*! * \brief Set acquisition/tracking common Gnss_Synchro object pointer - * to efficiently exchange synchronization data between acquisition and tracking blocks + * to efficiently exchange synchronization data between acquisition + * and tracking blocks */ void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; @@ -92,7 +85,7 @@ public: void stop_tracking() override; private: - gps_l1_ca_kf_tracking_cc_sptr tracking_; + kf_tracking_sptr tracking_; size_t item_size_; unsigned int channel_; std::string role_; @@ -100,7 +93,4 @@ private: unsigned int out_streams_; }; - -/** \} */ -/** \} */ #endif // GNSS_SDR_GPS_L1_CA_KF_TRACKING_H diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_kf_vtl_tracking.cc b/src/algorithms/tracking/adapters/gps_l1_ca_kf_vtl_tracking.cc deleted file mode 100644 index 7c28c1b07..000000000 --- a/src/algorithms/tracking/adapters/gps_l1_ca_kf_vtl_tracking.cc +++ /dev/null @@ -1,143 +0,0 @@ -/*! - * \file gps_l1_ca_kf_vtl_tracking.h - * \brief Interface of an adapter of a code + carrier Kalman Filter tracking loop with VTL capabilities block - * for GPS L1 C/A to a TrackingInterface - * \author Javier Arribas, 2020. jarribas(at)cttc.es - * - * - * - * ----------------------------------------------------------------------------- - * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) - * - * GNSS-SDR is a software defined Global Navigation - * Satellite Systems receiver - * - * This file is part of GNSS-SDR. - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - * ----------------------------------------------------------------------------- - */ - -#include "gps_l1_ca_kf_vtl_tracking.h" -#include "GPS_L1_CA.h" -#include "configuration_interface.h" -#include "display.h" -#include "gnss_sdr_flags.h" -#include "kf_conf.h" -#include -#include -#include - -GpsL1CaKfVtlTracking::GpsL1CaKfVtlTracking( - const ConfigurationInterface* configuration, const std::string& role, - unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) -{ - Kf_Conf trk_params = Kf_Conf(); - DLOG(INFO) << "role " << role; - trk_params.SetFromConfiguration(configuration, role); - - const auto vector_length = static_cast(std::round(trk_params.fs_in / (GPS_L1_CA_CODE_RATE_CPS / GPS_L1_CA_CODE_LENGTH_CHIPS))); - trk_params.vector_length = vector_length; - if (trk_params.extend_correlation_symbols < 1) - { - trk_params.extend_correlation_symbols = 1; - std::cout << TEXT_RED << "WARNING: GPS L1 C/A. extend_correlation_symbols must be bigger than 1. Coherent integration has been set to 1 symbol (1 ms)" << TEXT_RESET << '\n'; - } - else if (trk_params.extend_correlation_symbols > 20) - { - trk_params.extend_correlation_symbols = 20; - std::cout << TEXT_RED << "WARNING: GPS L1 C/A. extend_correlation_symbols must be lower than 21. Coherent integration has been set to 20 symbols (20 ms)" << TEXT_RESET << '\n'; - } - trk_params.track_pilot = configuration->property(role + ".track_pilot", false); - if (trk_params.track_pilot) - { - trk_params.track_pilot = false; - std::cout << TEXT_RED << "WARNING: GPS L1 C/A does not have pilot signal. Data tracking has been enabled" << TEXT_RESET << '\n'; - } - - trk_params.system = 'G'; - const std::array sig_{'1', 'C', '\0'}; - std::copy_n(sig_.data(), 3, trk_params.signal); - - // ################# Make a GNU Radio Tracking block object ################ - if (trk_params.item_type == "gr_complex") - { - item_size_ = sizeof(gr_complex); - tracking_ = kf_vtl_make_tracking(trk_params); - } - else - { - item_size_ = sizeof(gr_complex); - LOG(WARNING) << trk_params.item_type << " unknown tracking item type."; - } - channel_ = 0; - DLOG(INFO) << "tracking(" << tracking_->unique_id() << ")"; - if (in_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one input stream"; - } - if (out_streams_ > 1) - { - LOG(ERROR) << "This implementation only supports one output stream"; - } -} - - -void GpsL1CaKfVtlTracking::stop_tracking() -{ - tracking_->stop_tracking(); -} - - -void GpsL1CaKfVtlTracking::start_tracking() -{ - tracking_->start_tracking(); -} - - -/* - * Set tracking channel unique ID - */ -void GpsL1CaKfVtlTracking::set_channel(unsigned int channel) -{ - channel_ = channel; - tracking_->set_channel(channel); -} - - -void GpsL1CaKfVtlTracking::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) -{ - tracking_->set_gnss_synchro(p_gnss_synchro); -} - - -void GpsL1CaKfVtlTracking::connect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to connect, now the tracking uses gr_sync_decimator -} - - -void GpsL1CaKfVtlTracking::disconnect(gr::top_block_sptr top_block) -{ - if (top_block) - { /* top_block is not null */ - }; - // nothing to disconnect, now the tracking uses gr_sync_decimator -} - - -gr::basic_block_sptr GpsL1CaKfVtlTracking::get_left_block() -{ - return tracking_; -} - - -gr::basic_block_sptr GpsL1CaKfVtlTracking::get_right_block() -{ - return tracking_; -} diff --git a/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt b/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt index eae1f6c8d..213774a31 100644 --- a/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt @@ -34,12 +34,12 @@ set(TRACKING_GR_BLOCKS_SOURCES glonass_l1_ca_dll_pll_tracking_cc.cc glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc - gps_l1_ca_kf_tracking_cc.cc + gps_l1_ca_gaussian_tracking_cc.cc glonass_l2_ca_dll_pll_tracking_cc.cc glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc dll_pll_veml_tracking.cc - kf_vtl_tracking.cc + kf_tracking.cc ${OPT_TRACKING_BLOCKS_SOURCES} ) @@ -49,12 +49,12 @@ set(TRACKING_GR_BLOCKS_HEADERS glonass_l1_ca_dll_pll_tracking_cc.h glonass_l1_ca_dll_pll_c_aid_tracking_cc.h glonass_l1_ca_dll_pll_c_aid_tracking_sc.h - gps_l1_ca_kf_tracking_cc.h + gps_l1_ca_gaussian_tracking_cc.h glonass_l2_ca_dll_pll_tracking_cc.h glonass_l2_ca_dll_pll_c_aid_tracking_cc.h glonass_l2_ca_dll_pll_c_aid_tracking_sc.h dll_pll_veml_tracking.h - kf_vtl_tracking.h + kf_tracking.h ${OPT_TRACKING_BLOCKS_HEADERS} ) diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc similarity index 97% rename from src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.cc rename to src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc index 560992b45..af432dec8 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.cc @@ -1,5 +1,5 @@ /*! - * \file gps_l1_ca_kf_tracking_cc.cc + * \file gps_l1_ca_gaussian_tracking_cc.cc * \brief Implementation of a processing block of a DLL + Kalman carrier * tracking loop for GPS L1 C/A signals * \author Javier Arribas, 2018. jarribas(at)cttc.es @@ -23,7 +23,7 @@ * ----------------------------------------------------------------------------- */ -#include "gps_l1_ca_kf_tracking_cc.h" +#include "gps_l1_ca_gaussian_tracking_cc.h" #include "GPS_L1_CA.h" #include "gnss_satellite.h" #include "gnss_sdr_flags.h" @@ -45,7 +45,7 @@ #include -gps_l1_ca_kf_tracking_cc_sptr gps_l1_ca_kf_make_tracking_cc( +gps_l1_ca_gaussian_tracking_cc_sptr gps_l1_ca_gaussian_make_tracking_cc( uint32_t order, int64_t fs_in, uint32_t vector_length, @@ -59,13 +59,13 @@ gps_l1_ca_kf_tracking_cc_sptr gps_l1_ca_kf_make_tracking_cc( int32_t bce_nu, int32_t bce_kappa) { - return gps_l1_ca_kf_tracking_cc_sptr(new Gps_L1_Ca_Kf_Tracking_cc(order, + return gps_l1_ca_gaussian_tracking_cc_sptr(new Gps_L1_Ca_Gaussian_Tracking_cc(order, fs_in, vector_length, dump, dump_filename, dll_bw_hz, early_late_space_chips, bce_run, bce_ptrans, bce_strans, bce_nu, bce_kappa)); } -void Gps_L1_Ca_Kf_Tracking_cc::forecast(int noutput_items, +void Gps_L1_Ca_Gaussian_Tracking_cc::forecast(int noutput_items, gr_vector_int &ninput_items_required) { if (noutput_items != 0) @@ -75,7 +75,7 @@ void Gps_L1_Ca_Kf_Tracking_cc::forecast(int noutput_items, } -Gps_L1_Ca_Kf_Tracking_cc::Gps_L1_Ca_Kf_Tracking_cc( +Gps_L1_Ca_Gaussian_Tracking_cc::Gps_L1_Ca_Gaussian_Tracking_cc( uint32_t order, int64_t fs_in, uint32_t vector_length, @@ -88,7 +88,7 @@ Gps_L1_Ca_Kf_Tracking_cc::Gps_L1_Ca_Kf_Tracking_cc( uint32_t bce_strans, int32_t bce_nu, int32_t bce_kappa) - : gr::block("Gps_L1_Ca_Kf_Tracking_cc", gr::io_signature::make(1, 1, sizeof(gr_complex)), + : gr::block("Gps_L1_Ca_Gaussian_Tracking_cc", gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))), d_order(order), d_vector_length(vector_length), @@ -222,14 +222,14 @@ Gps_L1_Ca_Kf_Tracking_cc::Gps_L1_Ca_Kf_Tracking_cc( kf_x(2, 0) = 0.0; } - // Bayesian covariance estimator initialization + // Gaussian covariance estimator initialization kf_R_est = kf_R; bayes_estimator.init(arma::zeros(1, 1), bayes_kappa, bayes_nu, (kf_H * kf_P_x_ini * kf_H.t() + kf_R) * (bayes_nu + 2)); } -void Gps_L1_Ca_Kf_Tracking_cc::start_tracking() +void Gps_L1_Ca_Gaussian_Tracking_cc::start_tracking() { /* * correct the code phase according to the delay between acq and trk @@ -318,7 +318,7 @@ void Gps_L1_Ca_Kf_Tracking_cc::start_tracking() } -Gps_L1_Ca_Kf_Tracking_cc::~Gps_L1_Ca_Kf_Tracking_cc() +Gps_L1_Ca_Gaussian_Tracking_cc::~Gps_L1_Ca_Gaussian_Tracking_cc() { if (d_dump_file.is_open()) { @@ -339,7 +339,7 @@ Gps_L1_Ca_Kf_Tracking_cc::~Gps_L1_Ca_Kf_Tracking_cc() } try { - Gps_L1_Ca_Kf_Tracking_cc::save_matfile(); + Gps_L1_Ca_Gaussian_Tracking_cc::save_matfile(); } catch (const std::exception &ex) { @@ -362,7 +362,7 @@ Gps_L1_Ca_Kf_Tracking_cc::~Gps_L1_Ca_Kf_Tracking_cc() } -int32_t Gps_L1_Ca_Kf_Tracking_cc::save_matfile() +int32_t Gps_L1_Ca_Gaussian_Tracking_cc::save_matfile() { // READ DUMP FILE std::ifstream::pos_type size; @@ -557,7 +557,7 @@ int32_t Gps_L1_Ca_Kf_Tracking_cc::save_matfile() } -void Gps_L1_Ca_Kf_Tracking_cc::set_channel(uint32_t channel) +void Gps_L1_Ca_Gaussian_Tracking_cc::set_channel(uint32_t channel) { gr::thread::scoped_lock l(d_setlock); d_channel = channel; @@ -584,13 +584,13 @@ void Gps_L1_Ca_Kf_Tracking_cc::set_channel(uint32_t channel) } -void Gps_L1_Ca_Kf_Tracking_cc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) +void Gps_L1_Ca_Gaussian_Tracking_cc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) { d_acquisition_gnss_synchro = p_gnss_synchro; } -int Gps_L1_Ca_Kf_Tracking_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), +int Gps_L1_Ca_Gaussian_Tracking_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { // process vars diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.h b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.h similarity index 89% rename from src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.h rename to src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.h index b68927e31..a463b749d 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.h +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_gaussian_tracking_cc.h @@ -1,5 +1,5 @@ /*! - * \file gps_l1_ca_kf_tracking_cc.h + * \file gps_l1_ca_gaussian_tracking_cc.h * \brief Interface of a processing block of a DLL + Kalman carrier * tracking loop for GPS L1 C/A signals * \author Javier Arribas, 2018. jarribas(at)cttc.es @@ -23,8 +23,8 @@ * ----------------------------------------------------------------------------- */ -#ifndef GNSS_SDR_GPS_L1_CA_KF_TRACKING_CC_H -#define GNSS_SDR_GPS_L1_CA_KF_TRACKING_CC_H +#ifndef GNSS_SDR_GPS_L1_CA_GAUSSIAN_TRACKING_CC_H +#define GNSS_SDR_GPS_L1_CA_GAUSSIAN_TRACKING_CC_H #if ARMA_NO_BOUND_CHECKING #define ARMA_NO_DEBUG 1 @@ -49,12 +49,12 @@ * \{ */ -class Gps_L1_Ca_Kf_Tracking_cc; +class Gps_L1_Ca_Gaussian_Tracking_cc; -using gps_l1_ca_kf_tracking_cc_sptr = gnss_shared_ptr; +using gps_l1_ca_gaussian_tracking_cc_sptr = gnss_shared_ptr; -gps_l1_ca_kf_tracking_cc_sptr -gps_l1_ca_kf_make_tracking_cc(uint32_t order, +gps_l1_ca_gaussian_tracking_cc_sptr +gps_l1_ca_gaussian_make_tracking_cc(uint32_t order, int64_t fs_in, uint32_t vector_length, bool dump, @@ -71,10 +71,10 @@ gps_l1_ca_kf_make_tracking_cc(uint32_t order, /*! * \brief This class implements a DLL + PLL tracking loop block */ -class Gps_L1_Ca_Kf_Tracking_cc : public gr::block +class Gps_L1_Ca_Gaussian_Tracking_cc : public gr::block { public: - ~Gps_L1_Ca_Kf_Tracking_cc(); + ~Gps_L1_Ca_Gaussian_Tracking_cc(); void set_channel(uint32_t channel); void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro); @@ -86,8 +86,8 @@ public: void forecast(int noutput_items, gr_vector_int& ninput_items_required); private: - friend gps_l1_ca_kf_tracking_cc_sptr - gps_l1_ca_kf_make_tracking_cc(uint32_t order, + friend gps_l1_ca_gaussian_tracking_cc_sptr + gps_l1_ca_gaussian_make_tracking_cc(uint32_t order, int64_t fs_in, uint32_t vector_length, bool dump, @@ -100,7 +100,7 @@ private: int32_t bce_nu, int32_t bce_kappa); - Gps_L1_Ca_Kf_Tracking_cc(uint32_t order, + Gps_L1_Ca_Gaussian_Tracking_cc(uint32_t order, int64_t fs_in, uint32_t vector_length, bool dump, @@ -148,7 +148,7 @@ private: arma::colvec kf_y; // measurement vector arma::mat kf_K; // Kalman gain matrix - // Bayesian estimator + // Gaussian estimator Bayesian_estimator bayes_estimator; arma::mat kf_R_est; // measurement error covariance uint32_t bayes_ptrans; @@ -218,4 +218,4 @@ private: /** \} */ /** \} */ -#endif // GNSS_SDR_GPS_L1_CA_KF_TRACKING_CC_H +#endif // GNSS_SDR_GPS_L1_CA_GAUSSIAN_TRACKING_CC_H diff --git a/src/algorithms/tracking/gnuradio_blocks/kf_vtl_tracking.cc b/src/algorithms/tracking/gnuradio_blocks/kf_tracking.cc similarity index 89% rename from src/algorithms/tracking/gnuradio_blocks/kf_vtl_tracking.cc rename to src/algorithms/tracking/gnuradio_blocks/kf_tracking.cc index a01caaf99..53856bb4a 100644 --- a/src/algorithms/tracking/gnuradio_blocks/kf_vtl_tracking.cc +++ b/src/algorithms/tracking/gnuradio_blocks/kf_tracking.cc @@ -1,5 +1,5 @@ /*! - * \file kf_vtl_tracking.cc + * \file kf_tracking.cc * \brief Implementation of a Kalman filter based tracking with optional Vector * Tracking Loop message receiver block. * \author Javier Arribas, 2020. jarribas(at)cttc.es @@ -18,7 +18,7 @@ * ----------------------------------------------------------------------------- */ -#include "kf_vtl_tracking.h" +#include "kf_tracking.h" #include "Beidou_B1I.h" #include "Beidou_B3I.h" #include "GPS_L1_CA.h" @@ -71,14 +71,14 @@ namespace wht = boost; namespace wht = std; #endif -kf_vtl_tracking_sptr kf_vtl_make_tracking(const Kf_Conf &conf_) +kf_tracking_sptr kf_make_tracking(const Kf_Conf &conf_) { - return kf_vtl_tracking_sptr(new kf_vtl_tracking(conf_)); + return kf_tracking_sptr(new kf_tracking(conf_)); } -kf_vtl_tracking::kf_vtl_tracking(const Kf_Conf &conf_) - : gr::block("kf_vtl_tracking", +kf_tracking::kf_tracking(const Kf_Conf &conf_) + : gr::block("kf_tracking", gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))), d_trk_parameters(conf_), @@ -109,6 +109,7 @@ kf_vtl_tracking::kf_vtl_tracking(const Kf_Conf &conf_) d_code_phase_rate_step_chips(0.0), d_rem_code_phase_chips(0.0), d_rem_code_phase_samples(0.0), + d_beta(0.0), d_sample_counter(0ULL), d_acq_sample_stamp(0ULL), d_rem_carr_phase_rad(0.0), @@ -145,9 +146,9 @@ kf_vtl_tracking::kf_vtl_tracking(const Kf_Conf &conf_) [this](auto &&PH1) { msg_handler_telemetry_to_trk(PH1); }); #else #if USE_BOOST_BIND_PLACEHOLDERS - boost::bind(&kf_vtl_tracking::msg_handler_telemetry_to_trk, this, boost::placeholders::_1)); + boost::bind(&kf_tracking::msg_handler_telemetry_to_trk, this, boost::placeholders::_1)); #else - boost::bind(&kf_vtl_tracking::msg_handler_telemetry_to_trk, this, _1)); + boost::bind(&kf_tracking::msg_handler_telemetry_to_trk, this, _1)); #endif #endif @@ -159,9 +160,9 @@ kf_vtl_tracking::kf_vtl_tracking(const Kf_Conf &conf_) [this](auto &&PH1) { msg_handler_pvt_to_trk(PH1); }); #else #if USE_BOOST_BIND_PLACEHOLDERS - boost::bind(&kf_vtl_tracking::msg_handler_pvt_to_trk, this, boost::placeholders::_1)); + boost::bind(&kf_tracking::msg_handler_pvt_to_trk, this, boost::placeholders::_1)); #else - boost::bind(&kf_vtl_tracking::msg_handler_pvt_to_trk, this, _1)); + boost::bind(&kf_tracking::msg_handler_pvt_to_trk, this, _1)); #endif #endif @@ -437,13 +438,15 @@ kf_vtl_tracking::kf_vtl_tracking(const Kf_Conf &conf_) std::cerr << "Invalid System argument when instantiating tracking blocks\n"; d_correlation_length_ms = 1; d_secondary = false; - d_signal_carrier_freq = 0.0; + d_signal_carrier_freq = 1.0; d_code_period = 0.0; d_code_length_chips = 0; d_code_samples_per_chip = 0U; d_symbols_per_bit = 0; } + d_beta = d_code_chip_rate / d_signal_carrier_freq; + // Initialization of local code replica // Get space for a vector with the sinboc(1,1) replica sampled 2x/chip d_tracking_code.resize(2 * d_code_length_chips, 0.0); @@ -537,6 +540,17 @@ kf_vtl_tracking::kf_vtl_tracking(const Kf_Conf &conf_) clear_tracking_vars(); + if (d_trk_parameters.smoother_length > 0) + { + d_carr_ph_history.set_capacity(d_trk_parameters.smoother_length * 2); + d_code_ph_history.set_capacity(d_trk_parameters.smoother_length * 2); + } + else + { + d_carr_ph_history.set_capacity(1); + d_code_ph_history.set_capacity(1); + } + if (d_dump) { d_dump_filename = d_trk_parameters.dump_filename; @@ -573,7 +587,7 @@ kf_vtl_tracking::kf_vtl_tracking(const Kf_Conf &conf_) } -void kf_vtl_tracking::forecast(int noutput_items, +void kf_tracking::forecast(int noutput_items, gr_vector_int &ninput_items_required) { if (noutput_items != 0) @@ -583,7 +597,7 @@ void kf_vtl_tracking::forecast(int noutput_items, } -void kf_vtl_tracking::msg_handler_telemetry_to_trk(const pmt::pmt_t &msg) +void kf_tracking::msg_handler_telemetry_to_trk(const pmt::pmt_t &msg) { try { @@ -605,7 +619,7 @@ void kf_vtl_tracking::msg_handler_telemetry_to_trk(const pmt::pmt_t &msg) } -void kf_vtl_tracking::msg_handler_pvt_to_trk(const pmt::pmt_t &msg) +void kf_tracking::msg_handler_pvt_to_trk(const pmt::pmt_t &msg) { try { @@ -627,7 +641,7 @@ void kf_vtl_tracking::msg_handler_pvt_to_trk(const pmt::pmt_t &msg) } -void kf_vtl_tracking::start_tracking() +void kf_tracking::start_tracking() { gr::thread::scoped_lock l(d_setlock); // correct the code phase according to the delay between acq and trk @@ -638,6 +652,8 @@ void kf_vtl_tracking::start_tracking() d_carrier_doppler_kf_hz = d_acq_carrier_doppler_hz; d_carrier_phase_step_rad = TWO_PI * d_carrier_doppler_kf_hz / d_trk_parameters.fs_in; d_carrier_phase_rate_step_rad = 0.0; + d_carr_ph_history.clear(); + d_code_ph_history.clear(); std::array Signal_{}; Signal_[0] = d_acquisition_gnss_synchro->Signal[0]; Signal_[1] = d_acquisition_gnss_synchro->Signal[1]; @@ -732,7 +748,7 @@ void kf_vtl_tracking::start_tracking() { beidou_b1i_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN, 0); // GEO Satellites use different secondary code - if ((d_acquisition_gnss_synchro->PRN > 0 and d_acquisition_gnss_synchro->PRN < 6) or d_acquisition_gnss_synchro->PRN > 58) + if (d_acquisition_gnss_synchro->PRN > 0 and d_acquisition_gnss_synchro->PRN < 6) { d_symbols_per_bit = BEIDOU_B1I_GEO_TELEMETRY_SYMBOLS_PER_BIT; // todo: enable after fixing beidou symbol synchronization d_correlation_length_ms = 1; @@ -765,7 +781,7 @@ void kf_vtl_tracking::start_tracking() { beidou_b3i_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN, 0); // Update secondary code settings for geo satellites - if ((d_acquisition_gnss_synchro->PRN > 0 and d_acquisition_gnss_synchro->PRN < 6) or d_acquisition_gnss_synchro->PRN > 58) + if (d_acquisition_gnss_synchro->PRN > 0 and d_acquisition_gnss_synchro->PRN < 6) { d_symbols_per_bit = BEIDOU_B3I_GEO_TELEMETRY_SYMBOLS_PER_BIT; // todo: enable after fixing beidou symbol synchronization d_correlation_length_ms = 1; @@ -838,115 +854,108 @@ void kf_vtl_tracking::start_tracking() } -void kf_vtl_tracking::init_kf(double acq_code_phase_chips, double acq_doppler_hz) -{ - // Kalman Filter class variables - const double Ti = d_correlation_length_ms * 0.001; - // state vector: code_phase_chips, carrier_phase_rads, carrier_freq_hz,carrier_freq_rate_hz, code_freq_chips_s - d_F = arma::mat(5, 5); - d_F = {{1, 0, 0, 0, Ti}, - {0, 1, 2.0 * GNSS_PI * Ti, GNSS_PI * (Ti * Ti), 0}, - {0, 0, 1, Ti, 0}, - {0, 0, 0, 1, 0}, - {0, 0, 0, 0, 1}}; - - const double B = d_code_chip_rate / d_signal_carrier_freq; // carrier to code rate factor - - d_H = arma::mat(2, 5); - d_H = {{1, 0, -B * Ti / 2.0, B * (Ti * Ti) / 6.0, 0}, - {0, 1, -GNSS_PI * Ti, GNSS_PI * (Ti * Ti) / 3.0, 0}}; - // Phase noise variance - // const double CN0_lin = pow(10.0, d_trk_parameters.expected_cn0_dbhz / 10.0); // CN0 in Hz - // const double N_periods = 1; // Only 1 interval - // const double Sigma2_Tau = 0.25 * (1.0 + 2.0 * CN0_lin * Ti) / (N_periods * pow(CN0_lin * Ti, 2.0)) * (1.0 + (1.0 + 2.0 * CN0_lin * Ti) / (pow(N_periods * (CN0_lin * Ti), 2.0))); - // const double Sigma2_Phase = 1.0 / (2.0 * CN0_lin * Ti) * (1.0 + 1.0 / (2.0 * CN0_lin * Ti)); - - // measurement covariance matrix (static) - d_R = arma::mat(2, 2); - // d_R << Sigma2_Tau << 0 << arma::endr - // << 0 << Sigma2_Phase << arma::endr; - d_R = {{pow(d_trk_parameters.code_disc_sd_chips, 2.0), 0}, - {0, pow(d_trk_parameters.carrier_disc_sd_rads, 2.0)}}; - // system covariance matrix (static) - d_Q = arma::mat(5, 5); - d_Q = {{pow(d_trk_parameters.code_phase_sd_chips, 2.0), 0, 0, 0, 0}, - {0, pow(d_trk_parameters.carrier_phase_sd_rad, 2.0), 0, 0, 0}, - {0, 0, pow(d_trk_parameters.carrier_freq_sd_hz, 2.0), 0, 0}, - {0, 0, 0, pow(d_trk_parameters.carrier_freq_rate_sd_hz_s, 2.0), 0}, - {0, 0, 0, 0, pow(d_trk_parameters.code_rate_sd_chips_s, 2.0)}}; - // initial Kalman covariance matrix - d_P_old_old = arma::mat(5, 5); - d_P_old_old = {{pow(d_trk_parameters.init_code_phase_sd_chips, 2.0), 0, 0, 0, 0}, - {0, pow(d_trk_parameters.init_carrier_phase_sd_rad, 2.0), 0, 0, 0}, - {0, 0, pow(d_trk_parameters.init_carrier_freq_rate_sd_hz_s, 2.0), 0, 0}, - {0, 0, 0, pow(d_trk_parameters.init_carrier_freq_rate_sd_hz_s, 2.0), 0}, - {0, 0, 0, 0, pow(d_trk_parameters.init_code_rate_sd_chips_s, 2.0)}}; - // init state vector - d_x_old_old = arma::vec(5); - // states: code_phase_chips, carrier_phase_rads, carrier_freq_hz, carrier_freq_rate_hz_s, code_freq_rate_chips_s - d_x_old_old = {acq_code_phase_chips, 0, acq_doppler_hz, 0, 0}; - // std::cout << "F: " << d_F << "\n"; - // std::cout << "H: " << d_H << "\n"; - // std::cout << "R: " << d_R << "\n"; - // std::cout << "Q: " << d_Q << "\n"; - // std::cout << "P: " << d_P_old_old << "\n"; - // std::cout << "x: " << d_x_old_old << "\n"; -} - - -void kf_vtl_tracking::update_kf_narrow_integration_time() +void kf_tracking::init_kf(double acq_code_phase_chips, double acq_doppler_hz) { // Kalman Filter class variables const double Ti = d_current_correlation_time_s; + const double TiTi = Ti * Ti; - // state vector: code_phase_chips, carrier_phase_rads, carrier_freq_hz,carrier_freq_rate_hz, code_freq_chips_s - d_F = {{1, 0, 0, 0, Ti}, - {0, 1, 2.0 * GNSS_PI * Ti, GNSS_PI * (Ti * Ti), 0}, - {0, 0, 1, Ti, 0}, - {0, 0, 0, 1, 0}, - {0, 0, 0, 0, 1}}; - const double B = d_code_chip_rate / d_signal_carrier_freq; // carrier to code rate factor + d_F = {{1.0, 0.0, d_beta * Ti, d_beta * TiTi / 2.0}, + {0.0, 1.0, 2.0 * GNSS_PI * Ti, GNSS_PI * TiTi}, + {0.0, 0.0, 1.0, Ti}, + {0.0, 0.0, 0.0, 1.0}}; - d_H = {{1, 0, -B * Ti / 2.0, B * (Ti * Ti) / 6.0, 0}, - {0, 1, -GNSS_PI * Ti, GNSS_PI * (Ti * Ti) / 3.0, 0}}; + d_H = {{1.0, 0.0, -d_beta * Ti / 2.0, d_beta * TiTi / 6.0}, + {0.0, 1.0, -GNSS_PI * Ti, GNSS_PI * TiTi / 3.0}}; - // measurement covariance matrix (static) - d_R = {{pow(d_trk_parameters.code_disc_sd_chips, 2.0), 0}, - {0, pow(d_trk_parameters.carrier_disc_sd_rads, 2.0)}}; + d_R = {{pow(d_trk_parameters.code_disc_sd_chips, 2.0), 0.0}, + {0.0, pow(d_trk_parameters.carrier_disc_sd_rads, 2.0)}}; // system covariance matrix (static) - d_Q = {{pow(d_trk_parameters.narrow_code_phase_sd_chips, 2.0), 0, 0, 0, 0}, - {0, pow(d_trk_parameters.narrow_carrier_phase_sd_rad, 2.0), 0, 0, 0}, - {0, 0, pow(d_trk_parameters.narrow_carrier_freq_sd_hz, 2.0), 0, 0}, - {0, 0, 0, pow(d_trk_parameters.narrow_carrier_freq_rate_sd_hz_s, 2.0), 0}, - {0, 0, 0, 0, pow(d_trk_parameters.narrow_code_rate_sd_chips_s, 2.0)}}; + d_Q = {{pow(d_trk_parameters.code_phase_sd_chips, 2.0), 0.0, 0.0, 0.0}, + {0.0, pow(d_trk_parameters.carrier_phase_sd_rad, 2.0), 0.0, 0.0}, + {0.0, 0.0, pow(d_trk_parameters.carrier_freq_sd_hz, 2.0), 0.0}, + {0.0, 0.0, 0.0, pow(d_trk_parameters.carrier_freq_rate_sd_hz_s, 2.0)}}; + + // initial Kalman covariance matrix + d_P_old_old = {{pow(d_trk_parameters.init_code_phase_sd_chips, 2.0), 0.0, 0.0, 0.0}, + {0.0, pow(d_trk_parameters.init_carrier_phase_sd_rad, 2.0), 0.0, 0.0}, + {0.0, 0.0, pow(d_trk_parameters.init_carrier_freq_sd_hz, 2.0), 0.0}, + {0.0, 0.0, 0.0, pow(d_trk_parameters.init_carrier_freq_rate_sd_hz_s, 2.0)}}; + + // states: code_phase_chips, carrier_phase_rads, carrier_freq_hz, carrier_freq_rate_hz_s + d_x_old_old = {acq_code_phase_chips, 0.0, acq_doppler_hz, 0.0}; + + DLOG(INFO) << "F: " << d_F; + DLOG(INFO) << "H: " << d_H; + DLOG(INFO) << "R: " << d_R; + DLOG(INFO) << "Q: " << d_Q; + DLOG(INFO) << "P: " << d_P_old_old; + DLOG(INFO) << "x: " << d_x_old_old; } -void kf_vtl_tracking::update_kf_cn0(double current_cn0_dbhz) +void kf_tracking::update_kf_narrow_integration_time() { // Kalman Filter class variables - const double Ti = d_correlation_length_ms * 0.001; - const double B = d_code_chip_rate / d_signal_carrier_freq; // carrier to code rate factor + const double Ti = d_current_correlation_time_s; + const double TiTi = Ti * Ti; - d_H = arma::mat(2, 5); - d_H = {{1, 0, -B * Ti / 2.0, B * (Ti * Ti) / 6.0, 0}, - {0, 1, -GNSS_PI * Ti, GNSS_PI * (Ti * Ti) / 3.0, 0}}; + arma::mat Qnew = arma::zeros(4, 4); + for (int i = 0; i < d_trk_parameters.extend_correlation_symbols; i++) + { + Qnew += d_F * d_Q * d_F.t(); + d_Q = d_F * d_Q * d_F.t(); + } + d_Q = Qnew; + + // state vector: code_phase_chips, carrier_phase_rads, carrier_freq_hz, carrier_freq_rate_hz + d_F = {{1.0, 0.0, d_beta * Ti, d_beta * TiTi / 2.0}, + {0.0, 1.0, 2.0 * GNSS_PI * Ti, GNSS_PI * TiTi}, + {0.0, 0.0, 1.0, Ti}, + {0.0, 0.0, 0.0, 1.0}}; + + d_H = {{1.0, 0.0, -d_beta * Ti / 2.0, d_beta * TiTi / 6.0}, + {0.0, 1.0, -GNSS_PI * Ti, GNSS_PI * TiTi / 3.0}}; + + const double CN0_lin = pow(10.0, d_CN0_SNV_dB_Hz / 10.0); // CN0 in Hz + const double CN0_lin_Ti = CN0_lin * Ti; + const double Sigma2_Phase = (1.0 / (2.0 * CN0_lin_Ti)) * (1.0 + 1.0 / (2.0 * CN0_lin_Ti)); + const double Sigma2_Tau = (1.0 / CN0_lin_Ti) * (d_trk_parameters.spc + (d_trk_parameters.spc / (1.0 - d_trk_parameters.spc)) * (1.0 / (2.0 * CN0_lin_Ti))); + + d_R = {{Sigma2_Tau, 0.0}, + {0.0, Sigma2_Phase}}; + + DLOG(INFO) << "Fu: " << d_F; + DLOG(INFO) << "Hu: " << d_H; + DLOG(INFO) << "Ru: " << d_R; + DLOG(INFO) << "Qu: " << d_Q; + DLOG(INFO) << "Pu: " << d_P_old_old; + DLOG(INFO) << "xu: " << d_x_old_old; +} + + +void kf_tracking::update_kf_cn0(double current_cn0_dbhz) +{ + // Kalman Filter class variables + const double Ti = d_current_correlation_time_s; // d_correlation_length_ms * 0.001; + const double TiTi = Ti * Ti; + + d_H = {{1.0, 0.0, -d_beta * Ti / 2.0, d_beta * TiTi / 6.0}, + {0.0, 1.0, -GNSS_PI * Ti, GNSS_PI * TiTi / 3.0}}; // Phase noise variance const double CN0_lin = pow(10.0, current_cn0_dbhz / 10.0); // CN0 in Hz - const double N_periods = 1; // Only 1 interval - const double Sigma2_Tau = 0.25 * (1.0 + 2.0 * CN0_lin * Ti) / (N_periods * pow(CN0_lin * Ti, 2.0)) * (1.0 + (1.0 + 2.0 * CN0_lin * Ti) / (pow(N_periods * (CN0_lin * Ti), 2.0))); - const double Sigma2_Phase = 1.0 / (2.0 * CN0_lin * Ti) * (1.0 + 1.0 / (2.0 * CN0_lin * Ti)); + const double CN0_lin_Ti = CN0_lin * Ti; + const double Sigma2_Phase = (1.0 / (2.0 * CN0_lin_Ti)) * (1.0 + 1.0 / (2.0 * CN0_lin_Ti)); + const double Sigma2_Tau = (1.0 / CN0_lin_Ti) * (d_trk_parameters.spc + (d_trk_parameters.spc / (1.0 - d_trk_parameters.spc)) * (1.0 / (2.0 * CN0_lin_Ti))); - // measurement covariance matrix (static) - d_R = arma::mat(2, 2); - d_R = {{Sigma2_Tau, 0}, - {0, Sigma2_Phase}}; + d_R = {{Sigma2_Tau, 0.0}, + {0.0, Sigma2_Phase}}; } -kf_vtl_tracking::~kf_vtl_tracking() +kf_tracking::~kf_tracking() { if (d_dump_file.is_open()) { @@ -985,7 +994,7 @@ kf_vtl_tracking::~kf_vtl_tracking() } -bool kf_vtl_tracking::acquire_secondary() +bool kf_tracking::acquire_secondary() { // ******* preamble correlation ******** int32_t corr_value = 0; @@ -1024,7 +1033,7 @@ bool kf_vtl_tracking::acquire_secondary() } -bool kf_vtl_tracking::cn0_and_tracking_lock_status(double coh_integration_time_s) +bool kf_tracking::cn0_and_tracking_lock_status(double coh_integration_time_s) { // ####### CN0 ESTIMATION AND LOCK DETECTORS ###### if (d_cn0_estimation_counter < d_trk_parameters.cn0_samples) @@ -1089,7 +1098,7 @@ bool kf_vtl_tracking::cn0_and_tracking_lock_status(double coh_integration_time_s // - updated remnant code phase in samples (d_rem_code_phase_samples) // - d_code_freq_chips // - d_carrier_doppler_hz -void kf_vtl_tracking::do_correlation_step(const gr_complex *input_samples) +void kf_tracking::do_correlation_step(const gr_complex *input_samples) { // ################# CARRIER WIPEOFF AND CORRELATORS ############################## // perform carrier wipe-off and compute Early, Prompt and Late correlation @@ -1117,7 +1126,7 @@ void kf_vtl_tracking::do_correlation_step(const gr_complex *input_samples) } -void kf_vtl_tracking::run_Kf() +void kf_tracking::run_Kf() { // Carrier discriminator if (d_cloop) @@ -1141,21 +1150,20 @@ void kf_vtl_tracking::run_Kf() d_code_error_disc_chips = dll_nc_e_minus_l_normalized(d_E_accu, d_L_accu, d_trk_parameters.spc, d_trk_parameters.slope, d_trk_parameters.y_intercept); // [chips/Ti] } - // Kalman loop + // Kalman loop // Prediction d_x_new_old = d_F * d_x_old_old; + d_P_new_old = d_F * d_P_old_old * d_F.t() + d_Q; - // Innovation - arma::vec z = {d_code_error_disc_chips, d_carr_phase_error_disc_hz * TWO_PI}; - // Measurement update + arma::vec z = {d_code_error_disc_chips, d_carr_phase_error_disc_hz * TWO_PI}; arma::mat K = d_P_new_old * d_H.t() * arma::inv(d_H * d_P_new_old * d_H.t() + d_R); // Kalman gain d_x_new_new = d_x_new_old + K * z; - d_P_new_new = (arma::eye(5, 5) - K * d_H) * d_P_new_old; + d_P_new_new = (arma::eye(4, 4) - K * d_H) * d_P_new_old; // new code phase estimation d_code_error_kf_chips = d_x_new_new(0); @@ -1165,30 +1173,26 @@ void kf_vtl_tracking::run_Kf() d_carrier_phase_kf_rad = d_x_new_new(1); // New carrier Doppler frequency estimation - d_carrier_doppler_kf_hz = d_x_new_new(2); // d_carrier_loop_filter.get_carrier_error(0, static_cast(d_carr_phase_error_hz), static_cast(d_current_correlation_time_s)); + d_carrier_doppler_kf_hz = d_x_new_new(2); + + // d_carr_freq_error_hz = fll_four_quadrant_atan(d_P_accu_old, d_P_accu, 0, d_current_correlation_time_s) / TWO_PI; + // d_x_new_new(2) = d_x_new_new(2) + fll_four_quadrant_atan(d_P_accu_old, d_P_accu, 0, d_current_correlation_time_s) / TWO_PI; + d_P_accu_old = d_P_accu; d_carrier_doppler_rate_kf_hz_s = d_x_new_new(3); // New code Doppler frequency estimation - if (d_trk_parameters.carrier_aiding) - { - // estimate the code rate exclusively based on the carrier Doppler - d_code_freq_kf_chips_s = d_code_chip_rate + d_carrier_doppler_kf_hz * d_code_chip_rate / d_signal_carrier_freq; - } - else - { - // use its own KF code rate estimation - d_code_freq_kf_chips_s -= d_x_new_new(4); - } - d_x_new_new(4) = 0; - // Experimental: detect Carrier Doppler vs. Code Doppler incoherence and correct the Carrier Doppler - // if (d_trk_parameters.enable_doppler_correction == true) - // { - // if (d_pull_in_transitory == false and d_corrected_doppler == false) - // { - // todo: alforithm here... - // } - // } + d_code_freq_kf_chips_s = d_code_chip_rate + d_carrier_doppler_kf_hz * d_code_chip_rate / d_signal_carrier_freq; + + // d_x_new_new(4) = 0; + // Experimental: detect Carrier Doppler vs. Code Doppler incoherence and correct the Carrier Doppler + // if (d_trk_parameters.enable_doppler_correction == true) + // { + // if (d_pull_in_transitory == false and d_corrected_doppler == false) + // { + // todo: algorithm here... + // } + // } // correct code and carrier phase d_rem_code_phase_samples += d_trk_parameters.fs_in * d_code_error_kf_chips / d_code_freq_kf_chips_s; @@ -1200,7 +1204,7 @@ void kf_vtl_tracking::run_Kf() } -void kf_vtl_tracking::check_carrier_phase_coherent_initialization() +void kf_tracking::check_carrier_phase_coherent_initialization() { if (d_acc_carrier_phase_initialized == false) { @@ -1210,7 +1214,7 @@ void kf_vtl_tracking::check_carrier_phase_coherent_initialization() } -void kf_vtl_tracking::clear_tracking_vars() +void kf_tracking::clear_tracking_vars() { std::fill_n(d_correlator_outs.begin(), d_n_correlator_taps, gr_complex(0.0, 0.0)); if (d_trk_parameters.track_pilot) @@ -1224,11 +1228,13 @@ void kf_vtl_tracking::clear_tracking_vars() d_Prompt_circular_buffer.clear(); d_carrier_phase_rate_step_rad = 0.0; d_code_phase_rate_step_chips = 0.0; + d_carr_ph_history.clear(); + d_code_ph_history.clear(); } // todo: IT DOES NOT WORK WHEN NO KF IS RUNNING (extended correlation epochs!!) -void kf_vtl_tracking::update_tracking_vars() +void kf_tracking::update_tracking_vars() { d_T_chip_seconds = 1.0 / d_code_freq_kf_chips_s; d_T_prn_seconds = d_T_chip_seconds * static_cast(d_code_length_chips); @@ -1237,8 +1243,6 @@ void kf_vtl_tracking::update_tracking_vars() // keep alignment parameters for the next input buffer // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation d_T_prn_samples = d_T_prn_seconds * d_trk_parameters.fs_in; - // d_K_blk_samples = d_T_prn_samples + d_rem_code_phase_samples + d_trk_parameters.fs_in * d_code_error_kf_chips / d_code_freq_kf_chips_s; - // KF will update d_rem_code_phase_samples d_K_blk_samples = d_T_prn_samples + d_rem_code_phase_samples; d_current_prn_length_samples = static_cast(std::floor(d_K_blk_samples)); // round to a discrete number of samples @@ -1247,36 +1251,61 @@ void kf_vtl_tracking::update_tracking_vars() d_carrier_phase_step_rad = TWO_PI * d_carrier_doppler_kf_hz / d_trk_parameters.fs_in; // d_rem_carr_phase_rad = d_carrier_phase_kf_rad; - // remnant carrier phase to prevent overflow in the code NCO - d_rem_carr_phase_rad += static_cast(d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples) + - 0.5 * d_carrier_phase_rate_step_rad * static_cast(d_current_prn_length_samples) * static_cast(d_current_prn_length_samples)); - d_rem_carr_phase_rad = fmod(d_rem_carr_phase_rad, TWO_PI); - // carrier phase rate step (NCO phase increment rate per sample) [rads/sample^2] if (d_trk_parameters.high_dyn) { - d_carrier_phase_rate_step_rad = TWO_PI * d_carrier_doppler_rate_kf_hz_s / d_trk_parameters.fs_in; - } - // std::cout << d_carrier_phase_rate_step_rad * d_trk_parameters.fs_in * d_trk_parameters.fs_in / TWO_PI << '\n'; - // remnant carrier phase to prevent overflow in the code NCO - // d_rem_carr_phase_rad += static_cast(d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples) + 0.5 * d_carrier_phase_rate_step_rad * static_cast(d_current_prn_length_samples) * static_cast(d_current_prn_length_samples)); - // d_rem_carr_phase_rad = fmod(d_rem_carr_phase_rad, TWO_PI); + // d_carrier_phase_rate_step_rad = TWO_PI * d_carrier_doppler_rate_kf_hz_s / d_trk_parameters.fs_in; - // carrier phase accumulator - // double a = d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples); - // double b = 0.5 * d_carrier_phase_rate_step_rad * static_cast(d_current_prn_length_samples) * static_cast(d_current_prn_length_samples); - // std::cout << fmod(b, TWO_PI) / fmod(a, TWO_PI) << '\n'; - d_acc_carrier_phase_rad -= (d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples) + - 0.5 * d_carrier_phase_rate_step_rad * static_cast(d_current_prn_length_samples) * static_cast(d_current_prn_length_samples)); + // d_carrier_doppler_rate_kf_hz_s = d_carrier_phase_rate_step_rad * d_trk_parameters.fs_in / TWO_PI; + d_carr_ph_history.push_back(std::pair(d_carrier_phase_step_rad, static_cast(d_current_prn_length_samples))); + if (d_carr_ph_history.full()) + { + double tmp_cp1 = 0.0; + double tmp_cp2 = 0.0; + double tmp_samples = 0.0; + for (unsigned int k = 0; k < d_trk_parameters.smoother_length; k++) + { + tmp_cp1 += d_carr_ph_history[k].first; + tmp_cp2 += d_carr_ph_history[d_trk_parameters.smoother_length * 2 - k - 1].first; + tmp_samples += d_carr_ph_history[d_trk_parameters.smoother_length * 2 - k - 1].second; + } + tmp_cp1 /= static_cast(d_trk_parameters.smoother_length); + tmp_cp2 /= static_cast(d_trk_parameters.smoother_length); + d_carrier_phase_rate_step_rad = (tmp_cp2 - tmp_cp1) / tmp_samples; + d_x_old_old(3) = d_carrier_phase_rate_step_rad * d_trk_parameters.fs_in / TWO_PI; + } + } + // remnant carrier phase to prevent overflow in the code NCO + auto remnant_carrier_phase = static_cast(d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples) + + 0.5 * d_carrier_phase_rate_step_rad * static_cast(d_current_prn_length_samples) * static_cast(d_current_prn_length_samples)); + d_rem_carr_phase_rad += remnant_carrier_phase; + d_rem_carr_phase_rad = fmod(d_rem_carr_phase_rad, TWO_PI); + + d_acc_carrier_phase_rad -= remnant_carrier_phase; // ################### DLL COMMANDS ################################################# // code phase step (Code resampler phase increment per sample) [chips/sample] d_code_phase_step_chips = d_code_freq_kf_chips_s / d_trk_parameters.fs_in; // todo: extend kf to estimate code rate - // if (d_trk_parameters.high_dyn) - // { - // d_code_phase_rate_step_chips = d_code_freq_kf_rate_chips_s / d_trk_parameters.fs_in; - // } + if (d_trk_parameters.high_dyn) + { + d_code_ph_history.push_back(std::pair(d_code_phase_step_chips, static_cast(d_current_prn_length_samples))); + if (d_code_ph_history.full()) + { + double tmp_cp1 = 0.0; + double tmp_cp2 = 0.0; + double tmp_samples = 0.0; + for (unsigned int k = 0; k < d_trk_parameters.smoother_length; k++) + { + tmp_cp1 += d_code_ph_history[k].first; + tmp_cp2 += d_code_ph_history[d_trk_parameters.smoother_length * 2 - k - 1].first; + tmp_samples += d_code_ph_history[d_trk_parameters.smoother_length * 2 - k - 1].second; + } + tmp_cp1 /= static_cast(d_trk_parameters.smoother_length); + tmp_cp2 /= static_cast(d_trk_parameters.smoother_length); + d_code_phase_rate_step_chips = (tmp_cp2 - tmp_cp1) / tmp_samples; + } + } // remnant code phase [chips] d_rem_code_phase_samples = d_K_blk_samples - static_cast(d_current_prn_length_samples); // rounding error < 1 sample @@ -1284,7 +1313,7 @@ void kf_vtl_tracking::update_tracking_vars() } -void kf_vtl_tracking::save_correlation_results() +void kf_tracking::save_correlation_results() { if (d_secondary) { @@ -1397,7 +1426,7 @@ void kf_vtl_tracking::save_correlation_results() } -void kf_vtl_tracking::log_data() +void kf_tracking::log_data() { if (d_dump) { @@ -1496,7 +1525,7 @@ void kf_vtl_tracking::log_data() } -int32_t kf_vtl_tracking::save_matfile() const +int32_t kf_tracking::save_matfile() const { // READ DUMP FILE std::ifstream::pos_type size; @@ -1696,7 +1725,7 @@ int32_t kf_vtl_tracking::save_matfile() const } -void kf_vtl_tracking::set_channel(uint32_t channel) +void kf_tracking::set_channel(uint32_t channel) { gr::thread::scoped_lock l(d_setlock); d_channel = channel; @@ -1727,21 +1756,21 @@ void kf_vtl_tracking::set_channel(uint32_t channel) } -void kf_vtl_tracking::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) +void kf_tracking::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) { gr::thread::scoped_lock l(d_setlock); d_acquisition_gnss_synchro = p_gnss_synchro; } -void kf_vtl_tracking::stop_tracking() +void kf_tracking::stop_tracking() { gr::thread::scoped_lock l(d_setlock); d_state = 0; } -int kf_vtl_tracking::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items, +int kf_tracking::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { gr::thread::scoped_lock l(d_setlock); @@ -1792,18 +1821,7 @@ int kf_vtl_tracking::general_work(int noutput_items __attribute__((unused)), gr_ d_cn0_smoother.reset(); d_carrier_lock_test_smoother.reset(); - // init KF - // d_T_chip_seconds = 1.0 / d_code_freq_chips; - // d_T_prn_seconds = d_T_chip_seconds * static_cast(samples_offset); - // // keep alignment parameters for the next input buffer - // // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation - // d_T_prn_samples = d_T_prn_seconds * d_trk_parameters.fs_in; - // d_K_blk_samples = d_T_prn_samples + d_rem_code_phase_samples; - // // remnant code phase [chips] - // d_rem_code_phase_samples = d_K_blk_samples - static_cast(d_current_prn_length_samples); // rounding error < 1 sample - // d_rem_code_phase_chips = d_code_freq_chips * d_rem_code_phase_samples / d_trk_parameters.fs_in; - - init_kf(0, d_carrier_doppler_kf_hz); + init_kf(0.0, d_carrier_doppler_kf_hz); LOG(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_kf_hz @@ -1956,7 +1974,8 @@ int kf_vtl_tracking::general_work(int noutput_items __attribute__((unused)), gr_ // perform a correlation step do_correlation_step(in); save_correlation_results(); - update_tracking_vars(); + // run_Kf(); + update_tracking_vars(); // ? if (d_current_data_symbol == 0) { log_data(); @@ -2003,13 +2022,7 @@ int kf_vtl_tracking::general_work(int noutput_items __attribute__((unused)), gr_ } else { - if (d_trk_parameters.use_estimated_cn0 == true) - { - if (d_CN0_SNV_dB_Hz > 0) - { - update_kf_cn0(d_CN0_SNV_dB_Hz); - } - } + update_kf_cn0(d_CN0_SNV_dB_Hz); run_Kf(); update_tracking_vars(); check_carrier_phase_coherent_initialization(); diff --git a/src/algorithms/tracking/gnuradio_blocks/kf_vtl_tracking.h b/src/algorithms/tracking/gnuradio_blocks/kf_tracking.h similarity index 91% rename from src/algorithms/tracking/gnuradio_blocks/kf_vtl_tracking.h rename to src/algorithms/tracking/gnuradio_blocks/kf_tracking.h index eb3152ff2..37e38b679 100644 --- a/src/algorithms/tracking/gnuradio_blocks/kf_vtl_tracking.h +++ b/src/algorithms/tracking/gnuradio_blocks/kf_tracking.h @@ -1,5 +1,5 @@ /*! - * \file kf_vtl_tracking.cc + * \file kf_tracking.cc * \brief Implementation of a Kalman filter based tracking with optional Vector * Tracking Loop message receiver block. * \author Javier Arribas, 2020. jarribas(at)cttc.es @@ -18,8 +18,8 @@ * ----------------------------------------------------------------------------- */ -#ifndef GNSS_SDR_KF_VTL_TRACKING_H -#define GNSS_SDR_KF_VTL_TRACKING_H +#ifndef GNSS_SDR_KF_TRACKING_H +#define GNSS_SDR_KF_TRACKING_H #if ARMA_NO_BOUND_CHECKING #define ARMA_NO_DEBUG 1 @@ -48,19 +48,19 @@ #include // for pair class Gnss_Synchro; -class kf_vtl_tracking; +class kf_tracking; -using kf_vtl_tracking_sptr = gnss_shared_ptr; +using kf_tracking_sptr = gnss_shared_ptr; -kf_vtl_tracking_sptr kf_vtl_make_tracking(const Kf_Conf &conf_); +kf_tracking_sptr kf_make_tracking(const Kf_Conf &conf_); /*! * \brief This class implements a code DLL + carrier PLL tracking block. */ -class kf_vtl_tracking : public gr::block +class kf_tracking : public gr::block { public: - ~kf_vtl_tracking(); + ~kf_tracking(); void set_channel(uint32_t channel); void set_gnss_synchro(Gnss_Synchro *p_gnss_synchro); @@ -73,8 +73,8 @@ public: void forecast(int noutput_items, gr_vector_int &ninput_items_required); private: - friend kf_vtl_tracking_sptr kf_vtl_make_tracking(const Kf_Conf &conf_); - explicit kf_vtl_tracking(const Kf_Conf &conf_); + friend kf_tracking_sptr kf_make_tracking(const Kf_Conf &conf_); + explicit kf_tracking(const Kf_Conf &conf_); void init_kf(double acq_code_phase_chips, double acq_doppler_hz); void update_kf_narrow_integration_time(); @@ -112,6 +112,8 @@ private: volk_gnsssdr::vector d_Prompt_buffer; boost::circular_buffer d_Prompt_circular_buffer; + boost::circular_buffer> d_code_ph_history; + boost::circular_buffer> d_carr_ph_history; const size_t d_int_type_hash_code = typeid(int).hash_code(); @@ -193,6 +195,8 @@ private: double d_rem_code_phase_chips; double d_rem_code_phase_samples; + double d_beta; + uint64_t d_sample_counter; uint64_t d_acq_sample_stamp; @@ -229,4 +233,4 @@ private: bool d_enable_extended_integration; }; -#endif // GNSS_SDR_KF_VTL_TRACKING_H +#endif // GNSS_SDR_KF_TRACKING_H diff --git a/src/algorithms/tracking/libs/kf_conf.cc b/src/algorithms/tracking/libs/kf_conf.cc index 735098008..80b049c38 100644 --- a/src/algorithms/tracking/libs/kf_conf.cc +++ b/src/algorithms/tracking/libs/kf_conf.cc @@ -28,24 +28,16 @@ Kf_Conf::Kf_Conf() : item_type("gr_complex"), dump_filename("./Kf_dump.dat"), fs_in(2000000.0), carrier_lock_th(FLAGS_carrier_lock_th), - expected_cn0_dbhz(42.0), - code_disc_sd_chips(0.01), - carrier_disc_sd_rads(0.1), - code_phase_sd_chips(0.001), - code_rate_sd_chips_s(0.001), - carrier_phase_sd_rad(0.001), - carrier_freq_sd_hz(0.1), - carrier_freq_rate_sd_hz_s(1), - narrow_code_phase_sd_chips(0.001), - narrow_code_rate_sd_chips_s(0.001), - narrow_carrier_phase_sd_rad(0.001), - narrow_carrier_freq_sd_hz(0.1), - narrow_carrier_freq_rate_sd_hz_s(1), - init_code_phase_sd_chips(1), - init_code_rate_sd_chips_s(100), - init_carrier_phase_sd_rad(10), - init_carrier_freq_sd_hz(1000), - init_carrier_freq_rate_sd_hz_s(1000), + code_disc_sd_chips(0.2), + carrier_disc_sd_rads(0.3), + code_phase_sd_chips(0.15), + carrier_phase_sd_rad(0.25), + carrier_freq_sd_hz(0.6), + carrier_freq_rate_sd_hz_s(0.01), + init_code_phase_sd_chips(0.5), + init_carrier_phase_sd_rad(0.7), + init_carrier_freq_sd_hz(5), + init_carrier_freq_rate_sd_hz_s(1), early_late_space_chips(0.25), very_early_late_space_chips(0.5), early_late_space_narrow_chips(0.15), @@ -69,12 +61,9 @@ Kf_Conf::Kf_Conf() : item_type("gr_complex"), system('G'), track_pilot(true), enable_doppler_correction(false), - carrier_aiding(true), high_dyn(false), dump(false), - dump_mat(true), - enable_dynamic_measurement_covariance(false), - use_estimated_cn0(false) + dump_mat(true) { signal[0] = '1'; signal[1] = 'C'; @@ -112,7 +101,6 @@ void Kf_Conf::SetFromConfiguration(const ConfigurationInterface *configuration, max_code_lock_fail = configuration->property(role + ".max_lock_fail", max_code_lock_fail); max_carrier_lock_fail = configuration->property(role + ".max_carrier_lock_fail", max_carrier_lock_fail); carrier_lock_th = configuration->property(role + ".carrier_lock_th", carrier_lock_th); - carrier_aiding = configuration->property(role + ".carrier_aiding", carrier_aiding); // tracking lock tests smoother parameters cn0_smoother_samples = configuration->property(role + ".cn0_smoother_samples", cn0_smoother_samples); @@ -129,34 +117,17 @@ void Kf_Conf::SetFromConfiguration(const ConfigurationInterface *configuration, // Kalman filter covariances // Measurement covariances (R) - expected_cn0_dbhz = configuration->property(role + ".expected_cn0_dbhz", expected_cn0_dbhz); - code_disc_sd_chips = configuration->property(role + ".code_disc_sd_chips", code_disc_sd_chips); carrier_disc_sd_rads = configuration->property(role + ".carrier_disc_sd_rads", carrier_disc_sd_rads); - enable_dynamic_measurement_covariance = configuration->property(role + ".enable_dynamic_measurement_covariance", enable_dynamic_measurement_covariance); - use_estimated_cn0 = configuration->property(role + ".use_estimated_cn0", use_estimated_cn0); - // System covariances (Q) code_phase_sd_chips = configuration->property(role + ".code_phase_sd_chips", code_phase_sd_chips); - code_rate_sd_chips_s = configuration->property(role + ".code_rate_sd_chips_s", code_rate_sd_chips_s); - carrier_phase_sd_rad = configuration->property(role + ".carrier_phase_sd_rad", carrier_phase_sd_rad); carrier_freq_sd_hz = configuration->property(role + ".carrier_freq_sd_hz", carrier_freq_sd_hz); carrier_freq_rate_sd_hz_s = configuration->property(role + ".carrier_freq_rate_sd_hz_s", carrier_freq_rate_sd_hz_s); - // System covariances (narrow) (Q) - narrow_code_phase_sd_chips = configuration->property(role + ".narrow_code_phase_sd_chips", narrow_code_phase_sd_chips); - narrow_code_rate_sd_chips_s = configuration->property(role + ".narrow_code_rate_sd_chips_s", narrow_code_rate_sd_chips_s); - - narrow_carrier_phase_sd_rad = configuration->property(role + ".narrow_carrier_phase_sd_rad", narrow_carrier_phase_sd_rad); - narrow_carrier_freq_sd_hz = configuration->property(role + ".narrow_carrier_freq_sd_hz", narrow_carrier_freq_sd_hz); - narrow_carrier_freq_rate_sd_hz_s = configuration->property(role + ".narrow_carrier_freq_rate_sd_hz_s", narrow_carrier_freq_rate_sd_hz_s); - // initial Kalman covariance matrix (P) init_code_phase_sd_chips = configuration->property(role + ".init_code_phase_sd_chips", init_code_phase_sd_chips); - init_code_rate_sd_chips_s = configuration->property(role + ".init_code_rate_sd_chips_s", init_code_rate_sd_chips_s); - init_carrier_phase_sd_rad = configuration->property(role + ".init_carrier_phase_sd_rad", init_carrier_phase_sd_rad); init_carrier_freq_sd_hz = configuration->property(role + ".init_carrier_freq_sd_hz", init_carrier_freq_sd_hz); init_carrier_freq_rate_sd_hz_s = configuration->property(role + ".init_carrier_freq_rate_sd_hz_s", init_carrier_freq_rate_sd_hz_s); diff --git a/src/algorithms/tracking/libs/kf_conf.h b/src/algorithms/tracking/libs/kf_conf.h index 43c2ef0a5..fe7d620b3 100644 --- a/src/algorithms/tracking/libs/kf_conf.h +++ b/src/algorithms/tracking/libs/kf_conf.h @@ -38,33 +38,18 @@ public: double carrier_lock_th; // KF statistics - // states: code_phase_chips, carrier_phase_rads, carrier_freq_hz, carrier_freq_rate_hz_s, code_freq_rate_chips_s // Measurement covariances (R) - double expected_cn0_dbhz; - double code_disc_sd_chips; double carrier_disc_sd_rads; // System covariances (Q) double code_phase_sd_chips; - double code_rate_sd_chips_s; - double carrier_phase_sd_rad; double carrier_freq_sd_hz; double carrier_freq_rate_sd_hz_s; - // System covariances (narrow) (Q) - double narrow_code_phase_sd_chips; - double narrow_code_rate_sd_chips_s; - - double narrow_carrier_phase_sd_rad; - double narrow_carrier_freq_sd_hz; - double narrow_carrier_freq_rate_sd_hz_s; - // initial Kalman covariance matrix (P) double init_code_phase_sd_chips; - double init_code_rate_sd_chips_s; - double init_carrier_phase_sd_rad; double init_carrier_freq_sd_hz; double init_carrier_freq_rate_sd_hz_s; @@ -93,13 +78,9 @@ public: char system; bool track_pilot; bool enable_doppler_correction; - bool carrier_aiding; bool high_dyn; bool dump; bool dump_mat; - - bool enable_dynamic_measurement_covariance; - bool use_estimated_cn0; }; #endif diff --git a/src/core/receiver/gnss_block_factory.cc b/src/core/receiver/gnss_block_factory.cc index d45cb79c4..e1a6d3f15 100644 --- a/src/core/receiver/gnss_block_factory.cc +++ b/src/core/receiver/gnss_block_factory.cc @@ -73,8 +73,8 @@ #include "gnss_sdr_make_unique.h" #include "gnss_sdr_string_literals.h" #include "gps_l1_ca_dll_pll_tracking.h" +#include "gps_l1_ca_gaussian_tracking.h" #include "gps_l1_ca_kf_tracking.h" -#include "gps_l1_ca_kf_vtl_tracking.h" #include "gps_l1_ca_pcps_acquisition.h" #include "gps_l1_ca_pcps_acquisition_fine_doppler.h" #include "gps_l1_ca_pcps_assisted_acquisition.h" @@ -1093,15 +1093,15 @@ std::unique_ptr GNSSBlockFactory::GetBlock( out_streams); block = std::move(block_); } - else if (implementation == "GPS_L1_CA_KF_Tracking") + else if (implementation == "GPS_L1_CA_Gaussian_Tracking") { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, out_streams); block = std::move(block_); } - else if (implementation == "GPS_L1_CA_KF_VTL_Tracking") + else if (implementation == "GPS_L1_CA_KF_Tracking") { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, out_streams); block = std::move(block_); } @@ -1549,15 +1549,15 @@ std::unique_ptr GNSSBlockFactory::GetTrkBlock( out_streams); block = std::move(block_); } - else if (implementation == "GPS_L1_CA_KF_Tracking") + else if (implementation == "GPS_L1_CA_Gaussian_Tracking") { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, out_streams); block = std::move(block_); } - else if (implementation == "GPS_L1_CA_KF_VTL_Tracking") + else if (implementation == "GPS_L1_CA_KF_Tracking") { - std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, + std::unique_ptr block_ = std::make_unique(configuration, role, in_streams, out_streams); block = std::move(block_); } diff --git a/src/tests/test_main.cc b/src/tests/test_main.cc index 6efe155cd..894fb66d0 100644 --- a/src/tests/test_main.cc +++ b/src/tests/test_main.cc @@ -141,7 +141,7 @@ DECLARE_string(log_dir); #include "unit-tests/signal-processing-blocks/acquisition/gps_l2_m_pcps_acquisition_test.cc" // #include "unit-tests/signal-processing-blocks/pvt/rtklib_solver_test.cc" #include "unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc" -#include "unit-tests/signal-processing-blocks/tracking/gps_l1_ca_kf_tracking_test.cc" +#include "unit-tests/signal-processing-blocks/tracking/gps_l1_ca_gaussian_tracking_test.cc" #include "unit-tests/signal-processing-blocks/tracking/gps_l2_m_dll_pll_tracking_test.cc" #include "unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test.cc" #if FPGA_BLOCKS_TEST diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_kf_tracking_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_gaussian_tracking_test.cc similarity index 90% rename from src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_kf_tracking_test.cc rename to src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_gaussian_tracking_test.cc index ae94e744a..fbd1b2d0f 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_kf_tracking_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_gaussian_tracking_test.cc @@ -1,6 +1,6 @@ /*! - * \file gps_l1_ca_kf_tracking_test.cc - * \brief This class implements a tracking test for GPS_L1_CA_KF_Tracking + * \file gps_l1_ca_gaussian_tracking_test.cc + * \brief This class implements a tracking test for GPS_L1_CA_Gaussian_Tracking * implementation based on some input parameters. * \author Carles Fernandez, 2018 * @@ -60,37 +60,37 @@ namespace wht = boost; namespace wht = std; #endif -DEFINE_bool(plot_gps_l1_kf_tracking_test, false, "Plots results of GpsL1CAKfTrackingTest with gnuplot"); +DEFINE_bool(plot_gps_l1_gaussian_tracking_test, false, "Plots results of GpsL1CAGaussianTrackingTest with gnuplot"); // ######## GNURADIO BLOCK MESSAGE RECEVER ######### -class GpsL1CAKfTrackingTest_msg_rx; +class GpsL1CAGaussianTrackingTest_msg_rx; -using GpsL1CAKfTrackingTest_msg_rx_sptr = gnss_shared_ptr; +using GpsL1CAGaussianTrackingTest_msg_rx_sptr = gnss_shared_ptr; -GpsL1CAKfTrackingTest_msg_rx_sptr GpsL1CAKfTrackingTest_msg_rx_make(); +GpsL1CAGaussianTrackingTest_msg_rx_sptr GpsL1CAGaussianTrackingTest_msg_rx_make(); -class GpsL1CAKfTrackingTest_msg_rx : public gr::block +class GpsL1CAGaussianTrackingTest_msg_rx : public gr::block { private: - friend GpsL1CAKfTrackingTest_msg_rx_sptr GpsL1CAKfTrackingTest_msg_rx_make(); + friend GpsL1CAGaussianTrackingTest_msg_rx_sptr GpsL1CAGaussianTrackingTest_msg_rx_make(); void msg_handler_channel_events(const pmt::pmt_t msg); - GpsL1CAKfTrackingTest_msg_rx(); + GpsL1CAGaussianTrackingTest_msg_rx(); public: int rx_message; - ~GpsL1CAKfTrackingTest_msg_rx(); //!< Default destructor + ~GpsL1CAGaussianTrackingTest_msg_rx(); //!< Default destructor }; -GpsL1CAKfTrackingTest_msg_rx_sptr GpsL1CAKfTrackingTest_msg_rx_make() +GpsL1CAGaussianTrackingTest_msg_rx_sptr GpsL1CAGaussianTrackingTest_msg_rx_make() { - return GpsL1CAKfTrackingTest_msg_rx_sptr(new GpsL1CAKfTrackingTest_msg_rx()); + return GpsL1CAGaussianTrackingTest_msg_rx_sptr(new GpsL1CAGaussianTrackingTest_msg_rx()); } -void GpsL1CAKfTrackingTest_msg_rx::msg_handler_channel_events(const pmt::pmt_t msg) +void GpsL1CAGaussianTrackingTest_msg_rx::msg_handler_channel_events(const pmt::pmt_t msg) { try { @@ -105,7 +105,7 @@ void GpsL1CAKfTrackingTest_msg_rx::msg_handler_channel_events(const pmt::pmt_t m } -GpsL1CAKfTrackingTest_msg_rx::GpsL1CAKfTrackingTest_msg_rx() : gr::block("GpsL1CAKfTrackingTest_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)) +GpsL1CAGaussianTrackingTest_msg_rx::GpsL1CAGaussianTrackingTest_msg_rx() : gr::block("GpsL1CAGaussianTrackingTest_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)) { this->message_port_register_in(pmt::mp("events")); this->set_msg_handler(pmt::mp("events"), @@ -113,21 +113,21 @@ GpsL1CAKfTrackingTest_msg_rx::GpsL1CAKfTrackingTest_msg_rx() : gr::block("GpsL1C [this](auto&& PH1) { msg_handler_channel_events(PH1); }); #else #if USE_BOOST_BIND_PLACEHOLDERS - boost::bind(&GpsL1CAKfTrackingTest_msg_rx::msg_handler_channel_events, this, boost::placeholders::_1)); + boost::bind(&GpsL1CAGaussianTrackingTest_msg_rx::msg_handler_channel_events, this, boost::placeholders::_1)); #else - boost::bind(&GpsL1CAKfTrackingTest_msg_rx::msg_handler_channel_events, this, _1)); + boost::bind(&GpsL1CAGaussianTrackingTest_msg_rx::msg_handler_channel_events, this, _1)); #endif #endif rx_message = 0; } -GpsL1CAKfTrackingTest_msg_rx::~GpsL1CAKfTrackingTest_msg_rx() = default; +GpsL1CAGaussianTrackingTest_msg_rx::~GpsL1CAGaussianTrackingTest_msg_rx() = default; // ########################################################### -class GpsL1CAKfTrackingTest : public ::testing::Test +class GpsL1CAGaussianTrackingTest : public ::testing::Test { public: std::string generator_binary; @@ -137,7 +137,7 @@ public: std::string p4; std::string p5; - std::string implementation = "GPS_L1_CA_KF_Tracking"; + std::string implementation = "GPS_L1_CA_Gaussian_Tracking"; const int baseband_sampling_freq = FLAGS_fs_gen_sps; @@ -159,7 +159,7 @@ public: arma::vec& meas_time_s, arma::vec& meas_value); - GpsL1CAKfTrackingTest() + GpsL1CAGaussianTrackingTest() { factory = std::make_shared(); config = std::make_shared(); @@ -167,7 +167,7 @@ public: gnss_synchro = Gnss_Synchro(); } - ~GpsL1CAKfTrackingTest() = default; + ~GpsL1CAGaussianTrackingTest() = default; void configure_receiver(); @@ -179,7 +179,7 @@ public: }; -int GpsL1CAKfTrackingTest::configure_generator() +int GpsL1CAGaussianTrackingTest::configure_generator() { // Configure signal generator generator_binary = FLAGS_generator_binary; @@ -200,7 +200,7 @@ int GpsL1CAKfTrackingTest::configure_generator() } -int GpsL1CAKfTrackingTest::generate_signal() +int GpsL1CAGaussianTrackingTest::generate_signal() { int child_status; @@ -225,7 +225,7 @@ int GpsL1CAKfTrackingTest::generate_signal() } -void GpsL1CAKfTrackingTest::configure_receiver() +void GpsL1CAGaussianTrackingTest::configure_receiver() { gnss_synchro.Channel_ID = 0; gnss_synchro.System = 'G'; @@ -252,7 +252,7 @@ void GpsL1CAKfTrackingTest::configure_receiver() } -void GpsL1CAKfTrackingTest::check_results_doppler(arma::vec& true_time_s, +void GpsL1CAGaussianTrackingTest::check_results_doppler(arma::vec& true_time_s, arma::vec& true_value, arma::vec& meas_time_s, arma::vec& meas_value) @@ -291,7 +291,7 @@ void GpsL1CAKfTrackingTest::check_results_doppler(arma::vec& true_time_s, } -void GpsL1CAKfTrackingTest::check_results_acc_carrier_phase(arma::vec& true_time_s, +void GpsL1CAGaussianTrackingTest::check_results_acc_carrier_phase(arma::vec& true_time_s, arma::vec& true_value, arma::vec& meas_time_s, arma::vec& meas_value) @@ -330,7 +330,7 @@ void GpsL1CAKfTrackingTest::check_results_acc_carrier_phase(arma::vec& true_time } -void GpsL1CAKfTrackingTest::check_results_codephase(arma::vec& true_time_s, +void GpsL1CAGaussianTrackingTest::check_results_codephase(arma::vec& true_time_s, arma::vec& true_value, arma::vec& meas_time_s, arma::vec& meas_value) @@ -370,7 +370,7 @@ void GpsL1CAKfTrackingTest::check_results_codephase(arma::vec& true_time_s, } -TEST_F(GpsL1CAKfTrackingTest, ValidationOfResults) +TEST_F(GpsL1CAGaussianTrackingTest, ValidationOfResults) { // Configure the signal generator configure_generator(); @@ -399,7 +399,7 @@ TEST_F(GpsL1CAKfTrackingTest, ValidationOfResults) std::shared_ptr trk_ = factory->GetBlock(config.get(), "Tracking_1C", 1, 1); std::shared_ptr tracking = std::dynamic_pointer_cast(trk_); // std::make_shared(config.get(), "Tracking_1C", 1, 1); - auto msg_rx = GpsL1CAKfTrackingTest_msg_rx_make(); + auto msg_rx = GpsL1CAGaussianTrackingTest_msg_rx_make(); // load acquisition data based on the first epoch of the true observations ASSERT_EQ(true_obs_data.read_binary_obs(), true) @@ -523,7 +523,7 @@ TEST_F(GpsL1CAKfTrackingTest, ValidationOfResults) std::chrono::duration elapsed_seconds = end - start; std::cout << "Signal tracking completed in " << elapsed_seconds.count() << " seconds.\n"; - if (FLAGS_plot_gps_l1_kf_tracking_test == true) + if (FLAGS_plot_gps_l1_gaussian_tracking_test == true) { const std::string gnuplot_executable(FLAGS_gnuplot_executable); if (gnuplot_executable.empty())