Skip to content

Fix bilinear ABL grid_start probe/nozzle coordinate mixup#28380

Open
PenguinAkiko wants to merge 1 commit intoMarlinFirmware:bugfix-2.1.xfrom
PenguinAkiko:fix-abl-bilinear-coordinate-mixup
Open

Fix bilinear ABL grid_start probe/nozzle coordinate mixup#28380
PenguinAkiko wants to merge 1 commit intoMarlinFirmware:bugfix-2.1.xfrom
PenguinAkiko:fix-abl-bilinear-coordinate-mixup

Conversation

@PenguinAkiko
Copy link
Copy Markdown

Description

This PR fixes a critical coordinate-space mixup for the bedlevel.grid_start position when using Bilinear Auto Bed Leveling (AUTO_BED_LEVELING_BILINEAR).

The Problem:

The bilinear ABL probing process builds its mesh in probe-space, where abl.probe_position_lf represents the coordinate directly under the probe. However, the resulting bedlevel.grid_start value is later consumed by other systems (like bedlevel.get_z_correction()) as a motion/nozzle-space origin.

On machines with a non-zero NOZZLE_TO_PROBE_OFFSET in the XY plane, this discrepancy caused the entire leveling mesh to be incorrectly shifted by the probe's XY offset, leading to inaccurate bed compensation.

The Solution:

To resolve this, this PR introduces a centralized utility function, Probe::convert_to_nozzle_xy(), to handle the conversion from probe-space to nozzle-space. This function is now used in two key locations:

  1. In G29: The bilinear grid origin is now converted to nozzle-space before it is compared with a stored mesh or saved with bedlevel.set_grid().
  2. In M420 S2: The test pattern generator is also updated to use the same conversion, ensuring that all methods of generating a bilinear mesh use consistent, nozzle-space coordinates for the grid origin.

This change has no functional effect on setups where the XY probe offset is zero or when using NOZZLE_AS_PROBE.

Requirements

Any 3D printer configured with AUTO_BED_LEVELING_BILINEAR.

Benefits

Fixes a bug that incorrectly shifted the entire Bilinear ABL mesh by the probe's XY offset.

Configurations

No configuration files are attached as the change is hardware-independent.

To test this PR, any configuration with the following enabled will reproduce the issue and verify the fix:

// in Configuration.h
#define AUTO_BED_LEVELING_BILINEAR

// A probe with an XY offset from the nozzle
#define NOZZLE_TO_PROBE_OFFSET { 10, -5, 0 }

Related Issues

Fixes a bug that does not appear to have a corresponding open issue.

The variable abl.probe_position_lf is in probe-space, but bedlevel.grid_start is consumed as a nozzle-space origin for mesh interpolation. This caused the entire bilinear mesh to be shifted by the probe offset on machines with a non-zero XY offset.

Convert the bilinear lower-left grid origin before comparing or storing the mesh, and apply the same conversion in M420 S2.

Add Probe::convert_to_nozzle_xy() to centralize the conversion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant