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.)
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue