Skip to content

Commit

Permalink
Fix overly deep final pass on some TURN models
Browse files Browse the repository at this point in the history
  • Loading branch information
kachurovskiy committed Feb 16, 2025
1 parent b5aa2c1 commit 556c83d
Show file tree
Hide file tree
Showing 14 changed files with 177 additions and 432 deletions.
46 changes: 23 additions & 23 deletions docs/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lathecode",
"version": "0.0.21",
"version": "0.0.22",
"type": "module",
"license": "MIT",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/planner/plannerworker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class PlannerWorker {
this.postProgress();
for (let passIndex = 0; passIndex < this.passes.length; passIndex++) {
const endX = this.passes[passIndex].x;
const startX = passIndex === 0 ? this.canvas.width - 1 : this.passes[passIndex - 1].x;
const startX = passIndex === 0 ? this.canvas.width : this.passes[passIndex - 1].x;
for (let startY = this.canvas.height; startY >= 0; startY -= this.getDepthOfCutPx()) {
postMessage({progressMessage: `Starting subpass ${startY}`});
const endY = this.passes[passIndex].finishAfter ? Math.max(0, startY - this.getDepthOfCutPx()) : -this.toolOvershootY;
Expand Down
4 changes: 2 additions & 2 deletions test/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { readFileSync, readdirSync, write, writeFileSync, rmSync } from 'fs';
import { resolve } from 'path';
import puppeteer from 'puppeteer';
import { Page } from 'puppeteer';
import { get } from 'http';

const SUFFIX = '.gcode.txt';

Expand All @@ -13,7 +12,8 @@ function getInput(name: string) {

function saveInput(name: string, input: string) {
writeFileSync(resolve(__dirname, name + '.txt'), input + '\n');
writeFileSync(resolve(__dirname, name + SUFFIX), '');
const gcodePath = resolve(__dirname, name + SUFFIX);
if (!readdirSync(__dirname).includes(name + SUFFIX)) writeFileSync(gcodePath, '');
}

function saveGCode(name: string, gcode: string) {
Expand Down
61 changes: 30 additions & 31 deletions test/multi-part-turn.gcode.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
; L3 R9
; L3

; Run time 10.4 min, cutting 80% of time
; Run time 10.0 min, cutting 77% of time
; Working area 33.00 by 10.31 mm

G21 ; metric
Expand All @@ -23,19 +23,18 @@ F200
X-10 ; zero your tool X on centerline
Z0 ; zero your tool Z at the right edge of the stock
G91 ; relative positioning
Z0.01
X0.5

F50
X0.5 ; cut 0.0019 mm2
Z10.98 ; cut 5.4619 mm2
Z10.99 ; cut 5.4638 mm2

F200
X-0.5
Z-10.98
Z-10.99
X1

F50
X1 ; cut 0.0019 mm2
Z5.12 ; cut 2.5319 mm2
Z5.13 ; cut 2.5338 mm2
Z0.19 X-0.1 ; cut 0.0564 mm2 at -62.24°
Z5.36 ; cut 2.1431 mm2
Z0.14 X0.06 ; cut 0.2253 mm2 at 66.80°
Expand All @@ -44,11 +43,11 @@ Z0.12 ; cut 0.0827 mm2
X-1 ; cut 0.002 mm2

F200
Z-10.98
Z-10.99
X1.5

F50
X1.5 ; cut 0.0019 mm2
Z4.99 ; cut 2.4744 mm2
Z5 ; cut 2.4763 mm2

F200
X-0.6
Expand All @@ -61,59 +60,59 @@ Z0.05 X0.12 ; cut 0.363 mm2 at 22.62°
X-1.21 ; cut 0.0017 mm2

F200
Z-10.98
Z-10.99
X2

F50
X2 ; cut 0.0019 mm2
Z4.99 ; cut 2.4981 mm2
Z5 ; cut 2.5 mm2

F200
X-2
Z-4.99
Z-5
X2.5

F50
X2.5 ; cut 0.0019 mm2
Z4.99 ; cut 2.4981 mm2
Z5 ; cut 2.5 mm2

F200
X-2.5
Z-4.99
Z-5
X3

F50
X3 ; cut 0.0019 mm2
Z4.99 ; cut 2.4981 mm2
Z5 ; cut 2.5 mm2

F200
X-3
Z-4.99
Z-5
X3.5

F50
X3.5 ; cut 0.0019 mm2
Z4.99 ; cut 2.4981 mm2
Z5 ; cut 2.5 mm2

F200
X-3.5
Z-4.99
Z-5
X4

F50
X4 ; cut 0.0019 mm2
Z4.99 ; cut 2.4981 mm2
Z5 ; cut 2.5 mm2

F200
X-4
Z-4.99
Z-5
X4.5

F50
X4.5 ; cut 0.0019 mm2
Z4.99 ; cut 2.4981 mm2
Z5 ; cut 2.5 mm2

F200
X-4.5
Z-4.99
Z-5
X5

F50
X5 ; cut 0.0019 mm2
Z0.12 ; cut 0.0394 mm2
Z0.13 ; cut 0.0413 mm2
Z0.19 X-0.1 ; cut 0.0564 mm2 at -62.24°
Z4.68 ; cut 1.9023 mm2

Expand Down
Binary file modified test/multi-part-turn.moves.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 36 additions & 37 deletions test/parting-filet-turn.gcode.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
; L0.2 DS10.5 DE10.3
; L2

; Run time 3.8 min, cutting 82% of time
; Run time 3.2 min, cutting 73% of time
; Working area 10.60 by 6.14 mm

G21 ; metric
Expand All @@ -24,19 +24,18 @@ F200
X-6 ; zero your tool X on centerline
Z0 ; zero your tool Z at the right edge of the stock
G91 ; relative positioning
Z0.01
X0.5

F50
X0.5 ; cut 0.0036 mm2
Z10.58 ; cut 5.2843 mm2
Z10.59 ; cut 5.2879 mm2

F200
X-0.5
Z-10.58
Z-10.59
X1

F50
X1 ; cut 0.0036 mm2
Z7.49 ; cut 3.7393 mm2
Z7.5 ; cut 3.7429 mm2
Z0.01 X-0.23 ; cut 0.0014 mm2 at -2.49°
Z0.03 X-0.05 ; cut 0.0035 mm2 at -30.96°
Z0.07 X-0.05 ; cut 0.0066 mm2 at -54.46°
Expand All @@ -48,90 +47,90 @@ Z0.01 X0.04 ; cut 0.0821 mm2 at 14.04°
X-0.79 ; cut 0.002 mm2

F200
Z-10.58
Z-10.59
X1.5

F50
X1.5 ; cut 0.0036 mm2
Z7.49 ; cut 3.7464 mm2
Z7.5 ; cut 3.75 mm2

F200
X-1.5
Z-7.49
Z-7.5
X2

F50
X2 ; cut 0.0036 mm2
Z6.01 ; cut 2.9993 mm2
Z6.02 ; cut 3.0029 mm2
Z0.06 X-0.06 ; cut 0.0215 mm2 at -45.00°
Z0.27 X-0.14 ; cut 0.0785 mm2 at -62.59°
Z1.15 ; cut 0.3517 mm2

F200
X-1.8
Z-7.49
Z-7.5
X2.5

F50
X2.5 ; cut 0.0036 mm2
Z5.99 ; cut 2.9937 mm2
Z6 ; cut 2.9973 mm2

F200
X-2.5
Z-5.99
Z-6
X3

F50
X3 ; cut 0.0036 mm2
Z5.99 ; cut 2.9964 mm2
Z6 ; cut 3 mm2

F200
X-3
Z-5.99
Z-6
X3.5

F50
X3.5 ; cut 0.0036 mm2
Z5.99 ; cut 2.9964 mm2
Z6 ; cut 3 mm2

F200
X-3.5
Z-5.99
Z-6
X4

F50
X4 ; cut 0.0036 mm2
Z5.6 ; cut 2.7938 mm2
Z5.61 ; cut 2.7974 mm2
Z0.39 X-0.14 ; cut 0.1501 mm2 at -70.25°

F200
X-3.86
Z-5.99
Z-6
X4.5

F50
X4.5 ; cut 0.0036 mm2
Z4.23 ; cut 2.1086 mm2
Z4.24 ; cut 2.1122 mm2
Z1.24 X-0.45 ; cut 0.2628 mm2 at -70.05°

F200
X-4.05
Z-5.47
Z-5.48
X5

F50
X5 ; cut 0.0036 mm2
Z2.85 ; cut 1.4188 mm2
Z2.86 ; cut 1.4224 mm2
Z1.27 X-0.46 ; cut 0.2651 mm2 at -70.09°

F200
X-4.54
Z-4.12
Z-4.13
X5.5

F50
X5.5 ; cut 0.0036 mm2
Z1.48 ; cut 0.7336 mm2
Z1.49 ; cut 0.7372 mm2
Z1.24 X-0.45 ; cut 0.2628 mm2 at -70.05°

F200
X-5.05
Z-2.72
Z-2.73
X6

F50
X6 ; cut 0.0036 mm2
Z0.52 ; cut 0.254 mm2
Z0.53 ; cut 0.2576 mm2
Z0.02 X-0.1 ; cut 0.0054 mm2 at -11.31°
Z0.05 X-0.07 ; cut 0.0119 mm2 at -35.54°
Z0.78 X-0.29 ; cut 0.094 mm2 at -69.61°
Expand Down
Binary file modified test/parting-filet-turn.moves.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 556c83d

Please sign in to comment.