diff options
Diffstat (limited to 'zumo/pid.h')
-rw-r--r-- | zumo/pid.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/zumo/pid.h b/zumo/pid.h new file mode 100644 index 0000000..fbcd063 --- /dev/null +++ b/zumo/pid.h @@ -0,0 +1,20 @@ +#pragma once + +#include "protocol.h" + +class PID { +private: + float A0, A1, A2; + float error[3] = {0}; + float dt = 0.010; + float output = 0; + +public: + PID(float P, float I, float D); + float iter(float target); + void reset(float value); +}; + +/** @brief edit `current` to be closer to `target` using PID controllers */ +void apply_pid(dui_state_t* target, dui_state_t* current); + |