PID and PD controller classes for godot
A PID controller is a feedback control algorithm that continuously calculates and adjusts the control output based on the error between the desired setpoint and the measured process variable. It consists of three components:
Proportional (P) term: Produces an output proportional to the current error. Integral (I) term: Integrates the error over time to eliminate steady-state errors. Derivative (D) term: Predicts the future trend of the error based on its rate of change.
- Copy pd_controller.gd and/or pid_controller.gd to your project addons/godot-pid-controller folder
- setup your process loop:
var my_pid = PIDController.new()
...
func _process(delta):
my_pid.setpoint = desired_target_value
my_actual_value -= my_pid.step(my_actual_value, delta)
- Tune your pid controller Ki, Kp and Kd values for your case
Check out : https://github.com/TD-Dan/godot-pid-controller-examples