Skip to content
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

feat: Add ClockWaiter and ClockConditionalVariable #2691

Merged
merged 2 commits into from
Mar 19, 2025

Conversation

jmachowinski
Copy link
Collaborator

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 ?

@ros-discourse
Copy link

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

@sloretz
Copy link
Contributor

sloretz commented Dec 20, 2024

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



bool
wait_until_ros_time(std::unique_lock<std::mutex>& lock,
Copy link

Choose a reason for hiding this comment

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

Add documentation.
Especially document that system time will be used if ros time is not active

Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

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

@jmachowinski do we need to review this?

#2674 includes pretty much everything here?

@jmachowinski
Copy link
Collaborator Author

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

@fujitatomoya
Copy link
Collaborator

Ah, i missed that, sorry.

Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

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

Those classes have been already approved in jazzy to fix the action expired goal synchronization, so it will be better to keep those classes in rolling for maintainability.

i would like to request another review for this. CC: @alsora @mjcarroll @wjwwood

@alsora
Copy link
Collaborator

alsora commented Mar 1, 2025

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

@jmachowinski
Copy link
Collaborator Author

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

Copy link
Collaborator

@fujitatomoya fujitatomoya 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.

@fujitatomoya
Copy link
Collaborator

Pulls: #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

@jmachowinski
Copy link
Collaborator Author

This PR now depends on ros2/rcpputils#210

@jmachowinski
Copy link
Collaborator Author

jmachowinski commented Mar 13, 2025

Pulls: #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
Copy link
Collaborator Author

Pulls: #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

Janosch Machowinski added 2 commits March 18, 2025 14:44
Added two new synchronization primitives to perform waits
using an rclcpp::Clock.

Signed-off-by: Janosch Machowinski <[email protected]>
Signed-off-by: Janosch Machowinski <[email protected]>
@jmachowinski
Copy link
Collaborator Author

Pulls: #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
Copy link
Collaborator Author

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

@jmachowinski jmachowinski merged commit b9b46c5 into ros2:rolling Mar 19, 2025
2 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.

7 participants