tool path returns to origin many times

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!
steve123
Posts: 149
Joined: Fri Sep 04, 2015 8:58 pm

tool path returns to origin many times

Post by steve123 »

I have found what I think is undesired behaviour with the path workbench. I create a job and a tool path using the profile operation. When the operation is generated, the tool path shows that the tool moves back to the origin several times. In this particular instance, 42 times. I have confirmed the origin in the gcode output as well.

I attempted to upload the FCstd file but the file size attachment limit prevents me from doing so (file is 1.6MB). If I zip the file, it only compresses to 1.5MB.

EDIT: I removed a feature to reduce file size and attached it to the next message in this thread.

Code: Select all

OS: macOS 10.16
Word size of FreeCAD: 64-bit
Version: 0.21.30193 (Git)
Build type: Release
Branch: master
Hash: a8cb4e744483ce2c4b0770b948105a766330a4b2
Python 3.10.6, Qt 5.15.4, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.2
Locale: C/Default (C)
Installed mods: 
  * ThreadProfile 1.81.0
  * Reporting
  * WebTools
  * BIM 2021.12.0
  * kicadStepUpMod 10.12.7
  * fasteners 0.3.44
Attachments
Screen Shot 2022-08-30 at 1.04.38 PM.png
Screen Shot 2022-08-30 at 1.04.38 PM.png (151.8 KiB) Viewed 1586 times
Last edited by steve123 on Tue Aug 30, 2022 7:58 pm, edited 1 time in total.
steve123
Posts: 149
Joined: Fri Sep 04, 2015 8:58 pm

Re: tool path returns to origin many times

Post by steve123 »

I removed a feature to get the file size below 1MB. I can still recreate the issue with this slightly modified file.
Attachments
path returns to origin.FCStd
(930.11 KiB) Downloaded 37 times
steve123
Posts: 149
Joined: Fri Sep 04, 2015 8:58 pm

Re: tool path returns to origin many times

Post by steve123 »

Here is the gcode file and a sample taken from the file. Note how there appear to be several redundant movements in the Z before the path to the origin.

Code: Select all

G0 X0.000 Y0.000
G0 X232.851 Y317.669
G0 X232.851 Y317.669 Z3.000
G1 X232.851 Y317.669 Z-10.100 F200.000
G2 X231.182 Y322.320 Z-10.100 I2.611 J3.562 K0.000 F1200.000
G3 X230.180 Y324.093 Z-10.100 I-1.584 J0.274 K0.000 F1200.000
G2 X230.308 Y324.373 Z-10.100 I0.084 J0.131 K0.000 F1200.000
G3 X232.372 Y324.380 Z-10.100 I1.027 J1.283 K0.000 F1200.000
G2 X239.737 Y320.128 Z-10.100 I3.084 J-3.163 K0.000 F1200.000
G3 X240.739 Y318.355 Z-10.100 I1.584 J-0.274 K0.000 F1200.000
G2 X240.612 Y318.075 Z-10.100 I-0.084 J-0.131 K0.000 F1200.000
G3 X238.548 Y318.068 Z-10.100 I-1.027 J-1.283 K0.000 F1200.000
G2 X236.331 Y316.901 Z-10.100 I-3.119 J3.237 K0.000 F1200.000
G2 X232.851 Y317.669 Z-10.100 I-0.869 J4.330 K0.000 F1200.000
G0 Z5.000
G0 Z5.000
G0 X232.851 Y317.669
G0 X248.201 Y343.418
G0 X248.201 Y343.418 Z3.000
G1 X248.201 Y343.418 Z-10.100 F200.000
G2 X246.182 Y348.301 Z-10.100 I2.261 J3.793 K0.000 F1200.000
G3 X245.180 Y350.074 Z-10.100 I-1.584 J0.274 K0.000 F1200.000
G2 X245.308 Y350.354 Z-10.100 I0.084 J0.131 K0.000 F1200.000
G3 X247.372 Y350.361 Z-10.100 I1.027 J1.283 K0.000 F1200.000
G2 X254.737 Y346.109 Z-10.100 I3.084 J-3.163 K0.000 F1200.000
G3 X255.739 Y344.336 Z-10.100 I1.584 J-0.274 K0.000 F1200.000
G2 X255.612 Y344.056 Z-10.100 I-0.084 J-0.131 K0.000 F1200.000
G3 X253.548 Y344.048 Z-10.100 I-1.027 J-1.283 K0.000 F1200.000
G2 X251.331 Y342.882 Z-10.100 I-3.119 J3.237 K0.000 F1200.000
G2 X248.201 Y343.418 Z-10.100 I-0.869 J4.330 K0.000 F1200.000
G0 Z5.000
G0 Z5.000
G0 Z5.000
G0 Z5.000
G0 X0.000 Y0.000
G0 X278.811 Y357.506
G0 X278.811 Y357.506 Z3.000
G1 X278.811 Y357.506 Z-10.100 F200.000
G2 X278.756 Y357.593 Z-10.100 I0.095 J0.122 K0.000 F1200.000
G3 X277.717 Y359.376 Z-10.100 I-1.624 J0.248 K0.000 F1200.000
G2 X277.717 Y367.881 Z-10.100 I1.197 J4.253 K0.000 F1200.000
G3 X278.752 Y369.636 Z-10.100 I-0.555 J1.509 K0.000 F1200.000
G2 X279.058 Y369.665 Z-10.100 I0.155 J-0.007 K0.000 F1200.000
G3 X280.096 Y367.881 Z-10.100 I1.624 J-0.248 K0.000 F1200.000
G2 X280.096 Y359.376 Z-10.100 I-1.197 J-4.253 K0.000 F1200.000
G3 X279.062 Y357.622 Z-10.100 I0.555 J-1.509 K0.000 F1200.000
G2 X278.965 Y357.485 Z-10.100 I-0.155 J0.007 K0.000 F1200.000
G2 X278.811 Y357.506 Z-10.100 I-0.058 J0.144 K0.000 F1200.000
G0 Z5.000
G0 Z5.000
G0 Z5.000
G0 Z5.000
G0 X0.000 Y0.000
G0 X308.805 Y357.511
G0 X308.805 Y357.511 Z3.000
G1 X308.805 Y357.511 Z-10.100 F200.000
G2 X308.756 Y357.593 Z-10.100 I0.101 J0.117 K0.000 F1200.000
G3 X307.717 Y359.376 Z-10.100 I-1.624 J0.248 K0.000 F1200.000
G2 X307.717 Y367.881 Z-10.100 I1.197 J4.253 K0.000 F1200.000
G3 X308.752 Y369.636 Z-10.100 I-0.555 J1.509 K0.000 F1200.000
G2 X309.058 Y369.665 Z-10.100 I0.155 J-0.007 K0.000 F1200.000
G3 X310.096 Y367.881 Z-10.100 I1.624 J-0.248 K0.000 F1200.000
G2 X310.096 Y359.376 Z-10.100 I-1.197 J-4.253 K0.000 F1200.000
G3 X309.062 Y357.622 Z-10.100 I0.555 J-1.509 K0.000 F1200.000
G2 X308.965 Y357.485 Z-10.100 I-0.155 J0.007 K0.000 F1200.000
G2 X308.805 Y357.511 Z-10.100 I-0.058 J0.144 K0.000 F1200.000
G0 Z5.000
G0 Z5.000
G0 Z5.000
G0 Z5.000
G0 X0.000 Y0.000
G0 X332.050 Y344.093
G0 X332.050 Y344.093 Z3.000
G1 X332.050 Y344.093 Z-10.100 F200.000
G2 X332.051 Y344.317 Z-10.100 I0.108 J0.112 K0.000 F1200.000
G3 X333.077 Y346.109 Z-10.100 I-0.597 J1.531 K0.000 F1200.000
G2 X340.442 Y350.361 Z-10.100 I4.282 J1.089 K0.000 F1200.000
G3 X342.479 Y350.343 Z-10.100 I1.030 J1.235 K0.000 F1200.000
G2 X342.657 Y350.092 Z-10.100 I0.072 J-0.138 K0.000 F1200.000
G3 X341.632 Y348.301 Z-10.100 I0.597 J-1.531 K0.000 F1200.000
G2 X338.427 Y342.927 Z-10.100 I-4.284 J-1.088 K0.000 F1200.000
G2 X334.266 Y344.048 Z-10.100 I-1.073 J4.298 K0.000 F1200.000
G3 X332.230 Y344.067 Z-10.100 I-1.030 J-1.235 K0.000 F1200.000
G2 X332.050 Y344.093 Z-10.100 I-0.072 J0.138 K0.000 F1200.000
Attachments
path returns to origin.gcode.zip
(20.3 KiB) Downloaded 37 times
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: tool path returns to origin many times

Post by GeneFC »

steve123 wrote: Tue Aug 30, 2022 7:37 pm If I zip the file, it only compresses to 1.5MB.
The FCStd file is already a zip file, so re-zipping it will not do very much. However, it may be possible to shrink the FCStd file. In Edit >> Preferences >> General >> Document there is an option to adjust the amount of compression in the FCStd file. I believe the default is "3", but it is possible to increase the amount of compression.

The compression is always lossless, but high levels will cause slower save and open times.

I usually leave the compression at the default 3, but once in a while it is useful to shrink the file size below 1 MB.

Gene
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: tool path returns to origin many times

Post by GeneFC »

It appears that "Use Compensation", "Process Holes", and "Process Circles" are not really compatible in this case. For example, the small holes appear to be the same diameter as the milling cutter. Compensation is not going to work.

Also, if I select either Process Holes or Process Circles the multiple returns to origin disappear. I would break the path into two profile steps, one for holes and one for circles.

I think what is happening is that the algorithm is switching back and forth between holes and circles, and resetting the start position each time the transition is made.

There may be other optimizations you could try, such as completely separating the outline profile from the holes and "mouse ears" shapes.

Gene
steve123
Posts: 149
Joined: Fri Sep 04, 2015 8:58 pm

Re: tool path returns to origin many times

Post by steve123 »

GeneFC wrote: Tue Aug 30, 2022 9:19 pm It appears that "Use Compensation", "Process Holes", and "Process Circles" are not really compatible in this case. For example, the small holes appear to be the same diameter as the milling cutter. Compensation is not going to work.

Also, if I select either Process Holes or Process Circles the multiple returns to origin disappear. I would break the path into two profile steps, one for holes and one for circles.

I think what is happening is that the algorithm is switching back and forth between holes and circles, and resetting the start position each time the transition is made.

There may be other optimizations you could try, such as completely separating the outline profile from the holes and "mouse ears" shapes.

Gene
Thank you for the feedback :-) I did not think to try changing those parameters.

Regarding the holes that are the same size as the tool, I noticed that they are not included in the tool path. Is there a reason they are not included? If I increase the hole size slightly, to say 3.2 mm instead of 3.175, they are included.
steve123
Posts: 149
Joined: Fri Sep 04, 2015 8:58 pm

Re: tool path returns to origin many times

Post by steve123 »

GeneFC wrote: Tue Aug 30, 2022 9:19 pm Also, if I select either Process Holes or Process Circles the multiple returns to origin disappear. I would break the path into two profile steps, one for holes and one for circles.
I tried to generate a drill path for the 3.175mm holes but encountered a python exception:

Code: Select all

17:20:37  Traceback (most recent call last):
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/Path/PathScripts/PathUtils.py", line 71, in new_function
    res = function(*args, **kwargs)
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/Path/PathScripts/PathOp.py", line 820, in execute
    result = self.opExecute(obj)
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/Path/PathScripts/PathCircularHoleBase.py", line 194, in opExecute
    self.circularHoleExecute(obj, holes)
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/Path/PathScripts/PathDrilling.py", line 276, in circularHoleExecute
    PathFeedRate.setFeedRate(self.commandlist, obj.ToolController)
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/Path/PathFeedRate.py", line 80, in setFeedRate
    if _isVertical(machine.getPosition(), command):
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/Path/PathFeedRate.py", line 72, in _isVertical
    return PathGeom.isVertical(Part.makeLine(currentposition, endpoint))
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/Path/PathScripts/PathGeom.py", line 180, in isVertical
    if type(obj.Curve) == Part.Line or type(obj.Curve) == Part.LineSegment:
<class 'Base.FreeCADError'>: Unknown exception while reading attribute 'Curve' of object 'TopoShape'
17:20:38  Recompute failed! Please check report view.
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: tool path returns to origin many times

Post by GeneFC »

steve123 wrote: Tue Aug 30, 2022 9:53 pm Regarding the holes that are the same size as the tool, I noticed that they are not included in the tool path. Is there a reason they are not included? If I increase the hole size slightly, to say 3.2 mm instead of 3.175, they are included.
I do not think there is any significant tolerance required, but with rounding of floating point numbers it is quite possible that the nominal same size means the hole is slightly smaller than the tool.

The rounding is not just the common floating point uncertainty in the 15th digit (or thereabouts). Instead there is rounding to 6 or 7 digits several places in FreeCAD, including in the OCC kernel itself. There is also a user-settable tolerance in the Path WB that is often no more than 5 digits.

All of those things mean that trying to exactly match edge-on-edge is a risky proposition.

Gene
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: tool path returns to origin many times

Post by GeneFC »

steve123 wrote: Tue Aug 30, 2022 11:22 pm I tried to generate a drill path for the 3.175mm holes but encountered a python exception
Drilling is a bit broken for complex objects like this. The drilling operation automatically selects anything that the drill can fit into, including inappropriate openings. That is where the "curve" errors come from.

If you go in and laboriously select only the small holes the drilling works fine. Or alternatively deselect the openings that should not be drilled.

Gene
Joneb
Posts: 66
Joined: Tue Aug 11, 2020 10:35 am

Re: tool path returns to origin many times

Post by Joneb »

If you tick the box "Use Start Point" in the Profile operation tab the path does not return to origin every time. If I was doing this job I would have used 3 different profile operations as you have some inside cuts and some outside. How you did it works but I'm not sure why, Freecad seems to have worked it out for itself.

Code: Select all

OS: Windows 10 (10.0)
Word size of FreeCAD: 64-bit
Version: 0.21.29485 (Git)
Build type: Release
Branch: master
Hash: a236ca843fdd6674afb6d7ed1454fbd3b547f5ea
Python 3.8.13, Qt 5.12.9, Coin 4.0.0, Vtk 9.1.0, OCC 7.5.3
Locale: English/United Kingdom (en_GB)
Installed mods: 
  * FeedsAndSpeeds-master 0.4.0
Post Reply