Skip to content

Commit 3a37151

Browse files
committed
chore(hesai): fix clang-tidy errors
1 parent 6b865ef commit 3a37151

File tree

4 files changed

+34
-16
lines changed

4 files changed

+34
-16
lines changed

nebula_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_hesai/hesai_cmd_response.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ struct HesaiInventory
218218
return os;
219219
}
220220

221-
std::string get_str_model()
221+
std::string get_str_model() const
222222
{
223223
switch (model) {
224224
case 0:
@@ -400,7 +400,7 @@ struct HesaiLidarStatus
400400
return os;
401401
}
402402

403-
std::string get_str_gps_pps_lock()
403+
[[nodiscard]] std::string get_str_gps_pps_lock() const
404404
{
405405
switch (gps_pps_lock) {
406406
case 1:
@@ -411,7 +411,7 @@ struct HesaiLidarStatus
411411
return "Unknown";
412412
}
413413
}
414-
std::string get_str_gps_gprmc_status()
414+
[[nodiscard]] std::string get_str_gps_gprmc_status() const
415415
{
416416
switch (gps_gprmc_status) {
417417
case 1:
@@ -422,7 +422,7 @@ struct HesaiLidarStatus
422422
return "Unknown";
423423
}
424424
}
425-
std::string get_str_ptp_clock_status()
425+
[[nodiscard]] std::string get_str_ptp_clock_status() const
426426
{
427427
switch (ptp_clock_status) {
428428
case 0:

nebula_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_hesai/hesai_hw_interface.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ class HesaiHwInterface
122122
uint8_t error_flags = 0;
123123
uint8_t ptc_error_code = 0;
124124

125-
bool ok() { return !error_flags && !ptc_error_code; }
125+
[[nodiscard]] bool ok() const { return !error_flags && !ptc_error_code; }
126126
};
127127

128-
typedef nebula::util::expected<std::vector<uint8_t>, ptc_error_t> ptc_cmd_result_t;
128+
using ptc_cmd_result_t = nebula::util::expected<std::vector<uint8_t>, ptc_error_t>;
129129

130130
std::unique_ptr<::drivers::common::IoContext> cloud_io_context_;
131131
std::shared_ptr<boost::asio::io_context> m_owned_ctx;

nebula_hw_interfaces/src/nebula_hesai_hw_interfaces/hesai_hw_interface.cpp

+6-9
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111

1212
#include <boost/asio.hpp>
1313

14-
namespace nebula
15-
{
16-
namespace drivers
14+
namespace nebula::drivers
1715
{
1816
HesaiHwInterface::HesaiHwInterface()
1917
: cloud_io_context_{new ::drivers::common::IoContext(1)},
@@ -1266,16 +1264,16 @@ std::string HesaiHwInterface::PrettyPrintPTCError(ptc_error_t error_code)
12661264
std::vector<std::string> nebula_errors;
12671265

12681266
if (error_flags & TCP_ERROR_INCOMPLETE_RESPONSE) {
1269-
nebula_errors.push_back("Incomplete response payload");
1267+
nebula_errors.emplace_back("Incomplete response payload");
12701268
}
12711269
if (error_flags & TCP_ERROR_TIMEOUT) {
1272-
nebula_errors.push_back("Request timeout");
1270+
nebula_errors.emplace_back("Request timeout");
12731271
}
12741272
if (error_flags & TCP_ERROR_UNEXPECTED_PAYLOAD) {
1275-
nebula_errors.push_back("Received payload but expected payload length 0");
1273+
nebula_errors.emplace_back("Received payload but expected payload length 0");
12761274
}
12771275
if (error_flags & TCP_ERROR_UNRELATED_RESPONSE) {
1278-
nebula_errors.push_back("Received unrelated response");
1276+
nebula_errors.emplace_back("Received unrelated response");
12791277
}
12801278

12811279
ss << boost::algorithm::join(nebula_errors, ", ");
@@ -1297,5 +1295,4 @@ T HesaiHwInterface::CheckSizeAndParse(const std::vector<uint8_t> & data)
12971295
return parsed;
12981296
}
12991297

1300-
} // namespace drivers
1301-
} // namespace nebula
1298+
} // namespace nebula::drivers

nebula_ros/src/hesai/hesai_ros_wrapper.cpp

+22-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ namespace nebula
1717
{
1818
namespace ros
1919
{
20+
using std::get;
21+
2022
HesaiRosWrapper::HesaiRosWrapper(const rclcpp::NodeOptions & options)
2123
: rclcpp::Node("hesai_ros_wrapper", rclcpp::NodeOptions(options).use_intra_process_comms(true)),
2224
wrapper_status_(Status::NOT_INITIALIZED),
@@ -50,6 +52,25 @@ HesaiRosWrapper::HesaiRosWrapper(const rclcpp::NodeOptions & options)
5052
(std::stringstream() << "No valid calibration found: " << calibration_result.error()).str());
5153
}
5254

55+
if (hw_interface_wrapper_) {
56+
auto cloud_min = sensor_cfg_ptr_->cloud_min_angle / 10.f;
57+
auto cloud_max = sensor_cfg_ptr_->cloud_max_angle / 10.f;
58+
59+
auto padding = calibration_result.value()->getFovPadding();
60+
cloud_min += get<0>(padding);
61+
cloud_max += get<1>(padding);
62+
63+
if (cloud_min < 0) {
64+
cloud_min += 360;
65+
}
66+
67+
if (cloud_max > 360) {
68+
cloud_max -= 360;
69+
}
70+
71+
hw_interface_wrapper_->HwInterface()->setHardwareFov(cloud_min, cloud_max);
72+
}
73+
5374
decoder_wrapper_.emplace(this, sensor_cfg_ptr_, calibration_result.value());
5475

5576
RCLCPP_DEBUG(get_logger(), "Starting stream");
@@ -394,7 +415,7 @@ HesaiRosWrapper::get_calibration_result_t HesaiRosWrapper::GetCalibrationData(
394415
}
395416

396417
// If a sensor is connected, try to download and save its calibration data
397-
if (!ignore_others && launch_hw_) {
418+
if (!ignore_others && hw_interface_wrapper_) {
398419
try {
399420
auto raw_data = hw_interface_wrapper_->HwInterface()->GetLidarCalibrationBytes();
400421
RCLCPP_INFO(logger, "Downloaded calibration data from sensor.");

0 commit comments

Comments
 (0)