From b97d6e2a0329006ef806152052fe6bb0c86683ba Mon Sep 17 00:00:00 2001 From: Dmitry Butyugin Date: Mon, 25 Nov 2024 00:38:47 +0100 Subject: [PATCH] toolhead: Changed the threshold calculation for straight segments Signed-off-by: Dmitry Butyugin --- klippy/toolhead.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/klippy/toolhead.py b/klippy/toolhead.py index 242bce0d61bd..09be292053ad 100644 --- a/klippy/toolhead.py +++ b/klippy/toolhead.py @@ -72,23 +72,27 @@ def calc_junction(self, prev_move): + axes_r[2] * prev_axes_r[2]) if junction_cos_theta > 0.999999: return + sin_theta_d2 = math.sqrt(0.5*(1.0-junction_cos_theta)) + cos_theta_d2 = math.sqrt(0.5*(1.0+junction_cos_theta)) # Apply limits self.max_start_v2 = min( extruder_v2, self.max_cruise_v2, prev_move.max_cruise_v2, prev_move.max_start_v2 + prev_move.delta_v2) if junction_cos_theta >= -0.999999: - sin_theta_d2 = math.sqrt(0.5*(1.0-junction_cos_theta)) R_jd = sin_theta_d2 / (1. - sin_theta_d2) + self.max_start_v2 = min( + self.max_start_v2, + R_jd * self.junction_deviation * self.accel, + R_jd * prev_move.junction_deviation * prev_move.accel) + # Check that the radius of curvature for this junction is finite + if max(self.move_d, prev_move.move_d) < 99999999.9 * cos_theta_d2: # Approximated circle must contact moves no further than mid-move - tan_theta_d2 = sin_theta_d2 / math.sqrt(.5*(1.0+junction_cos_theta)) + tan_theta_d2 = sin_theta_d2 / cos_theta_d2 move_centripetal_v2 = .5 * self.move_d * tan_theta_d2 * self.accel prev_move_centripetal_v2 = (.5 * prev_move.move_d * tan_theta_d2 * prev_move.accel) - self.max_start_v2 = min( - self.max_start_v2, - R_jd * self.junction_deviation * self.accel, - R_jd * prev_move.junction_deviation * prev_move.accel, - move_centripetal_v2, prev_move_centripetal_v2) + self.max_start_v2 = min(self.max_start_v2, move_centripetal_v2, + prev_move_centripetal_v2) self.max_smoothed_v2 = min( self.max_start_v2 , prev_move.max_smoothed_v2 + prev_move.smooth_delta_v2)