manual_probe: Introduce new create_probe_result() helper function
Add a new create_probe_result() helper function that can generate a ProbeResult using a toolhead position and a set of probe offsets. Use this helper in other modules. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
1 parent
4046b34a7b
commit
7f5e918331
4 files changed
+18
-16
No files matched your search
@@ -5,7 +5,7 @@
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
import logging, math
|
||||
import mcu
|
||||
from . import probe, trigger_analog, load_cell, hx71x, ads1220
|
||||
from . import probe, manual_probe, trigger_analog, load_cell, hx71x, ads1220
|
||||
|
||||
np = None # delay NumPy import until configuration time
|
||||
|
||||
@@ -426,7 +426,8 @@ class TapSession:
|
||||
# probe until a single good sample is returned or retries are exhausted
|
||||
def run_probe(self, gcmd):
|
||||
epos, is_good = self._tapping_move.run_tap(gcmd)
|
||||
res = self._probe_offsets.create_probe_result(epos)
|
||||
offsets = self._probe_offsets.get_offsets()
|
||||
res = manual_probe.create_probe_result(epos, offsets)
|
||||
self._results.append(res)
|
||||
|
||||
def pull_probed_results(self):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Helper script for manual z height probing
|
||||
#
|
||||
# Copyright (C) 2019-2025 Kevin O'Connor <kevin@koconnor.net>
|
||||
# Copyright (C) 2019-2026 Kevin O'Connor <kevin@koconnor.net>
|
||||
#
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
import logging, bisect, collections
|
||||
@@ -14,6 +14,13 @@ import logging, bisect, collections
|
||||
ProbeResult = collections.namedtuple('probe_result', [
|
||||
'bed_x', 'bed_y', 'bed_z', 'test_x', 'test_y', 'test_z'])
|
||||
|
||||
# Helper to create a ProbeResult from a test position and probe offsets
|
||||
def create_probe_result(test_pos, offsets=(0., 0., 0.)):
|
||||
x_offset, y_offset, z_offset = offsets
|
||||
return ProbeResult(
|
||||
test_pos[0]+x_offset, test_pos[1]+y_offset, test_pos[2]-z_offset,
|
||||
test_pos[0], test_pos[1], test_pos[2])
|
||||
|
||||
# Helper to lookup the Z stepper config section
|
||||
def lookup_z_endstop_config(config):
|
||||
if config.has_section('stepper_z'):
|
||||
@@ -283,7 +290,7 @@ class ManualProbeHelper:
|
||||
mpresult = None
|
||||
if success:
|
||||
kin_pos = self.get_kinematics_pos()
|
||||
mpresult = ProbeResult(*(kin_pos[:3] + kin_pos[:3]))
|
||||
mpresult = create_probe_result(kin_pos)
|
||||
self.finalize_callback(mpresult)
|
||||
|
||||
def load_config(config):
|
||||
|
||||
@@ -270,7 +270,8 @@ class HomingViaProbeHelper:
|
||||
speed = self.param_helper.get_probe_params(gcmd)['probe_speed']
|
||||
phoming = self.printer.lookup_object('homing')
|
||||
ppos = phoming.probing_move(self.mcu_probe, pos, speed)
|
||||
res = self.probe_offsets.create_probe_result(ppos)
|
||||
offsets = self.probe_offsets.get_offsets()
|
||||
res = manual_probe.create_probe_result(ppos, offsets)
|
||||
self.results.append(res)
|
||||
def pull_probed_results(self):
|
||||
res = self.results
|
||||
@@ -430,10 +431,6 @@ class ProbeOffsetsHelper:
|
||||
self.z_offset = config.getfloat('z_offset')
|
||||
def get_offsets(self, gcmd=None):
|
||||
return self.x_offset, self.y_offset, self.z_offset
|
||||
def create_probe_result(self, test_pos):
|
||||
return manual_probe.ProbeResult(
|
||||
test_pos[0]+self.x_offset, test_pos[1]+self.y_offset,
|
||||
test_pos[2]-self.z_offset, test_pos[0], test_pos[1], test_pos[2])
|
||||
|
||||
|
||||
######################################################################
|
||||
|
||||
@@ -357,7 +357,7 @@ class EddyGatherSamples:
|
||||
"probe_eddy_current sensor outage")
|
||||
if mcu.is_fileoutput():
|
||||
# In debugging mode - just create dummy response
|
||||
dummy_pr = manual_probe.ProbeResult(0., 0., 0., 0., 0., 0.)
|
||||
dummy_pr = manual_probe.create_probe_result((0., 0., 0.,))
|
||||
self._analysis_results.append((dummy_pr, None))
|
||||
self._probe_requests.pop(0)
|
||||
continue
|
||||
@@ -384,10 +384,8 @@ def probe_results_from_avg(measures, toolhead_pos, calibration, offsets):
|
||||
sensor_z = calibration.freq_to_height(freq_avg)
|
||||
if sensor_z <= -OUT_OF_RANGE or sensor_z >= OUT_OF_RANGE:
|
||||
raise cmderr("probe_eddy_current sensor not in valid range")
|
||||
return manual_probe.ProbeResult(
|
||||
toolhead_pos[0] + offsets[0], toolhead_pos[1] + offsets[1],
|
||||
toolhead_pos[2] - sensor_z,
|
||||
toolhead_pos[0], toolhead_pos[1], toolhead_pos[2])
|
||||
return manual_probe.create_probe_result(toolhead_pos,
|
||||
(offsets[0], offsets[1], sensor_z))
|
||||
|
||||
MAX_VALID_RAW_VALUE=0x03ffffff
|
||||
|
||||
@@ -570,8 +568,7 @@ class EddyTap:
|
||||
self._validate_samples_time(measures, start_time, end_time)
|
||||
pos_time = self._pull_tap_time(measures)
|
||||
trig_pos = self._lookup_toolhead_pos(pos_time)
|
||||
return manual_probe.ProbeResult(trig_pos[0], trig_pos[1], trig_pos[2],
|
||||
trig_pos[0], trig_pos[1], trig_pos[2])
|
||||
return manual_probe.create_probe_result(trig_pos)
|
||||
# Probe session interface
|
||||
def start_probe_session(self, gcmd):
|
||||
self._prep_trigger_analog_tap(gcmd)
|
||||
|
||||
Reference in new issue
Block a user