summaryrefslogtreecommitdiff
path: root/zumo/pidtest.cpp
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/pidtest.cpp
parent2ed0ea4f12a5532092428f57e040f2cefb5fb973 (diff)
add pidtest
Diffstat (limited to 'zumo/pidtest.cpp')
-rw-r--r--zumo/pidtest.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/zumo/pidtest.cpp b/zumo/pidtest.cpp
new file mode 100644
index 0000000..f5198bb
--- /dev/null
+++ b/zumo/pidtest.cpp
@@ -0,0 +1,35 @@
+#include <cstdio>
+#include <random>
+
+#include "pid.h"
+
+std::random_device rd;
+std::mt19937 rng(rd());
+std::uniform_real_distribution<float> uni(0,13);
+
+auto random_integer = uni(rng);
+
+int main() {
+ float P, I, D;
+ do {
+ // P = uni(rng);
+ // I = uni(rng);
+ // D = uni(rng);
+ P = 10;
+ I = 0.1;
+ D = 10;
+ PID test(P, I, D);
+ test.reset(0.0);
+
+ float val = 0;
+ for (unsigned int i = 0; i < 100; i++) val = test.iter(1.0);
+ // if (val > 0.999 && val < 1.001) {
+ fprintf(stderr, "P: %.3f :: I: %.3f :: D: %.3f\n", P, I, D);
+ test.reset(0.0);
+ for (unsigned int i = 0; i < 100; i++) {
+ printf("%2.8f\n", test.iter(1.0));
+ }
+ exit(0);
+ // }
+ } while (false);
+}