incorrect pocket paths

Here's the place for discussion related to CAM/CNC and the development of the Path module.
User avatar
freman
Posts: 1569
Joined: Tue Nov 27, 2018 10:30 pm

incorrect pocket paths

Postby freman » Wed Jun 26, 2019 12:17 pm

Hi,

It seems that Pocket Path tool is not producing what it supposed to do on this model.

I have a 28mm diam hole which I am pocketing with a 10mm parallel end-mill.

The default zig-zag does not fully clear the area. This seems totally unnecessary.

If I select offset this looks a lot cleaner but it is proposing four paths with considerable overlap when the default parameter is 100% step over. It seems to me it could clear this area in two cuts, not four. An initial path radius 5mm would clear a 20mm circle , leaving 4mm to clean up in a final 2nd cut.

My misunderstanding or is this a bug ( or two )?

BTW the different depths are just to make the paths more readily distinguishable for this discussion.

Code: Select all

OS: Linux (LXDE/LXDE)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17119 (Git)
Build type: Release
Branch: master
Hash: e72b48e0cfcf4773e4b6527c74f2bac11ccff1ab
Python version: 2.7.15
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedKingdom (en_GB)
Attachments
housing-pocket-probs.FCStd
(50.13 KiB) Downloaded 24 times
Russ4262
Posts: 684
Joined: Sat Jun 30, 2018 3:22 pm

Re: incorrect pocket paths

Postby Russ4262 » Wed Jun 26, 2019 5:16 pm

Morning, Sir.
I loaded up your model provided. I think you have found a potential bug (or two, or three). Or, just one big one centralized on the path seeding algorithm for these various path patterns.

I ran the path simulation on your zigzag path to highlight the failure to clear the hole (image attached).

I tried a spiral pattern with the same 10 mm diameter end mill (image attached). The spiral only returns one loop, which would leave an 8 mm core uncleared. Running the path simulator on the spiral result (image attached) demonstrates the error/bug you are pointing out here.

The path seeding/generation algorithm needs to be investigated based upon these findings.

You might need to file a bug report. Or, if you like I will do so.

Thanks Freeman,
Russ
Attachments
path simulation of zigzag path with 10 mm end mill on the 28 mm hole
path simulation of zigzag path with 10 mm end mill on the 28 mm hole
housing-pocket-probs_1c.png (133.78 KiB) Viewed 797 times
10 mm spiral pattern - would leave an 8 mm core uncleared
10 mm spiral pattern - would leave an 8 mm core uncleared
housing-pocket-probs_1a.png (158.55 KiB) Viewed 797 times
path simulation of spiral path with 10 mm end mill on the 28 mm hole
path simulation of spiral path with 10 mm end mill on the 28 mm hole
housing-pocket-probs_1b.png (135.57 KiB) Viewed 797 times
User avatar
sliptonic
Posts: 2232
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: incorrect pocket paths

Postby sliptonic » Wed Jun 26, 2019 5:49 pm

It seems to go goofy if the stepover is greater than 89%. Below that, it looks more reasonable.
User avatar
freman
Posts: 1569
Joined: Tue Nov 27, 2018 10:30 pm

Re: incorrect pocket paths

Postby freman » Wed Jun 26, 2019 6:10 pm

You might need to file a bug report. Or, if you like I will do so.
If you would not mind doing that, with your knowledge of the code, you will probably make a more pertinent bug report than I would with my noob-eyed bug description.

Thanks for testing and confirming.
User avatar
freman
Posts: 1569
Joined: Tue Nov 27, 2018 10:30 pm

Re: incorrect pocket paths

Postby freman » Wed Jun 26, 2019 6:17 pm

sliptonic wrote: Wed Jun 26, 2019 5:49 pm It seems to go goofy if the stepover is greater than 89%. Below that, it looks more reasonable.
Thanks, that's useful additional input to the bug but since step over default is 100% on clearing ops, it is not what is usually seen.

Is there also agreement that offset is producing more path lines than it should?
User avatar
sliptonic
Posts: 2232
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: incorrect pocket paths

Postby sliptonic » Wed Jun 26, 2019 11:55 pm

I think the error is related to how PathArea generates offsets when the shape being cleared is small relative to the tool. In all images below, the tall cylinder represents a 10mm tool.

If the shape is 28mm in diameter and we're stepping over 50% everything looks good.
patharea4.png
patharea4.png (20.13 KiB) Viewed 760 times
Still looks good if we step over 100%
patharea3.png
patharea3.png (18.51 KiB) Viewed 760 times
If the shape is 14mm in diameter and we step over 50%, it looks mostly good although the center-most pass is unnecessary.
patharea1.png
patharea1.png (20.12 KiB) Viewed 760 times
The problem becomes when we try to step-over 100%
patharea2.png
patharea2.png (21.13 KiB) Viewed 760 times
I've created an issue #4038
realthunder wrote: realthunder
Any thoughts?
jmaustpc
Posts: 11037
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: incorrect pocket paths

Postby jmaustpc » Thu Jun 27, 2019 2:26 am

sliptonic wrote: Wed Jun 26, 2019 11:55 pm Any thoughts?
I am don't think my thoughts would much but ... at a guess it looks to me like a precision issue somewhere.
User avatar
freman
Posts: 1569
Joined: Tue Nov 27, 2018 10:30 pm

Re: incorrect pocket paths

Postby freman » Thu Jun 27, 2019 4:55 am

Still looks good if we step over 100%
Not as bad as zig-zag but not so good either. Your offset cut of 28mm with 10mm endmill creates 4 paths where 2 would suffice, as in my initial report. If I use 89% I get two cuts, a central plunge and a circular path. Perfect.

I can confirm your observation that 89% appears to be a critical limit.
If I set extra offset of 0.1mm, I need 88% ;)

Perhaps looking into zig-zag would permit to see the problem since the failure to clear is more flagrant. Also spiral leaves a central pillar, though I've seen others suggest that spiral is not working too well anyway, so that may not be the best starting point.

If I reopen the pocket op., I get this in report window. It is a precursor to what was causing the illegal memory access crash bug I opened.
In view of the 89%, I doubt this is the cause here but maybe should be noted. While this exception is trapped at low level it results in a null object being returned. This is likely not tested for higher up.

Code: Select all

PathOpGui.INFO: Title: 'Pocket Shape'
Pocketing Select Mode
PathPocketShape.ERROR: getDirection(): tangent.cross(FreeCAD.Vector(0, 0, 1)).normalize()
PathPocketShape.ERROR: Cannot normalize null vector
PathPocketShape.ERROR: extendWire(): (ePts[0] - endPts[0]).Length
PathPocketShape.ERROR: list index out of range
PathPocketShape.ERROR: extendWire(): (ePts[0] - endPts[0]).Length
PathPocketShape.ERROR: list index out of range
If the shape is 28mm in diameter
It appears that you are using 28mm radius here, though results are similar.
realthunder
Posts: 1981
Joined: Tue Jan 03, 2017 10:55 am

Re: incorrect pocket paths

Postby realthunder » Thu Jun 27, 2019 7:30 am

sliptonic wrote: Wed Jun 26, 2019 11:55 pm Any thoughts?
This phenomenon is a side effect of my work around of a "weakness" of ClipperLib's offset algorithm. The pocket path is generated by gradually increasing an inward offset from the shape contour. So by right, when the contour shrinks to nothing, the pocket is considered done. The problem lies in the last loop. See the picture below. This is stepover of 8mm. When you increase the stepover beyond about 8.9mm, the inner most loop disappear, because the loop shrinks to nothing, and obviously there will be left overs when you try to mill it.

There are more advanced algorithms available to figure out where the loop converges to, but they are not easy to add. My simple work around is a PathArea parameter called 'PocketLastStepover'. It specifies the step over for the last loop. The default value is 0.5*ToolRadius, which is a conservative value. So if you increase normal step over beyond 8.9, it will continue generate more loops using a smaller step over, hence the extra loops. Since the extra loops only occur near finish, it won't take much extra time.

Screenshot from 2019-06-27 15-21-31.png
Screenshot from 2019-06-27 15-21-31.png (75.36 KiB) Viewed 726 times
Try Assembly3 (latest version 0.11) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
freman
Posts: 1569
Joined: Tue Nov 27, 2018 10:30 pm

Re: incorrect pocket paths

Postby freman » Thu Jun 27, 2019 8:40 am

Thanks for the input.

If I get your explanation, ClipperLib is bailing out too early. It should be doing one final pass when the residual disappears theoretically to actually remove it. Has this problem been sent upstream ?

As for your workaround, 0.5*ToolRadius is 25% stepover. Is that too conservative , or is there problem with a larger value. ToolRadius or 50% would seem more suitable.

This unnecessary paths aspect is the least worrying of what I found. The residual material which is not cleared out with spiral and zig-zag seems far more of a bug than a defect.

Are those aspects related to what you refer to , or is that a separate issue?

Thanks.