Skip to content

Commit fc43094

Browse files
committed
chore: refactor
Signed-off-by: badai-nguyen <dai.nguyen@tier4.jp>
1 parent 946ae95 commit fc43094

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

sensing/pointcloud_preprocessor/src/blockage_diag/blockage_diag_nodelet.cpp

+11-20
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,6 @@ void BlockageDiagComponent::filter(
163163
static_cast<uint>((angle_range_deg_[1] - angle_range_deg_[0]) / horizontal_resolution_);
164164
pcl::PointCloud<PointXYZIRADRT>::Ptr pcl_input(new pcl::PointCloud<PointXYZIRADRT>);
165165
pcl::fromROSMsg(*input, *pcl_input);
166-
std::vector<float> horizontal_bin_reference(ideal_horizontal_bins);
167-
std::vector<pcl::PointCloud<PointXYZIRADRT>> each_ring_pointcloud(vertical_bins);
168166
cv::Mat full_size_depth_map(
169167
cv::Size(ideal_horizontal_bins, vertical_bins), CV_16UC1, cv::Scalar(0));
170168
cv::Mat lidar_depth_map(cv::Size(ideal_horizontal_bins, vertical_bins), CV_16UC1, cv::Scalar(0));
@@ -184,25 +182,18 @@ void BlockageDiagComponent::filter(
184182
sky_blockage_range_deg_[0] = angle_range_deg_[0];
185183
sky_blockage_range_deg_[1] = angle_range_deg_[1];
186184
} else {
187-
for (int i = 0; i < ideal_horizontal_bins; ++i) {
188-
horizontal_bin_reference.at(i) = angle_range_deg_[0] + i * horizontal_resolution_;
189-
}
190185
for (const auto p : pcl_input->points) {
191-
for (int horizontal_bin = 0;
192-
horizontal_bin < static_cast<int>(horizontal_bin_reference.size()); horizontal_bin++) {
193-
if (
194-
(p.azimuth / 100 >
195-
(horizontal_bin_reference.at(horizontal_bin) - horizontal_resolution_ / 2)) &&
196-
(p.azimuth / 100 <=
197-
(horizontal_bin_reference.at(horizontal_bin) + horizontal_resolution_ / 2))) {
198-
if (lidar_model_ == "Pandar40P") {
199-
full_size_depth_map.at<uint16_t>(p.ring, horizontal_bin) =
200-
UINT16_MAX - distance_coefficient * p.distance;
201-
} else if (lidar_model_ == "PandarQT") {
202-
full_size_depth_map.at<uint16_t>(vertical_bins - p.ring - 1, horizontal_bin) =
203-
UINT16_MAX - distance_coefficient * p.distance;
204-
}
205-
}
186+
int bin_idx =
187+
static_cast<int>((p.azimuth / 100. - angle_range_deg_[0]) / horizontal_resolution_);
188+
if (bin_idx < 0 || bin_idx >= ideal_horizontal_bins) {
189+
continue;
190+
}
191+
if (lidar_model_ == "Pandar40P") {
192+
full_size_depth_map.at<uint16_t>(p.ring, bin_idx) =
193+
UINT16_MAX - distance_coefficient * p.distance;
194+
} else if (lidar_model_ == "PandarQT") {
195+
full_size_depth_map.at<uint16_t>(vertical_bins - p.ring - 1, bin_idx) =
196+
UINT16_MAX - distance_coefficient * p.distance;
206197
}
207198
}
208199
}

0 commit comments

Comments
 (0)