aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2020-08-08 11:39:31 -0400
committerKevin O'Connor <kevin@koconnor.net>2020-08-08 11:59:19 -0400
commitea5e76746a8f0ea72d014b715ac4712bd47513de (patch)
tree0eae0f69f8f4a63a22ecafa3328394e46c3a4dab
parent513582afc410037907d9aeaa5564de82f3009a62 (diff)
downloadkutter-ea5e76746a8f0ea72d014b715ac4712bd47513de.tar.gz
kutter-ea5e76746a8f0ea72d014b715ac4712bd47513de.tar.xz
kutter-ea5e76746a8f0ea72d014b715ac4712bd47513de.zip
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 <kevin@koconnor.net>
-rw-r--r--klippy/chelper/itersolve.c6
1 files 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;
}