homing: Extract out movement verification to new check_no_movement()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
d39f849203
commit
38719c1359
|
@ -21,6 +21,7 @@ class HomingMove:
|
||||||
def __init__(self, printer):
|
def __init__(self, printer):
|
||||||
self.printer = printer
|
self.printer = printer
|
||||||
self.toolhead = printer.lookup_object('toolhead')
|
self.toolhead = printer.lookup_object('toolhead')
|
||||||
|
self.end_mcu_pos = []
|
||||||
def _calc_endstop_rate(self, mcu_endstop, movepos, speed):
|
def _calc_endstop_rate(self, mcu_endstop, movepos, speed):
|
||||||
startpos = self.toolhead.get_position()
|
startpos = self.toolhead.get_position()
|
||||||
axes_d = [mp - sp for mp, sp in zip(movepos, startpos)]
|
axes_d = [mp - sp for mp, sp in zip(movepos, startpos)]
|
||||||
|
@ -33,8 +34,7 @@ class HomingMove:
|
||||||
if max_steps <= 0.:
|
if max_steps <= 0.:
|
||||||
return .001
|
return .001
|
||||||
return move_t / max_steps
|
return move_t / max_steps
|
||||||
def homing_move(self, movepos, endstops, speed,
|
def homing_move(self, movepos, endstops, speed, probe_pos=False):
|
||||||
probe_pos=False, verify_movement=False):
|
|
||||||
# Notify start of homing/probing move
|
# Notify start of homing/probing move
|
||||||
self.printer.send_event("homing:homing_move_begin",
|
self.printer.send_event("homing:homing_move_begin",
|
||||||
[es for es, name in endstops])
|
[es for es, name in endstops])
|
||||||
|
@ -69,10 +69,10 @@ class HomingMove:
|
||||||
error = "Failed to home %s: Timeout during homing" % (name,)
|
error = "Failed to home %s: Timeout during homing" % (name,)
|
||||||
# Determine stepper halt positions
|
# Determine stepper halt positions
|
||||||
self.toolhead.flush_step_generation()
|
self.toolhead.flush_step_generation()
|
||||||
end_mcu_pos = [(s, name, spos, s.get_mcu_position())
|
self.end_mcu_pos = [(s, name, spos, s.get_mcu_position())
|
||||||
for s, name, spos in start_mcu_pos]
|
for s, name, spos in start_mcu_pos]
|
||||||
if probe_pos:
|
if probe_pos:
|
||||||
for s, name, spos, epos in end_mcu_pos:
|
for s, name, spos, epos in self.end_mcu_pos:
|
||||||
md = (epos - spos) * s.get_step_dist()
|
md = (epos - spos) * s.get_step_dist()
|
||||||
s.set_tag_position(s.get_tag_position() + md)
|
s.set_tag_position(s.get_tag_position() + md)
|
||||||
movepos = list(kin.calc_tag_position())[:3] + movepos[3:]
|
movepos = list(kin.calc_tag_position())[:3] + movepos[3:]
|
||||||
|
@ -86,17 +86,14 @@ class HomingMove:
|
||||||
error = str(e)
|
error = str(e)
|
||||||
if error is not None:
|
if error is not None:
|
||||||
raise self.printer.command_error(error)
|
raise self.printer.command_error(error)
|
||||||
# Check if some movement occurred
|
|
||||||
can_verify = self.printer.get_start_args().get('debuginput') is None
|
|
||||||
if verify_movement and can_verify:
|
|
||||||
for s, name, spos, epos in end_mcu_pos:
|
|
||||||
if spos == epos:
|
|
||||||
if probe_pos:
|
|
||||||
raise self.printer.command_error(
|
|
||||||
"Probe triggered prior to movement")
|
|
||||||
raise self.printer.command_error(
|
|
||||||
"Endstop %s still triggered after retract" % (name,))
|
|
||||||
return movepos
|
return movepos
|
||||||
|
def check_no_movement(self):
|
||||||
|
if self.printer.get_start_args().get('debuginput') is not None:
|
||||||
|
return None
|
||||||
|
for s, name, spos, epos in self.end_mcu_pos:
|
||||||
|
if spos == epos:
|
||||||
|
return name
|
||||||
|
return None
|
||||||
|
|
||||||
# State tracking of homing requests
|
# State tracking of homing requests
|
||||||
class Homing:
|
class Homing:
|
||||||
|
@ -144,8 +141,11 @@ class Homing:
|
||||||
for rp, ad in zip(retractpos, axes_d)]
|
for rp, ad in zip(retractpos, axes_d)]
|
||||||
self.toolhead.set_position(forcepos)
|
self.toolhead.set_position(forcepos)
|
||||||
hmove = HomingMove(self.printer)
|
hmove = HomingMove(self.printer)
|
||||||
hmove.homing_move(movepos, endstops, hi.second_homing_speed,
|
hmove.homing_move(movepos, endstops, hi.second_homing_speed)
|
||||||
verify_movement=True)
|
if hmove.check_no_movement() is not None:
|
||||||
|
raise self.printer.command_error(
|
||||||
|
"Endstop %s still triggered after retract"
|
||||||
|
% (hmove.check_no_movement(),))
|
||||||
# Signal home operation complete
|
# Signal home operation complete
|
||||||
self.toolhead.flush_step_generation()
|
self.toolhead.flush_step_generation()
|
||||||
kin = self.toolhead.get_kinematics()
|
kin = self.toolhead.get_kinematics()
|
||||||
|
@ -168,8 +168,11 @@ class PrinterHoming:
|
||||||
def probing_move(self, mcu_probe, pos, speed):
|
def probing_move(self, mcu_probe, pos, speed):
|
||||||
hmove = HomingMove(self.printer)
|
hmove = HomingMove(self.printer)
|
||||||
endstops = [(mcu_probe, "probe")]
|
endstops = [(mcu_probe, "probe")]
|
||||||
return hmove.homing_move(pos, endstops, speed,
|
epos = hmove.homing_move(pos, endstops, speed, probe_pos=True)
|
||||||
probe_pos=True, verify_movement=True)
|
if hmove.check_no_movement() is not None:
|
||||||
|
raise self.printer.command_error(
|
||||||
|
"Probe triggered prior to movement")
|
||||||
|
return epos
|
||||||
def cmd_G28(self, gcmd):
|
def cmd_G28(self, gcmd):
|
||||||
# Move to origin
|
# Move to origin
|
||||||
axes = []
|
axes = []
|
||||||
|
|
Loading…
Reference in New Issue