Quad_gantry_level: max_adjust only guards the positive direction

Basic Information:

Printer Model: Voron 2.4
MCU / Printerboard: Octopus
Host / SBC Raspi 4
klippy.log: Not applicable - this is a code-reading finding, not an observed failure

Fill out above information and in all cases attach your klippy.log file (use zip to compress it, if too big). Pasting your printer.cfg is not needed
Be sure to check our “Knowledge Base” Category first. Most relevant items, e.g. error messages, are covered there

Describe your issue:

quad_gantry_level: max_adjust only guards the positive direction

File: klippy/extras/quad_gantry_level.py, in probe_finalize()

Code:

z_ave = sum(z_height) / len(z_height)
z_adjust = []
for z in z_height:
    z_adjust.append(z_ave - z)

adjust_max = max(z_adjust)
if adjust_max > self.max_adjust:
    raise self.gcode.error("Aborting quad_gantry_level ...")

Problem:

z_adjust is computed as (z_ave - z_height) for each stepper, where z_ave is
the mean of z_height. The four values therefore always sum to exactly zero.

The guard tests only max(z_adjust), so it constrains the largest POSITIVE
adjustment and never examines the largest negative one.

Because the values sum to zero, for N=4 the most negative element is bounded
by -3 * max(z_adjust). The guard therefore permits a negative adjustment of
up to 3 * max_adjust.

Example (max_adjust = 10):

z_adjust = [-30.0, +10.0, +10.0, +10.0]
max(z_adjust) = 10.0  ->  not > 10.0  ->  passes
one gantry corner is then driven down 30 mm

Impact:

max_adjust is a safety limit intended to stop a bad probe result driving the
gantry into the bed. In the negative direction it under-protects by 3x. It
only bites when probing returns a wildly wrong value, which is exactly the
condition the guard exists for.

Suggested fix:

adjust_max = max(abs(z) for z in z_adjust)

or test max() and min() separately so the error message can report which
stepper and which direction.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.