Automatic bed mesh dimensions

Hi,
I think about implementing a feature so [bed_mesh] will have an option margin=... which will fill in missing mesh_min and mesh_max parameters, respecting printer dimensions, probe offset and that margin.
For further implementation the margin could be split into margin_x and margin_y or even comma-separated margins.

Do you think that feature will be useful, and if it will be likely approved to mainline klipper?

Generally, I’d appreciate an improvement here, as many users struggle with the definition. I guess the challenge will be:

  • Setting up the change in a way that it will not be literally breaking.
  • Considering all possible edge cases like IDEX, etc.

Thanks for the reply. Sure, I’m planning it to be optional, so only when user doesn’t provide mesh_min, mest_max, it will be considered (I think that’s the best option).
As with the edge cases, you’re right, I need to check the kinematics and edge cases for that. But I guess that could be patched later if any edge case appear.

Certain elder Klipper divine entities, whose names shall not be spoken aloud, might consider this heresy, so you should not think about it.

I already wrote my thoughts on discord, but I will write them here again:

  • In general I like the idea, a lot of users struggle with mesh parameters and probe offsets. And the “move out of range” error they get doesn’t really explain the issue very well. So automatic calculation of the mesh boundries would be a great feature.
  • I’m not sure about margin as a option, especially with adaptive_margin that adds additional space around adaptive meshes. Maybe bed_min and bed_max? But it could be to close to mesh_min/mesh_max.

Considering the points above, I think it is worth discussing if it wont be beneficial to implement automatic check in general, instead of running into “move out of range” errors.
So when mesh_min cant be reached, a reachable point is used instead?

I very much like Klipper’s clean philosophy of not “interpreting”, “second guessing”, or silently ignoring wrong input. Simplifying the process of getting it right and guiding users is something I very much appreciate. I would rather not deviate from the above general philosophy.

1 Like

Maybe a viable solution may be so klipper throws a warning when booting with a faulty bed mesh, something like:
bed_mesh: mesh_max Y coordinate 260 out of range, mesh may fail. Consider values below 235
additionally to the new approach of not specifying any meshing coordinates, just one margin value

ok, I can agree with that.
But then I would suggest a check before moving, if all the mesh points are reachable and a helpful error pointing to the issue. So there is at least a chance users will read the error and understand the issue.