Skip to content

Commit b3161cb

Browse files
committed
fix node dying
Signed-off-by: Takagi, Isamu <isamu.takagi@tier4.jp>
1 parent eb60bb1 commit b3161cb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

system/default_ad_api/src/heartbeat.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ namespace default_ad_api
2121

2222
HeartbeatNode::HeartbeatNode(const rclcpp::NodeOptions & options) : Node("heartbeat", options)
2323
{
24-
auto on_timer = [this]() {
24+
// Move this function so that the timer no longer holds it as a reference.
25+
const auto on_timer = [this]() {
2526
autoware_ad_api::system::Heartbeat::Message heartbeat;
2627
heartbeat.stamp = now();
2728
heartbeat.seq = ++sequence_; // Wraps at 65535.
@@ -32,7 +33,7 @@ HeartbeatNode::HeartbeatNode(const rclcpp::NodeOptions & options) : Node("heartb
3233
adaptor.init_pub(pub_);
3334

3435
const auto period = rclcpp::Rate(10.0).period();
35-
timer_ = rclcpp::create_timer(this, get_clock(), period, on_timer);
36+
timer_ = rclcpp::create_timer(this, get_clock(), period, std::move(on_timer));
3637
}
3738

3839
} // namespace default_ad_api

0 commit comments

Comments
 (0)