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>
This commit is contained in:
parent
513582afc4
commit
ea5e76746a
|
@ -43,11 +43,11 @@ itersolve_find_step(struct stepper_kinematics *sk, struct move *m
|
||||||
for (;;) {
|
for (;;) {
|
||||||
double guess_time = ((low.time*high.position - high.time*low.position)
|
double guess_time = ((low.time*high.position - high.time*low.position)
|
||||||
/ (high.position - low.position));
|
/ (high.position - low.position));
|
||||||
if (fabs(guess_time - best_guess.time) <= .000000001)
|
|
||||||
break;
|
|
||||||
best_guess.time = guess_time;
|
best_guess.time = guess_time;
|
||||||
best_guess.position = calc_position_cb(sk, m, guess_time);
|
best_guess.position = calc_position_cb(sk, m, guess_time);
|
||||||
double guess_position = best_guess.position - target;
|
double guess_position = best_guess.position - target;
|
||||||
|
if (fabs(guess_position) <= .000000001)
|
||||||
|
break;
|
||||||
int guess_sign = signbit(guess_position);
|
int guess_sign = signbit(guess_position);
|
||||||
if (guess_sign == high_sign) {
|
if (guess_sign == high_sign) {
|
||||||
high.time = guess_time;
|
high.time = guess_time;
|
||||||
|
@ -62,6 +62,8 @@ itersolve_find_step(struct stepper_kinematics *sk, struct move *m
|
||||||
high.position *= .5;
|
high.position *= .5;
|
||||||
prev_choice = -1;
|
prev_choice = -1;
|
||||||
}
|
}
|
||||||
|
if (high.time - low.time <= .000000001)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return best_guess;
|
return best_guess;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue