Speed measurer estimates the rate of change from a series of measurements. More...
#include <kanzi/core.ui/util/speed_measurer.hpp>
Public Member Functions | |
void | addMeasurement (TimePoint timestamp, float value) |
Adds a new measurement to a measurer. More... | |
optional< float > | getSpeed (TimePoint measurementTime) const |
Calculates the speed estimate for a time point. More... | |
void | reset () |
Resets the measurement data. More... | |
SpeedMeasurer (size_t maxMeasurements, chrono::milliseconds minMeasurementWindow, chrono::milliseconds maxMeasurementWindow) | |
Creates a speed measurer with the given properties. More... | |
Speed measurer estimates the rate of change from a series of measurements.
Speed measurer is primarily used to estimate speed from position measurements or angular velocity from angle measurements, but it can be used to estimate any time derivative.
Use addMeasurement() to add measurements, and getSpeed() to compute the speed estimates.
|
explicit |
Creates a speed measurer with the given properties.
maxMeasurements | The maximum number of speed measurements to use. |
minMeasurementWindow | The minimum measurement window in milliseconds. Kanzi drops the samples that arrive faster. |
maxMeasurementWindow | The maximum measurement window in milliseconds. Kanzi ignores older samples. |
void kanzi::SpeedMeasurer::reset | ( | ) |
Resets the measurement data.
void kanzi::SpeedMeasurer::addMeasurement | ( | TimePoint | timestamp, |
float | value | ||
) |
Adds a new measurement to a measurer.
timestamp | Time of the measurement. |
value | Value of the measurement. |
optional<float> kanzi::SpeedMeasurer::getSpeed | ( | TimePoint | measurementTime | ) | const |
Calculates the speed estimate for a time point.
measurementTime | Time of the speed estimate. |