Public: anyone can read this; the crew can change it.
Migrated from github.com/Trevato/SO-ARM100
workbenchthis machine
jam-stream.test.ts judges 'jams within 500 ms' on the readings' own clock, not the test machine's wall clock, so a loaded full run no longer fails it #556
Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.
smith/arm:smith/555-jam-stream-test-ts-judges-jams-within-50 → main 1 commit fork 1 thread · 1 unresolved
1 file
changed +6
−3
Software/so101/src/jam-stream.test.ts +6 −3
| @@ -5,6 +5,7 @@ import { join } from "node:path"; | ||
| 5 | 5 | import WebSocket from "ws"; |
| 6 | 6 | import { FeetechBus } from "./bus.ts"; |
| 7 | 7 | import { FakeBus } from "./fake-bus.ts"; |
| 8 | import { JAM_WINDOW_MS } from "./jam-watch.ts"; | |
| 8 | 9 | import { startServer, type RunningServer } from "./server.ts"; |
| 9 | 10 | |
| 10 | 11 | // The jam watch on the stream, against servos that move like the real ones (FakeBus dynamics: 70 % load while |
| @@ -58,11 +59,13 @@ describe("a jam is load without progress", () => { | ||
| 58 | 59 | const asked = performance.now(); |
| 59 | 60 | const push = setInterval(() => ws.send(JSON.stringify({ 1: START + 300, 2: START + 300 })), 20); |
| 60 | 61 | let s = await get<Status>("/status"); |
| 61 | while (!s.jammed.length && performance.now() - asked < 1500) s = await get<Status>((await sleep(10), "/status")); | |
| 62 | const took = performance.now() - asked; | |
| 62 | while (!s.jammed.length && performance.now() - asked < 3000) s = await get<Status>((await sleep(10), "/status")); // a deadline for the loop only | |
| 63 | 63 | clearInterval(push); |
| 64 | 64 | expect(s.jammed).toEqual([2]); |
| 65 | expect(took).toBeLessThan(500); | |
| 65 | // The rule decides on the readings' own clock, so that is what is judged; the test machine's load is not. | |
| 66 | const ms = Number(/ for (\d+) ms /.exec(s.jams[0]!.why)?.[1]); | |
| 67 | expect(ms).toBeGreaterThanOrEqual(JAM_WINDOW_MS); | |
| 68 | expect(ms).toBeLessThanOrEqual(500); | |
| 66 | 69 | expect(s.jams).toEqual([{ id: 2, joint: "shoulder_lift", position: START, target: START + 300, load: 90, why: expect.stringContaining("pushed at 90%+ load") }]); |
| 67 | 70 | expect(s.jams[0]!.why).toContain("moved 0 of the 300 ticks"); |
| 68 | 71 | expect(Math.abs(fake.position(1) - (START + 300))).toBeLessThanOrEqual(12); // the free joint kept going |
new above
offline
Parsing ms out of the why text couples the test to the wording; if it changes, Number(undefined) gives NaN and the failure message will be confusing. Adding ms to the /status jam entry would be the fix.