CTRE Phoenix 6 C++ 25.1.0
Loading...
Searching...
No Matches
ctre::phoenix6::swerve::TimeInterpolatableBuffer< T > Class Template Reference

The TimeInterpolatableBuffer provides an easy way to estimate past measurements. More...

#include <ctre/phoenix6/swerve/utility/TimeInterpolatableBuffer.hpp>

Public Member Functions

 TimeInterpolatableBuffer (units::second_t historySize, std::function< T(const T &, const T &, double)> func)
 Create a new TimeInterpolatableBuffer.
 
 TimeInterpolatableBuffer (units::second_t historySize)
 Create a new TimeInterpolatableBuffer.
 
void AddSample (units::second_t time, T sample)
 Add a sample to the buffer.
 
void Clear ()
 Clear all old samples.
 
std::optional< T > Sample (units::second_t time) const
 Sample the buffer at the given time.
 
std::vector< std::pair< units::second_t, T > > & GetInternalBuffer ()
 Grant access to the internal sample buffer.
 
const std::vector< std::pair< units::second_t, T > > & GetInternalBuffer () const
 Grant access to the internal sample buffer.
 
 TimeInterpolatableBuffer (units::second_t historySize)
 

Detailed Description

template<typename T>
class ctre::phoenix6::swerve::TimeInterpolatableBuffer< T >

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 Lerp can be used. For Pose2ds, we use Twists.

Template Parameters
TThe type stored in this buffer.

Constructor & Destructor Documentation

◆ TimeInterpolatableBuffer() [1/3]

template<typename T >
ctre::phoenix6::swerve::TimeInterpolatableBuffer< T >::TimeInterpolatableBuffer ( units::second_t historySize,
std::function< T(const T &, const T &, double)> func )
inline

Create a new TimeInterpolatableBuffer.

Parameters
historySizeThe history size of the buffer.
funcThe function used to interpolate between values.

◆ TimeInterpolatableBuffer() [2/3]

template<typename T >
ctre::phoenix6::swerve::TimeInterpolatableBuffer< T >::TimeInterpolatableBuffer ( units::second_t historySize)
inlineexplicit

Create a new TimeInterpolatableBuffer.

By default, the interpolation function is Lerp except for Pose2d, which uses the pose exponential.

Parameters
historySizeThe history size of the buffer.

◆ TimeInterpolatableBuffer() [3/3]

ctre::phoenix6::swerve::TimeInterpolatableBuffer< Pose2d >::TimeInterpolatableBuffer ( units::second_t historySize)
inline

Member Function Documentation

◆ AddSample()

template<typename T >
void ctre::phoenix6::swerve::TimeInterpolatableBuffer< T >::AddSample ( units::second_t time,
T sample )
inline

Add a sample to the buffer.

Parameters
timeThe timestamp of the sample.
sampleThe sample object.

◆ Clear()

template<typename T >
void ctre::phoenix6::swerve::TimeInterpolatableBuffer< T >::Clear ( )
inline

Clear all old samples.

◆ GetInternalBuffer() [1/2]

template<typename T >
std::vector< std::pair< units::second_t, T > > & ctre::phoenix6::swerve::TimeInterpolatableBuffer< T >::GetInternalBuffer ( )
inline

Grant access to the internal sample buffer.

Used in Pose Estimation to replay odometry inputs stored within this buffer.

◆ GetInternalBuffer() [2/2]

template<typename T >
const std::vector< std::pair< units::second_t, T > > & ctre::phoenix6::swerve::TimeInterpolatableBuffer< T >::GetInternalBuffer ( ) const
inline

Grant access to the internal sample buffer.

◆ Sample()

template<typename T >
std::optional< T > ctre::phoenix6::swerve::TimeInterpolatableBuffer< T >::Sample ( units::second_t time) const
inline

Sample the buffer at the given time.

If the buffer is empty, an empty optional is returned.

Parameters
timeThe time at which to sample the buffer.

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