Skip to content

Commit c34f79d

Browse files
committed
Revert "refactor"
This reverts commit d16b3e0.
1 parent d16b3e0 commit c34f79d

File tree

1 file changed

+16
-47
lines changed

1 file changed

+16
-47
lines changed

perception/occupancy_grid_map_outlier_filter/src/occupancy_grid_map_outlier_filter_nodelet.cpp

+16-47
Original file line numberDiff line numberDiff line change
@@ -261,16 +261,6 @@ void OccupancyGridMapOutlierFilterComponent::splitPointCloudFrontBack(
261261
{
262262
int x_offset = input_pc->fields[pcl::getFieldIndex(*input_pc, "x")].offset;
263263
int point_step = input_pc->point_step;
264-
265-
front_pc.data.resize(input_pc->data.size());
266-
behind_pc.data.resize(input_pc->data.size());
267-
front_pc.point_step = input_pc->point_step;
268-
behind_pc.point_step = input_pc->point_step;
269-
front_pc.fields = input_pc->fields;
270-
behind_pc.fields = input_pc->fields;
271-
front_pc.height = input_pc->height;
272-
behind_pc.height = input_pc->height;
273-
274264
size_t front_count = 0;
275265
size_t behind_count = 0;
276266

@@ -290,34 +280,24 @@ void OccupancyGridMapOutlierFilterComponent::splitPointCloudFrontBack(
290280
front_count++;
291281
}
292282
}
293-
front_pc.data.resize(front_count * point_step);
294-
front_pc.width = front_count;
295-
front_pc.row_step = front_count * front_pc.point_step;
296-
front_pc.header = input_pc->header;
297-
front_pc.is_bigendian = input_pc->is_bigendian;
298-
front_pc.is_dense = input_pc->is_dense;
299-
300-
behind_pc.data.resize(behind_count * point_step);
301-
behind_pc.width = behind_count;
302-
behind_pc.row_step = behind_count * behind_pc.point_step;
303-
behind_pc.header = input_pc->header;
304-
behind_pc.is_bigendian = input_pc->is_bigendian;
305-
behind_pc.is_dense = input_pc->is_dense;
306283
}
307284
void OccupancyGridMapOutlierFilterComponent::onOccupancyGridMapAndPointCloud2(
308285
const OccupancyGrid::ConstSharedPtr & input_ogm, const PointCloud2::ConstSharedPtr & input_pc)
309286
{
310287
stop_watch_ptr_->toc("processing_time", true);
311288
// Transform to occupancy grid map frame
312-
PointCloud2 ogm_frame_pc{};
313-
PointCloud2 input_front_pc{};
289+
314290
PointCloud2 input_behind_pc{};
315-
PointCloud2 ogm_frame_input_behind_pc{};
316-
PointCloud2 ogm_frame_pc;
317-
PointCloud2 input_front_pc;
318-
PointCloud2 input_behind_pc;
319-
PointCloud2 ogm_frame_input_behind_pc;
291+
PointCloud2 input_front_pc{};
292+
initializerPointCloud2(*input_pc, input_front_pc);
293+
initializerPointCloud2(*input_pc, input_behind_pc);
294+
// Split pointcloud into front and behind of the vehicle to reduce the calculation cost
320295
splitPointCloudFrontBack(input_pc, input_front_pc, input_behind_pc);
296+
finalizePointCloud2(*input_pc, input_front_pc);
297+
finalizePointCloud2(*input_pc, input_behind_pc);
298+
299+
PointCloud2 ogm_frame_pc{};
300+
PointCloud2 ogm_frame_input_behind_pc{};
321301
if (
322302
!transformPointcloud(input_front_pc, *tf2_, input_ogm->header.frame_id, ogm_frame_pc) ||
323303
!transformPointcloud(
@@ -331,20 +311,16 @@ void OccupancyGridMapOutlierFilterComponent::onOccupancyGridMapAndPointCloud2(
331311
initializerPointCloud2(ogm_frame_pc, high_confidence_pc);
332312
initializerPointCloud2(ogm_frame_pc, low_confidence_pc);
333313
initializerPointCloud2(ogm_frame_pc, out_ogm_pc);
334-
// PclPointCloud ogm_frame_behind_pc;
335-
// pcl::fromROSMsg(ogm_frame_input_behind_pc, ogm_frame_behind_pc);
314+
// split front pointcloud into high and low confidence and out of map pointcloud
336315
filterByOccupancyGridMap(
337316
*input_ogm, ogm_frame_pc, high_confidence_pc, low_confidence_pc, out_ogm_pc);
338317
// Apply Radius search 2d filter for low confidence pointcloud
339318
PointCloud2 filtered_low_confidence_pc{};
340319
PointCloud2 outlier_pc{};
341320
initializerPointCloud2(low_confidence_pc, outlier_pc);
342321
initializerPointCloud2(low_confidence_pc, filtered_low_confidence_pc);
343-
PointCloud2 outlier_pc;
344-
outlier_pc.data.resize(low_confidence_pc.data.size());
345-
outlier_pc.point_step = low_confidence_pc.point_step;
346-
outlier_pc.fields = low_confidence_pc.fields;
347-
outlier_pc.height = 1;
322+
initializerPointCloud2(low_confidence_pc, outlier_pc);
323+
348324
if (radius_search_2d_filter_ptr_) {
349325
auto pc_frame_pose_stamped = getPoseStamped(
350326
*tf2_, input_ogm->header.frame_id, input_pc->header.frame_id, input_ogm->header.stamp);
@@ -361,12 +337,7 @@ void OccupancyGridMapOutlierFilterComponent::onOccupancyGridMapAndPointCloud2(
361337
concatPointCloud2(ogm_frame_filtered_pc, filtered_low_confidence_pc);
362338
concatPointCloud2(ogm_frame_filtered_pc, out_ogm_pc);
363339
concatPointCloud2(ogm_frame_filtered_pc, ogm_frame_input_behind_pc);
364-
365340
finalizePointCloud2(ogm_frame_pc, ogm_frame_filtered_pc);
366-
finalizePointCloud2(ogm_frame_pc, filtered_low_confidence_pc);
367-
finalizePointCloud2(ogm_frame_pc, outlier_pc);
368-
finalizePointCloud2(ogm_frame_pc, high_confidence_pc);
369-
// Convert to ros msg
370341
{
371342
auto base_link_frame_filtered_pc_ptr = std::make_unique<PointCloud2>();
372343
ogm_frame_filtered_pc.header = ogm_frame_pc.header;
@@ -377,6 +348,9 @@ void OccupancyGridMapOutlierFilterComponent::onOccupancyGridMapAndPointCloud2(
377348
pointcloud_pub_->publish(std::move(base_link_frame_filtered_pc_ptr));
378349
}
379350
if (debugger_ptr_) {
351+
finalizePointCloud2(ogm_frame_pc, filtered_low_confidence_pc);
352+
finalizePointCloud2(ogm_frame_pc, outlier_pc);
353+
finalizePointCloud2(ogm_frame_pc, high_confidence_pc);
380354
debugger_ptr_->publishHighConfidence(high_confidence_pc, ogm_frame_pc.header);
381355
debugger_ptr_->publishLowConfidence(filtered_low_confidence_pc, ogm_frame_pc.header);
382356
debugger_ptr_->publishOutlier(outlier_pc, ogm_frame_pc.header);
@@ -396,12 +370,7 @@ void OccupancyGridMapOutlierFilterComponent::onOccupancyGridMapAndPointCloud2(
396370
void OccupancyGridMapOutlierFilterComponent::initializerPointCloud2(
397371
const PointCloud2 & input, PointCloud2 & output)
398372
{
399-
output.header = input.header;
400373
output.point_step = input.point_step;
401-
output.fields = input.fields;
402-
output.height = input.height;
403-
output.is_bigendian = input.is_bigendian;
404-
output.is_dense = input.is_dense;
405374
output.data.resize(input.data.size());
406375
}
407376

0 commit comments

Comments
 (0)