aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/toolhead.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-10-25 19:11:05 -0400
committerKevin O'Connor <kevin@koconnor.net>2016-10-25 19:19:29 -0400
commit6a96e83ea923ebd0d3a84da218afda020b8b9612 (patch)
tree695901a66269bf24df3c1555a0fa5184a820ee73 /klippy/toolhead.py
parent306db9a8516a42258346a1292da550199a06d8d6 (diff)
downloadkutter-6a96e83ea923ebd0d3a84da218afda020b8b9612.tar.gz
kutter-6a96e83ea923ebd0d3a84da218afda020b8b9612.tar.xz
kutter-6a96e83ea923ebd0d3a84da218afda020b8b9612.zip
toolhead: Store both the start and end position in the Move class
Store the start position (in addition to the existing end position) in the Move class. The start position can be useful to the kinematic classes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/toolhead.py')
-rw-r--r--klippy/toolhead.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/klippy/toolhead.py b/klippy/toolhead.py
index e73a2d15..1cda18df 100644
--- a/klippy/toolhead.py
+++ b/klippy/toolhead.py
@@ -14,12 +14,13 @@ EXTRUDE_DIFF_IGNORE = 1.02
# Class to track each move request
class Move:
- def __init__(self, toolhead, pos, axes_d, speed, accel):
+ def __init__(self, toolhead, start_pos, end_pos, speed, accel):
self.toolhead = toolhead
- self.pos = tuple(pos)
- self.axes_d = axes_d
+ self.start_pos = tuple(start_pos)
+ self.end_pos = tuple(end_pos)
self.accel = accel
self.do_calc_junction = True
+ self.axes_d = axes_d = [end_pos[i] - start_pos[i] for i in (0, 1, 2, 3)]
if axes_d[2]:
# Move with Z
move_d = math.sqrt(sum([d*d for d in axes_d[:3]]))
@@ -29,6 +30,10 @@ class Move:
if not move_d:
# Extrude only move
move_d = abs(axes_d[3])
+ if not move_d:
+ # No move
+ self.move_d = 0.
+ return
self.do_calc_junction = False
self.move_d = move_d
self.extrude_r = axes_d[3] / move_d
@@ -245,15 +250,12 @@ class ToolHead:
self.commanded_pos[:] = newpos
self.kin.set_position(newpos)
def move(self, newpos, speed, sloppy=False):
- axes_d = [newpos[i] - self.commanded_pos[i]
- for i in (0, 1, 2, 3)]
- if axes_d == [0., 0., 0., 0.]:
- # No move
- return
speed = min(speed, self.max_speed)
- move = Move(self, newpos, axes_d, speed, self.max_accel)
+ move = Move(self, self.commanded_pos, newpos, speed, self.max_accel)
+ if not move.move_d:
+ return
self.kin.check_move(move)
- if axes_d[3]:
+ if move.axes_d[3]:
self.extruder.check_move(move)
self.commanded_pos[:] = newpos
self.move_queue.add_move(move)