Repository navigation
Re-key EventsCBGExecutor timers after a time jump (backport #3344) - #3405
mergify[bot] wants to merge 2 commits into
Conversation
rcl moves next_call_time of a ROS time timer when the clock jumps back by more than one period and when ROS time is activated or deactivated, without calling the on reset callback. TimerQueue keyed its running timers by a copy of next_call_time taken when the timer was added, fired or reset, so after such a jump the timer thread slept until the stale deadline: a /clock jump from 1000 s back to 900 s silenced a 100 ms timer for 100 s of simulated time, and a timer that was created before use_sim_time was enabled never fired again. Register rcl's schedule change callback on every ROS time timer. It runs inside the clock jump callback with the clock mutex held, which the timer thread takes while holding its wait mutex, so it only flags the timer; the timer thread re-keys flagged timers before it computes its next wakeup, and the flag is part of its wait predicate. Signed-off-by: Yadunund Vijay <yadunund@gmail.com> Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com> Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com> (cherry picked from commit ae09d1b) # Conflicts: # rclcpp/src/rclcpp/executors/events_cbg_executor/timer_manager.hpp
|
Cherry-pick of ae09d1b has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
Signed-off-by: Alejandro Hernandez Cordero <ahcorde@gmail.com>
|
Pulls: #3405 |
ABI Compliance Check✅ Verdict: compatible
✅
|
Description
Fixes #3342
EventsCBGExecutortimers can stall after backward ROS time jumps or whenuse_sim_timeis enabled at runtime becauseTimerQueueretains stale deadlines.This PR uses the new schedule change callback from ros2/rcl#1352 to update timer deadlines. The callback only flags timers for rescheduling to avoid deadlocks.
test_executors_time_jumpverifies both scenarios. It fails on Rolling and passes with both fixes.Depends-On: ros2/rcl#1352
Is this user-facing behavior change?
Yes. Timers continue working after backward
/clockjumps (e.g.,ros2 bag play --loop --clock) and whenuse_sim_timeis enabled at runtime.Did you use Generative AI?
Yes. Claude Code (Claude Fable 5.1) assisted with investigation, implementation, and tests. Changes were reviewed and tested manually.
Additional Information
Reusing the on-reset callback causes a deadlock with
TimeSource::set_clock().This is an automatic backport of pull request #3344 done by Mergify.