WPILibC++ 2024.3.2
|
The TimeInterpolatableBuffer provides an easy way to estimate past measurements. More...
#include <frc/interpolation/TimeInterpolatableBuffer.h>
Public Member Functions | |
TimeInterpolatableBuffer (units::second_t historySize, std::function< T(const T &, const T &, double)> func) | |
Create a new TimeInterpolatableBuffer. More... | |
TimeInterpolatableBuffer (units::second_t historySize) | |
Create a new TimeInterpolatableBuffer. More... | |
void | AddSample (units::second_t time, T sample) |
Add a sample to the buffer. More... | |
void | Clear () |
Clear all old samples. More... | |
std::optional< T > | Sample (units::second_t time) |
Sample the buffer at the given time. More... | |
std::vector< std::pair< units::second_t, T > > & | GetInternalBuffer () |
Grant access to the internal sample buffer. More... | |
WPILIB_DLLEXPORT | TimeInterpolatableBuffer (units::second_t historySize) |
The TimeInterpolatableBuffer provides an easy way to estimate past measurements.
One application might be in conjunction with the DifferentialDrivePoseEstimator, where knowledge of the robot pose at the time when vision or other global measurement were recorded is necessary, or for recording the past angles of mechanisms as measured by encoders.
When sampling this buffer, a user-provided function or wpi::Lerp can be used. For Pose2ds, we use Twists.
T | The type stored in this buffer. |
|
inline |
Create a new TimeInterpolatableBuffer.
historySize | The history size of the buffer. |
func | The function used to interpolate between values. |
|
inlineexplicit |
Create a new TimeInterpolatableBuffer.
By default, the interpolation function is wpi::Lerp except for Pose2d, which uses the pose exponential.
historySize | The history size of the buffer. |
WPILIB_DLLEXPORT frc::TimeInterpolatableBuffer< Pose2d >::TimeInterpolatableBuffer | ( | units::second_t | historySize | ) |
|
inline |
Add a sample to the buffer.
time | The timestamp of the sample. |
sample | The sample object. |
|
inline |
Clear all old samples.
|
inline |
Grant access to the internal sample buffer.
Used in Pose Estimation to replay odometry inputs stored within this buffer.
|
inline |
Sample the buffer at the given time.
If the buffer is empty, an empty optional is returned.
time | The time at which to sample the buffer. |