From a29f52e2e48b184e10d0cf3d5bc5f781f05a2980 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 5 Jul 2023 19:37:35 +0200 Subject: [PATCH] Make clang-tidy happy --- src/algorithms/PVT/libs/pvt_kf.cc | 21 ++++++++---------- src/algorithms/PVT/libs/pvt_kf.h | 14 ++++++------ src/algorithms/PVT/libs/rtklib_solver.cc | 5 ++--- src/algorithms/PVT/libs/rtklib_solver.h | 4 ++-- .../adapters/file_timestamp_signal_source.cc | 22 ++++++++++++------- .../adapters/file_timestamp_signal_source.h | 3 ++- 6 files changed, 36 insertions(+), 33 deletions(-) diff --git a/src/algorithms/PVT/libs/pvt_kf.cc b/src/algorithms/PVT/libs/pvt_kf.cc index fc06b8757..a0fdda1d3 100644 --- a/src/algorithms/PVT/libs/pvt_kf.cc +++ b/src/algorithms/PVT/libs/pvt_kf.cc @@ -1,5 +1,5 @@ /*! - * \file Pvt_Kf.cc + * \file pvt_kf.cc * \brief Kalman Filter for Position and Velocity * \author Javier Arribas, 2023. jarribas(at)cttc.es * @@ -14,11 +14,13 @@ * * ----------------------------------------------------------------------------- */ + #include "pvt_kf.h" #include -void Pvt_Kf::init_kf(arma::vec p, arma::vec v, +void Pvt_Kf::init_kf(const arma::vec& p, + const arma::vec& v, double solver_interval_s, double measures_ecef_pos_sd_m, double measures_ecef_vel_sd_ms, @@ -28,7 +30,6 @@ void Pvt_Kf::init_kf(arma::vec p, arma::vec v, // Kalman Filter class variables const double Ti = solver_interval_s; - std::cout << "Ti=" << Ti << "\n"; d_F = {{1.0, 0.0, 0.0, Ti, 0.0, 0.0}, {0.0, 1.0, 0.0, 0.0, Ti, 0.0}, {0.0, 0.0, 1.0, 0.0, 0.0, Ti}, @@ -38,7 +39,7 @@ void Pvt_Kf::init_kf(arma::vec p, arma::vec v, d_H = arma::eye(6, 6); - // measurement matrix static covariances + // measurement matrix static covariances d_R = {{pow(measures_ecef_pos_sd_m, 2.0), 0.0, 0.0, 0.0, 0.0, 0.0}, {0.0, pow(measures_ecef_pos_sd_m, 2.0), 0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, pow(measures_ecef_pos_sd_m, 2.0), 0.0, 0.0, 0.0}, @@ -46,9 +47,7 @@ void Pvt_Kf::init_kf(arma::vec p, arma::vec v, {0.0, 0.0, 0.0, 0.0, pow(measures_ecef_vel_sd_ms, 2.0), 0.0}, {0.0, 0.0, 0.0, 0.0, 0.0, pow(measures_ecef_vel_sd_ms, 2.0)}}; - // system covariance matrix (static) - d_Q = {{pow(system_ecef_pos_sd_m, 2.0), 0.0, 0.0, 0.0, 0.0, 0.0}, {0.0, pow(system_ecef_pos_sd_m, 2.0), 0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, pow(system_ecef_pos_sd_m, 2.0), 0.0, 0.0, 0.0}, @@ -71,6 +70,7 @@ void Pvt_Kf::init_kf(arma::vec p, arma::vec v, initialized = true; + DLOG(INFO) << "Ti: " << Ti; DLOG(INFO) << "F: " << d_F; DLOG(INFO) << "H: " << d_H; DLOG(INFO) << "R: " << d_R; @@ -79,9 +79,10 @@ void Pvt_Kf::init_kf(arma::vec p, arma::vec v, DLOG(INFO) << "x: " << d_x_old_old; } -void Pvt_Kf::run_Kf(arma::vec p, arma::vec v) + +void Pvt_Kf::run_Kf(const arma::vec& p, const arma::vec& v); { - // 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; @@ -98,10 +99,6 @@ void Pvt_Kf::run_Kf(arma::vec p, arma::vec v) d_P_old_old = d_P_new_new; } -Pvt_Kf::Pvt_Kf() -{ - initialized = false; -} void Pvt_Kf::get_pvt(arma::vec& p, arma::vec& v) { diff --git a/src/algorithms/PVT/libs/pvt_kf.h b/src/algorithms/PVT/libs/pvt_kf.h index ce1a3f8ba..26dc25a43 100644 --- a/src/algorithms/PVT/libs/pvt_kf.h +++ b/src/algorithms/PVT/libs/pvt_kf.h @@ -1,5 +1,5 @@ /*! - * \file Pvt_Kf.h + * \file pvt_kf.h * \brief Kalman Filter for Position and Velocity * \author Javier Arribas, 2023. jarribas(at)cttc.es * @@ -33,18 +33,18 @@ class Pvt_Kf { public: - Pvt_Kf(); + Pvt_Kf() = default; virtual ~Pvt_Kf() = default; - void init_kf(arma::vec p, arma::vec v, + void init_kf(const arma::vec& p, + const arma::vec& v, double solver_interval_s, double measures_ecef_pos_sd_m, double measures_ecef_vel_sd_ms, double system_ecef_pos_sd_m, double system_ecef_vel_sd_ms); - - void run_Kf(arma::vec p, arma::vec v); - bool initialized; - void get_pvt(arma::vec &p, arma::vec &v); + void run_Kf(const arma::vec& p, const arma::vec& v); + void get_pvt(arma::vec& p, arma::vec& v); + bool initialized{false}; private: // Kalman Filter class variables diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc index 70384d613..e17edfa14 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.cc +++ b/src/algorithms/PVT/libs/rtklib_solver.cc @@ -51,11 +51,10 @@ Rtklib_Solver::Rtklib_Solver(const rtk_t &rtk, bool flag_dump_to_mat, Pvt_Conf conf) : d_dump_filename(dump_filename), d_rtk(rtk), + d_conf(std::move(conf)), d_type_of_rx(type_of_rx), d_flag_dump_enabled(flag_dump_to_file), - d_flag_dump_mat_enabled(flag_dump_to_mat), - d_conf(conf) - + d_flag_dump_mat_enabled(flag_dump_to_mat) { this->set_averaging_flag(false); diff --git a/src/algorithms/PVT/libs/rtklib_solver.h b/src/algorithms/PVT/libs/rtklib_solver.h index b967cb02f..7bffa042d 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.h +++ b/src/algorithms/PVT/libs/rtklib_solver.h @@ -151,11 +151,11 @@ private: rtk_t d_rtk{}; nav_t d_nav_data{}; Monitor_Pvt d_monitor_pvt{}; + Pvt_Conf d_conf; + Pvt_Kf d_pvt_kf; uint32_t d_type_of_rx; bool d_flag_dump_enabled; bool d_flag_dump_mat_enabled; - Pvt_Conf d_conf; - Pvt_Kf d_pvt_kf; }; diff --git a/src/algorithms/signal_source/adapters/file_timestamp_signal_source.cc b/src/algorithms/signal_source/adapters/file_timestamp_signal_source.cc index 8e17180f8..8a7c2958f 100644 --- a/src/algorithms/signal_source/adapters/file_timestamp_signal_source.cc +++ b/src/algorithms/signal_source/adapters/file_timestamp_signal_source.cc @@ -1,6 +1,7 @@ /*! - * \file file_timestamp_signal_source.h - * \brief This class reads samples stored in a file and generate stream tags with its timestamp information stored in separated file + * \file file_timestamp_signal_source.cc + * \brief This class reads samples stored in a file and generate stream tags + * with its timestamp information stored in separated file * \author Javier Arribas, jarribas(at)cttc.es * * ----------------------------------------------------------------------------- @@ -13,6 +14,7 @@ * * ----------------------------------------------------------------------------- */ + #include "file_timestamp_signal_source.h" #include "gnss_sdr_flags.h" #include "gnss_sdr_string_literals.h" @@ -22,7 +24,9 @@ using namespace std::string_literals; FileTimestampSignalSource::FileTimestampSignalSource(const ConfigurationInterface* configuration, - const std::string& role, unsigned int in_streams, unsigned int out_streams, + const std::string& role, + unsigned int in_streams, + unsigned int out_streams, Concurrent_Queue* queue) : FileSourceBase(configuration, role, "File_Timestamp_Signal_Source"s, queue, "byte"s), timestamp_file_(configuration->property(role + ".timestamp_filename"s, "../data/example_capture_timestamp.dat"s)), @@ -53,23 +57,23 @@ void FileTimestampSignalSource::create_file_source_hook() int source_items_to_samples = 1; bool is_complex = false; - if (item_type().compare("ibyte") == 0) + if (item_type() == "ibyte") { source_items_to_samples = 1; } - else if (item_type().compare("byte") == 0) + else if (item_type() == "byte") { source_items_to_samples = 1; } - else if (item_type().compare("short") == 0) + else if (item_type() == "short") { source_items_to_samples = 1; } - else if (item_type().compare("ishort") == 0) + else if (item_type() == "ishort") { source_items_to_samples = 1; } - else if (item_type().compare("gr_complex") == 0) + else if (item_type() == "gr_complex") { source_items_to_samples = 1; is_complex = true; @@ -96,12 +100,14 @@ void FileTimestampSignalSource::create_file_source_hook() DLOG(INFO) << "timestamp_block_(" << timestamp_block_->unique_id() << ")"; } + void FileTimestampSignalSource::pre_connect_hook(gr::top_block_sptr top_block) { top_block->connect(file_source(), 0, timestamp_block_, 0); DLOG(INFO) << "connected file_source to timestamp_block_"; } + void FileTimestampSignalSource::pre_disconnect_hook(gr::top_block_sptr top_block) { top_block->disconnect(file_source(), 0, timestamp_block_, 0); diff --git a/src/algorithms/signal_source/adapters/file_timestamp_signal_source.h b/src/algorithms/signal_source/adapters/file_timestamp_signal_source.h index f95b3622e..0c82cab86 100644 --- a/src/algorithms/signal_source/adapters/file_timestamp_signal_source.h +++ b/src/algorithms/signal_source/adapters/file_timestamp_signal_source.h @@ -1,6 +1,7 @@ /*! * \file file_timestamp_signal_source.h - * \brief This class reads samples stored in a file and generate stream tags with its timestamp information stored in separated file + * \brief This class reads samples stored in a file and generate stream tags + * with its timestamp information stored in separated file * \author Javier Arribas, jarribas(at)cttc.es * * -----------------------------------------------------------------------------