diff --git a/nebula_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_hesai/hesai_cmd_response.hpp b/nebula_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_hesai/hesai_cmd_response.hpp index 54e757224..f3bb7b073 100644 --- a/nebula_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_hesai/hesai_cmd_response.hpp +++ b/nebula_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_hesai/hesai_cmd_response.hpp @@ -218,7 +218,7 @@ struct HesaiInventory return os; } - std::string get_str_model() + std::string get_str_model() const { switch (model) { case 0: @@ -400,7 +400,7 @@ struct HesaiLidarStatus return os; } - std::string get_str_gps_pps_lock() + [[nodiscard]] std::string get_str_gps_pps_lock() const { switch (gps_pps_lock) { case 1: @@ -411,7 +411,7 @@ struct HesaiLidarStatus return "Unknown"; } } - std::string get_str_gps_gprmc_status() + [[nodiscard]] std::string get_str_gps_gprmc_status() const { switch (gps_gprmc_status) { case 1: @@ -422,7 +422,7 @@ struct HesaiLidarStatus return "Unknown"; } } - std::string get_str_ptp_clock_status() + [[nodiscard]] std::string get_str_ptp_clock_status() const { switch (ptp_clock_status) { case 0: diff --git a/nebula_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_hesai/hesai_hw_interface.hpp b/nebula_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_hesai/hesai_hw_interface.hpp index 668469b2e..a029ae224 100644 --- a/nebula_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_hesai/hesai_hw_interface.hpp +++ b/nebula_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_hesai/hesai_hw_interface.hpp @@ -122,10 +122,10 @@ class HesaiHwInterface uint8_t error_flags = 0; uint8_t ptc_error_code = 0; - bool ok() { return !error_flags && !ptc_error_code; } + [[nodiscard]] bool ok() const { return !error_flags && !ptc_error_code; } }; - typedef nebula::util::expected, ptc_error_t> ptc_cmd_result_t; + using ptc_cmd_result_t = nebula::util::expected, ptc_error_t>; std::unique_ptr<::drivers::common::IoContext> cloud_io_context_; std::shared_ptr m_owned_ctx; diff --git a/nebula_hw_interfaces/src/nebula_hesai_hw_interfaces/hesai_hw_interface.cpp b/nebula_hw_interfaces/src/nebula_hesai_hw_interfaces/hesai_hw_interface.cpp index 06dcb37dc..2bdaf3e6e 100644 --- a/nebula_hw_interfaces/src/nebula_hesai_hw_interfaces/hesai_hw_interface.cpp +++ b/nebula_hw_interfaces/src/nebula_hesai_hw_interfaces/hesai_hw_interface.cpp @@ -11,9 +11,7 @@ #include -namespace nebula -{ -namespace drivers +namespace nebula::drivers { HesaiHwInterface::HesaiHwInterface() : cloud_io_context_{new ::drivers::common::IoContext(1)}, @@ -1266,16 +1264,16 @@ std::string HesaiHwInterface::PrettyPrintPTCError(ptc_error_t error_code) std::vector nebula_errors; if (error_flags & TCP_ERROR_INCOMPLETE_RESPONSE) { - nebula_errors.push_back("Incomplete response payload"); + nebula_errors.emplace_back("Incomplete response payload"); } if (error_flags & TCP_ERROR_TIMEOUT) { - nebula_errors.push_back("Request timeout"); + nebula_errors.emplace_back("Request timeout"); } if (error_flags & TCP_ERROR_UNEXPECTED_PAYLOAD) { - nebula_errors.push_back("Received payload but expected payload length 0"); + nebula_errors.emplace_back("Received payload but expected payload length 0"); } if (error_flags & TCP_ERROR_UNRELATED_RESPONSE) { - nebula_errors.push_back("Received unrelated response"); + nebula_errors.emplace_back("Received unrelated response"); } ss << boost::algorithm::join(nebula_errors, ", "); @@ -1297,5 +1295,4 @@ T HesaiHwInterface::CheckSizeAndParse(const std::vector & data) return parsed; } -} // namespace drivers -} // namespace nebula +} // namespace nebula::drivers