Fix rotation point for transformation matrix for auto bed leveling #540
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There is a bug in auto bed leveling logic. After measurement bed plane we have to adjust current z position from bed plane at zero point, not at current position point because transformation matrix performs rotation through zero point.
For example, old behavior of G32:
10:17:37.527: Z-probe:20.00 X:20.00 Y:20.00
10:17:55.232: Z-probe:18.95 X:160.00 Y:20.00
10:18:12.466: Z-probe:19.05 X:100.00 Y:145.00 ; This is measured point. We can be sure that bed is 19.05mm far away at this position.
10:18:17.583: plane: a = -0.0075 b = -0.0025 c = 20.1978
10:18:17.592: Transformation matrix: 0.999972 0.000000 0.007471 -0.000019 0.999997 0.002504 -0.007471 -0.002504 0.999969
10:18:17.595: CurrentZ:18.88 atZ:23.00
10:18:18.047: Info:Autoleveling enabled
10:18:18.049: X:100.14 Y:145.04 Z:17.764 E:0.0000 ; Wow, we measured this point few lines before, and we got 19.05 as z-level, so after all transformations here should be 19.05 at Z
New behavior:
10:33:46.499: Z-probe:25.97 X:20.00 Y:20.00
10:34:10.184: Z-probe:24.93 X:160.00 Y:20.00
10:34:33.396: Z-probe:25.05 X:100.00 Y:145.00 ; Same place, measured Z here is true distance (regardless that is 5 mm greater than in previous example)
10:34:41.512: plane: a = -0.0074 b = -0.0023 c = 26.1634
10:34:41.520: Transformation matrix: 0.999973 0.000000 0.007410 -0.000017 0.999997 0.002342 -0.007410 -0.002342 0.999970
10:34:41.522: CurrentZ:26.16 atZ:28.95 ; Actually it is CurrentZ before transformation matrix applied
10:34:41.978: Info:Autoleveling enabled
10:35:03.686: X:100.19 Y:145.06 Z:25.081 E:0.0000 Now here after applying transformation we have same Z as measured before