|
Sylib
A C++ Library For V5
|
P Controller. More...
#include <math.hpp>
Public Member Functions | |
| ProportionalController (double kP, std::shared_ptr< double > error, double motorGearing=200, bool maxRangeEnabled=false, double kP2=0, double maxRange=0) | |
| Creates a P controller for a V5 motor. More... | |
| double | update () |
| Calculates controller output based on the current error value. More... | |
| double | getkP () const |
| Gets the kP constant. More... | |
| double | getOutput () const |
| Gets the current stored output value without calculating a new value. More... | |
| void | setkP (double gain) |
| Sets the kP constant. More... | |
| double | operator* () |
| Operator overload for getting the current filter ouput. More... | |
| void | setMaxRangeEnabled (bool enabled) |
| Sets whether the maxRangeEnabled flag is on or off. More... | |
| void | setMaxRange (double range) |
| Sets the error range from the target value that is used for switching between kP and kP2. More... | |
| void | setkP2 (double gain) |
| Sets the secondary kP constant. More... | |
P Controller.
| sylib::ProportionalController::ProportionalController | ( | double | kP, |
| std::shared_ptr< double > | error, | ||
| double | motorGearing = 200, |
||
| bool | maxRangeEnabled = false, |
||
| double | kP2 = 0, |
||
| double | maxRange = 0 |
||
| ) |
Creates a P controller for a V5 motor.
| kP | Proportional 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 |
| maxRangeEnabled | A flag that when true shifts the P controller to using kP2 as the kP constant when error is less than <maxRange> |
| kP2 | The secondary kP value that is used when maxRangeEnabled is on and the error is within maxRange |
| maxRange | Error range from the target value that is used for switching between kP and kP2 |
| double sylib::ProportionalController::getkP | ( | ) | const |
Gets the kP constant.
| double sylib::ProportionalController::getOutput | ( | ) | const |
Gets the current stored output value without calculating a new value.
| double sylib::ProportionalController::operator* | ( | ) |
Operator overload for getting the current filter ouput.
| void sylib::ProportionalController::setkP | ( | double | gain | ) |
Sets the kP constant.
| gain | Proportional gain |
| void sylib::ProportionalController::setkP2 | ( | double | gain | ) |
Sets the secondary kP constant.
| gain | Proportional gain |
| void sylib::ProportionalController::setMaxRange | ( | double | range | ) |
Sets the error range from the target value that is used for switching between kP and kP2.
| range | Max error value |
| void sylib::ProportionalController::setMaxRangeEnabled | ( | bool | enabled | ) |
Sets whether the maxRangeEnabled flag is on or off.
| enabled | Flag value |
| double sylib::ProportionalController::update | ( | ) |
Calculates controller output based on the current error value.