okapi::VelMath class

Constructors, destructors, conversion operators

VelMath(double iticksPerRev, std::unique_ptr<Filter> ifilter, QTime isampleTime, std::unique_ptr<AbstractTimer> iloopDtTimer, std::shared_ptr<Logger> ilogger = Logger::getDefaultLogger())
Velocity math helper.
~VelMath() virtual

Public functions

auto step(double inewPos) -> QAngularSpeed virtual
Calculates the current velocity and acceleration.
void setTicksPerRev(double iTPR) virtual
Sets ticks per revolution (or whatever units you are using).
auto getVelocity() const -> QAngularSpeed virtual
auto getAccel() const -> QAngularAcceleration virtual

Protected variables

std::shared_ptr<Logger> logger
QAngularSpeed vel
QAngularSpeed lastVel
QAngularAcceleration accel
double lastPos
double ticksPerRev
QTime sampleTime
std::unique_ptr<AbstractTimer> loopDtTimer
std::unique_ptr<Filter> filter

Function documentation

okapi::VelMath::VelMath(double iticksPerRev, std::unique_ptr<Filter> ifilter, QTime isampleTime, std::unique_ptr<AbstractTimer> iloopDtTimer, std::shared_ptr<Logger> ilogger = Logger::getDefaultLogger())

Velocity math helper.

Parameters
iticksPerRev The number of ticks per revolution (or whatever units you are using).
ifilter The filter used for filtering the calculated velocity.
isampleTime The minimum time between velocity measurements.
iloopDtTimer
ilogger The logger this instance will log to.

Calculates filtered velocity. Throws a std::invalid_argument exception if iticksPerRev is zero.

QAngularSpeed okapi::VelMath::step(double inewPos) virtual

Calculates the current velocity and acceleration.

Parameters
inewPos The new position measurement.
Returns The new velocity estimate.

Returns the (filtered) velocity.

void okapi::VelMath::setTicksPerRev(double iTPR) virtual

Sets ticks per revolution (or whatever units you are using).

Parameters
iTPR The number of ticks per revolution.

Throws a std::invalid_argument exception if iticksPerRev is zero.

QAngularSpeed okapi::VelMath::getVelocity() const virtual

Returns The last calculated velocity.

QAngularAcceleration okapi::VelMath::getAccel() const virtual

Returns The last calculated acceleration.