Last active
June 10, 2019 16:27
-
-
Save tanitanin/3ee5a8beb60dda7f55f3bcb98d5abc44 to your computer and use it in GitHub Desktop.
Discrete-Time Integrator with Forward Eular Method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
template<typename T> | |
class DescreteTimeIntegrator { | |
T x; | |
T y; | |
T Ts; | |
T K; | |
public: | |
DescreteTimeIntegrator(T k, T ts,T initial = T()) : K(k), Ts(ts) { | |
y = initial; | |
} | |
T update(T input) { | |
// forward eular | |
x = y + K * Ts * input; | |
y = x; | |
return y; | |
} | |
void reset(T initial) { y = initial; } | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment