Skip to content

Commit d7bd69f

Browse files
committed
fix: add intensity
Signed-off-by: badai-nguyen <dai.nguyen@tier4.jp>
1 parent 3eb83b2 commit d7bd69f

File tree

1 file changed

+9
-35
lines changed

1 file changed

+9
-35
lines changed

perception/occupancy_grid_map_outlier_filter/src/occupancy_grid_map_outlier_filter_nodelet.cpp

+9-35
Original file line numberDiff line numberDiff line change
@@ -234,48 +234,24 @@ OccupancyGridMapOutlierFilterComponent::OccupancyGridMapOutlierFilterComponent(
234234
if (enable_debugger) {
235235
debugger_ptr_ = std::make_shared<Debugger>(*this);
236236
}
237-
published_time_publisher_ = std::make_unique<tier4_autoware_utils::PublishedTimePublisher>(this);
238237
}
239238

240239
void OccupancyGridMapOutlierFilterComponent::splitPointCloudFrontBack(
241240
const PointCloud2::ConstSharedPtr & input_pc, PointCloud2 & front_pc, PointCloud2 & behind_pc)
242241
{
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) {
247247
if (*x < 0.0) {
248-
behind_count++;
248+
tmp_behind_pc.push_back(pcl::PointXYZI(*x, *y, *z, *intensity));
249249
} else {
250-
front_count++;
250+
tmp_front_pc.push_back(pcl::PointXYZI(*x, *y, *z, *intensity));
251251
}
252252
}
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);
279255
front_pc.header = input_pc->header;
280256
behind_pc.header = input_pc->header;
281257
}
@@ -329,8 +305,6 @@ void OccupancyGridMapOutlierFilterComponent::onOccupancyGridMapAndPointCloud2(
329305
return;
330306
}
331307
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);
334308
}
335309
if (debugger_ptr_) {
336310
debugger_ptr_->publishHighConfidence(high_confidence_pc, ogm_frame_pc.header);

0 commit comments

Comments
 (0)