48 MiniPID(
double p,
double i,
double d,
double f);
90 void setPID(
double p,
double i,
double d);
98 void setPID(
double p,
double i,
double d,
double f);
183 double clamp(
double value,
double min,
double max);
191 bool bounded(
double value,
double min,
double max);
void checkSigns()
Ensures all PID parameters have the correct sign.
void setF(double f)
Sets the feed-forward gain coefficient.
void setD(double d)
Sets the derivative gain coefficient.
void setP(double p)
Sets the proportional gain coefficient.
double maxError
Maximum error value used for I term calculation.
Definition pid.h:217
void setOutputLimits(double output)
Sets symmetric output limits (from -output to +output)
double outputRampRate
Maximum rate the output can increase per cycle.
Definition pid.h:241
double lastOutput
Last calculated output value.
Definition pid.h:244
void setI(double i)
Sets the integral gain coefficient.
double lastActual
Last measured input value (used for D term)
Definition pid.h:232
double getOutput(double actual, double setpoint)
Calculates the PID output for new actual and setpoint values.
MiniPID(double p, double i, double d, double f)
Constructor with P, I, D, and F parameters.
double getOutput(double actual)
Calculates the PID output for a new actual value and the stored setpoint.
double F
Feed-forward gain coefficient.
Definition pid.h:211
void reset()
Resets the controller state.
void setPID(double p, double i, double d, double f)
Sets all four PID parameters including feed-forward at once.
double outputFilter
Output filter strength (0-1)
Definition pid.h:247
void init()
Initializes controller parameters to default values.
double D
Derivative gain coefficient.
Definition pid.h:208
void setPID(double p, double i, double d)
Sets all three standard PID parameters at once.
MiniPID(double p, double i, double d)
Constructor with P, I, and D parameters.
bool firstRun
Flag indicating if this is the first execution.
Definition pid.h:235
double P
Proportional gain coefficient.
Definition pid.h:202
double minOutput
Minimum allowed output value.
Definition pid.h:226
void setDirection(bool reversed)
Sets the direction of the PID controller.
double clamp(double value, double min, double max)
Clamps a value between minimum and maximum bounds.
bool bounded(double value, double min, double max)
Checks if a value is within bounds (exclusive)
double getOutput()
Calculates the PID output using the last provided setpoint and actual values.
void setSetpoint(double setpoint)
Sets the target setpoint for the PID calculations.
void setOutputRampRate(double rate)
Sets the maximum rate the output can increase per cycle.
void setOutputLimits(double minimum, double maximum)
Sets asymmetric output limits.
double setpointRange
Maximum allowed setpoint distance from the current position.
Definition pid.h:250
void setMaxIOutput(double maximum)
Sets the maximum output value contributed by the I component.
double setpoint
Target setpoint value.
Definition pid.h:229
bool reversed
Flag indicating if the controller direction is reversed.
Definition pid.h:238
double maxIOutput
Maximum output value contributed by the I component.
Definition pid.h:214
double maxOutput
Maximum allowed output value.
Definition pid.h:223
double errorSum
Sum of errors for the I term.
Definition pid.h:220
double I
Integral gain coefficient.
Definition pid.h:205
void setSetpointRange(double range)
Sets a limit on how far the setpoint can be from the current position.
void setOutputFilter(double strength)
Sets a filter on the output to reduce sharp oscillations.
T maximum(T x, T y)
Returns what ever is greater, x or y of type T.
Definition fsUtil.h:130
T minimum(T x, T y)
Returns the which ever is lesser, x or y of type T.
Definition fsUtil.h:137
Defines export macros for the VREngage Utility library.
#define UTIL_DLL
Export/import macro for non-Windows platforms.
Definition export.h:39
Include export definitions for this library.
Definition glsVreMessageUtil.h:49