Package xbot.common.math
Class InterpolatingHistoryBuffer
java.lang.Object
xbot.common.math.InterpolatingHistoryBuffer
-
Constructor Summary
ConstructorDescriptionInterpolatingHistoryBuffer
(int length, double init_val) This class implements a set of circular buffers that can be used to store values of signals in the past, and retrieve values at arbitrary previous time indexes. -
Method Summary
Modifier and TypeMethodDescriptiondouble
getValAtTime
(double time) Returns the value at a given time, linearlly interpolated.boolean
insert
(double time, double value) Insert a new value into the buffer.
-
Constructor Details
-
InterpolatingHistoryBuffer
public InterpolatingHistoryBuffer(int length, double init_val) This class implements a set of circular buffers that can be used to store values of signals in the past, and retrieve values at arbitrary previous time indexes. The value is assumed to saturate at the end of the maintained history.- Parameters:
length
- Number of samples to keepinit_val
- Value to fill the inital samples with (probably zero is fine)
-
-
Method Details
-
insert
public boolean insert(double time, double value) Insert a new value into the buffer. Discards the oldest value.- Parameters:
time
- Time at which the value was sampled. elements must be inserted in a monotomically increasing fashionvalue
- Value of the signal right now- Returns:
- true if the value was inserted, false otherwise
-
getValAtTime
public double getValAtTime(double time) Returns the value at a given time, linearlly interpolated.- Parameters:
time
- time at which to retrieve value- Returns:
- value at inputted time.
-