Skip to content

axis_twist_compensation: fix coordinate space mismatch in compensation lookup#7246

Open
ramonsaboya wants to merge 1 commit intoKlipper3d:masterfrom
ramonsaboya:patch-1
Open

axis_twist_compensation: fix coordinate space mismatch in compensation lookup#7246
ramonsaboya wants to merge 1 commit intoKlipper3d:masterfrom
ramonsaboya:patch-1

Conversation

@ramonsaboya
Copy link
Copy Markdown

Summary

_update_z_compensation_value looks up twist compensation using pos.test_x/pos.test_y (probe coordinates), but compensation_start_x/y and compensation_end_x/y are stored in nozzle coordinates during calibration. When a probe has a non-zero offset, the compensation is applied at the wrong physical bed location.

This affects any probe with y_offset != 0 using Y-axis twist compensation (Beacon, Cartographer, offset BLTouch, etc.). X compensation is similarly affected for probes with x_offset != 0.

Fix

Use pos.bed_x/pos.bed_y (nozzle coordinates) instead of pos.test_x/pos.test_y for the interpolation lookup, matching the coordinate space of the stored boundaries.

Evidence

  • Bed mesh diffs with Y twist compensation enabled show the compensation pattern applied at wrong Y positions — shifted by the probe's y_offset (22.9mm in my case)
  • Independently reported by another user with a Cartographer probe (y_offset ~23.7mm) in Discourse topic #21633

@KevinOConnor
Copy link
Copy Markdown
Collaborator

KevinOConnor commented Apr 8, 2026

Thanks. This code was changed recently as part of adding internal support for bed_x vs test_x. So, it's certainly possible that something broke in that process.

However, I don't see a regression when I look at the recent changes (git diff -w 46ee920b93 klippy/extras/axis_twist_compensation.py). As near as I can tell, the code was using the equivalent of test_x before and after the recent changes. Would you be able to further explain why the recent changes are not correct? I'm not understanding your distinction between "probe coordinates" and "nozzle coordinates" as both sets of coordinates are "nozzle coordinates" - the bed_xyz coordinate contains the position the toolhead is expected to contact the bed if one commands the toolhead to the given bed_xy position and then descends, while the test_xyz coordinate is the toolhead position when the given probe measurement was taken.

Separately, if you're looking for me to commit this change directly then it would need a signed-off-by line - see: https://www.klipper3d.org/CONTRIBUTING.html

-Kevin

EDIT: Or, if the current code was not correct even prior to the recent changes, then can you also explain why that is?

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.

2 participants