-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Publish clock after delay is over and disable delay on next loops #1861
Publish clock after delay is over and disable delay on next loops #1861
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm with green CI.
@MichaelOrlov could you have 2nd review?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicolaloi Thanks for the PR. Overall looks good among one undefined behavior / race introducing with the
if (!play_options_.start_paused) {
clock_->resume();
}
in Play method.
Ah yes, the clock will resume automatically at the next loop regardless of user requests. Then to not overcomplicate things, I would suggest removing the "pause clock until delay is over" feature from this PR, and keeping the "publish clock after the delay is over" feature only, which is the actual fix for issue #1858. Pausing the clock is not required to fix this specific issue since anyway the I was pausing the clock as a comprehensive "inner" change for the |
5576c77
to
0323e46
Compare
Signed-off-by: Nicola Loi <nicolaloi@outlook.com>
0323e46
to
5f7da84
Compare
Removing
to keep the "pause clock until delay is over" feature only, but if it is not okay I can reintegrate and try to fix this "pause clock until delay is over" feature in this PR too. Extra change: now before sleeping for the delay period, the |
i prefer this approach, one thing at a time. and easier to backport to downstream distros. and the question here is that clock needs to be paused in delay duration? i am not quite sure about what state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicolaloi Thanks for addressing the comments from the review.
It looks good to me in the current form. However, I would move the delay out of the playback loop. IMO, there is no value in making a delay in the loop after we have finished the playback round.
Delay needs for the purporse to be able to wait for other nodes (subscribers and other dependend nodes in the pipeline) to start and be discoverable. When we have run the first playback round all other nodes still up un running. Thereofre, there is no need to make a delay on a consequent rounds of replay.
Okay, I will incorporate the change to the delay loop behavior in this PR. Need to invoke |
Signed-off-by: Nicola Loi <nicolaloi@outlook.com>
Signed-off-by: Nicola Loi <nicolaloi@outlook.com>
64bd7a4
to
cecd120
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicolaloi Thanks for the updates.
I think now it would be safe to init clock in pause mode in constructor and resume it after the delay. i.e.
clock_ = std::make_unique<rosbag2_cpp::TimeControllerClock>(
starting_time_, std::chrono::steady_clock::now,
std::chrono::milliseconds{100},
play_options_.start_paused || play_options_.delay > rclcpp::Duration(0, 0));
Also may I ask you in future do a separate commit after a round of review instead of push force the branch with the the same changed commit?
We are squashing all commits before merging to the target branch after review anyway automatically. However, the separate commits allow to keep history of changes during review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicolaloi Could you please also rebase your branch on top of the latest rolling branch?
We made some changes. Now we support multiple readers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicolaloi Thanks for the PR and for addressing the review comments. LGTM now.
Pulls: #1861 |
https://github.com/Mergifyio backport jazzy |
✅ Backports have been created
|
) * publish clock after the delay is over Signed-off-by: Nicola Loi <nicolaloi@outlook.com> * Disable delay period in subsequent loops (ros2 bag play) Signed-off-by: Nicola Loi <nicolaloi@outlook.com> * Reset clock publisher timer outisde playback loop Signed-off-by: Nicola Loi <nicolaloi@outlook.com> * review Signed-off-by: Nicola Loi <nicolaloi@outlook.com> --------- Signed-off-by: Nicola Loi <nicolaloi@outlook.com> (cherry picked from commit 15b8260)
) (#1878) * publish clock after the delay is over Signed-off-by: Nicola Loi <nicolaloi@outlook.com> * Disable delay period in subsequent loops (ros2 bag play) Signed-off-by: Nicola Loi <nicolaloi@outlook.com> * Reset clock publisher timer outisde playback loop Signed-off-by: Nicola Loi <nicolaloi@outlook.com> * review Signed-off-by: Nicola Loi <nicolaloi@outlook.com> --------- Signed-off-by: Nicola Loi <nicolaloi@outlook.com> (cherry picked from commit 15b8260) Co-authored-by: Nicola Loi <nicolaloi@outlook.com>
clock_publish_timer
is now initialized withautostart = false
, so it doesn't immediately start publishing the/clock
topic. It is "activated" later withclock_publish_timer->reset()
at the beginning of the playback thread, ensuring that the (optional) user-defined delay period has passed.Additionally, theclock_
now starts in a paused state if a delay time is specified by the user. It resumes after the delay period has ended.