LemLib  0.4.7
An easy to use and feature-rich PROS template
Loading...
Searching...
No Matches
lemlib::FAPID Class Reference

Feedforward, Acceleration, Proportional, Integral, Derivative PID controller. More...

#include <pid.hpp>

Public Member Functions

 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...
 

Static Public Member Functions

static void init ()
 initialize the FAPID logging system More...
 

Detailed Description

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); }

Constructor & Destructor Documentation

◆ FAPID()

lemlib::FAPID::FAPID ( float  kF,
float  kA,
float  kP,
float  kI,
float  kD,
std::string  name 
)

Construct a new FAPID.

Parameters
kFfeedfoward gain, multiplied by target and added to output. Set 0 if disabled
kAacceleration gain, limits the change in output. Set 0 if disabled
kPproportional gain, multiplied by error and added to output
kIintegral gain, multiplied by total error and added to output
kDderivative gain, multiplied by change in error and added to output
namename of the FAPID. Used for logging

Member Function Documentation

◆ 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
largeErrorrange where error is considered large
smallErrorrange where error is considered small
largeTimetime in milliseconds t
smallTime
maxTime

◆ setGains()

void lemlib::FAPID::setGains ( float  kF,
float  kA,
float  kP,
float  kI,
float  kD 
)

Set gains.

Parameters
kFfeedfoward gain, multiplied by target and added to output. Set 0 if disabled
kAacceleration gain, limits the change in output. Set 0 if disabled
kPproportional gain, multiplied by error and added to output
kIintegral gain, multiplied by total error and added to output
kDderivative 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
targetthe target value
positionthe current value
logwhether 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: