Skip to content

Commit 853a014

Browse files
f5sohfilnet
authored andcommitted
Merged in f5soh/librepilot/LP-596_AltitudeHold_transition (pull request #509)
LP-596 Fix AltitudeHold transition Approved-by: Lalanne Laurent <f5soh@free.fr> Approved-by: Cliff . <cliffsjunk@att.net> Approved-by: Julian Lilov <jdl@abv.bg> Approved-by: Philippe Renon <philippe_renon@yahoo.fr>
2 parents cb6d86b + 691c6c1 commit 853a014

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

  • flight/libraries/math

flight/libraries/math/pid.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,17 @@ float pid2_apply(
219219
// pid->I = (pid->u0 - pid->va) / pid->vb - pid->kp * (pid->beta * r - y);
220220
// this is dangerous, if pid->I starts nonzero with very low or zero kI, then
221221
// it will never settle!
222-
pid->I = 0.0f;
222+
// pid->I = 0.0f;
223+
// whether ki is zero or non-zero, when doing 'reconfigure' we start with setpoint==actual
224+
pid->I = (pid->u0 - pid->va) / pid->vb;
225+
// if ki is non-zero
226+
if (pid->bi > 5e-7f) {
227+
// then the output can wind up/down to get rid of a difference between setpoint and actual
228+
// so we can generate the full bumpless transfer here
229+
// else leave off the part that can vary due to difference between setpoint and actual
230+
// so that it is repeatable (for tuning purposes at least)
231+
pid->I -= pid->kp * (pid->beta * r - y);
232+
}
223233
}
224234

225235
// compute proportional part

0 commit comments

Comments
 (0)