Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bed_mesh: Implement adaptive bed mesh #6461

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 58 additions & 2 deletions docs/Bed_Mesh.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,14 +370,68 @@ are identified in green.

![bedmesh_interpolated](img/bedmesh_faulty_regions.svg)

### Adaptive Meshes

Adaptive bed meshing is a way to speed up the bed mesh generation by only probing
the area of the bed used by the objects being printed. When used, the method will
automatically adjust the mesh parameters based on the area occupied by the defined
print objects.

Copy link

@kyleisah kyleisah Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
It is important to consider that adaptive bed meshing is best implemented on machines that can normally probe the entire bed and achieve a maximum variance less than or equal to 1 layer height. Machines that have mechanical issues that a full bed mesh normally compensates for may have undesirable results when attempting print moves **outside** of the detected print object area. If a full bed mesh on your machine typically has a variance greater than 1 layer height, caution must be taken when attempting print moves outside of the meshed area.
Due to the nature of using an adapted bed mesh, it is not recommended that a user load a saved adaptive mesh to re-use for printing. Adaptive bed meshing is best utilized by generating a new mesh prior to every print.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kyleisah, I have added this to the documentation in a reworded/reorg'ed form.

@Arksine, I would appreciate a review of the new documentation section from you, as well?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated documentation looks good to me. This also adds context to your previous PR regarding BED_MESH_CLEAR. I think we should disable autosave when adaptive is enabled. It will be relatively easy, just a few lines of code. I'll make the recommendations here, but I can submit it as a follow-up PR if you prefer not to merge them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated documentation looks good to me. This also adds context to your previous PR regarding BED_MESH_CLEAR. I think we should disable autosave when adaptive is enabled. It will be relatively easy, just a few lines of code. I'll make the recommendations here, but I can submit it as a follow-up PR if you prefer not to merge them.

Yes, please. The recommendation would be appreciated. I actually do prefer to merge them since doing them separately will introduce a window during which it would be possible to save an adapted mesh. Plus, I was already thinking along the lines of restricting it in the actual code. Just didn't know exactly how (due to the issues with my previous PR).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the review point here. Hopefully its clear enough, Github doesn't seem to allow suggestions outside of the modified code. Essentially we just set self._profile_name = None right before returning True from set_adaptive_mesh(). Then we modify the last line probe_finalize() to prevent from sending the None value save_profile().

The adapted mesh area will be computed from the area defined by the boundaries of all
the defined print objects so it covers every object, including any margins defined in
the configuration. After the area is computed, the number of probe points will be
scaled down based on the ratio of the default mesh area and the adapted mesh area. To
illustrate this consider the following example:

For a 150mmx150mm bed with `mesh_min` set to `25,25` and `mesh_max` set to `125,125`,
the default mesh area is a 100mmx100mm square. An adapted mesh area of `50,50`
means a ratio of `0.5x0.5` between the adapted area and default mesh area.

If the `bed_mesh` configuration specified `probe_count` as `7x7`, the adapted bed
mesh will use 4x4 probe points (7 * 0.5 rounded up).

![adaptive_bedmesh](img/adaptive_bed_mesh.svg)

```
[bed_mesh]
speed: 120
horizontal_move_z: 5
mesh_min: 35, 6
mesh_max: 240, 198
probe_count: 5, 3
adaptive_margin: 5
```

- `adaptive_margin` \
_Default Value: 0_ \
Margin (in mm) to add around the area of the bed used by the defined objects. The diagram
below shows the adapted bed mesh area with an `adaptive_margin` of 5mm. The adapted mesh
area (area in green) is computed as the used bed area (area in blue) plus the defined margin.

![adaptive_bedmesh_margin](img/adaptive_bed_mesh_margin.svg)

By nature, adaptive bed meshes use the objects defined by the Gcode file being printed.
Therefore, it is expected that each Gcode file will generate a mesh that probes a different
area of the print bed. Therefore, adapted bed meshes should not be re-used. The expectation
is that a new mesh will be generated for each print if adaptive meshing is used.

It is also important to consider that adaptive bed meshing is best used on machines that can
normally probe the entire bed and achieve a maximum variance less than or equal to 1 layer
height. Machines with mechanical issues that a full bed mesh normally compensates for may
have undesirable results when attempting print moves **outside** of the probed area. If a
full bed mesh has a variance greater than 1 layer height, caution must be taken when using
adaptive bed meshes and attempting print moves outside of the meshed area.

## Bed Mesh Gcodes

### Calibration

`BED_MESH_CALIBRATE PROFILE=<name> METHOD=[manual | automatic] [<probe_parameter>=<value>]
[<mesh_parameter>=<value>]`\
[<mesh_parameter>=<value>] [ADAPTIVE=[0|1] [ADAPTIVE_MARGIN=<value>]`\
_Default Profile: default_\
_Default Method: automatic if a probe is detected, otherwise manual_
_Default Method: automatic if a probe is detected, otherwise manual_ \
_Default Adaptive: 0_ \
_Default Adaptive Margin: 0_

Initiates the probing procedure for Bed Mesh Calibration.

Expand All @@ -399,6 +453,8 @@ following parameters are available:
- `ROUND_PROBE_COUNT`
- All beds:
- `ALGORITHM`
- `ADAPTIVE`
- `ADAPTIVE_MARGIN`

See the configuration documentation above for details on how each parameter
applies to the mesh.
Expand Down
3 changes: 3 additions & 0 deletions docs/Config_Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,9 @@ Visual Examples:
# Optional points that define a faulty region. See docs/Bed_Mesh.md
# for details on faulty regions. Up to 99 faulty regions may be added.
# By default no faulty regions are set.
#adaptive_margin:
# An optional margin (in mm) to be added around the bed area used by
# the defined print objects when generating an adaptive mesh.
```

### [bed_tilt]
Expand Down
4 changes: 4 additions & 0 deletions docs/img/adaptive_bed_mesh.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading