Skip to content

Add rcl_timer_set_on_schedule_change_callback - #1352

Merged
skyegalaxy merged 1 commit into
rollingfrom
yadu/timer-on-schedule-change-callback
Nov 9, 2026
Merged

skyegalaxy merged 1 commit into
rollingfrom
yadu/timer-on-schedule-change-callback

Conversation

@Yadunund

Copy link
Copy Markdown
Member

Description

Helps address ros2/rclcpp#3342

ROS time jumps can change a timer's next call time without notifying the executor. This causes EventsCBGExecutor to miss timer updates after backward /clock jumps or when use_sim_time is toggled.

This PR adds rcl_timer_set_on_schedule_change_callback() to notify consumers when a timer's next call time changes due to:

  • Backward clock jumps past the last call time.
  • ROS time activation or deactivation.

No ABI changes.

Is this user-facing behavior change?

Yes. Enables executors to correctly reschedule timers after ROS time changes, preventing timers from stalling.

Did you use Generative AI?

Yes. Claude Fable 5.1

Additional Information

Tests:

  • Backward and forward clock jumps, including unchanged schedules.
  • ROS time activation and deactivation.
  • Callback removal.
  • All 29 test_timer tests pass.
  • ament_uncrustify and ament_cpplint pass.

A timer on ROS time moves its next call time inside its clock jump
callback when the clock jumps backward past the last call time and
when ROS time is activated or deactivated. Nothing told an executor
that keeps its own copy of the next call time about it: the on reset
callback is only called by rcl_timer_reset(), on purpose (#995), so
the EventsCBGExecutor in rclcpp kept sleeping until the old deadline.

Add a separate callback that is called at exactly those two places,
after the new next call time was stored. It is kept apart from the on
reset callback because it runs inside the clock jump callback, on the
thread and under the locks of whoever set the clock, so a consumer
has to handle it without blocking, while a reset callback may lock.

Signed-off-by: Yadunund Vijay <[email protected]>
@skyegalaxy
skyegalaxy requested review from jmachowinski and skyegalaxy and removed request for jmachowinski October 16, 2026 21:53
nevlife added a commit to nevlife/rcl that referenced this pull request Oct 21, 2026
nevlife added a commit to nevlife/rcl that referenced this pull request Oct 24, 2026
@skyegalaxy

Copy link
Copy Markdown
Member

Pulls: ros2/rclcpp#3344, #1352
Gist: https://gist.githubusercontent.com/skyegalaxy/d13c844de6c5b11ebd30e659d85cbbb6/raw/6f04b2be76f53e822813683587d36af9938b5337/ros2.repos
BUILD args: --packages-above-and-dependencies rcl rclcpp
TEST args: --packages-above rcl rclcpp
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/20969

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@skyegalaxy

Copy link
Copy Markdown
Member

Pulls: ros2/rclcpp#3344, #1352
Gist: https://gist.githubusercontent.com/skyegalaxy/db7f12561f4f969e62dd17e29b96b37a/raw/6f04b2be76f53e822813683587d36af9938b5337/ros2.repos
BUILD args: --packages-above-and-dependencies rcl rclcpp
TEST args: --packages-above rcl rclcpp
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/21045

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@skyegalaxy
skyegalaxy merged commit 0224ede into rolling Nov 9, 2026
3 checks passed
@skyegalaxy

Copy link
Copy Markdown
Member

@Mergifyio backport jazzy kilted lyrical

@mergify

mergify Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

backport jazzy kilted lyrical

✅ Backports have been created

Details

Cherry-pick of 0224ede has failed:

On branch mergify/bp/jazzy/pr-1352
Your branch is up to date with 'origin/jazzy'.

You are currently cherry-picking commit 0224ede.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   rcl/include/rcl/timer.h
	modified:   rcl/test/rcl/test_timer.cpp

Unmerged paths:
  (use "git add/rm <file>..." as appropriate to mark resolution)
	both modified:   rcl/src/rcl/timer.c
	deleted by us:   rcl/src/rcl/timer_impl.h

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

Cherry-pick of 0224ede has failed:

On branch mergify/bp/kilted/pr-1352
Your branch is up to date with 'origin/kilted'.

You are currently cherry-picking commit 0224ede.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   rcl/include/rcl/timer.h
	modified:   rcl/test/rcl/test_timer.cpp

Unmerged paths:
  (use "git add/rm <file>..." as appropriate to mark resolution)
	both modified:   rcl/src/rcl/timer.c
	deleted by us:   rcl/src/rcl/timer_impl.h

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

ahcorde pushed a commit that referenced this pull request Nov 11, 2026
A timer on ROS time moves its next call time inside its clock jump
callback when the clock jumps backward past the last call time and
when ROS time is activated or deactivated. Nothing told an executor
that keeps its own copy of the next call time about it: the on reset
callback is only called by rcl_timer_reset(), on purpose (#995), so
the EventsCBGExecutor in rclcpp kept sleeping until the old deadline.

Add a separate callback that is called at exactly those two places,
after the new next call time was stored. It is kept apart from the on
reset callback because it runs inside the clock jump callback, on the
thread and under the locks of whoever set the clock, so a consumer
has to handle it without blocking, while a reset callback may lock.


(cherry picked from commit 0224ede)

Signed-off-by: Yadunund Vijay <[email protected]>
Co-authored-by: yadunund <[email protected]>
ahcorde added a commit that referenced this pull request Nov 18, 2026
(cherry picked from commit 0224ede)

Signed-off-by: Alejandro Hernandez Cordero <[email protected]>
Co-authored-by: yadunund <[email protected]>
Co-authored-by: Alejandro Hernandez Cordero <[email protected]>
ahcorde added a commit that referenced this pull request Nov 18, 2026
(cherry picked from commit 0224ede)

Signed-off-by: Alejandro Hernandez Cordero <[email protected]>
Co-authored-by: yadunund <[email protected]>
Co-authored-by: Alejandro Hernandez Cordero <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants