Your message dated Tue, 11 Jul 2023 16:08:08 +0000
with message-id <[email protected]>
and subject line Bug#1040426: fixed in freecad 0.20.2+dfsg1-8
has caused the Debian Bug report #1040426,
regarding FreeCAD Path: Generate dangeruos first G-code move while G49 is active
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
1040426: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1040426
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: freecad
Version: 0.20.2+dfsg1-4
Severity: important
Forwarded: https://github.com/FreeCAD/FreeCAD/issues/9866
Tags: patch

I created a FreeCAD model and generated some Path Jobs to mill it out,
and was very surprised when the generated G-code ended up digging the
first cutter straight into the work table. This is using the linuxcnc
post processor, but is unrelated to the postprocessor used.

The model is available from
<URL: https://codeberg.org/pere/thinkpad-x230-dc-socket-bracket >. I
used the G-code in the subdirectory linuxcnc-jobs in commit
ff248e59b7c44bda3e6320e6499ee9c240156dae for this failure.

I tracked this down to the first move in the generated in the G-code
file, which is a "G0 Z", which is no longer safe when the
15 cm tool height compensation has been wiped out with the G49 in the
preamble.

This is the generated G-code:

(Exported by FreeCAD)
(Post Processor: linuxcnc_post)
(Output Time:2023-07-03 14:24:06.190303)
(begin preamble)
G17 G54 G40 G49 G80 G90
G21
(begin operation: G54)
(machine units: mm/min)
G54 
G0 Z19.000         ; <-------- This one is dangerous while G49 is active
(finish operation: G54)
(begin operation: 6mm-endmill001)
(machine units: mm/min)
(6mm-endmill001) 
M5
M6 T3 
G43 H3 
M3 S2500 
(finish operation: 6mm-endmill001)
(begin operation: MillFace)
(machine units: mm/min)
(MillFace) 
G0 Z19.000 

I see from <URL: https://forum.freecad.org/viewtopic.php?t=37839 > the
issue has been known since 2019, and was even mentioned as an issue when
the introduction of G43 was discussed in
<URL: https://forum.freecad.org/viewtopic.php?t=27180 >.  The dangerous
code is only generated when splitting the G-code into separate files per tool.

It is unclear to me why the G49 is used in the preamble to begin with.
Is it not better to put it just before the G43, and avoid any G0 move
before G43 has been used to load the correct tool height compensation?

I had used the automatic tool height measurement in the machine to set
the correct tool height compensation for the tool holder and bit in
question, and was very surprised to see that it dived straight down as
the first move. Was not able to stop it quickly enough to avoid damage.

I believe the following patch will fix the issue.  It is already sent
upstream.  I recommend considering it for the Debian package too.

commit d8f2f87130b28a769e91fe20ffad885feecf381d
Author: Petter Reinholdtsen <[email protected]>
Date:   Mon Jul 3 16:42:58 2023 +0200

    Avoid dagerous move without tool height compensation after setting first 
fixture
    
    The issue only happen when splitting jobs on tools (orderby == Tool), and 
when
    USE_TLO was active and the preamble include G49.  The first move is then 
done
    before tool height is set, and can cause damage if the existing tool height 
is set
    to more than the gap between the spindle and the table or work piece, when 
the machine
    take a sudden dive straight down.
    
    Removed move between G49 and first G43, to ensure all moves are done after 
G43
    correctly set tool height compensation.
    
    Rewrote code to introduce new method fixtureSetup() to ensure all orderby 
alternatives
    behave the same way.
    
    Fixes #9866.

diff --git a/src/Mod/Path/Path/Post/Command.py 
b/src/Mod/Path/Path/Post/Command.py
index 9393e7282f..d1f0635cf5 100644
--- a/src/Mod/Path/Path/Post/Command.py
+++ b/src/Mod/Path/Path/Post/Command.py
@@ -252,6 +252,33 @@ def resolveFileName(job, subpartname, sequencenumber):
     return fullPath
 
 
+def fixtureSetup(order, fixture, job):
+    """Convert a Fixure setting to _TempObject instance with a G0 move to a
+    safe height every time the fixture coordinate system change.  Skip
+    the move for first fixture, to avoid moving before tool and tool
+    height compensation is enabled.
+
+    """
+
+    fobj = _TempObject()
+    c1 = Path.Command(fixture)
+    fobj.Path = Path.Path([c1])
+    # Avoid any tool move after G49 in preamble and before tool change
+    # and G43 in case tool height compensation is in use, to avoid
+    # dangerous move without tool compesation.
+    if order != 0:
+        c2 = Path.Command(
+            "G0 Z"
+            + str(
+                job.Stock.Shape.BoundBox.ZMax
+                + job.SetupSheet.ClearanceHeightOffset.Value
+            )
+        )
+        fobj.Path.addCommands(c2)
+    fobj.InList.append(job)
+    return fobj
+
+
 def buildPostList(job):
     """Takes the job and determines the specific objects and order to
     postprocess  Returns a list of objects which can be passed to
@@ -269,20 +296,7 @@ def buildPostList(job):
         currTool = None
         for index, f in enumerate(wcslist):
             # create an object to serve as the fixture path
-            fobj = _TempObject()
-            c1 = Path.Command(f)
-            fobj.Path = Path.Path([c1])
-            if index != 0:
-                c2 = Path.Command(
-                    "G0 Z"
-                    + str(
-                        job.Stock.Shape.BoundBox.ZMax
-                        + job.SetupSheet.ClearanceHeightOffset.Value
-                    )
-                )
-                fobj.Path.addCommands(c2)
-            fobj.InList.append(job)
-            sublist = [fobj]
+            sublist = [fixtureSetup(index, f, job)]
 
             # Now generate the gcode
             for obj in job.Operations.Group:
@@ -306,20 +320,9 @@ def buildPostList(job):
 
         # Build the fixture list
         fixturelist = []
-        for f in wcslist:
+        for index, f in enumerate(wcslist):
             # create an object to serve as the fixture path
-            fobj = _TempObject()
-            c1 = Path.Command(f)
-            c2 = Path.Command(
-                "G0 Z"
-                + str(
-                    job.Stock.Shape.BoundBox.ZMax
-                    + job.SetupSheet.ClearanceHeightOffset.Value
-                )
-            )
-            fobj.Path = Path.Path([c1, c2])
-            fobj.InList.append(job)
-            fixturelist.append(fobj)
+            fixturelist.append(fixtureSetup(index, f, job))
 
         # Now generate the gcode
         curlist = []  # list of ops for tool, will repeat for each fixture
@@ -374,7 +377,6 @@ def buildPostList(job):
         # Order by operation means ops are done in each fixture in
         # sequence.
         currTool = None
-        firstFixture = True
 
         # Now generate the gcode
         for obj in job.Operations.Group:
@@ -386,22 +388,8 @@ def buildPostList(job):
             sublist = []
             Path.Log.debug("obj: {}".format(obj.Name))
 
-            for f in wcslist:
-                fobj = _TempObject()
-                c1 = Path.Command(f)
-                fobj.Path = Path.Path([c1])
-                if not firstFixture:
-                    c2 = Path.Command(
-                        "G0 Z"
-                        + str(
-                            job.Stock.Shape.BoundBox.ZMax
-                            + job.SetupSheet.ClearanceHeightOffset.Value
-                        )
-                    )
-                    fobj.Path.addCommands(c2)
-                fobj.InList.append(job)
-                sublist.append(fobj)
-                firstFixture = False
+            for index, f in enumerate(wcslist):
+                sublist.append(fixtureSetup(index, f, job))
                 tc = PathUtil.toolControllerForOp(obj)
                 if tc is not None:
                     if job.SplitOutput or (tc.ToolNumber != currTool):

-- 
Happy hacking
Petter Reinholdtsen

--- End Message ---
--- Begin Message ---
Source: freecad
Source-Version: 0.20.2+dfsg1-8
Done: Petter Reinholdtsen <[email protected]>

We believe that the bug you reported is fixed in the latest version of
freecad, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Petter Reinholdtsen <[email protected]> (supplier of updated freecad package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Format: 1.8
Date: Tue, 11 Jul 2023 17:29:12 +0200
Source: freecad
Architecture: source
Version: 0.20.2+dfsg1-8
Distribution: unstable
Urgency: medium
Maintainer: Debian Science Maintainers 
<[email protected]>
Changed-By: Petter Reinholdtsen <[email protected]>
Closes: 1040426
Changes:
 freecad (0.20.2+dfsg1-8) unstable; urgency=medium
 .
   * Team upload.
 .
   * Updated patch metadata for patches now applied upstream.
   * Added 1110-path-g49-move-0.20.patch avoiding dangerous G-code
     from Path (Closes: #1040426).
Checksums-Sha1:
 0df06454a81f6340dc5fc39efc12d614e8868f25 3423 freecad_0.20.2+dfsg1-8.dsc
 c6a57e2cac695a45509000a07c3d6067f4b9f140 33256 
freecad_0.20.2+dfsg1-8.debian.tar.xz
 7ccebfea2c3ebb85efdb33b5d2bbae9bc28ac1d9 32816 
freecad_0.20.2+dfsg1-8_source.buildinfo
Checksums-Sha256:
 5bb2b377b68ebf4a1adffcfa35e3062f423b04e3df7628b29696de7c7ae088cf 3423 
freecad_0.20.2+dfsg1-8.dsc
 bead7f91fc639475ffd3c8282b2d7b8eb3b338bb0085bbbff6dff214a691cced 33256 
freecad_0.20.2+dfsg1-8.debian.tar.xz
 bf8f02a12ce8343f3d03b4c2e55804aac0cfdb5565c7d1361985c7860bc7b744 32816 
freecad_0.20.2+dfsg1-8_source.buildinfo
Files:
 a9379e42e73ca9592533d521cec818ac 3423 science optional 
freecad_0.20.2+dfsg1-8.dsc
 9302d75afd81bc3810a4b658f6447d60 33256 science optional 
freecad_0.20.2+dfsg1-8.debian.tar.xz
 8f7f3aa79955f974ad9017250a5f59d1 32816 science optional 
freecad_0.20.2+dfsg1-8_source.buildinfo

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEERqLf4owIeylOb9kkgSgKoIe6+w4FAmSteEEACgkQgSgKoIe6
+w59fA//Yq7Mbg4dwPUZ4J7gEOjywjqcfk8iqoVMq9iD2tSxdftjMX1SDBbaIeq5
A/9+eUm0eB2QwjVnmFYa/UZKVaOEmcyX+b+mhnwpsvuSjvFNwbDS7L7zIp6OSyWw
sHzLnC3sKzYYIX6QPZ/V1MG39TzMGnMzZyfYIwT/12SqAYjWLRqXO4nAeuwhJoXu
McUEy7ns52QE83jNE5ZSyhhShJdBectkkuFINVfiTTkqXnUPXasu0EytyGK3kNB+
HlvUBojyPjGM7I09EgldeB416JwdYxFnbh9Q56XWASsAhzcTDOHpAm0FuM6xL3RC
/sGvkVj0JhqhMbycYjzGOUSYBNfmnJKhG7yZy6Gr847gdVGQRYvsiPlgGux6XtXD
3KDWjqfzX3Px9qA5LReRX52nzBkguWheJ2ODCNhpZki9BSatUWt68PsmLrnLLfTQ
v1SUAQgItuevW4Y3T2FdoZNcfkkdkY9plYX0JCfWY9+txiX9dpxeNMoHyo+C+MkX
zRLoDn3hYQZo+gGGsBJ4IFrPI79U/WAuhkja6EIhC4BxeR3m/pmcG+11a68rOlBN
Wkrz+p0YuHM50qWK07hMWjuqwJ3YOP/a4OJlHClVmOXjLjYJhvXhdhtRXGh7iWm3
hZduyenJPTlacf9ZzH9BU8szOcknEFk4hvIQuXMLxBCmfaXGjbE=
=DQNG
-----END PGP SIGNATURE-----

--- End Message ---
-- 
debian-science-maintainers mailing list
[email protected]
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/debian-science-maintainers

Reply via email to