Skip to content

Commit

Permalink
removed CARTOGRAPHER_THRESHOLD_TEST
Browse files Browse the repository at this point in the history
  • Loading branch information
krautech committed Nov 21, 2024
1 parent 7ffc5fb commit 0edc61a
Showing 1 changed file with 0 additions and 160 deletions.
160 changes: 0 additions & 160 deletions scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,6 @@ def __init__(self, config):
self.cmd_SCANNER_CALIBRATE,
desc=self.cmd_SCANNER_CALIBRATE_help,
)
self.gcode.register_command(
sensor_name + "_THRESHOLD_TEST",
self.cmd_SCANNER_THRESHOLD_TEST,
desc=self.cmd_SCANNER_THRESHOLD_TEST_help,
)
self.gcode.register_command(
sensor_name + "_THRESHOLD_SCAN",
self.cmd_SCANNER_THRESHOLD_SCAN,
Expand Down Expand Up @@ -2198,161 +2193,6 @@ def _save_threshold(self, threshold, speed):
configfile.set("scanner", "scanner_touch_threshold", "%d" % int(threshold))
configfile.set("scanner", "scanner_touch_speed", "%d" % int(speed))

cmd_SCANNER_THRESHOLD_TEST_help = (
"Home using touch and check with coil to see how consistent it is"
)

def cmd_SCANNER_THRESHOLD_TEST(self, gcmd):
threshold = gcmd.get_int("THRESHOLD", self.detect_threshold_z)
sample_count = gcmd.get_int("SAMPLES", 5, minval=1)
skip_samples = gcmd.get_int("SKIP", 1)
lift_speed = self.get_lift_speed(gcmd)
touch_location_x = gcmd.get_float(
"TOUCH_LOCATION_X", float(self.touch_location[0])
)
touch_location_y = gcmd.get_float(
"TOUCH_LOCATION_Y", float(self.touch_location[1])
)
accel = gcmd.get_float("ACCEL", self.scanner_touch_config["accel"], minval=1)
curtime = self.printer.get_reactor().monotonic()
max_accel = self.toolhead.get_status(curtime)["max_accel"]
self._move([touch_location_x, touch_location_y, None], 40)
gcmd.respond_info(
"Threshold Testing"
" (samples=%d threshold=%d skip=%d)\n"
% (sample_count, threshold, skip_samples)
)

original_trigger_method = self.trigger_method
original_threshold = self.detect_threshold_z
self.toolhead.wait_moves()
self.check_temp(gcmd)
try:
self.set_accel(accel)
self.trigger_method = 1
self.detect_threshold_z = threshold
result = self._probe_accuracy_check(
self.scanner_touch_config["speed"],
skip_samples,
sample_count,
5,
False,
lift_speed,
)

gcmd.respond_info(
"scanner threshold results: threshold quality: %r, maximum %.6f, minimum %.6f, range %.6f, "
"average %.6f, median %.6f, standard deviation %.6f, %d/%d within 0.1 range, %d early, %d late, %d skipped"
% (
# self._get_threshold_quality(result.range_value),
"Unknown",
result.max_value,
result.min_value,
result.range_value,
result.avg_value,
result.median,
result.sigma,
result.in_range,
sample_count,
result.early,
result.late,
skip_samples,
)
)
finally:
self._zhop()
self.detect_threshold_z = original_threshold
self.trigger_method = original_trigger_method
self.set_accel(max_accel)

def _test_threshold(self, threshold, sample_count):
toolhead = self.printer.lookup_object("toolhead")
curtime = self.printer.get_reactor().monotonic()
if "z" not in toolhead.get_status(curtime)["homed_axes"]:
raise self.printer.command_error("Must home before probe")

original_trigger_method = self.trigger_method
original_threshold = self.detect_threshold_z

try:
self.detect_threshold_z = threshold

positions = []
while len(positions) < sample_count:
# Change method to touch
self.trigger_method = 1
# home
self.gcode.run_script_from_command("G28 Z")
# Change method to scan
# Move to Z = 2 to get some solid data
self.toolhead.manual_move([None, None, 2], 1500)
self.toolhead.wait_moves()
self.trigger_method = 0
# probe to get position
(dist, samples) = self._sample(self.z_settling_time, 10)
# Reset the trigger method
positions.append(dist)
self.toolhead.manual_move([None, None, 10], 1500)
self.toolhead.wait_moves()

zs = positions
max_value = max(zs)
min_value = min(zs)
range_value = max_value - min_value
avg_value = sum(zs) / len(positions)
median_ = median(zs)
in_range = 0
early = 0
late = 0

for sampl in zs:
if abs(median_ - sampl) < 0.05:
in_range += 1
elif sampl > median_:
early += 1
else:
late += 1

deviation_sum = 0
for i in range(len(zs)):
deviation_sum += pow(zs[i] - avg_value, 2.0)
sigma = (deviation_sum / len(zs)) ** 0.5

return ThresholdResults(
max_value,
min_value,
range_value,
avg_value,
median_,
sigma,
in_range,
early,
late,
len(zs),
)
except:
self.trigger_method = 0
self.gcode.run_script_from_command("G28")
return ThresholdResults(
float("inf"),
float("inf"),
float("inf"),
float("inf"),
float("inf"),
float("inf"),
0,
0,
0,
0,
)
finally:
# Change method to scan
self.trigger_method = 0
self.gcode.run_script_from_command("G28 Z")

self.detect_threshold_z = original_threshold
self.trigger_method = original_trigger_method

cmd_SCANNER_ESTIMATE_BACKLASH_help = "Estimate Z axis backlash"

def cmd_SCANNER_ESTIMATE_BACKLASH(self, gcmd):
Expand Down

0 comments on commit 0edc61a

Please sign in to comment.