fc5ee4f2c6
Add declarative robot packages, shared simulation lifecycle and Microban ONNX/PD walking with independent head control. Unify comic UI and chase camera; default robot packages to a 4.5m arena with real collision walls. Include regression tests, asset provenance/licenses and verification evidence.
63 lines
1.8 KiB
JavaScript
63 lines
1.8 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { readFile } from "node:fs/promises";
|
|
import {
|
|
readOnnxMetadata,
|
|
resolveJointDefaults,
|
|
} from "../src/platform/loader/metadata.js";
|
|
test("actual Microban 19 joint metadata selects 18 policy defaults by name", async () => {
|
|
const bytes = await readFile(
|
|
new URL("../public/robots/microban/policies/walk.onnx", import.meta.url),
|
|
);
|
|
const meta = readOnnxMetadata(bytes);
|
|
const names = meta.joint_names.split(",");
|
|
assert.equal(names.length, 19);
|
|
assert.equal(names[0], "head");
|
|
const policy = names.slice(1);
|
|
assert.equal(resolveJointDefaults(meta, policy).length, 18);
|
|
assert.equal(resolveJointDefaults(meta, ["right_elbow"])[0], -0.349);
|
|
assert.throws(() => resolveJointDefaults(meta, ["missing"]), /missing/);
|
|
assert.throws(
|
|
() =>
|
|
resolveJointDefaults({ joint_names: "a,a", default_joint_pos: "0,1" }, [
|
|
"a",
|
|
]),
|
|
/Invalid/,
|
|
);
|
|
assert.throws(
|
|
() =>
|
|
resolveJointDefaults({ joint_names: "a", default_joint_pos: "NaN" }, [
|
|
"a",
|
|
]),
|
|
/Invalid/,
|
|
);
|
|
});
|
|
test("LFS pointers and empty reference values fail with actionable diagnostics", () => {
|
|
assert.throws(
|
|
() =>
|
|
readOnnxMetadata(
|
|
new TextEncoder().encode(
|
|
"version https://git-lfs.github.com/spec/v1\n",
|
|
),
|
|
),
|
|
/git lfs pull/,
|
|
);
|
|
assert.throws(
|
|
() =>
|
|
resolveJointDefaults({ joint_names: "a", default_joint_pos: "" }, ["a"]),
|
|
/Invalid/,
|
|
);
|
|
assert.deepEqual(
|
|
resolveJointDefaults({ joint_names: " a, b ", default_joint_pos: "1,2" }, [
|
|
"b",
|
|
"a",
|
|
]),
|
|
[2, 1],
|
|
);
|
|
});
|
|
test("truncated protobuf is rejected", () =>
|
|
assert.throws(
|
|
() => readOnnxMetadata(new Uint8Array([114, 10, 0])),
|
|
/Truncated/,
|
|
));
|