Kanzi  3.9.9
Kanzi Engine C++ API
kanzi::SpeedMeasurer Class Reference

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

kanzi::SpeedMeasurer::SpeedMeasurer ( size_t  maxMeasurements,
chrono::milliseconds  minMeasurementWindow,
chrono::milliseconds  maxMeasurementWindow 
)
explicit

Creates a speed measurer with the given properties.

Parameters
maxMeasurementsThe maximum number of speed measurements to use.
minMeasurementWindowThe minimum measurement window in milliseconds. Kanzi drops the samples that arrive faster.
maxMeasurementWindowThe maximum measurement window in milliseconds. Kanzi ignores older samples.

Member Function Documentation

void kanzi::SpeedMeasurer::reset ( )

Resets the measurement data.

void kanzi::SpeedMeasurer::addMeasurement ( TimePoint  timestamp,
float  value 
)

Adds a new measurement to a measurer.

Parameters
timestampTime of the measurement.
valueValue of the measurement.
optional<float> kanzi::SpeedMeasurer::getSpeed ( TimePoint  measurementTime) const

Calculates the speed estimate for a time point.

Parameters
measurementTimeTime of the speed estimate.
Returns
The speed estimate. If there are not enough measurements, returns nullopt.

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