summaryrefslogtreecommitdiff
path: root/zumo/pid.h
blob: ef733d69014b17f687d5069e71d1b673ded3c090 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#pragma once

#include "protocol.h"

class PID {
private:
	float A0, A1, A0d, A1d, A2d, tau, alpha, d0, d1, fd0, fd1;
	float error[3];
	float output;
	const float dt = 1.0;
	const float N = 10.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);