Class Pid
Defined in File pid.h
Class Documentation
-
class Pid
This class provides a simple PID controller implementation.
Public Functions
-
inline Pid(int kp, int kd, int ki, int ko, int output_min, int output_max)
Constructs a new PID object.
- Parameters:
kp – Tuning proportional gain.
kd – Tuning derivative gain.
ki – Tuning integral gain.
ko – Tuning output gain.
output_min – Output minimum limit.
output_max – Output maximum limit.
-
void reset(int encoder_count)
Resets the PID controller.
- Parameters:
encoder_count – Current encoder value.
-
bool enabled()
Returns if the PID controller is enabled or not.
-
void enable()
Enables the PID controller.
-
void disable()
Disables the PID controller.
-
void compute(int encoder_count, int &computed_output)
Computes a new output.
- Parameters:
encoder_count – Current encoder value.
computed_output – Computed output value.
-
void set_setpoint(int setpoint)
Sets the setpoint.
- Parameters:
setpoint – Desired setpoint value.
-
void set_tunings(int kp, int kd, int ki, int ko)
Sets the tuning gains.
- Parameters:
kp – Tuning proportional gain.
kd – Tuning derivative gain.
ki – Tuning integral gain.
ko – Tuning output gain.
-
inline Pid(int kp, int kd, int ki, int ko, int output_min, int output_max)