|
gramods
|
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. | |
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.
| typedef Eigen::Matrix<double, 3, Eigen::Dynamic> gramods::gmMisc::EFHOAW::polco |
Matrix holding the polynomial coefficients, one row for each dimension.
| gramods::gmMisc::EFHOAW::EFHOAW | ( | ) |
Creates a new end-fitting first-order adaptive window estimator using the default parameters.
| 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.
| [in] | id | The id to add position sample to. |
| [in] | position | The position value to use as sample. |
| [in] | time | The time at which the sample was taken. |
| [in] | replace | If true (default), old samples with the same time will be replaced with this new sample value. |
| 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.
| time | The current time, to use when estimating if samples are too old, or -1 to use the samples' time. |
| 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.
| [in] | id | The id to estimate velocity for. |
| [in] | error | An estimate of the position tracking error, used to determine how many samples to include in the averaging. |
| [in] | order | The order of estimation |
| [out] | samples | The number of history samples used in the estimation. |
| double gramods::gmMisc::EFHOAW::getHistoryDuration | ( | ) | const |
Get how old samples are saved to be used when estimating the velocity.
| size_t gramods::gmMisc::EFHOAW::getHistoryLength | ( | ) | const |
Get the number of samples that are saved to be used when estimating the velocity.
| 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.
| 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.
| 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.
| 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.
| 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.