From 29a910df300bdbae55bb451ccb7295a4f643a261 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 7 Jul 2019 19:56:23 +0200 Subject: [PATCH] Simplify initializations --- .../PVT/libs/monitor_pvt_udp_sink.cc | 28 ----------- .../PVT/libs/monitor_pvt_udp_sink.h | 2 +- src/algorithms/PVT/libs/rtklib_solver.cc | 46 ++----------------- src/algorithms/PVT/libs/rtklib_solver.h | 10 ++-- src/algorithms/PVT/libs/serdes_monitor_pvt.h | 5 +- src/core/monitor/serdes_gnss_synchro.h | 6 +-- src/core/receiver/file_configuration.h | 2 +- src/core/system_parameters/gnss_signal.cc | 41 ----------------- src/core/system_parameters/gnss_signal.h | 4 -- 9 files changed, 17 insertions(+), 127 deletions(-) diff --git a/src/algorithms/PVT/libs/monitor_pvt_udp_sink.cc b/src/algorithms/PVT/libs/monitor_pvt_udp_sink.cc index 0e962207b..2796f13da 100644 --- a/src/algorithms/PVT/libs/monitor_pvt_udp_sink.cc +++ b/src/algorithms/PVT/libs/monitor_pvt_udp_sink.cc @@ -42,34 +42,6 @@ Monitor_Pvt_Udp_Sink::Monitor_Pvt_Udp_Sink(const std::vector& addre boost::asio::ip::udp::endpoint endpoint(boost::asio::ip::address::from_string(address, error), port); endpoints.push_back(endpoint); } - monitor_pvt.TOW_at_current_symbol_ms = 0U; - monitor_pvt.week = 0U; - monitor_pvt.RX_time = 0.0; - monitor_pvt.user_clk_offset = 0.0; - monitor_pvt.pos_x = 0.0; - monitor_pvt.pos_y = 0.0; - monitor_pvt.pos_z = 0.0; - monitor_pvt.vel_x = 0.0; - monitor_pvt.vel_y = 0.0; - monitor_pvt.vel_z = 0.0; - monitor_pvt.cov_xx = 0.0; - monitor_pvt.cov_yy = 0.0; - monitor_pvt.cov_zz = 0.0; - monitor_pvt.cov_xy = 0.0; - monitor_pvt.cov_yz = 0.0; - monitor_pvt.cov_zx = 0.0; - monitor_pvt.latitude = 0.0; - monitor_pvt.longitude = 0.0; - monitor_pvt.height = 0.0; - monitor_pvt.valid_sats = 0; - monitor_pvt.solution_status = 0; - monitor_pvt.solution_type = 0; - monitor_pvt.AR_ratio_factor = 0.0; - monitor_pvt.AR_ratio_threshold = 0.0; - monitor_pvt.gdop = 0.0; - monitor_pvt.pdop = 0.0; - monitor_pvt.hdop = 0.0; - monitor_pvt.vdop = 0.0; use_protobuf = protobuf_enabled; if (use_protobuf) diff --git a/src/algorithms/PVT/libs/monitor_pvt_udp_sink.h b/src/algorithms/PVT/libs/monitor_pvt_udp_sink.h index 85a612358..f1f9146f4 100644 --- a/src/algorithms/PVT/libs/monitor_pvt_udp_sink.h +++ b/src/algorithms/PVT/libs/monitor_pvt_udp_sink.h @@ -53,7 +53,7 @@ private: boost::asio::ip::udp::socket socket; boost::system::error_code error; std::vector endpoints; - Monitor_Pvt monitor_pvt; + Monitor_Pvt monitor_pvt{}; Serdes_Monitor_Pvt serdes; bool use_protobuf; }; diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc index ebb359b0f..0f6e84b06 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.cc +++ b/src/algorithms/PVT/libs/rtklib_solver.cc @@ -77,16 +77,7 @@ Rtklib_Solver::Rtklib_Solver(int nchannels, std::string dump_filename, bool flag count_valid_position = 0; this->set_averaging_flag(false); rtk_ = rtk; - for (double &i : dop_) - { - i = 0.0; - } - pvt_sol = {{0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, '0', '0', '0', 0, 0, 0}; - ssat_t ssat0 = {0, 0, {0.0}, {0.0}, {0.0}, {'0'}, {'0'}, {'0'}, {'0'}, {'0'}, {}, {}, {}, {}, 0.0, 0.0, 0.0, 0.0, {{{0, 0}}, {{0, 0}}}, {{}, {}}}; - for (auto &i : pvt_ssat) - { - i = ssat0; - } + // ############# ENABLE DATA FILE LOG ################# if (d_flag_dump_enabled == true) { @@ -104,35 +95,6 @@ Rtklib_Solver::Rtklib_Solver(int nchannels, std::string dump_filename, bool flag } } } - // PVT MONITOR - monitor_pvt.TOW_at_current_symbol_ms = 0U; - monitor_pvt.week = 0U; - monitor_pvt.RX_time = 0.0; - monitor_pvt.user_clk_offset = 0.0; - monitor_pvt.pos_x = 0.0; - monitor_pvt.pos_y = 0.0; - monitor_pvt.pos_z = 0.0; - monitor_pvt.vel_x = 0.0; - monitor_pvt.vel_y = 0.0; - monitor_pvt.vel_z = 0.0; - monitor_pvt.cov_xx = 0.0; - monitor_pvt.cov_yy = 0.0; - monitor_pvt.cov_zz = 0.0; - monitor_pvt.cov_xy = 0.0; - monitor_pvt.cov_yz = 0.0; - monitor_pvt.cov_zx = 0.0; - monitor_pvt.latitude = 0.0; - monitor_pvt.longitude = 0.0; - monitor_pvt.height = 0.0; - monitor_pvt.valid_sats = 0; - monitor_pvt.solution_status = 0; - monitor_pvt.solution_type = 0; - monitor_pvt.AR_ratio_factor = 0.0; - monitor_pvt.AR_ratio_threshold = 0.0; - monitor_pvt.gdop = 0.0; - monitor_pvt.pdop = 0.0; - monitor_pvt.hdop = 0.0; - monitor_pvt.vdop = 0.0; } bool Rtklib_Solver::save_matfile() @@ -450,9 +412,9 @@ bool Rtklib_Solver::get_PVT(const std::map &gnss_observables_ int valid_obs = 0; // valid observations counter int glo_valid_obs = 0; // GLONASS L1/L2 valid observations counter - std::array obs_data; - std::array eph_data; - std::array geph_data; + std::array obs_data{}; + std::array eph_data{}; + std::array geph_data{}; // Workaround for NAV/CNAV clash problem bool gps_dual_band = false; diff --git a/src/algorithms/PVT/libs/rtklib_solver.h b/src/algorithms/PVT/libs/rtklib_solver.h index 8e1b94cc7..128d8bebf 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.h +++ b/src/algorithms/PVT/libs/rtklib_solver.h @@ -94,8 +94,8 @@ public: bool get_PVT(const std::map& gnss_observables_map, bool flag_averaging); - sol_t pvt_sol; - std::array pvt_ssat; + sol_t pvt_sol{}; + std::array pvt_ssat{}; double get_hdop() const; double get_vdop() const; double get_pdop() const; @@ -129,15 +129,15 @@ public: int count_valid_position; private: - rtk_t rtk_; + rtk_t rtk_{}; std::string d_dump_filename; std::ofstream d_dump_file; bool save_matfile(); bool d_flag_dump_enabled; bool d_flag_dump_mat_enabled; int d_nchannels; // Number of available channels for positioning - std::array dop_; - Monitor_Pvt monitor_pvt; + std::array dop_{}; + Monitor_Pvt monitor_pvt{}; }; #endif diff --git a/src/algorithms/PVT/libs/serdes_monitor_pvt.h b/src/algorithms/PVT/libs/serdes_monitor_pvt.h index 3294a5fc1..2e5b95a17 100644 --- a/src/algorithms/PVT/libs/serdes_monitor_pvt.h +++ b/src/algorithms/PVT/libs/serdes_monitor_pvt.h @@ -55,6 +55,7 @@ public: // google::protobuf::ShutdownProtobufLibrary(); } + /* inline Serdes_Monitor_Pvt(Serdes_Monitor_Pvt&& other) //!< Copy constructor { this->monitor_ = other.monitor_; @@ -83,7 +84,7 @@ public: this->monitor_ = std::move(other.monitor_); } return *this; - } + }*/ inline std::string createProtobuffer(const Monitor_Pvt& monitor) //!< Serialization into a string { @@ -161,7 +162,7 @@ public: } private: - gnss_sdr::MonitorPvt monitor_; + gnss_sdr::MonitorPvt monitor_{}; }; #endif // GNSS_SDR_SERDES_MONITOR_PVT_H_ diff --git a/src/core/monitor/serdes_gnss_synchro.h b/src/core/monitor/serdes_gnss_synchro.h index c90e93282..935c292de 100644 --- a/src/core/monitor/serdes_gnss_synchro.h +++ b/src/core/monitor/serdes_gnss_synchro.h @@ -56,7 +56,7 @@ public: { google::protobuf::ShutdownProtobufLibrary(); } - + /* inline Serdes_Gnss_Synchro(Serdes_Gnss_Synchro&& other) //!< Copy constructor { this->observables = other.observables; @@ -85,7 +85,7 @@ public: this->observables = std::move(other.observables); } return *this; - } + }*/ inline std::string createProtobuffer(const std::vector& vgs) //!< Serialization into a string { @@ -179,7 +179,7 @@ public: } private: - gnss_sdr::Observables observables; + gnss_sdr::Observables observables{}; }; #endif // GNSS_SDR_SERDES_GNSS_SYNCHRO_H_ diff --git a/src/core/receiver/file_configuration.h b/src/core/receiver/file_configuration.h index 0e2ccb53e..c4d480d0b 100644 --- a/src/core/receiver/file_configuration.h +++ b/src/core/receiver/file_configuration.h @@ -79,7 +79,7 @@ private: std::shared_ptr ini_reader_; std::shared_ptr overrided_; std::unique_ptr converter_; - int error_; + int error_{}; }; #endif /*GNSS_SDR_FILE_CONFIGURATION_H_*/ diff --git a/src/core/system_parameters/gnss_signal.cc b/src/core/system_parameters/gnss_signal.cc index c73382d1c..71b0603fc 100644 --- a/src/core/system_parameters/gnss_signal.cc +++ b/src/core/system_parameters/gnss_signal.cc @@ -50,47 +50,6 @@ Gnss_Signal::Gnss_Signal(const Gnss_Satellite& satellite_, const std::string& si } -/* -// Copy constructor -Gnss_Signal::Gnss_Signal(Gnss_Signal&& other) -{ - *this = std::move(other); -} - - -// Copy assignment operator -Gnss_Signal& Gnss_Signal::operator=(const Gnss_Signal& rhs) -{ - // Only do assignment if RHS is a different object from this. - if (this != &rhs) - { - // Deallocate, allocate new space, copy values... - this->satellite = rhs.get_satellite(); - this->signal = rhs.get_signal_str(); - } - return *this; -} - - -// Move constructor -Gnss_Signal::Gnss_Signal(const Gnss_Signal& other) -{ - *this = other; -} - - -// Move assignment operator -Gnss_Signal& Gnss_Signal::operator=(Gnss_Signal&& other) -{ - if (this != &other) - { - this->satellite = std::move(other.get_satellite()); - this->signal = std::move(other.get_signal_str()); - } - return *this; -} -*/ - std::string Gnss_Signal::get_signal_str() const { return this->signal; diff --git a/src/core/system_parameters/gnss_signal.h b/src/core/system_parameters/gnss_signal.h index 62f69b5ee..767a12a0c 100644 --- a/src/core/system_parameters/gnss_signal.h +++ b/src/core/system_parameters/gnss_signal.h @@ -54,10 +54,6 @@ public: friend bool operator==(const Gnss_Signal& /*sig1*/, const Gnss_Signal& /*sig2*/); //!< operator== for comparison friend std::ostream& operator<<(std::ostream& /*out*/, const Gnss_Signal& /*sig*/); //!< operator<< for pretty printing - /*Gnss_Signal(Gnss_Signal&& other); //!< Copy constructor - Gnss_Signal& operator=(const Gnss_Signal&); //!< Copy assignment operator - Gnss_Signal(const Gnss_Signal& other); //!< Move constructor - Gnss_Signal& operator=(Gnss_Signal&& other); //!< Move assignment operator */ private: Gnss_Satellite satellite{}; std::string signal{};