diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2016-07-12 12:04:06 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2016-07-22 15:42:19 -0400 |
commit | c84760631101e7576b10ee7374fd5bf92b70aa4d (patch) | |
tree | bffe05d00bb156dd3f27fb6fcd44c60b720545b8 /klippy/toolhead.py | |
parent | 589017a3d6de81a52c5a496a4b82ae202a4f990c (diff) | |
download | kutter-c84760631101e7576b10ee7374fd5bf92b70aa4d.tar.gz kutter-c84760631101e7576b10ee7374fd5bf92b70aa4d.tar.xz kutter-c84760631101e7576b10ee7374fd5bf92b70aa4d.zip |
toolhead: Limit lookahead optimization to moves with similar extrude ratios
Only skip acceleration between moves if both moves perform a similar
amount of extrusion. This ensures the extruder has sufficient time to
accelerate to and from each extrude move.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/toolhead.py')
-rw-r--r-- | klippy/toolhead.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/klippy/toolhead.py b/klippy/toolhead.py index 521413a5..d0cd86a5 100644 --- a/klippy/toolhead.py +++ b/klippy/toolhead.py @@ -6,6 +6,8 @@ import math, logging, time import cartesian +EXTRUDE_DIFF_IGNORE = 1.02 + # Common suffixes: _d is distance (in mm), _v is velocity (in # mm/second), _t is time (in seconds), _r is ratio (scalar between # 0.0 and 1.0) @@ -18,6 +20,7 @@ class Move: self.move_d = move_d self.axes_d = axes_d self.accel = accel + self.extrude_r = axes_d[3] / move_d # Junction speeds are velocities squared. The junction_delta # is the maximum amount of this squared-velocity that can # change in this move. @@ -25,8 +28,14 @@ class Move: self.junction_delta = 2.0 * move_d * accel self.junction_start_max = 0. def calc_junction(self, prev_move): - # Find max start junction velocity using approximated - # centripetal velocity as described at: + # Find max junction_start_velocity between two moves + if (self.extrude_r > prev_move.extrude_r * EXTRUDE_DIFF_IGNORE + or prev_move.extrude_r > self.extrude_r * EXTRUDE_DIFF_IGNORE): + # Extrude ratio between moves is too different + return + self.extrude_r = prev_move.extrude_r + # Find max velocity using approximated centripetal velocity as + # described at: # https://onehossshay.wordpress.com/2011/09/24/improving_grbl_cornering_algorithm/ junction_cos_theta = -((self.axes_d[0] * prev_move.axes_d[0] + self.axes_d[1] * prev_move.axes_d[1]) @@ -34,7 +43,7 @@ class Move: if junction_cos_theta > 0.999999: return junction_cos_theta = max(junction_cos_theta, -0.999999) - sin_theta_d2 = math.sqrt(0.5*(1.0-junction_cos_theta)); + sin_theta_d2 = math.sqrt(0.5*(1.0-junction_cos_theta)) R = self.toolhead.junction_deviation * sin_theta_d2 / (1. - sin_theta_d2) self.junction_start_max = min( R * self.accel, self.junction_max, prev_move.junction_max) |