Skip to content

Commit

Permalink
chore: fix init collector
Browse files Browse the repository at this point in the history
Signed-off-by: vividf <yihsiang.fang@tier4.jp>
  • Loading branch information
vividf committed Feb 12, 2025
1 parent 85f75e6 commit 0bed7b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,17 @@ CloudCollector::CloudCollector(
{
status_ = CollectorStatus::Idle;

double temp_timeout_sec = 1.0; // This will be overwritten when the first cloud comes
const auto period_ns = std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::duration<double>(temp_timeout_sec));
std::chrono::duration<double>(timeout_sec_));

timer_ =
rclcpp::create_timer(ros2_parent_node_, ros2_parent_node_->get_clock(), period_ns, [this]() {
std::lock_guard<std::mutex> concatenate_lock(concatenate_mutex_);
if (status_ == CollectorStatus::Finished) return;
concatenate_callback();
});

timer_->cancel();
}

void CloudCollector::set_info(std::shared_ptr<CollectorInfoBase> collector_info)
Expand All @@ -73,6 +74,7 @@ bool CloudCollector::process_pointcloud(
if (status_ == CollectorStatus::Finished) {
return false;
}

if (status_ == CollectorStatus::Idle) {
// Add first pointcloud to the collector, restart the timer
status_ = CollectorStatus::Processing;
Expand Down Expand Up @@ -105,8 +107,6 @@ CollectorStatus CloudCollector::get_status()

void CloudCollector::concatenate_callback()
{
if (topic_to_cloud_map_.size() == 0) return;

if (debug_mode_) {
show_debug_message();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ ConcatenatedCloudResult CombineCloudHandler::combine_pointclouds(
{
ConcatenatedCloudResult concatenate_cloud_result;

if (topic_to_cloud_map.empty()) return concatenate_cloud_result;

std::vector<rclcpp::Time> pc_stamps;
pc_stamps.reserve(topic_to_cloud_map.size());
for (const auto & [topic, cloud] : topic_to_cloud_map) {
Expand Down

0 comments on commit 0bed7b3

Please sign in to comment.