summaryrefslogtreecommitdiff
path: root/zumo/pidtest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zumo/pidtest.cpp')
-rw-r--r--zumo/pidtest.cpp35
1 files changed, 9 insertions, 26 deletions
diff --git a/zumo/pidtest.cpp b/zumo/pidtest.cpp
index f5198bb..b9ce50b 100644
--- a/zumo/pidtest.cpp
+++ b/zumo/pidtest.cpp
@@ -3,33 +3,16 @@
#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);
+ P = -0.02;
+ I = 0.13;
+ D = -300;
+ 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);
+ 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));
+ }
}