bed_mesh: enable relative offset bed meshes (#1323)

Adds parameter for bed meshes to be adjusted relative to a probed point
during calibration. This allows the probe z offset to be ignored for
probes that are not stable over time (for example, the thermal drift of
inductive probes). An endstop other than the probe is then necessary to
determine the bed-nozzle offset.

Signed-off-by: Matt Baker <baker.matt.j@gmail.com>
This commit is contained in:
Matt Baker 2019-03-21 07:39:22 -07:00 committed by KevinOConnor
parent 6f91574cd9
commit f2fbe98454
2 changed files with 21 additions and 2 deletions

View File

@ -226,6 +226,10 @@
# may be applied to change the amount of slope interpolated. # may be applied to change the amount of slope interpolated.
# Larger numbers will increase the amount of slope, which # Larger numbers will increase the amount of slope, which
# results in more curvature in the mesh. Default is .2. # results in more curvature in the mesh. Default is .2.
#relative_reference_index:
# A point index in the mesh to reference all z values to. Enabling
# this parameter produces a mesh relative to the probed z position
# at the provided index.
# Tool to help adjust bed leveling screws. One may define a # Tool to help adjust bed leveling screws. One may define a

View File

@ -186,6 +186,7 @@ class BedMeshCalibrate:
self.printer = config.get_printer() self.printer = config.get_printer()
self.name = config.get_name() self.name = config.get_name()
self.radius = None self.radius = None
self.relative_reference_index = None
self.bedmesh = bedmesh self.bedmesh = bedmesh
self.probed_z_table = None self.probed_z_table = None
self.build_map = False self.build_map = False
@ -267,8 +268,17 @@ class BedMeshCalibrate:
points.append((pos_x, pos_y)) points.append((pos_x, pos_y))
pos_y += y_dist pos_y += y_dist
logging.info('bed_mesh: generated points') logging.info('bed_mesh: generated points')
for p in points: for i, p in enumerate(points):
logging.info("(%.1f, %.1f)" % (p[0], p[1])) logging.info("%d: (%.1f, %.1f)" % (i, p[0], p[1]))
rref_index = config.get('relative_reference_index', None)
if rref_index is not None:
rref_index = int(rref_index)
if rref_index < 0 or rref_index >= len(points):
raise config.error("bed_mesh: relative reference index %d "
"is out of bounds" % (rref_index))
logging.info("bed_mesh: relative_reference_index %d is (%.2f, %.2f)"
% (rref_index, points[rref_index][0], points[rref_index][1]))
self.relative_reference_index = rref_index
return points return points
def _init_probe_params(self, config, points): def _init_probe_params(self, config, points):
self.probe_params['min_x'] = min(points, key=lambda p: p[0])[0] self.probe_params['min_x'] = min(points, key=lambda p: p[0])[0]
@ -411,6 +421,11 @@ class BedMeshCalibrate:
x_cnt = self.probe_params['x_count'] x_cnt = self.probe_params['x_count']
y_cnt = self.probe_params['y_count'] y_cnt = self.probe_params['y_count']
if self.relative_reference_index is not None:
# zero out probe z offset and
# set offset relative to reference index
z_offset = positions[self.relative_reference_index][2]
self.probed_z_table = [] self.probed_z_table = []
row = [] row = []
prev_pos = positions[0] prev_pos = positions[0]