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

D Controller. More...

#include <math.hpp>

Public Member Functions

 DerivativeController (double kD, std::shared_ptr< double > error, double motorGearing=200)
 Creates a D controller for a V5 motor. More...
 
double update ()
 Calculates controller output based on the current error value. More...
 
double getkD () const
 Gets the kD constant. More...
 
double getOutput () const
 Gets the current stored output value without calculating a new value. More...
 
double getCurrentTime () const
 Gets the current time the controller is using. More...
 
uint32_t getdT () const
 Gets the most recent time difference between updates. More...
 
void setkD (double gain)
 Sets the kD constant. More...
 
double operator* ()
 Operator overload for getting the current filter ouput. More...
 

Detailed Description

D Controller.

Constructor & Destructor Documentation

◆ DerivativeController()

sylib::DerivativeController::DerivativeController ( double  kD,
std::shared_ptr< double >  error,
double  motorGearing = 200 
)

Creates a D controller for a V5 motor.

Parameters
kDDerivative gain
errorA pointer to a double containing the error value to use for calculations
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

◆ getCurrentTime()

double sylib::DerivativeController::getCurrentTime ( ) const

Gets the current time the controller is using.

Returns
Time in milliseconds

◆ getdT()

uint32_t sylib::DerivativeController::getdT ( ) const

Gets the most recent time difference between updates.

Returns
Time in milliseconds

◆ getkD()

double sylib::DerivativeController::getkD ( ) const

Gets the kD constant.

Returns
kD value

◆ getOutput()

double sylib::DerivativeController::getOutput ( ) const

Gets the current stored output value without calculating a new value.

Returns
Controller output

◆ operator*()

double sylib::DerivativeController::operator* ( )

Operator overload for getting the current filter ouput.

Returns
Controller output

◆ setkD()

void sylib::DerivativeController::setkD ( double  gain)

Sets the kD constant.

Parameters
gainDerivative gain

◆ update()

double sylib::DerivativeController::update ( )

Calculates controller output based on the current error value.

Returns
Controller output