Skip to content

Add sleep function that respects ROS time #617

@sloretz

Description

@sloretz

Feature request

Feature description

This is a request for a function that sleeps the current thread while respecting ROS time.

Implementation considerations

There's some discussion about where a method like this should live in ros2/rclcpp#1248.
Historically this method has lived as rospy.sleep() and rospy.Rate.sleep()

Sleeping should respect the clock being used. I think this could be implemented by waiting on a threading.Event that's woken by a time jump callback. Steady clock and system clocks don't have time jump callbacks, so the event would expire on the timeout being reached.

I'm assuming this would be a sleep_for(duration) rather than a sleep_until(time). The latter is tricky when using system time because right now we don't have time jump callbacks for when system time changes.

Sleeping on ROS clocks would only be as accurate as the frequency of published time messages on the /clock topic. More frequent publishing has a drawback that it will wake the time jump callback more frequently before the sleep period has elapsed.

Related to ros2/rclcpp#1730

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions