Drilling op touches stock on horizontal move on LinuxCNC

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
agren
Posts: 40
Joined: Sat Apr 20, 2019 7:37 am

Drilling op touches stock on horizontal move on LinuxCNC

Post by agren »

Hi all,

I think I've found a bug where the drilling operation is touching the stock while moving horizontally between holes. Technically it's seems to be positioned 0 mm from the top of the stock but neither my stock nor my table is perfectly level.

FreeCAD renders a lift to Safe Height as I would expect.
Camotics lift to Safe Height.
LinuxCNC does not lift to Safe Height.
The gcode is generated by the linuxcnc post processor.

A workaround is to manually set Start Depth for the operation to something above the stock.

Anyone noticed the same thing?

FreeCAD:
freecad.png
freecad.png (10.96 KiB) Viewed 1090 times
Camotics:
camotics-renders-path-as-expected.png
camotics-renders-path-as-expected.png (6.01 KiB) Viewed 1090 times
LinuxCNC (top of stock at Z=0):
linuxcnc-touches-stock-on-horizontal-feed.png
linuxcnc-touches-stock-on-horizontal-feed.png (19.94 KiB) Viewed 1090 times

Code: Select all

OS: Ubuntu 20.04.4 LTS (MATE/mate)
Word size of FreeCAD: 64-bit
Version: 0.20.
Build type: Release
Branch: unknown
Hash: 134fa8b7ea5000ae648afcbe9b36c37a32974e89
Python 3.8.10, Qt 5.12.8, Coin 4.0.0, OCC 7.5.2
Locale: English/United States (en_US)
Attachments
path-not-lifting-between-drill-holes.ngc.txt
(720 Bytes) Downloaded 11 times
path-not-lifting-between-drill-holes.FCStd
(22.72 KiB) Downloaded 15 times
agren
Posts: 40
Joined: Sat Apr 20, 2019 7:37 am

Re: Drilling op touches stock on horizontal move on LinuxCNC

Post by agren »

The offending gcode can be seen here. The top of my stock is at Z=0 and my safe height is at Z=3.
G81...R0.000 in G99 mode tells LinuxCNC to go to Z=0 when the drill cycle is done.

Line 26-30 (Drilling the first hole):

Code: Select all

G90 
G99 
G0 X10.000 Y10.000 
G0 Z3.000 
G81 X10.000 Y10.000 Z-10.000 F100.000 R0.000 
G0 X20.000 Y10.000 
G0 Z3.000
agren
Posts: 40
Joined: Sat Apr 20, 2019 7:37 am

Re: Drilling op touches stock on horizontal move on LinuxCNC

Post by agren »

Suggested fix here.
It adds a retractheight argument to drill_generator.generate().

LinuxCNC lifts to Retract Height (Z=3) after fix:
linuxcnc-fix.png
linuxcnc-fix.png (12.04 KiB) Viewed 963 times
User avatar
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Drilling op touches stock on horizontal move on LinuxCNC

Post by sliptonic »

I think the default value for retractHeight should be None. Then the generator should check if it's none and use startpoint.z if so. Otherwise use the explicitly passed retractHeight.

Why don't you create a draft PR for the change and we'll go from there.

I would like to make the generators as thoroughly tested as possible. That's why they're structured as pure functions. So please add additional tests to
https://github.com/FreeCAD/FreeCAD/blob ... nerator.py
agren
Posts: 40
Joined: Sat Apr 20, 2019 7:37 am

Re: Drilling op touches stock on horizontal move on LinuxCNC

Post by agren »

Sounds like a plan!
agren
Posts: 40
Joined: Sat Apr 20, 2019 7:37 am

Re: Drilling op touches stock on horizontal move on LinuxCNC

Post by agren »

Draft pull-request here for those interested.
User avatar
sliptonic
Veteran
Posts: 3459
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Drilling op touches stock on horizontal move on LinuxCNC

Post by sliptonic »

I think this looks great. I don't see any problems but let's see if we can get some others testing as well.

BTW, This thread is a master class on how to do it:
Excellent, clear description ... check
Pictures... check
FreeCAD info... check
Attached project file... check
Attached output... check
Suggested fix... check
Draft PR... check
Unit tests.... check

Brilliant!
Post Reply