#include <arpirobot/core/action/PID.hpp>
Implementation of a simple PID controller with feedforward gain support.
◆ PID()
arpirobot::PID::PID |
( |
double |
kp = 0 , |
|
|
double |
ki = 0 , |
|
|
double |
kd = 0 , |
|
|
double |
kf = 0 , |
|
|
double |
min = -1.0 , |
|
|
double |
max = 1.0 |
|
) |
| |
Construct a new PID object
- Parameters
-
kp | Proportional gain |
ki | Integral gain |
kd | Derivative gain |
kf | Feedforward gain (often not used, but useful for some systems) |
min | Minimum value to cap PID output at |
max | Maximum value to cap PID output at |
◆ getKd()
double arpirobot::PID::getKd |
( |
| ) |
|
Get the derivitive gain
- Returns
- derivative gain (kd)
◆ getKf()
double arpirobot::PID::getKf |
( |
| ) |
|
Get the feedforward gain
- Returns
- feedforward gain (kf)
◆ getKi()
double arpirobot::PID::getKi |
( |
| ) |
|
Get the integral gain
- Returns
- integral gain (ki)
◆ getKp()
double arpirobot::PID::getKp |
( |
| ) |
|
Get the proportional gain
- Returns
- proportional gain (kp)
◆ getMax()
double arpirobot::PID::getMax |
( |
| ) |
|
Get the maximum allowed PID output
- Returns
- max allowed PID output
◆ getMin()
double arpirobot::PID::getMin |
( |
| ) |
|
Get the minimum allowed PID output
- Returns
- min allowed PID output
◆ getOutput()
double arpirobot::PID::getOutput |
( |
double |
currentPv | ) |
|
Calculate the current output of the PID controller.
- Parameters
-
currentPv | Current value of the process variable. |
- Returns
- The PID controller's output, capped at the set min and max values
◆ getSetpoint()
double arpirobot::PID::getSetpoint |
( |
| ) |
|
Get the controller's current setpoint
- Returns
- Current setpoint
◆ reset()
void arpirobot::PID::reset |
( |
| ) |
|
Reset the PID controller's internal state. This resets the accumulated integral value and the previous error used by the derivative gain.
◆ setKd()
void arpirobot::PID::setKd |
( |
double |
kd | ) |
|
Set the derivative gain
- Parameters
-
◆ setKf()
void arpirobot::PID::setKf |
( |
double |
kf | ) |
|
Set the feedforward gain
- Parameters
-
◆ setKi()
void arpirobot::PID::setKi |
( |
double |
ki | ) |
|
Set the integral gain (ki)
- Parameters
-
◆ setKp()
void arpirobot::PID::setKp |
( |
double |
kp | ) |
|
Set the proportional gain (kp)
- Parameters
-
◆ setMax()
void arpirobot::PID::setMax |
( |
double |
max | ) |
|
Set the maximum allowed PID output
- Parameters
-
max | New max allowed PID output |
◆ setMin()
void arpirobot::PID::setMin |
( |
double |
min | ) |
|
Set the minimum allowed PID output
- Parameters
-
min | New min allowed PID output |
◆ setSetpoint()
void arpirobot::PID::setSetpoint |
( |
double |
setpoint | ) |
|
Set the controller's setpoint
- Parameters
-
setpoint | New setpoint for the controller |
The documentation for this class was generated from the following file:
- include/arpirobot/core/control/PID.hpp