aboutsummaryrefslogtreecommitdiff
path: root/zumo/pidtest.cpp
blob: f5198bbb3e17b9c93f6e8574e1cc8625e96f52a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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);
}