winder / Universal-G-Code-Sender

A cross-platform G-Code sender for GRBL, Smoothieware, TinyG and G2core.
http://winder.github.io/ugs_website/
GNU General Public License v3.0
1.84k stars 758 forks source link

Program freezes when arc radii are too large (and python fix) #2517

Closed gatornuke235 closed 1 month ago

gatornuke235 commented 1 month ago

Version

2.1.6

Hardware / Firmware

GRBL 1.1

What happened

When loading a gcode file with an intricate geometry that may have extremely wide radius arcs the UGS sender freezes. older versions would send the router off in random directions when that line was executed.

As a result I wrote a python script to scrub the gcode file and change the G2 or G3 commands to a G1 line. After all, any short arc segments with very large radius are basically a straight line:

import sys

def process_gcode(input_file, output_file, threshold):
    threshold = float(threshold)
    with open(input_file, 'r') as file:
        lines = file.readlines()

    with open(output_file, 'w') as file:

        for line in lines:
            if line.startswith(('G2', 'G3')):
                exceeded = False
                parts = line.split()

                for part in parts[1:]:
                    if part.startswith(('I', 'J', 'K')):
                        value = float(part[1:])
                        if abs(value) > threshold:
                            exceeded = True

                if (exceeded):            
                    new_line = 'G1' + ' (' + parts[0] + ')' # Overrite the original G2 or G3 command
                    for part in parts[1:]:
                        if part.startswith(('X', 'Y', 'Z', 'F')):
                            new_line += ' ' + part
                        elif part.startswith(('I', 'J', 'K')):
                            new_line += ' (' + part + ')'  # Comment out arc
                    file.write(new_line + '\n')
                else:
                    file.write(line)
            else:
                file.write(line)

if __name__ == '__main__':
    args = sys.argv
    globals()[args[1]](*args[2:])

This is callable from the command shell as such: python cleaner.py process_gcode input.gcode output.gcode 800000

Which will change this: G3 X-35.429 Y-19.142 Z-2.000 I3486934.545 J205113.019 K0.000 F500.000 into this: G1 (G3) X-35.429 Y-19.142 Z-2.000 (I3486934.545) (J205113.019) (K0.000) F500.000

How to reproduce

include this line in any gcode: G3 X-35.429 Y-19.142 Z-2.000 I3486934.545 J205113.019 K0.000 F500.000

Operating System

Windows 11

Anything else

Every time

breiler commented 1 month ago

Can you post a sample gcode program with the problem. This could be related to the visualizer which will take an arc and split it up into several small lines.

gatornuke235 commented 1 month ago

Sure. this should cause the error:

(Exported by FreeCAD)
(Post Processor: grbl_post)
(Output Time:2024-05-10 01:52:00.747480)
(Begin preamble)
G17 G90
G21
(Begin operation: Fixture)
(Path: Fixture)
G54
(Finish operation: Fixture)
(Begin operation: 4th-inch-endmill-6.35mm-001)
(Path: 4th-inch-endmill-6.35mm-001)
(4th-inch-endmill-6.35mm)
(Begin toolchange)
( M6 T1 )
M3 S20000
(Finish operation: 4th-inch-endmill-6.35mm-001)
(Begin operation: Pocket_Shape)
(Path: Pocket_Shape)
(Pocket_Shape)
G0 Z6
G0 X0 Y0
G0 X-18.550 Y52.769
G0 X-18.550 Y52.769 Z4
G1 X-18.550 Y52.769 Z-4 F200
G2 X-18.725 Y55.370 Z-4 I40.631 J4.042 K0 F700
G1 X-18.725 Y74.856 Z-4 F700
G3 X-24.456 Y74.256 Z-4 I40.691 J-416.520 K0 F700
G1 X-27.344 Y73.818 Z-4 F700
G2 X-27.306 Y72.929 Z-4 I-19.200 J-1.250 K0 F700
G2 X-27.306 Y52.107 Z-4 I-2426220.106 J-10.411 K0 F700
G2 X-21.382 Y51.786 Z-4 I2.804 J-3.066 K0 F700
G2 X-19.584 Y52.648 Z-4 I3.996 J-6.028 K0 F700
G2 X-18.550 Y52.769 Z-4 I0.974 J-3.837 K0 F700
G0 Z6
G0 X-27.306 Y54.252 Z6
G0 X-27.306 Y54.252 Z4
G1 X-27.306 Y54.252 Z-4 F200
G1 X-27.306 Y52.107 Z-4 F700
G2 X-25.974 Y52.919 Z-4 I2.688 J-2.915 K0 F700
G1 X-27.306 Y54.252 Z-4 F700
G1 X-27.306 Y60.089 Z-4 F700
G1 X-19.797 Y52.580 Z-4 F700
G2 X-18.550 Y52.769 Z-4 I1.106 J-3.076 K0 F700
G2 X-18.719 Y55.147 Z-4 I237.203 J18.072 K0 F700
G2 X-18.725 Y57.345 Z-4 I31.094 J1.183 K0 F700
G1 X-27.306 Y65.926 Z-4 F700
G3 X-27.306 Y71.763 Z-4 I-4458.754 J2.919 K0 F700
G1 X-18.725 Y63.182 Z-4 F700
G1 X-18.725 Y69.019 Z-4 F700
G1 X-24.028 Y74.321 Z-4 F700
G2 X-18.725 Y74.856 Z-4 I401.296 J-3952.942 K0 F700
G0 Z6
G0 Z6
G0 X-18.725 Y74.856
G0 X-51.416 Y68.830
G0 X-51.416 Y68.830 Z4
G1 X-51.416 Y68.830 Z-4 F200
G1 X-54.967 Y67.785 Z-4 F700
G1 X-57.676 Y66.988 Z-4 F700
G3 X-57.755 Y66.965 Z-4 I0.895 J-3.186 K0 F700
G3 X-58.363 Y66.770 Z-4 I2.430 J-8.631 K0 F700
G1 X-58.363 Y66.770 Z-4 F700
G2 X-59.959 Y66.238 Z-4 I-1695759.683 J5087278.619 K0 F700
G1 X-60.746 Y65.976 Z-4 F700
G2 X-60.535 Y62.463 Z-4 I-216.044 J-14.692 K0 F700
G2 X-60.534 Y62.268 Z-4 I-9.979 J-0.170 K0 F700
G1 X-60.534 Y46.894 Z-4 F700
G3 X-60.298 Y47.031 Z-4 I-1.513 J2.887 K0 F700
G2 X-52.850 Y48.511 Z-4 I4.065 J-0.978 K0 F700
G2 X-52.079 Y47.278 Z-4 I-4.772 J-3.839 K0 F700
G2 X-51.741 Y47.465 Z-4 I0.867 J-1.169 K0 F700
G2 X-51.717 Y51.287 Z-4 I57.204 J1.549 K0 F700
G2 X-49.019 Y55.697 Z-4 I5.383 J-0.263 K0 F700
G2 X-51.741 Y59.631 Z-4 I1.466 J3.923 K0 F700
G2 X-51.741 Y67.225 Z-4 I2329.319 J3.792 K0 F700
G2 X-51.416 Y68.830 Z-4 I4.149 J-0.006 K0 F700
G0 Z6
G0 X-60.534 Y62.021 Z6
G0 X-60.534 Y62.021 Z4
G1 X-60.534 Y62.021 Z-4 F200
G1 X-54.687 Y67.868 Z-4 F700
G3 X-60.746 Y65.976 Z-4 I23.532 J-86.017 K0 F700
G2 X-60.534 Y62.381 Z-4 I-471.495 J-29.551 K0 F700
G2 X-60.534 Y62.021 Z-4 I-62.345 J-0.195 K0 F700
G1 X-60.534 Y56.183 Z-4 F700
G1 X-51.741 Y64.976 Z-4 F700
G1 X-51.741 Y59.631 Z-4 F700
G3 X-51.712 Y59.168 Z-4 I3.346 J-0.022 K0 F700
G1 X-60.534 Y50.346 Z-4 F700
G1 X-60.534 Y46.894 Z-4 F700
G3 X-60.298 Y47.031 Z-4 I-1.513 J2.887 K0 F700
G2 X-55.003 Y50.040 Z-4 I4.047 J-0.958 K0 F700
G1 X-49.256 Y55.788 Z-4 F700
G2 X-49.019 Y55.697 Z-4 I-5.097 J-13.751 K0 F700
G3 X-51.717 Y51.287 Z-4 I2.685 J-4.673 K0 F700
G3 X-51.741 Y47.465 Z-4 I57.180 J-2.273 K0 F700
G0 Z6
G0 Z6
G0 X-51.741 Y47.465
G0 X-4.873 Y57.845
G0 X-4.873 Y57.845 Z4
G1 X-4.873 Y57.845 Z-4 F200
G2 X-1.531 Y56.201 Z-4 I0.052 J-4.112 K0 F700
G2 X0.542 Y58.244 Z-4 I7.086 J-5.116 K0 F700
G2 X4.938 Y58.317 Z-4 I2.256 J-3.481 K0 F700
G2 X6.797 Y59.391 Z-4 I2.808 J-2.714 K0 F700
G2 X3.709 Y63.419 Z-4 I1.077 J4.023 K0 F700
G2 X3.709 Y72.302 Z-4 I448759.606 J4.264 K0 F700
G2 X5.251 Y75.534 Z-4 I4.137 J0.010 K0 F700
G1 X-5.084 Y75.534 Z-4 F700
G3 X-5.070 Y67.756 Z-4 I1333.845 J-1.408 K0 F700
G1 X-4.882 Y64.752 Z-4 F700
G2 X-4.873 Y64.468 Z-4 I-4.485 J-0.291 K0 F700
G1 X-4.873 Y57.845 Z-4 F700
G1 X-4.873 Y63.107 Z-4 F200
G1 X-4.873 Y57.845 Z-4 F700
G2 X-1.531 Y56.201 Z-4 I0.052 J-4.112 K0 F700
G2 X0.226 Y58.009 Z-4 I6.814 J-4.865 K0 F700
G1 X-4.873 Y63.107 Z-4 F700
G3 X-4.882 Y64.752 Z-4 I-15.363 J0.734 K0 F700
G2 X-5.084 Y69.156 Z-4 I56.215 J4.788 K0 F700
G1 X5.375 Y58.697 Z-4 F700
G2 X6.797 Y59.391 Z-4 I2.311 J-2.931 K0 F700
G2 X3.709 Y63.401 Z-4 I1.065 J4.014 K0 F700
G2 X3.709 Y66.200 Z-4 I541.182 J1.407 K0 F700
G1 X-5.084 Y74.993 Z-4 F700
G1 X-5.084 Y75.534 Z-4 F700
G1 X0.212 Y75.534 Z-4 F700
G1 X3.709 Y72.037 Z-4 F700
G2 X5.251 Y75.534 Z-4 I4.180 J0.245 K0 F700
G1 X0.212 Y75.534 Z-4 F700
G0 Z6
G0 X16.095 Y75.307 Z6
G0 X16.095 Y75.307 Z4
G1 X16.095 Y75.307 Z-4 F200
G2 X17.960 Y71.305 Z-4 I-3.588 J-4.108 K0 F700
G2 X17.985 Y69.112 Z-4 I-27.623 J-1.404 K0 F700
G2 X17.985 Y63.208 Z-4 I-8501.999 J-2.949 K0 F700
G2 X13.808 Y59.034 Z-4 I-4.187 J0.013 K0 F700
G3 X10.636 Y59.034 Z-4 I-1.582 J-131114.769 K0 F700
G2 X9.773 Y59.087 Z-4 I0.375 J13.340 K0 F700
G2 X11.532 Y57.402 Z-4 I-1.973 J-3.820 K0 F700
G1 X12.136 Y56.356 Z-4 F700
G1 X12.136 Y56.356 Z-4 F700
G1 X13.510 Y53.977 Z-4 F700
G2 X20.271 Y53.086 Z-4 I3.063 J-2.852 K0 F700
G2 X20.634 Y52.480 Z-4 I-9.062 J-5.844 K0 F700
G2 X21.366 Y53.387 Z-4 I4.925 J-3.222 K0 F700
G2 X24.864 Y59.105 Z-4 I3.880 J1.555 K0 F700
G1 X24.873 Y59.283 Z-4 F700
G3 X24.873 Y73.145 Z-4 I-9863.857 J6.915 K0 F700
G3 X24.773 Y74.303 Z-4 I-4.341 J0.208 K0 F700
G3 X23.953 Y74.644 Z-4 I-1.042 J-1.350 K0 F700
G3 X20.733 Y74.982 Z-4 I-4.823 J-30.401 K0 F700
G2 X16.095 Y75.307 Z-4 I15.348 J252.497 K0 F700
G0 Z6
G0 X24.759 Y74.336 Z6
G0 X24.759 Y74.336 Z4
G1 X24.759 Y74.336 Z-4 F200
G3 X23.953 Y74.644 Z-4 I-1.148 J-1.798 K0 F700
G3 X20.733 Y74.982 Z-4 I-4.823 J-30.401 K0 F700
G1 X19.880 Y75.038 Z-4 F700
G1 X19.880 Y75.038 Z-4 F700
G2 X18.100 Y75.158 Z-4 I5.879 J100.190 K0 F700
G1 X24.873 Y68.385 Z-4 F700
G1 X24.873 Y62.548 Z-4 F700
G1 X17.988 Y69.432 Z-4 F700
G3 X17.985 Y63.599 Z-4 I264.256 J-3.077 K0 F700
G1 X23.076 Y58.508 Z-4 F700
G3 X21.081 Y54.665 Z-4 I2.165 J-3.562 K0 F700
G1 X16.051 Y59.695 Z-4 F700
G2 X13.808 Y59.034 Z-4 I-2.235 J3.453 K0 F700
G1 X10.874 Y59.034 Z-4 F700
G1 X14.933 Y54.975 Z-4 F700
G3 X13.510 Y53.977 Z-4 I1.457 J-3.589 K0 F700
G1 X12.136 Y56.356 Z-4 F700
G3 X10.795 Y58.363 Z-4 I-8.108 J-3.967 K0 F700
G3 X9.773 Y59.087 Z-4 I-2.237 J-2.076 K0 F700
G3 X10.874 Y59.034 Z-4 I1.083 J11.188 K0 F700
G0 Z6
G0 Z6
G0 X10.874 Y59.034
G0 X42.535
G0 X42.535 Z4
G1 X42.535 Y59.034 Z-4 F200
G1 X42.535 Y50.430 Z-4 F700
G2 X42.747 Y47.113 Z-4 I-61.285 J-5.576 K0 F700
G1 X42.747 Y46.903 Z-4 F700
G2 X45.479 Y46.733 Z-4 I1.123 J-3.983 K0 F700
G3 X47.241 Y46.115 Z-4 I9.746 J24.955 K0 F700
G2 X47.906 Y45.867 Z-4 I-2.260 J-7.088 K0 F700
G2 X51.328 Y47.896 Z-4 I3.545 J-2.079 K0 F700
G2 X51.328 Y51.808 Z-4 I292.360 J1.943 K0 F700
G2 X53.490 Y55.429 Z-4 I4.174 J-0.036 K0 F700
G2 X51.690 Y58.361 Z-4 I2.390 J3.486 K0 F700
G2 X51.328 Y60.671 Z-4 I12.967 J3.214 K0 F700
G2 X51.328 Y65.741 Z-4 I163526.634 J2.532 K0 F700
G2 X53.090 Y69.144 Z-4 I4.157 J0.005 K0 F700
G1 X51.421 Y69.580 Z-4 F700
G2 X51.421 Y69.580 Z-4 I-0 J0 K0 F700
G1 X48.058 Y70.460 Z-4 F700
G2 X47.101 Y70.710 Z-4 I1.664 J8.320 K0 F700
G2 X46.843 Y70.777 Z-4 I3.010 J12.040 K0 F700
G1 X46.843 Y70.777 Z-4 F700
G3 X42.535 Y71.828 Z-4 I-29.471 J-111.450 K0 F700
G1 X42.535 Y59.034 Z-4 F700
G0 Z6
G0 X45.398 Y71.152 Z6
G0 X45.398 Y71.152 Z4
G1 X45.398 Y71.152 Z-4 F200
G3 X42.535 Y71.828 Z-4 I-29.743 J-119.508 K0 F700
G1 X42.535 Y68.289 Z-4 F700
G1 X45.398 Y71.152 Z-4 F700
G2 X46.843 Y70.777 Z-4 I-65.334 J-254.972 K0 F700
G2 X47.101 Y70.710 Z-4 I-0.380 J-1.981 K0 F700
G3 X48.058 Y70.460 Z-4 I2.621 J8.070 K0 F700
G1 X50.028 Y69.945 Z-4 F700
G1 X42.535 Y62.452 Z-4 F700
G1 X42.535 Y56.615 Z-4 F700
G1 X51.328 Y65.408 Z-4 F700
G1 X51.328 Y60.671 Z-4 F700
G3 X51.439 Y59.682 Z-4 I5.266 J0.092 K0 F700
G1 X42.535 Y50.778 Z-4 F700
G3 X42.594 Y49.550 Z-4 I18.680 J0.278 K0 F700
G2 X42.747 Y46.903 Z-4 I-28.146 J-2.954 K0 F700
G2 X44.583 Y46.988 Z-4 I1.097 J-3.814 K0 F700
G1 X53.225 Y55.631 Z-4 F700
G3 X53.490 Y55.429 Z-4 I1.401 J1.556 K0 F700
G3 X51.328 Y51.808 Z-4 I2.012 J-3.657 K0 F700
G3 X51.328 Y47.896 Z-4 I292.387 J-1.969 K0 F700
G0 Z6
G0 Z6
(Finish operation: Pocket_Shape)
(Begin postamble)
M5
G17 G90
M2

and this shouldn't

(Exported by FreeCAD)
(Post Processor: grbl_post)
(Output Time:2024-05-10 01:52:00.747480)
(Begin preamble)
G17 G90
G21
(Begin operation: Fixture)
(Path: Fixture)
G54
(Finish operation: Fixture)
(Begin operation: 4th-inch-endmill-6.35mm-001)
(Path: 4th-inch-endmill-6.35mm-001)
(4th-inch-endmill-6.35mm)
(Begin toolchange)
( M6 T1 )
M3 S20000
(Finish operation: 4th-inch-endmill-6.35mm-001)
(Begin operation: Pocket_Shape)
(Path: Pocket_Shape)
(Pocket_Shape)
G0 Z6
G0 X0 Y0
G0 X-18.550 Y52.769
G0 X-18.550 Y52.769 Z4
G1 X-18.550 Y52.769 Z-4 F200
G2 X-18.725 Y55.370 Z-4 I40.631 J4.042 K0 F700
G1 X-18.725 Y74.856 Z-4 F700
G3 X-24.456 Y74.256 Z-4 I40.691 J-416.520 K0 F700
G1 X-27.344 Y73.818 Z-4 F700
G2 X-27.306 Y72.929 Z-4 I-19.200 J-1.250 K0 F700
G1 (G2) X-27.306 Y52.107 Z-4 F700
G2 X-21.382 Y51.786 Z-4 I2.804 J-3.066 K0 F700
G2 X-19.584 Y52.648 Z-4 I3.996 J-6.028 K0 F700
G2 X-18.550 Y52.769 Z-4 I0.974 J-3.837 K0 F700
G0 Z6
G0 X-27.306 Y54.252 Z6
G0 X-27.306 Y54.252 Z4
G1 X-27.306 Y54.252 Z-4 F200
G1 X-27.306 Y52.107 Z-4 F700
G2 X-25.974 Y52.919 Z-4 I2.688 J-2.915 K0 F700
G1 X-27.306 Y54.252 Z-4 F700
G1 X-27.306 Y60.089 Z-4 F700
G1 X-19.797 Y52.580 Z-4 F700
G2 X-18.550 Y52.769 Z-4 I1.106 J-3.076 K0 F700
G2 X-18.719 Y55.147 Z-4 I237.203 J18.072 K0 F700
G2 X-18.725 Y57.345 Z-4 I31.094 J1.183 K0 F700
G1 X-27.306 Y65.926 Z-4 F700
G1 (G3) X-27.306 Y71.763 Z-4 F700
G1 X-18.725 Y63.182 Z-4 F700
G1 X-18.725 Y69.019 Z-4 F700
G1 X-24.028 Y74.321 Z-4 F700
G1 (G2) X-18.725 Y74.856 Z-4 F700
G0 Z6
G0 Z6
G0 X-18.725 Y74.856
G0 X-51.416 Y68.830
G0 X-51.416 Y68.830 Z4
G1 X-51.416 Y68.830 Z-4 F200
G1 X-54.967 Y67.785 Z-4 F700
G1 X-57.676 Y66.988 Z-4 F700
G3 X-57.755 Y66.965 Z-4 I0.895 J-3.186 K0 F700
G3 X-58.363 Y66.770 Z-4 I2.430 J-8.631 K0 F700
G1 X-58.363 Y66.770 Z-4 F700
G1 (G2) X-59.959 Y66.238 Z-4 F700
G1 X-60.746 Y65.976 Z-4 F700
G2 X-60.535 Y62.463 Z-4 I-216.044 J-14.692 K0 F700
G2 X-60.534 Y62.268 Z-4 I-9.979 J-0.170 K0 F700
G1 X-60.534 Y46.894 Z-4 F700
G3 X-60.298 Y47.031 Z-4 I-1.513 J2.887 K0 F700
G2 X-52.850 Y48.511 Z-4 I4.065 J-0.978 K0 F700
G2 X-52.079 Y47.278 Z-4 I-4.772 J-3.839 K0 F700
G2 X-51.741 Y47.465 Z-4 I0.867 J-1.169 K0 F700
G2 X-51.717 Y51.287 Z-4 I57.204 J1.549 K0 F700
G2 X-49.019 Y55.697 Z-4 I5.383 J-0.263 K0 F700
G2 X-51.741 Y59.631 Z-4 I1.466 J3.923 K0 F700
G1 (G2) X-51.741 Y67.225 Z-4 F700
G2 X-51.416 Y68.830 Z-4 I4.149 J-0.006 K0 F700
G0 Z6
G0 X-60.534 Y62.021 Z6
G0 X-60.534 Y62.021 Z4
G1 X-60.534 Y62.021 Z-4 F200
G1 X-54.687 Y67.868 Z-4 F700
G3 X-60.746 Y65.976 Z-4 I23.532 J-86.017 K0 F700
G2 X-60.534 Y62.381 Z-4 I-471.495 J-29.551 K0 F700
G2 X-60.534 Y62.021 Z-4 I-62.345 J-0.195 K0 F700
G1 X-60.534 Y56.183 Z-4 F700
G1 X-51.741 Y64.976 Z-4 F700
G1 X-51.741 Y59.631 Z-4 F700
G3 X-51.712 Y59.168 Z-4 I3.346 J-0.022 K0 F700
G1 X-60.534 Y50.346 Z-4 F700
G1 X-60.534 Y46.894 Z-4 F700
G3 X-60.298 Y47.031 Z-4 I-1.513 J2.887 K0 F700
G2 X-55.003 Y50.040 Z-4 I4.047 J-0.958 K0 F700
G1 X-49.256 Y55.788 Z-4 F700
G2 X-49.019 Y55.697 Z-4 I-5.097 J-13.751 K0 F700
G3 X-51.717 Y51.287 Z-4 I2.685 J-4.673 K0 F700
G3 X-51.741 Y47.465 Z-4 I57.180 J-2.273 K0 F700
G0 Z6
G0 Z6
G0 X-51.741 Y47.465
G0 X-4.873 Y57.845
G0 X-4.873 Y57.845 Z4
G1 X-4.873 Y57.845 Z-4 F200
G2 X-1.531 Y56.201 Z-4 I0.052 J-4.112 K0 F700
G2 X0.542 Y58.244 Z-4 I7.086 J-5.116 K0 F700
G2 X4.938 Y58.317 Z-4 I2.256 J-3.481 K0 F700
G2 X6.797 Y59.391 Z-4 I2.808 J-2.714 K0 F700
G2 X3.709 Y63.419 Z-4 I1.077 J4.023 K0 F700
G1 (G2) X3.709 Y72.302 Z-4 F700
G2 X5.251 Y75.534 Z-4 I4.137 J0.010 K0 F700
G1 X-5.084 Y75.534 Z-4 F700
G1 (G3) X-5.070 Y67.756 Z-4 F700
G1 X-4.882 Y64.752 Z-4 F700
G2 X-4.873 Y64.468 Z-4 I-4.485 J-0.291 K0 F700
G1 X-4.873 Y57.845 Z-4 F700
G1 X-4.873 Y63.107 Z-4 F200
G1 X-4.873 Y57.845 Z-4 F700
G2 X-1.531 Y56.201 Z-4 I0.052 J-4.112 K0 F700
G2 X0.226 Y58.009 Z-4 I6.814 J-4.865 K0 F700
G1 X-4.873 Y63.107 Z-4 F700
G3 X-4.882 Y64.752 Z-4 I-15.363 J0.734 K0 F700
G2 X-5.084 Y69.156 Z-4 I56.215 J4.788 K0 F700
G1 X5.375 Y58.697 Z-4 F700
G2 X6.797 Y59.391 Z-4 I2.311 J-2.931 K0 F700
G2 X3.709 Y63.401 Z-4 I1.065 J4.014 K0 F700
G2 X3.709 Y66.200 Z-4 I541.182 J1.407 K0 F700
G1 X-5.084 Y74.993 Z-4 F700
G1 X-5.084 Y75.534 Z-4 F700
G1 X0.212 Y75.534 Z-4 F700
G1 X3.709 Y72.037 Z-4 F700
G2 X5.251 Y75.534 Z-4 I4.180 J0.245 K0 F700
G1 X0.212 Y75.534 Z-4 F700
G0 Z6
G0 X16.095 Y75.307 Z6
G0 X16.095 Y75.307 Z4
G1 X16.095 Y75.307 Z-4 F200
G2 X17.960 Y71.305 Z-4 I-3.588 J-4.108 K0 F700
G2 X17.985 Y69.112 Z-4 I-27.623 J-1.404 K0 F700
G1 (G2) X17.985 Y63.208 Z-4 F700
G2 X13.808 Y59.034 Z-4 I-4.187 J0.013 K0 F700
G1 (G3) X10.636 Y59.034 Z-4 F700
G2 X9.773 Y59.087 Z-4 I0.375 J13.340 K0 F700
G2 X11.532 Y57.402 Z-4 I-1.973 J-3.820 K0 F700
G1 X12.136 Y56.356 Z-4 F700
G1 X12.136 Y56.356 Z-4 F700
G1 X13.510 Y53.977 Z-4 F700
G2 X20.271 Y53.086 Z-4 I3.063 J-2.852 K0 F700
G2 X20.634 Y52.480 Z-4 I-9.062 J-5.844 K0 F700
G2 X21.366 Y53.387 Z-4 I4.925 J-3.222 K0 F700
G2 X24.864 Y59.105 Z-4 I3.880 J1.555 K0 F700
G1 X24.873 Y59.283 Z-4 F700
G1 (G3) X24.873 Y73.145 Z-4 F700
G3 X24.773 Y74.303 Z-4 I-4.341 J0.208 K0 F700
G3 X23.953 Y74.644 Z-4 I-1.042 J-1.350 K0 F700
G3 X20.733 Y74.982 Z-4 I-4.823 J-30.401 K0 F700
G2 X16.095 Y75.307 Z-4 I15.348 J252.497 K0 F700
G0 Z6
G0 X24.759 Y74.336 Z6
G0 X24.759 Y74.336 Z4
G1 X24.759 Y74.336 Z-4 F200
G3 X23.953 Y74.644 Z-4 I-1.148 J-1.798 K0 F700
G3 X20.733 Y74.982 Z-4 I-4.823 J-30.401 K0 F700
G1 X19.880 Y75.038 Z-4 F700
G1 X19.880 Y75.038 Z-4 F700
G2 X18.100 Y75.158 Z-4 I5.879 J100.190 K0 F700
G1 X24.873 Y68.385 Z-4 F700
G1 X24.873 Y62.548 Z-4 F700
G1 X17.988 Y69.432 Z-4 F700
G3 X17.985 Y63.599 Z-4 I264.256 J-3.077 K0 F700
G1 X23.076 Y58.508 Z-4 F700
G3 X21.081 Y54.665 Z-4 I2.165 J-3.562 K0 F700
G1 X16.051 Y59.695 Z-4 F700
G2 X13.808 Y59.034 Z-4 I-2.235 J3.453 K0 F700
G1 X10.874 Y59.034 Z-4 F700
G1 X14.933 Y54.975 Z-4 F700
G3 X13.510 Y53.977 Z-4 I1.457 J-3.589 K0 F700
G1 X12.136 Y56.356 Z-4 F700
G3 X10.795 Y58.363 Z-4 I-8.108 J-3.967 K0 F700
G3 X9.773 Y59.087 Z-4 I-2.237 J-2.076 K0 F700
G3 X10.874 Y59.034 Z-4 I1.083 J11.188 K0 F700
G0 Z6
G0 Z6
G0 X10.874 Y59.034
G0 X42.535
G0 X42.535 Z4
G1 X42.535 Y59.034 Z-4 F200
G1 X42.535 Y50.430 Z-4 F700
G2 X42.747 Y47.113 Z-4 I-61.285 J-5.576 K0 F700
G1 X42.747 Y46.903 Z-4 F700
G2 X45.479 Y46.733 Z-4 I1.123 J-3.983 K0 F700
G3 X47.241 Y46.115 Z-4 I9.746 J24.955 K0 F700
G2 X47.906 Y45.867 Z-4 I-2.260 J-7.088 K0 F700
G2 X51.328 Y47.896 Z-4 I3.545 J-2.079 K0 F700
G2 X51.328 Y51.808 Z-4 I292.360 J1.943 K0 F700
G2 X53.490 Y55.429 Z-4 I4.174 J-0.036 K0 F700
G2 X51.690 Y58.361 Z-4 I2.390 J3.486 K0 F700
G2 X51.328 Y60.671 Z-4 I12.967 J3.214 K0 F700
G1 (G2) X51.328 Y65.741 Z-4 F700
G2 X53.090 Y69.144 Z-4 I4.157 J0.005 K0 F700
G1 X51.421 Y69.580 Z-4 F700
G2 X51.421 Y69.580 Z-4 I-0 J0 K0 F700
G1 X48.058 Y70.460 Z-4 F700
G2 X47.101 Y70.710 Z-4 I1.664 J8.320 K0 F700
G2 X46.843 Y70.777 Z-4 I3.010 J12.040 K0 F700
G1 X46.843 Y70.777 Z-4 F700
G3 X42.535 Y71.828 Z-4 I-29.471 J-111.450 K0 F700
G1 X42.535 Y59.034 Z-4 F700
G0 Z6
G0 X45.398 Y71.152 Z6
G0 X45.398 Y71.152 Z4
G1 X45.398 Y71.152 Z-4 F200
G3 X42.535 Y71.828 Z-4 I-29.743 J-119.508 K0 F700
G1 X42.535 Y68.289 Z-4 F700
G1 X45.398 Y71.152 Z-4 F700
G2 X46.843 Y70.777 Z-4 I-65.334 J-254.972 K0 F700
G2 X47.101 Y70.710 Z-4 I-0.380 J-1.981 K0 F700
G3 X48.058 Y70.460 Z-4 I2.621 J8.070 K0 F700
G1 X50.028 Y69.945 Z-4 F700
G1 X42.535 Y62.452 Z-4 F700
G1 X42.535 Y56.615 Z-4 F700
G1 X51.328 Y65.408 Z-4 F700
G1 X51.328 Y60.671 Z-4 F700
G3 X51.439 Y59.682 Z-4 I5.266 J0.092 K0 F700
G1 X42.535 Y50.778 Z-4 F700
G3 X42.594 Y49.550 Z-4 I18.680 J0.278 K0 F700
G2 X42.747 Y46.903 Z-4 I-28.146 J-2.954 K0 F700
G2 X44.583 Y46.988 Z-4 I1.097 J-3.814 K0 F700
G1 X53.225 Y55.631 Z-4 F700
G3 X53.490 Y55.429 Z-4 I1.401 J1.556 K0 F700
G3 X51.328 Y51.808 Z-4 I2.012 J-3.657 K0 F700
G3 X51.328 Y47.896 Z-4 I292.387 J-1.969 K0 F700
G0 Z6
G0 Z6
(Finish operation: Pocket_Shape)
(Begin postamble)
M5
G17 G90
M2
gatornuke235 commented 1 month ago

I should also mention that i have to omit the commented out sections in version 20240308 (2.1.6),

java.lang.StringIndexOutOfBoundsException: String index out of range: 0
    at java.base/java.lang.StringLatin1.charAt(Unknown Source)
    at java.base/java.lang.String.charAt(Unknown Source)
    at com.willwinder.universalgcodesender.gcode.GcodePreprocessorUtils.extractWord(GcodePreprocessorUtils.java:443)
    at com.willwinder.universalgcodesender.gcode.GcodePreprocessorUtils.parseCoord(GcodePreprocessorUtils.java:455)
    at com.willwinder.universalgcodesender.gcode.GcodePreprocessorUtils.updatePointWithCommand(GcodePreprocessorUtils.java:206)
    at com.willwinder.universalgcodesender.gcode.util.GcodeParserUtils.handleGCode(GcodeParserUtils.java:263)
    at com.willwinder.universalgcodesender.gcode.util.GcodeParserUtils.processCommand(GcodeParserUtils.java:152)
    at com.willwinder.universalgcodesender.gcode.GcodeParser.addCommand(GcodeParser.java:147)
    at com.willwinder.universalgcodesender.gcode.GcodeParser.addCommand(GcodeParser.java:134)
    at com.willwinder.universalgcodesender.gcode.util.GcodeParserUtils.preprocessAndWrite(GcodeParserUtils.java:400)
    at com.willwinder.universalgcodesender.gcode.util.GcodeParserUtils.processAndExportText(GcodeParserUtils.java:442)
    at com.willwinder.universalgcodesender.gcode.util.GcodeParserUtils.processAndExport(GcodeParserUtils.java:381)
    at com.willwinder.universalgcodesender.model.GUIBackend.preprocessAndExportToFile(GUIBackend.java:152)
    at com.willwinder.universalgcodesender.model.GUIBackend.initializeProcessedLines(GUIBackend.java:785)
    at com.willwinder.universalgcodesender.model.GUIBackend.processGcodeFile(GUIBackend.java:380)
    at com.willwinder.universalgcodesender.model.GUIBackend.setGcodeFile(GUIBackend.java:471)
[catch] at com.willwinder.ugs.nbp.editor.EditorUtils.openFile(EditorUtils.java:45)
    at com.willwinder.ugs.nbp.editor.SourceMultiviewElement.componentOpened(SourceMultiviewElement.java:72)
    at org.netbeans.core.multiview.MultiViewPeer.showCurrentElement(MultiViewPeer.java:471)
    at org.netbeans.core.multiview.MultiViewPeer.peerComponentOpened(MultiViewPeer.java:357)
    at org.netbeans.core.multiview.MultiViewCloneableTopComponent.componentOpened(MultiViewCloneableTopComponent.java:129)
    at org.openide.windows.WindowManager.componentOpenNotify(WindowManager.java:282)
    at org.netbeans.core.windows.WindowManagerImpl.notifyTopComponentOpened(WindowManagerImpl.java:1192)
    at org.netbeans.core.windows.Central.addModeOpenedTopComponent(Central.java:773)
    at org.netbeans.core.windows.ModeImpl.addOpenedTopComponent(ModeImpl.java:336)
    at org.netbeans.core.windows.WindowManagerImpl.topComponentOpenAtTabPosition(WindowManagerImpl.java:1305)
    at org.netbeans.core.windows.WindowManagerImpl.topComponentOpen(WindowManagerImpl.java:1262)
    at org.openide.windows.TopComponent.open(TopComponent.java:473)
    at org.openide.windows.TopComponent.open(TopComponent.java:453)
    at org.openide.windows.CloneableOpenSupport.openCloneableTopComponent(CloneableOpenSupport.java:183)
    at org.openide.windows.CloneableOpenSupport$1.run(CloneableOpenSupport.java:82)
    at org.netbeans.modules.openide.util.NbMutexEventProvider$Event.doEvent(NbMutexEventProvider.java:97)
    at org.netbeans.modules.openide.util.NbMutexEventProvider$Event.writeAccess(NbMutexEventProvider.java:62)
    at org.netbeans.modules.openide.util.LazyMutexImplementation.writeAccess(LazyMutexImplementation.java:56)
    at org.openide.util.Mutex.writeAccess(Mutex.java:292)
    at org.openide.windows.CloneableOpenSupport.open(CloneableOpenSupport.java:79)
    at org.openide.text.CloneableEditorSupport.open(CloneableEditorSupport.java:412)
    at com.willwinder.ugs.nbp.core.actions.OpenFileAction.actionPerformed(OpenFileAction.java:61)
    at com.willwinder.ugs.nbp.core.actions.OpenAction.openFile(OpenAction.java:92)
    at java.base/java.util.Optional.ifPresent(Unknown Source)
    at com.willwinder.ugs.nbp.core.actions.OpenAction.actionPerformed(OpenAction.java:87)
    at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
    at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
    at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
    at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.desktop/java.awt.Component.processEvent(Unknown Source)
    at java.desktop/java.awt.Container.processEvent(Unknown Source)
    at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
    at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
    at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
    at java.base/java.security.AccessController.doPrivileged(Unknown Source)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
    at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
    at java.base/java.security.AccessController.doPrivileged(Unknown Source)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
    at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:136)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)

but not for version 20200207 unless the line is greater than 50 characters:

com.willwinder.universalgcodesender.gcode.util.GcodeParserException: Command 'G2X-8.431Y2.673Z-2.000I50962.610J-8.815K0.000F500.000' is longer than 50 characters.
    at com.willwinder.universalgcodesender.gcode.processors.CommandLengthProcessor.processCommand(CommandLengthProcessor.java:32)
    at com.willwinder.universalgcodesender.gcode.GcodeParser.preprocessCommand(GcodeParser.java:499)
    at com.willwinder.universalgcodesender.gcode.util.GcodeParserUtils.write(GcodeParserUtils.java:73)
    at com.willwinder.universalgcodesender.gcode.util.GcodeParserUtils.processAndExportText(GcodeParserUtils.java:126)
    at com.willwinder.universalgcodesender.gcode.util.GcodeParserUtils.processAndExport(GcodeParserUtils.java:56)
    at com.willwinder.universalgcodesender.model.GUIBackend.preprocessAndExportToFile(GUIBackend.java:174)
    at com.willwinder.universalgcodesender.model.GUIBackend.initializeProcessedLines(GUIBackend.java:849)
    at com.willwinder.universalgcodesender.model.GUIBackend.setGcodeFile(GUIBackend.java:449)
[catch] at com.willwinder.universalgcodesender.utils.GUIHelpers.lambda$openGcodeFile$2(GUIHelpers.java:94)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
breiler commented 1 month ago

I had no problems creating a gcode file with the contents and running it. Can you attach the actual gcode file, I am suspecting a UTF-8 BOM character problem.

gatornuke235 commented 1 month ago

After updating java and assigning more memory to UGS (-J-Xms1024m) I'm no longer having the crashes, now it just behaves like the older version, sending the router in a straight line to infinity unless i hit the stop button before it reaches the limit when a bad instruction is called.

The last lines shown in the console before I stopped the excursion are:

>>> G3X-57.755Y66.965Z-4I0.895J-3.186K0F4000
ok
ok
>>> G3X-58.363Y66.770Z-4I2.430J-8.631K0F4000
ok
>>> G1X-58.363Y66.770Z-4F4000
ok
>>> G2X-59.959Y66.238Z-4I-1695759.683J5087278.619K0F4000
ok
>>> G1X-60.746Y65.976Z-4F4000
ok
>>> G2X-60.535Y62.463Z-4I-216.044J-14.692K0F4000
ok

**** Canceling file transfer. ****

**** Pausing file transfer. ****

ok
Grbl 1.1h for MillRight CNC Carve King 2 ['$' for help] 

Note the very large I and J values, which is why I got suspicious of these in the first place: I = -1,695,759.683 and J = 5,087,278.619. I suspected some kind of data overflow issue.

Executing the modified "clean" file runs the job to completion with no excursions. See files attached.

FnI_2_6mm-test-files.zip

breiler commented 1 month ago

Ok so there are two problems. I was completely focusing on the loading/freezing problem which does still not happen for me with the default settings in UGS (2.1.5 or 2.1.6).

The setting you've changed is setting the minimum required memory, not increasing the maximum. By default Java will be able to use maximum 1/4 of the total memory. So if you have < 4GB of ram this setting could potentially have solved a memory problem.

Upgrading Java is a bit tricky so I am suspecting that you are still running the bundled Java.

Can you post your log file from Tools / Open log directory and attach the messages.log. It will contain your systems memory and which Java it is using.

The next problem is indeed with the Arc. I have tested sending this command to GRBL, FluidNC, GrblHAL and all of them are experiencing the same problem. Since the visualizer can render the model correctly (and also NCViewer) I am suspecting that this is a firmware problem. Can you share your FreeCAD project? I am curious if there are any settings that one could tweak in the post processor settings.

UGS has a feature to convert arcs to tiny line segments - "Arc Expander", when I activated this I can run the project: image

gatornuke235 commented 1 month ago

Thanks for the clarification with the memory issue. This machine has 16GB of RAM, so that's probably not the issue. I've also attached the log file. I wound up uninstalling java and getting the latest 64bit offline install version from java.com and that seems to have fixed the freezing issue.

FreeCAD does indeed have a "split arcs" option in the properties for each operation path. I suspect this does the same as the "arc expander."

I personally would prefer to leave the small proper arcs and just linearizing the ones with humongous radii, but that's personal preference I suppose. I should mention that i had to remove the commented out sections of the gcode otherwise I'd get a "java.lang.StringIndexOutOfBoundsException: String index out of range: 0" warning, i.e.:

                if (exceeded):            
                    new_line = 'G1' # + ' (' + parts[0] + ')' # Overrite the original G2 or G3 command
                    for part in parts[1:]:
                        if part.startswith(('X', 'Y', 'Z', 'F')):
                            new_line += ' ' + part
                        #elif part.startswith(('I', 'J', 'K')):
                            #new_line += ' (' + part + ')'  # Comment out arc

Either way, I feel this issue is resolved and I'm closing the ticket. I appreciate your time. I just wanted to bring it to your attention in case you hadn't seen this yet.

messages.log image

breiler commented 1 month ago

Thanks for the feedback.

Just a note, according to the log file UGS is still using the bundled Java at: C:\Users\eddyc\OneDrive\Desktop\ugsplatform-win\jdk\jdk-17.0.8.1+1-jre

If you encounter more problems, try and move UGS to another folder outside OneDrive. The problems you are experienced could have been related to the program folder getting synced. 🤷🏻‍♂️

gatornuke235 commented 1 month ago

If you encounter more problems, try and move UGS to another folder outside OneDrive. The problems you are experienced could have been related to the program folder getting synced. 🤷🏻‍♂️

Roger. Thanks.