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

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

#include <EFFOAW.hh>

Classes

struct  Impl
 

Public Member Functions

 EFFOAW ()
 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, size_t N=0)
 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)
 Add a position sample.
 
void removeLastSample (size_t id)
 Remove the last sample for the specified id.
 
Eigen::Vector3d estimateVelocity (size_t id, double error, size_t *samples=nullptr) const
 Estimate and return the velocity using samples associated to id.
 
Eigen::Vector3d estimatePosition (size_t id, double error, double time, size_t *samples=nullptr) const
 Estimate and return the position using samples associated to id.
 
void cleanup (double time=-1)
 Clean-up old samples and unused ids.
 

Detailed Description

This is an end-fitting first-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.

The class uses std::valarray<double> to represent both position and velocity.

Constructor & Destructor Documentation

◆ EFFOAW()

gramods::gmMisc::EFFOAW::EFFOAW ( )

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

Member Function Documentation

◆ addSample()

void gramods::gmMisc::EFFOAW::addSample ( size_t  id,
Eigen::Vector3d  position,
double  time 
)

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.

◆ cleanup()

void gramods::gmMisc::EFFOAW::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.

◆ estimatePosition()

Eigen::Vector3d gramods::gmMisc::EFFOAW::estimatePosition ( size_t  id,
double  error,
double  time,
size_t *  samples = nullptr 
) const

Estimate and return the position using samples associated to id.

This is not really a functionality of EFFOAW, but uses the EFFOAW estimated velocity as a means to estimate a position in the immediate future. It is assumed that the specified time occurs after or at the time of the last sample.

Parameters
[in]idThe id to estimate position for.
[in]errorAn estimate of the position tracking error, used to determine how many samples to include in the averaging.
[in]timeThe time to estimate the position for.
[out]samplesThe number of history samples used in the estimation.

◆ estimateVelocity()

Eigen::Vector3d gramods::gmMisc::EFFOAW::estimateVelocity ( size_t  id,
double  error,
size_t *  samples = nullptr 
) const

Estimate and return the velocity using samples associated to id.

The velocity will be expressed in chosen units per second.

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.
[out]samplesThe number of history samples used in the estimation.

◆ getHistoryDuration()

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

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

◆ getHistoryLength()

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

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

◆ getLastSampleTime()

double gramods::gmMisc::EFFOAW::getLastSampleTime ( size_t  id,
size_t  N = 0 
)

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

Parameters
[in]idThe id to read off the last sample for.
[in]NRead off the Nth last sample, 0 (default) being the last sample.

◆ removeLastSample()

void gramods::gmMisc::EFFOAW::removeLastSample ( size_t  id)

Remove the last sample for the specified id.

This will remove the last sample what was actually added to the id; it will not restore a sample that was overwritten by another with the same time.

Parameters
[in]idThe id to remove the last sample for.

◆ setHistoryDuration()

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

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

◆ setHistoryLength()

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

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


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