create-rulecad 0.3.23 → 0.3.25
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/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,12 @@ print (a hole's diameter, a seat's depth, a part's outline). Each release lists
|
|
|
5
5
|
it makes, with its reason. A **fasten** is an entry in an assembly's `"fasten"` list: one screwed joint, naming the
|
|
6
6
|
screw by thread and head, the parts it passes through and the part it ends in.
|
|
7
7
|
|
|
8
|
+
## 0.3.25: the arm's sender says what a gait file is (#199)
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- The arm's `send.mjs` names a gait's cycles, time and start pose in its dry run's summary, and before it sends one it
|
|
12
|
+
says the leg must stand in that pose. `STREAMER.md` explains how a leg's stand runs on the same streamer.
|
|
13
|
+
|
|
8
14
|
## 0.3.23: the leg on a 17HS4401 knee and 12 V
|
|
9
15
|
|
|
10
16
|
### Changed
|
|
@@ -24,6 +24,33 @@ hardware is your test: the arm's measured milestone.
|
|
|
24
24
|
3. Dry run, with no board: `node projects/arm/send.mjs exports/arm/arm-test.steps.json --machine exports/arm/arm.machine.json --dry-run`. It prints each line it would send with the answer the streamer would give, then a summary. `--quiet` prints the summary only. A dry run has no clock, so it takes each block as finished before the next line: its answer to `?` is the positions summed from the blocks so far, with 0 blocks queued.
|
|
25
25
|
4. Draw: `node projects/arm/send.mjs exports/arm/arm-test.steps.json --machine exports/arm/arm.machine.json --port <port>`. It turns the drivers on, homes each axis, sends the file, reports every hundredth line, and turns the drivers off. `--no-home` skips homing.
|
|
26
26
|
|
|
27
|
+
## A leg on the same streamer
|
|
28
|
+
|
|
29
|
+
The streamer knows only axes and steps, so a leg runs on it as the arm does. The leg's stand (`projects/leg`, with the
|
|
30
|
+
hip's motor on the shield's X slot and the knee's on Y) takes the same sketch, the same drivers and the same sender:
|
|
31
|
+
|
|
32
|
+
1. Flash `firmware/arm/arm.ino` to the stand's Uno, as in step 1 above.
|
|
33
|
+
2. Write the machine and the gait's step file: `npx cad machine leg/stand` writes `exports/leg/stand.machine.json`, and
|
|
34
|
+
`npx cad plot leg/stand` writes `exports/leg/stand-gait.steps.json`: three cycles of the gait, from the pose the
|
|
35
|
+
assembly shows (`standing`) and back to it. `--cycles 5` plays five, `--pose <name>` starts and ends at another pose,
|
|
36
|
+
and `--period 4` plays a cycle in 4 s. `.preview/leg/stand-gait.svg` draws each axis through the run.
|
|
37
|
+
3. Dry run: `node projects/arm/send.mjs exports/leg/stand-gait.steps.json --machine exports/leg/stand.machine.json --dry-run`.
|
|
38
|
+
4. Stand the leg in its pose, then send the file with `--port <port>`. The stand has no home switches, so the streamer
|
|
39
|
+
counts from where the motors are when it starts: the file's first block takes the leg from its pose to the cycle, and
|
|
40
|
+
its last brings it back. At the end the drivers go off and the carriage settles on its stop collars.
|
|
41
|
+
|
|
42
|
+
How the gait becomes blocks:
|
|
43
|
+
|
|
44
|
+
| | |
|
|
45
|
+
|---|---|
|
|
46
|
+
| **A block** | The move from one frame of the gait (48 a cycle) to the next, every axis in it, at the rate that keeps to the gait's period |
|
|
47
|
+
| **Too fast for a motor** | A block that would step an axis past its `maxRate` (the motor's working speed, from `cad machine`) is slowed to it, and the cycle takes longer. `cad plot` says by how much, with a warning when a cycle takes over 5% longer than the gait's period. The stand's gait asks the knee for 11712 steps/s at its 2 s period, past the 5333 of a 17HS4401 at 200 rpm and 1/8 steps, so a cycle takes 2.89 s on the motors |
|
|
48
|
+
| **A joint turning back** | Where a foot lifts off or sets down, a joint reverses. The run slows there so that no axis changes speed by more than its jump at once: an eighth of its `maxRate`, the rate `cad machine` homes it at from rest. It speeds up and slows down at no more than 4 × `maxRate` steps/s², full speed in 0.25 s. Both are estimates: no motor's start-stop rate under load has been measured yet |
|
|
49
|
+
| **From the pose and back** | A move from rest to rest at half the axes' fastest |
|
|
50
|
+
|
|
51
|
+
The streamer has three axes, and the sender refuses a file with more before anything moves: the quadruped's eight
|
|
52
|
+
motors need more than one Uno under one shield. `cad plot` still writes its step file, and says so.
|
|
53
|
+
|
|
27
54
|
## The line protocol
|
|
28
55
|
|
|
29
56
|
115200 baud, 8 data bits, no parity, 1 stop bit. One command a line, ended by a newline. The streamer answers every
|
|
@@ -94,7 +121,8 @@ board has not yet been timed: your bench test does that, and the USB turnaround
|
|
|
94
121
|
|
|
95
122
|
`node scripts/firmware.mjs` (in the kit's repository) compiles every sketch for `arduino:avr:uno` and fails on a compile
|
|
96
123
|
error. With `--simulate <steps file> --machine <machine file>` it also runs this streamer on a simulated Uno, and fails
|
|
97
|
-
when any of these does not hold:
|
|
124
|
+
when any of these does not hold. The two flags can be given again for another step file: the kit's tests stream the arm's
|
|
125
|
+
drawing and then the leg's gait, each with its own machine, and measure the loop's own ceilings once.
|
|
98
126
|
|
|
99
127
|
| Check | Held to |
|
|
100
128
|
|---|---|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Sends a step file (rulecad.steps/1, from cad plot) to the
|
|
2
|
+
// Sends a step file (rulecad.steps/1, from cad plot: an arm's drawing or a leg's gait) to the Uno, line by line, each after
|
|
3
|
+
// the last was answered.
|
|
3
4
|
// node send.mjs <file.steps.json> --port /dev/tty.usbmodem101 [--machine arm.machine.json] [--no-home]
|
|
4
5
|
// node send.mjs <file.steps.json> --dry-run [--machine arm.machine.json] [--quiet]
|
|
5
6
|
// echoes each line it would send with the answer the streamer would give,
|
|
@@ -94,6 +95,9 @@ export function dryRun(lines, { machine, turnaround = TURNAROUND } = {}) {
|
|
|
94
95
|
return { lines: lines.length, ...seen, peakRate: peak, axisPeaks, position, said };
|
|
95
96
|
}
|
|
96
97
|
|
|
98
|
+
/** What a gait's step file is, for the summary: its cycles, time and start pose (nothing for a drawing). @param {object} file */
|
|
99
|
+
export const gait = (file) => (file?.kind === 'gait' ? `, ${file.cycles} cycle${file.cycles === 1 ? '' : 's'} of a gait, ${Number(file.time).toFixed(1)} s${file.pose ? ` from the pose "${file.pose}" and back` : ''}` : '');
|
|
100
|
+
|
|
97
101
|
async function send(port, lines, say) {
|
|
98
102
|
const r = spawnSync('stty', [process.platform === 'darwin' ? '-f' : '-F', port, '115200', 'raw', '-echo', '-hupcl'], { encoding: 'utf8' });
|
|
99
103
|
if (r.status) throw new Error(`stty ${port}: ${r.stderr}`);
|
|
@@ -120,9 +124,11 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
|
120
124
|
try { r = dryRun(lines, { machine }); } catch (e) { console.error(`${has('dry-run') ? 'dry run' : 'not sent'}: ${e.message}`); process.exit(1); }
|
|
121
125
|
if (has('dry-run')) {
|
|
122
126
|
if (!has('quiet')) for (const s of r.said) console.log(s);
|
|
123
|
-
console.log(`dry run: ${r.lines} lines, ${r.m} blocks, ${r.p} pen moves, ${r.h} homes, peak ${r.peakRate} steps/s (the streamer takes ${MAX_RATE})${machine ? `, axes at most ${r.axisPeaks.slice(0, machine.axes.length).map((x, k) => `${Math.round(x)} of ${machine.axes[k].maxRate}`).join(', ')} steps/s` : ''}`);
|
|
127
|
+
console.log(`dry run: ${r.lines} lines, ${r.m} blocks, ${r.p} pen moves, ${r.h} homes, peak ${r.peakRate} steps/s (the streamer takes ${MAX_RATE})${machine ? `, axes at most ${r.axisPeaks.slice(0, machine.axes.length).map((x, k) => `${Math.round(x)} of ${machine.axes[k].maxRate}`).join(', ')} steps/s` : ''}${gait(file)}`);
|
|
124
128
|
process.exit(0);
|
|
125
129
|
}
|
|
126
130
|
if (!opt('port')) { console.error('--port <device>, or --dry-run'); process.exit(2); }
|
|
131
|
+
// a gait has no home: the streamer counts from where the motors stand when it starts, so the leg must be in its pose
|
|
132
|
+
if (file.kind === 'gait') console.log(`a gait${gait(file)}: the streamer counts from where the motors stand now, so the leg must be in ${file.pose ? `its pose "${file.pose}"` : "the cycle's first frame"}`);
|
|
127
133
|
send(opt('port'), lines, console.log).then(() => console.log('done')).catch((e) => { console.error(e.message); process.exit(1); });
|
|
128
134
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-rulecad",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.25",
|
|
4
4
|
"description": "Start a rulecad project: npm create rulecad my-designs. A workspace with a soap tray to start from, ready to check, preview, export and share.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|