aboutsummaryrefslogtreecommitdiff
path: root/zumo/pid.h
diff options
context:
space:
mode:
Diffstat (limited to 'zumo/pid.h')
-rw-r--r--zumo/pid.h20
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);
+