Skip to content

Commit

Permalink
publish clock after the delay is over
Browse files Browse the repository at this point in the history
Signed-off-by: Nicola Loi <[email protected]>
  • Loading branch information
nicolaloi committed Nov 23, 2024
1 parent b5098ef commit 5f7da84
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion rosbag2_transport/src/rosbag2_transport/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,9 @@ bool PlayerImpl::play()
try {
do {
if (delay > rclcpp::Duration(0, 0)) {
if (clock_publish_timer_ != nullptr) {
clock_publish_timer_->cancel();
}
RCLCPP_INFO_STREAM(owner_->get_logger(), "Sleep " << delay.nanoseconds() << " ns");
std::chrono::nanoseconds delay_duration(delay.nanoseconds());
std::this_thread::sleep_for(delay_duration);
Expand All @@ -494,6 +497,9 @@ bool PlayerImpl::play()
reader_->seek(starting_time_);
clock_->jump(starting_time_);
}
if (clock_publish_timer_ != nullptr) {
clock_publish_timer_->reset();
}
load_storage_content_ = true;
storage_loading_future_ = std::async(
std::launch::async, [this]() {
Expand Down Expand Up @@ -1072,7 +1078,7 @@ void PlayerImpl::prepare_publishers()
clock_publish_timer_ = owner_->create_wall_timer(
publish_period, [this]() {
publish_clock_update();
});
}, nullptr, false);
}

if (play_options_.clock_publish_on_topic_publish) {
Expand Down

0 comments on commit 5f7da84

Please sign in to comment.