probe: Add z_offset parameter

Move the probe_z_offset parameter from delta_calibrate and
bed_tilt_calibrate to a z_offset parameter within the probe config
section.  It's easier to understand the z offset setting when it is in
the probe config section.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-03-17 14:00:37 -04:00
parent c95cc3fb66
commit e3f9ff6701
5 changed files with 15 additions and 14 deletions

View File

@ -121,9 +121,6 @@ radius: 50
#horizontal_move_z: 5 #horizontal_move_z: 5
# The height (in mm) that the head should be commanded to move to # The height (in mm) that the head should be commanded to move to
# just prior to starting a probe operation. The default is 5. # just prior to starting a probe operation. The default is 5.
#probe_z_offset: 0
# The Z height (in mm) of the head when the probe triggers. The
# default is 0.
#manual_probe: #manual_probe:
# If true, then DELTA_CALIBRATE will perform manual probing. If # If true, then DELTA_CALIBRATE will perform manual probing. If
# false, then a PROBE command will be run at each probe # false, then a PROBE command will be run at each probe

View File

@ -17,6 +17,9 @@
#[probe] #[probe]
#pin: ar15 #pin: ar15
# Probe detection pin. This parameter must be provided. # Probe detection pin. This parameter must be provided.
#z_offset:
# The distance (in mm) between the bed and the nozzle when the probe
# triggers. This parameter must be provided.
#speed: 5.0 #speed: 5.0
# Speed (in mm/s) of the Z axis when probing. The default is 5mm/s. # Speed (in mm/s) of the Z axis when probing. The default is 5mm/s.
#activate_gcode: #activate_gcode:
@ -52,9 +55,6 @@
#horizontal_move_z: 5 #horizontal_move_z: 5
# The height (in mm) that the head should be commanded to move to # The height (in mm) that the head should be commanded to move to
# just prior to starting a probe operation. The default is 5. # just prior to starting a probe operation. The default is 5.
#probe_z_offset: 0
# The Z height (in mm) of the head when the probe triggers. The
# default is 0.
#manual_probe: #manual_probe:
# If true, then BED_TILT_CALIBRATE will perform manual probing. If # If true, then BED_TILT_CALIBRATE will perform manual probing. If
# false, then a PROBE command will be run at each probe # false, then a PROBE command will be run at each probe

View File

@ -43,7 +43,6 @@ class BedTiltCalibrate:
raise config.error("Need at least 3 points for bed_tilt_calibrate") raise config.error("Need at least 3 points for bed_tilt_calibrate")
self.speed = config.getfloat('speed', 50., above=0.) self.speed = config.getfloat('speed', 50., above=0.)
self.horizontal_move_z = config.getfloat('horizontal_move_z', 5.) self.horizontal_move_z = config.getfloat('horizontal_move_z', 5.)
self.probe_z_offset = config.getfloat('probe_z_offset', 0.)
self.z_position_endstop = None self.z_position_endstop = None
if config.has_section('stepper_z'): if config.has_section('stepper_z'):
zconfig = config.getsection('stepper_z') zconfig = config.getsection('stepper_z')
@ -64,11 +63,11 @@ class BedTiltCalibrate:
def get_position(self): def get_position(self):
kin = self.printer.lookup_object('toolhead').get_kinematics() kin = self.printer.lookup_object('toolhead').get_kinematics()
return kin.get_position() return kin.get_position()
def finalize(self, positions): def finalize(self, z_offset, positions):
logging.info("Calculating bed_tilt with: %s", positions) logging.info("Calculating bed_tilt with: %s", positions)
params = { 'x_adjust': self.bedtilt.x_adjust, params = { 'x_adjust': self.bedtilt.x_adjust,
'y_adjust': self.bedtilt.y_adjust, 'y_adjust': self.bedtilt.y_adjust,
'z_adjust': self.probe_z_offset } 'z_adjust': z_offset }
logging.info("Initial bed_tilt parameters: %s", params) logging.info("Initial bed_tilt parameters: %s", params)
def adjusted_height(pos, params): def adjusted_height(pos, params):
x, y, z = pos x, y, z = pos
@ -85,7 +84,7 @@ class BedTiltCalibrate:
for pos in positions: for pos in positions:
logging.info("orig: %s new: %s", adjusted_height(pos, params), logging.info("orig: %s new: %s", adjusted_height(pos, params),
adjusted_height(pos, new_params)) adjusted_height(pos, new_params))
z_diff = new_params['z_adjust'] - self.probe_z_offset z_diff = new_params['z_adjust'] - z_offset
if self.z_position_endstop is not None: if self.z_position_endstop is not None:
# Cartesian style robot # Cartesian style robot
z_extra = "" z_extra = ""

View File

@ -14,7 +14,6 @@ class DeltaCalibrate:
self.radius = config.getfloat('radius', above=0.) self.radius = config.getfloat('radius', above=0.)
self.speed = config.getfloat('speed', 50., above=0.) self.speed = config.getfloat('speed', 50., above=0.)
self.horizontal_move_z = config.getfloat('horizontal_move_z', 5.) self.horizontal_move_z = config.getfloat('horizontal_move_z', 5.)
self.probe_z_offset = config.getfloat('probe_z_offset', 0.)
self.manual_probe = config.getboolean('manual_probe', None) self.manual_probe = config.getboolean('manual_probe', None)
if self.manual_probe is None: if self.manual_probe is None:
self.manual_probe = not config.has_section('probe') self.manual_probe = not config.has_section('probe')
@ -38,7 +37,7 @@ class DeltaCalibrate:
def get_position(self): def get_position(self):
kin = self.printer.lookup_object('toolhead').get_kinematics() kin = self.printer.lookup_object('toolhead').get_kinematics()
return kin.get_stable_position() return kin.get_stable_position()
def finalize(self, positions): def finalize(self, z_offset, positions):
kin = self.printer.lookup_object('toolhead').get_kinematics() kin = self.printer.lookup_object('toolhead').get_kinematics()
logging.info("Calculating delta_calibrate with: %s", positions) logging.info("Calculating delta_calibrate with: %s", positions)
params = kin.get_calibrate_params() params = kin.get_calibrate_params()
@ -49,7 +48,7 @@ class DeltaCalibrate:
total_error = 0. total_error = 0.
for spos in positions: for spos in positions:
x, y, z = delta.get_position_from_stable(spos, params) x, y, z = delta.get_position_from_stable(spos, params)
total_error += (z - self.probe_z_offset)**2 total_error += (z - z_offset)**2
return total_error return total_error
new_params = mathutil.coordinate_descent( new_params = mathutil.coordinate_descent(
adj_params, params, delta_errorfunc) adj_params, params, delta_errorfunc)

View File

@ -16,6 +16,7 @@ class PrinterProbe:
def __init__(self, config): def __init__(self, config):
self.printer = config.get_printer() self.printer = config.get_printer()
self.speed = config.getfloat('speed', 5.0) self.speed = config.getfloat('speed', 5.0)
self.z_offset = config.getfloat('z_offset')
# Infer Z position to move to during a probe # Infer Z position to move to during a probe
if config.has_section('stepper_z'): if config.has_section('stepper_z'):
zconfig = config.getsection('stepper_z') zconfig = config.getsection('stepper_z')
@ -137,6 +138,7 @@ class ProbePointsHelper:
self.probe_points = probe_points self.probe_points = probe_points
self.horizontal_move_z = horizontal_move_z self.horizontal_move_z = horizontal_move_z
self.speed = speed self.speed = speed
self.manual_probe = manual_probe
self.callback = callback self.callback = callback
self.toolhead = self.printer.lookup_object('toolhead') self.toolhead = self.printer.lookup_object('toolhead')
self.results = [] self.results = []
@ -177,7 +179,11 @@ class ProbePointsHelper:
self.gcode.reset_last_position() self.gcode.reset_last_position()
self.gcode.register_command('NEXT', None) self.gcode.register_command('NEXT', None)
if success: if success:
self.callback.finalize(self.results) z_offset = 0.
if not self.manual_probe:
probe = self.printer.lookup_object('probe')
z_offset = probe.z_offset
self.callback.finalize(z_offset, self.results)
def load_config(config): def load_config(config):
return PrinterProbe(config) return PrinterProbe(config)