motion_queuing: Try harder to use next_batch_time when flushing

Use the next_batch_time even if it is slightly past or before the
ideal flushing window.  This should improve run to run reproducibility
of flush timing.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor committed 2025-09-15 13:46:35 -04:00
1 parent 950aa103e4
commit f341031834
1 file changed
+5 -4
+5 -4
View File
@@ -187,12 +187,13 @@ class PrinterMotionQueuing:
if self.last_step_gen_time < aggr_sg_time:
# Actively stepping - want more aggressive flushing
want_sg_time = est_print_time + BGFLUSH_SG_HIGH_TIME
want_sg_time = min(want_sg_time, aggr_sg_time)
# Try improving run-to-run reproducibility by batching from last
batch_time = BGFLUSH_SG_HIGH_TIME - BGFLUSH_SG_LOW_TIME
next_batch_time = self.last_step_gen_time + batch_time
if next_batch_time > est_print_time + BGFLUSH_SG_LOW_TIME:
want_sg_time = min(want_sg_time, next_batch_time)
if (next_batch_time > est_print_time
and next_batch_time < want_sg_time + 0.005):
# Improve run-to-run reproducibility by batching from last
want_sg_time = next_batch_time
want_sg_time = min(want_sg_time, aggr_sg_time)
# Flush motion queues (if needed)
if want_sg_time > self.last_step_gen_time:
self._advance_flush_time(0., want_sg_time)