From 4573932f89d4bc0f0c0fea5ee40f7a2d4d3ed757 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 11 Sep 2018 13:23:20 -0400 Subject: [PATCH] toolhead: Handle rounding errors with extrude only moves It's possible that a g-code transform class may make an extrude only move appear as a kinematic move due to limitations of double precision math. Handle this by checking for an inconsequential move distance instead of checking for a move distance of exactly zero. Signed-off-by: Kevin O'Connor --- klippy/toolhead.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/klippy/toolhead.py b/klippy/toolhead.py index d94eddad..963d8052 100644 --- a/klippy/toolhead.py +++ b/klippy/toolhead.py @@ -21,8 +21,11 @@ class Move: self.is_kinematic_move = True self.axes_d = axes_d = [end_pos[i] - start_pos[i] for i in (0, 1, 2, 3)] self.move_d = move_d = math.sqrt(sum([d*d for d in axes_d[:3]])) - if not move_d: + if move_d < .000000001: # Extrude only move + self.end_pos = (start_pos[0], start_pos[1], start_pos[2], + end_pos[3]) + axes_d[0] = axes_d[1] = axes_d[2] = 0. self.move_d = move_d = abs(axes_d[3]) self.is_kinematic_move = False self.min_move_t = move_d / speed