aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-03-08 12:32:01 -0500
committerKevin O'Connor <kevin@koconnor.net>2019-03-08 12:32:01 -0500
commiteac22df7cbe0e7058e12a2f1700319353943a5cf (patch)
treef12e103a5b5daf80282edd7b08b3b738574b0d93
parent5c0a2479be961816d02ffbf261cf3e51ac5f5751 (diff)
downloadkutter-eac22df7cbe0e7058e12a2f1700319353943a5cf.tar.gz
kutter-eac22df7cbe0e7058e12a2f1700319353943a5cf.tar.xz
kutter-eac22df7cbe0e7058e12a2f1700319353943a5cf.zip
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>
-rw-r--r--klippy/extras/probe.py27
1 files changed, 12 insertions, 15 deletions
diff --git a/klippy/extras/probe.py b/klippy/extras/probe.py
index 83871d15..f82a3a6e 100644
--- a/klippy/extras/probe.py
+++ b/klippy/extras/probe.py
@@ -91,6 +91,7 @@ class PrinterProbe:
'Z', params, default=10., minval=self.z_offset, maxval=70.)
x_start_position = self.gcode.get_float('X', params, default=pos[0])
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"
" "
"and read %d times with speed of %d mm/s" % (
@@ -100,8 +101,7 @@ class PrinterProbe:
sum_reads = 0
for i in range(number_of_reads):
# Move Z to start reading position
- self._move_position(x_start_position, y_start_position,
- z_start_position, speed)
+ self._move(start_pos, speed)
# Probe
self._probe(speed)
# Get Z value, accumulate value to calculate average
@@ -110,8 +110,7 @@ class PrinterProbe:
sum_reads += pos[2]
probes.append(pos[2])
# Move Z to start reading position
- self._move_position(x_start_position, y_start_position,
- z_start_position, speed)
+ self._move(start_pos, speed)
# Calculate maximum, minimum and average values
max_value = max(probes)
min_value = min(probes)
@@ -135,16 +134,14 @@ class PrinterProbe:
"probe accuracy results: maximum %.6f, minimum %.6f, "
"average %.6f, median %.6f, standard deviation %.6f" % (
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')
- pos = toolhead.get_position()
- # set new position
- pos[0] = x
- pos[1] = y
- pos[2] = z
- # Move to position
+ curpos = toolhead.get_position()
+ for i in range(len(coord)):
+ if coord[i] is not None:
+ curpos[i] = coord[i]
try:
- toolhead.move(pos, speed)
+ toolhead.move(curpos, speed)
except homing.EndstopError as e:
raise self.gcode.error(str(e))
def probe_calibrate_finalize(self, kin_pos):
@@ -160,16 +157,16 @@ class PrinterProbe:
cmd_PROBE_CALIBRATE_help = "Calibrate the probe's z_offset"
def cmd_PROBE_CALIBRATE(self, params):
# Perform initial probe
- self.cmd_PROBE(params)
+ self._probe(self.speed)
# Move away from the bed
toolhead = self.printer.lookup_object('toolhead')
curpos = toolhead.get_position()
curpos[2] += 5.
- toolhead.move(curpos, self.speed)
+ self._move(curpos, self.speed)
# Move the nozzle over the probe point
curpos[0] += self.x_offset
curpos[1] += self.y_offset
- toolhead.move(curpos, self.speed)
+ self._move(curpos, self.speed)
# Start manual probe
manual_probe.ManualProbeHelper(self.printer, params,
self.probe_calibrate_finalize)