Skip to content

Commit

Permalink
fix(agnocastlib): use detached thread for ros2 publisher
Browse files Browse the repository at this point in the history
Signed-off-by: veqcc <ryuta.kambe@tier4.jp>
  • Loading branch information
veqcc committed Feb 4, 2025
1 parent 2e1ecfb commit 240724b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/agnocastlib/include/agnocast_publisher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,14 @@ class Publisher
}

if (do_always_ros2_publish_ || ros2_publisher_->get_subscription_count() > 0) {
const MessageT * raw = message.get();
ros2_publisher_->publish(*raw);
std::thread([this, message = std::move(message)]() mutable {
const MessageT * raw = message.get();
ros2_publisher_->publish(*raw);
message.reset();
}).detach();
} else {
message.reset();
}

message.reset();
}

uint32_t get_subscription_count() const
Expand Down

0 comments on commit 240724b

Please sign in to comment.