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>
This commit is contained in:
parent
306db9a851
commit
6a96e83ea9
|
@ -67,16 +67,17 @@ class CartKinematics:
|
||||||
def query_endstops(self, move_time):
|
def query_endstops(self, move_time):
|
||||||
return homing.QueryEndstops(["x", "y", "z"], self.steppers)
|
return homing.QueryEndstops(["x", "y", "z"], self.steppers)
|
||||||
def check_endstops(self, move):
|
def check_endstops(self, move):
|
||||||
|
end_pos = move.end_pos
|
||||||
for i in StepList:
|
for i in StepList:
|
||||||
if (move.axes_d[i]
|
if (move.axes_d[i]
|
||||||
and (move.pos[i] < self.limits[i][0]
|
and (end_pos[i] < self.limits[i][0]
|
||||||
or move.pos[i] > self.limits[i][1])):
|
or end_pos[i] > self.limits[i][1])):
|
||||||
if self.limits[i][0] > self.limits[i][1]:
|
if self.limits[i][0] > self.limits[i][1]:
|
||||||
raise homing.EndstopError(move.pos, "Must home axis first")
|
raise homing.EndstopError(end_pos, "Must home axis first")
|
||||||
raise homing.EndstopError(move.pos)
|
raise homing.EndstopError(end_pos)
|
||||||
def check_move(self, move):
|
def check_move(self, move):
|
||||||
limits = self.limits
|
limits = self.limits
|
||||||
xpos, ypos = move.pos[:2]
|
xpos, ypos = move.end_pos[:2]
|
||||||
if (xpos < limits[0][0] or xpos > limits[0][1]
|
if (xpos < limits[0][0] or xpos > limits[0][1]
|
||||||
or ypos < limits[1][0] or ypos > limits[1][1]):
|
or ypos < limits[1][0] or ypos > limits[1][1]):
|
||||||
self.check_endstops(move)
|
self.check_endstops(move)
|
||||||
|
@ -96,7 +97,8 @@ class CartKinematics:
|
||||||
inv_accel = 1. / move.accel
|
inv_accel = 1. / move.accel
|
||||||
inv_cruise_v = 1. / move.cruise_v
|
inv_cruise_v = 1. / move.cruise_v
|
||||||
for i in StepList:
|
for i in StepList:
|
||||||
new_step_pos = int(move.pos[i]*self.steppers[i].inv_step_dist + 0.5)
|
new_step_pos = int(
|
||||||
|
move.end_pos[i]*self.steppers[i].inv_step_dist + 0.5)
|
||||||
steps = new_step_pos - self.stepper_pos[i]
|
steps = new_step_pos - self.stepper_pos[i]
|
||||||
if not steps:
|
if not steps:
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -21,7 +21,7 @@ class PrinterExtruder:
|
||||||
self.stepper.motor_enable(move_time, 0)
|
self.stepper.motor_enable(move_time, 0)
|
||||||
def check_move(self, move):
|
def check_move(self, move):
|
||||||
if not self.heater.can_extrude:
|
if not self.heater.can_extrude:
|
||||||
raise homing.EndstopError(move.pos, "Extrude below minimum temp")
|
raise homing.EndstopError(move.end_pos, "Extrude below minimum temp")
|
||||||
if (not move.do_calc_junction
|
if (not move.do_calc_junction
|
||||||
and not move.axes_d[0] and not move.axes_d[1]
|
and not move.axes_d[0] and not move.axes_d[1]
|
||||||
and not move.axes_d[2]):
|
and not move.axes_d[2]):
|
||||||
|
|
|
@ -14,12 +14,13 @@ EXTRUDE_DIFF_IGNORE = 1.02
|
||||||
|
|
||||||
# Class to track each move request
|
# Class to track each move request
|
||||||
class Move:
|
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.toolhead = toolhead
|
||||||
self.pos = tuple(pos)
|
self.start_pos = tuple(start_pos)
|
||||||
self.axes_d = axes_d
|
self.end_pos = tuple(end_pos)
|
||||||
self.accel = accel
|
self.accel = accel
|
||||||
self.do_calc_junction = True
|
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]:
|
if axes_d[2]:
|
||||||
# Move with Z
|
# Move with Z
|
||||||
move_d = math.sqrt(sum([d*d for d in axes_d[:3]]))
|
move_d = math.sqrt(sum([d*d for d in axes_d[:3]]))
|
||||||
|
@ -29,6 +30,10 @@ class Move:
|
||||||
if not move_d:
|
if not move_d:
|
||||||
# Extrude only move
|
# Extrude only move
|
||||||
move_d = abs(axes_d[3])
|
move_d = abs(axes_d[3])
|
||||||
|
if not move_d:
|
||||||
|
# No move
|
||||||
|
self.move_d = 0.
|
||||||
|
return
|
||||||
self.do_calc_junction = False
|
self.do_calc_junction = False
|
||||||
self.move_d = move_d
|
self.move_d = move_d
|
||||||
self.extrude_r = axes_d[3] / move_d
|
self.extrude_r = axes_d[3] / move_d
|
||||||
|
@ -245,15 +250,12 @@ class ToolHead:
|
||||||
self.commanded_pos[:] = newpos
|
self.commanded_pos[:] = newpos
|
||||||
self.kin.set_position(newpos)
|
self.kin.set_position(newpos)
|
||||||
def move(self, newpos, speed, sloppy=False):
|
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)
|
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)
|
self.kin.check_move(move)
|
||||||
if axes_d[3]:
|
if move.axes_d[3]:
|
||||||
self.extruder.check_move(move)
|
self.extruder.check_move(move)
|
||||||
self.commanded_pos[:] = newpos
|
self.commanded_pos[:] = newpos
|
||||||
self.move_queue.add_move(move)
|
self.move_queue.add_move(move)
|
||||||
|
|
Loading…
Reference in New Issue