Adaptive Path/CAM Operation

Here's the place for discussion related to CAM/CNC and the development of the Path module.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
kreso-t
Posts: 115
Joined: Sat Aug 04, 2018 2:32 pm

Re: Adaptive Path/CAM Operation

Post by kreso-t »

sliptonic wrote: Thu Sep 13, 2018 3:11 pm Using the same model at home (AMD FX(tm)-4100 Quad-Core Processor 12GB), I'm seeing this result:

*** Adaptive toolpath processing started...
Tool diam: 6.350000
*** Done. Elapsed: 322.135314 sec

The first 2/3 of the path generate quite fast ~15 seconds. The rest goes very slow. I had htop running and the four CPU cores were bouncing around 17%. Max memory usage for freecad about 30%. System peak memory usage about 6GB of 12GB. Plenty of swap.

I shut down every other application I could and shaved about 10 seconds off the total time.
When I put accuracy to max (slider full to the left) I managed to reproduce this slow down: the first part then goes relatively fast and at the end slows down significantly (i.e. like 10 times slower).

Since I can reproduce it now I will probably be able to fix it. My initial guess is that it is related to size of the model - paths grow to have a lot of points and then clipping slows down. Solution I have in mind is to introduce bounding boxes and process the model box by box, that would limit clipping to smaller area (of fixed size) and then (in theory) speed should not depend on size of the model.

Thx for the feedback,
BR,
K.
kreso-t
Posts: 115
Joined: Sat Aug 04, 2018 2:32 pm

Re: Adaptive Path/CAM Operation

Post by kreso-t »

kreso-t wrote: Thu Sep 13, 2018 5:36 pm
sliptonic wrote: Thu Sep 13, 2018 3:11 pm Using the same model at home (AMD FX(tm)-4100 Quad-Core Processor 12GB), I'm seeing this result:

*** Adaptive toolpath processing started...
Tool diam: 6.350000
*** Done. Elapsed: 322.135314 sec

The first 2/3 of the path generate quite fast ~15 seconds. The rest goes very slow. I had htop running and the four CPU cores were bouncing around 17%. Max memory usage for freecad about 30%. System peak memory usage about 6GB of 12GB. Plenty of swap.

I shut down every other application I could and shaved about 10 seconds off the total time.
When I put accuracy to max (slider full to the left) I managed to reproduce this slow down: the first part then goes relatively fast and at the end slows down significantly (i.e. like 10 times slower).

Since I can reproduce it now I will probably be able to fix it. My initial guess is that it is related to size of the model - paths grow to have a lot of points and then clipping slows down. Solution I have in mind is to introduce bounding boxes and process the model box by box, that would limit clipping to smaller area (of fixed size) and then (in theory) speed should not depend on size of the model.

Thx for the feedback,
BR,
K.
With which accuracy setting are you getting those results?
User avatar
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Adaptive Path/CAM Operation

Post by sliptonic »

kreso-t wrote: Fri Sep 14, 2018 8:35 am With which accuracy setting are you getting those results?
The default
kreso-t
Posts: 115
Joined: Sat Aug 04, 2018 2:32 pm

Re: Adaptive Path/CAM Operation

Post by kreso-t »

sliptonic wrote: Fri Sep 14, 2018 12:05 pm
kreso-t wrote: Fri Sep 14, 2018 8:35 am With which accuracy setting are you getting those results?
The default
Added the performance optimizations for larger models.

On my PC your model is now processed in the range from 4 sec (min accuracy), 6 sec (default accuracy), 32 sec (max accuracy)
for comparison the same model with the previous version ranged from 13 sec (min accuracy) to 600 sec. (max accuracy)

So performance should now be more stable, not so dependent on the settings and model size. For small models it is about the same as before, maybe a little better.

Besides adding bounding boxes had to also change how the tool down linking paths are resolved, previous version was based on offsets which tend to be slow for larger polygons with many points. Also this new linking alg. should be better in resolving the shortest linking path.

these changes are pushed to separate branch in my git profile https://github.com/kreso-t/FreeCAD/tree/PathAdaptive

BR,
K.
User avatar
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Adaptive Path/CAM Operation

Post by sliptonic »

Now that your first round of adaptive has been merged into master, will you please rebase your PathAdaptive branch or do additional development in a new branch? If I try to merge your latest changes to test, I get a merge conflict with master.
kreso-t
Posts: 115
Joined: Sat Aug 04, 2018 2:32 pm

Re: Adaptive Path/CAM Operation

Post by kreso-t »

sliptonic wrote: Sun Sep 16, 2018 3:23 pm Now that your first round of adaptive has been merged into master, will you please rebase your PathAdaptive branch or do additional development in a new branch? If I try to merge your latest changes to test, I get a merge conflict with master.
Hi, I've rebased it, now it's in sync with master + one commit ahead (containing those changes and manually merged changes from master i.e. automatic spelling and white space fixes). I did regression tests with all models I previously used for testing and it all still looks OK (only faster), so I submitted PR for those changes.

BR,
K.
User avatar
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Adaptive Path/CAM Operation

Post by sliptonic »

Very Nice! Huge improvement for me. Even on old-busted computer, less than 30 seconds to build the path. Thank you!
kreso-t
Posts: 115
Joined: Sat Aug 04, 2018 2:32 pm

Re: Adaptive Path/CAM Operation

Post by kreso-t »

sliptonic wrote: Tue Sep 18, 2018 2:53 pm Very Nice! Huge improvement for me. Even on old-busted computer, less than 30 seconds to build the path. Thank you!
That's good to hear.

In meanwhile I managed to squeeze some 20-30 percent more. Also have some bug fixes i.e. noticed that in some cases it may happen to approach into the cut too close with rapid move, it's fixed now. I submitted new PR for this.

BR,
K.
kreso-t
Posts: 115
Joined: Sat Aug 04, 2018 2:32 pm

Re: Adaptive Path/CAM Operation

Post by kreso-t »

Added some smoothing of linking paths, now it looks like so:
Selection_047.png
Selection_047.png (15.51 KiB) Viewed 979 times
Also I noticed in some rare cases it could happen to leave some internal area uncleared, this is also fixed now.

BR
K.
User avatar
dubstar-04
Posts: 698
Joined: Mon Mar 04, 2013 8:41 pm
Location: Chester, UK
Contact:

Re: Adaptive Path/CAM Operation

Post by dubstar-04 »

kreso-t wrote: Sun Sep 23, 2018 7:53 pm Added some smoothing of linking paths, now it looks like so:

Selection_047.png

Also I noticed in some rare cases it could happen to leave some internal area uncleared, this is also fixed now.

BR
K.
Really nice job. As soon as I get time I will run a part and see how it works in the real world.

Thanks,

Dan
Post Reply