aboutsummaryrefslogtreecommitdiff
path: root/zumo/pidtest
diff options
context:
space:
mode:
Diffstat (limited to 'zumo/pidtest')
-rw-r--r--zumo/pidtest/.gitignore1
-rw-r--r--zumo/pidtest/makefile21
-rw-r--r--zumo/pidtest/pidtest.cpp18
3 files changed, 40 insertions, 0 deletions
diff --git a/zumo/pidtest/.gitignore b/zumo/pidtest/.gitignore
new file mode 100644
index 0000000..41dc46e
--- /dev/null
+++ b/zumo/pidtest/.gitignore
@@ -0,0 +1 @@
+pidtest
diff --git a/zumo/pidtest/makefile b/zumo/pidtest/makefile
new file mode 100644
index 0000000..832d60b
--- /dev/null
+++ b/zumo/pidtest/makefile
@@ -0,0 +1,21 @@
+CPP = g++
+LD = g++
+RM = rm -f
+CFLAGS =
+LFLAGS =
+TARGET = pidtest
+
+SRCS := pidtest.cpp ../pid.cpp
+OBJS := pidtest.o ../pid.o
+
+all: pidtest
+
+%.o: %.cpp
+ $(CPP) -c $(CFLAGS) $< -o $@
+
+$(TARGET): $(OBJS)
+ $(LD) $^ $(LFLAGS) -o $@
+
+clean:
+ $(RM) $(TARGET) $(OBJS)
+
diff --git a/zumo/pidtest/pidtest.cpp b/zumo/pidtest/pidtest.cpp
new file mode 100644
index 0000000..4d047fb
--- /dev/null
+++ b/zumo/pidtest/pidtest.cpp
@@ -0,0 +1,18 @@
+#include <cstdio>
+#include <random>
+
+#include "../pid.h"
+
+int main() {
+ float P, I, D;
+ P = -0.02;
+ I = 0.13;
+ D = -300;
+ PID test(P, I, D);
+ test.reset(0.0);
+
+ fprintf(stderr, "P: %.3f :: I: %.3f :: D: %.3f\n", P, I, D);
+ for (unsigned int i = 0; i < 100; i++) {
+ printf("%2.8f\n", test.iter(i < 50 ? 1.0 : 0.0));
+ }
+}