[GSoC 2023] On-machine Inspection

Contributions from the participants, questions and answers to their projects.
Discussions of proposals for upcoming events.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
tanahy
Posts: 11
Joined: Thu Mar 30, 2023 5:32 pm
Contact:

[GSoC 2023] On-machine Inspection

Post by tanahy »

Hi!

I'll work on the On-machine Inspection (OMI) feature for the Path Workbench of FreeCAD for the latest edition of Google Summer of Code. If you have any suggestions, criticisms or ideas on this, please let me know so as to take them into account for implementing the solution. I will be updating this thread, weekly at the very least, with any advances I make on the project.

Here is the description of the project as in the GSoC page:

On-machine Inspection (OMI) is a valuable tool used in CNC commercial manufacturing to ensure proper tolerances of the manufactured piece. This is done by attaching a probe to the tool head of the machine and scanning the surface of the finalised product to see if there are discrepancies between the expected result and actual measurements.
Including such a tool on FreeCAD, which already has a dedicated set of tools for CNC milling in the Path Workbench, will not only bring it closer to proprietary solutions but even surpass some of them that don't have this feature. This would save time for the machinist and also increase the inherent accuracy of the whole process. Building upon this, sensing solutions can introduce novel approaches to improve the CAM workflow and even generate new solutions not seen before. This proposal argues for an automatized post-processing of, for example, 3D prints by milling them to correct tolerances and inherent defects of the manufacturing process like layer patterns, over-extrusion or limited resolution.
For On-machine inspection, there are already commercial solutions available so it's a matter of replicating their implementations on Python for FreeCAD. For the post-processing tool, a more involved overview of optimization algorithms for closely-matching volumes will be needed but it's surely available in the literature. If not, my background in mathematics and physics should prove valuable in the development of such an algorithm. Thus, the main goals for the proposal are to prodive the FreeCAD Path Workbench with two new tools, On-machine Inspection and automatized post-processing of already manufactured pieces, and also to properly test and document these new tools in the FreeCAD wiki.
Attachments
proposal.pdf
(252.78 KiB) Downloaded 161 times
User avatar
tanahy
Posts: 11
Joined: Thu Mar 30, 2023 5:32 pm
Contact:

Re: [GSoC 2023] On-machine Inspection

Post by tanahy »

Last week I compiled FreeCAD from the git repo to get used to building my own changes and work with the latest version, this wasn't a problem on my laptop with Manjaro but it was with my work laptop with Fedora 38 due to issues with Qt dependencies. For now, I will not bother with the second computer, even though it's more powerful.

I also familiarized myself with the Path Workbench interface and followed the brief Path tutorial from the wiki. I found some problems along the way but I managed to solve them all, apparently. Some of these problems were my being unable to use the sketch workbench properly to execute a pocket on a cube, which I did with boolean operations on the Part Workbench in the end. I guess I should do some FreeCAD tutorials to get used to the different workbenches at some point.

Also, I had problems with the sanity tool, which unintuitively required me to save the project by throwing an error instead of a save window. Afterwards, it threw more errors so I gave up on the sanity check. Moreover, I selected the linuxcnc post-processor but gave me errors and had to restart the whole process as I couldn't find how to change it easily, selecting the linuxcnc refactored version on the second try. This time the post-processor worked.

I have also searched for sources that could be useful for the project in later stages. After looking for explanations on commercial solutions I went through different papers for more extensive explanations and clear algorithms. Particularly, this paper for OMI path planning for aerospace structures was quite interesting and I believe I will follow it's four step guide to creating a full OMI procedure for later stages in the project. For now, I will focus on manual probing and a way less automatized and more simple probing feature that can be controlled by the machinist.

Also, I found this very nice paper about surface matching for profile inspection that could be used for the second feature of the proposal, the post-processing of externally fabricated pieces.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: [GSoC 2023] On-machine Inspection

Post by Kunda1 »

Thanks for your work and reporting. Feel free to open bug reports when you encounter issues.
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
M4x
Veteran
Posts: 1472
Joined: Sat Mar 11, 2017 9:23 am
Location: Germany

Re: [GSoC 2023] On-machine Inspection

Post by M4x »

Thanks for your work and report. This should resolve your PD issues: Creating_a_simple_part_with_PartDesign
User avatar
tanahy
Posts: 11
Joined: Thu Mar 30, 2023 5:32 pm
Contact:

Re: [GSoC 2023] On-machine Inspection

Post by tanahy »

Thanks for the link @M4x, very well-explained tutorial! I now understand sketches better.
User avatar
tanahy
Posts: 11
Joined: Thu Mar 30, 2023 5:32 pm
Contact:

Re: [GSoC 2023] On-machine Inspection

Post by tanahy »

Last week I read many articles in the wiki related to Python scripting and interface handling with Qt through Pyside. I also scanned through the codebase of the Path workbench to try to understand its inner workings. I didn't understand the code structure completely, but now I have a better idea of how to proceed.
I also had a meeting with my mentor @sliptonic where I exposed my questions about the UI and what a minimal working example should look like. Thanks to him, I have a clear picture of how the workflow should be and look like.

As suggested by my mentor, I will work with the Tag Path Dressup function as a template for the basic user interface while adding functionality to redirect the probing direction based on an initial guess based on the predicted surface construction after a given operation and the assumption the probe has spherical symmetry on the tip. This might be subject to change in the future depending on triggering differences due to the anisotropic deflection of the probe and tolerances, but it's a good start.

As in the Tag feature, the user will be able to choose probing points based on already created path jobs, choosing the probing points by hand for now.

I expect to fulfil the following tasks in the next two weeks:
  • Examine the Tag feature to understand how it works
  • Copy and modify the Tag feature code into a macro (temporary) to adapt it to my use case for OMI probing
  • Develop code to calculate an initial guessed direction for probing for a chosen point by the user based on the selected path job and corresponding tool
  • Add an interface in the shape of an arrow for the user to change the direction of probing if desired, apart from a numerical option to write the probing vector
  • Use the already developed code for Probe and Custom features to add the probing instructions to the job
Suggestions on the interface and code structure are always welcome!
User avatar
tanahy
Posts: 11
Joined: Thu Mar 30, 2023 5:32 pm
Contact:

Re: [GSoC 2023] On-machine Inspection

Post by tanahy »

After months of stumbling while learning about FreeCAD and its code base, I now finally present a functional prototype of the On Machine Inspection Operation!

Some decisions were taken along the way between my mentor @sliptonic and me about the requirements of the code and interface, mainly:
  • Code-wise it makes more sense to treat the OMI feature as an Operation
  • The user should be able to select points on the surface of the geometry to measure the discrepancy between ideal and machined geometries (this measures accuracies for client requirements)
  • The user should be able to select points on a machining path to measure the discrepancy between expected and actual machined geometries (this measures machine tolerances and related issues)
  • Manual and automatic generation of probing locations should be available
  • In principle, the probe is assumed to have a perfectly symmetrical spherical tip
With all this in mind, I made the following design decisions for the prototype:
  • The user can set an anchor point from which a probing operation is created and the orientation of the probing operation is set by the normal of the reference object surface.
  • This normal vector is uniquely defined when probing over the model geometry, but it's not so for the machining path geometry. In the latter, the normal is initially calculated using the closest point on the machining tool surface at the desired location with respect to the model geometry. In the future, the user might be allowed to choose freely a point on the tool surface, with a small constraint. This constraint is that the surface is previously sliced along the tangent of the machining path or an alternative direction to pick points that can actually touch a physical surface.
Current features of the OMI operation include:
  • Task Panel interface with the necessary fields for setting a probe, an output file, auto-generation of probing locations (to be implemented) and probing location listing
  • Addition of probing locations by selection of objects in the 3D view
  • Calculation of probing locations and normal vectors based on model geometry and reference (either a machining path or the model itself)
  • Removal of proving locations selected in the Task Panel list
Current bugs to solve for the machining path case:
  • Sometimes the normal is defined in the opposite direction, mathematically non-trivial issue (ongoing)
  • Incorrect calculation of normal when the probe diameter is larger than the tool diameter (ongoing)
Current bugs to solve:
  • The use of scripted objects in a LinkList property seems to derive in a cyclic dependency when recompute() is called, which derives in an infinite loop. I need help from other developers to solve this issue, as I couldn't figure it out on my own
  • The selection of objects is possible because the selection gates are totally removed by brute force. It would be ideal to understand where these selection gates are implemented to remove them gracefully and reestablish them after adding the desired locations.
Extension features of the OMI operation include:
  • Lock the manipulation of elements on the Task Panel table so data can't be manually changed for now (easy)
  • Manual reordering of probing locations through the Task Panel by drag and drop (easy)
  • Implementation of a more sophisticated probing operation generator so that post-processors can adequately correct probing paths and give meaningful outputs in different machines other than LinuxCNC-based ones (hard)
  • Auto generation of probing locations based on model geometry features (medium)
  • Auto generation of probing locations based on machining path while removing segments that don't interact with the stock material (easy)
  • Implementation of viewProvider for probing operation scripted objects so that the user can manipulate the anchor point and exact probing location (if model geometry is the reference, they are the same) through the 3D view (medium).
Extra things to be done:
  • Tests for checking the OMI operation works successfully
  • Documentation of the OMI operation on the wiki
Optional features that require feedback from users:
  • Automatic reordering of probing locations based on distances between them (easy)
  • Enable and disable probing locations with a check element in the Task Panel table (easy)
All of this sounds very complicated but it's quite straightforward to understand how this works once you see a demo of the functionality, so here's a short demo video of the OMI operation as it is at the moment.

phpBB [video]


I would really appreciate feedback from potential users on how this looks like, what they actually need in terms of interface and results and also what they think are features they don't need.

You can find the code in the omi branch of my FreeCAD fork: https://github.com/tanahy/FreeCAD/tree/omi. Mainly in the Path/Op/OMI.py and Path/Op/Gui/OMI.py files.
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: [GSoC 2023] On-machine Inspection

Post by yorik »

I have a hard time understanding it all (I'm not into CNC) :D but one can see the good work that is being done. Congrats!
User avatar
tanahy
Posts: 11
Joined: Thu Mar 30, 2023 5:32 pm
Contact:

Re: [GSoC 2023] On-machine Inspection

Post by tanahy »

Thanks @yorik! I admit it might be pretty obscure. I will try to explain things better in the future :oops: . I would like to continue developing this feature, do you think I should use this thread for future developments or should I make a new topic in a different sub-forum?

Best,
Tana
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: [GSoC 2023] On-machine Inspection

Post by yorik »

As you prefer! But I would keep using this one., why not! People already know where to find it ;)
Post Reply