Skip to content

Refactor: base clock#1627

Merged
ahcorde merged 8 commits into
ros2:rollingfrom
nadavelkabets:feature/base-clock
Mar 24, 2026
Merged

Refactor: base clock#1627
ahcorde merged 8 commits into
ros2:rollingfrom
nadavelkabets:feature/base-clock

Conversation

@nadavelkabets
Copy link
Copy Markdown
Contributor

Part of #1620

Changes

  • New BaseClock class
  • Clock class retains the blocking sleep_for() and sleep_until() methods
  • Following rclcpp, ROSClock deprecated in favor of Clock(clock_type=ClockType.ROS_TIME)`
  • JumpHandle, TimeSource and ThrottleContext now accept BaseClock
  • TimeSource checks ClockType instead of isinstance()
  • ROSClock is kept as thin deprecated subclass for backwards compatibility

Notes

  • Users with SYSTEM_TIME and STEADY_TIME can now call ros_time_is_active() and set_ros_time_override(). Similar to rclcpp, RCLError is raised if the clock is not a ROS_TIME clock
  • Removed Clock.__new__ - surprising behavior that silently returned a ROSClock instance when Clock was initialized with clock_type=ROS_TIME

@mjcarroll mjcarroll self-requested a review March 18, 2026 00:18
@mjcarroll
Copy link
Copy Markdown
Member

@nadavelkabets just a note (from @InvincibleRMC) that resolute (26.04) is going to be using Python 3.14, which does introduce some AsyncIO API changes.

You may want to pre-test what you have here for when we make the jump later this month.

Copy link
Copy Markdown
Member

@mjcarroll mjcarroll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve with a single nit and green CI.

Overall a solid refactor.

Comment thread rclpy/test/test_clock.py Outdated
Comment thread rclpy/test/test_clock.py Outdated
@mjcarroll
Copy link
Copy Markdown
Member

mjcarroll commented Mar 18, 2026

I'll run CI after you address the nits. Should be fine.

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

@nadavelkabets
Copy link
Copy Markdown
Contributor Author

@nadavelkabets just a note (from @InvincibleRMC) that resolute (26.04) is going to be using Python 3.14, which does introduce some AsyncIO API changes.

You may want to pre-test what you have here for when we make the jump later this month.

I checked the 3.13 and 3.14 changelogs - 3.13 adds keyword argument passing to the task constructor and some new util functions, and 3.14 adds task introspection. Neither affects us.
I agree it's valuable to pre-test against 3.14. Will do that for the AsyncNode feature.

nadavelkabets and others added 2 commits March 18, 2026 11:58
Co-authored-by: Michael Carroll <[email protected]>
Signed-off-by: Nadav Elkabets <[email protected]>
@nadavelkabets
Copy link
Copy Markdown
Contributor Author

@mjcarroll could you run CI again please?

@InvincibleRMC
Copy link
Copy Markdown
Contributor

Pulls: #1627
Gist: https://gist.githubusercontent.com/InvincibleRMC/3d6cdfb898475f0aeb6be8dfb579af1f/raw/3f103b104d59464c9cf20fe1504e8b1b410f4d4a/ros2.repos
BUILD args: --continue-on-error --packages-above-and-dependencies rclpy
TEST args: --packages-above rclpy
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/18643

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

Copy link
Copy Markdown
Member

@skyegalaxy skyegalaxy left a 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. looks like a solid refactor!

@ahcorde ahcorde merged commit d7de46f into ros2:rolling Mar 24, 2026
2 of 3 checks passed
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.

5 participants