toolhead: Fix error in lookahead logic

Commit c24b7a7e reworked the way lookahead was done and it introduced
a bug when a full acceleration move is immiedietly followed by a full
deceleration move.  In that situation, depending on when the lookahead
queue was flushed, it was possible to call move.move() without calling
move.set_junction().  This resulted in a "Move instance has no
attribute 'accel_t'" internal error.

Simplify and fix the logic for checking full accel moves followed by
full decel moves.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2017-02-20 12:37:43 -05:00
parent 29ba92a551
commit 566699f68a
1 changed files with 11 additions and 11 deletions

View File

@ -100,12 +100,10 @@ class MoveQueue:
self.extruder_lookahead = extruder_lookahead self.extruder_lookahead = extruder_lookahead
self.queue = [] self.queue = []
self.leftover = 0 self.leftover = 0
self.next_start_v2 = 0.
self.junction_flush = LOOKAHEAD_FLUSH_TIME self.junction_flush = LOOKAHEAD_FLUSH_TIME
def reset(self): def reset(self):
del self.queue[:] del self.queue[:]
self.leftover = 0 self.leftover = 0
self.next_start_v2 = 0.
self.junction_flush = LOOKAHEAD_FLUSH_TIME self.junction_flush = LOOKAHEAD_FLUSH_TIME
def set_flush_time(self, flush_time): def set_flush_time(self, flush_time):
self.junction_flush = flush_time self.junction_flush = flush_time
@ -128,8 +126,9 @@ class MoveQueue:
if smoothed_v2 < reachable_smoothed_v2: if smoothed_v2 < reachable_smoothed_v2:
# It's possible for this move to accelerate # It's possible for this move to accelerate
if (smoothed_v2 + move.smooth_delta_v2 > next_smoothed_v2 if (smoothed_v2 + move.smooth_delta_v2 > next_smoothed_v2
or next_smoothed_v2 >= peak_cruise_v2): or delayed):
# This move can both accelerate and decelerate # This move can decelerate or this is a full accel
# move after a full decel move
if update_flush_count and peak_cruise_v2: if update_flush_count and peak_cruise_v2:
flush_count = i flush_count = i
update_flush_count = False update_flush_count = False
@ -137,17 +136,18 @@ class MoveQueue:
smoothed_v2 + reachable_smoothed_v2) * .5) smoothed_v2 + reachable_smoothed_v2) * .5)
if delayed: if delayed:
# Propagate peak_cruise_v2 to any delayed moves # Propagate peak_cruise_v2 to any delayed moves
if not update_flush_count and i < flush_count:
for m, ms_v2, me_v2 in delayed: for m, ms_v2, me_v2 in delayed:
mc_v2 = min(peak_cruise_v2, ms_v2) mc_v2 = min(peak_cruise_v2, ms_v2)
m.set_junction(min(ms_v2, mc_v2), mc_v2 m.set_junction(min(ms_v2, mc_v2), mc_v2
, min(me_v2, mc_v2)) , min(me_v2, mc_v2))
del delayed[:] del delayed[:]
if not update_flush_count and i < flush_count:
cruise_v2 = min((start_v2 + reachable_start_v2) * .5 cruise_v2 = min((start_v2 + reachable_start_v2) * .5
, move.max_cruise_v2, peak_cruise_v2) , move.max_cruise_v2, peak_cruise_v2)
if not update_flush_count and i < flush_count:
move.set_junction(min(start_v2, cruise_v2), cruise_v2 move.set_junction(min(start_v2, cruise_v2), cruise_v2
, min(next_end_v2, cruise_v2)) , min(next_end_v2, cruise_v2))
elif not update_flush_count: else:
# Delay calculating this move until peak_cruise_v2 is known # Delay calculating this move until peak_cruise_v2 is known
delayed.append((move, start_v2, next_end_v2)) delayed.append((move, start_v2, next_end_v2))
next_end_v2 = start_v2 next_end_v2 = start_v2