Skip to content

Commit 6ce2a74

Browse files
committed
feat: enable to count empty pointclouds topic
Signed-off-by: yoshiri <yoshiyoshidetteiu@gmail.com>
1 parent ae3e758 commit 6ce2a74

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

sensing/pointcloud_preprocessor/src/concatenate_data/concatenate_and_time_sync_nodelet.cpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ PointCloudConcatenateDataSynchronizerComponent::combineClouds(
318318
for (const auto & e : cloud_stdmap_) {
319319
transformed_clouds[e.first] = nullptr;
320320
if (e.second != nullptr) {
321+
if (e.second->data.size() == 0) {
322+
continue;
323+
}
321324
pc_stamps.push_back(rclcpp::Time(e.second->header.stamp));
322325
}
323326
}
@@ -332,6 +335,9 @@ PointCloudConcatenateDataSynchronizerComponent::combineClouds(
332335
// Step2. Calculate compensation transform and concatenate with the oldest stamp
333336
for (const auto & e : cloud_stdmap_) {
334337
if (e.second != nullptr) {
338+
if (e.second->data.size() == 0) {
339+
continue;
340+
}
335341
sensor_msgs::msg::PointCloud2::SharedPtr transformed_cloud_ptr(
336342
new sensor_msgs::msg::PointCloud2());
337343
transformPointCloud(e.second, transformed_cloud_ptr);
@@ -479,16 +485,16 @@ void PointCloudConcatenateDataSynchronizerComponent::cloud_callback(
479485
const sensor_msgs::msg::PointCloud2::ConstSharedPtr & input_ptr, const std::string & topic_name)
480486
{
481487
std::lock_guard<std::mutex> lock(mutex_);
488+
sensor_msgs::msg::PointCloud2::SharedPtr xyzi_input_ptr(new sensor_msgs::msg::PointCloud2());
482489
auto input = std::make_shared<sensor_msgs::msg::PointCloud2>(*input_ptr);
483490
if (input->data.empty()) {
484491
RCLCPP_WARN_STREAM_THROTTLE(
485492
this->get_logger(), *this->get_clock(), 1000, "Empty sensor points!");
486-
return;
493+
} else {
494+
// convert to XYZI pointcloud if pointcloud is not empty
495+
convertToXYZICloud(input, xyzi_input_ptr);
487496
}
488497

489-
sensor_msgs::msg::PointCloud2::SharedPtr xyzi_input_ptr(new sensor_msgs::msg::PointCloud2());
490-
convertToXYZICloud(input, xyzi_input_ptr);
491-
492498
const bool is_already_subscribed_this = (cloud_stdmap_[topic_name] != nullptr);
493499
const bool is_already_subscribed_tmp = std::any_of(
494500
std::begin(cloud_stdmap_tmp_), std::end(cloud_stdmap_tmp_),

0 commit comments

Comments
 (0)