Sylib
A C++ Library For V5
|
Accurate Motor Velocity Estimator. More...
#include <motor.hpp>
Public Member Functions | |
SylviesPogVelocityEstimator (double motorGearing=200) | |
Creates a velocity estimator for a smart motor. More... | |
double | getVelocity (double currentMotorTicks, std::uint32_t currentInternalMotorClock) |
Calculates motor velocity. More... | |
double | getVelocityNoCalculations () const |
Gets the most recent calculated motor velocity. More... | |
double | getRawVelocity () const |
Gets the raw motor velocity. More... | |
double | getRawPosition () const |
Gets the most recent user-provided motor position. More... | |
double | getSmaFilteredVelocity () const |
Gets the motor velocity put through a 3-tap simple moving average. More... | |
double | getEmaFilteredVelocity () const |
Gets the motor velocity put through a an exponential moving average filter. More... | |
double | getMedianFilteredVelocity () const |
Gets the motor velocity put through a median filter. More... | |
double | getAcceleration () const |
Gets the motor acceleration. More... | |
double | getPreFilterAcceleration () const |
Gets the raw motor acceleration based on a partially filtered velocity calculation. More... | |
double | getJerk () const |
Gets the motor jerk. More... | |
double | getSnap () const |
Gets the motor snap. More... | |
double | getCalculatedkA () const |
Gets the current value of the variable gain used for the velocity EMA filter. More... | |
double | getMaxFilteredAcceleration () const |
Gets the absolute value of the largest or smallest acceleration measurement in the last 200ms. More... | |
Accurate Motor Velocity Estimator.
sylib::SylviesPogVelocityEstimator::SylviesPogVelocityEstimator | ( | double | motorGearing = 200 | ) |
Creates a velocity estimator for a smart motor.
motorGearing | The output speed of the motor, in RPM, if the motor internally is spinning at 3600 RPM. 200 is default for a green motor cartridge |
double sylib::SylviesPogVelocityEstimator::getAcceleration | ( | ) | const |
Gets the motor acceleration.
This value is a second derivative of any actual measurement. It will not be very accurate.
double sylib::SylviesPogVelocityEstimator::getCalculatedkA | ( | ) | const |
Gets the current value of the variable gain used for the velocity EMA filter.
double sylib::SylviesPogVelocityEstimator::getEmaFilteredVelocity | ( | ) | const |
Gets the motor velocity put through a an exponential moving average filter.
This value is the same as the estimator's output velocity, but without the motor gearset translation.
double sylib::SylviesPogVelocityEstimator::getJerk | ( | ) | const |
Gets the motor jerk.
This value is a third derivative of any actual measurement. It will not be very accurate.
double sylib::SylviesPogVelocityEstimator::getMaxFilteredAcceleration | ( | ) | const |
Gets the absolute value of the largest or smallest acceleration measurement in the last 200ms.
This value is a second derivative of any actual measurement. It will not be very accurate.
double sylib::SylviesPogVelocityEstimator::getMedianFilteredVelocity | ( | ) | const |
Gets the motor velocity put through a median filter.
This value is partially filtered, and will be of limitied use.
double sylib::SylviesPogVelocityEstimator::getPreFilterAcceleration | ( | ) | const |
Gets the raw motor acceleration based on a partially filtered velocity calculation.
This value is a second derivative of any actual measurement. It will not be very accurate.
double sylib::SylviesPogVelocityEstimator::getRawPosition | ( | ) | const |
Gets the most recent user-provided motor position.
double sylib::SylviesPogVelocityEstimator::getRawVelocity | ( | ) | const |
Gets the raw motor velocity.
This value is not filtered, and will be of limitied use. It is purely difference in ticks divided by difference in time.
double sylib::SylviesPogVelocityEstimator::getSmaFilteredVelocity | ( | ) | const |
Gets the motor velocity put through a 3-tap simple moving average.
This value is partially filtered, and will be of limitied use.
double sylib::SylviesPogVelocityEstimator::getSnap | ( | ) | const |
Gets the motor snap.
This value is a fourth derivative of any actual measurement. It will not be very accurate.
double sylib::SylviesPogVelocityEstimator::getVelocity | ( | double | currentMotorTicks, |
std::uint32_t | currentInternalMotorClock | ||
) |
Calculates motor velocity.
currentMotorTicks | The current number of raw encoder ticks the motor has recorded |
double sylib::SylviesPogVelocityEstimator::getVelocityNoCalculations | ( | ) | const |
Gets the most recent calculated motor velocity.