diff options
author | UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> | 2023-05-25 21:07:27 +0200 |
---|---|---|
committer | UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> | 2023-05-25 21:07:27 +0200 |
commit | fbe109a12420033c3421733072d36a875e154f64 (patch) | |
tree | 3f0efe7cee27c2389d057f411261fd037fccbb2b /zumo/pid.h | |
parent | 76df689d48df0b5056769b9c8ca968ac4a0eb261 (diff) | |
parent | 6daf8036c1342899196b2f7830ae5a18f0918d07 (diff) |
Merge branch 'master' of https://github.com/unavailabledev/avans-dui
Diffstat (limited to 'zumo/pid.h')
-rw-r--r-- | zumo/pid.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/zumo/pid.h b/zumo/pid.h new file mode 100644 index 0000000..beb73ac --- /dev/null +++ b/zumo/pid.h @@ -0,0 +1,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 = -0.02, float I = 0.13, float D = -300.0); + 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); + |