gramods
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
gramods::gmMisc::EFHOAW Class Reference

This is an end-fitting higher-order adaptive window estimator of velocity from samples allowing jittering. More...

#include <EFHOAW.hh>

Classes

struct  Impl
 

Public Types

typedef Eigen::Matrix< double, 3, Eigen::Dynamic > polco
 Matrix holding the polynomial coefficients, one row for each dimension.
 

Public Member Functions

 EFHOAW ()
 Creates a new end-fitting first-order adaptive window estimator using the default parameters.
 
void setHistoryLength (size_t N)
 Set how many samples should be saved to be used when estimating the velocity.
 
size_t getHistoryLength () const
 Get the number of samples that are saved to be used when estimating the velocity.
 
void setHistoryDuration (double t)
 Set how old samples should be saved to be used when estimating the velocity.
 
double getHistoryDuration () const
 Get how old samples are saved to be used when estimating the velocity.
 
double getLastSampleTime (size_t id)
 Returns the time associated with the last sample associated with the specified id, or -1 if there is no last sample available.
 
void addSample (size_t id, Eigen::Vector3d position, double time, bool replace=true)
 Add a position sample.
 
polco estimateCoefficients (size_t id, double error, size_t order=2, size_t *samples=nullptr)
 Estimate and return the coefficients of the polynomial, of the specified order, that best fits the data.
 
Eigen::Vector3d getPolynomialPosition (int id, double t) const
 Returns the position calculated from the polynomial using the last estimated coefficients, from the previous call to estimateCoefficients.
 
Eigen::Vector3d getPolynomialVelocity (int id, double t) const
 Returns the velocity calculated from the polynomial using the last estimated coefficients, from the previous call to estimateCoefficients.
 
void cleanup (double time=-1)
 Clean-up old samples and unused ids.
 

Detailed Description

This is an end-fitting higher-order adaptive window estimator of velocity from samples allowing jittering.

Units of both length and time can be arbitrarily chosen and the velocity will be estimated as distance over time in the same units.

Member Typedef Documentation

◆ polco

typedef Eigen::Matrix<double, 3, Eigen::Dynamic> gramods::gmMisc::EFHOAW::polco

Matrix holding the polynomial coefficients, one row for each dimension.

Constructor & Destructor Documentation

◆ EFHOAW()

gramods::gmMisc::EFHOAW::EFHOAW ( )

Creates a new end-fitting first-order adaptive window estimator using the default parameters.

Member Function Documentation

◆ addSample()

void gramods::gmMisc::EFHOAW::addSample ( size_t  id,
Eigen::Vector3d  position,
double  time,
bool  replace = true 
)

Add a position sample.

Each sample is associated to an id and a time. If a new sample is provided with the same id and time as a previously added sample, this new sample will replace the old.

Parameters
[in]idThe id to add position sample to.
[in]positionThe position value to use as sample.
[in]timeThe time at which the sample was taken.
[in]replaceIf true (default), old samples with the same time will be replaced with this new sample value.

◆ cleanup()

void gramods::gmMisc::EFHOAW::cleanup ( double  time = -1)

Clean-up old samples and unused ids.

This function should be called from time to time, for example after calling addSample, to avoid too much unnecessary memory usage.

Parameters
timeThe current time, to use when estimating if samples are too old, or -1 to use the samples' time.

◆ estimateCoefficients()

EFHOAW::polco gramods::gmMisc::EFHOAW::estimateCoefficients ( size_t  id,
double  error,
size_t  order = 2,
size_t *  samples = nullptr 
)

Estimate and return the coefficients of the polynomial, of the specified order, that best fits the data.

This method uses as many samples backwards that gives an estimate within the specified error.

Parameters
[in]idThe id to estimate velocity for.
[in]errorAn estimate of the position tracking error, used to determine how many samples to include in the averaging.
[in]orderThe order of estimation
[out]samplesThe number of history samples used in the estimation.
Returns
A 3 rows and order+1 column matrix with the polynomial coefficients

◆ getHistoryDuration()

double gramods::gmMisc::EFHOAW::getHistoryDuration ( ) const

Get how old samples are saved to be used when estimating the velocity.

◆ getHistoryLength()

size_t gramods::gmMisc::EFHOAW::getHistoryLength ( ) const

Get the number of samples that are saved to be used when estimating the velocity.

◆ getLastSampleTime()

double gramods::gmMisc::EFHOAW::getLastSampleTime ( size_t  id)

Returns the time associated with the last sample associated with the specified id, or -1 if there is no last sample available.

◆ getPolynomialPosition()

Eigen::Vector3d gramods::gmMisc::EFHOAW::getPolynomialPosition ( int  id,
double  t 
) const

Returns the position calculated from the polynomial using the last estimated coefficients, from the previous call to estimateCoefficients.

Observe that this method can be used both for inter- and extrapolation.

◆ getPolynomialVelocity()

Eigen::Vector3d gramods::gmMisc::EFHOAW::getPolynomialVelocity ( int  id,
double  t 
) const

Returns the velocity calculated from the polynomial using the last estimated coefficients, from the previous call to estimateCoefficients.

Observe that this method can be used both for inter- and extrapolation.

◆ setHistoryDuration()

void gramods::gmMisc::EFHOAW::setHistoryDuration ( double  t)

Set how old samples should be saved to be used when estimating the velocity.

Per default all samples are saved and used.

◆ setHistoryLength()

void gramods::gmMisc::EFHOAW::setHistoryLength ( size_t  N)

Set how many samples should be saved to be used when estimating the velocity.

Per default all samples are saved and used.


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