Simple implementation of a PID controller.
More...
#include <PID.h>
Inherited by ProfiledPID.
|
| PID (double p_gain, double i_gain, double d_gain, double ff_gain=1.0, double i_decay=0.5, bool feedforward=true, double filterFreq=7.0) |
| Constructs a PID controller. All gains are in constant (not timebase) form.
|
|
| PID () |
| Constructs a PID controller with no gains set.
|
|
void | setParameters (double p_gain, double i_gain, double d_gain, double ff_gain=1.0, double i_decay=0.87, bool feedforward=true, double filterFreq=7.0) |
| Sets PID parameters. All gains are in constant (not timebase) form.
|
|
virtual double | update (double dt) |
| updates the PID controller, call on each loop
|
|
void | setInput (double input) |
| sets the feedback input
|
|
virtual void | setSetpoint (double setpoint) |
| sets the setpoint
|
|
double | getOutput () |
| gets the PID output
|
|
double | getProportionalGain () |
| Gets the p gain.
|
|
double | getIntegralGain () |
| Gets the i gain.
|
|
double | getDerivativeGain () |
| Gets the d gain.
|
|
double | getFeedForwardGain () |
| Gets the feed forward gain.
|
|
double | getIntegralDecay () |
| Gets the integral decay rate.
|
|
double | getInput () |
| Gets the input value.
|
|
double | getSetpoint () |
| Gets the setpoint value.
|
|
double | getError () |
| Gets the error value.
|
|
double | getAccumulatedError () |
| Gets the accumulated m_is_running sum.
|
|
double | getPreviousError () |
| Gets the previous error (one iteration ago)
|
|
bool | isFeedForward () |
| m_status flag for feed-forward PID
|
|
void | reset () |
| Resets PID setpoint, input, error, accumulated error, differential, and output.
|
|
void | disablePID () |
| Disables PID – output returns setpoint.
|
|
void | enablePID () |
| Enables PID.
|
|
void | setIIREnabled (bool enabled) |
| Enables an IIR filter on output.
|
|
void | setIIRDecay (double decay) |
| Sets the IFR Decay rate.
|
|
Simple implementation of a PID controller.
- Author
- Robert Ying
-
Brian Axelrod
PID::PID |
( |
double |
p_gain, |
|
|
double |
i_gain, |
|
|
double |
d_gain, |
|
|
double |
ff_gain = 1.0 , |
|
|
double |
i_decay = 0.5 , |
|
|
bool |
feedforward = true , |
|
|
double |
filterFreq = 7.0 |
|
) |
| |
Constructs a PID controller. All gains are in constant (not timebase) form.
- Parameters
-
p_gain | proportional gain |
i_gain | integral gain |
d_gain | derivative gain |
ff_gain | feedforward gain (defaults to 1.0) |
i_decay | integral decay (defaults to 0.5) |
feedforward | whether or not feedforward is used |
double PID::getAccumulatedError |
( |
| ) |
|
Gets the accumulated m_is_running sum.
- Returns
- m_is_running sum
double PID::getDerivativeGain |
( |
| ) |
|
Gets the d gain.
- Returns
- derivative PID gain
Gets the error value.
- Returns
- error
double PID::getFeedForwardGain |
( |
| ) |
|
Gets the feed forward gain.
- Returns
- feed forward gain
Gets the input value.
- Returns
- input
double PID::getIntegralDecay |
( |
| ) |
|
Gets the integral decay rate.
- Returns
- integral decay rate
double PID::getIntegralGain |
( |
| ) |
|
Gets the i gain.
- Returns
- integral PID gain
double PID::getOutput |
( |
| ) |
|
gets the PID output
- Returns
- PID output
double PID::getPreviousError |
( |
| ) |
|
Gets the previous error (one iteration ago)
- Returns
- previous error
double PID::getProportionalGain |
( |
| ) |
|
Gets the p gain.
- Returns
- proportional PID gain
double PID::getSetpoint |
( |
| ) |
|
Gets the setpoint value.
- Returns
- setpoint
bool PID::isFeedForward |
( |
| ) |
|
m_status flag for feed-forward PID
- Returns
- whether this controller uses feedforward PID
void PID::setInput |
( |
double |
input | ) |
|
sets the feedback input
- Parameters
-
void PID::setParameters |
( |
double |
p_gain, |
|
|
double |
i_gain, |
|
|
double |
d_gain, |
|
|
double |
ff_gain = 1.0 , |
|
|
double |
i_decay = 0.87 , |
|
|
bool |
feedforward = true , |
|
|
double |
filterFreq = 7.0 |
|
) |
| |
Sets PID parameters. All gains are in constant (not timebase) form.
This method does reset accumulated error and differential error
- Parameters
-
p_gain | proportional gain |
i_gain | integral gain |
d_gain | derivative gain |
ff_gain | feedforward gain (defaults to 1.0) |
i_decay | integral decay (defaults to 0.5) |
feedforward | whether or not feedforward is used |
void PID::setSetpoint |
( |
double |
setpoint | ) |
|
|
virtual |
sets the setpoint
- Parameters
-
double PID::update |
( |
double |
dt | ) |
|
|
virtual |
updates the PID controller, call on each loop
- Parameters
-
- Returns
- pid output
The documentation for this class was generated from the following files:
- Utils/PID.h
- Utils/PID.cpp