@rulecad/cad 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/AGENTS.md +45 -16
  2. package/CHANGELOG.md +724 -0
  3. package/EXAMPLES.md +61 -54
  4. package/README.md +376 -98
  5. package/TUTORIAL.md +2 -2
  6. package/bin/cad.mjs +2664 -541
  7. package/lib/animate.mjs +173 -49
  8. package/lib/assembly.mjs +1883 -435
  9. package/lib/beams.mjs +256 -52
  10. package/lib/belts.mjs +66 -15
  11. package/lib/board-work.mjs +12 -0
  12. package/lib/bought.mjs +309 -53
  13. package/lib/buildpage.mjs +179 -29
  14. package/lib/cache-file.mjs +105 -0
  15. package/lib/carried.mjs +201 -0
  16. package/lib/clone.mjs +194 -42
  17. package/lib/code-text.mjs +28 -0
  18. package/lib/design-imports.mjs +127 -0
  19. package/lib/design.mjs +871 -147
  20. package/lib/designshapes.mjs +142 -0
  21. package/lib/drive.mjs +187 -63
  22. package/lib/edit.mjs +922 -192
  23. package/lib/errors.mjs +16 -3
  24. package/lib/estimates.mjs +51 -0
  25. package/lib/explain.mjs +62 -13
  26. package/lib/fasten.mjs +2708 -507
  27. package/lib/fe-key.mjs +29 -0
  28. package/lib/fittings.mjs +721 -122
  29. package/lib/fixings.mjs +38 -13
  30. package/lib/framebuild.mjs +790 -175
  31. package/lib/framecheck.mjs +1901 -368
  32. package/lib/framegen.mjs +108 -22
  33. package/lib/frameheat.mjs +225 -42
  34. package/lib/frameprint.mjs +513 -108
  35. package/lib/frames.mjs +86 -18
  36. package/lib/framesize.mjs +719 -120
  37. package/lib/frametip.mjs +235 -0
  38. package/lib/gait.mjs +135 -23
  39. package/lib/grip.mjs +62 -13
  40. package/lib/guides.mjs +1403 -230
  41. package/lib/host.mjs +129 -23
  42. package/lib/inplace.mjs +171 -36
  43. package/lib/jigs.mjs +360 -78
  44. package/lib/joins.mjs +697 -118
  45. package/lib/jsonedit.mjs +88 -26
  46. package/lib/kept.mjs +84 -0
  47. package/lib/kit.mjs +439 -69
  48. package/lib/layout.mjs +2 -1
  49. package/lib/links.mjs +149 -42
  50. package/lib/list.mjs +334 -64
  51. package/lib/live-guard.mjs +68 -0
  52. package/lib/live-shape.mjs +96 -24
  53. package/lib/live.mjs +189 -59
  54. package/lib/loads.mjs +597 -136
  55. package/lib/machine.mjs +372 -74
  56. package/lib/magnets.mjs +162 -44
  57. package/lib/measured.mjs +1080 -117
  58. package/lib/mesh.mjs +526 -119
  59. package/lib/meshcmd.mjs +215 -60
  60. package/lib/motors.mjs +1002 -214
  61. package/lib/motorsvg.mjs +114 -32
  62. package/lib/names.mjs +18 -1
  63. package/lib/optimise.mjs +991 -287
  64. package/lib/order.mjs +515 -114
  65. package/lib/panels.mjs +482 -94
  66. package/lib/parts.mjs +81 -23
  67. package/lib/pins.mjs +163 -44
  68. package/lib/plates.mjs +223 -35
  69. package/lib/player.mjs +37 -9
  70. package/lib/power.mjs +64 -13
  71. package/lib/preview.mjs +83 -16
  72. package/lib/profilemeasure.mjs +572 -129
  73. package/lib/rules.mjs +17 -6
  74. package/lib/sandbox-hooks.mjs +179 -27
  75. package/lib/sandbox-lock.mjs +225 -0
  76. package/lib/sandbox-preload.mjs +2 -2
  77. package/lib/sandbox-run.mjs +122 -25
  78. package/lib/sandbox.mjs +667 -75
  79. package/lib/schema.mjs +42 -11
  80. package/lib/seats.mjs +227 -49
  81. package/lib/services.mjs +261 -52
  82. package/lib/sheet.mjs +963 -179
  83. package/lib/slotnuts.mjs +213 -34
  84. package/lib/targets/gist.mjs +4 -1
  85. package/lib/targets.mjs +22 -4
  86. package/lib/task.mjs +376 -79
  87. package/lib/versions.mjs +285 -39
  88. package/lib/wires.mjs +228 -45
  89. package/lib/workspace.mjs +200 -14
  90. package/package.json +19 -19
  91. package/schemas/assembly.schema.json +2 -2
  92. package/schemas/project.schema.json +6 -0
  93. package/templates/coupons/MEASURE.md +109 -0
  94. package/templates/coupons/assemblies/fixings-test.json +20 -0
  95. package/templates/coupons/assemblies/slot-test.json +11 -0
  96. package/templates/coupons/objects/fixings-coupon.js +88 -0
  97. package/templates/coupons/objects/fixings-coupon.json +26 -0
  98. package/templates/coupons/objects/holds-coupon.js +130 -0
  99. package/templates/coupons/objects/holds-coupon.json +42 -0
  100. package/templates/coupons/objects/slot-coupon.js +89 -0
  101. package/templates/coupons/objects/slot-coupon.json +29 -0
  102. package/templates/coupons/project.json +10 -0
package/lib/task.mjs CHANGED
@@ -4,7 +4,7 @@
4
4
  // "task": { "tool": "pen.tip", "sheet": { "size": "a5", "at": [60, -74, 0] }, "speed": 50, "accuracy": 0.3 }
5
5
  import fs from 'node:fs';
6
6
  import { chainFromMotion, reach, sheetFrame, sheetPoint, jacobian, fk } from '@rulecad/robots';
7
- import { evaluate, peekRuleSet } from './rules.mjs';
7
+ import { peekRuleSet } from './rules.mjs';
8
8
  import { paths } from './workspace.mjs';
9
9
  import { trainFrom, workingSpeed } from './motors.mjs';
10
10
  import { placeItems } from '@rulecad/model-link';
@@ -15,21 +15,64 @@ const CORNERS = ['lower left', 'lower right', 'upper right', 'upper left'];
15
15
 
16
16
  /** The task as written, checked by name when the assembly is built. */
17
17
  export function taskOf(a, motion, num) {
18
- const t = a.task; if (!t) return null;
18
+ const t = a.task;
19
+ if (!t) return null;
19
20
  const what = 'task';
20
- if (!t.tool || !String(t.tool).includes('.')) throw new Error(`${what}: tool is an anchor, <item>.<anchor> (got ${JSON.stringify(t.tool)})`);
21
+ if (!t.tool || !String(t.tool).includes('.'))
22
+ throw new Error(`${what}: tool is an anchor, <item>.<anchor> (got ${JSON.stringify(t.tool)})`);
21
23
  const given = ['sheet', 'region', 'volume'].filter((k) => t[k] != null);
22
- if (given.length !== 1) throw new Error(`${what}: give one of sheet, region or volume (got ${given.join(', ') || 'none'})`);
23
- const [id, name] = String(t.tool).split('.'), mark = motion.marks.find((m) => m.id === id && m.name === name);
24
- if (!mark) throw new Error(`${what}: no anchor "${t.tool}" (anchors: ${motion.marks.filter((m) => m.id === id).map((m) => m.name).join(', ') || `no item ${id}`})`);
25
- const vec = (v) => v.map(num), value = (k) => { if (t[k] == null) return null; const x = num(t[k]); if (!(x > 0)) throw new Error(`${what}: ${k} is above 0 (got ${x})`); return x; };
26
- const out = { tool: t.tool, item: id, point: [mark.frame[3], mark.frame[7], mark.frame[11]], speed: value('speed'), accuracy: value('accuracy'), elbow: t.elbow ?? null, deflection: t.deflection != null ? num(t.deflection) : 0, payload: t.payload != null ? num(t.payload) : null, accel: t.accel != null ? num(t.accel) : null, blockTime: value('blockTime') };
27
- if (t.elbow != null && !['left', 'right'].includes(t.elbow)) throw new Error(`${what}: elbow is left or right (got ${JSON.stringify(t.elbow)})`);
28
- if (t.sheet) out.sheet = { ...t.sheet, at: vec(t.sheet.at), ...(t.sheet.normal ? { normal: vec(t.sheet.normal) } : {}), ...(t.sheet.u ? { u: vec(t.sheet.u) } : {}) };
29
- const ranges = (o) => Object.fromEntries(Object.entries(o).map(([k, x]) => [k, Array.isArray(x) ? x.map(num) : typeof x === 'object' ? x : num(x)]));
24
+ if (given.length !== 1)
25
+ throw new Error(`${what}: give one of sheet, region or volume (got ${given.join(', ') || 'none'})`);
26
+ const [id, name] = String(t.tool).split('.'),
27
+ mark = motion.marks.find((m) => m.id === id && m.name === name);
28
+ if (!mark)
29
+ throw new Error(
30
+ `${what}: no anchor "${t.tool}" (anchors: ${
31
+ motion.marks
32
+ .filter((m) => m.id === id)
33
+ .map((m) => m.name)
34
+ .join(', ') || `no item ${id}`
35
+ })`,
36
+ );
37
+ const vec = (v) => v.map(num),
38
+ value = (k) => {
39
+ if (t[k] == null) return null;
40
+ const x = num(t[k]);
41
+ if (!(x > 0)) throw new Error(`${what}: ${k} is above 0 (got ${x})`);
42
+ return x;
43
+ };
44
+ const out = {
45
+ tool: t.tool,
46
+ item: id,
47
+ point: [mark.frame[3], mark.frame[7], mark.frame[11]],
48
+ speed: value('speed'),
49
+ accuracy: value('accuracy'),
50
+ elbow: t.elbow ?? null,
51
+ deflection: t.deflection != null ? num(t.deflection) : 0,
52
+ payload: t.payload != null ? num(t.payload) : null,
53
+ accel: t.accel != null ? num(t.accel) : null,
54
+ blockTime: value('blockTime'),
55
+ };
56
+ if (t.elbow != null && !['left', 'right'].includes(t.elbow))
57
+ throw new Error(`${what}: elbow is left or right (got ${JSON.stringify(t.elbow)})`);
58
+ if (t.sheet)
59
+ out.sheet = {
60
+ ...t.sheet,
61
+ at: vec(t.sheet.at),
62
+ ...(t.sheet.normal ? { normal: vec(t.sheet.normal) } : {}),
63
+ ...(t.sheet.u ? { u: vec(t.sheet.u) } : {}),
64
+ };
65
+ const ranges = (o) =>
66
+ Object.fromEntries(
67
+ Object.entries(o).map(([k, x]) => [k, Array.isArray(x) ? x.map(num) : typeof x === 'object' ? x : num(x)]),
68
+ );
30
69
  if (t.region) out.region = ranges(t.region);
31
70
  if (t.volume) out.volume = ranges(t.volume);
32
- try { if (out.sheet) sheetFrame(out.sheet); } catch (e) { throw new Error(`${what}: ${e.message}`); }
71
+ try {
72
+ if (out.sheet) sheetFrame(out.sheet);
73
+ } catch (e) {
74
+ throw new Error(`${what}: ${e.message}`);
75
+ }
33
76
  return out;
34
77
  }
35
78
 
@@ -38,46 +81,115 @@ export const chainOf = (s) => chainFromMotion(s.motion, { tip: s.task.item, tool
38
81
  // One sampling of the task, kept so the three checks and the picture read the same samples
39
82
  export function sample(s) {
40
83
  if (s.taskSamples) return s.taskSamples;
41
- const t = s.task, c = chainOf(s), spec = t.sheet ? { sheet: t.sheet } : t.region ? { region: t.region } : { volume: t.volume };
84
+ const t = s.task,
85
+ c = chainOf(s),
86
+ spec = t.sheet ? { sheet: t.sheet } : t.region ? { region: t.region } : { volume: t.volume };
42
87
  let step = 10;
43
- if (t.sheet) { const f = sheetFrame(t.sheet); step = Math.min(f.width, f.height) / 12; }
88
+ if (t.sheet) {
89
+ const f = sheetFrame(t.sheet);
90
+ step = Math.min(f.width, f.height) / 12;
91
+ }
44
92
  const go = (elbow) => reach(c, { ...spec, step, ...(elbow ? { elbow } : {}) });
45
93
  // Hold the elbow it's given, or the one that reaches the most
46
- let r, elbow = t.elbow;
47
- if (c.dof === 2 && !elbow) { const a = go('right'), b = go('left'); r = b.summary.reachable > a.summary.reachable || (b.summary.reachable === a.summary.reachable && b.summary.margin > a.summary.margin) ? (elbow = 'left', b) : (elbow = 'right', a); } else r = go(elbow);
94
+ let r,
95
+ elbow = t.elbow;
96
+ if (c.dof === 2 && !elbow) {
97
+ const a = go('right'),
98
+ b = go('left');
99
+ r =
100
+ b.summary.reachable > a.summary.reachable ||
101
+ (b.summary.reachable === a.summary.reachable && b.summary.margin > a.summary.margin)
102
+ ? ((elbow = 'left'), b)
103
+ : ((elbow = 'right'), a);
104
+ } else r = go(elbow);
48
105
  return (s.taskSamples = { c, r, elbow, step });
49
106
  }
50
107
 
51
108
  // A point on the sheet, said in millimetres from its centre
52
- const onSheet = (t, p) => { if (!t.sheet) return `(${p.map((x) => n3(x, 1)).join(', ')})`; const f = sheetFrame(t.sheet), d = p.map((x, k) => x - f.at[k]); return `(${n3(dot(d, f.u), 1)}, ${n3(dot(d, f.v), 1)}) from its centre`; };
109
+ const onSheet = (t, p) => {
110
+ if (!t.sheet) return `(${p.map((x) => n3(x, 1)).join(', ')})`;
111
+ const f = sheetFrame(t.sheet),
112
+ d = p.map((x, k) => x - f.at[k]);
113
+ return `(${n3(dot(d, f.u), 1)}, ${n3(dot(d, f.v), 1)}) from its centre`;
114
+ };
53
115
 
54
116
  function reachCheck(s, f, picture) {
55
- const t = s.task, { r, elbow } = sample(s), code = 'task.reach', { summary } = r, thing = t.sheet ? 'sheet' : t.region ? 'region' : 'volume';
56
- const miss = summary.corners.map((c, i) => ({ c, name: CORNERS[i] ?? `corner ${i + 1}` })).filter((x) => !x.c.reachable).sort((a, b) => b.c.miss - a.c.miss);
57
- const values = { margin: summary.margin, reachable: summary.reachable, total: summary.total, elbow, samples: r.samples.map((x) => ({ point: x.point.map((v) => +v.toFixed(3)), reachable: x.reachable, q: x.q.map((v) => +v.toFixed(4)), margin: +x.margin.toFixed(3), manipulability: +x.manipulability.toFixed(1) })), picture };
117
+ const t = s.task,
118
+ { r, elbow } = sample(s),
119
+ code = 'task.reach',
120
+ { summary } = r,
121
+ thing = t.sheet ? 'sheet' : t.region ? 'region' : 'volume';
122
+ const miss = summary.corners
123
+ .map((c, i) => ({ c, name: CORNERS[i] ?? `corner ${i + 1}` }))
124
+ .filter((x) => !x.c.reachable)
125
+ .sort((a, b) => b.c.miss - a.c.miss);
126
+ const values = {
127
+ margin: summary.margin,
128
+ reachable: summary.reachable,
129
+ total: summary.total,
130
+ elbow,
131
+ samples: r.samples.map((x) => ({
132
+ point: x.point.map((v) => +v.toFixed(3)),
133
+ reachable: x.reachable,
134
+ q: x.q.map((v) => +v.toFixed(4)),
135
+ margin: +x.margin.toFixed(3),
136
+ manipulability: +x.manipulability.toFixed(1),
137
+ })),
138
+ picture,
139
+ };
58
140
  if (miss.length) {
59
141
  const w = miss[0];
60
- return f('fail', `the ${w.name} corner of the ${thing} can't be reached: ${t.tool} misses it by ${n3(w.c.miss)} mm (${summary.reachable} of ${summary.total} points on it are in reach)`, `${thing}: ${w.name} out of reach`, { code, at: w.c.point, refs: { corner: w.name, tool: t.tool }, values: { ...values, miss: w.c.miss } });
142
+ return f(
143
+ 'fail',
144
+ `the ${w.name} corner of the ${thing} can't be reached: ${t.tool} misses it by ${n3(w.c.miss)} mm (${summary.reachable} of ${summary.total} points on it are in reach)`,
145
+ `${thing}: ${w.name} out of reach`,
146
+ { code, at: w.c.point, refs: { corner: w.name, tool: t.tool }, values: { ...values, miss: w.c.miss } },
147
+ );
61
148
  }
62
149
  if (summary.reachable < summary.total) {
63
150
  const w = summary.worst;
64
- return f('fail', `${summary.total - summary.reachable} of ${summary.total} points on the ${thing} can't be reached, ${n3(w.miss)} mm short at worst, at ${onSheet(t, w.point)}: limits or the hole near the base`, `${thing}: not all in reach`, { code, at: w.point, refs: { tool: t.tool }, values: { ...values, miss: w.miss } });
151
+ return f(
152
+ 'fail',
153
+ `${summary.total - summary.reachable} of ${summary.total} points on the ${thing} can't be reached, ${n3(w.miss)} mm short at worst, at ${onSheet(t, w.point)}: limits or the hole near the base`,
154
+ `${thing}: not all in reach`,
155
+ { code, at: w.point, refs: { tool: t.tool }, values: { ...values, miss: w.miss } },
156
+ );
65
157
  }
66
- const w = summary.corners.reduce((a, b) => (b.margin < a.margin ? b : a)), near = Math.min(summary.margin, w.margin);
67
- f('pass', `${t.tool} reaches the whole ${thing} with ${elbow ? `the elbow to the ${elbow}` : 'its joints'}: ${n3(near)} mm to spare at the worst point`, null, { code, at: summary.worst.point, refs: { tool: t.tool }, values });
158
+ const w = summary.corners.reduce((a, b) => (b.margin < a.margin ? b : a)),
159
+ near = Math.min(summary.margin, w.margin);
160
+ f(
161
+ 'pass',
162
+ `${t.tool} reaches the whole ${thing} with ${elbow ? `the elbow to the ${elbow}` : 'its joints'}: ${n3(near)} mm to spare at the worst point`,
163
+ null,
164
+ { code, at: summary.worst.point, refs: { tool: t.tool }, values },
165
+ );
68
166
  }
69
167
 
70
168
  // How fast a sampled point can go: in each direction across the sheet, the speed at which the first joint hits its limit
71
169
  function fastest(c, q, frame, limits) {
72
170
  if (!frame) return fastestAnyWay(c, q, limits);
73
- const J = jacobian(c, q), rows = frame ? [frame.u, frame.v].map((d) => c.names.map((_, i) => d[0] * J[0][i] + d[1] * J[1][i] + d[2] * J[2][i])) : [J[0], J[1]];
74
- const N = c.names.length, a = dot2(rows[0], rows[0]), b = dot2(rows[0], rows[1]), d = dot2(rows[1], rows[1]), det = a * d - b * b;
171
+ const J = jacobian(c, q),
172
+ rows = frame
173
+ ? [frame.u, frame.v].map((d) => c.names.map((_, i) => d[0] * J[0][i] + d[1] * J[1][i] + d[2] * J[2][i]))
174
+ : [J[0], J[1]];
175
+ const N = c.names.length,
176
+ a = dot2(rows[0], rows[0]),
177
+ b = dot2(rows[0], rows[1]),
178
+ d = dot2(rows[1], rows[1]),
179
+ det = a * d - b * b;
75
180
  if (Math.abs(det) < 1e-9) return 0;
76
181
  let worst = Infinity;
77
182
  for (let k = 0; k < 24; k++) {
78
- const th = (k * Math.PI) / 12, vx = Math.cos(th), vy = Math.sin(th), l0 = (d * vx - b * vy) / det, l1 = (a * vy - b * vx) / det;
183
+ const th = (k * Math.PI) / 12,
184
+ vx = Math.cos(th),
185
+ vy = Math.sin(th),
186
+ l0 = (d * vx - b * vy) / det,
187
+ l1 = (a * vy - b * vx) / det;
79
188
  let scale = Infinity;
80
- for (let i = 0; i < N; i++) { const qd = Math.abs(rows[0][i] * l0 + rows[1][i] * l1); if (qd > 1e-12) scale = Math.min(scale, limits[i] / qd); }
189
+ for (let i = 0; i < N; i++) {
190
+ const qd = Math.abs(rows[0][i] * l0 + rows[1][i] * l1);
191
+ if (qd > 1e-12) scale = Math.min(scale, limits[i] / qd);
192
+ }
81
193
  worst = Math.min(worst, scale);
82
194
  }
83
195
  return worst;
@@ -85,11 +197,28 @@ function fastest(c, q, frame, limits) {
85
197
  const dot2 = (a, b) => a.reduce((t, x, i) => t + x * b[i], 0);
86
198
  // In a volume or along a single axis: every way the joints can move together, the slowest the tool goes before a joint runs out
87
199
  function fastestAnyWay(c, q, limits) {
88
- const J = jacobian(c, q), N = c.names.length, turns = N === 1 ? [[1]] : N === 2 ? Array.from({ length: 24 }, (_, k) => [Math.cos((k * Math.PI) / 12), Math.sin((k * Math.PI) / 12)]) : Array.from({ length: 200 }, (_, k) => { const z = 1 - (2 * (k + 0.5)) / 200, r = Math.sqrt(1 - z * z), a = k * 2.399963; return [r * Math.cos(a), r * Math.sin(a), z, ...new Array(N - 3).fill(0)]; });
200
+ const J = jacobian(c, q),
201
+ N = c.names.length,
202
+ turns =
203
+ N === 1
204
+ ? [[1]]
205
+ : N === 2
206
+ ? Array.from({ length: 24 }, (_, k) => [Math.cos((k * Math.PI) / 12), Math.sin((k * Math.PI) / 12)])
207
+ : Array.from({ length: 200 }, (_, k) => {
208
+ const z = 1 - (2 * (k + 0.5)) / 200,
209
+ r = Math.sqrt(1 - z * z),
210
+ a = k * 2.399963;
211
+ return [r * Math.cos(a), r * Math.sin(a), z, ...new Array(N - 3).fill(0)];
212
+ });
89
213
  let worst = Infinity;
90
214
  for (const d of turns) {
91
- const v = J.map((row) => dot2(row, d)), tool = Math.hypot(...v); if (tool < 1e-9) continue;
92
- let scale = Infinity; d.forEach((x, i) => { if (Math.abs(x) > 1e-12) scale = Math.min(scale, limits[i] / Math.abs(x)); });
215
+ const v = J.map((row) => dot2(row, d)),
216
+ tool = Math.hypot(...v);
217
+ if (tool < 1e-9) continue;
218
+ let scale = Infinity;
219
+ d.forEach((x, i) => {
220
+ if (Math.abs(x) > 1e-12) scale = Math.min(scale, limits[i] / Math.abs(x));
221
+ });
93
222
  worst = Math.min(worst, tool * scale);
94
223
  }
95
224
  return worst === Infinity ? 0 : worst;
@@ -99,37 +228,88 @@ function fastestAnyWay(c, q, limits) {
99
228
  function jointSpeeds(s, c) {
100
229
  const motion = s.motion;
101
230
  return c.names.map((id) => {
102
- const t = trainFrom(motion, id), d = motion.drives.find((x) => x.joint === t.root);
231
+ const t = trainFrom(motion, id),
232
+ d = motion.drives.find((x) => x.joint === t.root);
103
233
  if (!d) return null;
104
- const rpm = workingSpeed(d.model, d.spec, d.supply), output = (rpm / t.ratio) * 6; // deg/s at the joint
234
+ const rpm = workingSpeed(d.model, d.spec, d.supply),
235
+ output = (rpm / t.ratio) * 6; // deg/s at the joint
105
236
  return t.slide != null ? output * t.slide : output;
106
237
  });
107
238
  }
108
239
 
109
240
  function speedCheck(s, f) {
110
- const t = s.task, code = 'task.speed'; if (t.speed == null) return;
111
- const { c, r } = sample(s), limits = jointSpeeds(s, c), frame = t.sheet ? sheetFrame(t.sheet) : null;
241
+ const t = s.task,
242
+ code = 'task.speed';
243
+ if (t.speed == null) return;
244
+ const { c, r } = sample(s),
245
+ limits = jointSpeeds(s, c),
246
+ frame = t.sheet ? sheetFrame(t.sheet) : null;
112
247
  const free = c.names.filter((_, i) => limits[i] == null);
113
- if (free.length) return f('warn', `nothing says how fast ${free.join(' and ')} can turn, so ${t.speed} mm/s isn't checked: give ${free.length > 1 ? 'them' : 'it'} a motor`, `speed: ${free.join(', ')} undriven`, { code, refs: { joints: free } });
248
+ if (free.length)
249
+ return f(
250
+ 'warn',
251
+ `nothing says how fast ${free.join(' and ')} can turn, so ${t.speed} mm/s isn't checked: give ${free.length > 1 ? 'them' : 'it'} a motor`,
252
+ `speed: ${free.join(', ')} undriven`,
253
+ { code, refs: { joints: free } },
254
+ );
114
255
  let worst = null;
115
- for (const x of r.samples) if (x.reachable) { const v = fastest(c, x.q, frame, limits); if (!worst || v < worst.v) worst = { v, x }; }
256
+ for (const x of r.samples)
257
+ if (x.reachable) {
258
+ const v = fastest(c, x.q, frame, limits);
259
+ if (!worst || v < worst.v) worst = { v, x };
260
+ }
116
261
  if (!worst) return;
117
- const values = { slowest: worst.v, wanted: t.speed, margin: worst.v / t.speed }, at = worst.x.point, say = `at ${n3(worst.v, 1)} mm/s at the slowest point, ${onSheet(t, at)}, against the ${t.speed} mm/s it's asked for`;
118
- if (worst.v < t.speed) f('fail', `${t.tool} moves ${say}: a faster motor speed, less ratio or a shorter arm`, `speed ${n3(worst.v, 0)} mm/s`, { code, at, values });
262
+ const values = { slowest: worst.v, wanted: t.speed, margin: worst.v / t.speed },
263
+ at = worst.x.point,
264
+ say = `at ${n3(worst.v, 1)} mm/s at the slowest point, ${onSheet(t, at)}, against the ${t.speed} mm/s it's asked for`;
265
+ if (worst.v < t.speed)
266
+ f(
267
+ 'fail',
268
+ `${t.tool} moves ${say}: a faster motor speed, less ratio or a shorter arm`,
269
+ `speed ${n3(worst.v, 0)} mm/s`,
270
+ { code, at, values },
271
+ );
119
272
  else f('pass', `${t.tool} moves ${say}`, null, { code, at, values });
120
273
  }
121
274
 
122
275
  // Each joint's error terms: step resolution from its motor, what the assembly says of its play, its twist and so on, and a
123
276
  // guide's rail's (its parallelism, its carriage's play, the beam's straightness and sag)
124
277
  export function terms(s, c) {
125
- const motion = s.motion, specs = new Map((s.a.joints || []).map((j) => [j.id, j]));
278
+ const motion = s.motion,
279
+ specs = new Map((s.a.joints || []).map((j) => [j.id, j]));
126
280
  return c.names.map((id) => {
127
- const out = [], t = trainFrom(motion, id), d = motion.drives.find((x) => x.joint === t.root), spec = specs.get(id);
128
- if (d?.model.stepAngle) { const micro = d.spec.microsteps ?? 16; out.push({ term: 'step', value: t.slide != null ? (d.model.stepAngle / micro) * t.slide : d.model.stepAngle / micro / t.ratio, kind: 'spec', note: `${n3(d.model.stepAngle, 3)}° at 1/${micro} step, ${n3(t.ratio, 1)}:1` }); }
129
- const belt = motion.joints.find((x) => x.id === id)?.slide?.stretch; if (belt) out.push({ term: 'belt stretch', value: (belt.load * belt.length) / (belt.k * belt.width), kind: 'estimate', note: `${belt.load} N over ${belt.length} mm` });
130
- for (const [term, expr] of Object.entries(spec?.errors ?? {})) out.push({ term, value: s.num(expr), kind: kindOf(expr), expr });
281
+ const out = [],
282
+ t = trainFrom(motion, id),
283
+ d = motion.drives.find((x) => x.joint === t.root),
284
+ spec = specs.get(id);
285
+ if (d?.model.stepAngle) {
286
+ const micro = d.spec.microsteps ?? 16;
287
+ out.push({
288
+ term: 'step',
289
+ value: t.slide != null ? (d.model.stepAngle / micro) * t.slide : d.model.stepAngle / micro / t.ratio,
290
+ kind: 'spec',
291
+ note: `${n3(d.model.stepAngle, 3)}° at 1/${micro} step, ${n3(t.ratio, 1)}:1`,
292
+ });
293
+ }
294
+ const belt = motion.joints.find((x) => x.id === id)?.slide?.stretch;
295
+ if (belt)
296
+ out.push({
297
+ term: 'belt stretch',
298
+ value: (belt.load * belt.length) / (belt.k * belt.width),
299
+ kind: 'estimate',
300
+ note: `${belt.load} N over ${belt.length} mm`,
301
+ });
302
+ for (const [term, expr] of Object.entries(spec?.errors ?? {}))
303
+ out.push({ term, value: s.num(expr), kind: kindOf(expr), expr });
131
304
  for (const x of spec?._guide?.terms ?? []) out.push({ term: x.term, value: x.value, kind: x.kind, note: x.note }); // (a guide's rail: mm along its travel, from its rule sets and the beam's)
132
- if (spec?._guide?.id) { const fr = frameTerms(s, spec._guide); return { joint: id, terms: [...out.filter((x) => !fr.drop.includes(x.term)), ...fr.add], geared: t.stages.length > 0 }; }
305
+ if (spec?._guide?.id) {
306
+ const fr = frameTerms(s, spec._guide);
307
+ return {
308
+ joint: id,
309
+ terms: [...out.filter((x) => !fr.drop.includes(x.term)), ...fr.add],
310
+ geared: t.stages.length > 0,
311
+ };
312
+ }
133
313
  return { joint: id, terms: out, geared: t.stages.length > 0 };
134
314
  });
135
315
  }
@@ -142,23 +322,53 @@ export function terms(s, c) {
142
322
  * does not reach them. @returns {{ add: object[], drop: string[] }} terms to add, and the guide's own to drop
143
323
  */
144
324
  export function frameTerms(s, g) {
145
- const none = { add: [], drop: [] }, rec = (s.guides ?? []).find((x) => x.id === g.id);
325
+ const none = { add: [], drop: [] },
326
+ rec = (s.guides ?? []).find((x) => x.id === g.id);
146
327
  if (!rec?.beam || ['rods', 'screw'].includes(rec.kind)) return none;
147
- const o = s.objects.find((x) => x.id === rec.beam && x.beam), p = o?.beam?.profile, L = rec.length;
328
+ const o = s.objects.find((x) => x.id === rec.beam && x.beam),
329
+ p = o?.beam?.profile,
330
+ L = rec.length;
148
331
  if (!p || !(L > 0)) return none;
149
- const add = [], drop = [], have = new Set((g.terms ?? []).map((x) => x.term)), solved = s.frameGuideSag?.get(g.id);
332
+ const add = [],
333
+ drop = [],
334
+ have = new Set((g.terms ?? []).map((x) => x.term)),
335
+ solved = s.frameGuideSag?.get(g.id);
150
336
  if (solved) {
151
337
  drop.push('beam sag');
152
- add.push({ term: 'beam sag', value: solved.sag, kind: solved.restsOn === 'beams' ? 'derived' : solved.restsOn, note: `${rec.beam} under ${g.id}, solved with the frame${solved.pose ? `, ${solved.pose}` : ''}: ${n3(solved.rigid, 3)} mm with its joins rigid` });
338
+ add.push({
339
+ term: 'beam sag',
340
+ value: solved.sag,
341
+ kind: solved.restsOn === 'beams' ? 'derived' : solved.restsOn,
342
+ note: `${rec.beam} under ${g.id}, solved with the frame${solved.pose ? `, ${solved.pose}` : ''}: ${n3(solved.rigid, 3)} mm with its joins rigid`,
343
+ });
153
344
  }
154
345
  const st = p.supply?.straightness;
155
- if (st != null && !have.has('beam straightness')) add.push({ term: 'beam straightness', value: +((st * L) / 1000).toFixed(4), kind: p.figures?.straightness_per_metre?.kind ?? 'spec', note: `${p.name}, ${n3(st)} mm a metre over the guide's ${n3(L, 1)} mm` });
156
- const tw = p.supply?.twist, W = s.task?.point && s.motion ? worldOf(s, rec.beam) : null, T = W ? worldOf(s, s.task.item) : null;
346
+ if (st != null && !have.has('beam straightness'))
347
+ add.push({
348
+ term: 'beam straightness',
349
+ value: +((st * L) / 1000).toFixed(4),
350
+ kind: p.figures?.straightness_per_metre?.kind ?? 'spec',
351
+ note: `${p.name}, ${n3(st)} mm a metre over the guide's ${n3(L, 1)} mm`,
352
+ });
353
+ const tw = p.supply?.twist,
354
+ W = s.task?.point && s.motion ? worldOf(s, rec.beam) : null,
355
+ T = W ? worldOf(s, s.task.item) : null;
157
356
  if (tw != null && W && T) {
158
- const q = s.task.point, P = [0, 1, 2].map((r) => T[4 * r] * q[0] + T[4 * r + 1] * q[1] + T[4 * r + 2] * q[2] + T[4 * r + 3]); // (the tool, in the world, as drawn)
159
- const O = [W[3], W[7], W[11]], d = [W[2], W[6], W[10]], v = P.map((x, k) => x - O[k]), along = dot(v, d), lever = Math.hypot(...v.map((x, k) => x - along * d[k]));
357
+ const q = s.task.point,
358
+ P = [0, 1, 2].map((r) => T[4 * r] * q[0] + T[4 * r + 1] * q[1] + T[4 * r + 2] * q[2] + T[4 * r + 3]); // (the tool, in the world, as drawn)
359
+ const O = [W[3], W[7], W[11]],
360
+ d = [W[2], W[6], W[10]],
361
+ v = P.map((x, k) => x - O[k]),
362
+ along = dot(v, d),
363
+ lever = Math.hypot(...v.map((x, k) => x - along * d[k]));
160
364
  const deg = (tw * L) / 1000;
161
- if (lever > 1e-6) add.push({ term: 'beam twist', value: +(((deg * Math.PI) / 180) * lever).toFixed(4), kind: p.figures?.twist_per_metre?.kind ?? 'spec', note: `${p.name}, ${n3(tw)}° a metre over the guide's ${n3(L, 1)} mm, ${n3(deg, 3)}°, at the tool ${n3(lever, 1)} mm from ${rec.beam}'s axis` });
365
+ if (lever > 1e-6)
366
+ add.push({
367
+ term: 'beam twist',
368
+ value: +(((deg * Math.PI) / 180) * lever).toFixed(4),
369
+ kind: p.figures?.twist_per_metre?.kind ?? 'spec',
370
+ note: `${p.name}, ${n3(tw)}° a metre over the guide's ${n3(L, 1)} mm, ${n3(deg, 3)}°, at the tool ${n3(lever, 1)} mm from ${rec.beam}'s axis`,
371
+ });
162
372
  }
163
373
  return { add, drop };
164
374
  }
@@ -166,41 +376,81 @@ export function frameTerms(s, g) {
166
376
  function worldOf(s, id) {
167
377
  const i = s.motion.items.findIndex((x) => x[0] === id);
168
378
  if (i < 0) return null;
169
- try { return placeItems(s.motion, s.jointValues)[i]; } catch { return null; }
379
+ try {
380
+ return placeItems(s.motion, s.jointValues)[i];
381
+ } catch {
382
+ return null;
383
+ }
170
384
  }
171
385
  function kindOf(expr) {
172
- const kinds = [...String(expr).matchAll(/([a-z][\w-]*)\.([a-z_]\w*)/gi)].map(([, set, rule]) => { try { return peekRuleSet(set).rules[rule]?.kind ?? 'estimate'; } catch { return 'estimate'; } });
386
+ const kinds = [...String(expr).matchAll(/([a-z][\w-]*)\.([a-z_]\w*)/gi)].map(([, set, rule]) => {
387
+ try {
388
+ return peekRuleSet(set).rules[rule]?.kind ?? 'estimate';
389
+ } catch {
390
+ return 'estimate';
391
+ }
392
+ });
173
393
  return kinds.length ? (kinds.includes('estimate') ? 'estimate' : kinds[0]) : 'estimate';
174
394
  }
175
395
 
176
396
  // The error at one sample: each angle times what it swings at the tool. Worst case, root-sum-square, and each term's share
177
397
  function errorAt(c, q, list, extra) {
178
- const J = jacobian(c, q), lever = c.names.map((_, i) => Math.hypot(J[0][i], J[1][i], J[2][i])), parts = [];
179
- list.forEach((j, i) => { for (const x of j.terms) parts.push({ joint: j.joint, term: x.term, kind: x.kind, note: x.note, angle: x.value, mm: x.value * lever[i] }); });
398
+ const J = jacobian(c, q),
399
+ lever = c.names.map((_, i) => Math.hypot(J[0][i], J[1][i], J[2][i])),
400
+ parts = [];
401
+ list.forEach((j, i) => {
402
+ for (const x of j.terms)
403
+ parts.push({ joint: j.joint, term: x.term, kind: x.kind, note: x.note, angle: x.value, mm: x.value * lever[i] });
404
+ });
180
405
  if (extra) parts.push({ joint: null, term: 'link deflection', kind: 'estimate', mm: extra });
181
- return { worst: parts.reduce((t, p) => t + p.mm, 0), rss: Math.sqrt(parts.reduce((t, p) => t + p.mm * p.mm, 0)), parts };
406
+ return {
407
+ worst: parts.reduce((t, p) => t + p.mm, 0),
408
+ rss: Math.sqrt(parts.reduce((t, p) => t + p.mm * p.mm, 0)),
409
+ parts,
410
+ };
182
411
  }
183
412
 
184
413
  // The worst-case error at one joint configuration
185
414
  export const jacobianError = (c, q, list, extra) => errorAt(c, q, list, extra).worst;
186
415
 
187
416
  export function accuracyOf(s) {
188
- const { c, r } = sample(s), list = terms(s, c), at = r.samples.filter((x) => x.reachable).map((x) => ({ x, e: errorAt(c, x.q, list, s.task.deflection) }));
417
+ const { c, r } = sample(s),
418
+ list = terms(s, c),
419
+ at = r.samples.filter((x) => x.reachable).map((x) => ({ x, e: errorAt(c, x.q, list, s.task.deflection) }));
189
420
  return { list, at, worst: at.reduce((a, b) => (b.e.worst > a.e.worst ? b : a), at[0]) };
190
421
  }
191
422
 
192
423
  function accuracyCheck(s, f, picture) {
193
- const t = s.task, code = 'task.accuracy'; if (t.accuracy == null) return null;
194
- const { list, at, worst } = accuracyOf(s); if (!worst) return null;
195
- const big = [...worst.e.parts].sort((a, b) => b.mm - a.mm)[0], soft = worst.e.parts.filter((p) => p.kind === 'estimate');
424
+ const t = s.task,
425
+ code = 'task.accuracy';
426
+ if (t.accuracy == null) return null;
427
+ const { list, at, worst } = accuracyOf(s);
428
+ if (!worst) return null;
429
+ const big = [...worst.e.parts].sort((a, b) => b.mm - a.mm)[0],
430
+ soft = worst.e.parts.filter((p) => p.kind === 'estimate');
196
431
  const slides = new Set(s.motion.joints.filter((j) => j.type === 'prismatic').map((j) => j.id)); // (a sliding joint's terms are mm already)
197
- const name = (p) => `${p.joint ? `${p.joint}'s ` : ''}${p.term}${p.angle != null && !slides.has(p.joint) ? ` (${n3(p.angle, 3)}°)` : ''}`;
198
- const unmeasured = list.filter((j) => j.geared && !j.terms.some((x) => /play|backlash/.test(x.term))).map((j) => j.joint);
432
+ const name = (p) =>
433
+ `${p.joint ? `${p.joint}'s ` : ''}${p.term}${p.angle != null && !slides.has(p.joint) ? ` (${n3(p.angle, 3)}°)` : ''}`;
434
+ const unmeasured = list
435
+ .filter((j) => j.geared && !j.terms.some((x) => /play|backlash/.test(x.term)))
436
+ .map((j) => j.joint);
199
437
  const predict = { name: code, figure: `${t.tool} error at its worst point`, value: worst.e.worst, unit: 'mm' };
200
- const margin = worst.e.worst / t.accuracy, level = margin > 1 ? 'fail' : margin > 0.8 ? 'warn' : 'pass';
201
- const caveat = soft.length ? ` Rests on estimates (${soft.map(name).join(', ')}): settle them with cad measured.` : '', missing = unmeasured.length ? ` ${unmeasured.join(' and ')} ${unmeasured.length > 1 ? 'have' : 'has'} gears and no play given: it counts as none until measured (bench test 14).` : '';
438
+ const margin = worst.e.worst / t.accuracy,
439
+ level = margin > 1 ? 'fail' : margin > 0.8 ? 'warn' : 'pass';
440
+ const caveat = soft.length
441
+ ? ` Rests on estimates (${soft.map(name).join(', ')}): settle them with cad measured.`
442
+ : '',
443
+ missing = unmeasured.length
444
+ ? ` ${unmeasured.join(' and ')} ${unmeasured.length > 1 ? 'have' : 'has'} gears and no play given: it counts as none until measured (bench test 14).`
445
+ : '';
202
446
  const text = `${t.tool} can be out by ${n3(worst.e.worst, 3)} mm at worst, ${n3(worst.e.rss, 3)} mm root-sum-square, at ${onSheet(t, worst.x.point)}, against ${t.accuracy} mm. Biggest: ${name(big)}, ${n3(big.mm, 3)} mm.${caveat}${missing}`;
203
- f(level, text, level === 'pass' ? null : `pen error ${n3(worst.e.worst, 2)} mm`, { code, at: worst.x.point, predict, refs: { biggest: big.term, joint: big.joint }, values: { worst: worst.e.worst, rss: worst.e.rss, wanted: t.accuracy, margin, terms: worst.e.parts, picture } });
447
+ f(level, text, level === 'pass' ? null : `pen error ${n3(worst.e.worst, 2)} mm`, {
448
+ code,
449
+ at: worst.x.point,
450
+ predict,
451
+ refs: { biggest: big.term, joint: big.joint },
452
+ values: { worst: worst.e.worst, rss: worst.e.rss, wanted: t.accuracy, margin, terms: worst.e.parts, picture },
453
+ });
204
454
  return at;
205
455
  }
206
456
 
@@ -208,20 +458,61 @@ function accuracyCheck(s, f, picture) {
208
458
  const colour = (x) => `rgb(${Math.round(240 - 180 * x)},${Math.round(240 - 100 * x)},${Math.round(250 - 40 * x)})`;
209
459
  function pictures(s, errors) {
210
460
  if (!s.task.sheet) return null;
211
- const { c, r } = sample(s), f = sheetFrame(s.task.sheet), toSheet = (p) => { const d = p.map((x, k) => x - f.at[k]); return [dot(d, f.u), -dot(d, f.v)]; };
212
- const pts = [...r.samples.map((x) => toSheet(x.point)), ...fk(c, r.summary.worst.q).frames.map((x) => toSheet(x.at))], lo = [0, 1].map((k) => Math.min(...pts.map((p) => p[k]))), hi = [0, 1].map((k) => Math.max(...pts.map((p) => p[k])));
213
- const m = 15, W = hi[0] - lo[0] + 2 * m, H = hi[1] - lo[1] + 2 * m, step = sample(s).step;
461
+ const { c, r } = sample(s),
462
+ f = sheetFrame(s.task.sheet),
463
+ toSheet = (p) => {
464
+ const d = p.map((x, k) => x - f.at[k]);
465
+ return [dot(d, f.u), -dot(d, f.v)];
466
+ };
467
+ const pts = [...r.samples.map((x) => toSheet(x.point)), ...fk(c, r.summary.worst.q).frames.map((x) => toSheet(x.at))],
468
+ lo = [0, 1].map((k) => Math.min(...pts.map((p) => p[k]))),
469
+ hi = [0, 1].map((k) => Math.max(...pts.map((p) => p[k])));
470
+ const m = 15,
471
+ W = hi[0] - lo[0] + 2 * m,
472
+ H = hi[1] - lo[1] + 2 * m,
473
+ step = sample(s).step;
214
474
  const head = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${lo[0] - m} ${lo[1] - m} ${W} ${H}" width="${Math.round(W * 3)}" height="${Math.round(H * 3)}" font-family="sans-serif" font-size="5">`;
215
475
  const sheet = `<rect x="${-f.width / 2}" y="${-f.height / 2}" width="${f.width}" height="${f.height}" fill="none" stroke="#333" stroke-width="0.6"/>`;
216
- const arm = (q) => { const F = fk(c, q), P = [...F.frames.map((x) => x.at), F.position].map(toSheet); return `<polyline points="${P.map((p) => p.join(',')).join(' ')}" fill="none" stroke="#c33" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>` + P.map((p) => `<circle cx="${p[0]}" cy="${p[1]}" r="2" fill="#c33"/>`).join(''); };
217
- const cells = (val) => r.samples.map((x) => { const [px, py] = toSheet(x.point), v = val(x); return `<rect x="${px - step / 2}" y="${py - step / 2}" width="${step}" height="${step}" fill="${v == null ? '#f8c0c0' : colour(v)}"/>`; }).join('');
218
- const dir = paths.preview(s.project, ''); fs.mkdirSync(dir, { recursive: true });
219
- const write = (name, body, title) => { const file = paths.preview(s.project, `${s.name}-${name}.svg`); fs.writeFileSync(file, `${head}<text x="${lo[0] - m + 2}" y="${lo[1] - m + 7}">${title}</text>${body}</svg>\n`); return file; };
476
+ const arm = (q) => {
477
+ const F = fk(c, q),
478
+ P = [...F.frames.map((x) => x.at), F.position].map(toSheet);
479
+ return (
480
+ `<polyline points="${P.map((p) => p.join(',')).join(' ')}" fill="none" stroke="#c33" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>` +
481
+ P.map((p) => `<circle cx="${p[0]}" cy="${p[1]}" r="2" fill="#c33"/>`).join('')
482
+ );
483
+ };
484
+ const cells = (val) =>
485
+ r.samples
486
+ .map((x) => {
487
+ const [px, py] = toSheet(x.point),
488
+ v = val(x);
489
+ return `<rect x="${px - step / 2}" y="${py - step / 2}" width="${step}" height="${step}" fill="${v == null ? '#f8c0c0' : colour(v)}"/>`;
490
+ })
491
+ .join('');
492
+ const dir = paths.preview(s.project, '');
493
+ fs.mkdirSync(dir, { recursive: true });
494
+ const write = (name, body, title) => {
495
+ const file = paths.preview(s.project, `${s.name}-${name}.svg`);
496
+ fs.writeFileSync(file, `${head}<text x="${lo[0] - m + 2}" y="${lo[1] - m + 7}">${title}</text>${body}</svg>\n`);
497
+ return file;
498
+ };
220
499
  const top = Math.max(...r.samples.map((x) => x.manipulability), 1e-9);
221
- const out = { reach: write('reach', cells((x) => (x.reachable ? x.manipulability / top : null)) + sheet + arm(r.summary.worst.q), 'Reach: darker has more dexterity, red is out of reach. The arm at the least margin') };
500
+ const out = {
501
+ reach: write(
502
+ 'reach',
503
+ cells((x) => (x.reachable ? x.manipulability / top : null)) + sheet + arm(r.summary.worst.q),
504
+ 'Reach: darker has more dexterity, red is out of reach. The arm at the least margin',
505
+ ),
506
+ };
222
507
  if (errors?.length) {
223
- const most = Math.max(...errors.map((e) => e.e.worst), 1e-9), by = new Map(errors.map((e) => [e.x, e.e.worst / most])), worst = errors.reduce((a, b) => (b.e.worst > a.e.worst ? b : a));
224
- out.error = write('error', cells((x) => (by.has(x) ? by.get(x) : null)) + sheet + arm(worst.x.q), `Predicted error: darkest is ${n3(most, 3)} mm. The arm at its worst point`);
508
+ const most = Math.max(...errors.map((e) => e.e.worst), 1e-9),
509
+ by = new Map(errors.map((e) => [e.x, e.e.worst / most])),
510
+ worst = errors.reduce((a, b) => (b.e.worst > a.e.worst ? b : a));
511
+ out.error = write(
512
+ 'error',
513
+ cells((x) => (by.has(x) ? by.get(x) : null)) + sheet + arm(worst.x.q),
514
+ `Predicted error: darkest is ${n3(most, 3)} mm. The arm at its worst point`,
515
+ );
225
516
  }
226
517
  return out;
227
518
  }
@@ -231,7 +522,13 @@ export function taskChecks(s, f) {
231
522
  if (!s.task) return;
232
523
  const relative = (x) => x && x.replace(`${paths.preview(s.project, '')}/`, '');
233
524
  let drawn = null;
234
- try { const { c } = sample(s); if (!c.dof) return; drawn = true; } catch (e) { return f('fail', `task: ${e.message}`, 'task: no chain', { code: 'task.chain' }); }
525
+ try {
526
+ const { c } = sample(s);
527
+ if (!c.dof) return;
528
+ drawn = true;
529
+ } catch (e) {
530
+ return f('fail', `task: ${e.message}`, 'task: no chain', { code: 'task.chain' });
531
+ }
235
532
  const pic = pictures(s, s.task.accuracy != null ? accuracyOf(s).at : null);
236
533
  reachCheck(s, f, relative(pic?.reach));
237
534
  speedCheck(s, f);