probe: Support manual probing at runtime

Don't require the config file to specify manual probing.  Instead,
allow the user to select manual probing on each ProbePointsHelper
invocation.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-09-26 13:07:18 -04:00 committed by KevinOConnor
parent 0e9b8abde2
commit 33887b8c39
10 changed files with 41 additions and 54 deletions

View File

@ -121,14 +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.
#manual_probe:
# If true, then DELTA_CALIBRATE will perform manual probing. If
# false, then a PROBE command will be run at each probe
# point. Manual probing is accomplished by manually jogging the Z
# position of the print head at each probe point and then issuing a
# NEXT extended g-code command to record the position at that
# point. The default is false if a [probe] config section is present
# and true otherwise.
#samples: 1 #samples: 1
# The number of times to probe each point. The probed z-values # The number of times to probe each point. The probed z-values
# will be averaged. The default is to probe 1 time. # will be averaged. The default is to probe 1 time.

View File

@ -63,14 +63,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.
#manual_probe:
# If true, then BED_TILT_CALIBRATE will perform manual probing. If
# false, then a PROBE command will be run at each probe
# point. Manual probing is accomplished by manually jogging the Z
# position of the print head at each probe point and then issuing a
# NEXT extended g-code command to record the position at that
# point. The default is false if a [probe] config section is present
# and true otherwise.
#samples: 1 #samples: 1
# The number of times to probe each point. The probed z-values # The number of times to probe each point. The probed z-values
# will be averaged. The default is to probe 1 time. # will be averaged. The default is to probe 1 time.
@ -140,9 +132,6 @@
# 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.
#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 # Multiple Z stepper tilt adjustment. This feature enables independent

View File

@ -46,7 +46,7 @@ eliminates error introduced by the probe.
To perform the basic probe, make sure the config has a To perform the basic probe, make sure the config has a
[delta_calibrate] section defined and run: [delta_calibrate] section defined and run:
``` ```
DELTA_CALIBRATE DELTA_CALIBRATE METHOD=manual
``` ```
After probing the seven points new delta parameters will be After probing the seven points new delta parameters will be
calculated. Save and apply these parameters by running: calculated. Save and apply these parameters by running:

View File

@ -147,8 +147,9 @@ enabled:
The following commands are available when the "delta_calibrate" config The following commands are available when the "delta_calibrate" config
section is enabled: section is enabled:
- `DELTA_CALIBRATE`: This command will probe seven points on the bed - `DELTA_CALIBRATE [METHOD=manual]`: This command will probe seven
and recommend updated endstop positions, tower angles, and radius. points on the bed and recommend updated endstop positions, tower
angles, and radius.
- `NEXT`: If manual bed probing is enabled, then one can use this - `NEXT`: If manual bed probing is enabled, then one can use this
command to move to the next probing point during a DELTA_CALIBRATE command to move to the next probing point during a DELTA_CALIBRATE
operation. operation.
@ -159,8 +160,9 @@ section is enabled:
The following commands are available when the "bed_tilt" config The following commands are available when the "bed_tilt" config
section is enabled: section is enabled:
- `BED_TILT_CALIBRATE`: This command will probe the points specified - `BED_TILT_CALIBRATE [METHOD=manual]`: This command will probe the
in the config and then recommend updated x and y tilt adjustments. points specified in the config and then recommend updated x and y
tilt adjustments.
- `NEXT`: If manual bed probing is enabled, then one can use this - `NEXT`: If manual bed probing is enabled, then one can use this
command to move to the next probing point during a command to move to the next probing point during a
BED_TILT_CALIBRATE operation. BED_TILT_CALIBRATE operation.
@ -169,9 +171,13 @@ section is enabled:
The following commands are available when the "bed_mesh" config The following commands are available when the "bed_mesh" config
section is enabled: section is enabled:
- `BED_MESH_CALIBRATE`: This command probes the bed using generated - `BED_MESH_CALIBRATE [METHOD=manual]`: This command probes the bed
points specified by the parameters in the config. After probing, using generated points specified by the parameters in the
a mesh is generated and z-movement is adjusted according to the mesh. config. After probing, a mesh is generated and z-movement is
adjusted according to the mesh.
- `NEXT`: If manual bed probing is enabled, then one can use this
command to move to the next probing point during a
BED_MESH_CALIBRATE operation.
- `BED_MESH_OUTPUT`: This command outputs the current probed z values - `BED_MESH_OUTPUT`: This command outputs the current probed z values
and current mesh values to the terminal. and current mesh values to the terminal.
- `BED_MESH_MAP`: This command probes the bed in a similar fashion - `BED_MESH_MAP`: This command probes the bed in a similar fashion

View File

@ -204,15 +204,15 @@ class BedMeshCalibrate:
cmd_BED_MESH_MAP_help = "Probe the bed and serialize output" cmd_BED_MESH_MAP_help = "Probe the bed and serialize output"
def cmd_BED_MESH_MAP(self, params): def cmd_BED_MESH_MAP(self, params):
self.build_map = True self.build_map = True
self.start_calibration() self.start_calibration(params)
cmd_BED_MESH_CALIBRATE_help = "Perform Mesh Bed Leveling" cmd_BED_MESH_CALIBRATE_help = "Perform Mesh Bed Leveling"
def cmd_BED_MESH_CALIBRATE(self, params): def cmd_BED_MESH_CALIBRATE(self, params):
self.build_map = False self.build_map = False
self.start_calibration() self.start_calibration(params)
def start_calibration(self): def start_calibration(self, params):
self.bedmesh.set_mesh(None) self.bedmesh.set_mesh(None)
self.gcode.run_script_from_command("G28") self.gcode.run_script_from_command("G28")
self.probe_helper.start_probe() self.probe_helper.start_probe(params)
def print_probed_positions(self, print_func): def print_probed_positions(self, print_func):
if self.probed_z_table is not None: if self.probed_z_table is not None:
msg = "Mesh Leveling Probed Z positions:\n" msg = "Mesh Leveling Probed Z positions:\n"

View File

@ -56,7 +56,7 @@ class BedTiltCalibrate:
cmd_BED_TILT_CALIBRATE_help = "Bed tilt calibration script" cmd_BED_TILT_CALIBRATE_help = "Bed tilt calibration script"
def cmd_BED_TILT_CALIBRATE(self, params): def cmd_BED_TILT_CALIBRATE(self, params):
self.gcode.run_script_from_command("G28") self.gcode.run_script_from_command("G28")
self.probe_helper.start_probe() self.probe_helper.start_probe(params)
def probe_finalize(self, offsets, positions): def probe_finalize(self, offsets, positions):
z_offset = offsets[2] z_offset = offsets[2]
logging.info("Calculating bed_tilt with: %s", positions) logging.info("Calculating bed_tilt with: %s", positions)

View File

@ -275,7 +275,7 @@ class DeltaCalibrate:
cmd_DELTA_CALIBRATE_help = "Delta calibration script" cmd_DELTA_CALIBRATE_help = "Delta calibration script"
def cmd_DELTA_CALIBRATE(self, params): def cmd_DELTA_CALIBRATE(self, params):
self.gcode.run_script_from_command("G28") self.gcode.run_script_from_command("G28")
self.probe_helper.start_probe() self.probe_helper.start_probe(params)
def do_extended_calibration(self): def do_extended_calibration(self):
# Extract distance positions # Extract distance positions
if len(self.delta_analyze_entry) <= 1: if len(self.delta_analyze_entry) <= 1:

View File

@ -155,23 +155,10 @@ class ProbePointsHelper:
config.get_name())) config.get_name()))
self.horizontal_move_z = config.getfloat('horizontal_move_z', 5.) self.horizontal_move_z = config.getfloat('horizontal_move_z', 5.)
self.speed = self.lift_speed = config.getfloat('speed', 50., above=0.) self.speed = self.lift_speed = config.getfloat('speed', 50., above=0.)
# Lookup probe object
self.probe = None
self.probe_offsets = (0., 0., 0.) self.probe_offsets = (0., 0., 0.)
self.samples = config.getint('samples', 1, minval=1) self.samples = config.getint('samples', 1, minval=1)
self.sample_retract_dist = config.getfloat( self.sample_retract_dist = config.getfloat(
'sample_retract_dist', 2., above=0.) 'sample_retract_dist', 2., above=0.)
manual_probe = config.getboolean('manual_probe', None)
if manual_probe is None:
manual_probe = not config.has_section('probe')
if not manual_probe:
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_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 # Internal probing state
self.results = [] self.results = []
self.busy = False self.busy = False
@ -179,10 +166,10 @@ class ProbePointsHelper:
def get_lift_speed(self): def get_lift_speed(self):
return self.lift_speed return self.lift_speed
def get_last_xy_home_positon(self): def get_last_xy_home_positon(self):
if self.probe is not None: probe = self.printer.lookup_object('probe', None)
return self.probe.last_home_position() if probe is None:
else:
return None return None
return probe.last_home_position()
def _lift_z(self, z_pos, add=False, speed=None): def _lift_z(self, z_pos, add=False, speed=None):
# Lift toolhead # Lift toolhead
curpos = self.toolhead.get_position() curpos = self.toolhead.get_position()
@ -232,15 +219,28 @@ class ProbePointsHelper:
avg_pos = [sum([pos[i] for pos in positions]) / self.samples avg_pos = [sum([pos[i] for pos in positions]) / self.samples
for i in range(3)] for i in range(3)]
self.results.append(avg_pos) self.results.append(avg_pos)
def start_probe(self): def start_probe(self, params):
# Begin probing # Lookup objects
self.toolhead = self.printer.lookup_object('toolhead') self.toolhead = self.printer.lookup_object('toolhead')
self.gcode = self.printer.lookup_object('gcode') self.gcode = self.printer.lookup_object('gcode')
probe = self.printer.lookup_object('probe', None)
method = self.gcode.get_str('METHOD', params, 'automatic').lower()
if probe is not None and method == 'automatic':
self.lift_speed = min(self.speed, probe.speed)
self.probe_offsets = probe.get_offsets()
if self.horizontal_move_z < self.probe_offsets[2]:
raise self.gcode.error("horizontal_move_z can't be less than"
" probe's z_offset")
else:
probe = None
self.lift_speed = self.speed
self.probe_offsets = (0., 0., 0.)
# Start probe
self.results = [] self.results = []
self.busy = True self.busy = True
self._lift_z(self.horizontal_move_z, speed=self.speed) self._lift_z(self.horizontal_move_z, speed=self.speed)
self._move_next() self._move_next()
if self.probe is None: if probe is None:
# Setup for manual probing # Setup for manual probing
self.gcode.register_command('NEXT', None) self.gcode.register_command('NEXT', None)
self.gcode.register_command('NEXT', self.cmd_NEXT, self.gcode.register_command('NEXT', self.cmd_NEXT,

View File

@ -38,7 +38,7 @@ class QuadGantryLevel:
self.z_steppers = z_steppers self.z_steppers = z_steppers
cmd_QUAD_GANTRY_LEVEL_help = "Conform a moving, twistable gantry to the shape of a stationary bed" cmd_QUAD_GANTRY_LEVEL_help = "Conform a moving, twistable gantry to the shape of a stationary bed"
def cmd_QUAD_GANTRY_LEVEL(self, params): def cmd_QUAD_GANTRY_LEVEL(self, params):
self.probe_helper.start_probe() self.probe_helper.start_probe(params)
def probe_finalize(self, offsets, positions): def probe_finalize(self, offsets, positions):
logging.info("quad_gantry_level Calculating gantry geometry with: %s", positions) logging.info("quad_gantry_level Calculating gantry geometry with: %s", positions)
p1 = [positions[0][0] + offsets[0],positions[0][2]] p1 = [positions[0][0] + offsets[0],positions[0][2]]

View File

@ -39,7 +39,7 @@ class ZTilt:
self.z_steppers = z_steppers self.z_steppers = z_steppers
cmd_Z_TILT_ADJUST_help = "Adjust the Z tilt" cmd_Z_TILT_ADJUST_help = "Adjust the Z tilt"
def cmd_Z_TILT_ADJUST(self, params): def cmd_Z_TILT_ADJUST(self, params):
self.probe_helper.start_probe() self.probe_helper.start_probe(params)
def probe_finalize(self, offsets, positions): def probe_finalize(self, offsets, positions):
z_offset = offsets[2] z_offset = offsets[2]
logging.info("Calculating bed tilt with: %s", positions) logging.info("Calculating bed tilt with: %s", positions)