LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
okapi::VelMath Class Reference

#include <velMath.hpp>

Public Member Functions

 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.
 
virtual ~VelMath ()
 
virtual QAngularSpeed step (double inewPos)
 Calculates the current velocity and acceleration.
 
virtual void setTicksPerRev (double iTPR)
 Sets ticks per revolution (or whatever units you are using).
 
virtual QAngularSpeed getVelocity () const
 
virtual QAngularAcceleration getAccel () const
 

Protected Attributes

std::shared_ptr< Loggerlogger
 
QAngularSpeed vel {0_rpm}
 
QAngularSpeed lastVel {0_rpm}
 
QAngularAcceleration accel {0.0}
 
double lastPos {0}
 
double ticksPerRev
 
QTime sampleTime
 
std::unique_ptr< AbstractTimerloopDtTimer
 
std::unique_ptr< Filterfilter
 

Detailed Description

Definition at line 17 of file velMath.hpp.

Constructor & Destructor Documentation

◆ VelMath()

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.

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

Parameters
iticksPerRevThe number of ticks per revolution (or whatever units you are using).
ifilterThe filter used for filtering the calculated velocity.
isampleTimeThe minimum time between velocity measurements.
iloggerThe logger this instance will log to.

◆ ~VelMath()

virtual okapi::VelMath::~VelMath ( )
virtual

Member Function Documentation

◆ getAccel()

virtual QAngularAcceleration okapi::VelMath::getAccel ( ) const
virtual
Returns
The last calculated acceleration.

◆ getVelocity()

virtual QAngularSpeed okapi::VelMath::getVelocity ( ) const
virtual
Returns
The last calculated velocity.

◆ setTicksPerRev()

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

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

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

Parameters
iTPRThe number of ticks per revolution.

◆ step()

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

Calculates the current velocity and acceleration.

Returns the (filtered) velocity.

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

Member Data Documentation

◆ accel

QAngularAcceleration okapi::VelMath::accel {0.0}
protected

Definition at line 66 of file velMath.hpp.

◆ filter

std::unique_ptr<Filter> okapi::VelMath::filter
protected

Definition at line 72 of file velMath.hpp.

◆ lastPos

double okapi::VelMath::lastPos {0}
protected

Definition at line 67 of file velMath.hpp.

◆ lastVel

QAngularSpeed okapi::VelMath::lastVel {0_rpm}
protected

Definition at line 65 of file velMath.hpp.

◆ logger

std::shared_ptr<Logger> okapi::VelMath::logger
protected

Definition at line 63 of file velMath.hpp.

◆ loopDtTimer

std::unique_ptr<AbstractTimer> okapi::VelMath::loopDtTimer
protected

Definition at line 71 of file velMath.hpp.

◆ sampleTime

QTime okapi::VelMath::sampleTime
protected

Definition at line 70 of file velMath.hpp.

◆ ticksPerRev

double okapi::VelMath::ticksPerRev
protected

Definition at line 68 of file velMath.hpp.

◆ vel

QAngularSpeed okapi::VelMath::vel {0_rpm}
protected

Definition at line 64 of file velMath.hpp.


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