|
CPP-TOOLBOX
|
A class for generating periodic signals based on a specified rate with different operation modes. More...
#include <periodic_signal.hpp>
Public Member Functions | |
| PeriodicSignal (int rate_limit_hz, OperationMode mode=OperationMode::MEASURED_DELTAS) | |
| bool | process_and_get_signal () |
| Returns true if one or more signals should have occurred since the last call. If we have fallen behind, it "catches up" to the latest expected signal. | |
| double | get_last_delta_time () const |
| returns the amount of time it took for the last signal to come through | |
| bool | enough_time_has_passed () const |
| returns true if a signal would have occurred since the last signal. | |
| double | get_cycle_progress () const |
| Returns normalized progress [0,1] through the current cycle. | |
A class for generating periodic signals based on a specified rate with different operation modes.
The current implementation was found to be more accurate then the previous implementation, which can be viewed by going back in the git history to when this comment was added, and viewing the periodic signals implementation, in the old implementation everything was based off the last time and it would have error building up over time, with the new implemenation everything is thought of as a timeline, and the "ticks" are laid out before hand, we just sample the clock and figure out which tick we are in, which has shown to be more accurate.
|
inlineexplicit |
|
inline |
returns true if a signal would have occurred since the last signal.
|
inline |
Returns normalized progress [0,1] through the current cycle.
|
inline |
returns the amount of time it took for the last signal to come through
when the operation mode is PERFECT_DELTAS, this function lies and always returns the computed period based off rate_limit_hz when the operation mode is MEASURED_DELTAS, this function returns the measured amount of time
|
inline |
Returns true if one or more signals should have occurred since the last call. If we have fallen behind, it "catches up" to the latest expected signal.