@@ -163,6 +163,8 @@ void BlockageDiagComponent::filter(
163
163
static_cast <uint >((angle_range_deg_[1 ] - angle_range_deg_[0 ]) / horizontal_resolution_);
164
164
pcl::PointCloud<PointXYZIRADRT>::Ptr pcl_input (new pcl::PointCloud<PointXYZIRADRT>);
165
165
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);
166
168
cv::Mat full_size_depth_map (
167
169
cv::Size (ideal_horizontal_bins, vertical_bins), CV_16UC1, cv::Scalar (0 ));
168
170
cv::Mat lidar_depth_map (cv::Size (ideal_horizontal_bins, vertical_bins), CV_16UC1, cv::Scalar (0 ));
@@ -182,18 +184,25 @@ void BlockageDiagComponent::filter(
182
184
sky_blockage_range_deg_[0 ] = angle_range_deg_[0 ];
183
185
sky_blockage_range_deg_[1 ] = angle_range_deg_[1 ];
184
186
} 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
+ }
185
190
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
+ }
197
206
}
198
207
}
199
208
}
0 commit comments