Files
VibemakerSandbox/app/e2e/scene-stability.spec.js
chenlin a8be5e0134 feat: release v0.5 with shared interactive arenas and textured RP1
Unify lighting and line-colour controls across robots, replace the football with a shared layout of draggable physical props, and import the supplied RP1 GLBs without changing trained physics or policies.

Include reproducible visual import/provenance, regression coverage and verification records. Verified 66 unit tests, 55 browser tests and production-build checks.
2026-10-30 14:14:03 +08:00

69 lines
2.4 KiB
JavaScript

import { test, expect } from "@playwright/test";
import { bootDuck } from "./support/simulation.js";
test("two simulated minutes of movement with physical toys stay finite in feet and rollers; escape recovery is local", async ({
page,
}) => {
const errors = await bootDuck(page);
await page.evaluate(() => {
const r = window.rl;
r.setPropsParked(false);
// A deterministic controller source exercises actual commanded motion,
// independent of frame-rate keyboard polling during manual stepping.
r.controller.addSource({
id: "stability-drive",
isActive: () => true,
command: new Float32Array([0.25, 0, 0.4]),
});
});
for (const mode of ["legs", "rollers"]) {
await page.evaluate(async (mode) => {
const r = window.rl;
await r.setLoco(mode, { force: true });
r.controller.sources
.find((s) => s.id === "stability-drive")
.command.set(mode === "legs" ? [0.25, 0, 0.4] : [0.4, 0, 0.15]);
}, mode);
let moved = false;
for (let chunk = 0; chunk < 30; chunk++) {
const sample = await page.evaluate(async () => {
const r = window.rl;
await r.step(100);
return {
finite: [r.data.qpos, r.data.qvel, r.data.ctrl].every((array) =>
Array.from(array).every(Number.isFinite),
),
moved: Math.hypot(r.data.qpos[0] + 0.6, r.data.qpos[1]) > 0.04,
inside: r.interactiveProps.every(
(p) =>
Math.abs(r.data.qpos[p.qAdr]) <
r.world.boundary.half_extent + 0.11 &&
Math.abs(r.data.qpos[p.qAdr + 1]) <
r.world.boundary.half_extent + 0.11,
),
};
});
expect(sample.finite).toBe(true);
expect(sample.inside).toBe(true);
moved ||= sample.moved;
}
expect(moved).toBe(true);
}
const recovery = await page.evaluate(async () => {
const r = window.rl,
p = r.interactiveProps[0];
r.data.qpos[p.qAdr] = r.world.boundary.half_extent + 1;
r.mujoco.mj_forward(r.model, r.data);
await r.step(1);
return {
actual: Array.from(r.data.qpos.slice(p.qAdr, p.qAdr + 3)),
expected: p.pos,
count: r.interactiveProps.length,
};
});
expect(recovery.actual).toEqual(recovery.expected);
expect(recovery.count).toBeGreaterThanOrEqual(5);
expect(recovery.count).toBeLessThanOrEqual(7);
expect(errors).toEqual([]);
});