upkie 9.0.0
Open-source wheeled biped robots
Loading...
Searching...
No Matches
SynchronousClock Class Reference

Synchronous (blocking) clock. More...

#include <SynchronousClock.h>

Public Member Functions

 SynchronousClock (double frequency)
 Initialize clock. More...
 
void wait_for_next_tick ()
 Wait until the next tick of the internal clock. More...
 
double measured_period () const noexcept
 Get measured period in seconds.
 
int skip_count () const noexcept
 Get last number of clock cycles skipped.
 
double slack () const noexcept
 Get the last sleep duration duration in seconds.
 

Static Public Member Functions

static constexpr double skip_warning_interval () noexcept
 Get skip warning interval in seconds (for testing).
 

Detailed Description

Synchronous (blocking) clock.

This clock ticks at a fixed frequency. It provides a method to wait for the next tick (which is always blocking, see below), and reports missed ticks if applicable.

The difference between a blocking clock and a rate limiter lies in the behavior when skipping cycles. A rate limiter does nothing if there is no time left, as the caller's rate does not need to be limited. On the contrary, a synchronous clock waits for the next tick, which is by definition in the future, so it always waits for a non-zero duration.

Internally all durations in this class are stored in microseconds.


The documentation for this class was generated from the following files: