Fixed pid bug, attitude was not controlled

This commit is contained in:
Julian Oes
2013-06-16 09:55:28 +02:00
parent 8559315f4f
commit 303694f5f7
2 changed files with 8 additions and 7 deletions
+2 -3
View File
@@ -101,7 +101,7 @@ __EXPORT int pid_set_parameters(PID_t *pid, float kp, float ki, float kd, float
}
if (isfinite(diff_filter_factor)) {
pid->limit = diff_filter_factor;
pid->diff_filter_factor = diff_filter_factor;
} else {
ret = 1;
@@ -179,8 +179,7 @@ __EXPORT float pid_calculate(PID_t *pid, float sp, float val, float val_dot, flo
}
// Calculate the output. Limit output magnitude to pid->limit
float output = (pid->error_previous * pid->kp) + (i * pid->ki) + (d * pid->kd);
float output = (error * pid->kp) + (i * pid->ki) + (d * pid->kd);
if (output > pid->limit) output = pid->limit;
if (output < -pid->limit) output = -pid->limit;