Repository navigation
Update rcutils_steady_time_now to return the same data as std::chrono - #357
Merged
Merged
Conversation
Based on an investigation several years ago, rcutils_steady_time_now has slightly different behavior than std::chrono::now . In particular, on Linux rcutils_steady_time_now was using CLOCK_MONOTONIC_RAW, while std::chrono is using CLOCK_MONOTONIC. On macOS, rcutils_steady_time_now was using SYSTEM_CLOCK, while std::chrono was using CLOCK_MONOTONIC_RAW. Fix both of these so they match what std::chrono does, and in the case of macOS, significantly simplify the code by switching to clock_gettime. Signed-off-by: Chris Lalancette <[email protected]>
fujitatomoya
approved these changes
Apr 23, 2022
fujitatomoya
left a comment
Collaborator
There was a problem hiding this comment.
lgtm, aligned with std::chrono would be better for user application.
With this, all of the tests seem to pass. Signed-off-by: Chris Lalancette <[email protected]>
clalancette
marked this pull request as ready for review
April 26, 2022 18:48
Contributor
Author
Contributor
Author
|
The test failing on Windows shows up in the Windows repeated jobs as well: https://ci.ros2.org/view/nightly/job/nightly_win_rep/2596 . So I'm going to go ahead and merge this, thanks for the reviews. |
alsora
pushed a commit
to irobot-ros/rcutils
that referenced
this pull request
Jul 28, 2023
…ros2#357) * Update rcutils_steady_time_now to return the same data as std::chrono Based on an investigation several years ago, rcutils_steady_time_now has slightly different behavior than std::chrono::now . In particular, on Linux rcutils_steady_time_now was using CLOCK_MONOTONIC_RAW, while std::chrono is using CLOCK_MONOTONIC. On macOS, rcutils_steady_time_now was using SYSTEM_CLOCK, while std::chrono was using CLOCK_MONOTONIC_RAW. Fix both of these so they match what std::chrono does, and in the case of macOS, significantly simplify the code by switching to clock_gettime. Signed-off-by: Chris Lalancette <[email protected]>
alsora
pushed a commit
to irobot-ros/rcutils
that referenced
this pull request
Jul 28, 2023
…ros2#357) * Update rcutils_steady_time_now to return the same data as std::chrono Based on an investigation several years ago, rcutils_steady_time_now has slightly different behavior than std::chrono::now . In particular, on Linux rcutils_steady_time_now was using CLOCK_MONOTONIC_RAW, while std::chrono is using CLOCK_MONOTONIC. On macOS, rcutils_steady_time_now was using SYSTEM_CLOCK, while std::chrono was using CLOCK_MONOTONIC_RAW. Fix both of these so they match what std::chrono does, and in the case of macOS, significantly simplify the code by switching to clock_gettime. Signed-off-by: Chris Lalancette <[email protected]>
This was referenced Nov 3, 2026
bobzwik
added a commit
to bobzwik/camera_ros
that referenced
this pull request
Nov 5, 2026
libcamera's SensorTimestamp is on CLOCK_MONOTONIC. Before rcutils 5.2.0 (ros2/rcutils#357), RCL_STEADY_TIME reads CLOCK_MONOTONIC_RAW instead, and the gap between the two clocks grows with uptime and ends up in header.stamp. With rcutils < 5.2.0 (Humble), measure the latency with std::chrono::steady_clock, which is CLOCK_MONOTONIC. Fixes christianrauch#180
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on an investigation several years ago, rcutils_steady_time_now
has slightly different behavior than std::chrono::now . In
particular, on Linux rcutils_steady_time_now was using
CLOCK_MONOTONIC_RAW, while std::chrono is using CLOCK_MONOTONIC.
On macOS, rcutils_steady_time_now was using SYSTEM_CLOCK, while std::chrono
was using CLOCK_MONOTONIC_RAW. Fix both of these so they
match what std::chrono does, and in the case of macOS, significantly
simplify the code by switching to clock_gettime.
Signed-off-by: Chris Lalancette [email protected]
This should fix #43 . Draft for now, as I haven't even compile tested this on macOS yet.