bed_mesh: move probe x and y offsets to the [probe] module

All probe offsets are now passed to the finalize() callback in the ProbePointsHelper Class.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2018-08-18 12:25:57 -04:00 committed by KevinOConnor
parent 52df40dfbb
commit 3387cccdcf
6 changed files with 42 additions and 30 deletions

View File

@ -17,6 +17,12 @@
#[probe]
#pin: ar15
# Probe detection pin. This parameter must be provided.
#x_offset: 0.0
# The distance (in mm) between the probe and the nozzle along the
# x-axis. The default is 0.
#y_offset: 0.0
# The distance (in mm) between the probe and the nozzle along the
# y-axis. The default is 0.
#z_offset:
# The distance (in mm) between the bed and the nozzle when the probe
# triggers. This parameter must be provided.
@ -65,9 +71,9 @@
# and true otherwise.
# Mesh Bed Leveling. One may define a [bed_mesh] config section
# Mesh Bed Leveling. One may define a [bed_mesh] config section
# to enable move transformations that offset the z axis based
# on a mesh generated from probed points. Note that bed_mesh
# on a mesh generated from probed points. Note that bed_mesh
# and bed_tilt are incompatible, both cannot be defined.
#[bed_mesh]
#speed: 50
@ -76,34 +82,31 @@
#horizontal_move_z: 5
# The height (in mm) that the head should be commanded to move to
# just prior to starting a probe operation. The default is 5.
#probe_offset:
# An X,Y point defining the probe's offset relative to the nozzle.
# This parameter must be provided.
#min_point:
# An X,Y point defining the minimum coordinate to probe on
# the bed. Note that this refers to the nozzle position,
# the bed. Note that this refers to the nozzle position,
# and take care that you do not define a point that will move
# the probe off of the bed. This parameter must be provided.
# the probe off of the bed. This parameter must be provided.
#max_point:
# An X,Y point defining the maximum coordinate to probe on
# the bed. Follow the same precautions as listed in min_point.
# the bed. Follow the same precautions as listed in min_point.
# Also note that this does not necessarily define the last point
# probed, only the maximum coordinate. This parameter must be provided.
# probed, only the maximum coordinate. This parameter must be provided.
#probe_count: 3,3
# A comma separated pair of integer values (X,Y) defining the number
# of points to probe along each axis. A single value is also valid,
# in which case that value will be for both axes. Default is 3,3
# in which case that value will be for both axes. Default is 3,3
# which probes a 3x3 grid.
#fade_start: 1.0
# The z-axis position in which to start phasing z-adjustment out.
# Default is 1.0.
#fade_end: 10.0
# The z-axis position in which phase out is complete. If this
# The z-axis position in which phase out is complete. If this
# value is less than or equal to fade_start then phasing out
# is disabled. Default is 10.0.
#split_delta_z: .025
# The amount of Z difference (in mm) along a move that will
# trigger a split. Default is .025.
# trigger a split. Default is .025.
#move_check_distance: 5.0
# The distance (in mm) along a move to check for split_delta_z.
# This is also the minimum length that a move can be split. Default
@ -112,17 +115,20 @@
# A comma separated pair of integers (X,Y) defining the number of
# points per segment to interpolate in the mesh along each axis. A
# "segment" can be defined as the space between each probed
# point. The user may enter a single value which will be applied
# point. The user may enter a single value which will be applied
# to both axes. Default is 2,2.
#algorithm: lagrange
# The interpolation algorthm to use. May be either "langrange"
# or "bicubic". This option will not affect 3x3 grids, which
# The interpolation algorthm to use. May be either "langrange"
# or "bicubic". This option will not affect 3x3 grids, which
# are forced to use lagrange sampling. Default is lagrange.
#bicubic_tension: .2
# When using the bicubic algoritm the tension parameter above
# may be applied to change the amount of slope interpolated.
# Larger numbers will increase the amount of slope, which
# results in more curvature in the mesh. Default is .2.
#manual_probe:
# See the manual_probe option of [bed_tilt] for details. The default
# is false if a [probe] config section is present and true otherwise.
# Multiple Z stepper tilt adjustment. This feature enables independent

View File

@ -187,9 +187,6 @@ class BedMeshCalibrate:
self.probe_params['max_x'] = max(points, key=lambda p: p[0])[0]
self.probe_params['min_y'] = min(points, key=lambda p: p[1])[1]
self.probe_params['max_y'] = max(points, key=lambda p: p[1])[1]
offset = parse_pair(config, ('probe_offset',))
self.probe_params['x_offset'] = offset[0]
self.probe_params['y_offset'] = offset[1]
pps = parse_pair(config, ('mesh_pps', '2'), check=False,
cast=int, minval=0)
self.probe_params['mesh_x_pps'] = pps[0]
@ -202,9 +199,6 @@ class BedMeshCalibrate:
% (self.probe_params['algo']))
self.probe_params['tension'] = config.getfloat(
'bicubic_tension', .2, minval=0., maxval=2.)
logging.debug('bed_mesh: probe/mesh parameters:')
for key, value in self.probe_params.iteritems():
logging.debug("%s : %s" % (key, value))
cmd_BED_MESH_MAP_help = "Probe the bed and serialize output"
def cmd_BED_MESH_MAP(self, params):
self.build_map = True
@ -230,7 +224,10 @@ class BedMeshCalibrate:
print_func(msg)
else:
print_func("bed_mesh: bed has not been probed")
def finalize(self, z_offset, positions):
def finalize(self, offsets, positions):
self.probe_params['x_offset'] = offsets[0]
self.probe_params['y_offset'] = offsets[1]
z_offset = offsets[2]
if self.probe_helper.get_last_xy_home_positon() is not None \
and self.z_endstop_pos is not None:
# Using probe as a virtual endstop, warn user if the
@ -271,7 +268,6 @@ class BedMeshCalibrate:
except BedMeshError as e:
raise self.gcode.error(e.message)
self.bedmesh.set_mesh(mesh)
self.print_probed_positions(logging.debug)
self.gcode.respond_info("Mesh Bed Leveling Complete")
@ -344,6 +340,9 @@ class ZMesh:
def __init__(self, params):
self.mesh_z_table = None
self.probe_params = params
logging.debug('bed_mesh: probe/mesh parameters:')
for key, value in self.probe_params.iteritems():
logging.debug("%s : %s" % (key, value))
self.mesh_x_min = params['min_x'] + params['x_offset']
self.mesh_x_max = params['max_x'] + params['x_offset']
self.mesh_y_min = params['min_y'] + params['y_offset']

View File

@ -51,7 +51,8 @@ class BedTiltCalibrate:
def get_probed_position(self):
kin = self.printer.lookup_object('toolhead').get_kinematics()
return kin.calc_position()
def finalize(self, z_offset, positions):
def finalize(self, offsets, positions):
z_offset = offsets[2]
logging.info("Calculating bed_tilt with: %s", positions)
params = { 'x_adjust': self.bedtilt.x_adjust,
'y_adjust': self.bedtilt.y_adjust,

View File

@ -33,7 +33,8 @@ class DeltaCalibrate:
def get_probed_position(self):
kin = self.printer.lookup_object('toolhead').get_kinematics()
return kin.get_stable_position()
def finalize(self, z_offset, positions):
def finalize(self, offsets, positions):
z_offset = offsets[2]
kin = self.printer.lookup_object('toolhead').get_kinematics()
logging.info("Calculating delta_calibrate with: %s", positions)
params = kin.get_calibrate_params()

View File

@ -16,6 +16,8 @@ class PrinterProbe:
def __init__(self, config):
self.printer = config.get_printer()
self.speed = config.getfloat('speed', 5.0)
self.x_offset = config.getfloat('x_offset', 0.)
self.y_offset = config.getfloat('y_offset', 0.)
self.z_offset = config.getfloat('z_offset')
# Infer Z position to move to during a probe
if config.has_section('stepper_z'):
@ -55,6 +57,8 @@ class PrinterProbe:
self.z_virtual_endstop = ProbeVirtualEndstop(
self.printer, self.mcu_probe)
return self.z_virtual_endstop
def get_offsets(self):
return self.x_offset, self.y_offset, self.z_offset
def last_home_position(self):
if self.z_virtual_endstop is None:
return None
@ -153,7 +157,7 @@ class ProbePointsHelper:
self.speed = self.lift_speed = config.getfloat('speed', 50., above=0.)
# Lookup probe object
self.probe = None
self.probe_z_offset = 0.
self.probe_offsets = (0., 0., 0.)
manual_probe = config.getboolean('manual_probe', None)
if manual_probe is None:
manual_probe = not config.has_section('probe')
@ -161,8 +165,8 @@ class ProbePointsHelper:
self.printer.try_load_module(config, 'probe')
self.probe = self.printer.lookup_object('probe')
self.lift_speed = min(self.speed, self.probe.speed)
self.probe_z_offset = self.probe.z_offset
if self.horizontal_move_z < self.probe_z_offset:
self.probe_offsets = self.probe.get_offsets()
if self.horizontal_move_z < self.probe_offsets[2]:
raise config.error("horizontal_move_z can't be less than probe's"
" z_offset in %s" % (config.get_name()))
# Internal probing state
@ -229,7 +233,7 @@ class ProbePointsHelper:
self.gcode.reset_last_position()
self.gcode.register_command('NEXT', None)
if success:
self.callback.finalize(self.probe_z_offset, self.results)
self.callback.finalize(self.probe_offsets, self.results)
def load_config(config):
return PrinterProbe(config)

View File

@ -43,7 +43,8 @@ class ZTilt:
def get_probed_position(self):
kin = self.printer.lookup_object('toolhead').get_kinematics()
return kin.calc_position()
def finalize(self, z_offset, positions):
def finalize(self, offsets, positions):
z_offset = offsets[2]
logging.info("Calculating bed tilt with: %s", positions)
params = { 'x_adjust': 0., 'y_adjust': 0., 'z_adjust': z_offset }
def adjusted_height(pos, params):