From ea5e76746a8f0ea72d014b715ac4712bd47513de Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sat, 8 Aug 2020 11:39:31 -0400 Subject: [PATCH] itersolve: Use stricter completion check in itersolve_find_step() Use a more strict check for determining if the iterative solver has correctly found a step - the guess must be within 1 picometer of the target or correct to within 1 nanosecond. Signed-off-by: Kevin O'Connor --- klippy/chelper/itersolve.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/klippy/chelper/itersolve.c b/klippy/chelper/itersolve.c index ae351f7d..36f9ea90 100644 --- a/klippy/chelper/itersolve.c +++ b/klippy/chelper/itersolve.c @@ -43,11 +43,11 @@ itersolve_find_step(struct stepper_kinematics *sk, struct move *m for (;;) { double guess_time = ((low.time*high.position - high.time*low.position) / (high.position - low.position)); - if (fabs(guess_time - best_guess.time) <= .000000001) - break; best_guess.time = guess_time; best_guess.position = calc_position_cb(sk, m, guess_time); double guess_position = best_guess.position - target; + if (fabs(guess_position) <= .000000001) + break; int guess_sign = signbit(guess_position); if (guess_sign == high_sign) { high.time = guess_time; @@ -62,6 +62,8 @@ itersolve_find_step(struct stepper_kinematics *sk, struct move *m high.position *= .5; prev_choice = -1; } + if (high.time - low.time <= .000000001) + break; } return best_guess; }