Skip to content
This repository was archived by the owner on May 31, 2025. It is now read-only.

add MonotonicTimer#1003

Closed
flixr wants to merge 1 commit intoros:lunar-develfrom
flixr:monotonic_timer
Closed

add MonotonicTimer#1003
flixr wants to merge 1 commit intoros:lunar-develfrom
flixr:monotonic_timer

Conversation

@flixr
Copy link
Copy Markdown
Contributor

@flixr flixr commented Feb 26, 2017

based on MonotonicTime (which uses the CLOCK_MONOTONIC).
This timer is not influenced by time jumps of the system time,
so ideal for things like periodic checks of timeout/heartbeat, etc...

Depends on ros/roscpp_core#55

based on MonotonicTime (which uses the CLOCK_MONOTONIC).
This timer is not influenced by time jumps of the system time,
so ideal for things like periodic checks of timeout/heartbeat, etc...
@flixr
Copy link
Copy Markdown
Contributor Author

flixr commented Feb 27, 2017

So while in theory this should work well, it seems that there is a bug in the boost condition timed_wait:
Even if you pass it a duration it will simply add it to the current system time and wait until then.
It seems to be fixed in boost 1.61 if you specify BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC, see https://svn.boost.org/trac/boost/ticket/6377

So that means that currently the MonotonicTimer can nicely deal with forward jumps in time, but not with backwards jumps.

Possible solutions:

  • also only wait for 1ms just like in the sim time case and re-check the sleep_end predicate
    • drawback is that you up a lot more often than needed
    • to do this only for the MonotonicTimer we either need to add a member function isMonotonicTime or use a typeid check?
  • replace the boost condition variable with C++11 equivalent where you can specify it to use a monotonic clock

@flixr flixr mentioned this pull request Mar 6, 2017
@flixr
Copy link
Copy Markdown
Contributor Author

flixr commented Mar 6, 2017

Closing in favor of #1014

@flixr flixr closed this Mar 6, 2017
@flixr flixr deleted the monotonic_timer branch March 6, 2017 16:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant