Created
January 22, 2016 19:35
-
-
Save evgeniyp/7fced36573932723443d to your computer and use it in GitHub Desktop.
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
float KP = 300, KI = 15, KD = 600; | |
float pTerm = 0, iTerm = 0, dTerm = 0; | |
float last_pitch = 0; | |
void loop() | |
{ | |
float pitch = get_pitch(); // угол отклонения от вертикальной оси | |
pTerm = KP * pitch; | |
iTerm = KI * pitch + iTerm; | |
dTerm = KD * (pitch - last_pitch); | |
last_pitch = pitch; | |
float spd = pTerm + iTerm + dTerm; | |
set_motors(-spd, -spd); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment