ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

create_wall_timer(): monotonic clock?

asked 2021-08-10 11:08:37 -0600

high12noon gravatar image

Is the timer created by create_wall_timer() monotonic? i.e., guaranteed never to jump backwards (or forwards) due to midnight, daylight savings time, user changing the system clock, clock adjustments via NTP, etc?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2021-08-10 18:14:10 -0600

ijnek gravatar image

According to rclcpp::timer docs, std::chrono::steady_clock is used,

using   WallTimer = GenericTimer< CallbackType, std::chrono::steady_clock >

Quoting from std::chrono::steady_clock docs,

Class std::chrono::steady_clock represents a monotonic clock. The time points of this clock cannot decrease as physical time moves forward and the time between ticks of this clock is constant. This clock is not related to wall clock time (for example, it can be time since last reboot), and is most suitable for measuring intervals.

So to answer your question, Yes, it is guaranteed never to jump backwards (or forwards) due to midnight, daylight savings time, user changing the system clock, clock adjustments via NTP, etc

edit flag offensive delete link more

Comments

And adding a small note for anyone who is curious, from std::chrono::duration docs,

Note: each of the predefined duration types up to hours covers a range of at least ±292 years.

So overflow also won't be an issue, at least in our lifetime

shonigmann gravatar image shonigmann  ( 2021-08-10 18:25:47 -0600 )edit

Question Tools

5 followers

Stats

Asked: 2021-08-10 11:08:37 -0600

Seen: 374 times

Last updated: Aug 10 '21