@rulecad/cad 0.7.89 → 0.7.97

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.
package/AGENTS.md CHANGED
@@ -256,6 +256,8 @@ variable says which rule it comes from. Follow these steps; they're what makes a
256
256
  factor, and where the peak stress is.
257
257
  - For a part that must not break (a lever, a pedal), give its problem a `"stress"` limit (the material's strength
258
258
  over a safety factor) instead of a `"volume"`: the lightest layout under it. Then verify it on finer cells.
259
+ Add `"robust": true` so it holds made a little thin and a little thick too (`cad optimise` prints both copies'
260
+ peaks); a mechanism with `"robust": true` and a `"strain"` limit is optimised under the limit.
259
261
  - Mark a problem `"critical": true` if the part could hurt someone if it broke. Say plainly that the analysis is a
260
262
  design aid and the material values are data-sheet figures: such a part needs testing, recorded under
261
263
  `"verification"`, not just a check.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,85 @@ print (a hole's diameter, a seat's depth, a part's outline). Each release lists
5
5
  its reason. A **fasten** is an entry in an assembly's `"fasten"` list: one screwed joint, naming the screw by thread
6
6
  and head, the parts it passes through and the part it ends in.
7
7
 
8
+ ## 0.7.97: robust: true
9
+ ### Added
10
+
11
+ - A problem's `robust: true` (schema first): optimised as made, a little thin and a little thick (topopt's robust
12
+ formulation). With a stress or strain limit, the lightest layout that keeps it on all three; a mechanism, the layout
13
+ whose worst copy moves furthest, and with a limit, optimised under it. `cad optimise` prints the copies: "made a
14
+ little thin, peak stress X MPa; a little thick, Y MPa" (with a note where either is over the limit) and, for a
15
+ mechanism, "made a little thin, its output moves X mm; a little thick, Y mm". Refused by name with a volume alone.
16
+
17
+ ### Printed sizes that moved
18
+
19
+ - None.
20
+
21
+ ## 0.7.95: a rubber is refused as a printed fitting
22
+ ### Changed
23
+
24
+ - A project whose material is a rubber (a rule set whose strength over its modulus is past 0.5, such as the kit's new
25
+ `tpu`) is refused by name for printed fittings, whose sums are for a stiff plastic, and a rubber is left out of the
26
+ plastics another refusal lists. No printed size moved.
27
+
28
+ ## 0.7.93: milled by a tool, cast with draft, a minimum feature, voids prevented
29
+ ### Added
30
+
31
+ - A problem milled from several sides (`"mill": ["+z", "-z"]`), by a tool of a size (`"tool"`, mm), or cast with a
32
+ draft (`"draft"`, degrees): the schema first. `cad optimise` says how it is made, the draft as made at the grid
33
+ ("a step out every 3 layers: 18.43°"), and any cells too narrow for the tool, in the design or in avoid regions
34
+ (drill those holes). A tool or draft with no milling or casting is refused by name.
35
+ - `"mill"` and `"cast"` can name a variable holding the side or sides (`"+z"`, `"+z -z"`) or `"none"`, so a variant
36
+ switches the process; a tool or draft goes off with it.
37
+ - `"voids": "prevented"`: the optimiser keeps every empty pocket open to the outside; cad optimise says so, and any
38
+ void a keep region walls in is still an error, said to be left though prevented.
39
+ - `"feature"` (mm): the thinnest member, from the printer's line (`x1c.wall_min`, two lines). `cad optimise` says the
40
+ grid holds it where a cell is as wide, or that it was held to three cells, with any cells left narrower; past three
41
+ cells it is refused with the cell size that would hold it.
42
+ - The bench's lever E (`bench/lever:milled`): the lever's profile milled through a 6 mm plate by a 4 mm end mill,
43
+ 98.9 N/mm against the printed C's 100. No existing printed size moves.
44
+ - A refusal of a feature past three cells asks for cells of at least a third of it, rounded up (it asked for cells of
45
+ 1.33 mm or less for 4 mm, which it refused again), or a smaller feature.
46
+
47
+
48
+ ## 0.7.92: eight axes on a Mega 2560 (#199)
49
+ - The wiring sheet names a Mega slot's pins as step, dir and enable (D38, every slot's): the wire to a driver breakout carries EN, STEP, DIR and GND, and the axis's home switch is a wire of its own. A CNC shield's axis still names its limit pin.
50
+ - The quadruped carries a 12 V supply (a Mean Well LRS-100-12 to buy: about 6 A for eight motors, an estimate) and a power wire to each breakout.
51
+ ### Added
52
+
53
+ - `cad machine` writes the machine's `controller`: the bought board the streamer runs on, a CNC Shield V3 (an Uno,
54
+ three axes, slots X, Y, Z) or an `arduino-mega-2560` (eight axes, slots S0 to S7), with the Uno where the assembly
55
+ names none. A motor's slot is read from its wire to the board, or, for a driver on its own breakout, from the motor's
56
+ wire to the breakout and the breakout's signal wire on to the slot. Two different controllers are refused by name.
57
+ - `cad plot` on a gait holds the axes to the controller's slots: the quadruped's eight stream through the Mega, and an
58
+ Uno still warns `stream.axes` past three, naming the Mega as the way to more.
59
+ - The wiring sheet names a Mega slot's pins as it does a shield's.
60
+
61
+ ### Changed
62
+
63
+ - The bench quadruped and crawl carry a Mega 2560, a DRV8825 on a driver breakout for each motor and sixteen wires
64
+ (each motor to its breakout, each breakout's EN, STEP, DIR and GND to the Mega); each motor names its driver, so the
65
+ check says each trimmer's setting. The boards sit over the body as references; no printed size moved. EXAMPLES
66
+ chapter 14 says how the eight axes are wired, and `leg.robot_mass`'s rule names the Mega (its 4.2 kg is unchanged).
67
+
68
+ ## 0.7.91: problems at an assembly's joints, avoid regions from a sweep
69
+ ### Added
70
+
71
+ - Optimisation problems placed in an assembly (#28): `"in": { "assembly", "item", "pose", "z" }` puts a problem in
72
+ an item's frame. A region, support or load can sit at one of the assembly's joints (`"joint": "hinge"`, read as an
73
+ anchor is), and an `avoid` region can be a part swept through a joint's range (`{ "sweep": "gate", "through":
74
+ "swing", "steps" }`), each step kept clear; in a flat problem, all of the part within the plate's thickness (its
75
+ sections up the plate, half a cell apart and closer where a face leans, so a part dipping into the plate's top or
76
+ bottom is kept clear too), holes open. Steps by default so no point moves more than half a cell between two. Changing the assembly reruns the
77
+ optimisation. `cad why` names the assembly, the joints read and each sweep's range and steps. Schema first:
78
+ `problem.schema.json` gains `in`, `joint`, `sweep`, `through` and `steps`. Refused by name: a sweep outside avoid,
79
+ of the item itself or through a joint that doesn't move it against the item; a part that never reaches into a flat
80
+ plate's thickness; a joint or item the assembly has not got; more than 360 default steps.
81
+
82
+ ### Printed sizes that moved
83
+
84
+ - None. Problems without `in` read as before (each result is drawn again once, since this file's code is in the
85
+ drawing's key; no densities key moves).
86
+
8
87
  ## 0.7.89: fewer triangles by default
9
88
  ### Changed
10
89
 
package/EXAMPLES.md CHANGED
@@ -4410,7 +4410,7 @@ The stack of the same gearbox with the motor's face as zero, what the leg stands
4410
4410
  "body_half": {"value": 75, "unit": "mm", "rule": "Hip to hip along the body, halved: the side plate, 242 mm long, fits on a 256 mm bed, and the knees point outward so they stay apart", "kind": "default", "source": "EXAMPLES chapter 14", "checked": "2026-11-09"},
4411
4411
  "body_w": {"value": 50, "unit": "mm", "rule": "The body's half-width, to the hips' plates: two hip motors back to back fit inside", "kind": "default", "source": "EXAMPLES chapter 14", "checked": "2026-11-09"},
4412
4412
  "side_t": {"value": 6, "unit": "mm", "rule": "The side plate's thickness", "kind": "default", "source": "EXAMPLES chapter 14", "checked": "2026-11-09"},
4413
- "robot_mass": {"value": 4.2, "unit": "kg", "rule": "The quadruped as drawn: 3.83 kg of prints, eight 17HS4401s, bearings and screws from cad list, and about 0.4 kg for its drivers, an Uno and shield, a battery and the wires, an estimate until built", "kind": "estimate", "source": "cad list leg/quadruped (3834 g, the knees 17HS4401s at 280 g each) and a guess at the electronics", "checked": "2026-11-23"},
4413
+ "robot_mass": {"value": 4.2, "unit": "kg", "rule": "The quadruped as drawn: 3.83 kg of prints, eight 17HS4401s, bearings and screws from cad list, and about 0.4 kg for its electronics (a Mega 2560, eight DRV8825s on their breakouts, none weighed), a battery and the wires, an estimate until built", "kind": "estimate", "source": "cad list leg/quadruped (3834 g, the knees 17HS4401s at 280 g each) and a guess at the electronics", "checked": "2026-11-23"},
4414
4414
  "foot_socket": {"value": 12, "unit": "mm", "rule": "How far each rod goes into a foot block", "kind": "default", "source": "EXAMPLES chapter 14", "checked": "2026-11-09"}
4415
4415
  }
4416
4416
  }
@@ -5453,6 +5453,8 @@ export function main (v) {
5453
5453
 
5454
5454
  The quadruped carries the leg's parts, every one, as items of a single assembly. That costs length, because each leg's gearbox is written out; it is what lets the gait below move every joint, with every planet turning, and lets the sweep look for leg against leg. Two gaits, one file each: a trot and a crawl, the same machine. The hip motors live between the two plates, with the beams between them.
5455
5455
 
5456
+ Eight motors are more than the stand's Uno under a CNC shield can step: its streamer has three axes. The quadruped carries one Arduino Mega 2560 (`mega`, the `arduino-mega-2560` rule set), which runs the same streamer built for eight axes, and a DRV8825 for each motor on its own driver breakout (`driver-breakout`): each motor's wire goes to its breakout, and each breakout's EN, STEP, DIR and GND go on to one of the Mega's slots, `S0` to `S7`. One board keeps every leg's steps in the same blocks, which two boards kept in step could not promise. The boards sit over the body, clear of the hip motors, as references for the shopping list and the wire lengths; a deck to hold them is not designed yet. `cad machine leg/quadruped` lists each axis with its slot, and `cad plot leg/quadruped` writes the trot as a step file that the sender, `projects/leg/send.mjs`, streams to the Mega (`projects/leg/STREAMER.md` says how).
5457
+
5456
5458
  ```json projects/leg/assemblies/quadruped.json
5457
5459
  {
5458
5460
  "$schema": "https://jonibach.github.io/rulecad/schemas/assembly.schema.json",
@@ -5465,7 +5467,7 @@ The quadruped carries the leg's parts, every one, as items of a single assembly.
5465
5467
  {"id": "right", "object": "side", "at": [0, "0 - leg.body_w",0], "rotate": [90,0,180]},
5466
5468
  {"id": "beam1", "object": "beam", "at": ["left.beam_at",0,-6], "rotate": [0,0,90]},
5467
5469
  {"id": "beam2", "object": "beam", "at": ["0 - left.beam_at",0,-6], "rotate": [0,0,90]},
5468
- {"id": "fl_m1", "motor": {"model": "17HS4401", "drives": "fl_hd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8}},
5470
+ {"id": "fl_m1", "motor": {"model": "17HS4401", "drives": "fl_hd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8, "driver": "fl_d1"}},
5469
5471
  {"id": "fl_housing", "object": "housing", "at": ["leg.body_half", "leg.body_w",0], "rotate": [-90,0,0]},
5470
5472
  {"id": "fl_sun", "object": "sun"},
5471
5473
  {"id": "fl_carrier", "object": "speck"},
@@ -5477,7 +5479,7 @@ The quadruped carries the leg's parts, every one, as items of a single assembly.
5477
5479
  {"id": "fl_bridge", "object": "bridge"},
5478
5480
  {"id": "fl_b1", "bought": "bearing-6800"},
5479
5481
  {"id": "fl_thigh", "object": "thigh"},
5480
- {"id": "fl_m2", "motor": {"model": "17HS4401", "drives": "fl_kd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8}},
5482
+ {"id": "fl_m2", "motor": {"model": "17HS4401", "drives": "fl_kd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8, "driver": "fl_d2"}},
5481
5483
  {"id": "fl_esun", "object": "sun", "set": {"tip": 11.7}},
5482
5484
  {"id": "fl_ecarrier", "object": "speck"},
5483
5485
  {"id": "fl_ering", "object": "speck"},
@@ -5490,7 +5492,7 @@ The quadruped carries the leg's parts, every one, as items of a single assembly.
5490
5492
  {"id": "fl_clip3", "object": "clip"},
5491
5493
  {"id": "fl_shin", "object": "shin"},
5492
5494
  {"id": "fl_pad", "object": "pad"},
5493
- {"id": "fr_m1", "motor": {"model": "17HS4401", "drives": "fr_hd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8}},
5495
+ {"id": "fr_m1", "motor": {"model": "17HS4401", "drives": "fr_hd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8, "driver": "fr_d1"}},
5494
5496
  {"id": "fr_housing", "object": "housing", "at": ["leg.body_half", "0 - leg.body_w",0], "rotate": [-90,0,180]},
5495
5497
  {"id": "fr_sun", "object": "sun"},
5496
5498
  {"id": "fr_carrier", "object": "speck"},
@@ -5502,7 +5504,7 @@ The quadruped carries the leg's parts, every one, as items of a single assembly.
5502
5504
  {"id": "fr_bridge", "object": "bridge"},
5503
5505
  {"id": "fr_b1", "bought": "bearing-6800"},
5504
5506
  {"id": "fr_thigh", "object": "thigh"},
5505
- {"id": "fr_m2", "motor": {"model": "17HS4401", "drives": "fr_kd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8}},
5507
+ {"id": "fr_m2", "motor": {"model": "17HS4401", "drives": "fr_kd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8, "driver": "fr_d2"}},
5506
5508
  {"id": "fr_esun", "object": "sun", "set": {"tip": 11.7}},
5507
5509
  {"id": "fr_ecarrier", "object": "speck"},
5508
5510
  {"id": "fr_ering", "object": "speck"},
@@ -5515,7 +5517,7 @@ The quadruped carries the leg's parts, every one, as items of a single assembly.
5515
5517
  {"id": "fr_clip3", "object": "clip"},
5516
5518
  {"id": "fr_shin", "object": "shin"},
5517
5519
  {"id": "fr_pad", "object": "pad"},
5518
- {"id": "bl_m1", "motor": {"model": "17HS4401", "drives": "bl_hd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8}},
5520
+ {"id": "bl_m1", "motor": {"model": "17HS4401", "drives": "bl_hd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8, "driver": "bl_d1"}},
5519
5521
  {"id": "bl_housing", "object": "housing", "at": ["0 - leg.body_half", "leg.body_w",0], "rotate": [-90,0,0]},
5520
5522
  {"id": "bl_sun", "object": "sun"},
5521
5523
  {"id": "bl_carrier", "object": "speck"},
@@ -5527,7 +5529,7 @@ The quadruped carries the leg's parts, every one, as items of a single assembly.
5527
5529
  {"id": "bl_bridge", "object": "bridge"},
5528
5530
  {"id": "bl_b1", "bought": "bearing-6800"},
5529
5531
  {"id": "bl_thigh", "object": "thigh"},
5530
- {"id": "bl_m2", "motor": {"model": "17HS4401", "drives": "bl_kd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8}},
5532
+ {"id": "bl_m2", "motor": {"model": "17HS4401", "drives": "bl_kd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8, "driver": "bl_d2"}},
5531
5533
  {"id": "bl_esun", "object": "sun", "set": {"tip": 11.7}},
5532
5534
  {"id": "bl_ecarrier", "object": "speck"},
5533
5535
  {"id": "bl_ering", "object": "speck"},
@@ -5540,7 +5542,7 @@ The quadruped carries the leg's parts, every one, as items of a single assembly.
5540
5542
  {"id": "bl_clip3", "object": "clip"},
5541
5543
  {"id": "bl_shin", "object": "shin"},
5542
5544
  {"id": "bl_pad", "object": "pad"},
5543
- {"id": "br_m1", "motor": {"model": "17HS4401", "drives": "br_hd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8}},
5545
+ {"id": "br_m1", "motor": {"model": "17HS4401", "drives": "br_hd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8, "driver": "br_d1"}},
5544
5546
  {"id": "br_housing", "object": "housing", "at": ["0 - leg.body_half", "0 - leg.body_w",0], "rotate": [-90,0,180]},
5545
5547
  {"id": "br_sun", "object": "sun"},
5546
5548
  {"id": "br_carrier", "object": "speck"},
@@ -5552,7 +5554,7 @@ The quadruped carries the leg's parts, every one, as items of a single assembly.
5552
5554
  {"id": "br_bridge", "object": "bridge"},
5553
5555
  {"id": "br_b1", "bought": "bearing-6800"},
5554
5556
  {"id": "br_thigh", "object": "thigh"},
5555
- {"id": "br_m2", "motor": {"model": "17HS4401", "drives": "br_kd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8}},
5557
+ {"id": "br_m2", "motor": {"model": "17HS4401", "drives": "br_kd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8, "driver": "br_d2"}},
5556
5558
  {"id": "br_esun", "object": "sun", "set": {"tip": 11.7}},
5557
5559
  {"id": "br_ecarrier", "object": "speck"},
5558
5560
  {"id": "br_ering", "object": "speck"},
@@ -5564,7 +5566,25 @@ The quadruped carries the leg's parts, every one, as items of a single assembly.
5564
5566
  {"id": "br_clip2", "object": "clip"},
5565
5567
  {"id": "br_clip3", "object": "clip"},
5566
5568
  {"id": "br_shin", "object": "shin"},
5567
- {"id": "br_pad", "object": "pad"}
5569
+ {"id": "br_pad", "object": "pad"},
5570
+ {"id": "mega", "bought": "arduino-mega-2560", "at": [0, 0, 20]},
5571
+ {"id": "psu", "bought": "supply-12v", "at": [0, 150, 20]},
5572
+ {"id": "fl_board1", "bought": "driver-breakout", "at": [69, 19.5, 48]},
5573
+ {"id": "fl_d1", "bought": "drv8825", "at": [69, 19.5, 58.1]},
5574
+ {"id": "fl_board2", "bought": "driver-breakout", "at": [23, 19.5, 48]},
5575
+ {"id": "fl_d2", "bought": "drv8825", "at": [23, 19.5, 58.1]},
5576
+ {"id": "fr_board1", "bought": "driver-breakout", "at": [69, -19.5, 48]},
5577
+ {"id": "fr_d1", "bought": "drv8825", "at": [69, -19.5, 58.1]},
5578
+ {"id": "fr_board2", "bought": "driver-breakout", "at": [23, -19.5, 48]},
5579
+ {"id": "fr_d2", "bought": "drv8825", "at": [23, -19.5, 58.1]},
5580
+ {"id": "bl_board1", "bought": "driver-breakout", "at": [-69, 19.5, 48]},
5581
+ {"id": "bl_d1", "bought": "drv8825", "at": [-69, 19.5, 58.1]},
5582
+ {"id": "bl_board2", "bought": "driver-breakout", "at": [-23, 19.5, 48]},
5583
+ {"id": "bl_d2", "bought": "drv8825", "at": [-23, 19.5, 58.1]},
5584
+ {"id": "br_board1", "bought": "driver-breakout", "at": [-69, -19.5, 48]},
5585
+ {"id": "br_d1", "bought": "drv8825", "at": [-69, -19.5, 58.1]},
5586
+ {"id": "br_board2", "bought": "driver-breakout", "at": [-23, -19.5, 48]},
5587
+ {"id": "br_d2", "bought": "drv8825", "at": [-23, -19.5, 58.1]}
5568
5588
  ],
5569
5589
  "joints": [
5570
5590
  {"id": "fl_m1_on", "type": "fixed", "parent": "fl_housing.motor", "child": "fl_m1.face"},
@@ -5754,6 +5774,32 @@ The quadruped carries the leg's parts, every one, as items of a single assembly.
5754
5774
  {"a": "br_ecarrier", "b": "br_ering", "min": -1},
5755
5775
  {"a": "br_pad", "b": "br_shin", "min": -2}
5756
5776
  ],
5777
+ "wires": [
5778
+ {"id": "fl_hd_motor", "from": "fl_m1.connector", "to": "fl_board1.top", "gauge": "awg24", "colour": "black, red, green, blue", "connectors": ["JST-XH 4 pin", "screw terminal"]},
5779
+ {"id": "fl_hd_signal", "from": "fl_board1.centre", "to": "mega.S0", "gauge": "awg26", "conductors": 4, "colour": "white, yellow, green, black", "connectors": ["Dupont 4 pin", "Dupont"], "note": "EN, STEP, DIR and GND: the streamer's axis 0"},
5780
+ {"id": "fl_kd_motor", "from": "fl_m2.connector", "to": "fl_board2.top", "via": ["fl_thigh.cable"], "gauge": "awg24", "colour": "black, red, green, blue", "connectors": ["JST-XH 4 pin", "screw terminal"]},
5781
+ {"id": "fl_kd_signal", "from": "fl_board2.centre", "to": "mega.S1", "gauge": "awg26", "conductors": 4, "colour": "white, yellow, green, black", "connectors": ["Dupont 4 pin", "Dupont"], "note": "EN, STEP, DIR and GND: the streamer's axis 1"},
5782
+ {"id": "fr_hd_motor", "from": "fr_m1.connector", "to": "fr_board1.top", "gauge": "awg24", "colour": "black, red, green, blue", "connectors": ["JST-XH 4 pin", "screw terminal"]},
5783
+ {"id": "fr_hd_signal", "from": "fr_board1.centre", "to": "mega.S2", "gauge": "awg26", "conductors": 4, "colour": "white, yellow, green, black", "connectors": ["Dupont 4 pin", "Dupont"], "note": "EN, STEP, DIR and GND: the streamer's axis 2"},
5784
+ {"id": "fr_kd_motor", "from": "fr_m2.connector", "to": "fr_board2.top", "via": ["fr_thigh.cable"], "gauge": "awg24", "colour": "black, red, green, blue", "connectors": ["JST-XH 4 pin", "screw terminal"]},
5785
+ {"id": "fr_kd_signal", "from": "fr_board2.centre", "to": "mega.S3", "gauge": "awg26", "conductors": 4, "colour": "white, yellow, green, black", "connectors": ["Dupont 4 pin", "Dupont"], "note": "EN, STEP, DIR and GND: the streamer's axis 3"},
5786
+ {"id": "bl_hd_motor", "from": "bl_m1.connector", "to": "bl_board1.top", "gauge": "awg24", "colour": "black, red, green, blue", "connectors": ["JST-XH 4 pin", "screw terminal"]},
5787
+ {"id": "bl_hd_signal", "from": "bl_board1.centre", "to": "mega.S4", "gauge": "awg26", "conductors": 4, "colour": "white, yellow, green, black", "connectors": ["Dupont 4 pin", "Dupont"], "note": "EN, STEP, DIR and GND: the streamer's axis 4"},
5788
+ {"id": "bl_kd_motor", "from": "bl_m2.connector", "to": "bl_board2.top", "via": ["bl_thigh.cable"], "gauge": "awg24", "colour": "black, red, green, blue", "connectors": ["JST-XH 4 pin", "screw terminal"]},
5789
+ {"id": "bl_kd_signal", "from": "bl_board2.centre", "to": "mega.S5", "gauge": "awg26", "conductors": 4, "colour": "white, yellow, green, black", "connectors": ["Dupont 4 pin", "Dupont"], "note": "EN, STEP, DIR and GND: the streamer's axis 5"},
5790
+ {"id": "br_hd_motor", "from": "br_m1.connector", "to": "br_board1.top", "gauge": "awg24", "colour": "black, red, green, blue", "connectors": ["JST-XH 4 pin", "screw terminal"]},
5791
+ {"id": "br_hd_signal", "from": "br_board1.centre", "to": "mega.S6", "gauge": "awg26", "conductors": 4, "colour": "white, yellow, green, black", "connectors": ["Dupont 4 pin", "Dupont"], "note": "EN, STEP, DIR and GND: the streamer's axis 6"},
5792
+ {"id": "br_kd_motor", "from": "br_m2.connector", "to": "br_board2.top", "via": ["br_thigh.cable"], "gauge": "awg24", "colour": "black, red, green, blue", "connectors": ["JST-XH 4 pin", "screw terminal"]},
5793
+ {"id": "br_kd_signal", "from": "br_board2.centre", "to": "mega.S7", "gauge": "awg26", "conductors": 4, "colour": "white, yellow, green, black", "connectors": ["Dupont 4 pin", "Dupont"], "note": "EN, STEP, DIR and GND: the streamer's axis 7"},
5794
+ {"id": "fl_board1_power", "from": "psu.terminals", "to": "fl_board1.bottom", "gauge": "awg22", "colour": "red, black", "conductors": 2, "current": 2, "connectors": ["Ring terminal", "Screw terminal"], "note": "12 V into the breakout's motor supply terminals (VMOT and GND), with its 100 uF capacitor across them"},
5795
+ {"id": "fl_board2_power", "from": "psu.terminals", "to": "fl_board2.bottom", "gauge": "awg22", "colour": "red, black", "conductors": 2, "current": 2, "connectors": ["Ring terminal", "Screw terminal"], "note": "12 V into the breakout's motor supply terminals (VMOT and GND), with its 100 uF capacitor across them"},
5796
+ {"id": "fr_board1_power", "from": "psu.terminals", "to": "fr_board1.bottom", "gauge": "awg22", "colour": "red, black", "conductors": 2, "current": 2, "connectors": ["Ring terminal", "Screw terminal"], "note": "12 V into the breakout's motor supply terminals (VMOT and GND), with its 100 uF capacitor across them"},
5797
+ {"id": "fr_board2_power", "from": "psu.terminals", "to": "fr_board2.bottom", "gauge": "awg22", "colour": "red, black", "conductors": 2, "current": 2, "connectors": ["Ring terminal", "Screw terminal"], "note": "12 V into the breakout's motor supply terminals (VMOT and GND), with its 100 uF capacitor across them"},
5798
+ {"id": "bl_board1_power", "from": "psu.terminals", "to": "bl_board1.bottom", "gauge": "awg22", "colour": "red, black", "conductors": 2, "current": 2, "connectors": ["Ring terminal", "Screw terminal"], "note": "12 V into the breakout's motor supply terminals (VMOT and GND), with its 100 uF capacitor across them"},
5799
+ {"id": "bl_board2_power", "from": "psu.terminals", "to": "bl_board2.bottom", "gauge": "awg22", "colour": "red, black", "conductors": 2, "current": 2, "connectors": ["Ring terminal", "Screw terminal"], "note": "12 V into the breakout's motor supply terminals (VMOT and GND), with its 100 uF capacitor across them"},
5800
+ {"id": "br_board1_power", "from": "psu.terminals", "to": "br_board1.bottom", "gauge": "awg22", "colour": "red, black", "conductors": 2, "current": 2, "connectors": ["Ring terminal", "Screw terminal"], "note": "12 V into the breakout's motor supply terminals (VMOT and GND), with its 100 uF capacitor across them"},
5801
+ {"id": "br_board2_power", "from": "psu.terminals", "to": "br_board2.bottom", "gauge": "awg22", "colour": "red, black", "conductors": 2, "current": 2, "connectors": ["Ring terminal", "Screw terminal"], "note": "12 V into the breakout's motor supply terminals (VMOT and GND), with its 100 uF capacitor across them"}
5802
+ ],
5757
5803
  "gait": {"legs": ["fl_shin.tip", "fr_shin.tip", "bl_shin.tip", "br_shin.tip"], "pattern": "trot", "stride": "leg.stride", "lift": "leg.lift", "period": 2, "height": "leg.stance", "mass": "leg.robot_mass", "clearance": 11},
5758
5804
  "poses": { "standing": {"fl_hd": -3171.4, "fl_kd": 2597, "fr_hd": -5587.7, "fr_kd": -2236, "bl_hd": -5587.7, "bl_kd": -2236, "br_hd": -3171.4, "br_kd": 2597} }
5759
5805
  }
@@ -5771,7 +5817,7 @@ The quadruped carries the leg's parts, every one, as items of a single assembly.
5771
5817
  {"id": "right", "object": "side", "at": [0, "0 - leg.body_w",0], "rotate": [90,0,180]},
5772
5818
  {"id": "beam1", "object": "beam", "at": ["left.beam_at",0,-6], "rotate": [0,0,90]},
5773
5819
  {"id": "beam2", "object": "beam", "at": ["0 - left.beam_at",0,-6], "rotate": [0,0,90]},
5774
- {"id": "fl_m1", "motor": {"model": "17HS4401", "drives": "fl_hd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8}},
5820
+ {"id": "fl_m1", "motor": {"model": "17HS4401", "drives": "fl_hd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8, "driver": "fl_d1"}},
5775
5821
  {"id": "fl_housing", "object": "housing", "at": ["leg.body_half", "leg.body_w",0], "rotate": [-90,0,0]},
5776
5822
  {"id": "fl_sun", "object": "sun"},
5777
5823
  {"id": "fl_carrier", "object": "speck"},
@@ -5783,7 +5829,7 @@ The quadruped carries the leg's parts, every one, as items of a single assembly.
5783
5829
  {"id": "fl_bridge", "object": "bridge"},
5784
5830
  {"id": "fl_b1", "bought": "bearing-6800"},
5785
5831
  {"id": "fl_thigh", "object": "thigh"},
5786
- {"id": "fl_m2", "motor": {"model": "17HS4401", "drives": "fl_kd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8}},
5832
+ {"id": "fl_m2", "motor": {"model": "17HS4401", "drives": "fl_kd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8, "driver": "fl_d2"}},
5787
5833
  {"id": "fl_esun", "object": "sun", "set": {"tip": 11.7}},
5788
5834
  {"id": "fl_ecarrier", "object": "speck"},
5789
5835
  {"id": "fl_ering", "object": "speck"},
@@ -5796,7 +5842,7 @@ The quadruped carries the leg's parts, every one, as items of a single assembly.
5796
5842
  {"id": "fl_clip3", "object": "clip"},
5797
5843
  {"id": "fl_shin", "object": "shin"},
5798
5844
  {"id": "fl_pad", "object": "pad"},
5799
- {"id": "fr_m1", "motor": {"model": "17HS4401", "drives": "fr_hd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8}},
5845
+ {"id": "fr_m1", "motor": {"model": "17HS4401", "drives": "fr_hd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8, "driver": "fr_d1"}},
5800
5846
  {"id": "fr_housing", "object": "housing", "at": ["leg.body_half", "0 - leg.body_w",0], "rotate": [-90,0,180]},
5801
5847
  {"id": "fr_sun", "object": "sun"},
5802
5848
  {"id": "fr_carrier", "object": "speck"},
@@ -5808,7 +5854,7 @@ The quadruped carries the leg's parts, every one, as items of a single assembly.
5808
5854
  {"id": "fr_bridge", "object": "bridge"},
5809
5855
  {"id": "fr_b1", "bought": "bearing-6800"},
5810
5856
  {"id": "fr_thigh", "object": "thigh"},
5811
- {"id": "fr_m2", "motor": {"model": "17HS4401", "drives": "fr_kd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8}},
5857
+ {"id": "fr_m2", "motor": {"model": "17HS4401", "drives": "fr_kd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8, "driver": "fr_d2"}},
5812
5858
  {"id": "fr_esun", "object": "sun", "set": {"tip": 11.7}},
5813
5859
  {"id": "fr_ecarrier", "object": "speck"},
5814
5860
  {"id": "fr_ering", "object": "speck"},
@@ -5821,7 +5867,7 @@ The quadruped carries the leg's parts, every one, as items of a single assembly.
5821
5867
  {"id": "fr_clip3", "object": "clip"},
5822
5868
  {"id": "fr_shin", "object": "shin"},
5823
5869
  {"id": "fr_pad", "object": "pad"},
5824
- {"id": "bl_m1", "motor": {"model": "17HS4401", "drives": "bl_hd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8}},
5870
+ {"id": "bl_m1", "motor": {"model": "17HS4401", "drives": "bl_hd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8, "driver": "bl_d1"}},
5825
5871
  {"id": "bl_housing", "object": "housing", "at": ["0 - leg.body_half", "leg.body_w",0], "rotate": [-90,0,0]},
5826
5872
  {"id": "bl_sun", "object": "sun"},
5827
5873
  {"id": "bl_carrier", "object": "speck"},
@@ -5833,7 +5879,7 @@ The quadruped carries the leg's parts, every one, as items of a single assembly.
5833
5879
  {"id": "bl_bridge", "object": "bridge"},
5834
5880
  {"id": "bl_b1", "bought": "bearing-6800"},
5835
5881
  {"id": "bl_thigh", "object": "thigh"},
5836
- {"id": "bl_m2", "motor": {"model": "17HS4401", "drives": "bl_kd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8}},
5882
+ {"id": "bl_m2", "motor": {"model": "17HS4401", "drives": "bl_kd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8, "driver": "bl_d2"}},
5837
5883
  {"id": "bl_esun", "object": "sun", "set": {"tip": 11.7}},
5838
5884
  {"id": "bl_ecarrier", "object": "speck"},
5839
5885
  {"id": "bl_ering", "object": "speck"},
@@ -5846,7 +5892,7 @@ The quadruped carries the leg's parts, every one, as items of a single assembly.
5846
5892
  {"id": "bl_clip3", "object": "clip"},
5847
5893
  {"id": "bl_shin", "object": "shin"},
5848
5894
  {"id": "bl_pad", "object": "pad"},
5849
- {"id": "br_m1", "motor": {"model": "17HS4401", "drives": "br_hd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8}},
5895
+ {"id": "br_m1", "motor": {"model": "17HS4401", "drives": "br_hd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8, "driver": "br_d1"}},
5850
5896
  {"id": "br_housing", "object": "housing", "at": ["0 - leg.body_half", "0 - leg.body_w",0], "rotate": [-90,0,180]},
5851
5897
  {"id": "br_sun", "object": "sun"},
5852
5898
  {"id": "br_carrier", "object": "speck"},
@@ -5858,7 +5904,7 @@ The quadruped carries the leg's parts, every one, as items of a single assembly.
5858
5904
  {"id": "br_bridge", "object": "bridge"},
5859
5905
  {"id": "br_b1", "bought": "bearing-6800"},
5860
5906
  {"id": "br_thigh", "object": "thigh"},
5861
- {"id": "br_m2", "motor": {"model": "17HS4401", "drives": "br_kd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8}},
5907
+ {"id": "br_m2", "motor": {"model": "17HS4401", "drives": "br_kd", "speed": 200, "duty": 0.3, "current": 1, "microsteps": 8, "driver": "br_d2"}},
5862
5908
  {"id": "br_esun", "object": "sun", "set": {"tip": 11.7}},
5863
5909
  {"id": "br_ecarrier", "object": "speck"},
5864
5910
  {"id": "br_ering", "object": "speck"},
@@ -5870,7 +5916,24 @@ The quadruped carries the leg's parts, every one, as items of a single assembly.
5870
5916
  {"id": "br_clip2", "object": "clip"},
5871
5917
  {"id": "br_clip3", "object": "clip"},
5872
5918
  {"id": "br_shin", "object": "shin"},
5873
- {"id": "br_pad", "object": "pad"}
5919
+ {"id": "br_pad", "object": "pad"},
5920
+ {"id": "mega", "bought": "arduino-mega-2560", "at": [0, 0, 20]},
5921
+ {"id": "fl_board1", "bought": "driver-breakout", "at": [69, 19.5, 48]},
5922
+ {"id": "fl_d1", "bought": "drv8825", "at": [69, 19.5, 58.1]},
5923
+ {"id": "fl_board2", "bought": "driver-breakout", "at": [23, 19.5, 48]},
5924
+ {"id": "fl_d2", "bought": "drv8825", "at": [23, 19.5, 58.1]},
5925
+ {"id": "fr_board1", "bought": "driver-breakout", "at": [69, -19.5, 48]},
5926
+ {"id": "fr_d1", "bought": "drv8825", "at": [69, -19.5, 58.1]},
5927
+ {"id": "fr_board2", "bought": "driver-breakout", "at": [23, -19.5, 48]},
5928
+ {"id": "fr_d2", "bought": "drv8825", "at": [23, -19.5, 58.1]},
5929
+ {"id": "bl_board1", "bought": "driver-breakout", "at": [-69, 19.5, 48]},
5930
+ {"id": "bl_d1", "bought": "drv8825", "at": [-69, 19.5, 58.1]},
5931
+ {"id": "bl_board2", "bought": "driver-breakout", "at": [-23, 19.5, 48]},
5932
+ {"id": "bl_d2", "bought": "drv8825", "at": [-23, 19.5, 58.1]},
5933
+ {"id": "br_board1", "bought": "driver-breakout", "at": [-69, -19.5, 48]},
5934
+ {"id": "br_d1", "bought": "drv8825", "at": [-69, -19.5, 58.1]},
5935
+ {"id": "br_board2", "bought": "driver-breakout", "at": [-23, -19.5, 48]},
5936
+ {"id": "br_d2", "bought": "drv8825", "at": [-23, -19.5, 58.1]}
5874
5937
  ],
5875
5938
  "joints": [
5876
5939
  {"id": "fl_m1_on", "type": "fixed", "parent": "fl_housing.motor", "child": "fl_m1.face"},
@@ -6060,6 +6123,24 @@ The quadruped carries the leg's parts, every one, as items of a single assembly.
6060
6123
  {"a": "br_ecarrier", "b": "br_ering", "min": -1},
6061
6124
  {"a": "br_pad", "b": "br_shin", "min": -2}
6062
6125
  ],
6126
+ "wires": [
6127
+ {"id": "fl_hd_motor", "from": "fl_m1.connector", "to": "fl_board1.top", "gauge": "awg24", "colour": "black, red, green, blue", "connectors": ["JST-XH 4 pin", "screw terminal"]},
6128
+ {"id": "fl_hd_signal", "from": "fl_board1.centre", "to": "mega.S0", "gauge": "awg26", "conductors": 4, "colour": "white, yellow, green, black", "connectors": ["Dupont 4 pin", "Dupont"], "note": "EN, STEP, DIR and GND: the streamer's axis 0"},
6129
+ {"id": "fl_kd_motor", "from": "fl_m2.connector", "to": "fl_board2.top", "via": ["fl_thigh.cable"], "gauge": "awg24", "colour": "black, red, green, blue", "connectors": ["JST-XH 4 pin", "screw terminal"]},
6130
+ {"id": "fl_kd_signal", "from": "fl_board2.centre", "to": "mega.S1", "gauge": "awg26", "conductors": 4, "colour": "white, yellow, green, black", "connectors": ["Dupont 4 pin", "Dupont"], "note": "EN, STEP, DIR and GND: the streamer's axis 1"},
6131
+ {"id": "fr_hd_motor", "from": "fr_m1.connector", "to": "fr_board1.top", "gauge": "awg24", "colour": "black, red, green, blue", "connectors": ["JST-XH 4 pin", "screw terminal"]},
6132
+ {"id": "fr_hd_signal", "from": "fr_board1.centre", "to": "mega.S2", "gauge": "awg26", "conductors": 4, "colour": "white, yellow, green, black", "connectors": ["Dupont 4 pin", "Dupont"], "note": "EN, STEP, DIR and GND: the streamer's axis 2"},
6133
+ {"id": "fr_kd_motor", "from": "fr_m2.connector", "to": "fr_board2.top", "via": ["fr_thigh.cable"], "gauge": "awg24", "colour": "black, red, green, blue", "connectors": ["JST-XH 4 pin", "screw terminal"]},
6134
+ {"id": "fr_kd_signal", "from": "fr_board2.centre", "to": "mega.S3", "gauge": "awg26", "conductors": 4, "colour": "white, yellow, green, black", "connectors": ["Dupont 4 pin", "Dupont"], "note": "EN, STEP, DIR and GND: the streamer's axis 3"},
6135
+ {"id": "bl_hd_motor", "from": "bl_m1.connector", "to": "bl_board1.top", "gauge": "awg24", "colour": "black, red, green, blue", "connectors": ["JST-XH 4 pin", "screw terminal"]},
6136
+ {"id": "bl_hd_signal", "from": "bl_board1.centre", "to": "mega.S4", "gauge": "awg26", "conductors": 4, "colour": "white, yellow, green, black", "connectors": ["Dupont 4 pin", "Dupont"], "note": "EN, STEP, DIR and GND: the streamer's axis 4"},
6137
+ {"id": "bl_kd_motor", "from": "bl_m2.connector", "to": "bl_board2.top", "via": ["bl_thigh.cable"], "gauge": "awg24", "colour": "black, red, green, blue", "connectors": ["JST-XH 4 pin", "screw terminal"]},
6138
+ {"id": "bl_kd_signal", "from": "bl_board2.centre", "to": "mega.S5", "gauge": "awg26", "conductors": 4, "colour": "white, yellow, green, black", "connectors": ["Dupont 4 pin", "Dupont"], "note": "EN, STEP, DIR and GND: the streamer's axis 5"},
6139
+ {"id": "br_hd_motor", "from": "br_m1.connector", "to": "br_board1.top", "gauge": "awg24", "colour": "black, red, green, blue", "connectors": ["JST-XH 4 pin", "screw terminal"]},
6140
+ {"id": "br_hd_signal", "from": "br_board1.centre", "to": "mega.S6", "gauge": "awg26", "conductors": 4, "colour": "white, yellow, green, black", "connectors": ["Dupont 4 pin", "Dupont"], "note": "EN, STEP, DIR and GND: the streamer's axis 6"},
6141
+ {"id": "br_kd_motor", "from": "br_m2.connector", "to": "br_board2.top", "via": ["br_thigh.cable"], "gauge": "awg24", "colour": "black, red, green, blue", "connectors": ["JST-XH 4 pin", "screw terminal"]},
6142
+ {"id": "br_kd_signal", "from": "br_board2.centre", "to": "mega.S7", "gauge": "awg26", "conductors": 4, "colour": "white, yellow, green, black", "connectors": ["Dupont 4 pin", "Dupont"], "note": "EN, STEP, DIR and GND: the streamer's axis 7"}
6143
+ ],
6063
6144
  "gait": {"legs": ["fl_shin.tip", "fr_shin.tip", "bl_shin.tip", "br_shin.tip"], "pattern": "crawl", "stride": "leg.stride", "lift": "leg.lift", "period": 4, "height": "leg.stance", "mass": "leg.robot_mass", "clearance": 11},
6064
6145
  "poses": { "standing": {"fl_hd": -3171.4, "fl_kd": 2597, "fr_hd": -5587.7, "fr_kd": -2236, "bl_hd": -5587.7, "bl_kd": -2236, "br_hd": -3171.4, "br_kd": 2597} }
6065
6146
  }
@@ -6091,7 +6172,7 @@ Said plainly, because a gait that passes these checks is not a robot that walks:
6091
6172
  - **Feedback.** The motors are open-loop steppers: a stall or a slip goes unnoticed. A real leg needs at least encoders at the joints and a way to feel the ground, and code that uses them.
6092
6173
  - **Measuring.** Nothing here has been printed. The stand exists to change that: run its leg, write what the scale reads into the ledger with `cad measured`, and start again from what it says.
6093
6174
 
6094
- `npm create rulecad --machine leg` starts a project from the leg and its stand. The step file for a gait, for a streamer grown to more axes, is not done yet, and neither is a measured leg.
6175
+ `npm create rulecad --machine leg` starts a project from the leg and its stand, with the streamer and its sender. The trot streams through the streamer on a simulated Mega 2560 in the kit's tests, every step counted; a measured leg is not done yet.
6095
6176
 
6096
6177
 
6097
6178
  ## 15. Fixings: a bracket screwed on
package/README.md CHANGED
@@ -1519,18 +1519,44 @@ with numbers as expressions like an object's (schema: `schemas/problem.schema.js
1519
1519
  it, as an assembly reads it). The problem then follows the design: move the plate's
1520
1520
  pivot and the support, the boss round it and the result move with it. A design built from this problem can't be
1521
1521
  named (it would need the result to be built): name the part it is fixed to.
1522
+ - **In an assembly:** `"in": { "assembly": "bench", "item": "plate" }` places the problem in an assembly of the
1523
+ project. Its coordinates are then the item's own, as that item's design draws the result, and two more kinds of
1524
+ region open up:
1525
+ - `"joint": "hinge"` in place of `at`, on any region, support or load: where the joint is, read the way an anchor
1526
+ is. When the item is one end of the joint, it is the item's own anchor for it, the same in every pose; otherwise
1527
+ it is where the joint's parent anchor stands in the pose.
1528
+ - `{ "sweep": "gate", "through": "swing" }` under `avoid`: an item (or `item.part`) moved through a joint's range,
1529
+ the other joints held at the pose, kept clear at every step. By default there are enough steps that no point of
1530
+ the part moves more than half a cell between two; `"steps"` sets them. A flat problem keeps clear of all of the
1531
+ part that lies within the plate's thickness about its middle plane (`in.z`, by default half the thickness, a plate
1532
+ drawn up from z 0): an arm dipping 1 mm into the plate's top is kept clear as surely as one through it. Its
1533
+ sections are taken up the plate no more than half a cell apart, and closer where a face leans, so together they
1534
+ cover it to half a cell; each distinct one is a region. A part passing over or under the plate, or only touching
1535
+ its face, is no obstacle; holes in a section stay open, and the design cuts each exactly.
1536
+ The assembly is read in its pose (`in.pose`, default the one it shows). While it is read, the item itself, and any
1537
+ other built from this problem, is drawn without a result (its problem variables set to `none`), so its design must
1538
+ draw something for `none`: a blank of the space will do. Change the assembly (a joint's range, a part's size) and
1539
+ the problem follows it, so the result is optimised again. `cad check <project>/<assembly> --sweep` then shows the
1540
+ part built from the result is clear through the swing. Refused by name: a sweep outside `avoid`, a sweep of the
1541
+ item itself, a joint that doesn't move the part against the item, a part that never reaches into a flat plate's thickness,
1542
+ and more than 360 default steps (give `steps`, or larger cells).
1522
1543
  - **Or a stress limit instead of a volume:** `"stress": "pla.strength / 3"` (MPa) finds the lightest layout that keeps
1523
1544
  every cell's von Mises stress under it, which rounds off the sharp inside corners where cracks start. It takes about
1524
1545
  a thousand steps, each with two solves, so it's slower: give it a coarse cell first. Give supports and loads some
1525
1546
  area (a hole's edge, a pad), as stress where a load meets a point has no limit. `cad optimise` reports the peak
1526
1547
  stress against the limit. Check the final part with an `analysis` on a finer `cell`: a sharp corner that's
1527
1548
  within the limit on the optimiser's cells can still be over it on finer ones.
1549
+ - **Robust:** `"robust": true` optimises the design as made, a little thin and a little thick (eroded and dilated
1550
+ copies) together. With a stress or strain limit, the lightest layout that keeps it on all three; a mechanism, the
1551
+ layout whose worst copy moves its output furthest, and with a limit, optimised under it. `cad optimise` prints
1552
+ the copies' peaks (and a mechanism's copies' travels). About three times the solves. A sharp inside corner of the
1553
+ space still stays sharp; topopt's README has the figures.
1528
1554
  - **Variants**, picked as `name:variant`, set variables that have a tweak range, as an object's do.
1529
1555
 
1530
1556
  `cad optimise <project>/<problem>` runs it, reports how far each load case moves its load and the stiffness that
1531
1557
  gives, and draws the layout in `.preview/`. The result is kept, keyed by everything it's made from, so it's only
1532
1558
  worked out again when something it depends on changes. `cad why <project>/<object>.<problem variable>` names what
1533
- that is: the problem file, its rule sets and values, the parts and anchors it reads, where its filter came from, and
1559
+ that is: the problem file, its rule sets and values, the parts and anchors it reads (and the assembly, joints and sweeps), where its filter came from, and
1534
1560
  the file the result is kept in.
1535
1561
 
1536
1562
  A 3D result with a build direction is made printable before it's drawn: built up layer by layer from the bed, every
@@ -1591,12 +1617,28 @@ A part made another way says so in place of `overhang` (one process to a problem
1591
1617
  - **Milled:** `"mill": "+z"` (the tool cuts down from above). No undercuts: a cell is as solid as every cell
1592
1618
  between it and the tool. `cad optimise` says `milled from +z: no undercuts`, or counts the cells an avoid region
1593
1619
  or the space's own edge hides behind material. The `mill-3axis` rule set holds the walls, corners and pockets a 3-axis machine manages.
1620
+ `"tool": 2` is the end mill's radius (mm, at least a cell): no pocket narrower, every inside corner rounded to it,
1621
+ and `cad optimise` counts any cells still too narrow, in the design or in avoid regions (drill those holes). A flat
1622
+ (2D) problem milled from `+z` with a tool is a plate's profile cut through by an end mill. `"mill": ["+z", "-z"]`
1623
+ mills from several sides, a setup each: a cell stays only where no side's tool reaches it. `"mill"` can also name a
1624
+ variable holding `"+z"`, `"+z -z"` or `"none"`, so a variant switches it: the bench's `bench/lever:milled` is the
1625
+ lever cut from a 6 mm plate by a 4 mm end mill.
1594
1626
  - **Cast or moulded:** `"cast": "+z"` for a mould drawn off one way, or `"cast": { "draw": "z", "parting": 6 }` for
1595
- two halves drawn off both ways from a parting plane (mm along the axis; the space's middle when left out). Draft
1596
- (`mould-injection`: a degree or so) is less than a cell, so it is left to the drawing.
1627
+ two halves drawn off both ways from a parting plane (mm along the axis; the space's middle when left out). `"draft": 15`
1628
+ (degrees) narrows the part towards the side it is drawn off: a wall steps a cell out every whole number of layers
1629
+ in 1 / tan(draft), so at least the draft, and `cad optimise` says the angle made (15° is a step every 3
1630
+ layers, 18.43°). A draft too shallow for the grid (3° needs 19 layers) is refused by name: draw it on the finished
1631
+ part instead (`mould-injection`: a degree or so).
1597
1632
  - **Printed in a metal powder bed:** `"overhang": "+z"` with `"voids": "refused"`. Powder left in an enclosed void
1598
1633
  can't be got out, so `cad optimise` fails with each void's volume and centre: open it with an avoid region (an
1599
1634
  escape hole, `dmls.escape_hole` wide) or allow voids. The `dmls` rule set holds the process's limits.
1635
+ `"voids": "prevented"` keeps every pocket open as the part is optimised (a virtual temperature, kept under a cap:
1636
+ an enclosed void runs hot); any a keep region walls in are still errors.
1637
+
1638
+ Any problem can give `"feature"`, the thinnest member it makes, mm: for a printed part `"x1c.wall_min"`, the
1639
+ printer's two lines (0.84 mm). Where a cell is as wide, every member already is, and `cad optimise` says the grid
1640
+ holds it; up to three cells across, members narrower go as it optimises; wider is refused with the cells that would
1641
+ hold it.
1600
1642
 
1601
1643
  Any of them can also be `"symmetry": { "mirror": "y" }` (mirrored across the grid's middle planes; `"turns": 2` or
1602
1644
  `4` about `"axis"` for half or quarter turns) or `"extrude": "x"` (one section all along x, a part cut from a bar).
@@ -1777,7 +1819,7 @@ module and read `pip`'s variables) and name them in the assembly's `"printInPlac
1777
1819
  together, so the assembly order never takes them apart from each other. `cad order` fits them as one step and
1778
1820
  `cad list` gives them one printed row, the one print's grams and minutes.
1779
1821
 
1780
- An assembly with a `gait` (EXAMPLES chapter 14) plays too: `cad animate <project>/<assembly>` writes the cycle as an animated SVG in `.preview/` (a side view of the legs and a plan of the feet and what they stand on) and its data as JSON. The model page plays the same cycle in its Motion panel. `cad machine <project>/<assembly>` on such an assembly describes it as a legged machine, an axis for each motor's shaft in the order the shield's slots are wired, and `cad plot <project>/<assembly>` with no drawing writes the gait as a step file for the streamer: `--cycles` of it (3) from a pose (`--pose`, by default the one shown) and back, every axis in each block, slowed where a motor cannot keep to the gait's period (`--period` to set it) and where a joint turns back, with a picture of each axis through the run in `.preview/`. A motor wired to a shield slot out of the streamer's order (X, Y, Z) fails by name.
1822
+ An assembly with a `gait` (EXAMPLES chapter 14) plays too: `cad animate <project>/<assembly>` writes the cycle as an animated SVG in `.preview/` (a side view of the legs and a plan of the feet and what they stand on) and its data as JSON. The model page plays the same cycle in its Motion panel. `cad machine <project>/<assembly>` on such an assembly describes it as a legged machine, an axis for each motor's shaft in the order its controller's slots are wired, and `cad plot <project>/<assembly>` with no drawing writes the gait as a step file for the streamer: `--cycles` of it (3) from a pose (`--pose`, by default the one shown) and back, every axis in each block, slowed where a motor cannot keep to the gait's period (`--period` to set it) and where a joint turns back, with a picture of each axis through the run in `.preview/`. A motor wired to a slot out of the streamer's order (X, Y, Z on a CNC shield; S0 to S7 on a Mega 2560) fails by name. The machine's `controller` is the bought board the streamer runs on: a `cnc-shield-v3` (an Uno, three axes, and the default) or an `arduino-mega-2560` (eight axes, the quadruped's). A motor on a driver of its own reaches its slot through its wire to the driver's breakout and the breakout's signal wire on to the Mega.
1781
1823
 
1782
1824
  An assembly with a motor, or with gears that follow a joint, plays its drive: `cad animate <project>/<assembly>` writes `<assembly>-drive.svg`, the gears cut across their shafts through their teeth (up to three cuts side by side, a compound planetary's two rings each in its own), each part turning and moving as it does, the part with the load picked out. It turns the drive until the slowest part has moved about 60° (one to six turns; `--turns n` to choose). Each part's outline is drawn once and moved, so a gearbox stays a few hundred kilobytes.
1783
1825
 
package/bin/cad.mjs CHANGED
@@ -263,7 +263,7 @@ async function optimiseProblem(ref, { preview: previewing = false } = {}) {
263
263
  const lines = [`${p.material.name}${r.dim === 2 ? `, ${fmt(r.thickness)} mm thick` : ''}: ${r.cases.map((c) => c.moment ? `${c.name} ${sig(c.angle * 180 / Math.PI)}° (${sig(c.torsion / 1000 * Math.PI / 180)} N·m/°)` : `${c.name} ${sig(c.deflection)} mm (${sig(c.stiffness)} N/mm)`).join(', ')}`,
264
264
  `${fmt(r.volume * 100)}% of the space, ${cells} cells of ${fmt(r.grid.h)} mm, ${r.steps} steps${r.converged ? '' : ' (stopped: not settled)'}${r.overhang ? `, printable built ${r.overhang}` : ''}${r.stress ? `, peak stress ${sig(r.stress.peak)} MPa (limit ${sig(r.stress.limit)})` : ''}${r.dropped ? `; ${r.dropped.length} loose ${r.dropped.length === 1 ? 'piece' : 'pieces'} dropped (${sig(r.dropped.reduce((t, v) => t + v, 0))} mm³)` : ''}${r.emptied ? `; ${r.emptied} ${r.emptied === 1 ? 'cell' : 'cells'} that wouldn't print emptied` : ''}${r.cleared ? `; sliced as the printer will, ${r.cleared} ${r.cleared === 1 ? 'cell' : 'cells'} under islands emptied` : ''}`,
265
265
  ...(r.unsupported > 0.01 ? [`${fmt(r.unsupported * 100)}% of the kept regions has nothing holding it up (at ${r.overhang ? 'the printer\'s overhang limit' : '45°'} or less): give the part more material to stand them on, or keep less`] : []),
266
- ...(r.process ? [processLine(r)] : []), ...(r.voids?.length ? [voidsLine(r)] : [])];
266
+ ...(r.process ? [processLine(r)] : []), ...(r.feature ? [featureLine(r)] : []), ...(r.voids?.length ? [voidsLine(r)] : [])];
267
267
  let out;
268
268
  if (r.dim === 3) {
269
269
  out = paths.preview(project, `${name.replace(':', '-')}-optimised.png`);
@@ -286,22 +286,36 @@ async function optimiseProblem(ref, { preview: previewing = false } = {}) {
286
286
  if (r.mechanism) console.log(` the output moves ${sig(r.mechanism.travel)} mm its way for ${sig(r.mechanism.input)} mm of push: an advantage of ${sig(r.mechanism.advantage)}`);
287
287
  if (r.stress && r.mechanism) console.log(` peak stress ${sig(r.stress.peak)} MPa at its input force${r.stress.strain != null ? ` (strain ${sig(r.stress.strain * 100)}%)` : ''}, the limit ${sig(r.stress.limit)} MPa${r.stress.strainLimit != null ? ` (${sig(r.stress.strainLimit * 100)}%)` : ''}: it reaches the limit at ${sig(r.stress.force)} N of push, its output then ${sig(r.stress.travel)} mm along`);
288
288
  else if (r.stress) console.log(` peak stress ${sig(r.stress.peak)} MPa, the limit ${sig(r.stress.limit)} MPa${r.stress.peak > r.stress.limit * 1.02 ? ': over it (raise the volume, ease the limit, or use a smaller cell)' : ''}`);
289
+ if (r.stress?.copies) console.log(` made a little thin, peak stress ${sig(r.stress.copies.eroded)} MPa; a little thick, ${sig(r.stress.copies.dilated)} MPa${Math.max(r.stress.copies.eroded, r.stress.copies.dilated) > r.stress.limit * 1.02 ? ` (over the limit: ${p.problem?.robust ? 'a smaller cell or a looser limit' : 'give the problem robust: true'})` : ''}`);
290
+ if (r.mechanism?.copies) console.log(` made a little thin, its output moves ${sig(r.mechanism.copies.eroded)} mm; a little thick, ${sig(r.mechanism.copies.dilated)} mm`);
289
291
  if (r.dim === 3) console.log(` ${fmt(r.volume * 100)}% of the space filled: ${fmt(r.solid / 1000)} cm³ (${fmt(r.solid / 1000 * (p.material.density || 0))} g of ${p.material.name})${r.overhang ? `, printable built ${r.overhang}` : ''}`);
290
292
  else console.log(` ${fmt(r.volume * 100)}% of the space filled, outline ${fmt(r.area)} mm² (${fmt(r.area * r.thickness / 1000)} cm³ before bosses and holes are made exact)`);
291
293
  if (r.reduced) console.log(` ${r.reduced.before} triangles reduced to ${r.reduced.after} (${fmt(r.reduced.after / r.reduced.before * 100)}%), the surface kept within ${fmt(r.reduced.tolerance)} mm`);
292
294
  console.log(` ${cells} cells of ${fmt(r.grid.h)} mm, ${r.steps} steps${r.converged ? ', settled' : ': stopped before it settled (raise steps)'}`);
293
295
  if (r.process) console.log(` ${processLine(r)}`);
294
296
  if (r.symmetry || r.extrude) console.log(` ${[r.symmetry?.mirror ? `mirrored across ${[...r.symmetry.mirror].join(' and ')}` : '', r.symmetry?.turns ? `the same each ${r.symmetry.turns === 4 ? 'quarter' : 'half'} turn about ${r.symmetry.axis || 'z'}` : '', r.extrude ? `one section along ${r.extrude}` : ''].filter(Boolean).join(', ')}`);
297
+ if (r.feature) console.log(` ${r.feature.thin ? 'warning: ' : ''}${featureLine(r)}`);
295
298
  if (r.grey > 0.1) console.log(` warning: ${greyLine(r)}`);
296
- if (r.voids?.length) { console.log(` error: ${voidsLine(r)}`); process.exitCode = 1; }
299
+ if (r.voids?.length) { console.log(` error: ${voidsLine(r)}`); process.exitCode = 1; } else if (r.vented) console.log(' voids prevented: none enclosed, every empty pocket open to the outside');
297
300
  console.log(out);
298
301
  if (previewing) console.log(`${run}\n ${recorded ? `the run, step by step: open it to watch it again (${r.steps} steps)` : 'the run\'s end only: its steps weren\'t recorded (cad preview --fresh runs it again and records them)'}`);
299
302
  }
300
303
  // How a milled or cast result is made, and its undercuts (none, unless an avoid region or the space's own shape sits
301
304
  // behind material: the optimiser keeps every cell as solid as those on its way out, but can't fill a cell it mustn't)
302
305
  function processLine(r) {
303
- const how = r.process.mill ? `milled from ${r.process.mill}` : typeof r.process.cast === 'string' ? `cast, drawn off ${r.process.cast}` : `cast in two halves drawn off along ${r.process.cast.draw} from ${fmt(r.process.cast.parting)} mm`;
304
- return r.undercuts ? `${how}: ${r.undercuts} ${r.undercuts === 1 ? 'cell is' : 'cells are'} undercut (an avoid region, or the edge of the space, with material between it and the ${r.process.mill ? 'tool' : 'draw'}: move it, or make it from that side)` : `${how}: no undercuts`;
306
+ const p = r.process, sides = [p.mill].flat(), tool = p.tool ? ` by a tool of ${fmt(p.tool)} mm radius` : '';
307
+ const draft = p.draft ? ` with a ${fmt(p.draft)}° draft (a step out every ${p.every} layers: ${fmt(p.made)}°)` : '';
308
+ const how = p.mill ? `milled from ${sides.length > 1 ? `${sides.slice(0, -1).join(', ')} and ${sides.at(-1)}` : sides[0]}${tool}` : typeof p.cast === 'string' ? `cast, drawn off ${p.cast}${draft}` : `cast in two halves drawn off along ${p.cast.draw} from ${fmt(p.cast.parting)} mm${draft}`;
309
+ const n = r.narrow, narrow = !n ? '' : [n.design ? `${n.design} ${n.design === 1 ? 'cell' : 'cells'} of the design too narrow for the tool` : '', n.avoided ? `${n.avoided} ${n.avoided === 1 ? 'cell' : 'cells'} of avoid regions narrower than the tool: drill those holes, or give a smaller tool` : ''].filter(Boolean).join('; ');
310
+ const tail = narrow ? `; ${narrow}` : n ? ', and nothing narrower than the tool' : '';
311
+ return r.undercuts ? `${how}: ${r.undercuts} ${r.undercuts === 1 ? 'cell is' : 'cells are'} undercut (an avoid region, or the edge of the space, with material between it and the ${p.mill ? 'tool' : 'draw'}: move it, or make it from that side)${tail}` : `${how}: no undercuts${tail}`;
312
+ }
313
+ // The thinnest member asked (a printer's two lines): met by the grid itself, or held to three cells, with any cells left
314
+ // in members narrower
315
+ function featureLine(r) {
316
+ const f = r.feature, h = f.holds / (2 * f.cells + 1);
317
+ if (!f.cells) return `thinnest member ${fmt(f.asked)} mm: every member is at least a cell (${fmt(h)} mm), so the grid holds it`;
318
+ return `thinnest member ${fmt(f.asked)} mm: held to three cells (${fmt(f.holds)} mm)${f.thin ? `, and ${f.thin} solid ${f.thin === 1 ? 'cell is' : 'cells are'} still in a narrower member or a square outside corner: give a bigger filter radius` : ', none narrower'}`;
305
319
  }
306
320
  // A grey result (warned of above a tenth): its design cells between a tenth and nine tenths solid. A clear design has
307
321
  // a few per cent, on its surfaces (the 3D cantilever milled from above 5.3%, free 2D cantilevers 1 to 3%): a tenth
@@ -311,7 +325,7 @@ function greyLine(r) {
311
325
  }
312
326
  // Enclosed voids, refused by the problem (powder that can't get out, a trapped core)
313
327
  function voidsLine(r) {
314
- return `${r.voids.length} enclosed ${r.voids.length === 1 ? 'void' : 'voids'} (${r.voids.map((v) => `${sig(v.volume)} ${r.dim === 3 ? 'mm³' : 'mm²'} at ${v.at.map(fmt).join(', ')}`).join('; ')}): powder or a core can't get out: open ${r.voids.length === 1 ? 'it' : 'each'} to the outside with an avoid region (an escape hole), or allow voids`;
328
+ return `${r.voids.length} enclosed ${r.voids.length === 1 ? 'void' : 'voids'} (${r.voids.map((v) => `${sig(v.volume)} ${r.dim === 3 ? 'mm³' : 'mm²'} at ${v.at.map(fmt).join(', ')}`).join('; ')})${r.vented ? ', left though voids were prevented (a keep region or the space walls it in)' : ''}: powder or a core can't get out: open ${r.voids.length === 1 ? 'it' : 'each'} to the outside with an avoid region (an escape hole), or allow voids`;
315
329
  }
316
330
 
317
331
  // An object's analyses for cad check: each problem's load cases on the part, and its volume against a target
@@ -786,6 +800,7 @@ async function explainValue(ref) {
786
800
  console.log(`${pad} rule sets: ${q.uses.join(', ')}`);
787
801
  if (vals.length) console.log(`${pad} its values: ${vals.map(([k, v]) => `${k} = ${typeof v === 'number' ? fmt(v) : v}`).join(', ')}`);
788
802
  if (q.parts.length) console.log(`${pad} parts read: ${q.parts.join(', ')}`);
803
+ if (q.assembly) { const A = q.assembly, bits = [...(A.joints.length ? [`joints read: ${A.joints.map((j) => `${j.joint} at (${j.at.map(fmt).join(', ')})`).join(', ')}`] : []), ...(A.sweeps.length ? [`swept: ${A.sweeps.map((w) => `${w.sweep} through ${w.through}, ${fmt(w.from)} to ${fmt(w.to)} in ${w.steps} steps`).join(', ')}`] : [])]; console.log(`${pad} in the assembly ${A.name}, item ${A.item}${A.pose ? `, pose ${A.pose}` : ''}${bits.length ? `: ${bits.join('; ')}` : ''}`); }
789
804
  if (q.anchors.length) console.log(`${pad} anchors read: ${q.anchors.map((a) => `${a.anchor} at (${a.at.map(fmt).join(', ')})`).join(', ')}`);
790
805
  console.log(`${pad} filter ${fmt(q.filter.value)} mm: ${q.filter.from}`);
791
806
  console.log(`${pad} ${q.made ? `kept in ${q.densities}` : `not made yet (cad optimise ${n.object.split('/')[0]}/${q.problem}); it will be kept in ${q.densities}`}: made again only when one of these, or the solver, changes`);