Skip to content

Commit 26a771c

Browse files
committed
Revert "chore: refactor"
This reverts commit fc43094.
1 parent fc43094 commit 26a771c

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

sensing/pointcloud_preprocessor/src/blockage_diag/blockage_diag_nodelet.cpp

+20-11
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ 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);
166168
cv::Mat full_size_depth_map(
167169
cv::Size(ideal_horizontal_bins, vertical_bins), CV_16UC1, cv::Scalar(0));
168170
cv::Mat lidar_depth_map(cv::Size(ideal_horizontal_bins, vertical_bins), CV_16UC1, cv::Scalar(0));
@@ -182,18 +184,25 @@ void BlockageDiagComponent::filter(
182184
sky_blockage_range_deg_[0] = angle_range_deg_[0];
183185
sky_blockage_range_deg_[1] = angle_range_deg_[1];
184186
} 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+
}
185190
for (const auto p : pcl_input->points) {
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;
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+
}
197206
}
198207
}
199208
}

0 commit comments

Comments
 (0)