rclcpp icon indicating copy to clipboard operation
rclcpp copied to clipboard

feat: Add ClockWaiter and ClockConditionalVariable

Open jmachowinski opened this issue 1 year ago • 4 comments

This replaces the Clock::cancel_sleep_or_wait with two new synchronization primitives, that can be instantiated separate from the Clock object.

The old API turned out the be a bad design, as one can not simply copy or create new clock objects.

If one copys a clock object, the same internal pimpl is copied, which is undesirable in combination with this API, as they then all share the same conditional. Therefore one can't do sleeps with multiple threads without waking up other threads.

If one tries to create a new clock, then there is no clockprovider registered to it. Leading to an unexpected behavior in simulation mode. We should perhaps add a BIG warning to the constructor to not do this.

This merge request is a first step in reworking the clock code, and I want to get some feedback on the API / class names, before refactoring further.

@arneboe Can you have a look the documentation and API ?

jmachowinski avatar Dec 02 '24 17:12 jmachowinski

This pull request has been mentioned on ROS Discourse. There might be relevant details there:

https://discourse.ros.org/t/next-client-library-wg-meeting-friday-6th-december-2024-8am-pt/40954/2

ros-discourse avatar Dec 06 '24 17:12 ros-discourse

Assigned @wjwwood, and recommend Client Library Working group review 🧇

sloretz avatar Dec 20 '24 19:12 sloretz

This is the rolling version of general useful code used in 2674.

jmachowinski avatar Feb 12 '25 21:02 jmachowinski

Ah, i missed that, sorry.

fujitatomoya avatar Feb 12 '25 21:02 fujitatomoya

The changes look good. I think we should add unit-tests and then we are good to merge

alsora avatar Mar 01 '25 10:03 alsora

I added tests, and fixed a bug that I found through this...

jmachowinski avatar Mar 07 '25 15:03 jmachowinski

Pulls: ros2/rclcpp#2691 Gist: https://gist.githubusercontent.com/fujitatomoya/0d3dcb844cf0e7ec6ea465a2cfce1e9a/raw/66f4f58452aabc6993e98b6fe94f01ed818f73a0/ros2.repos BUILD args: --packages-above-and-dependencies rclcpp TEST args: --packages-above rclcpp ROS Distro: rolling Job: ci_launcher ci_launcher ran: https://ci.ros2.org/job/ci_launcher/15307

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

fujitatomoya avatar Mar 07 '25 18:03 fujitatomoya

This PR now depends on https://github.com/ros2/rcpputils/pull/210

jmachowinski avatar Mar 10 '25 14:03 jmachowinski

Pulls: ros2/rclcpp#2691 Gist: https://gist.githubusercontent.com/jmachowinski/9da107eefb9f3b72af8f2ef7876ff88b/raw/66f4f58452aabc6993e98b6fe94f01ed818f73a0/ros2.repos BUILD args: TEST args: ROS Distro: rolling Job: ci_launcher ci_launcher ran: https://ci.ros2.org/job/ci_launcher/15367

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

jmachowinski avatar Mar 13 '25 15:03 jmachowinski

Pulls: ros2/rclcpp#2691 Gist: https://gist.githubusercontent.com/jmachowinski/a04d30035afad41146ae80dd67c1d8b9/raw/66f4f58452aabc6993e98b6fe94f01ed818f73a0/ros2.repos BUILD args: TEST args: ROS Distro: rolling Job: ci_launcher ci_launcher ran: https://ci.ros2.org/job/ci_launcher/15410

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

jmachowinski avatar Mar 18 '25 12:03 jmachowinski

Pulls: ros2/rclcpp#2691 Gist: https://gist.githubusercontent.com/jmachowinski/02144ac023a0049d5d71095f052eb60d/raw/66f4f58452aabc6993e98b6fe94f01ed818f73a0/ros2.repos BUILD args: TEST args: ROS Distro: rolling Job: ci_launcher ci_launcher ran: https://ci.ros2.org/job/ci_launcher/15411

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

jmachowinski avatar Mar 18 '25 13:03 jmachowinski

All failures in the CI are unrelated to this PR, I would say we are ready to merge.

jmachowinski avatar Mar 19 '25 09:03 jmachowinski