Skip to content

feat(rclrs): add Clock sleep and async sleep APIs#647

Open
PvRao-29 wants to merge 1 commit into
ros2-rust:mainfrom
PvRao-29:feature/clock-sleep
Open

feat(rclrs): add Clock sleep and async sleep APIs#647
PvRao-29 wants to merge 1 commit into
ros2-rust:mainfrom
PvRao-29:feature/clock-sleep

Conversation

@PvRao-29

@PvRao-29 PvRao-29 commented Jun 14, 2026

Copy link
Copy Markdown

Summary

  • Adds Clock::sleep_for, sleep_until, async_sleep_for, and async_sleep_until, aligned with rclcpp semantics
  • Adds ros_time_is_active() helper used by the sleep loop
  • Async sleep yields to the runtime so it can be used under use_sim_time without blocking the executor
    Fixes Add support for Clock sleep_for/sleep_until #604

Design notes

  • Poll-loop implementation (10ms tick) rather than jump callbacks; keeps the diff small and avoids overlap with Feature request: Clock Jump Callbacks #524
  • Sync sleep_for can still deadlock under sim time in a single-threaded executor callback; documented in rustdoc, with async variants as the recommended path
  • Returns bool like rclcpp (true = target reached, false = context invalid)

Test plan

  • cargo fmt
  • cargo clippy --all-targets (pre-existing warnings only)
  • cargo test clock — 13 passed including 4 new clock sleep tests
  • CI (rust-stable / rust-minimal)

Add sleep_for, sleep_until, async_sleep_for, and async_sleep_until to
Clock, aligned with rclcpp semantics. Async variants yield to the runtime
so they work under use_sim_time without blocking the executor.
Fixes ros2-rust#604
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.

Add support for Clock sleep_for/sleep_until

1 participant