From d08dcfe995a3797d69791aaadb93be6082c3b574 Mon Sep 17 00:00:00 2001 From: "Yi-Hsiang Fang (Vivid)" <146902905+vividf@users.noreply.github.com> Date: Tue, 27 Aug 2024 17:48:02 +0900 Subject: [PATCH] fix(autoware_pointcloud_preprocessor): blockage diag node add runtime error when the parameter is wrong (#8564) * fix: add runtime error Signed-off-by: vividf * Update blockage_diag_node.cpp Co-authored-by: badai nguyen <94814556+badai-nguyen@users.noreply.github.com> * fix: add RCLCPP error logging Signed-off-by: vividf * chore: remove unused variable Signed-off-by: vividf --------- Signed-off-by: vividf Co-authored-by: badai nguyen <94814556+badai-nguyen@users.noreply.github.com> --- .../src/blockage_diag/blockage_diag_node.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sensing/autoware_pointcloud_preprocessor/src/blockage_diag/blockage_diag_node.cpp b/sensing/autoware_pointcloud_preprocessor/src/blockage_diag/blockage_diag_node.cpp index 2f34d78b8e9a0..6703eb6b70741 100644 --- a/sensing/autoware_pointcloud_preprocessor/src/blockage_diag/blockage_diag_node.cpp +++ b/sensing/autoware_pointcloud_preprocessor/src/blockage_diag/blockage_diag_node.cpp @@ -190,6 +190,14 @@ void BlockageDiagComponent::filter( sky_blockage_range_deg_[1] = angle_range_deg_[1]; } else { for (const auto p : pcl_input->points) { + if (p.channel >= vertical_bins) { + RCLCPP_ERROR( + this->get_logger(), + "p.channel: %d is larger than vertical_bins: %d .Please check the parameter " + "'vertical_bins'.", + p.channel, vertical_bins); + throw std::runtime_error("Parameter is not valid"); + } double azimuth_deg = p.azimuth * (180.0 / M_PI); if ( ((azimuth_deg > angle_range_deg_[0]) &&