mirror of https://github.com/Desuuuu/klipper.git
probe: Catch toolhead.move() exceptions in cmd_PROBE_CALIBRATE()
Slightly rework the self._move_position() code and also use it in PROBE_CALIBRATE. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
5c0a2479be
commit
eac22df7cb
|
@ -91,6 +91,7 @@ class PrinterProbe:
|
||||||
'Z', params, default=10., minval=self.z_offset, maxval=70.)
|
'Z', params, default=10., minval=self.z_offset, maxval=70.)
|
||||||
x_start_position = self.gcode.get_float('X', params, default=pos[0])
|
x_start_position = self.gcode.get_float('X', params, default=pos[0])
|
||||||
y_start_position = self.gcode.get_float('Y', params, default=pos[1])
|
y_start_position = self.gcode.get_float('Y', params, default=pos[1])
|
||||||
|
start_pos = [x_start_position, y_start_position, z_start_position]
|
||||||
self.gcode.respond_info("probe accuracy: at X:%.3f Y:%.3f Z:%.3f\n"
|
self.gcode.respond_info("probe accuracy: at X:%.3f Y:%.3f Z:%.3f\n"
|
||||||
" "
|
" "
|
||||||
"and read %d times with speed of %d mm/s" % (
|
"and read %d times with speed of %d mm/s" % (
|
||||||
|
@ -100,8 +101,7 @@ class PrinterProbe:
|
||||||
sum_reads = 0
|
sum_reads = 0
|
||||||
for i in range(number_of_reads):
|
for i in range(number_of_reads):
|
||||||
# Move Z to start reading position
|
# Move Z to start reading position
|
||||||
self._move_position(x_start_position, y_start_position,
|
self._move(start_pos, speed)
|
||||||
z_start_position, speed)
|
|
||||||
# Probe
|
# Probe
|
||||||
self._probe(speed)
|
self._probe(speed)
|
||||||
# Get Z value, accumulate value to calculate average
|
# Get Z value, accumulate value to calculate average
|
||||||
|
@ -110,8 +110,7 @@ class PrinterProbe:
|
||||||
sum_reads += pos[2]
|
sum_reads += pos[2]
|
||||||
probes.append(pos[2])
|
probes.append(pos[2])
|
||||||
# Move Z to start reading position
|
# Move Z to start reading position
|
||||||
self._move_position(x_start_position, y_start_position,
|
self._move(start_pos, speed)
|
||||||
z_start_position, speed)
|
|
||||||
# Calculate maximum, minimum and average values
|
# Calculate maximum, minimum and average values
|
||||||
max_value = max(probes)
|
max_value = max(probes)
|
||||||
min_value = min(probes)
|
min_value = min(probes)
|
||||||
|
@ -135,16 +134,14 @@ class PrinterProbe:
|
||||||
"probe accuracy results: maximum %.6f, minimum %.6f, "
|
"probe accuracy results: maximum %.6f, minimum %.6f, "
|
||||||
"average %.6f, median %.6f, standard deviation %.6f" % (
|
"average %.6f, median %.6f, standard deviation %.6f" % (
|
||||||
max_value, min_value, avg_value, median, sigma))
|
max_value, min_value, avg_value, median, sigma))
|
||||||
def _move_position(self, x, y, z, speed):
|
def _move(self, coord, speed):
|
||||||
toolhead = self.printer.lookup_object('toolhead')
|
toolhead = self.printer.lookup_object('toolhead')
|
||||||
pos = toolhead.get_position()
|
curpos = toolhead.get_position()
|
||||||
# set new position
|
for i in range(len(coord)):
|
||||||
pos[0] = x
|
if coord[i] is not None:
|
||||||
pos[1] = y
|
curpos[i] = coord[i]
|
||||||
pos[2] = z
|
|
||||||
# Move to position
|
|
||||||
try:
|
try:
|
||||||
toolhead.move(pos, speed)
|
toolhead.move(curpos, speed)
|
||||||
except homing.EndstopError as e:
|
except homing.EndstopError as e:
|
||||||
raise self.gcode.error(str(e))
|
raise self.gcode.error(str(e))
|
||||||
def probe_calibrate_finalize(self, kin_pos):
|
def probe_calibrate_finalize(self, kin_pos):
|
||||||
|
@ -160,16 +157,16 @@ class PrinterProbe:
|
||||||
cmd_PROBE_CALIBRATE_help = "Calibrate the probe's z_offset"
|
cmd_PROBE_CALIBRATE_help = "Calibrate the probe's z_offset"
|
||||||
def cmd_PROBE_CALIBRATE(self, params):
|
def cmd_PROBE_CALIBRATE(self, params):
|
||||||
# Perform initial probe
|
# Perform initial probe
|
||||||
self.cmd_PROBE(params)
|
self._probe(self.speed)
|
||||||
# Move away from the bed
|
# Move away from the bed
|
||||||
toolhead = self.printer.lookup_object('toolhead')
|
toolhead = self.printer.lookup_object('toolhead')
|
||||||
curpos = toolhead.get_position()
|
curpos = toolhead.get_position()
|
||||||
curpos[2] += 5.
|
curpos[2] += 5.
|
||||||
toolhead.move(curpos, self.speed)
|
self._move(curpos, self.speed)
|
||||||
# Move the nozzle over the probe point
|
# Move the nozzle over the probe point
|
||||||
curpos[0] += self.x_offset
|
curpos[0] += self.x_offset
|
||||||
curpos[1] += self.y_offset
|
curpos[1] += self.y_offset
|
||||||
toolhead.move(curpos, self.speed)
|
self._move(curpos, self.speed)
|
||||||
# Start manual probe
|
# Start manual probe
|
||||||
manual_probe.ManualProbeHelper(self.printer, params,
|
manual_probe.ManualProbeHelper(self.printer, params,
|
||||||
self.probe_calibrate_finalize)
|
self.probe_calibrate_finalize)
|
||||||
|
|
Loading…
Reference in New Issue