itersolve: Improve numerical stability of itersolve_generate_steps() loop

Minor rework of the loop to reduce the chance that numerical stability
could cause an infinite loop.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-11-08 13:31:47 -05:00
parent 0bfb655f66
commit bdc7383e51
1 changed files with 10 additions and 11 deletions

View File

@ -147,20 +147,17 @@ itersolve_generate_steps(struct stepper_kinematics *sk, double flush_time)
if (!sk->tq || list_empty(&sk->tq->moves))
return 0;
struct move *m = list_first_entry(&sk->tq->moves, struct move, node);
for (;;) {
double move_print_time = m->print_time;
double move_end_time = move_print_time + m->move_t;
if (last_flush_time >= move_end_time) {
while (last_flush_time >= m->print_time + m->move_t) {
if (list_is_last(&m->node, &sk->tq->moves))
break;
return 0;
m = list_next_entry(m, node);
continue;
}
double start = move_print_time, end = move_end_time;
for (;;) {
double start = m->print_time, end = start + m->move_t;
if (start < last_flush_time)
start = last_flush_time;
if (start >= flush_time)
break;
return 0;
if (end > flush_time)
end = flush_time;
if (check_active(sk, m)) {
@ -169,8 +166,10 @@ itersolve_generate_steps(struct stepper_kinematics *sk, double flush_time)
return ret;
}
last_flush_time = end;
}
if (list_is_last(&m->node, &sk->tq->moves))
return 0;
m = list_next_entry(m, node);
}
}
// Check if the given stepper is likely to be active in the given time range