|
TR-mbed 1.0
|
#include <PID.h>
Public Member Functions | |
| PID () | |
| PID (float kP, float kI, float kD, float integralCap=0, float outputCap=0) | |
| void | setPID (float p, float i, float d, float integralCap=0, float outputCap=0) |
| void | resetPID (float kP, float kI, float kD, float integralCap=0, float outputCap=0) |
| void | resetErrorIntegral () |
| int | calculate (int desired, int current, double dt) |
| int | calculatePeriodic (float error, double dt) |
| void | limitOutput (double &PIDCalc) const |
| double | limitErrorDerivative (double dTerm) |
| void | limitErrorIntegral () |
| void | setDerivativeCap (float derivativeCap) |
| void | setIntegralCap (float integralCap) |
| void | setOutputCap (float outCap) |
Public Attributes | |
| float | feedForward = 0 |
| float | pC |
| float | iC |
| float | dC = 0 |
| lastfew | dBuffer |
The PID class is used to implement PID (proportional, integral, derivative) control of a motor. It is used by almost every motor on the robot, and supports both position and velocity control.
| PID::PID | ( | ) |
Creates a new PID object with the default control parameters
| PID::PID | ( | float | kP, |
| float | kI, | ||
| float | kD, | ||
| float | integralCap = 0, |
||
| float | outputCap = 0 |
||
| ) |
Creates a new PID object with the given control parameters
| kP | The P (proportional) parameter |
| kI | The I (integral) parameter |
| kD | The D (derivative) parameter |
| integralCAp | The maximum integral that can be achieved, above which the integral will be capped |
| outputCap | The maximum output of the PID, above which the output will be capped |
Calculates an output power based on the current and desired measurement (speed/position)
| desired | The desired speed/position |
| current | The current speed/position |
| dt | The time that has passed since the last calculation, in milliseconds |
| int PID::calculatePeriodic | ( | float | error, |
| double | dt | ||
| ) |
| double PID::limitErrorDerivative | ( | double | dTerm | ) |
| void PID::limitErrorIntegral | ( | ) |
| void PID::limitOutput | ( | double & | PIDCalc | ) | const |
| void PID::resetErrorIntegral | ( | ) |
| void PID::resetPID | ( | float | kP, |
| float | kI, | ||
| float | kD, | ||
| float | integralCap = 0, |
||
| float | outputCap = 0 |
||
| ) |
| void PID::setDerivativeCap | ( | float | derivativeCap | ) |
Sets the integral cap
| derivativeCap | The new integral cap |
| void PID::setIntegralCap | ( | float | integralCap | ) |
Sets the integral cap
| integralCap | The new integral cap |
| void PID::setOutputCap | ( | float | outCap | ) |
Sets the output cap
| outCap | The new output cap |
| void PID::setPID | ( | float | p, |
| float | i, | ||
| float | d, | ||
| float | integralCap = 0, |
||
| float | outputCap = 0 |
||
| ) |
Sets the P, I, and D control parameters
| p | The new P (proportional) parameter |
| i | The new I (integral) parameter |
| d | The new D (derivative) parameter |
| lastfew PID::dBuffer |
| float PID::dC = 0 |
| float PID::feedForward = 0 |
| float PID::iC |
| float PID::pC |