Sylib
A C++ Library For V5
Loading...
Searching...
No Matches
sylib::SylviesPogVelocityEstimator Class Reference

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...
 

Detailed Description

Accurate Motor Velocity Estimator.

Constructor & Destructor Documentation

◆ SylviesPogVelocityEstimator()

sylib::SylviesPogVelocityEstimator::SylviesPogVelocityEstimator ( double  motorGearing = 200)

Creates a velocity estimator for a smart motor.

Parameters
motorGearingThe output speed of the motor, in RPM, if the motor internally is spinning at 3600 RPM. 200 is default for a green motor cartridge

Member Function Documentation

◆ getAcceleration()

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.

Returns
RPM per millisecond

◆ getCalculatedkA()

double sylib::SylviesPogVelocityEstimator::getCalculatedkA ( ) const

Gets the current value of the variable gain used for the velocity EMA filter.

Returns
kA value

◆ getEmaFilteredVelocity()

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.

Returns
Velocity in RPM out of 3600

◆ getJerk()

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.

Returns
RPM per millisecond per millisecond

◆ getMaxFilteredAcceleration()

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.

Returns
RPM per millisecond

◆ getMedianFilteredVelocity()

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.

Returns
Velocity in RPM out of 3600

◆ getPreFilterAcceleration()

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.

Returns
RPM per millisecond

◆ getRawPosition()

double sylib::SylviesPogVelocityEstimator::getRawPosition ( ) const

Gets the most recent user-provided motor position.

Returns
Ticks

◆ getRawVelocity()

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.

Returns
Velocity in RPM out of 3600

◆ getSmaFilteredVelocity()

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.

Returns
Velocity in RPM out of 3600

◆ getSnap()

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.

Returns
RPM per millisecond per millisecond per millisecond

◆ getVelocity()

double sylib::SylviesPogVelocityEstimator::getVelocity ( double  currentMotorTicks,
std::uint32_t  currentInternalMotorClock 
)

Calculates motor velocity.

Parameters
currentMotorTicksThe current number of raw encoder ticks the motor has recorded
Returns
Velocity in RPM

◆ getVelocityNoCalculations()

double sylib::SylviesPogVelocityEstimator::getVelocityNoCalculations ( ) const

Gets the most recent calculated motor velocity.

Returns
Velocity in RPM