Feedforward, Acceleration, Proportional, Integral, Derivative PID controller.
More...
#include <pid.hpp>
|
| FAPID (float kF, float kA, float kP, float kI, float kD, std::string name) |
| Construct a new FAPID. More...
|
|
void | setGains (float kF, float kA, float kP, float kI, float kD) |
| Set gains. More...
|
|
void | setExit (float largeError, float smallError, int largeTime, int smallTime, int maxTime) |
| Set the exit conditions. More...
|
|
float | update (float target, float position, bool log=false) |
| Update the FAPID. More...
|
|
void | reset () |
| Reset the FAPID.
|
|
bool | settled () |
| Check if the FAPID has settled. More...
|
|
Feedforward, Acceleration, Proportional, Integral, Derivative PID controller.
The controller does not loop on its own. It must be called in a loop. For example: while(!controller.settled) { controller.update(input, output); }
◆ FAPID()
lemlib::FAPID::FAPID |
( |
float |
kF, |
|
|
float |
kA, |
|
|
float |
kP, |
|
|
float |
kI, |
|
|
float |
kD, |
|
|
std::string |
name |
|
) |
| |
Construct a new FAPID.
- Parameters
-
kF | feedfoward gain, multiplied by target and added to output. Set 0 if disabled |
kA | acceleration gain, limits the change in output. Set 0 if disabled |
kP | proportional gain, multiplied by error and added to output |
kI | integral gain, multiplied by total error and added to output |
kD | derivative gain, multiplied by change in error and added to output |
name | name of the FAPID. Used for logging |
◆ init()
static void lemlib::FAPID::init |
( |
| ) |
|
|
static |
initialize the FAPID logging system
if this function is called, std::cin will be used to interact with the FAPID
the user can interact with the FAPID through the terminal the user can access gains and other variables with the following format: <name>.<variable> to get the value of the variable <name>.<variable>_<value> to set the value of the variable for example: pid.kP_0.5 will set the kP value to 0.5 list of variables thats value can be set: kF, kA, kP, kI, kD list of variables that can be accessed: kF, kA, kP, kI, kD, totalError list of functions that can be called: reset()
◆ setExit()
void lemlib::FAPID::setExit |
( |
float |
largeError, |
|
|
float |
smallError, |
|
|
int |
largeTime, |
|
|
int |
smallTime, |
|
|
int |
maxTime |
|
) |
| |
Set the exit conditions.
- Parameters
-
largeError | range where error is considered large |
smallError | range where error is considered small |
largeTime | time in milliseconds t |
smallTime | |
maxTime | |
◆ setGains()
void lemlib::FAPID::setGains |
( |
float |
kF, |
|
|
float |
kA, |
|
|
float |
kP, |
|
|
float |
kI, |
|
|
float |
kD |
|
) |
| |
Set gains.
- Parameters
-
kF | feedfoward gain, multiplied by target and added to output. Set 0 if disabled |
kA | acceleration gain, limits the change in output. Set 0 if disabled |
kP | proportional gain, multiplied by error and added to output |
kI | integral gain, multiplied by total error and added to output |
kD | derivative gain, multiplied by change in error and added to output |
◆ settled()
bool lemlib::FAPID::settled |
( |
| ) |
|
Check if the FAPID has settled.
If the exit conditions have not been set, this function will always return false
- Returns
- true - the FAPID has settled
-
false - the FAPID has not settled
◆ update()
float lemlib::FAPID::update |
( |
float |
target, |
|
|
float |
position, |
|
|
bool |
log = false |
|
) |
| |
Update the FAPID.
- Parameters
-
target | the target value |
position | the current value |
log | whether to check the most recent terminal input for user input. Default is false because logging multiple PIDs could slow down the program. |
- Returns
- float - output
The documentation for this class was generated from the following file: