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

Fluid Motion Smoothing Fails to Smooth in Some Cases #1982

Open
mfish38 opened this issue Nov 14, 2023 · 1 comment
Open

Fluid Motion Smoothing Fails to Smooth in Some Cases #1982

mfish38 opened this issue Nov 14, 2023 · 1 comment

Comments

@mfish38
Copy link

mfish38 commented Nov 14, 2023

Application Version
Cura 5.5.0

Platform
Cura 5.5.0

Qt
Cura 5.5.0

PyQt
Cura 5.5.0

Display Driver
AMD Adrenalin Edition 23.11.1

Steps to Reproduce

  1. Turn on fluid motion with shift distance of 0.1, small distance of 0.05, and angle of 15.
  2. Slice a benchy.
  3. Print using a Klipper based printer.

Actual Results
There are still non-fluid motion segments remaining at the start of the bow curves that result in blobbing on the print. When I slice it there is one on layer 116 on the front right, identifiable by the gradient shading discontinuity:

image

Expected results

The current fluid motion smoothing will not process segments if the smooth distance is too large, leaving non-fluid segments. And if the smooth distance is set smaller so that the points are processed, then not all points are shifted enough as the shift amount is scaled by the smooth distance. This makes it practically impossible to set a smooth distance that will remove all non-fluid motions.

I believe the segment should be collapsed to single point, a different method of scaling the distance points are shifted, or some additional parameter added to handle this case.

Reading the smoothing source code the comment here indicates that if the outer segments are less than the shift distance the segment should be deleted:

// Smooth the path, by moving over three segments at a time. If the middle segment is shorter than the max resolution, then we try shifting those points outwards.
// The previous and next segment should have a remaining length of at least the smooth distance, otherwise the point is not shifted, but deleted.

However, testing shows that the deletion of such line segments is never done. It looks like it should be done here but it is not:

// only if segments ab and cd are long enough, we can shift b and c
// 3 * fluid_motion_shift_distance is the minimum length of the segments ab and cd
// as this allows us to shift both ends with the shift distance and still have some room to spare
if (magnitude_ab < fluid_motion_shift_distance3 || magnitude_cd < fluid_motion_shift_distance3)
{
continue;
}

Additional Information
Using a different G-Code viewer shows the segment in question and the coordinates around it (note that this g code was produced by Cura):
Capture

Note the super small line segment veering at almost a 45 degree angle towards the outside of the wall.

Here is a transcription of the a, b, c, d points from the g code that would be used by the smoothing algorithm:

a = Point(123.275, 97.555)
b = Point(122.311, 97.139)
c = Point(122.306, 97.122)
d = Point(121.33, 96.757)

@mfish38 mfish38 changed the title Fluid Motion Smoothing Bug Fluid Motion Smoothing Fails to Smooth in Some Cases Nov 14, 2023
@mfish38
Copy link
Author

mfish38 commented Nov 14, 2023

My guess is that this has the potential to occur whenever shift distance is greater than 1/3 of the maximum resolution slicer setting. At a minimum, perhaps adding fluid_motion_shift_distance = min(<max resolution> / 3.0 - epsilon, fluid_motion_shift_distance) would prevent large shift distances from unexpectedly resulting in suddenly having unsmoothed segments.

Then perhaps some setting or toggle to optionally collapse segments that fail the 3x shift distance check to a point instead of limiting the shift distance.

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

No branches or pull requests

1 participant