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

#include "protocol.h"

class PID {
private:
	float A0, A1, A2;
	float error[3] = {0};
	float dt = 0.010;
	float output = 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);