aboutsummaryrefslogtreecommitdiff
path: root/zumo/pid.h
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-05-19 13:34:31 +0200
committerlonkaars <loek@pipeframe.xyz>2023-05-19 13:34:31 +0200
commitff7a914055cf851c994ee037342a331902f84a0c (patch)
tree790f9398aa23bb526f93787bb3af73a426877e76 /zumo/pid.h
parent2ed0ea4f12a5532092428f57e040f2cefb5fb973 (diff)
add pidtest
Diffstat (limited to 'zumo/pid.h')
-rw-r--r--zumo/pid.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/zumo/pid.h b/zumo/pid.h
index 2cdbc91..fbcd063 100644
--- a/zumo/pid.h
+++ b/zumo/pid.h
@@ -2,6 +2,19 @@
#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);