@@ -234,48 +234,24 @@ OccupancyGridMapOutlierFilterComponent::OccupancyGridMapOutlierFilterComponent(
234
234
if (enable_debugger) {
235
235
debugger_ptr_ = std::make_shared<Debugger >(*this );
236
236
}
237
- published_time_publisher_ = std::make_unique<tier4_autoware_utils::PublishedTimePublisher>(this );
238
237
}
239
238
240
239
void OccupancyGridMapOutlierFilterComponent::splitPointCloudFrontBack (
241
240
const PointCloud2::ConstSharedPtr & input_pc, PointCloud2 & front_pc, PointCloud2 & behind_pc)
242
241
{
243
- size_t front_count = 0 ;
244
- size_t behind_count = 0 ;
245
-
246
- for (sensor_msgs::PointCloud2ConstIterator<float > x (*input_pc, " x" ); x != x.end (); ++x) {
242
+ PclPointCloud tmp_behind_pc;
243
+ PclPointCloud tmp_front_pc;
244
+ for (sensor_msgs::PointCloud2ConstIterator<float > x (*input_pc, " x" ), y (*input_pc, " y" ),
245
+ z (*input_pc, " z" ), intensity (*input_pc, " intensity" );
246
+ x != x.end (); ++x, ++y, ++z, ++intensity) {
247
247
if (*x < 0.0 ) {
248
- behind_count++ ;
248
+ tmp_behind_pc. push_back ( pcl::PointXYZI (*x, *y, *z, *intensity)) ;
249
249
} else {
250
- front_count++ ;
250
+ tmp_front_pc. push_back ( pcl::PointXYZI (*x, *y, *z, *intensity)) ;
251
251
}
252
252
}
253
-
254
- sensor_msgs::PointCloud2Modifier front_pc_modifier (front_pc);
255
- sensor_msgs::PointCloud2Modifier behind_pc_modifier (behind_pc);
256
- front_pc_modifier.setPointCloud2FieldsByString (1 , " xyz" );
257
- behind_pc_modifier.setPointCloud2FieldsByString (1 , " xyz" );
258
- front_pc_modifier.resize (front_count);
259
- behind_pc_modifier.resize (behind_count);
260
-
261
- sensor_msgs::PointCloud2Iterator<float > fr_iter (front_pc, " x" );
262
- sensor_msgs::PointCloud2Iterator<float > be_iter (behind_pc, " x" );
263
-
264
- for (sensor_msgs::PointCloud2ConstIterator<float > in_iter (*input_pc, " x" );
265
- in_iter != in_iter.end (); ++in_iter) {
266
- if (*in_iter < 0.0 ) {
267
- *be_iter = in_iter[0 ];
268
- be_iter[1 ] = in_iter[1 ];
269
- be_iter[2 ] = in_iter[2 ];
270
- ++be_iter;
271
- } else {
272
- *fr_iter = in_iter[0 ];
273
- fr_iter[1 ] = in_iter[1 ];
274
- fr_iter[2 ] = in_iter[2 ];
275
- ++fr_iter;
276
- }
277
- }
278
-
253
+ pcl::toROSMsg (tmp_front_pc, front_pc);
254
+ pcl::toROSMsg (tmp_behind_pc, behind_pc);
279
255
front_pc.header = input_pc->header ;
280
256
behind_pc.header = input_pc->header ;
281
257
}
@@ -329,8 +305,6 @@ void OccupancyGridMapOutlierFilterComponent::onOccupancyGridMapAndPointCloud2(
329
305
return ;
330
306
}
331
307
pointcloud_pub_->publish (std::move (base_link_frame_filtered_pc_ptr));
332
- published_time_publisher_->publish_if_subscribed (
333
- pointcloud_pub_, ogm_frame_filtered_pc.header .stamp );
334
308
}
335
309
if (debugger_ptr_) {
336
310
debugger_ptr_->publishHighConfidence (high_confidence_pc, ogm_frame_pc.header );
0 commit comments