Public: anyone can read this; the crew can change it.

Migrated from github.com/Trevato/SO-ARM100

workbenchthis machine

The safe zone never refuses a move that goes no deeper than the pose the arm starts in #167

Merged opened this

Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.

Merged

smith/arm:smith/161-the-safe-zone-never-refuses-a-move-that → main 1 commit fork 2 threads · 2 unresolved

  • Merged. smith/161-the-safe-zone-never-refuses-a-move-that was merged into main as 8d89036.

Review

Sign in to review this change.
2 files changed +24 −1
Software/so101/src/server.test.ts +21
@@ -573,6 +573,27 @@ describe("the safe zone, the jam watch, and the model routes", () => {
573573 await zcall("/settings", { zone: "enforce" }, "PUT");
574574 });
575575
576 test("an arm already 30 mm in the table can move up, and is refused moving further down", async () => {
577 const rest = (await (await fetch(`${zurl}/status`)).json()) as { lowestMm: number };
578 const saved = (await (await fetch(`${zurl}/settings`)).json()) as { floorMarginMm: number };
579 const margin = Math.round(rest.lowestMm) + 30; // the rest pose now sits 30 mm inside the zone
580 expect((await zcall("/settings", { zone: "enforce", floorMarginMm: margin }, "PUT")).status).toBe(200);
581 try {
582 const deeper = await zcall("/move", { targets: { "2": ticks(2, 80) } });
583 expect(deeper.status).toBe(409);
584 expect(((await deeper.json()) as { error: string }).error).toMatch(/^refused: \S.* would be \d+ mm below the table/);
585 let up = 0;
586 for (const deg of [-10, -20, -30]) {
587 const r = await zcall("/move", { targets: { "2": ticks(2, deg) } });
588 if (r.status === 200) up++;
589 }
590 expect(up).toBeGreaterThan(0); // some direction goes no deeper than the start
591 await moved({ "2": mid(2) });
592 } finally {
593 await zcall("/settings", { zone: "enforce", floorMarginMm: saved.floorMarginMm }, "PUT");
594 }
595 });

A loop with up>0 will pass if any one direction works. Pin the direction known to be up and assert 200 for it.

596
576597 test("a stream frame into the table holds the arm; a safe frame resumes it", async () => {
577598 const ws = new WebSocket(`ws://127.0.0.1:${zoneServer.port}/follow`);
578599 await new Promise((r) => ws.once("open", r));
Software/so101/src/server.ts +3 −1
@@ -256,11 +256,13 @@ export async function startServer(bus: FeetechBus, options: ServerOptions = {}):
256256 const checkPath = (from: ReadonlyMap<number, number>, to: ReadonlyMap<number, number>, steps = 12): Violation | null => {
257257 if (!model || settings.zone === "off") return null;
258258 let worst: Violation | null = null;
259 // The arm may already rest inside the zone (the real one sits a few cm "into" the virtual table): a move no deeper than that is not refused.

held is the single deepest violation over any link. A move that deepens a different link up to that depth passes. Consider keying held by link, as the stream path might.

260 const held = model.check(toQ(from), zoneSettings())?.depth ?? 0;
259261 for (let s = 1; s <= steps; s++) {
260262 const mix = new Map<number, number>();
261263 for (const [id, a] of from) mix.set(id, Math.round(a + ((to.get(id) ?? a) - a) * (s / steps)));
262264 const v = model.check(toQ(mix), zoneSettings());
263 if (v && (!worst || v.depth > worst.depth)) worst = v;
265 if (v && v.depth > held + 0.001 && (!worst || v.depth > worst.depth)) worst = v;
264266 }
265267 return worst;
266268 };

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs