Sylib
A C++ Library For V5
|
I Controller. More...
#include <math.hpp>
Public Member Functions | |
IntegralController (double kI, std::shared_ptr< double > error, double motorGearing=200, bool antiWindupEnabled=false, double antiWindupRange=0) | |
Creates an I controller for a V5 motor. More... | |
double | update () |
Calculates controller output based on the current error value. More... | |
double | getkI () const |
Gets the kI constant. More... | |
void | resetValue () |
Resets the integral value to 0. 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 | setkI (double gain) |
Sets the kI constant. More... | |
double | operator* () |
Operator overload for getting the current filter ouput. More... | |
void | setAntiWindupEnabled (bool enabled) |
Sets whether the antiWindupEnabled flag is on or off. More... | |
void | setAntiWindupRange (double range) |
Sets the error range from the target value that is used for anti-windup. More... | |
I Controller.
sylib::IntegralController::IntegralController | ( | double | kI, |
std::shared_ptr< double > | error, | ||
double | motorGearing = 200 , |
||
bool | antiWindupEnabled = false , |
||
double | antiWindupRange = 0 |
||
) |
Creates an I controller for a V5 motor.
kI | Integral gain |
error | A pointer to a double containing the error value to use for calculations |
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 |
antiWindupEnabled | A flag that when true enables anti-windup, setting the output value to 0 when error is more than <antiWindupRange> |
antiWindupRange | Error range from the target value that is used for anti-windup |
double sylib::IntegralController::getCurrentTime | ( | ) | const |
Gets the current time the controller is using.
uint32_t sylib::IntegralController::getdT | ( | ) | const |
Gets the most recent time difference between updates.
double sylib::IntegralController::getkI | ( | ) | const |
Gets the kI constant.
double sylib::IntegralController::getOutput | ( | ) | const |
Gets the current stored output value without calculating a new value.
double sylib::IntegralController::operator* | ( | ) |
Operator overload for getting the current filter ouput.
void sylib::IntegralController::resetValue | ( | ) |
Resets the integral value to 0.
void sylib::IntegralController::setAntiWindupEnabled | ( | bool | enabled | ) |
Sets whether the antiWindupEnabled flag is on or off.
enabled | Flag value |
void sylib::IntegralController::setAntiWindupRange | ( | double | range | ) |
Sets the error range from the target value that is used for anti-windup.
range | Max error value |
void sylib::IntegralController::setkI | ( | double | gain | ) |
Sets the kI constant.
gain | Integral gain |
double sylib::IntegralController::update | ( | ) |
Calculates controller output based on the current error value.