Adaptive (?) Rouging Pockets and sort of trochoidal profiles with Openvoronoi

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!
Post Reply
roivai
Posts: 117
Joined: Thu Feb 02, 2017 5:29 pm
Location: Oulu, Finland

Adaptive (?) Rouging Pockets and sort of trochoidal profiles with Openvoronoi

Post by roivai »

I've been toying around with OpenVoronoi (https://github.com/aewallin/openvoronoi) for a while every now and then. Just for fun mostly, but I think the results are nice, so thought I can show some here.

The library contains (experimental) medial axis pocketing algorithm which I used. I find that the pocket algorithm works fine, the tricky thing was to get the polygons to the Voronoi diagram in the first place.. Openvoronoi seems pretty picky on the order on which the vertexes and lines are added to the diagram.. And the fun thing is that when error is detected, it does not spit out exception, but it asserts the whole thing and FreeCAD dies. But I managed to get the algorithm to accept offset polygons calculated by Path.Area and got this kind of medial axis circles for example:
2018-07-14-182036_1920x1080_scrot.png
2018-07-14-182036_1920x1080_scrot.png (47.15 KiB) Viewed 2396 times
Please note that these are not actually machining paths just yet, they are maximum inscribed circles along the medial axis at 1mm steps. There are a few examples along with OpenVoronoi source on how to translate that into machining path, i.e only run half of the arc, then rapid to other side and so on.. Another thing worth mentioning is that this is clearly a roughing algorithm, it does not cover the corners of the pocket fully. But I think normal profiling pass is added after this type of operation anyway..?

Another thing I tried was creating some kind of trochoidal/arced profiles with this algorithm. This is a feature I'd really like to see as profiling aluminum with my crappy mill with crappy tools and crappy coolant system is a pain and I think this would help greatly on chip evacuation. There has been some pull request coming and going about this, I don't know how that is going, but here's my idea of it. What I did was I created two paths by Path.Area.makeOffset(), one with the usual tooldiameter/2 offset and second with larger offset, the difference being the wanted diameter of the arcs. Then I simply applied that same medial axis pocket to the area between those offset paths. Here are the results showing both internal and external profiles of the face. I think that looks pretty cool!
2018-07-14-154815_1920x1080_scrot.png
2018-07-14-154815_1920x1080_scrot.png (31.05 KiB) Viewed 2396 times


I know Openvoronoi has been discussed earlier as well and I'm aware that the license is not directly compatible with FreeCAD but I think the case is the same as with OpenCamLib and it has not stopped us from using it..? What worries me more is that OpenVoronoi (just like OCL) has not been actively developed since maybe 2012 so is this like betting on a dead horse..? And I quickly skimmed through a few papers about Voronoi diagrams, medial axes and such and boy, my math is not there to really understand what's going on, so my option is to use the libraries as is.. :D

Next I will try to imitate the examples on creating actually machineable paths out of this algorithm and then maybe create an actual Path OP out of these instead of just copy-pasting code to console.. :) Any comments? There are other voronoi diagram libraries (at least Boost.Polygon should be very licence compatible). Does anyone have experience on those?
User avatar
sliptonic
Veteran
Posts: 3457
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Adaptive (?) Rouging Pockets and sort of trochoidal profiles with Openvoronoi

Post by sliptonic »

roivai wrote: Sat Jul 14, 2018 5:56 pm I've been toying around with OpenVoronoi (https://github.com/aewallin/openvoronoi) for a while every now and then. Just for fun mostly, but I think the results are nice, so thought I can show some here.
Awesome! I'd like to do more with Openvoronoi too. The medial axis pocket could be used for center-line engraving of truetype fonts as well.
roivai wrote: Sat Jul 14, 2018 5:56 pm Another thing worth mentioning is that this is clearly a roughing algorithm,
No problem. Perfectly valid operation type.
roivai wrote: Sat Jul 14, 2018 5:56 pm Another thing I tried was creating some kind of trochoidal/arced profiles with this algorithm.
IchGucksLive has been playing with something similar but has not posted here about it. This arced/looped path is probably a useful strategy for a profile. Somebody correct me if I'm wrong but my understanding of trochoidal is that it also maintains a constant engagement of the cutter. This would be particularly useful for roughing so that the cutter never hits an inside corner and overloads to the breaking point.
roivai wrote: Sat Jul 14, 2018 5:56 pm I know Openvoronoi has been discussed earlier as well and I'm aware that the license is not directly compatible with FreeCAD but I think the case is the same as with OpenCamLib and it has not stopped us from using it..? What worries me more is that OpenVoronoi (just like OCL) has not been actively developed since maybe 2012 so is this like betting on a dead horse..? And I quickly skimmed through a few papers about Voronoi diagrams, medial axes and such and boy, my math is not there to really understand what's going on, so my option is to use the libraries as is..
Agreed. I think it's still worth playing with. I also wish there were debian packages and windows binaries but we've got what we've got.


Nice work. Keep it up!
herbk
Veteran
Posts: 2657
Joined: Mon Nov 03, 2014 3:45 pm
Location: Windsbach, Bavarya (Germany)

Re: Adaptive (?) Rouging Pockets and sort of trochoidal profiles with Openvoronoi

Post by herbk »

Hi roivai,

hm, i'm not sure what ti think about this circled pathes for roughing... :? What are the circles good for? At my toughts it only takes a lot of time... but maybe someone can give me an idea. :)

Atm my workaround for roughing is like this:
For rouging i use for the path creaton a tool which is bigger as the tool i have in the machine and use the Pocket OP to remove the unneeded material.
After that, the finish can be done with the "countour by Edges OP".
Gruß Herbert
chrisb
Veteran
Posts: 53945
Joined: Tue Mar 17, 2015 9:14 am

Re: Adaptive (?) Rouging Pockets and sort of trochoidal profiles with Openvoronoi

Post by chrisb »

herbk wrote: Sun Jul 15, 2018 8:08 am but maybe someone can give me an idea
Trochoidal milling has the advantage that the the thickness of the material removed is constant as opposed to conventional paths. English readers please excuse linking a german website https://www.youtube.com/watch?v=SRCg6jWM3Uw. If you mind I can search for an english one.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
awallin66
Posts: 4
Joined: Sun Feb 23, 2014 8:18 pm

Re: Adaptive (?) Rouging Pockets and sort of trochoidal profiles with Openvoronoi

Post by awallin66 »

Hi, nice to see that there is interest in openvoronoi - I am the original author but I have not had time to maintain the code much lately...

1. Licensing. Would a change to LGPL make building/linking/packaging with FreeCAD easier?
- please post an issue on github explaining the situation and what would be the desired license.

2. the algorithm itself contains some bugs, problems, and corner cases. These are not so easy to track down and requires a solid few hours of study to remember how it all works again... A step in the right direction would be to set up automated tests and coverage-analysis (travis, coveralls, etc.) which allows tracking down old and potential new bugs.
- exceptions are mentioned in issue #28 on github. discussion/contributions and pull-requests are welcome.
- there are alternative voronoi codes such as the boost.voronoi work (sponsored by Intel!?), and Julian Todd (freesteel blogger) also posted some brute-force mesh approach.

3. once we have a voronoi diagram and a medial-axis from that the path-generation should be fairly straightforward. it could probably be documented much better, and most(or all) of the path-generation (i.e. traversing the medial-axis) can be in python.
In the videos (below) you see "stupid" behavior when we come back to an area which has already been cut - this is not implemented but one could probably keep track of what areas of the medial axis have been cut and avoid 'stupid' overly large circle/arc cuts.

4. I made some animations (already 6 years ago now!) where we figure out what part of the circle is a cutting move and then do a small arc (+lift?) and rapid to start on the next circle:
https://www.youtube.com/watch?v=X2IO1i0EQ3M
https://www.youtube.com/watch?v=_Qr8tZXGXZU
https://www.youtube.com/watch?v=lfIU_gv0iB8
(these were exported as g-code and then run on some cutting-simulator on windows (I forget the name), and screencaptured)

5. for V-carving we start with the same medial-axis and move the cutter along it, setting the depth based on the circle-diameter at that point.
https://www.youtube.com/watch?v=n4P9SvT4L7g
this could be tweaked for different cutter V-angles as well as what to do if we find places which require a depth larger than the cutter-diameter allows (creating vertical walls, which we probably don't want).

I could probably find time to do minor maintenance, set up testing, and perhaps work on the exceptions - but it would be good to find more core developers and see more use of the library. This is motivated by actual use and activity with issues/pull-requests on github - so all you freecad/c++/python afficionados do start posting there!

cheerio! ;)
Anders
roivai
Posts: 117
Joined: Thu Feb 02, 2017 5:29 pm
Location: Oulu, Finland

Re: Adaptive (?) Rouging Pockets and sort of trochoidal profiles with Openvoronoi

Post by roivai »

Terve Anders, great to hear from you!

awallin66 wrote: Sun Jul 15, 2018 3:24 pm 1. Licensing. Would a change to LGPL make building/linking/packaging with FreeCAD easier?
- please post an issue on github explaining the situation and what would be the desired license.
I let others comment about licensing. I have no clue, except for reading the discussions somewhere here in this forum stating that GPLv3 is incompatible..
2. the algorithm itself contains some bugs, problems, and corner cases. These are not so easy to track down and requires a solid few hours of study to remember how it all works again... A step in the right direction would be to set up automated tests and coverage-analysis (travis, coveralls, etc.) which allows tracking down old and potential new bugs.
- exceptions are mentioned in issue #28 on github. discussion/contributions and pull-requests are welcome.
- there are alternative voronoi codes such as the boost.voronoi work (sponsored by Intel!?), and Julian Todd (freesteel blogger) also posted some brute-force mesh approach.
After some head-banging, the algorithm has worked quite reliably on the very few tests I've done. The thing that took me a while to realize is that all the vertexes need to be added to the diagram first and the lines only after that. How about the arc support? To some extent it seems to be there, but I suppose it is not complete?
3. once we have a voronoi diagram and a medial-axis from that the path-generation should be fairly straightforward. it could probably be documented much better, and most(or all) of the path-generation (i.e. traversing the medial-axis) can be in python.
In the videos (below) you see "stupid" behavior when we come back to an area which has already been cut - this is not implemented but one could probably keep track of what areas of the medial axis have been cut and avoid 'stupid' overly large circle/arc cuts.

4. I made some animations (already 6 years ago now!) where we figure out what part of the circle is a cutting move and then do a small arc (+lift?) and rapid to start on the next circle:
https://www.youtube.com/watch?v=X2IO1i0EQ3M
https://www.youtube.com/watch?v=_Qr8tZXGXZU
https://www.youtube.com/watch?v=lfIU_gv0iB8
(these were exported as g-code and then run on some cutting-simulator on windows (I forget the name), and screencaptured)
I was able to run the test you had in the source which creates this pocket from letters. Had to do some hacks to make the visualizations work with vtk 6.0. After that I saw in the issue tracker that someone has already done the porting for vtk6.0 (https://github.com/Blokkendoos/openvoronoi). I will try to implement the G-code generation and visualization with FreeCAD next.
5. for V-carving we start with the same medial-axis and move the cutter along it, setting the depth based on the circle-diameter at that point.
https://www.youtube.com/watch?v=n4P9SvT4L7g
this could be tweaked for different cutter V-angles as well as what to do if we find places which require a depth larger than the cutter-diameter allows (creating vertical walls, which we probably don't want).
V-carving is something I didn't even think of, but that would be cool too!
User avatar
sliptonic
Veteran
Posts: 3457
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Adaptive (?) Rouging Pockets and sort of trochoidal profiles with Openvoronoi

Post by sliptonic »

Great news! The re-license of Openvoronoi is complete. https://github.com/aewallin/openvoronoi/issues/35


In even more great news, the same process is under way for Opencamlib: https://github.com/aewallin/opencamlib/issues/28
User avatar
kkremitzki
Veteran
Posts: 2511
Joined: Thu Mar 03, 2016 9:52 pm
Location: Illinois

Re: Adaptive (?) Rouging Pockets and sort of trochoidal profiles with Openvoronoi

Post by kkremitzki »

sliptonic wrote: Tue Jul 31, 2018 2:43 pm Great news! The re-license of Openvoronoi is complete. https://github.com/aewallin/openvoronoi/issues/35


In even more great news, the same process is under way for Opencamlib: https://github.com/aewallin/opencamlib/issues/28
Awesome! As soon as it's tagging with an official version number I will be ready to submit the package to Debian.
Like my FreeCAD work? I'd appreciate any level of support via Patreon, Liberapay, or PayPal! Read more about what I do at my blog.
chrisb
Veteran
Posts: 53945
Joined: Tue Mar 17, 2015 9:14 am

Re: Adaptive (?) Rouging Pockets and sort of trochoidal profiles with Openvoronoi

Post by chrisb »

That's really great news!
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply