Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 57b3108ab3 | |||
| 09f7b02c3e |
@@ -29,11 +29,13 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||
*.f32 filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
*.stl filter=lfs diff=lfs merge=lfs -text
|
||||
*.STL filter=lfs diff=lfs merge=lfs -text
|
||||
*.wav filter=lfs diff=lfs merge=lfs -text
|
||||
*.png filter=lfs diff=lfs merge=lfs -text
|
||||
*.webp filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
@@ -11,7 +11,7 @@ license: apache-2.0
|
||||
|
||||
# Browser robot simulation platform
|
||||
|
||||
MuJoCo WASM + onnxruntime-web + three.js, with **Microduck** (legs / rollers) and **Microban** Robot Packages. Physics and ONNX inference run locally in the browser; no simulation backend is required.
|
||||
MuJoCo WASM + onnxruntime-web + three.js, with **Microduck** (legs / rollers), **Microban**, and **RP1** Robot Packages. Physics and ONNX inference run locally in the browser; no simulation backend is required.
|
||||
|
||||
The application opens directly into simulation, defaults to Microduck, and keeps pause, reset, robot selection and a collapsible keyboard reference on that same screen. There is no welcome / RESUME menu or BIOS animation. Anton is bundled locally, so the default interface does not wait for an external font service.
|
||||
|
||||
@@ -20,11 +20,12 @@ The application opens directly into simulation, defaults to Microduck, and keeps
|
||||
| Robot | Default scene / presentation | Controls |
|
||||
|---|---|---|
|
||||
| Microduck | Shared 4.5 × 4.5 m bounded arena, ball, original GLB/palette/comic effects | Existing walking, skating, skills and recovery |
|
||||
| Microban | Shared 4.5 × 4.5 m bounded arena, dark/orange grid and comic UI, MJCF robot visuals | Walking policy + independent head rotation |
|
||||
| Microban | Robot-scaled 5.5 × 5.5 m arena, dark/orange grid and comic UI, textured per-body GLB visuals | Walking policy + independent head rotation |
|
||||
| RP1 | Robot-scaled 22 × 22 m arena/comic UI, original 24-DOF MJCF visuals | Completed walking policy; trained 10 s dance segment (J) and full 4.36 s wave (H) |
|
||||
|
||||
Switch robots using **Robot** in the toolbar. Returning to Microduck restores the session's colour and feet / rollers choice, but initializes a fresh physical state. Failed loads keep the previous robot available and show an inline retry action.
|
||||
|
||||
Microduck policies / assets originate from [pollen-robotics/microduck](https://github.com/pollen-robotics/microduck) and [pollen-robotics/microduck_rl](https://github.com/pollen-robotics/microduck_rl). Microban assets originate from [Rhoban/microban](https://github.com/Rhoban/microban); exact source hashes, dirty-worktree provenance and license notices are included in its Package.
|
||||
Microduck policies / assets originate from [pollen-robotics/microduck](https://github.com/pollen-robotics/microduck) and [pollen-robotics/microduck_rl](https://github.com/pollen-robotics/microduck_rl). Microban physics / policy assets originate from [Rhoban/microban](https://github.com/Rhoban/microban); its textured visual replacement comes from the user-supplied `microban2.zip`. Exact hashes, dirty-worktree provenance and license caveats are included in its [Package source notes](app/public/robots/microban/SOURCE.md).
|
||||
|
||||
## Keyboard and mouse
|
||||
|
||||
@@ -40,12 +41,13 @@ Microduck policies / assets originate from [pollen-robotics/microduck](https://g
|
||||
| Microduck ground pick | G |
|
||||
| Microduck forward roll; roller crouch | T |
|
||||
| Microduck feet / rollers | M or quickbar |
|
||||
| Restore rear chase camera (both robots) | C |
|
||||
| Restore rear chase camera (all robots) | C |
|
||||
| Microban independent head rotation | H |
|
||||
| RP1 trained dance (10 s segment) / wave (4.36 s) | J / H |
|
||||
|
||||
The on-screen reference comes from the same Package bindings as the keyboard, and its skill entries are also clickable buttons. Text fields / selectors retain their normal keyboard behavior. Focused buttons retain native Space / Enter behavior without also resetting the robot. Losing focus, pausing, resetting or switching clears held movement keys.
|
||||
|
||||
All bundled robots, and future Packages omitting `presentation.world`, use the shared **4.5 × 4.5 m** arena (length and width increased 50% from 3 m). Its four real collision walls are 0.25 m high and 0.05 m thick, with Microduck's dark glowing grid. Microban's interior stays flat; no relief or automatic coordinate clamping is added. Explicit `world: "flat"` remains available for generic-runtime diagnostics. Both robots start with the camera behind the body. Mouse orbit detaches chase mode; **C** restores rear following and the default zoom, including while paused (pressing C again does not detach). Microduck mouse dragging still applies physical forces to the robot / ball. Microban mouse dragging orbits the camera. Gamepad / touch are not part of this release's acceptance scope.
|
||||
All bundled robots, and future Packages omitting `presentation.world`, use the same **robot-scaled arena template**. Microduck remains at **4.5 × 4.5 m**, with 0.25 m high / 0.05 m thick collision walls. World lengths scale by `dimensions.height / 0.27`: Microban gets **5.5 × 5.5 m**, walls ≈0.306 m high; RP1 gets **22 × 22 m**, walls ≈1.222 m high. Wall thickness, visual geometry, grid spacing and fade distances scale together, preserving Microduck's scene-to-body proportions. Nominal standing height is fixed per package, not inferred from the live pose or root spawn height; missing dimensions retain the reference scale. Interiors stay flat; no relief or automatic coordinate clamping is added. Explicit `world: "flat"` remains available for generic-runtime diagnostics. All robots start with the camera behind the body. Mouse orbit detaches chase mode; **C** restores rear following and the default zoom, including while paused (pressing C again does not detach). Microduck mouse dragging still applies physical forces to the robot / ball. Microban / RP1 mouse dragging orbits the camera. Gamepad / touch are not part of this release's acceptance scope.
|
||||
|
||||
## Microban fidelity and limits
|
||||
|
||||
@@ -60,9 +62,17 @@ All bundled robots, and future Packages omitting `presentation.world`, use the s
|
||||
|
||||
BAM battery / friction / delay modeling, Placo squat, training, hardware control, ROS, camera observations, external Packages and online sharing are **not implemented** in this release. Ghost networking, stickers and celebration / entrance sequences are deferred. Audio retains the existing `SOUND_DISABLED=true` master setting; simulation never waits for an audio-unlock gesture.
|
||||
|
||||
## RP1 trained skills
|
||||
|
||||
Walking uses final `model_9000.pt` from `rp1_24dof_flat/2026-10-28_15-47-49`, float32 `[1,243]` (three term-major history frames) → `[1,24]`. Dance uses resumed `2026-10-29_11-05-14_dance_resume/model_23998.pt`; wave retains its separate final `model_7999.pt`. Their actual actor branch is **student**, float32 `[1,126]` → `[1,24]`, with joint-reference position/velocity commands. All exports include the empirical normalizer and use their own reference defaults, named joint order and action history.
|
||||
|
||||
Independent ONNX skills share `load/reset/run/dispose` and an exclusive full-body FSM: walk → settle → blend in → play → blend back to walk. Release movement keys before requesting a skill; movement interrupts it. Reference playback is simulation-clocked, freezes on pause, restarts on each activation, and never writes kinematic poses. **Wave plays its complete 4.36 s clip. Dance exposes only the validated first 10 s**: the previous dance checkpoint fell near 20 s during full 131.46 s playback; full-length playback of the updated checkpoint has not been qualified. These are trained policies, not scripted motion substitutes. Completed training does not imply exact training-simulator or hardware equivalence. See [RP1 integration and weight updates](docs/robots/rp1.md) and [completed-skills verification](docs/superpowers/verification/2026-10-29-rp1-completed-skills.md), plus the [23998 dance update](docs/superpowers/verification/2026-10-29-rp1-dance-23998.md).
|
||||
|
||||
**RP1 description asset licensing is not supplied in the upstream checkout. Local evaluation only; confirm rights before public deployment/redistribution.** Provenance and caveats are recorded in [the package SOURCE.md](app/public/robots/rp1/SOURCE.md).
|
||||
|
||||
## Development
|
||||
|
||||
Binary robot meshes and ONNX files use Git LFS:
|
||||
Binary robot meshes, ONNX policies and `.f32` motion samples use Git LFS:
|
||||
|
||||
```bash
|
||||
git lfs install
|
||||
@@ -106,9 +116,9 @@ For prefixed hosting, build and preview with `VITE_BASE=/play/`; `DEPLOY_PATH=/p
|
||||
- `app/src/robots/microduck/runtime.js`: compatibility adapter retaining original skill / recovery quirks and GLB presentation while using shared runtimes, scheduler, input, observation / action mapping and actuation.
|
||||
- `app/src/game/worlds/arena/`: arena physics composition and rendering. `game/game.js` and `game/arena.js` are compatibility entry points, not generic engines.
|
||||
|
||||
A robot expressible with existing capabilities can be added by a Package and index entry, without a robot-id branch in the platform. Current generic scope is floating-base robots with scalar joint groups, unit-gear actuators, supported proprioceptive terms, ONNX primary control, position targets and optional sinusoidal overlays. Unsupported capabilities are rejected, not silently simulated incorrectly. New capabilities require explicit registry / schema work.
|
||||
A robot expressible with existing capabilities can be added by a Package and index entry, without a robot-id branch in the platform. Current generic scope is floating-base robots with scalar joint groups, unit-gear actuators, supported proprioceptive / joint-reference terms, ONNX primary control, independent episodic policies, simulation-clocked motion references, position targets and optional sinusoidal overlays. Unsupported capabilities are rejected, not silently simulated incorrectly. New capabilities require explicit registry / schema work.
|
||||
|
||||
See [Package authoring](docs/robots/package-authoring.md), [Microban details](docs/robots/microban.md), [approved design](docs/superpowers/specs/2026-10-27-multi-robot-platform-design.md), [implementation plan](docs/superpowers/plans/2026-10-27-multi-robot-platform-implementation.md) and [initial verification](docs/superpowers/verification/2026-10-27-multi-robot-platform.md) and [style/camera verification](docs/superpowers/verification/2026-10-28-style-and-chase-camera.md), plus [arena-style verification](docs/superpowers/verification/2026-10-28-arena-presentation.md) and [current bounded-default verification](docs/superpowers/verification/2026-10-28-default-bounded-arena.md).
|
||||
See [Package authoring](docs/robots/package-authoring.md), [Microban details](docs/robots/microban.md), [approved design](docs/superpowers/specs/2026-10-27-multi-robot-platform-design.md), [implementation plan](docs/superpowers/plans/2026-10-27-multi-robot-platform-implementation.md) and [initial verification](docs/superpowers/verification/2026-10-27-multi-robot-platform.md) and [style/camera verification](docs/superpowers/verification/2026-10-28-style-and-chase-camera.md), plus [arena-style verification](docs/superpowers/verification/2026-10-28-arena-presentation.md) and [initial bounded-default verification](docs/superpowers/verification/2026-10-28-default-bounded-arena.md). Current size-adaptive behavior is documented in [robot-scaled arena verification](docs/superpowers/verification/2026-10-28-robot-scaled-arena.md).
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -57,8 +57,8 @@ test("arena appearance matches Microduck while Microban physics stays flat and W
|
||||
};
|
||||
});
|
||||
expect(state).toEqual({
|
||||
cell: 0.1,
|
||||
section: 0.6,
|
||||
cell: 0.1 * (0.33 / 0.27),
|
||||
section: 0.6 * (0.33 / 0.27),
|
||||
color: 0xffb366,
|
||||
reveal: 1,
|
||||
topo: 0,
|
||||
|
||||
+101
-67
@@ -2,21 +2,37 @@ import { test, expect } from "@playwright/test";
|
||||
import { bootDuck } from "./support/simulation.js";
|
||||
import { arenaWalls } from "../src/platform/worlds/arena.js";
|
||||
const boundary = { half_extent: 2.25, wall_height: 0.25, wall_thickness: 0.05 };
|
||||
test("Microduck and Microban share the 4.5m collision arena; visual inner faces match and C remains attached", async ({
|
||||
test("all three robots keep Microduck's arena-to-body proportions; visual and physical walls agree", async ({
|
||||
page,
|
||||
}, info) => {
|
||||
await bootDuck(page);
|
||||
for (const id of ["microduck-legs", "microban"]) {
|
||||
if (id === "microban")
|
||||
for (const [id, scale] of [
|
||||
["microduck-legs", 1],
|
||||
["microban", 0.33 / 0.27],
|
||||
["rp1", 1.32 / 0.27],
|
||||
]) {
|
||||
if (id !== "microduck-legs")
|
||||
expect(
|
||||
await page.evaluate(() => window.__gameApi.switchRobot("microban")),
|
||||
await page.evaluate((id) => window.__gameApi.switchRobot(id), id),
|
||||
).toBe(true);
|
||||
const fitted = Object.fromEntries(
|
||||
Object.entries(boundary).map(([k, v]) => [k, v * scale]),
|
||||
);
|
||||
const state = await page.evaluate(() => {
|
||||
const r = window.rl;
|
||||
return {
|
||||
id: r.world.id,
|
||||
boundary: r.world.boundary,
|
||||
scale: r.world.scale,
|
||||
following: r.chaseCam,
|
||||
grid: r.scene.getObjectByName("arena-grid")
|
||||
? {
|
||||
cell: r.scene.getObjectByName("arena-grid").material.uniforms
|
||||
.uCell.value,
|
||||
fade: r.scene.getObjectByName("arena-grid").material.uniforms
|
||||
.uFadeDist.value,
|
||||
}
|
||||
: null,
|
||||
walls: ["wall_px", "wall_nx", "wall_py", "wall_ny"].map((name) => {
|
||||
const g = r.model.geom(name).id;
|
||||
return {
|
||||
@@ -33,24 +49,30 @@ test("Microduck and Microban share the 4.5m collision arena; visual inner faces
|
||||
};
|
||||
});
|
||||
expect(state.id).toBe("arena");
|
||||
expect(state.boundary).toEqual(boundary);
|
||||
expect(state.boundary).toEqual(fitted);
|
||||
expect(state.scale).toBe(scale);
|
||||
expect(state.following).toBe(true);
|
||||
expect(state.walls).toEqual(
|
||||
arenaWalls(boundary).map((w) => ({ ...w, type: 6, body: 0 })),
|
||||
arenaWalls(fitted).map((w) => ({ ...w, type: 6, body: 0 })),
|
||||
);
|
||||
expect(state.visuals).toEqual([
|
||||
[2.25, 0.125, 0],
|
||||
[-2.25, 0.125, 0],
|
||||
[0, 0.125, 2.25],
|
||||
[0, 0.125, -2.25],
|
||||
[fitted.half_extent, fitted.wall_height / 2, 0],
|
||||
[-fitted.half_extent, fitted.wall_height / 2, 0],
|
||||
[0, fitted.wall_height / 2, fitted.half_extent],
|
||||
[0, fitted.wall_height / 2, -fitted.half_extent],
|
||||
]);
|
||||
if (state.grid) {
|
||||
expect(state.grid.cell).toBeCloseTo(0.1 * scale, 8);
|
||||
expect(state.grid.fade).toBeCloseTo(3 * scale, 8);
|
||||
}
|
||||
}
|
||||
// QA overview only; normal entry remains the rear chase framing above.
|
||||
await page.locator("canvas").click({ position: { x: 1000, y: 700 } });
|
||||
await page.evaluate(() => {
|
||||
const r = window.rl;
|
||||
r.controls.maxDistance = 8;
|
||||
r.camera.position.set(-3, 3, 3);
|
||||
const scale = r.world.scale;
|
||||
r.controls.maxDistance = 8 * scale;
|
||||
r.camera.position.set(-3 * scale, 3 * scale, 3 * scale);
|
||||
r.controls.target.set(0, 0, 0);
|
||||
r.controls.update();
|
||||
});
|
||||
@@ -87,63 +109,75 @@ test("a future Package with no world field automatically loads the bounded defau
|
||||
world: window.rl.world.id,
|
||||
bounds: window.rl.world.boundary,
|
||||
})),
|
||||
).toEqual({ id: "future-bot", world: "arena", bounds: boundary });
|
||||
).toEqual({
|
||||
id: "future-bot",
|
||||
world: "arena",
|
||||
bounds: Object.fromEntries(
|
||||
Object.entries(boundary).map(([k, v]) => [k, v * (0.33 / 0.27)]),
|
||||
),
|
||||
});
|
||||
});
|
||||
test("real MuJoCo wall contacts block commanded motion on all four sides without coordinate clamping", async ({
|
||||
page,
|
||||
}, info) => {
|
||||
await bootDuck(page);
|
||||
expect(
|
||||
await page.evaluate(() => window.__gameApi.switchRobot("microban")),
|
||||
).toBe(true);
|
||||
const results = await page.evaluate(async () => {
|
||||
const r = window.rl,
|
||||
report = [];
|
||||
for (const [name, axis, sign, yaw] of [
|
||||
["wall_px", 0, 1, 0],
|
||||
["wall_nx", 0, -1, Math.PI],
|
||||
["wall_py", 1, 1, Math.PI / 2],
|
||||
["wall_ny", 1, -1, -Math.PI / 2],
|
||||
]) {
|
||||
await r.resetSim();
|
||||
const id = r.model.geom(name).id;
|
||||
r.data.qpos[axis] = sign * 2.05;
|
||||
r.data.qpos[3] = Math.cos(yaw / 2);
|
||||
r.data.qpos[6] = Math.sin(yaw / 2);
|
||||
r.mujoco.mj_forward(r.model, r.data);
|
||||
r.command.set([0.15, 0, 0]);
|
||||
let contacts = 0,
|
||||
max = sign * r.data.qpos[axis];
|
||||
for (let tick = 0; tick < 30; tick++) {
|
||||
await r.step(5);
|
||||
max = Math.max(max, sign * r.data.qpos[axis]);
|
||||
const list = r.data.contact;
|
||||
for (let i = 0; i < r.data.ncon; i++) {
|
||||
const c = list.get(i);
|
||||
if (c.geom1 === id || c.geom2 === id) contacts++;
|
||||
c.delete();
|
||||
for (const robot of [
|
||||
{ id: "microban", forward: 0.15, pad: 0.2 },
|
||||
{ id: "rp1", forward: 0.4, pad: 0.35 },
|
||||
])
|
||||
test(`${robot.id}: real scaled wall contacts block motion on all four sides without coordinate clamping`, async ({
|
||||
page,
|
||||
}, info) => {
|
||||
await bootDuck(page);
|
||||
expect(
|
||||
await page.evaluate((id) => window.__gameApi.switchRobot(id), robot.id),
|
||||
).toBe(true);
|
||||
const results = await page.evaluate(async (robot) => {
|
||||
const r = window.rl,
|
||||
report = [],
|
||||
half = r.world.boundary.half_extent;
|
||||
for (const [name, axis, sign, yaw] of [
|
||||
["wall_px", 0, 1, 0],
|
||||
["wall_nx", 0, -1, Math.PI],
|
||||
["wall_py", 1, 1, Math.PI / 2],
|
||||
["wall_ny", 1, -1, -Math.PI / 2],
|
||||
]) {
|
||||
await r.resetSim();
|
||||
const id = r.model.geom(name).id;
|
||||
r.data.qpos[axis] = sign * (half - robot.pad);
|
||||
r.data.qpos[3] = Math.cos(yaw / 2);
|
||||
r.data.qpos[6] = Math.sin(yaw / 2);
|
||||
r.mujoco.mj_forward(r.model, r.data);
|
||||
r.command.set([robot.forward, 0, 0]);
|
||||
let contacts = 0,
|
||||
max = sign * r.data.qpos[axis];
|
||||
for (let tick = 0; tick < 30; tick++) {
|
||||
await r.step(5);
|
||||
max = Math.max(max, sign * r.data.qpos[axis]);
|
||||
const list = r.data.contact;
|
||||
for (let i = 0; i < r.data.ncon; i++) {
|
||||
const c = list.get(i);
|
||||
if (c.geom1 === id || c.geom2 === id) contacts++;
|
||||
c.delete();
|
||||
}
|
||||
list.delete();
|
||||
}
|
||||
list.delete();
|
||||
report.push({
|
||||
name,
|
||||
contacts,
|
||||
max,
|
||||
half,
|
||||
time: r.data.time,
|
||||
fallen: r.fallen,
|
||||
finite: Array.from(r.data.qpos).every(Number.isFinite),
|
||||
});
|
||||
}
|
||||
report.push({
|
||||
name,
|
||||
contacts,
|
||||
max,
|
||||
time: r.data.time,
|
||||
fallen: r.fallen,
|
||||
finite: Array.from(r.data.qpos).every(Number.isFinite),
|
||||
});
|
||||
return report;
|
||||
}, robot);
|
||||
for (const r of results) {
|
||||
expect(r.contacts, JSON.stringify(r)).toBeGreaterThan(0);
|
||||
expect(r.max, JSON.stringify(r)).toBeLessThan(r.half);
|
||||
expect(r.time).toBeCloseTo(3, 6);
|
||||
expect(r.finite).toBe(true);
|
||||
}
|
||||
return report;
|
||||
await info.attach("wall-contacts.json", {
|
||||
body: JSON.stringify(results, null, 2),
|
||||
contentType: "application/json",
|
||||
});
|
||||
});
|
||||
for (const r of results) {
|
||||
expect(r.contacts, JSON.stringify(r)).toBeGreaterThan(0);
|
||||
expect(r.max, JSON.stringify(r)).toBeLessThan(2.25);
|
||||
expect(r.time).toBeCloseTo(3, 6);
|
||||
expect(r.finite).toBe(true);
|
||||
}
|
||||
await info.attach("wall-contacts.json", {
|
||||
body: JSON.stringify(results, null, 2),
|
||||
contentType: "application/json",
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
test.use({ video: { mode: "on", size: { width: 1280, height: 800 } } });
|
||||
test("deployed assets respect the base path and both Robot Packages boot", async ({
|
||||
test("deployed assets respect the base path and all three Robot Packages boot", async ({
|
||||
page,
|
||||
}, info) => {
|
||||
const failures = [],
|
||||
@@ -29,6 +29,12 @@ test("deployed assets respect the base path and both Robot Packages boot", async
|
||||
await expect(page.getByRole("status")).toContainText("Simplified actuation");
|
||||
await page.waitForTimeout(500);
|
||||
await page.screenshot({ path: info.outputPath("microban.png") });
|
||||
await page.getByLabel("Robot", { exact: true }).selectOption("rp1");
|
||||
await expect
|
||||
.poll(() => page.evaluate(() => window.__store.getState().robotId))
|
||||
.toBe("rp1");
|
||||
await expect(page.getByRole("status")).toContainText("Skill: walk");
|
||||
await page.screenshot({ path: info.outputPath("rp1.png") });
|
||||
expect(errors).toEqual([]);
|
||||
expect(failures).toEqual([]);
|
||||
const origin = new URL(page.url()).origin;
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
async function boot(page) {
|
||||
await page.goto("/");
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Pause", exact: true }),
|
||||
).toBeEnabled();
|
||||
await page.evaluate(() => window.__gameApi.pause());
|
||||
}
|
||||
test("20 textured GLBs replace only Microban visuals, align to original geometry and follow all bodies", async ({
|
||||
page,
|
||||
}, info) => {
|
||||
const errors = [];
|
||||
page.on("pageerror", (error) => errors.push(error.message));
|
||||
await boot(page);
|
||||
expect(
|
||||
await page.evaluate(() => window.__gameApi.switchRobot("microban")),
|
||||
).toBe(true);
|
||||
const inspect = () =>
|
||||
page.evaluate(() => {
|
||||
const r = window.rl,
|
||||
layer = r.scene.getObjectByName("body-visuals"),
|
||||
rig = layer.parent;
|
||||
rig.updateMatrixWorld(true);
|
||||
let maxFrameError = 0,
|
||||
maxBoundsError = 0,
|
||||
maps = 0,
|
||||
colorMaps = 0,
|
||||
meshes = 0,
|
||||
hidden = 0;
|
||||
const bounds = (objects, frame) => {
|
||||
const lo = [Infinity, Infinity, Infinity],
|
||||
hi = [-Infinity, -Infinity, -Infinity];
|
||||
const inverse = frame.matrixWorld.clone().invert(),
|
||||
vector = frame.position.clone();
|
||||
for (const mesh of objects) {
|
||||
const transform = inverse.clone().multiply(mesh.matrixWorld),
|
||||
attr = mesh.geometry.attributes.position;
|
||||
for (let i = 0; i < attr.count; i++) {
|
||||
vector.fromBufferAttribute(attr, i).applyMatrix4(transform);
|
||||
const v = vector.toArray();
|
||||
for (let axis = 0; axis < 3; axis++) {
|
||||
lo[axis] = Math.min(lo[axis], v[axis]);
|
||||
hi[axis] = Math.max(hi[axis], v[axis]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return [...lo, ...hi];
|
||||
};
|
||||
for (const frame of layer.children) {
|
||||
const body = frame.name.slice("body-visual:".length),
|
||||
id = r.mujoco.mj_name2id(
|
||||
r.model,
|
||||
r.mujoco.mjtObj.mjOBJ_BODY.value,
|
||||
body,
|
||||
);
|
||||
const p = Array.from(r.data.xpos.slice(id * 3, id * 3 + 3));
|
||||
const q = Array.from(r.data.xquat.slice(id * 4, id * 4 + 4));
|
||||
maxFrameError = Math.max(
|
||||
maxFrameError,
|
||||
...p.map((v, i) => Math.abs(v - frame.position.toArray()[i])),
|
||||
...[q[1], q[2], q[3], q[0]].map((v, i) =>
|
||||
Math.abs(v - frame.quaternion.toArray()[i]),
|
||||
),
|
||||
);
|
||||
const originals = rig.children.filter(
|
||||
(mesh) =>
|
||||
mesh.userData.geomId !== undefined &&
|
||||
r.model.geom_bodyid[mesh.userData.geomId] === id,
|
||||
);
|
||||
const replacements = [];
|
||||
frame.traverse((object) => {
|
||||
if (!object.isMesh) return;
|
||||
meshes++;
|
||||
replacements.push(object);
|
||||
const materials = [object.material].flat();
|
||||
maps += materials.filter(
|
||||
(material) => material.normalMap?.image?.width > 0,
|
||||
).length;
|
||||
colorMaps += materials.filter(
|
||||
(material) => material.map?.image?.width > 0,
|
||||
).length;
|
||||
});
|
||||
hidden += originals.filter((mesh) => !mesh.visible).length;
|
||||
const oldBounds = bounds(originals, frame),
|
||||
newBounds = bounds(replacements, frame);
|
||||
maxBoundsError = Math.max(
|
||||
maxBoundsError,
|
||||
...oldBounds.map((v, i) => Math.abs(v - newBounds[i])),
|
||||
);
|
||||
}
|
||||
return {
|
||||
count: layer.children.length,
|
||||
maps,
|
||||
colorMaps,
|
||||
meshes,
|
||||
hidden,
|
||||
maxFrameError,
|
||||
maxBoundsError,
|
||||
obs: r.buildObs().length,
|
||||
};
|
||||
});
|
||||
const initial = await inspect();
|
||||
console.log("Microban visual alignment", initial);
|
||||
expect(initial.count).toBe(20);
|
||||
expect(initial.maps).toBeGreaterThanOrEqual(20);
|
||||
expect(initial.colorMaps).toBeGreaterThanOrEqual(1);
|
||||
expect(initial.hidden).toBeGreaterThan(20);
|
||||
expect(initial.maxFrameError).toBeLessThan(1e-12);
|
||||
expect(initial.maxBoundsError).toBeLessThan(0.0031);
|
||||
expect(initial.obs).toBe(63);
|
||||
// Change root yaw and every hinge, including head: no bind-pose-only rig.
|
||||
await page.evaluate(() => {
|
||||
const r = window.rl;
|
||||
r.data.qpos[3] = Math.cos(0.4);
|
||||
r.data.qpos[6] = Math.sin(0.4);
|
||||
for (let i = 7; i < r.model.nq; i++) r.data.qpos[i] += 0.12;
|
||||
r.mujoco.mj_forward(r.model, r.data);
|
||||
});
|
||||
await page.waitForTimeout(150);
|
||||
const articulated = await inspect();
|
||||
expect(articulated.maxFrameError).toBeLessThan(1e-12);
|
||||
expect(articulated.maxBoundsError).toBeLessThan(0.0031);
|
||||
await page.evaluate(() => window.rl.resetSim());
|
||||
await page.waitForTimeout(150);
|
||||
// Front 3/4 view for a useful visual acceptance artifact.
|
||||
await page.evaluate(() => {
|
||||
window.rl.camera.position.set(0.58, 0.38, 0.58);
|
||||
window.rl.controls.target.set(0, 0.17, 0);
|
||||
window.rl.controls.update();
|
||||
});
|
||||
await page.waitForTimeout(200);
|
||||
const screenshot = info.outputPath("textured-microban.png");
|
||||
await page.screenshot({ path: screenshot });
|
||||
await info.attach("textured-microban.png", {
|
||||
path: screenshot,
|
||||
contentType: "image/png",
|
||||
});
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
test("failed visual candidate rolls back without hiding the old robot; retry loads textures", async ({
|
||||
page,
|
||||
}) => {
|
||||
await boot(page);
|
||||
const before = await page.evaluate(
|
||||
() => window.__gameApi.diagnostics().sceneChildren,
|
||||
);
|
||||
let fail = true;
|
||||
await page.route(
|
||||
"**/robots/microban/visuals/LINK10__visual_0__LINK10.glb",
|
||||
(route) =>
|
||||
fail
|
||||
? route.fulfill({ status: 404, body: "missing visual" })
|
||||
: route.continue(),
|
||||
);
|
||||
expect(
|
||||
await page.evaluate(() => window.__gameApi.switchRobot("microban")),
|
||||
).toBe(false);
|
||||
expect(await page.evaluate(() => window.__store.getState().robotId)).toBe(
|
||||
"microduck-legs",
|
||||
);
|
||||
expect(
|
||||
await page.evaluate(() => window.__gameApi.diagnostics().sceneChildren),
|
||||
).toBe(before);
|
||||
expect(
|
||||
await page.evaluate(
|
||||
() => window.rl.scene.getObjectByName("body-visuals") === undefined,
|
||||
),
|
||||
).toBe(true);
|
||||
fail = false;
|
||||
expect(
|
||||
await page.evaluate(() => window.__gameApi.switchRobot("microban")),
|
||||
).toBe(true);
|
||||
expect(
|
||||
await page.evaluate(
|
||||
() => window.rl.scene.getObjectByName("body-visuals").children.length,
|
||||
),
|
||||
).toBe(20);
|
||||
});
|
||||
test("visual replacement leaves deterministic physics and ONNX actions unchanged", async ({
|
||||
page,
|
||||
}) => {
|
||||
await boot(page);
|
||||
let textured = false;
|
||||
await page.route("**/robots/microban/robot.json", async (route) => {
|
||||
const response = await route.fetch(),
|
||||
config = await response.json();
|
||||
if (!textured) delete config.render.body_visuals;
|
||||
await route.fulfill({ json: config });
|
||||
});
|
||||
async function run() {
|
||||
expect(
|
||||
await page.evaluate(() => window.__gameApi.switchRobot("microban")),
|
||||
).toBe(true);
|
||||
return page.evaluate(async () => {
|
||||
const r = window.rl;
|
||||
await r.resetSim();
|
||||
await r.step(80);
|
||||
return {
|
||||
qpos: Array.from(r.data.qpos),
|
||||
qvel: Array.from(r.data.qvel),
|
||||
action: Array.from(r.lastAction),
|
||||
};
|
||||
});
|
||||
}
|
||||
const white = await run();
|
||||
expect(
|
||||
await page.evaluate(() => window.__gameApi.switchRobot("microduck-legs")),
|
||||
).toBe(true);
|
||||
textured = true;
|
||||
const visual = await run();
|
||||
expect(visual).toEqual(white);
|
||||
});
|
||||
@@ -0,0 +1,347 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
import { readFileSync } from "node:fs";
|
||||
|
||||
async function allowStaged(page) {
|
||||
// Qualification can exercise disabled candidates; normal CI uses the actual manifest.
|
||||
if (process.env.RP1_TEST_STAGED) {
|
||||
await page.route("**/robots/rp1/robot.json*", async (route) => {
|
||||
const response = await route.fetch(),
|
||||
config = await response.json();
|
||||
for (const skill of config.skills.filter((s) => s.kind === "episodic")) {
|
||||
skill.available = true;
|
||||
config.input.bindings.find(
|
||||
(b) => b.action === `skill:${skill.id}`,
|
||||
).disabled = false;
|
||||
}
|
||||
await route.fulfill({ response, json: config });
|
||||
});
|
||||
}
|
||||
}
|
||||
async function boot(page) {
|
||||
await allowStaged(page);
|
||||
await page.goto("/");
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Pause", exact: true }),
|
||||
).toBeEnabled();
|
||||
expect(await page.evaluate(() => window.__gameApi.switchRobot("rp1"))).toBe(
|
||||
true,
|
||||
);
|
||||
await page.evaluate(() => window.rl.pause());
|
||||
}
|
||||
|
||||
for (const skill of ["wave", "dance"]) {
|
||||
test(`trained ${skill}: three headings, configured segment, physical walk→skill→walk`, async ({
|
||||
page,
|
||||
}, info) => {
|
||||
test.setTimeout(240000);
|
||||
await boot(page);
|
||||
const reports = [];
|
||||
for (const turn of [0, 1.8, -1.8]) {
|
||||
const report = await page.evaluate(
|
||||
async ({ skill, turn }) => {
|
||||
const r = window.rl;
|
||||
await r.resetSim();
|
||||
if (turn) {
|
||||
r.command.set([0, 0, Math.sign(turn) * 0.6]);
|
||||
await r.step(Math.round(Math.abs(turn) * 50));
|
||||
}
|
||||
r.command.set([0.4, 0, 0]);
|
||||
await r.step(50);
|
||||
r.command.fill(0);
|
||||
await r.step(100);
|
||||
const before = Array.from(r.data.qpos.slice(0, 3));
|
||||
if (!r.policyState.request(skill, r.data.time))
|
||||
throw new Error("request refused");
|
||||
const states = [],
|
||||
samples = [];
|
||||
let entered = false,
|
||||
fallen = null,
|
||||
completed = false,
|
||||
minHeight = Infinity;
|
||||
let previousState = "",
|
||||
previousPosition = before,
|
||||
maxStep = 0,
|
||||
maxAction = 0,
|
||||
maxFrame = 0;
|
||||
const duration = r.policyState.episodes.get(skill).duration;
|
||||
for (let i = 0; i < (duration + 10) * 50; i++) {
|
||||
await r.step(1);
|
||||
const state = r.policyState.state;
|
||||
if (state !== previousState) {
|
||||
states.push({
|
||||
state,
|
||||
time: r.data.time,
|
||||
reference: r.referenceFrame,
|
||||
});
|
||||
previousState = state;
|
||||
}
|
||||
const p = Array.from(r.data.qpos.slice(0, 3));
|
||||
maxStep = Math.max(
|
||||
maxStep,
|
||||
Math.hypot(...p.map((v, j) => v - previousPosition[j])),
|
||||
);
|
||||
previousPosition = p;
|
||||
minHeight = Math.min(minHeight, p[2]);
|
||||
maxAction = Math.max(
|
||||
maxAction,
|
||||
...Array.from(r.lastAction, Math.abs),
|
||||
);
|
||||
maxFrame = Math.max(maxFrame, r.referenceFrame ?? 0);
|
||||
if (
|
||||
![
|
||||
...r.data.qpos,
|
||||
...r.data.qvel,
|
||||
...r.data.ctrl,
|
||||
...r.lastAction,
|
||||
].every(Number.isFinite)
|
||||
)
|
||||
throw new Error("non-finite physics/action state");
|
||||
if (r.activePolicy === skill) entered = true;
|
||||
if (i % 50 === 0 && r.activePolicy === skill) {
|
||||
const obs = Array.from(r.buildObs());
|
||||
if (obs.length !== 126)
|
||||
throw new Error(`wrong observation length ${obs.length}`);
|
||||
samples.push({
|
||||
time: r.data.time,
|
||||
frame: r.referenceFrame,
|
||||
pos: p,
|
||||
obs,
|
||||
});
|
||||
}
|
||||
if (r.fallen) {
|
||||
fallen = { time: r.data.time, frame: r.referenceFrame, p };
|
||||
break;
|
||||
}
|
||||
if (entered && state === "walk") {
|
||||
completed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const after = Array.from(r.data.qpos.slice(0, 3));
|
||||
const [w, x, y, z] = r.data.qpos.slice(3, 7);
|
||||
const yaw = Math.atan2(2 * (w * z + x * y), 1 - 2 * (y * y + z * z));
|
||||
if (completed) {
|
||||
r.command.set([0.4, 0, 0]);
|
||||
await r.step(150);
|
||||
}
|
||||
const walkAfter = Array.from(r.data.qpos.slice(0, 3));
|
||||
return {
|
||||
skill,
|
||||
turn,
|
||||
duration,
|
||||
before,
|
||||
after,
|
||||
states,
|
||||
samples,
|
||||
entered,
|
||||
completed,
|
||||
fallen,
|
||||
finalFallen: r.fallen,
|
||||
minHeight,
|
||||
maxStep,
|
||||
maxAction,
|
||||
maxFrame,
|
||||
stats: r.actuationStats,
|
||||
walkAfter,
|
||||
forwardAfter:
|
||||
(walkAfter[0] - after[0]) * Math.cos(yaw) +
|
||||
(walkAfter[1] - after[1]) * Math.sin(yaw),
|
||||
};
|
||||
},
|
||||
{ skill, turn },
|
||||
);
|
||||
reports.push(report);
|
||||
const base = new URL("../public/robots/rp1/", import.meta.url);
|
||||
const descriptor = JSON.parse(
|
||||
readFileSync(new URL(`motions/${skill}.json`, base)),
|
||||
);
|
||||
const binary = readFileSync(new URL(descriptor.data, base));
|
||||
for (const sample of report.samples) {
|
||||
for (let j = 0; j < 24; j++) {
|
||||
expect(sample.obs[j]).toBe(
|
||||
binary.readFloatLE((sample.frame * 24 + j) * 4),
|
||||
);
|
||||
expect(sample.obs[j + 24]).toBe(
|
||||
binary.readFloatLE(
|
||||
(descriptor.frames * 24 + sample.frame * 24 + j) * 4,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
await info.attach(`${skill}-${turn}-playback.json`, {
|
||||
body: JSON.stringify(report),
|
||||
contentType: "application/json",
|
||||
});
|
||||
console.log(
|
||||
`RP1 ${skill} playback`,
|
||||
JSON.stringify({ ...report, samples: undefined }),
|
||||
);
|
||||
expect(report.entered).toBe(true);
|
||||
expect(report.fallen).toBeNull();
|
||||
expect(report.completed).toBe(true);
|
||||
expect(report.finalFallen).toBe(false);
|
||||
expect(report.maxStep).toBeLessThan(0.15);
|
||||
expect(report.minHeight).toBeGreaterThan(0.4);
|
||||
expect(report.forwardAfter).toBeGreaterThan(0.4);
|
||||
expect(report.maxFrame).toBeGreaterThanOrEqual(report.duration * 50 - 2);
|
||||
expect(report.stats.longestSaturatedSeconds).toBeLessThan(0.5);
|
||||
}
|
||||
await page.screenshot({ path: info.outputPath(`${skill}.png`) });
|
||||
});
|
||||
}
|
||||
|
||||
test("trained skill keyboard activation, pause freezes reference, movement interrupts, reset clears", async ({
|
||||
page,
|
||||
}) => {
|
||||
await boot(page);
|
||||
for (const [skill, key] of [
|
||||
["wave", "KeyH"],
|
||||
["dance", "KeyJ"],
|
||||
]) {
|
||||
await page.evaluate(async () => {
|
||||
const r = window.rl;
|
||||
await r.resetSim();
|
||||
await r.step(100);
|
||||
r.resume();
|
||||
});
|
||||
await page
|
||||
.locator("canvas")
|
||||
.first()
|
||||
.click({ position: { x: 700, y: 600 } });
|
||||
await page.keyboard.press(key);
|
||||
await expect
|
||||
.poll(() => page.evaluate(() => window.rl.policyState.state))
|
||||
.not.toBe("walk");
|
||||
await page.evaluate(async () => {
|
||||
await window.rl.pause();
|
||||
await window.rl.step(45);
|
||||
});
|
||||
expect(await page.evaluate(() => window.rl.activePolicy)).toBe(skill);
|
||||
const paused = await page.evaluate(() => ({
|
||||
time: window.rl.data.time,
|
||||
frame: window.rl.referenceFrame,
|
||||
}));
|
||||
await page.waitForTimeout(250);
|
||||
expect(
|
||||
await page.evaluate(() => ({
|
||||
time: window.rl.data.time,
|
||||
frame: window.rl.referenceFrame,
|
||||
})),
|
||||
).toEqual(paused);
|
||||
const result = await page.evaluate(async () => {
|
||||
const r = window.rl;
|
||||
r.command.set([0.4, 0, 0]);
|
||||
await r.step(1);
|
||||
const interrupted = {
|
||||
active: r.activePolicy,
|
||||
state: r.policyState.state,
|
||||
};
|
||||
await r.step(100);
|
||||
return { interrupted, state: r.policyState.state, fallen: r.fallen };
|
||||
});
|
||||
expect(result.interrupted).toEqual({ active: "walk", state: "returning" });
|
||||
expect(result.state).toBe("walk");
|
||||
expect(result.fallen).toBe(false);
|
||||
await page.keyboard.press("Space");
|
||||
await expect.poll(() => page.evaluate(() => window.rl.data.time)).toBe(0);
|
||||
expect(await page.evaluate(() => window.rl.referenceFrame)).toBeNull();
|
||||
expect(
|
||||
await page.evaluate(() =>
|
||||
Array.from(window.rl.lastAction).every((v) => v === 0),
|
||||
),
|
||||
).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
test("repeated real skills restart reference at zero without resetting the robot", async ({
|
||||
page,
|
||||
}, info) => {
|
||||
await boot(page);
|
||||
const report = await page.evaluate(async () => {
|
||||
const r = window.rl,
|
||||
episodes = [];
|
||||
await r.step(100);
|
||||
for (const skill of ["wave", "dance", "wave", "dance"]) {
|
||||
r.command.fill(0);
|
||||
await r.step(100);
|
||||
if (!r.policyState.request(skill, r.data.time))
|
||||
throw new Error("request refused");
|
||||
let firstFrame = null,
|
||||
lastFrame = null,
|
||||
entered = false,
|
||||
complete = false;
|
||||
const duration = r.policyState.episodes.get(skill).duration;
|
||||
for (let i = 0; i < (duration + 7) * 50; i++) {
|
||||
await r.step(1);
|
||||
if (r.fallen) throw new Error(`${skill}: fallen at ${r.data.time}`);
|
||||
if (r.activePolicy === skill) {
|
||||
firstFrame ??= r.referenceFrame;
|
||||
lastFrame = r.referenceFrame;
|
||||
entered = true;
|
||||
}
|
||||
if (entered && r.policyState.state === "walk") {
|
||||
complete = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
episodes.push({
|
||||
skill,
|
||||
firstFrame,
|
||||
lastFrame,
|
||||
complete,
|
||||
time: r.data.time,
|
||||
});
|
||||
r.command.set([0.4, 0, 0]);
|
||||
await r.step(50);
|
||||
}
|
||||
return episodes;
|
||||
});
|
||||
await info.attach("repeated-skills.json", {
|
||||
body: JSON.stringify(report),
|
||||
contentType: "application/json",
|
||||
});
|
||||
for (const episode of report) {
|
||||
expect(episode.firstFrame).toBe(0);
|
||||
expect(episode.lastFrame).toBe(episode.skill === "wave" ? 217 : 499);
|
||||
expect(episode.complete).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
test("truncated motion asset rolls back the candidate and permits a clean retry", async ({
|
||||
page,
|
||||
}) => {
|
||||
await allowStaged(page);
|
||||
await page.goto("/");
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Pause", exact: true }),
|
||||
).toBeEnabled();
|
||||
await page.route("**/robots/rp1/motions/wave.f32*", (route) =>
|
||||
route.fulfill({
|
||||
body: Buffer.alloc(8),
|
||||
contentType: "application/octet-stream",
|
||||
}),
|
||||
);
|
||||
const old = await page.evaluate(() => {
|
||||
window.__oldRobotModel = window.rl.model;
|
||||
return window.__store.getState().robotId;
|
||||
});
|
||||
expect(await page.evaluate(() => window.__gameApi.switchRobot("rp1"))).toBe(
|
||||
false,
|
||||
);
|
||||
expect(await page.evaluate(() => window.__store.getState().robotId)).toBe(
|
||||
old,
|
||||
);
|
||||
expect(
|
||||
await page.evaluate(() => window.__store.getState().runtimeError),
|
||||
).toContain("sample count");
|
||||
expect(
|
||||
await page.evaluate(() => window.rl.model === window.__oldRobotModel),
|
||||
).toBe(true);
|
||||
await page.unroute("**/robots/rp1/motions/wave.f32*");
|
||||
expect(await page.evaluate(() => window.__gameApi.switchRobot("rp1"))).toBe(
|
||||
true,
|
||||
);
|
||||
expect(
|
||||
await page.evaluate(() => window.__store.getState().runtimeError),
|
||||
).toBeNull();
|
||||
});
|
||||
@@ -0,0 +1,291 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
async function boot(page) {
|
||||
await page.goto("/");
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Pause", exact: true }),
|
||||
).toBeEnabled();
|
||||
await page.getByLabel("Robot", { exact: true }).selectOption("rp1");
|
||||
await page.waitForFunction(
|
||||
() =>
|
||||
window.__store.getState().robotId === "rp1" ||
|
||||
window.__store.getState().runtimeError,
|
||||
);
|
||||
expect(
|
||||
await page.evaluate(() => window.__store.getState().runtimeError),
|
||||
).toBeNull();
|
||||
await page.evaluate(() => window.rl.pause());
|
||||
}
|
||||
test("third robot: real WASM/ONNX, keyboard command contract, trained skill bindings, fall/reset, switching", async ({
|
||||
page,
|
||||
}, info) => {
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await boot(page);
|
||||
expect(
|
||||
await page.getByLabel("Robot", { exact: true }).locator("option").count(),
|
||||
).toBe(3);
|
||||
expect(await page.evaluate(() => window.rl.buildObs().length)).toBe(243);
|
||||
expect(await page.evaluate(() => window.rl.lastAction.length)).toBe(24);
|
||||
await page
|
||||
.locator("canvas")
|
||||
.first()
|
||||
.click({ position: { x: 700, y: 600 } });
|
||||
await page.evaluate(() => window.rl.resume());
|
||||
await expect(page.getByRole("button", { name: /^J\s*Dance$/ })).toBeEnabled();
|
||||
await expect(page.getByRole("button", { name: /^H\s*Wave$/ })).toBeEnabled();
|
||||
expect(
|
||||
await page
|
||||
.getByRole("complementary", { name: "Keyboard controls" })
|
||||
.innerText(),
|
||||
).not.toMatch(/\p{Script=Han}/u);
|
||||
for (const [key, expected] of [
|
||||
["KeyW", [0.4, 0, 0]],
|
||||
["KeyS", [-0.3, 0, 0]],
|
||||
["KeyA", [0, 0, 0.6]],
|
||||
["KeyD", [0, 0, -0.6]],
|
||||
]) {
|
||||
await page.evaluate(async () => {
|
||||
await window.rl.resetSim();
|
||||
window.rl.resume();
|
||||
});
|
||||
await page.keyboard.down(key);
|
||||
const command = await page.evaluate(() => Array.from(window.rl.command));
|
||||
command.forEach((v, i) => expect(v).toBeCloseTo(expected[i], 5));
|
||||
await page.keyboard.up(key);
|
||||
expect(await page.evaluate(() => Array.from(window.rl.command))).toEqual([
|
||||
0, 0, 0,
|
||||
]);
|
||||
await page.evaluate(() => window.rl.pause());
|
||||
}
|
||||
const report = await page.evaluate(async () => {
|
||||
const r = window.rl,
|
||||
trials = [];
|
||||
for (const [name, command] of [
|
||||
["stand", [0, 0, 0]],
|
||||
["forward", [0.4, 0, 0]],
|
||||
["backward", [-0.3, 0, 0]],
|
||||
["left", [0, 0, 0.6]],
|
||||
["right", [0, 0, -0.6]],
|
||||
]) {
|
||||
await r.resetSim();
|
||||
r.command.set(command);
|
||||
const before = Array.from(r.data.qpos.slice(0, 3));
|
||||
let firstFall = null;
|
||||
for (let i = 0; i < 150; i++) {
|
||||
await r.step(1);
|
||||
if (
|
||||
![
|
||||
...r.data.qpos,
|
||||
...r.data.qvel,
|
||||
...r.data.ctrl,
|
||||
...r.lastAction,
|
||||
].every(Number.isFinite)
|
||||
)
|
||||
throw new Error("non-finite RP1 state");
|
||||
if (r.fallen) {
|
||||
firstFall = r.data.time;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const [w, x, y, z] = r.data.qpos.slice(3, 7);
|
||||
trials.push({
|
||||
name,
|
||||
before,
|
||||
after: Array.from(r.data.qpos.slice(0, 3)),
|
||||
time: r.data.time,
|
||||
yaw: Math.atan2(2 * (w * z + x * y), 1 - 2 * (y * y + z * z)),
|
||||
firstFall,
|
||||
actuation: r.actuationStats,
|
||||
});
|
||||
}
|
||||
return trials;
|
||||
});
|
||||
for (const trial of report) expect(trial.firstFall).toBeNull();
|
||||
expect(report.find((t) => t.name === "forward").after[0]).toBeGreaterThan(
|
||||
0.4,
|
||||
);
|
||||
expect(report.find((t) => t.name === "backward").after[0]).toBeLessThan(-0.3);
|
||||
expect(report.find((t) => t.name === "left").yaw).toBeGreaterThan(0.5);
|
||||
expect(report.find((t) => t.name === "right").yaw).toBeLessThan(-0.5);
|
||||
console.log("RP1 completed-checkpoint trials", JSON.stringify(report));
|
||||
await info.attach("rp1-preview-trials.json", {
|
||||
body: JSON.stringify(report, null, 2),
|
||||
contentType: "application/json",
|
||||
});
|
||||
await page.evaluate(async () => {
|
||||
await window.rl.resetSim();
|
||||
window.rl.data.qpos[2] = 1.2;
|
||||
window.rl.data.qpos.set([Math.SQRT1_2, Math.SQRT1_2, 0, 0], 3);
|
||||
window.rl.mujoco.mj_forward(window.rl.model, window.rl.data);
|
||||
await window.rl.step(1);
|
||||
});
|
||||
expect(await page.evaluate(() => window.rl.fallen)).toBe(true);
|
||||
await page.keyboard.press("Space");
|
||||
await expect.poll(() => page.evaluate(() => window.rl.fallen)).toBe(false);
|
||||
expect(await page.evaluate(() => window.rl.policyState.state)).toBe("walk");
|
||||
await page.screenshot({ path: info.outputPath("rp1.png") });
|
||||
for (const robot of ["microban", "microduck", "rp1"]) {
|
||||
await page.getByLabel("Robot", { exact: true }).selectOption(robot);
|
||||
await expect
|
||||
.poll(() => page.evaluate(() => window.__store.getState().robotId))
|
||||
.toBe(robot === "microduck" ? "microduck-legs" : robot);
|
||||
}
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
|
||||
test("three 25-second bounded RP1 sequences preserve direction and balance; realtime controller stays near 50Hz", async ({
|
||||
page,
|
||||
}, info) => {
|
||||
await boot(page);
|
||||
const report = await page.evaluate(async () => {
|
||||
const r = window.rl,
|
||||
trials = [];
|
||||
const pose = () => {
|
||||
const [w, x, y, z] = r.data.qpos.slice(3, 7);
|
||||
return {
|
||||
pos: Array.from(r.data.qpos.slice(0, 3)),
|
||||
yaw: Math.atan2(2 * (w * z + x * y), 1 - 2 * (y * y + z * z)),
|
||||
};
|
||||
};
|
||||
for (let trial = 0; trial < 3; trial++) {
|
||||
await r.resetSim();
|
||||
const segments = [];
|
||||
for (const [name, seconds, vx, wz] of [
|
||||
["stand", 5, 0, 0],
|
||||
["forward", 3, 0.4, 0],
|
||||
["rest", 2, 0, 0],
|
||||
["backward", 3, -0.3, 0],
|
||||
["rest", 2, 0, 0],
|
||||
["left", 3, 0, 0.6],
|
||||
["rest", 2, 0, 0],
|
||||
["right", 3, 0, -0.6],
|
||||
["rest", 2, 0, 0],
|
||||
]) {
|
||||
const before = pose();
|
||||
r.command.set([vx, 0, wz]);
|
||||
let yaw = 0,
|
||||
previousYaw = before.yaw,
|
||||
minHeight = Infinity;
|
||||
for (let i = 0; i < seconds * 10; i++) {
|
||||
await r.step(5);
|
||||
const p = pose();
|
||||
if (r.fallen)
|
||||
throw new Error(`trial ${trial} ${name}: fallen at ${r.data.time}`);
|
||||
if (Math.max(Math.abs(p.pos[0]), Math.abs(p.pos[1])) > 1.9)
|
||||
throw new Error("unexpected wall approach");
|
||||
yaw += Math.atan2(
|
||||
Math.sin(p.yaw - previousYaw),
|
||||
Math.cos(p.yaw - previousYaw),
|
||||
);
|
||||
previousYaw = p.yaw;
|
||||
minHeight = Math.min(minHeight, p.pos[2]);
|
||||
}
|
||||
const after = pose();
|
||||
segments.push({
|
||||
name,
|
||||
minHeight,
|
||||
yaw,
|
||||
displacement:
|
||||
(after.pos[0] - before.pos[0]) * Math.cos(before.yaw) +
|
||||
(after.pos[1] - before.pos[1]) * Math.sin(before.yaw),
|
||||
});
|
||||
}
|
||||
trials.push({
|
||||
trial,
|
||||
time: r.data.time,
|
||||
segments,
|
||||
actuation: r.actuationStats,
|
||||
});
|
||||
}
|
||||
return trials;
|
||||
});
|
||||
for (const trial of report) {
|
||||
const find = (name) => trial.segments.find((s) => s.name === name);
|
||||
expect(trial.time).toBeCloseTo(25, 5);
|
||||
expect(find("forward").displacement).toBeGreaterThan(0.4);
|
||||
expect(find("backward").displacement).toBeLessThan(-0.3);
|
||||
expect(find("left").yaw).toBeGreaterThan(0.5);
|
||||
expect(find("right").yaw).toBeLessThan(-0.5);
|
||||
expect(trial.actuation.longestSaturatedSeconds).toBeLessThan(0.5);
|
||||
}
|
||||
await info.attach("rp1-three-sequences.json", {
|
||||
body: JSON.stringify(report, null, 2),
|
||||
contentType: "application/json",
|
||||
});
|
||||
await page.evaluate(async () => {
|
||||
await window.rl.resetSim();
|
||||
window.rl.resume();
|
||||
});
|
||||
const first = await page.evaluate(() => ({
|
||||
sim: window.rl.data.time,
|
||||
wall: performance.now(),
|
||||
}));
|
||||
await page.waitForTimeout(4000);
|
||||
const second = await page.evaluate(() => ({
|
||||
sim: window.rl.data.time,
|
||||
wall: performance.now(),
|
||||
fallen: window.rl.fallen,
|
||||
}));
|
||||
const ratio = (second.sim - first.sim) / ((second.wall - first.wall) / 1000);
|
||||
expect(second.fallen).toBe(false);
|
||||
expect(ratio).toBeGreaterThan(0.8);
|
||||
expect(ratio).toBeLessThan(1.15);
|
||||
await info.attach("rp1-realtime.json", {
|
||||
body: JSON.stringify({ first, second, ratio }),
|
||||
contentType: "application/json",
|
||||
});
|
||||
});
|
||||
|
||||
test("episodic ONNX lifecycle is exclusive and resets on return (walk reused as interface fixture, NOT a dance policy)", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.route("**/robots/rp1/robot.json*", async (route) => {
|
||||
const response = await route.fetch(),
|
||||
config = await response.json();
|
||||
const skill = config.skills.find((s) => s.id === "dance");
|
||||
Object.assign(skill, {
|
||||
available: true,
|
||||
duration: 0.8,
|
||||
blend: 0.2,
|
||||
observations: config.observations,
|
||||
actions: config.actions,
|
||||
defaults: config.joints.defaults,
|
||||
});
|
||||
delete skill.reference;
|
||||
skill.controller.policy = "policies/walk.onnx";
|
||||
config.input.bindings.find((b) => b.action === "skill:dance").disabled =
|
||||
false;
|
||||
await route.fulfill({ response, json: config });
|
||||
});
|
||||
await boot(page);
|
||||
const report = await page.evaluate(async () => {
|
||||
const r = window.rl;
|
||||
await r.resetSim();
|
||||
if (!r.policyState.request("dance", r.data.time))
|
||||
throw new Error("request refused");
|
||||
await r.step(23); // Real zero-command locomotion must satisfy the stop gate.
|
||||
const first = { active: r.activePolicy, state: r.policyState.state };
|
||||
await r.step(65);
|
||||
const returned = { active: r.activePolicy, state: r.policyState.state };
|
||||
r.policyState.request("dance", r.data.time);
|
||||
await r.step(23);
|
||||
r.command.set([0.4, 0, 0]);
|
||||
await r.step(1);
|
||||
const interrupted = { active: r.activePolicy, state: r.policyState.state };
|
||||
await r.step(12);
|
||||
return {
|
||||
first,
|
||||
returned,
|
||||
interrupted,
|
||||
active: r.activePolicy,
|
||||
state: r.policyState.state,
|
||||
fallen: r.fallen,
|
||||
};
|
||||
});
|
||||
expect(report.first).toEqual({ active: "dance", state: "entering" });
|
||||
expect(report.returned).toEqual({ active: "walk", state: "walk" });
|
||||
expect(report.interrupted).toEqual({ active: "walk", state: "returning" });
|
||||
expect(report.active).toBe("walk");
|
||||
expect(report.state).toBe("walk");
|
||||
expect(report.fallen).toBe(false);
|
||||
});
|
||||
@@ -41,7 +41,7 @@ test("20 robot transitions release old WASM objects and plateau scene/GPU/listen
|
||||
await page.evaluate(() => window.__gameApi.pause());
|
||||
const measurements = [];
|
||||
for (let i = 0; i < 20; i++) {
|
||||
const id = i % 2 === 0 ? "microban" : "microduck-legs";
|
||||
const id = ["microban", "microduck-legs", "rp1"][i % 3];
|
||||
console.log(`Ownership transition ${i + 1}/20: ${id}`);
|
||||
const sample = await page.evaluate(async (id) => {
|
||||
const model = window.rl.model,
|
||||
@@ -65,8 +65,9 @@ test("20 robot transitions release old WASM objects and plateau scene/GPU/listen
|
||||
measurements.push(sample);
|
||||
}
|
||||
const duck = measurements.filter((s) => s.id === "microduck-legs"),
|
||||
ban = measurements.filter((s) => s.id === "microban");
|
||||
for (const samples of [duck, ban]) {
|
||||
ban = measurements.filter((s) => s.id === "microban"),
|
||||
rp1 = measurements.filter((s) => s.id === "rp1");
|
||||
for (const samples of [duck, ban, rp1]) {
|
||||
expect(samples.at(-1).listeners).toBe(samples[0].listeners);
|
||||
expect(samples.at(-1).sceneChildren).toBe(samples[0].sceneChildren);
|
||||
expect(samples.at(-1).memory.geometries).toBeLessThanOrEqual(
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "microduck-sandbox",
|
||||
"version": "0.2.0",
|
||||
"version": "0.4.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "microduck-sandbox",
|
||||
"version": "0.2.0",
|
||||
"version": "0.4.0",
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.14.0",
|
||||
"@emotion/styled": "^11.14.1",
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "microduck-sandbox",
|
||||
"private": true,
|
||||
"version": "0.2.0",
|
||||
"version": "0.4.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -16,5 +16,11 @@
|
||||
"family": "microban",
|
||||
"name": "Microban",
|
||||
"manifest": "microban/robot.json"
|
||||
},
|
||||
{
|
||||
"id": "rp1",
|
||||
"family": "rp1",
|
||||
"name": "RP1",
|
||||
"manifest": "rp1/robot.json"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -11,4 +11,12 @@ The precise origin remote, HEAD, dirty-worktree flag, per-file SHA-256 and behav
|
||||
|
||||
Browser adaptations (not edits to the copied XML): 0.005 s physics timestep; separate flat ground; explicit 18-joint policy order excluding head; body-frame gravity and IMU-site gyroscope following source observation semantics; limited joint-PD torque control instead of BAM. Default PD kp=0.3 Nm/rad, kd=0.02 Nm·s/rad, torque limit=0.65 Nm are experimentally selected simplified parameters, not metadata gains and not a claim of hardware equivalence.
|
||||
|
||||
## Textured visual replacement
|
||||
|
||||
`visuals/*.glb` are the 20 files copied byte-for-byte from the user-supplied `microban2.zip`, replacing the earlier `microban.zip` visual export, not from the upstream checkout above. They retain their embedded PBR materials and 46 textures (45 normal maps and one screen base-colour image, all 1024 × 1024). The archive contains no license notice; **confirm public redistribution rights with the asset owner** rather than assuming the upstream model license covers these replacements. Archive and file SHA-256 values are recorded separately in `visual-source-manifest.json`.
|
||||
|
||||
Reimport with `python3 app/scripts/import-microban-visuals.py /path/to/microban2.zip`. This does not change `model.xml`, the original STL files, policy, original source manifest or the reviewed `render.body_visuals` mapping in `robot.json`.
|
||||
|
||||
The GLBs have different local frames from the original MJCF. `robot.json` records fixed, visual-only rigid transforms (metres and xyzw quaternions), checked against the original per-body geometry; body-local bounding-box endpoint differences are at most 3.01 mm, allowing the replacement's added details. Mapping: BASE → trunk; LINK1 → head; LINK2–4 → right arm; LINK5–7 → left arm; LINK8–13 → left leg; LINK14–19 → right leg. Vertex positions and node transforms in all 20 GLBs are unchanged from the previous visual export, so the existing body registration is retained. Runtime follows the existing MuJoCo body poses and hides only the replaced visual geoms; collisions, inertias, joints, policy inputs and actuation are untouched. This is geometric registration, not a claim that the archive supplied authoritative joint-frame metadata.
|
||||
|
||||
No Placo, real-robot control, source Python code, CAD project, BAM battery model or communication delays are bundled into the browser runtime.
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"name": "Microban",
|
||||
"family": "microban",
|
||||
"adapter": "generic",
|
||||
"dimensions": { "height": 0.33 },
|
||||
"model": "model.xml",
|
||||
"assets": [
|
||||
{
|
||||
@@ -314,6 +315,119 @@
|
||||
},
|
||||
"render": {
|
||||
"source": "mjcf_visual",
|
||||
"body_visuals": [
|
||||
{
|
||||
"body": "trunk",
|
||||
"path": "visuals/BASE__visual_0__BASE.glb",
|
||||
"quaternion": [0.7071067811865476, 0, 0, 0.7071067811865476]
|
||||
},
|
||||
{
|
||||
"body": "head",
|
||||
"path": "visuals/LINK1__visual_0__LINK1.glb",
|
||||
"quaternion": [0.5, -0.5, -0.5, 0.5]
|
||||
},
|
||||
{
|
||||
"body": "shoulder",
|
||||
"path": "visuals/LINK2__visual_0__LINK2.glb"
|
||||
},
|
||||
{
|
||||
"body": "humerus__configuration_right",
|
||||
"path": "visuals/LINK3__visual_0__LINK3.glb",
|
||||
"position": [0, 0, -0.02755],
|
||||
"quaternion": [0, -0.7071067811865476, 0, 0.7071067811865476]
|
||||
},
|
||||
{
|
||||
"body": "radius",
|
||||
"path": "visuals/LINK4__visual_0__LINK4.glb",
|
||||
"position": [-0.00529885, -0.00021476, 0.00145]
|
||||
},
|
||||
{
|
||||
"body": "shoulder_2",
|
||||
"path": "visuals/LINK5__visual_0__LINK5.glb"
|
||||
},
|
||||
{
|
||||
"body": "humerus__configuration_left",
|
||||
"path": "visuals/LINK6__visual_0__LINK6.glb",
|
||||
"position": [-0.00529885, -0.00021476, -0.02755],
|
||||
"quaternion": [0.7071067811865476, 0, -0.7071067811865476, 0]
|
||||
},
|
||||
{
|
||||
"body": "radius_2",
|
||||
"path": "visuals/LINK7__visual_0__LINK7.glb",
|
||||
"position": [-0.00529885, 0.00021476, -0.00145],
|
||||
"quaternion": [0, 0, 1, 0]
|
||||
},
|
||||
{
|
||||
"body": "hip_2",
|
||||
"path": "visuals/LINK8__visual_0__LINK8.glb",
|
||||
"quaternion": [0, 0.7071067811865476, 0.7071067811865476, 0]
|
||||
},
|
||||
{
|
||||
"body": "hip_block__configuration_left",
|
||||
"path": "visuals/LINK9__visual_0__LINK9.glb",
|
||||
"position": [0, 0, 0.00027893],
|
||||
"quaternion": [0.7071067811865476, 0, 0.7071067811865476, 0]
|
||||
},
|
||||
{
|
||||
"body": "femur__configuration_left",
|
||||
"path": "visuals/LINK10__visual_0__LINK10.glb",
|
||||
"position": [0, 0, -0.00145],
|
||||
"quaternion": [1, 0, 0, 0]
|
||||
},
|
||||
{
|
||||
"body": "tibia__configuration_left",
|
||||
"path": "visuals/LINK11__visual_0__LINK11.glb",
|
||||
"position": [0, 0, -0.00145],
|
||||
"quaternion": [1, 0, 0, 0]
|
||||
},
|
||||
{
|
||||
"body": "ankle_block__configuration_right",
|
||||
"path": "visuals/LINK12__visual_0__LINK12.glb",
|
||||
"position": [0, 0, -0.00145],
|
||||
"quaternion": [0, 1, 0, 0]
|
||||
},
|
||||
{
|
||||
"body": "foot_2",
|
||||
"path": "visuals/LINK13__visual_0__LINK13.glb",
|
||||
"position": [0, 0, 0.0008],
|
||||
"quaternion": [0, -0.7071067811865476, 0, 0.7071067811865476]
|
||||
},
|
||||
{
|
||||
"body": "hip",
|
||||
"path": "visuals/LINK14__visual_0__LINK14.glb",
|
||||
"quaternion": [0.7071067811865476, 0, 0, 0.7071067811865476]
|
||||
},
|
||||
{
|
||||
"body": "hip_block__configuration_right",
|
||||
"path": "visuals/LINK15__visual_0__LINK15.glb",
|
||||
"position": [0, 0, 0.0008],
|
||||
"quaternion": [0.7071067811865476, 0, 0.7071067811865476, 0]
|
||||
},
|
||||
{
|
||||
"body": "femur__configuration_right",
|
||||
"path": "visuals/LINK16__visual_0__LINK16.glb",
|
||||
"position": [0, 0, -0.02755],
|
||||
"quaternion": [0, 1, 0, 0]
|
||||
},
|
||||
{
|
||||
"body": "tibia__configuration_right",
|
||||
"path": "visuals/LINK17__visual_0__LINK17.glb",
|
||||
"position": [0, 0, -0.02745],
|
||||
"quaternion": [0, 1, 0, 0]
|
||||
},
|
||||
{
|
||||
"body": "ankle_block__configuration_left",
|
||||
"path": "visuals/LINK18__visual_0__LINK18.glb",
|
||||
"position": [0, 0, -0.02755],
|
||||
"quaternion": [1, 0, 0, 0]
|
||||
},
|
||||
{
|
||||
"body": "foot",
|
||||
"path": "visuals/LINK19__visual_0__LINK19.glb",
|
||||
"position": [0, 0, 0.0008],
|
||||
"quaternion": [0, -0.7071067811865476, 0, 0.7071067811865476]
|
||||
}
|
||||
],
|
||||
"groups": [
|
||||
2
|
||||
],
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
{
|
||||
"source": "User-provided microban2.zip (textured visual replacement)",
|
||||
"archive_sha256": "dfb20a34103afecdc7996cc5ac9f6a61705560717f9c6aac420f3d6307d3e6d4",
|
||||
"license": "Not supplied in the archive; confirm redistribution rights with the asset owner.",
|
||||
"files": [
|
||||
{
|
||||
"file": "visuals/BASE__visual_0__BASE.glb",
|
||||
"sha256": "32cc5d7df7ab62779cb61ae777dafe485fc357489998020fba86e2bb94d968a6"
|
||||
},
|
||||
{
|
||||
"file": "visuals/LINK1__visual_0__LINK1.glb",
|
||||
"sha256": "33f7776ad30bc04fb0a93a1a80641636d5cca382c12093bf97df9d9cd1416553"
|
||||
},
|
||||
{
|
||||
"file": "visuals/LINK2__visual_0__LINK2.glb",
|
||||
"sha256": "ffbdd241b96d8e9d371bbddb57908912e95edb4c7ce88e9e20a79c663f80058f"
|
||||
},
|
||||
{
|
||||
"file": "visuals/LINK3__visual_0__LINK3.glb",
|
||||
"sha256": "01718a43c6b8936543c6c2e47b00150907c7ac7c892c90f9d612a21d6fc566b9"
|
||||
},
|
||||
{
|
||||
"file": "visuals/LINK4__visual_0__LINK4.glb",
|
||||
"sha256": "7dad340b731e9f5ed8fe37bc77dd2b7b5ff1ac540cc501dad35b487438ab4e0d"
|
||||
},
|
||||
{
|
||||
"file": "visuals/LINK5__visual_0__LINK5.glb",
|
||||
"sha256": "aa54506ab2503ac34cb4d8240772798d353f72a04b81224543b9347df38a68ba"
|
||||
},
|
||||
{
|
||||
"file": "visuals/LINK6__visual_0__LINK6.glb",
|
||||
"sha256": "2bed471a7c3e51107d5307130c342696b3e986384584c4891b4b7a161380aeb4"
|
||||
},
|
||||
{
|
||||
"file": "visuals/LINK7__visual_0__LINK7.glb",
|
||||
"sha256": "909cc20e48dad6dd8478c8dd19499ffc49c8427305ead62e1b267ae8a3939d9e"
|
||||
},
|
||||
{
|
||||
"file": "visuals/LINK8__visual_0__LINK8.glb",
|
||||
"sha256": "d2a43a6606906fd8bd8a982208ea2121245969bded44a3f81ee074e1968c5abf"
|
||||
},
|
||||
{
|
||||
"file": "visuals/LINK9__visual_0__LINK9.glb",
|
||||
"sha256": "33f34ba76488c0dfe99bcf80bb48ff3ba0c0240e506a79203d380e20aa17f952"
|
||||
},
|
||||
{
|
||||
"file": "visuals/LINK10__visual_0__LINK10.glb",
|
||||
"sha256": "4bf30a00a35ec588a74476cefc6cff79b14f16ebf8136a55ab8392c8b2b5a6be"
|
||||
},
|
||||
{
|
||||
"file": "visuals/LINK11__visual_0__LINK11.glb",
|
||||
"sha256": "04e8b462a92a6689074211bc1243a28bd031148c6f390cf00d9af977e33d4616"
|
||||
},
|
||||
{
|
||||
"file": "visuals/LINK12__visual_0__LINK12.glb",
|
||||
"sha256": "e1549141dbd462ef4aa31be2f5bb8ae2f31a0d0b49da3de41911ef482c008cd7"
|
||||
},
|
||||
{
|
||||
"file": "visuals/LINK13__visual_0__LINK13.glb",
|
||||
"sha256": "ded693e8bc53cdda7ac36b5f4d49c56391eaa283f6549872e2eeaa33d0b43afd"
|
||||
},
|
||||
{
|
||||
"file": "visuals/LINK14__visual_0__LINK14.glb",
|
||||
"sha256": "03f70f51f86a4eb67b069629ed89576cae71910f903d34638dc8fd5fc8b9bb4d"
|
||||
},
|
||||
{
|
||||
"file": "visuals/LINK15__visual_0__LINK15.glb",
|
||||
"sha256": "87202389c4bc6dade765d805f399f8577add3c2b3a10a317264dbe4e4e99f54d"
|
||||
},
|
||||
{
|
||||
"file": "visuals/LINK16__visual_0__LINK16.glb",
|
||||
"sha256": "eb8a287ca42899b728973690352974a9351fcbc7a7f9e7e632376f4aebdad3d0"
|
||||
},
|
||||
{
|
||||
"file": "visuals/LINK17__visual_0__LINK17.glb",
|
||||
"sha256": "1f942e545727ce342c97827f06d33d6ab8186120ea6dbcf36369eb2b4e3e54e5"
|
||||
},
|
||||
{
|
||||
"file": "visuals/LINK18__visual_0__LINK18.glb",
|
||||
"sha256": "808675acb0fddbbacdbed43ad71de1df7ffd0b898a8bf7814098cbe7d1d1ad29"
|
||||
},
|
||||
{
|
||||
"file": "visuals/LINK19__visual_0__LINK19.glb",
|
||||
"sha256": "b00cec2f4a0924efd7805f405ab0bb103e1ecdf1d56310caa3c275c7ef0a7c1b"
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -4,6 +4,7 @@
|
||||
"name": "Microduck",
|
||||
"family": "microduck",
|
||||
"adapter": "microduck",
|
||||
"dimensions": { "height": 0.27 },
|
||||
"model": "../../robot/mjlab/robot_allcollisions.xml",
|
||||
"assets": [],
|
||||
"base": {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"name": "Microduck",
|
||||
"family": "microduck",
|
||||
"adapter": "microduck",
|
||||
"dimensions": { "height": 0.27 },
|
||||
"model": "../../robot/mjlab/robot_allcollisions_rollers.xml",
|
||||
"assets": [],
|
||||
"base": {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
Copyright (c) 2022-2025, The Isaac Lab Project Developers.
|
||||
Copyright (c) 2025-2026, The RoboLab Project Developers.
|
||||
All rights reserved.
|
||||
|
||||
SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -0,0 +1,37 @@
|
||||
# RP1 local-evaluation package
|
||||
|
||||
## Inputs and provenance
|
||||
|
||||
- Training repository: `/home/cen/Embodied_Workspace/Mujoco_Projects/roboparty_train`.
|
||||
- Model/meshes: `robolab/data/robots/roboparty/rp1`, upstream `https://github.com/Roboparty/rp1_description`, commit `d8c6dd03aeecc7f7ead3d962e09fedba4c8460f0` (clean asset worktree at original import).
|
||||
- Input MJCF: `mjcf/robot_24dof.xml`; `compiler.meshdir` changes from `../` to `.` for package-relative VFS loading. XML is reserialized. Bodies, inertias, primitive collision geometry, motors, sensors and mesh bytes are retained.
|
||||
- Walk: final `rp1_24dof_flat/2026-10-28_15-47-49/model_9000.pt` (9001 configured iterations).
|
||||
- Dance: resumed final `rp1_24dof_beyondmimic_dance/2026-10-29_11-05-14_dance_resume/model_23998.pt` (starts from iteration 7999, adds 16000 iterations; final 23998).
|
||||
- Wave: final `rp1_24dof_beyondmimic_wave/2026-10-28_19-00-23_wave/model_7999.pt` (8000 iterations).
|
||||
- Importers do not launch/stop training or modify the training repository. Completed iterations do not establish convergence, arbitrary-duration stability or hardware safety.
|
||||
- Logged `params/env.yaml` and `params/agent.yaml` determine actual actor branch, terms, joint order, defaults, actuator contract and network. `source-manifest.json` records checkpoint/config/motion/resource SHA-256 and export error.
|
||||
|
||||
## Deterministic exports
|
||||
|
||||
`app/scripts/import-rp1.py` exports walking, ELU MLP `243→512→256→128→24`, including empirical normalization `(obs - mean) / (std + 0.01)` and runner ±100 action clip. Three term-major history frames follow training joint order. First sample backfills history; reset/skill entry clears it. PyTorch/ONNX max absolute error: approximately **1.55e-6**.
|
||||
|
||||
`app/scripts/import-rp1-motion.py` exports dance/wave, ELU MLP `126→512→256→128→24`, including empirical normalization and no additional action clip (runner clip is null). Logged actor branch is **student**, not the privileged policy observation group. Inputs are reference joint positions/velocities (48), gyro (3), projected gravity (3), relative joint positions (24), joint velocities (24), last actor action (24). Each skill uses its own trained defaults and last action. The distribution and critic are not deployed. PyTorch/ONNX max errors: dance **1.31e-6**, wave **1.91e-6**.
|
||||
|
||||
Actions are reference-pose-relative joint targets, scale `0.25`. Named gains, torque caps and four-quadrant motor torque-speed limits are preserved. Browser intentionally omits training-time random actuator delays (0–2 physics steps), randomized physics/default positions, external pushes and observation noise. It is not an exact reproduction of Newton/MJWarp training or hardware motor control.
|
||||
|
||||
## Motion references and deployed limits
|
||||
|
||||
Source archives under `robolab/data/motions/rp1_bm/`:
|
||||
|
||||
- `dance1_subject2_smooth6hz.npz`: 6573 frames at 50 fps, 131.46 s total. **Only the validated first 10 s are enabled.** The previous 7999 checkpoint fell at frame 994 (~19.9 s) in a full-clip rollout. The updated 23998 checkpoint has been qualified for the 10 s prefix only; full continuous playback has not been requalified.
|
||||
- `wave_R_001__A428.npz`: 218 frames at 50 fps, full 4.36 s enabled.
|
||||
|
||||
`.json` reference descriptors plus little-endian `.f32` files contain joint position/velocity commands in logged joint order. Motion command time advances one frame per 50 Hz control tick, freezes on pause and resets at activation. Reference end clamps; there is no random resampling or wrapping. References only supply policy observations: they do not teleport the root, set kinematic joint poses, or replace trained actions with scripted animation.
|
||||
|
||||
Both skills use exclusive full-body policies, a physical stop gate, entry/return blends and locomotion interruption. Validation includes three initial headings, walking before/after, repeated episodes without robot reset, keyboard/pause/reset, numerical reference checks and malformed-asset rollback. Initial integration: `docs/superpowers/verification/2026-10-29-rp1-completed-skills.md`; current dance weights: `docs/superpowers/verification/2026-10-29-rp1-dance-23998.md`. UI labels are simply `Dance` and `Wave`; durations and transition behavior remain unchanged.
|
||||
|
||||
## License limitation — local evaluation only
|
||||
|
||||
The RP1 description submodule does not supply a license file in this checkout. Do **not** infer an Apache/BSD license for its meshes/model or motion data from the platform or RoboLab. Confirm upstream rights before redistributing this package or deploying publicly.
|
||||
|
||||
`LICENSES/RoboLab-BSD-3-Clause.txt` preserves RoboLab's code notice; it does not grant rights to separately sourced RP1 description assets, motion recordings/retargeting data or the user's checkpoints. Training-code, model, checkpoint and motion provenance must be reviewed independently for redistribution. No public deployment was performed.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,282 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<mujoco model="rp1">
|
||||
<compiler angle="radian" meshdir="." autolimits="true" eulerseq="zyx" balanceinertia="true" />
|
||||
<option timestep="0.005" integrator="implicitfast" iterations="100" solver="Newton" gravity="0 0 -9.81">
|
||||
<flag frictionloss="enable" />
|
||||
</option>
|
||||
<size memory="32M" />
|
||||
<default>
|
||||
<default class="RP1">
|
||||
<joint damping="0.01" frictionloss="0.1" armature="0.01" />
|
||||
<default class="visual">
|
||||
<geom type="mesh" contype="0" conaffinity="0" group="2" />
|
||||
</default>
|
||||
<default class="collision">
|
||||
<geom group="3" condim="4" contype="1" conaffinity="1" solref="0.01 1" friction="0.9 0.2 0.2" />
|
||||
</default>
|
||||
</default>
|
||||
</default>
|
||||
<worldbody>
|
||||
<body name="base_link" pos="0 0 0.78" quat="1 0 0 0" childclass="RP1">
|
||||
<site name="imu" size="0.01" pos="0.0 0 0.0" />
|
||||
<freejoint name="base_link_freejoint" />
|
||||
<inertial pos="-0.03786057 -0.00301243 -0.04479345" mass="3.295" fullinertia="0.00960796 0.00699457 0.00815508 0.00000112 -0.00015116 -0.00000270" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="base_link" material="base_link_material" />
|
||||
|
||||
<body name="left_hip_pitch_link" pos="-0.03843 0.062987 -0.051639" quat="1 0 0 0">
|
||||
<joint axis="0 1 0" name="left_hip_pitch_joint" type="hinge" range="-2.86 2.86" armature="0.0290856" />
|
||||
<inertial pos="-0.00326988 0.05886633 -0.05765170" mass="1.83930168" fullinertia="0.00338343 0.00286182 0.00254132 0.00000610 -0.00000685 0.00030016" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="left_hip_pitch_link" material="left_hip_pitch_material" />
|
||||
<geom name="left_hip_pitch_collision" type="capsule" class="collision" size="0.04970" fromto="-0.01122 0.06756 -0.06890 -0.01122 0.05070 -0.01118" />
|
||||
<body name="left_hip_roll_link" pos="0.031915 0.061254 -0.060672" quat="1 0 0 0">
|
||||
<joint axis="1 0 0" name="left_hip_roll_joint" type="hinge" range="-0.74 2.6" armature="0.0290856" />
|
||||
<inertial pos="-0.00518991 -0.00003499 -0.08084106" mass="1.473" fullinertia="0.00376408 0.00382823 0.00192275 0.00000313 -0.00065554 -0.00000256" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="left_hip_roll_link" material="left_hip_roll_material" />
|
||||
<geom name="left_hip_roll_collision" type="capsule" class="collision" size="0.05622" fromto="-0.01270 0 -0.07578 -0.01270 0 -0.00658" />
|
||||
<body name="left_hip_yaw_link" pos="-0.012698 0 -0.129" quat="1 0 0 0">
|
||||
<joint axis="0 0 -1" name="left_hip_yaw_joint" type="hinge" range="-2.76 2.76" armature="0.00884" />
|
||||
<inertial pos="-0.01959270 -0.00023200 -0.12376414" mass="2.483" fullinertia="0.01126838 0.01225761 0.00388513 0.00001684 -0.00196020 0.00002442" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="left_hip_yaw_link" material="left_hip_yaw_material" />
|
||||
<geom name="left_hip_yaw_collision" type="capsule" class="collision" size="0.05622" fromto="-0.03046 0 -0.16235 -0.00001 0 -0.05622" />
|
||||
<body name="left_knee_link" pos="-0.033201 -0.030809 -0.16509" quat="1 0 0 0">
|
||||
<joint axis="0 -1 0" name="left_knee_joint" type="hinge" range="-2.83 0.06" armature="0.0290856" />
|
||||
<inertial pos="0.03105182 0.03046366 -0.13362250" mass="2.557" fullinertia="0.01819333 0.01828843 0.00291276 -0.00006969 -0.00019845 0.00002464" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="left_knee_link" material="left_knee_material" />
|
||||
<geom name="left_knee_upper_collision" type="capsule" class="collision" size="0.0520" fromto="0.0330 0.03081 -0.1450 0.0030 0.03081 -0.0040" />
|
||||
<geom name="left_knee_lower_collision" type="capsule" class="collision" size="0.0405" fromto="0.0270 0.03081 -0.2780 0.0330 0.03081 -0.1850" />
|
||||
<body name="left_ankle_pitch_link" pos="0.03131 0.030811 -0.30533" quat="1 0 0 0">
|
||||
<joint axis="0 1 0" name="left_ankle_pitch_joint" type="hinge" range="-0.78 0.61" armature="0.006266268" frictionloss="0.1" />
|
||||
<inertial pos="0.00126332 0.00000000 -0.01319163" mass="0.16605731" fullinertia="0.00003624 0.00004292 0.00002407 0.00000000 0.00000148 0.00000000" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="left_ankle_pitch_link" material="left_ankle_pitch_material" />
|
||||
<geom name="left_ankle_pitch_collision" type="capsule" class="collision" size="0.02150" fromto="-0.00145 0 -0.00614 0.00959 0 -0.01051" />
|
||||
<body name="left_ankle_roll_link" pos="0.013067 0 -0.018922" quat="1 0 0 0">
|
||||
<joint axis="0.999993677858222 0 0.00355587451777954" name="left_ankle_roll_joint" type="hinge" range="-0.26 0.26" armature="0.006266268" frictionloss="0.1" />
|
||||
<inertial pos="0.008711 -0.000002 -0.021633" mass="0.6430" fullinertia="0.000361 0.001920 0.002002 0.000000 0.000123 0.000000" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="left_ankle_roll_link" material="left_ankle_roll_material" />
|
||||
<geom name="left_foot_toe_neg_collision" type="capsule" class="collision" size="0.01" fromto="0.03 -0.03 -0.035 0.09 -0.03 -0.035" />
|
||||
<geom name="left_foot_outer_neg_collision" type="capsule" class="collision" size="0.01" fromto="-0.065 -0.02 -0.035 0.11 -0.02 -0.035" />
|
||||
<geom name="left_foot_inner_neg_collision" type="capsule" class="collision" size="0.01" fromto="-0.0775 -0.01 -0.035 0.1225 -0.01 -0.035" />
|
||||
<geom name="left_foot_center_collision" type="capsule" class="collision" size="0.01" fromto="-0.0825 0 -0.035 0.1275 0 -0.035" />
|
||||
<geom name="left_foot_inner_pos_collision" type="capsule" class="collision" size="0.01" fromto="-0.0775 0.01 -0.035 0.1225 0.01 -0.035" />
|
||||
<geom name="left_foot_outer_pos_collision" type="capsule" class="collision" size="0.01" fromto="-0.065 0.02 -0.035 0.11 0.02 -0.035" />
|
||||
<geom name="left_foot_toe_pos_collision" type="capsule" class="collision" size="0.01" fromto="0.03 0.03 -0.035 0.09 0.03 -0.035" />
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
|
||||
<body name="right_hip_pitch_link" pos="-0.03843 -0.069013 -0.051639" quat="1 0 0 0">
|
||||
<joint axis="0 -1 0" name="right_hip_pitch_joint" type="hinge" range="-2.86 2.86" armature="0.0290856" />
|
||||
<inertial pos="-0.00326831 -0.05867998 -0.05764945" mass="1.84174869" fullinertia="0.00339042 0.00287691 0.00253348 0.00000130 -0.00000978 -0.00029218" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="right_hip_pitch_link" material="right_hip_pitch_material" />
|
||||
<geom name="right_hip_pitch_collision" type="capsule" class="collision" size="0.04970" fromto="-0.01122 -0.06756 -0.06890 -0.01122 -0.05070 -0.01118" />
|
||||
<body name="right_hip_roll_link" pos="0.031915 -0.061254 -0.060672" quat="1 0 0 0">
|
||||
<joint axis="1 0 0" name="right_hip_roll_joint" type="hinge" range="-2.6 0.74" armature="0.0290856" />
|
||||
<inertial pos="-0.00518991 -0.00003499 -0.08084106" mass="1.473" fullinertia="0.00376408 0.00382823 0.00192275 0.00000313 -0.00065554 -0.00000256" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="right_hip_roll_link" material="right_hip_roll_material" />
|
||||
<geom name="right_hip_roll_collision" type="capsule" class="collision" size="0.05622" fromto="-0.01270 0 -0.07578 -0.01270 0 -0.00658" />
|
||||
<body name="right_hip_yaw_link" pos="-0.012698 0 -0.129" quat="1 0 0 0">
|
||||
<joint axis="0 0 -1" name="right_hip_yaw_joint" type="hinge" range="-2.76 2.76" armature="0.00884" />
|
||||
<inertial pos="-0.01958069 0.00023065 -0.12376565" mass="2.483" fullinertia="0.01132547 0.01225907 0.00383024 -0.00001670 -0.00196009 -0.00002438" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="right_hip_yaw_link" material="right_hip_yaw_material" />
|
||||
<geom name="right_hip_yaw_collision" type="capsule" class="collision" size="0.05622" fromto="-0.03046 0 -0.16235 -0.00001 0 -0.05622" />
|
||||
<body name="right_knee_link" pos="-0.0332010004232152 0.0308089665012395 -0.165090022909223" quat="1 0 0 0">
|
||||
<joint axis="0 1 0" name="right_knee_joint" type="hinge" range="-0.06 2.83" armature="0.0290856" />
|
||||
<inertial pos="0.03115290 -0.03066848 -0.13404559" mass="2.557" fullinertia="0.01802753 0.01813266 0.00288242 0.00006186 -0.00023263 0.00002714" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="right_knee_link" material="right_knee_material" />
|
||||
<geom name="right_knee_upper_collision" type="capsule" class="collision" size="0.0520" fromto="0.0330 -0.03081 -0.1450 0.0030 -0.03081 -0.0040" />
|
||||
<geom name="right_knee_lower_collision" type="capsule" class="collision" size="0.0405" fromto="0.0270 -0.03081 -0.2780 0.0330 -0.03081 -0.1850" />
|
||||
<body name="right_ankle_pitch_link" pos="0.03131 -0.030809 -0.30533" quat="1 0 0 0">
|
||||
<joint axis="0 1 0" name="right_ankle_pitch_joint" type="hinge" range="-0.78 0.61" armature="0.006266268" frictionloss="0.1" />
|
||||
<inertial pos="0.00126328 0.00000000 -0.01319163" mass="0.16605731" fullinertia="0.00003624 0.00004292 0.00002407 0.00000000 0.00000148 0.00000000" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="right_ankle_pitch_link" material="right_ankle_pitch_material" />
|
||||
<geom name="right_ankle_pitch_collision" type="capsule" class="collision" size="0.02150" fromto="-0.00145 0 -0.00614 0.00959 0 -0.01051" />
|
||||
<body name="right_ankle_roll_link" pos="0.013067 0 -0.018922" quat="1 0 0 0">
|
||||
<joint axis="0.999993677858222 0 0.00355587451777984" name="right_ankle_roll_joint" type="hinge" range="-0.26 0.26" armature="0.006266268" frictionloss="0.1" />
|
||||
<inertial pos="0.008711 -0.000002 -0.021633" mass="0.6430" fullinertia="0.000361 0.001920 0.002002 0.000000 0.000123 0.000000" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="right_ankle_roll_link" material="right_ankle_roll_material" />
|
||||
<geom name="right_foot_toe_neg_collision" type="capsule" class="collision" size="0.01" fromto="0.03 -0.03 -0.035 0.09 -0.03 -0.035" />
|
||||
<geom name="right_foot_outer_neg_collision" type="capsule" class="collision" size="0.01" fromto="-0.065 -0.02 -0.035 0.11 -0.02 -0.035" />
|
||||
<geom name="right_foot_inner_neg_collision" type="capsule" class="collision" size="0.01" fromto="-0.0775 -0.01 -0.035 0.1225 -0.01 -0.035" />
|
||||
<geom name="right_foot_center_collision" type="capsule" class="collision" size="0.01" fromto="-0.0825 0 -0.035 0.1275 0 -0.035" />
|
||||
<geom name="right_foot_inner_pos_collision" type="capsule" class="collision" size="0.01" fromto="-0.0775 0.01 -0.035 0.1225 0.01 -0.035" />
|
||||
<geom name="right_foot_outer_pos_collision" type="capsule" class="collision" size="0.01" fromto="-0.065 0.02 -0.035 0.11 0.02 -0.035" />
|
||||
<geom name="right_foot_toe_pos_collision" type="capsule" class="collision" size="0.01" fromto="0.03 0.03 -0.035 0.09 0.03 -0.035" />
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
|
||||
<body name="waist_roll_link" pos="-0.00757994881845658 -0.00301269924435144 0.0529838303646947" quat="1 0 0 0">
|
||||
<joint axis="1 0 0" name="waist_roll_joint" type="hinge" range="-0.7 0.7" armature="0.0290856" />
|
||||
<inertial pos="-0.03058205 0.00004115 -0.00029517" mass="1.53201882" fullinertia="0.00221249 0.00166198 0.00164327 -0.00000117 -0.00000777 -0.00000329" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="waist_roll_link" material="waist_roll_material" />
|
||||
<geom name="waist_roll_neg_y_collision" type="capsule" class="collision" size="0.04164" fromto="-0.03686 -0.01336 -0.01336 -0.03686 -0.01336 0.02536" />
|
||||
<geom name="waist_roll_pos_y_collision" type="capsule" class="collision" size="0.04164" fromto="-0.03686 0.01336 -0.01336 -0.03686 0.01336 0.02536" />
|
||||
<body name="waist_yaw_link" pos="-0.0308449999997339 0 0.0679999999997294" quat="1 0 0 0">
|
||||
<joint axis="0 0 -1" name="waist_yaw_joint" type="hinge" range="-2.91 2.91" armature="0.0290856" />
|
||||
<inertial pos="-0.001424 0.000080 0.128866" mass="8.3430" fullinertia="0.109179 0.092853 0.041145 -0.000027 0.002082 -0.000013" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="waist_yaw_link" material="waist_yaw_material" />
|
||||
<geom name="torso_lower_collision" type="capsule" class="collision" size="0.090" fromto="0.0100 0 0.0394 0.0100 0 0.0800" />
|
||||
<geom name="torso_middle_collision" type="capsule" class="collision" size="0.120" fromto="-0.0244 0 0.1450 -0.0244 0 0.2100" />
|
||||
<geom name="torso_upper_collision" type="capsule" class="collision" size="0.088" fromto="-0.0185 0 0.3350 -0.0185 0 0.33668" />
|
||||
|
||||
<body name="left_shoulder_pitch_link" pos="0 0.116496194698121 0.19848715574272" quat="1 0 0 0">
|
||||
<joint axis="0 0.99619 0.087156" name="left_shoulder_pitch_joint" type="hinge" range="-3.4 2.35" armature="0.00884" />
|
||||
<inertial pos="-0.00227488 0.05877203 -0.01145894" mass="0.82850012" fullinertia="0.00077624 0.00060519 0.00074547 0.00001858 -0.00000678 0.00008598" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="left_shoulder_pitch_link" material="left_shoulder_pitch_material" />
|
||||
<geom name="left_shoulder_pitch_collision" type="capsule" class="collision" size="0.03808" fromto="-0.00326 0.03582 -0.00238 -0.00326 0.06284 -0.01210" />
|
||||
<body name="left_shoulder_roll_link" pos="0.0287432951006891 0.0653494445514435 -0.014608906526987" quat="1 0 0 0">
|
||||
<joint axis="1 0 0" name="left_shoulder_roll_joint" type="hinge" range="-0.47 2.9" armature="0.00313313" />
|
||||
<inertial pos="-0.01613398 0.00000564 -0.06609383" mass="0.76916758" fullinertia="0.00079857 0.00081142 0.00051033 0.00000012 -0.00012702 -0.00000004" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="left_shoulder_roll_link" material="left_shoulder_roll_material" />
|
||||
<geom name="left_shoulder_roll_collision" type="capsule" class="collision" size="0.04000" fromto="-0.01906 0 -0.06800 -0.01906 0 -0.00656" />
|
||||
<body name="left_shoulder_yaw_link" pos="-0.0190574930004302 0 -0.105000039994097" quat="1 0 0 0">
|
||||
<joint axis="0 0 -1" name="left_shoulder_yaw_joint" type="hinge" range="-2.87 2.87" armature="0.00313313" />
|
||||
<inertial pos="0.01447570 -0.00112029 -0.08587480" mass="0.95227320" fullinertia="0.00179605 0.00188468 0.00081430 -0.00000292 0.00031386 -0.00001579" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="left_shoulder_yaw_link" material="left_shoulder_yaw_material" />
|
||||
<geom name="left_shoulder_yaw_collision" type="capsule" class="collision" size="0.04008" fromto="0.01816 0.00008 -0.10150 0.00008 0.00008 -0.01708" />
|
||||
<body name="left_elbow_link" pos="0.020796 -0.031888 -0.10414" quat="1 0 0 0">
|
||||
<joint axis="0 -1 0" name="left_elbow_joint" type="hinge" range="-1.6 1.24" armature="0.00313313" />
|
||||
<inertial pos="0.07222795 0.03107894 -0.01809537" mass="0.77922872" fullinertia="0.00060310 0.00112121 0.00118539 -0.00005057 0.00006993 0.00001181" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="left_elbow_link" material="left_elbow_material" />
|
||||
<geom name="left_elbow_collision" type="capsule" class="collision" size="0.04220" fromto="0.00487 0.03186 -0.00484 0.07959 0.03186 -0.01404" />
|
||||
<body name="left_wrist_link" pos="0.116093381994033 0.031859446289993 -0.0187927584979322" quat="1 0 0 0">
|
||||
<joint axis="1 0 0" name="left_wrist_joint" type="hinge" range="-2.56 2.56" armature="0.00313313" />
|
||||
<inertial pos="0.10279104 -0.00368067 0.00149822" mass="0.46025356" fullinertia="0.00032495 0.00202426 0.00199776 0.00013222 -0.00009324 0.00001796" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="left_wrist_link" material="left_wrist_material" />
|
||||
<geom name="left_wrist_collision" type="capsule" class="collision" size="0.03948" fromto="0.01646 -0.00206 0.00203 0.16132 -0.01175 0.00203" />
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
|
||||
<body name="right_shoulder_pitch_link" pos="0 -0.116496194698064 0.198487155742749" quat="1 0 0 0">
|
||||
<joint axis="0 -0.99619 0.087156" name="right_shoulder_pitch_joint" type="hinge" range="-2.35 3.4" armature="0.00884" />
|
||||
<inertial pos="-0.00227477 -0.05856201 -0.01145858" mass="0.82850796" fullinertia="0.00077392 0.00060520 0.00074316 -0.00001370 -0.00000678 -0.00008562" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="right_shoulder_pitch_link" material="right_shoulder_pitch_material" />
|
||||
<geom name="right_shoulder_pitch_collision" type="capsule" class="collision" size="0.03808" fromto="-0.00326 -0.06284 -0.01210 -0.00326 -0.03582 -0.00238" />
|
||||
<body name="right_shoulder_roll_link" pos="0.0287432951007422 -0.0653494445235536 -0.0146089065305009" quat="1 0 0 0">
|
||||
<joint axis="1 0 0" name="right_shoulder_roll_joint" type="hinge" range="-2.9 0.47" armature="0.00313313" />
|
||||
<inertial pos="-0.01626203 0.00000539 -0.06810375" mass="0.80442734" fullinertia="0.00087815 0.00088810 0.00052415 0.00000011 -0.00013154 -0.00000005" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="right_shoulder_roll_link" material="right_shoulder_roll_material" />
|
||||
<geom name="right_shoulder_roll_collision" type="capsule" class="collision" size="0.04000" fromto="-0.01906 0 -0.07700 -0.01906 0 -0.00656" />
|
||||
<body name="right_shoulder_yaw_link" pos="-0.0190573923593691 0 -0.105000126276637" quat="1 0 0 0">
|
||||
<joint axis="0 0 -1" name="right_shoulder_yaw_joint" type="hinge" range="-2.87 2.87" armature="0.00313313" />
|
||||
<inertial pos="0.01430772 0.00112150 -0.08592529" mass="0.95225273" fullinertia="0.00179792 0.00188417 0.00081194 -0.00000160 0.00031064 0.00001448" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="right_shoulder_yaw_link" material="right_shoulder_yaw_material" />
|
||||
<geom name="right_shoulder_yaw_collision" type="capsule" class="collision" size="0.04008" fromto="0.01816 -0.00008 -0.10150 0.00008 -0.00008 -0.01708" />
|
||||
<body name="right_elbow_link" pos="0.0207956801502895 0.031887525882762 -0.104135222723484" quat="1 0 0 0">
|
||||
<joint axis="0 1 0" name="right_elbow_joint" type="hinge" range="-1.24 1.6" armature="0.00313313" />
|
||||
<inertial pos="0.07222795 -0.03090613 -0.01799316" mass="0.77922499" fullinertia="0.00060275 0.00112238 0.00118388 0.00005257 0.00007112 -0.00001226" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="right_elbow_link" material="right_elbow_material" />
|
||||
<geom name="right_elbow_collision" type="capsule" class="collision" size="0.04220" fromto="0.00487 -0.03186 -0.00484 0.07959 -0.03186 -0.01404" />
|
||||
<body name="right_wrist_link" pos="0.11609334409225 -0.031859369715491 -0.0187927299688337" quat="1 0 0 0">
|
||||
<joint axis="1 0 0" name="right_wrist_joint" type="hinge" range="-2.56 2.56" armature="0.00313313" />
|
||||
<inertial pos="0.10279542 0.00367933 0.00149885" mass="0.46029783" fullinertia="0.00032496 0.00202412 0.00199758 -0.00013231 -0.00009325 -0.00001798" />
|
||||
<geom type="mesh" class="visual" pos="0 0 0" quat="1 0 0 0" mesh="right_wrist_link" material="right_wrist_material" />
|
||||
<geom name="right_wrist_collision" type="capsule" class="collision" size="0.03948" fromto="0.01646 0.00206 0.00203 0.16132 0.01175 0.00203" />
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</worldbody>
|
||||
<asset>
|
||||
<mesh file="meshes/base_link.STL" />
|
||||
<mesh file="meshes/left_hip_pitch_link.STL" />
|
||||
<mesh file="meshes/left_hip_roll_link.STL" />
|
||||
<mesh file="meshes/left_hip_yaw_link.STL" />
|
||||
<mesh file="meshes/left_knee_link.STL" />
|
||||
<mesh file="meshes/left_ankle_pitch_link.STL" />
|
||||
<mesh file="meshes/left_ankle_roll_link.STL" />
|
||||
<mesh file="meshes/right_hip_pitch_link.STL" />
|
||||
<mesh file="meshes/right_hip_roll_link.STL" />
|
||||
<mesh file="meshes/right_hip_yaw_link.STL" />
|
||||
<mesh file="meshes/right_knee_link.STL" />
|
||||
<mesh file="meshes/right_ankle_pitch_link.STL" />
|
||||
<mesh file="meshes/right_ankle_roll_link.STL" />
|
||||
<mesh file="meshes/waist_roll_link.STL" />
|
||||
<mesh file="meshes/waist_yaw_link.STL" />
|
||||
<mesh file="meshes/left_shoulder_pitch_link.STL" />
|
||||
<mesh file="meshes/left_shoulder_roll_link.STL" />
|
||||
<mesh file="meshes/left_shoulder_yaw_link.STL" />
|
||||
<mesh file="meshes/left_elbow_link.STL" />
|
||||
<mesh file="meshes/left_wrist_link.STL" />
|
||||
<mesh file="meshes/right_shoulder_pitch_link.STL" />
|
||||
<mesh file="meshes/right_shoulder_roll_link.STL" />
|
||||
<mesh file="meshes/right_shoulder_yaw_link.STL" />
|
||||
<mesh file="meshes/right_elbow_link.STL" />
|
||||
<mesh file="meshes/right_wrist_link.STL" />
|
||||
<material name="base_link_material" rgba="0.752941 0.752941 0.752941 1" />
|
||||
<material name="left_hip_pitch_material" rgba="0.752941 0.752941 0.752941 1" />
|
||||
<material name="left_hip_roll_material" rgba="0.752941 0.752941 0.752941 1" />
|
||||
<material name="left_hip_yaw_material" rgba="0.752941 0.752941 0.752941 1" />
|
||||
<material name="left_knee_material" rgba="0.752941 0.752941 0.752941 1" />
|
||||
<material name="left_ankle_pitch_material" rgba="0.650980 0.619608 0.588235 1" />
|
||||
<material name="left_ankle_roll_material" rgba="0.752941 0.752941 0.752941 1" />
|
||||
<material name="right_hip_pitch_material" rgba="0.752941 0.752941 0.752941 1" />
|
||||
<material name="right_hip_roll_material" rgba="0.752941 0.752941 0.752941 1" />
|
||||
<material name="right_hip_yaw_material" rgba="0.752941 0.752941 0.752941 1" />
|
||||
<material name="right_knee_material" rgba="0.752941 0.752941 0.752941 1" />
|
||||
<material name="right_ankle_pitch_material" rgba="0.650980 0.619608 0.588235 1" />
|
||||
<material name="right_ankle_roll_material" rgba="0.752941 0.752941 0.752941 1" />
|
||||
<material name="waist_roll_material" rgba="0.752941 0.752941 0.752941 1" />
|
||||
<material name="waist_yaw_material" rgba="0.752941 0.752941 0.752941 1" />
|
||||
<material name="left_shoulder_pitch_material" rgba="0.752941 0.752941 0.752941 1" />
|
||||
<material name="left_shoulder_roll_material" rgba="0.752941 0.752941 0.752941 1" />
|
||||
<material name="left_shoulder_yaw_material" rgba="0.752941 0.752941 0.752941 1" />
|
||||
<material name="left_elbow_material" rgba="0.752941 0.752941 0.752941 1" />
|
||||
<material name="left_wrist_material" rgba="0.752941 0.752941 0.752941 1" />
|
||||
<material name="right_shoulder_pitch_material" rgba="0.752941 0.752941 0.752941 1" />
|
||||
<material name="right_shoulder_roll_material" rgba="0.752941 0.752941 0.752941 1" />
|
||||
<material name="right_shoulder_yaw_material" rgba="0.752941 0.752941 0.752941 1" />
|
||||
<material name="right_elbow_material" rgba="0.752941 0.752941 0.752941 1" />
|
||||
<material name="right_wrist_material" rgba="0.752941 0.752941 0.752941 1" />
|
||||
</asset>
|
||||
<actuator>
|
||||
<motor class="RP1" gear="1" ctrlrange="-140 140" name="left_hip_pitch_joint" joint="left_hip_pitch_joint" />
|
||||
<motor class="RP1" gear="1" ctrlrange="-140 140" name="left_hip_roll_joint" joint="left_hip_roll_joint" />
|
||||
<motor class="RP1" gear="1" ctrlrange="-55 55" name="left_hip_yaw_joint" joint="left_hip_yaw_joint" />
|
||||
<motor class="RP1" gear="1" ctrlrange="-140 140" name="left_knee_joint" joint="left_knee_joint" />
|
||||
<motor class="RP1" gear="1" ctrlrange="-64 64" name="left_ankle_pitch_joint" joint="left_ankle_pitch_joint" />
|
||||
<motor class="RP1" gear="1" ctrlrange="-64 64" name="left_ankle_roll_joint" joint="left_ankle_roll_joint" />
|
||||
<motor class="RP1" gear="1" ctrlrange="-140 140" name="right_hip_pitch_joint" joint="right_hip_pitch_joint" />
|
||||
<motor class="RP1" gear="1" ctrlrange="-140 140" name="right_hip_roll_joint" joint="right_hip_roll_joint" />
|
||||
<motor class="RP1" gear="1" ctrlrange="-55 55" name="right_hip_yaw_joint" joint="right_hip_yaw_joint" />
|
||||
<motor class="RP1" gear="1" ctrlrange="-140 140" name="right_knee_joint" joint="right_knee_joint" />
|
||||
<motor class="RP1" gear="1" ctrlrange="-64 64" name="right_ankle_pitch_joint" joint="right_ankle_pitch_joint" />
|
||||
<motor class="RP1" gear="1" ctrlrange="-64 64" name="right_ankle_roll_joint" joint="right_ankle_roll_joint" />
|
||||
<motor class="RP1" gear="1" ctrlrange="-140 140" name="waist_roll_joint" joint="waist_roll_joint" />
|
||||
<motor class="RP1" gear="1" ctrlrange="-140 140" name="waist_yaw_joint" joint="waist_yaw_joint" />
|
||||
<motor class="RP1" gear="1" ctrlrange="-55 55" name="left_shoulder_pitch_joint" joint="left_shoulder_pitch_joint" />
|
||||
<motor class="RP1" gear="1" ctrlrange="-32 32" name="left_shoulder_roll_joint" joint="left_shoulder_roll_joint" />
|
||||
<motor class="RP1" gear="1" ctrlrange="-32 32" name="left_shoulder_yaw_joint" joint="left_shoulder_yaw_joint" />
|
||||
<motor class="RP1" gear="1" ctrlrange="-32 32" name="left_elbow_joint" joint="left_elbow_joint" />
|
||||
<motor class="RP1" gear="1" ctrlrange="-32 32" name="left_wrist_joint" joint="left_wrist_joint" />
|
||||
<motor class="RP1" gear="1" ctrlrange="-55 55" name="right_shoulder_pitch_joint" joint="right_shoulder_pitch_joint" />
|
||||
<motor class="RP1" gear="1" ctrlrange="-32 32" name="right_shoulder_roll_joint" joint="right_shoulder_roll_joint" />
|
||||
<motor class="RP1" gear="1" ctrlrange="-32 32" name="right_shoulder_yaw_joint" joint="right_shoulder_yaw_joint" />
|
||||
<motor class="RP1" gear="1" ctrlrange="-32 32" name="right_elbow_joint" joint="right_elbow_joint" />
|
||||
<motor class="RP1" gear="1" ctrlrange="-32 32" name="right_wrist_joint" joint="right_wrist_joint" />
|
||||
</actuator>
|
||||
<sensor>
|
||||
<framequat name="orientation" objtype="site" noise="0.001" objname="imu" />
|
||||
<framepos name="position" objtype="site" noise="0.001" objname="imu" />
|
||||
<gyro name="angular-velocity" site="imu" noise="0.005" cutoff="34.9" />
|
||||
<velocimeter name="linear-velocity" site="imu" noise="0.001" cutoff="30" />
|
||||
<accelerometer name="linear-acceleration" site="imu" noise="0.005" cutoff="157" />
|
||||
<magnetometer name="magnetometer" site="imu" />
|
||||
</sensor>
|
||||
<visual>
|
||||
<global offwidth="1920" offheight="1080" />
|
||||
</visual>
|
||||
</mujoco>
|
||||
Binary file not shown.
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"schema": 1,
|
||||
"layout": "positions_then_velocities",
|
||||
"dtype": "float32-le",
|
||||
"step_dt": 0.02,
|
||||
"frames": 6573,
|
||||
"joint_names": [
|
||||
"left_hip_pitch_joint",
|
||||
"left_hip_roll_joint",
|
||||
"left_hip_yaw_joint",
|
||||
"left_knee_joint",
|
||||
"left_ankle_pitch_joint",
|
||||
"left_ankle_roll_joint",
|
||||
"right_hip_pitch_joint",
|
||||
"right_hip_roll_joint",
|
||||
"right_hip_yaw_joint",
|
||||
"right_knee_joint",
|
||||
"right_ankle_pitch_joint",
|
||||
"right_ankle_roll_joint",
|
||||
"waist_roll_joint",
|
||||
"waist_yaw_joint",
|
||||
"left_shoulder_pitch_joint",
|
||||
"left_shoulder_roll_joint",
|
||||
"left_shoulder_yaw_joint",
|
||||
"left_elbow_joint",
|
||||
"left_wrist_joint",
|
||||
"right_shoulder_pitch_joint",
|
||||
"right_shoulder_roll_joint",
|
||||
"right_shoulder_yaw_joint",
|
||||
"right_elbow_joint",
|
||||
"right_wrist_joint"
|
||||
],
|
||||
"data": "motions/dance.f32"
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"schema": 1,
|
||||
"layout": "positions_then_velocities",
|
||||
"dtype": "float32-le",
|
||||
"step_dt": 0.02,
|
||||
"frames": 218,
|
||||
"joint_names": [
|
||||
"left_hip_pitch_joint",
|
||||
"left_hip_roll_joint",
|
||||
"left_hip_yaw_joint",
|
||||
"left_knee_joint",
|
||||
"left_ankle_pitch_joint",
|
||||
"left_ankle_roll_joint",
|
||||
"right_hip_pitch_joint",
|
||||
"right_hip_roll_joint",
|
||||
"right_hip_yaw_joint",
|
||||
"right_knee_joint",
|
||||
"right_ankle_pitch_joint",
|
||||
"right_ankle_roll_joint",
|
||||
"waist_roll_joint",
|
||||
"waist_yaw_joint",
|
||||
"left_shoulder_pitch_joint",
|
||||
"left_shoulder_roll_joint",
|
||||
"left_shoulder_yaw_joint",
|
||||
"left_elbow_joint",
|
||||
"left_wrist_joint",
|
||||
"right_shoulder_pitch_joint",
|
||||
"right_shoulder_roll_joint",
|
||||
"right_shoulder_yaw_joint",
|
||||
"right_elbow_joint",
|
||||
"right_wrist_joint"
|
||||
],
|
||||
"data": "motions/wave.f32"
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,692 @@
|
||||
{
|
||||
"schema": 1,
|
||||
"id": "rp1",
|
||||
"name": "RP1",
|
||||
"family": "rp1",
|
||||
"adapter": "generic",
|
||||
"dimensions": {
|
||||
"height": 1.32
|
||||
},
|
||||
"model": "model.xml",
|
||||
"assets": [
|
||||
{
|
||||
"path": "meshes/base_link.STL",
|
||||
"vfs": "meshes/base_link.STL"
|
||||
},
|
||||
{
|
||||
"path": "meshes/left_hip_pitch_link.STL",
|
||||
"vfs": "meshes/left_hip_pitch_link.STL"
|
||||
},
|
||||
{
|
||||
"path": "meshes/left_hip_roll_link.STL",
|
||||
"vfs": "meshes/left_hip_roll_link.STL"
|
||||
},
|
||||
{
|
||||
"path": "meshes/left_hip_yaw_link.STL",
|
||||
"vfs": "meshes/left_hip_yaw_link.STL"
|
||||
},
|
||||
{
|
||||
"path": "meshes/left_knee_link.STL",
|
||||
"vfs": "meshes/left_knee_link.STL"
|
||||
},
|
||||
{
|
||||
"path": "meshes/left_ankle_pitch_link.STL",
|
||||
"vfs": "meshes/left_ankle_pitch_link.STL"
|
||||
},
|
||||
{
|
||||
"path": "meshes/left_ankle_roll_link.STL",
|
||||
"vfs": "meshes/left_ankle_roll_link.STL"
|
||||
},
|
||||
{
|
||||
"path": "meshes/right_hip_pitch_link.STL",
|
||||
"vfs": "meshes/right_hip_pitch_link.STL"
|
||||
},
|
||||
{
|
||||
"path": "meshes/right_hip_roll_link.STL",
|
||||
"vfs": "meshes/right_hip_roll_link.STL"
|
||||
},
|
||||
{
|
||||
"path": "meshes/right_hip_yaw_link.STL",
|
||||
"vfs": "meshes/right_hip_yaw_link.STL"
|
||||
},
|
||||
{
|
||||
"path": "meshes/right_knee_link.STL",
|
||||
"vfs": "meshes/right_knee_link.STL"
|
||||
},
|
||||
{
|
||||
"path": "meshes/right_ankle_pitch_link.STL",
|
||||
"vfs": "meshes/right_ankle_pitch_link.STL"
|
||||
},
|
||||
{
|
||||
"path": "meshes/right_ankle_roll_link.STL",
|
||||
"vfs": "meshes/right_ankle_roll_link.STL"
|
||||
},
|
||||
{
|
||||
"path": "meshes/waist_roll_link.STL",
|
||||
"vfs": "meshes/waist_roll_link.STL"
|
||||
},
|
||||
{
|
||||
"path": "meshes/waist_yaw_link.STL",
|
||||
"vfs": "meshes/waist_yaw_link.STL"
|
||||
},
|
||||
{
|
||||
"path": "meshes/left_shoulder_pitch_link.STL",
|
||||
"vfs": "meshes/left_shoulder_pitch_link.STL"
|
||||
},
|
||||
{
|
||||
"path": "meshes/left_shoulder_roll_link.STL",
|
||||
"vfs": "meshes/left_shoulder_roll_link.STL"
|
||||
},
|
||||
{
|
||||
"path": "meshes/left_shoulder_yaw_link.STL",
|
||||
"vfs": "meshes/left_shoulder_yaw_link.STL"
|
||||
},
|
||||
{
|
||||
"path": "meshes/left_elbow_link.STL",
|
||||
"vfs": "meshes/left_elbow_link.STL"
|
||||
},
|
||||
{
|
||||
"path": "meshes/left_wrist_link.STL",
|
||||
"vfs": "meshes/left_wrist_link.STL"
|
||||
},
|
||||
{
|
||||
"path": "meshes/right_shoulder_pitch_link.STL",
|
||||
"vfs": "meshes/right_shoulder_pitch_link.STL"
|
||||
},
|
||||
{
|
||||
"path": "meshes/right_shoulder_roll_link.STL",
|
||||
"vfs": "meshes/right_shoulder_roll_link.STL"
|
||||
},
|
||||
{
|
||||
"path": "meshes/right_shoulder_yaw_link.STL",
|
||||
"vfs": "meshes/right_shoulder_yaw_link.STL"
|
||||
},
|
||||
{
|
||||
"path": "meshes/right_elbow_link.STL",
|
||||
"vfs": "meshes/right_elbow_link.STL"
|
||||
},
|
||||
{
|
||||
"path": "meshes/right_wrist_link.STL",
|
||||
"vfs": "meshes/right_wrist_link.STL"
|
||||
}
|
||||
],
|
||||
"base": {
|
||||
"type": "floating",
|
||||
"root_body": "base_link",
|
||||
"freejoint": "base_link_freejoint",
|
||||
"spawn": {
|
||||
"pos": [
|
||||
0.0,
|
||||
0.0,
|
||||
0.78
|
||||
],
|
||||
"yaw": 0
|
||||
},
|
||||
"initial": {
|
||||
"left_hip_pitch_joint": -0.1,
|
||||
"left_hip_roll_joint": 0.0,
|
||||
"left_hip_yaw_joint": 0.0,
|
||||
"left_knee_joint": -0.3,
|
||||
"left_ankle_pitch_joint": -0.2,
|
||||
"left_ankle_roll_joint": 0.0,
|
||||
"right_hip_pitch_joint": 0.1,
|
||||
"right_hip_roll_joint": 0.0,
|
||||
"right_hip_yaw_joint": 0.0,
|
||||
"right_knee_joint": 0.3,
|
||||
"right_ankle_pitch_joint": -0.2,
|
||||
"right_ankle_roll_joint": 0.0,
|
||||
"waist_roll_joint": 0.0,
|
||||
"waist_yaw_joint": 0.0,
|
||||
"left_shoulder_pitch_joint": 0.2,
|
||||
"left_shoulder_roll_joint": 0.2,
|
||||
"left_shoulder_yaw_joint": 0.0,
|
||||
"left_elbow_joint": -1.2,
|
||||
"left_wrist_joint": 0.0,
|
||||
"right_shoulder_pitch_joint": -0.2,
|
||||
"right_shoulder_roll_joint": -0.2,
|
||||
"right_shoulder_yaw_joint": 0.0,
|
||||
"right_elbow_joint": 1.2,
|
||||
"right_wrist_joint": 0.0
|
||||
}
|
||||
},
|
||||
"sim": {
|
||||
"timestep": 0.005,
|
||||
"decimation": 4
|
||||
},
|
||||
"joints": {
|
||||
"groups": {
|
||||
"policy": [
|
||||
"left_hip_pitch_joint",
|
||||
"left_hip_roll_joint",
|
||||
"left_hip_yaw_joint",
|
||||
"left_knee_joint",
|
||||
"left_ankle_pitch_joint",
|
||||
"left_ankle_roll_joint",
|
||||
"right_hip_pitch_joint",
|
||||
"right_hip_roll_joint",
|
||||
"right_hip_yaw_joint",
|
||||
"right_knee_joint",
|
||||
"right_ankle_pitch_joint",
|
||||
"right_ankle_roll_joint",
|
||||
"waist_roll_joint",
|
||||
"waist_yaw_joint",
|
||||
"left_shoulder_pitch_joint",
|
||||
"left_shoulder_roll_joint",
|
||||
"left_shoulder_yaw_joint",
|
||||
"left_elbow_joint",
|
||||
"left_wrist_joint",
|
||||
"right_shoulder_pitch_joint",
|
||||
"right_shoulder_roll_joint",
|
||||
"right_shoulder_yaw_joint",
|
||||
"right_elbow_joint",
|
||||
"right_wrist_joint"
|
||||
]
|
||||
},
|
||||
"defaults": {
|
||||
"left_hip_pitch_joint": -0.1,
|
||||
"left_hip_roll_joint": 0.0,
|
||||
"left_hip_yaw_joint": 0.0,
|
||||
"left_knee_joint": -0.3,
|
||||
"left_ankle_pitch_joint": -0.2,
|
||||
"left_ankle_roll_joint": 0.0,
|
||||
"right_hip_pitch_joint": 0.1,
|
||||
"right_hip_roll_joint": 0.0,
|
||||
"right_hip_yaw_joint": 0.0,
|
||||
"right_knee_joint": 0.3,
|
||||
"right_ankle_pitch_joint": -0.2,
|
||||
"right_ankle_roll_joint": 0.0,
|
||||
"waist_roll_joint": 0.0,
|
||||
"waist_yaw_joint": 0.0,
|
||||
"left_shoulder_pitch_joint": 0.2,
|
||||
"left_shoulder_roll_joint": 0.2,
|
||||
"left_shoulder_yaw_joint": 0.0,
|
||||
"left_elbow_joint": -1.2,
|
||||
"left_wrist_joint": 0.0,
|
||||
"right_shoulder_pitch_joint": -0.2,
|
||||
"right_shoulder_roll_joint": -0.2,
|
||||
"right_shoulder_yaw_joint": 0.0,
|
||||
"right_elbow_joint": 1.2,
|
||||
"right_wrist_joint": 0.0
|
||||
}
|
||||
},
|
||||
"observations": {
|
||||
"obs": {
|
||||
"history": 3,
|
||||
"layout": "term_major",
|
||||
"terms": [
|
||||
{
|
||||
"type": "gyro",
|
||||
"sensor": "angular-velocity"
|
||||
},
|
||||
{
|
||||
"type": "projected_gravity",
|
||||
"body": "base_link"
|
||||
},
|
||||
{
|
||||
"type": "command",
|
||||
"size": 3
|
||||
},
|
||||
{
|
||||
"type": "joint_pos_rel",
|
||||
"group": "policy"
|
||||
},
|
||||
{
|
||||
"type": "joint_vel",
|
||||
"group": "policy"
|
||||
},
|
||||
{
|
||||
"type": "last_action",
|
||||
"group": "policy"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "joint_position",
|
||||
"group": "policy",
|
||||
"scale": 0.25,
|
||||
"offset": "default"
|
||||
}
|
||||
],
|
||||
"actuation": {
|
||||
"type": "joint_pd",
|
||||
"kp": 120,
|
||||
"kd": 7.5,
|
||||
"torque_limit": 140,
|
||||
"joints": {
|
||||
"left_hip_pitch_joint": {
|
||||
"kp": 120.0,
|
||||
"kd": 7.5,
|
||||
"torque_limit": 140.0,
|
||||
"velocity_limit": 13.61357,
|
||||
"keep_velocity": 8.37758
|
||||
},
|
||||
"left_hip_roll_joint": {
|
||||
"kp": 120.0,
|
||||
"kd": 7.5,
|
||||
"torque_limit": 140.0,
|
||||
"velocity_limit": 13.61357,
|
||||
"keep_velocity": 8.37758
|
||||
},
|
||||
"left_hip_yaw_joint": {
|
||||
"kp": 35.0,
|
||||
"kd": 2.5,
|
||||
"torque_limit": 55.0,
|
||||
"velocity_limit": 16.23156,
|
||||
"keep_velocity": 6.28319
|
||||
},
|
||||
"left_knee_joint": {
|
||||
"kp": 120.0,
|
||||
"kd": 7.5,
|
||||
"torque_limit": 140.0,
|
||||
"velocity_limit": 13.61357,
|
||||
"keep_velocity": 8.37758
|
||||
},
|
||||
"left_ankle_pitch_joint": {
|
||||
"kp": 25.0,
|
||||
"kd": 1.5,
|
||||
"torque_limit": 64.0,
|
||||
"velocity_limit": 15.70796,
|
||||
"keep_velocity": 14.66077
|
||||
},
|
||||
"left_ankle_roll_joint": {
|
||||
"kp": 25.0,
|
||||
"kd": 1.5,
|
||||
"torque_limit": 64.0,
|
||||
"velocity_limit": 15.70796,
|
||||
"keep_velocity": 14.66077
|
||||
},
|
||||
"right_hip_pitch_joint": {
|
||||
"kp": 120.0,
|
||||
"kd": 7.5,
|
||||
"torque_limit": 140.0,
|
||||
"velocity_limit": 13.61357,
|
||||
"keep_velocity": 8.37758
|
||||
},
|
||||
"right_hip_roll_joint": {
|
||||
"kp": 120.0,
|
||||
"kd": 7.5,
|
||||
"torque_limit": 140.0,
|
||||
"velocity_limit": 13.61357,
|
||||
"keep_velocity": 8.37758
|
||||
},
|
||||
"right_hip_yaw_joint": {
|
||||
"kp": 35.0,
|
||||
"kd": 2.5,
|
||||
"torque_limit": 55.0,
|
||||
"velocity_limit": 16.23156,
|
||||
"keep_velocity": 6.28319
|
||||
},
|
||||
"right_knee_joint": {
|
||||
"kp": 120.0,
|
||||
"kd": 7.5,
|
||||
"torque_limit": 140.0,
|
||||
"velocity_limit": 13.61357,
|
||||
"keep_velocity": 8.37758
|
||||
},
|
||||
"right_ankle_pitch_joint": {
|
||||
"kp": 25.0,
|
||||
"kd": 1.5,
|
||||
"torque_limit": 64.0,
|
||||
"velocity_limit": 15.70796,
|
||||
"keep_velocity": 14.66077
|
||||
},
|
||||
"right_ankle_roll_joint": {
|
||||
"kp": 25.0,
|
||||
"kd": 1.5,
|
||||
"torque_limit": 64.0,
|
||||
"velocity_limit": 15.70796,
|
||||
"keep_velocity": 14.66077
|
||||
},
|
||||
"waist_roll_joint": {
|
||||
"kp": 120.0,
|
||||
"kd": 7.5,
|
||||
"torque_limit": 140.0,
|
||||
"velocity_limit": 13.61357,
|
||||
"keep_velocity": 8.37758
|
||||
},
|
||||
"waist_yaw_joint": {
|
||||
"kp": 120.0,
|
||||
"kd": 7.5,
|
||||
"torque_limit": 140.0,
|
||||
"velocity_limit": 13.61357,
|
||||
"keep_velocity": 8.37758
|
||||
},
|
||||
"left_shoulder_pitch_joint": {
|
||||
"kp": 35.0,
|
||||
"kd": 2.5,
|
||||
"torque_limit": 55.0,
|
||||
"velocity_limit": 16.23156,
|
||||
"keep_velocity": 6.28319
|
||||
},
|
||||
"left_shoulder_roll_joint": {
|
||||
"kp": 12.5,
|
||||
"kd": 0.75,
|
||||
"torque_limit": 32.0,
|
||||
"velocity_limit": 15.70796,
|
||||
"keep_velocity": 14.66077
|
||||
},
|
||||
"left_shoulder_yaw_joint": {
|
||||
"kp": 12.5,
|
||||
"kd": 0.75,
|
||||
"torque_limit": 32.0,
|
||||
"velocity_limit": 15.70796,
|
||||
"keep_velocity": 14.66077
|
||||
},
|
||||
"left_elbow_joint": {
|
||||
"kp": 12.5,
|
||||
"kd": 0.75,
|
||||
"torque_limit": 32.0,
|
||||
"velocity_limit": 15.70796,
|
||||
"keep_velocity": 14.66077
|
||||
},
|
||||
"left_wrist_joint": {
|
||||
"kp": 12.5,
|
||||
"kd": 0.75,
|
||||
"torque_limit": 32.0,
|
||||
"velocity_limit": 15.70796,
|
||||
"keep_velocity": 14.66077
|
||||
},
|
||||
"right_shoulder_pitch_joint": {
|
||||
"kp": 35.0,
|
||||
"kd": 2.5,
|
||||
"torque_limit": 55.0,
|
||||
"velocity_limit": 16.23156,
|
||||
"keep_velocity": 6.28319
|
||||
},
|
||||
"right_shoulder_roll_joint": {
|
||||
"kp": 12.5,
|
||||
"kd": 0.75,
|
||||
"torque_limit": 32.0,
|
||||
"velocity_limit": 15.70796,
|
||||
"keep_velocity": 14.66077
|
||||
},
|
||||
"right_shoulder_yaw_joint": {
|
||||
"kp": 12.5,
|
||||
"kd": 0.75,
|
||||
"torque_limit": 32.0,
|
||||
"velocity_limit": 15.70796,
|
||||
"keep_velocity": 14.66077
|
||||
},
|
||||
"right_elbow_joint": {
|
||||
"kp": 12.5,
|
||||
"kd": 0.75,
|
||||
"torque_limit": 32.0,
|
||||
"velocity_limit": 15.70796,
|
||||
"keep_velocity": 14.66077
|
||||
},
|
||||
"right_wrist_joint": {
|
||||
"kp": 12.5,
|
||||
"kd": 0.75,
|
||||
"torque_limit": 32.0,
|
||||
"velocity_limit": 15.70796,
|
||||
"keep_velocity": 14.66077
|
||||
}
|
||||
}
|
||||
},
|
||||
"commands": {
|
||||
"size": 3,
|
||||
"limits": [
|
||||
0.4,
|
||||
-0.3,
|
||||
0.6
|
||||
]
|
||||
},
|
||||
"skills": [
|
||||
{
|
||||
"id": "walk",
|
||||
"kind": "primary",
|
||||
"owns": "policy",
|
||||
"controller": {
|
||||
"type": "onnx",
|
||||
"policy": "policies/walk.onnx"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "dance",
|
||||
"kind": "episodic",
|
||||
"owns": "policy",
|
||||
"available": true,
|
||||
"duration": 10.0,
|
||||
"blend": 0.5,
|
||||
"controller": {
|
||||
"type": "onnx",
|
||||
"policy": "policies/dance.onnx"
|
||||
},
|
||||
"defaults": {
|
||||
"left_hip_pitch_joint": -0.1,
|
||||
"left_hip_roll_joint": 0.0,
|
||||
"left_hip_yaw_joint": 0.0,
|
||||
"left_knee_joint": -0.3,
|
||||
"left_ankle_pitch_joint": -0.2,
|
||||
"left_ankle_roll_joint": 0.0,
|
||||
"right_hip_pitch_joint": 0.1,
|
||||
"right_hip_roll_joint": 0.0,
|
||||
"right_hip_yaw_joint": 0.0,
|
||||
"right_knee_joint": 0.3,
|
||||
"right_ankle_pitch_joint": -0.2,
|
||||
"right_ankle_roll_joint": 0.0,
|
||||
"waist_roll_joint": 0.0,
|
||||
"waist_yaw_joint": 0.0,
|
||||
"left_shoulder_pitch_joint": 0.2,
|
||||
"left_shoulder_roll_joint": 0.2,
|
||||
"left_shoulder_yaw_joint": 0.0,
|
||||
"left_elbow_joint": -1.2,
|
||||
"left_wrist_joint": 0.0,
|
||||
"right_shoulder_pitch_joint": -0.2,
|
||||
"right_shoulder_roll_joint": -0.2,
|
||||
"right_shoulder_yaw_joint": 0.0,
|
||||
"right_elbow_joint": 1.2,
|
||||
"right_wrist_joint": 0.0
|
||||
},
|
||||
"reference": "motions/dance.json",
|
||||
"observations": {
|
||||
"obs": {
|
||||
"terms": [
|
||||
{
|
||||
"type": "motion_command",
|
||||
"group": "policy"
|
||||
},
|
||||
{
|
||||
"type": "gyro",
|
||||
"sensor": "angular-velocity"
|
||||
},
|
||||
{
|
||||
"type": "projected_gravity",
|
||||
"body": "base_link"
|
||||
},
|
||||
{
|
||||
"type": "joint_pos_rel",
|
||||
"group": "policy"
|
||||
},
|
||||
{
|
||||
"type": "joint_vel",
|
||||
"group": "policy"
|
||||
},
|
||||
{
|
||||
"type": "last_action",
|
||||
"group": "policy"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "joint_position",
|
||||
"group": "policy",
|
||||
"scale": 0.25,
|
||||
"offset": "default"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "wave",
|
||||
"kind": "episodic",
|
||||
"owns": "policy",
|
||||
"available": true,
|
||||
"duration": 4.36,
|
||||
"blend": 0.5,
|
||||
"controller": {
|
||||
"type": "onnx",
|
||||
"policy": "policies/wave.onnx"
|
||||
},
|
||||
"defaults": {
|
||||
"left_hip_pitch_joint": -0.1,
|
||||
"left_hip_roll_joint": 0.0,
|
||||
"left_hip_yaw_joint": 0.0,
|
||||
"left_knee_joint": -0.3,
|
||||
"left_ankle_pitch_joint": -0.2,
|
||||
"left_ankle_roll_joint": 0.0,
|
||||
"right_hip_pitch_joint": 0.1,
|
||||
"right_hip_roll_joint": 0.0,
|
||||
"right_hip_yaw_joint": 0.0,
|
||||
"right_knee_joint": 0.3,
|
||||
"right_ankle_pitch_joint": -0.2,
|
||||
"right_ankle_roll_joint": 0.0,
|
||||
"waist_roll_joint": 0.0,
|
||||
"waist_yaw_joint": 0.0,
|
||||
"left_shoulder_pitch_joint": 0.2,
|
||||
"left_shoulder_roll_joint": 0.2,
|
||||
"left_shoulder_yaw_joint": 0.0,
|
||||
"left_elbow_joint": -1.2,
|
||||
"left_wrist_joint": 0.0,
|
||||
"right_shoulder_pitch_joint": -0.2,
|
||||
"right_shoulder_roll_joint": -0.2,
|
||||
"right_shoulder_yaw_joint": 0.0,
|
||||
"right_elbow_joint": 1.2,
|
||||
"right_wrist_joint": 0.0
|
||||
},
|
||||
"reference": "motions/wave.json",
|
||||
"observations": {
|
||||
"obs": {
|
||||
"terms": [
|
||||
{
|
||||
"type": "motion_command",
|
||||
"group": "policy"
|
||||
},
|
||||
{
|
||||
"type": "gyro",
|
||||
"sensor": "angular-velocity"
|
||||
},
|
||||
{
|
||||
"type": "projected_gravity",
|
||||
"body": "base_link"
|
||||
},
|
||||
{
|
||||
"type": "joint_pos_rel",
|
||||
"group": "policy"
|
||||
},
|
||||
{
|
||||
"type": "joint_vel",
|
||||
"group": "policy"
|
||||
},
|
||||
{
|
||||
"type": "last_action",
|
||||
"group": "policy"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "joint_position",
|
||||
"group": "policy",
|
||||
"scale": 0.25,
|
||||
"offset": "default"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"input": {
|
||||
"bindings": [
|
||||
{
|
||||
"action": "move_forward",
|
||||
"codes": [
|
||||
"ArrowUp",
|
||||
"KeyW"
|
||||
],
|
||||
"label": "Forward"
|
||||
},
|
||||
{
|
||||
"action": "move_backward",
|
||||
"codes": [
|
||||
"ArrowDown",
|
||||
"KeyS"
|
||||
],
|
||||
"label": "Backward"
|
||||
},
|
||||
{
|
||||
"action": "turn_left",
|
||||
"codes": [
|
||||
"ArrowLeft",
|
||||
"KeyA"
|
||||
],
|
||||
"label": "Turn left"
|
||||
},
|
||||
{
|
||||
"action": "turn_right",
|
||||
"codes": [
|
||||
"ArrowRight",
|
||||
"KeyD"
|
||||
],
|
||||
"label": "Turn right"
|
||||
},
|
||||
{
|
||||
"action": "reset",
|
||||
"codes": [
|
||||
"Space"
|
||||
],
|
||||
"label": "Reset"
|
||||
},
|
||||
{
|
||||
"action": "pause",
|
||||
"codes": [
|
||||
"Escape"
|
||||
],
|
||||
"label": "Pause / continue"
|
||||
},
|
||||
{
|
||||
"action": "chaseToggle",
|
||||
"codes": [
|
||||
"KeyC"
|
||||
],
|
||||
"label": "Restore chase camera"
|
||||
},
|
||||
{
|
||||
"action": "skill:dance",
|
||||
"codes": [
|
||||
"KeyJ"
|
||||
],
|
||||
"label": "Dance",
|
||||
"disabled": false
|
||||
},
|
||||
{
|
||||
"action": "skill:wave",
|
||||
"codes": [
|
||||
"KeyH"
|
||||
],
|
||||
"label": "Wave",
|
||||
"disabled": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"render": {
|
||||
"source": "mjcf_visual",
|
||||
"groups": [
|
||||
2
|
||||
],
|
||||
"camera": {
|
||||
"distance": 2.4
|
||||
}
|
||||
},
|
||||
"presentation": {
|
||||
"theme": "comic"
|
||||
},
|
||||
"termination": {
|
||||
"tilt_z": -0.5,
|
||||
"min_height": 0.4,
|
||||
"on_fall": "hold"
|
||||
},
|
||||
"license": "Local evaluation; RP1 mesh license not supplied upstream. Local evaluation only; see SOURCE.md. Actuation omits randomized delay/domain randomization."
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
{
|
||||
"source": "https://github.com/Roboparty/rp1_description",
|
||||
"commit": "d8c6dd03aeecc7f7ead3d962e09fedba4c8460f0",
|
||||
"checkpoint": "/home/cen/Embodied_Workspace/Mujoco_Projects/roboparty_train/logs/rsl_rl/rp1_24dof_flat/2026-10-28_15-47-49/model_9000.pt",
|
||||
"checkpoint_sha256": "5ecf0891f65cff08b2f93fef4326bb097021fb2396598de2d80be38e9247c20e",
|
||||
"iteration": 9000,
|
||||
"training_params_sha256": {
|
||||
"env.yaml": "1b899ff3a774fcba93a64d79298c7e2cc53151fc9ca80461e3c230302fb3fc82",
|
||||
"agent.yaml": "05c11617af2dc7a8efdd0b7ba6deb768e8e59f43dab451b1b6305cacaf9c7ceb"
|
||||
},
|
||||
"source_model_sha256": "4cdb024f9c2a721fa0ef2a7e987ab69ebaf66218bfdd2c20aa91c2f2d5e3495e",
|
||||
"export_max_abs_error": 1.5497207641601562e-06,
|
||||
"files": [
|
||||
{
|
||||
"file": "model.xml",
|
||||
"sha256": "8c663d2cf2382d9ed0c705210c33a11dac12d3fb83eed573e4796b10f9cd5473"
|
||||
},
|
||||
{
|
||||
"file": "policies/walk.onnx",
|
||||
"sha256": "74593afcf52e7cca56e521ad93900d62fc5f9ceefad6114d590bf77f05413be8"
|
||||
},
|
||||
{
|
||||
"file": "LICENSES/RoboLab-BSD-3-Clause.txt",
|
||||
"sha256": "e8dec07c6537300f8dcbf9801c68137c23a0b745b3d7f0278a6d30bc5ed50297"
|
||||
},
|
||||
{
|
||||
"file": "meshes/base_link.STL",
|
||||
"sha256": "8fa93e11010c1d0a35ae79f03638fadfc26335320dbfbbd6ff56b5c6cb3c0d2e"
|
||||
},
|
||||
{
|
||||
"file": "meshes/left_hip_pitch_link.STL",
|
||||
"sha256": "cd12a399efb65721f3c75b73619971eafb26958367c30222ef3110bd4090a19d"
|
||||
},
|
||||
{
|
||||
"file": "meshes/left_hip_roll_link.STL",
|
||||
"sha256": "4ccc27044b9c274cd81dae6775a59036c6449bb3d64fb6ed70294f17046edcb8"
|
||||
},
|
||||
{
|
||||
"file": "meshes/left_hip_yaw_link.STL",
|
||||
"sha256": "e6361ed133e72f2040c88529746d4c17a057d60b0e8d253318fc94bea514e129"
|
||||
},
|
||||
{
|
||||
"file": "meshes/left_knee_link.STL",
|
||||
"sha256": "878aa675f24ad2154265e72c4a3fbed65de041337dfe5c80c74f3333e6f6602a"
|
||||
},
|
||||
{
|
||||
"file": "meshes/left_ankle_pitch_link.STL",
|
||||
"sha256": "c4f5d66f6d6f0eaa0ef232b841d85907fca99ec81013b0682f35277ae16cc9e1"
|
||||
},
|
||||
{
|
||||
"file": "meshes/left_ankle_roll_link.STL",
|
||||
"sha256": "4ac951e3a1adef25aff5d5a9557bab03e293340bb5713cb2b43d3888947560c0"
|
||||
},
|
||||
{
|
||||
"file": "meshes/right_hip_pitch_link.STL",
|
||||
"sha256": "a427e4c982b181623b8f322f45be08ebfc2f73abdf5492afb8728e0fefa80d83"
|
||||
},
|
||||
{
|
||||
"file": "meshes/right_hip_roll_link.STL",
|
||||
"sha256": "52c5c2edb3e83aafdbc633ee10ff4c368993e6c889d6a560d75982da5cc9a799"
|
||||
},
|
||||
{
|
||||
"file": "meshes/right_hip_yaw_link.STL",
|
||||
"sha256": "7e792ca8795b4f44b7de1e2e8747a6c188c10fb8810b17f3269965dde27292bc"
|
||||
},
|
||||
{
|
||||
"file": "meshes/right_knee_link.STL",
|
||||
"sha256": "ffe17fc9ba1614ae86610dc1b657461a3d1d70350729296c9210f68f3934d01d"
|
||||
},
|
||||
{
|
||||
"file": "meshes/right_ankle_pitch_link.STL",
|
||||
"sha256": "f19f73d04f8b0252e4001de541657864c44c5e7da204b7487d24eff162644b6c"
|
||||
},
|
||||
{
|
||||
"file": "meshes/right_ankle_roll_link.STL",
|
||||
"sha256": "057843359003abc4e5ec0a9763833440c42b881f853c1ddbd3945bd1168ff947"
|
||||
},
|
||||
{
|
||||
"file": "meshes/waist_roll_link.STL",
|
||||
"sha256": "500f00489349bf018bbf325d9ed67dd272629b5f37e734a82b141329a9d656df"
|
||||
},
|
||||
{
|
||||
"file": "meshes/waist_yaw_link.STL",
|
||||
"sha256": "36de51037852da450e75b86ef000d145e9e1b37e30925edd3e2307d5c2f449d3"
|
||||
},
|
||||
{
|
||||
"file": "meshes/left_shoulder_pitch_link.STL",
|
||||
"sha256": "2c0eb4ed8ccd410dc2d7f6949829a59d05889ab27ea4944120e8689720e6c40b"
|
||||
},
|
||||
{
|
||||
"file": "meshes/left_shoulder_roll_link.STL",
|
||||
"sha256": "41f6738917180d3aa62798f279e99f4d64ed57950d6138f8e249c7ca629444a9"
|
||||
},
|
||||
{
|
||||
"file": "meshes/left_shoulder_yaw_link.STL",
|
||||
"sha256": "4cfe28c2a31c5b7602c8546cac8fa491a97f1b88cbe579d48034bf857702adbb"
|
||||
},
|
||||
{
|
||||
"file": "meshes/left_elbow_link.STL",
|
||||
"sha256": "45e761a34c5570ec7b200a6b15cf6e5d7dfe61fea1497e1954e17140c3c400b1"
|
||||
},
|
||||
{
|
||||
"file": "meshes/left_wrist_link.STL",
|
||||
"sha256": "1184e55a4a98a75f2d9143e65cd5b1b1f6f42f35c49b4565c94d22f542df7c73"
|
||||
},
|
||||
{
|
||||
"file": "meshes/right_shoulder_pitch_link.STL",
|
||||
"sha256": "21ac44a4e038f09a7f0472490ee06c3ecb5c87cac51fdb645ad4382875235be0"
|
||||
},
|
||||
{
|
||||
"file": "meshes/right_shoulder_roll_link.STL",
|
||||
"sha256": "4435df453ffe4325b6783d217081ec6360d52252ddb87b7f894434eb9e60c39b"
|
||||
},
|
||||
{
|
||||
"file": "meshes/right_shoulder_yaw_link.STL",
|
||||
"sha256": "a88c4bce9e69979ae082de8420a031ca6772a4e0d08ab9f10af4b9617f4ec723"
|
||||
},
|
||||
{
|
||||
"file": "meshes/right_elbow_link.STL",
|
||||
"sha256": "34c9eeeb41588fc9970940d4d82db73ee0c3881613d1a76f0c90421d3b7c8e81"
|
||||
},
|
||||
{
|
||||
"file": "meshes/right_wrist_link.STL",
|
||||
"sha256": "09064a38d9f2bddcc8c6b705811426bc88473c9587221012d08bdbddce94eda2"
|
||||
},
|
||||
{
|
||||
"file": "policies/wave.onnx",
|
||||
"sha256": "1b20142e8ebb41e6aa0424a79fe2fe9abbc015c598acc0444d473f975e7f4ae2"
|
||||
},
|
||||
{
|
||||
"file": "motions/wave.json",
|
||||
"sha256": "54cdcd71d21e8a7e339a3beaf12e4810b753b7eb21b27bf9cd4f66b348823b8e"
|
||||
},
|
||||
{
|
||||
"file": "motions/wave.f32",
|
||||
"sha256": "6e3187978c53410a4faf4e2adad72149c596b274cbab378520d9490d60fbc04a"
|
||||
},
|
||||
{
|
||||
"file": "policies/dance.onnx",
|
||||
"sha256": "ea2b58b4004e62a789bfa8c231c25238c5a7a1347405b804c4f74c7464de9246"
|
||||
},
|
||||
{
|
||||
"file": "motions/dance.json",
|
||||
"sha256": "96df97dcdc8e6ee7c4dd2f0e421eb134877dc3061df72137365d9ce8b91d7a14"
|
||||
},
|
||||
{
|
||||
"file": "motions/dance.f32",
|
||||
"sha256": "4af5c93c4881019f9d5bb03d58a17a6368eecc6c9fe49eef0a05cf814b164522"
|
||||
}
|
||||
],
|
||||
"skills": {
|
||||
"dance": {
|
||||
"checkpoint": "/home/cen/Embodied_Workspace/Mujoco_Projects/roboparty_train/logs/rsl_rl/rp1_24dof_beyondmimic_dance/2026-10-29_11-05-14_dance_resume/model_23998.pt",
|
||||
"checkpoint_sha256": "45f537be2678c4bd956de25719477523900e60d33fda49b6e8b7b2105f16cd84",
|
||||
"iteration": 23998,
|
||||
"configured_iterations": 16000,
|
||||
"initial_iteration": 7999,
|
||||
"expected_final_iteration": 23998,
|
||||
"resumed_from": "/home/cen/Embodied_Workspace/Mujoco_Projects/roboparty_train/logs/rsl_rl/rp1_24dof_beyondmimic_dance/2026-10-28_17-40-59_dance/model_7999.pt",
|
||||
"motion": "/home/cen/Embodied_Workspace/Mujoco_Projects/roboparty_train/robolab/data/motions/rp1_bm/dance1_subject2_smooth6hz.npz",
|
||||
"motion_sha256": "3e56bdff732df480994167462fe7f0fb64a71c398dc09b72c57fb9e43254cf69",
|
||||
"frames": 6573,
|
||||
"fps": 50.0,
|
||||
"actor_observation_group": "student",
|
||||
"export_max_abs_error": 1.3113021850585938e-06,
|
||||
"training_params_sha256": {
|
||||
"env.yaml": "841e1d9266a1dbba371cb7a68b04a778395de04aa6fd2c6b6bbf96897795ce0e",
|
||||
"agent.yaml": "6b92c5f47b25026ff972fe2a833b95b40bfbec187361611e90cd1d18fffcc8bc"
|
||||
},
|
||||
"deployed_duration": 10.0,
|
||||
"validation": "browser-wasm-three-headings-and-transitions-passed",
|
||||
"limitation": "Only the first 10s are qualified for this checkpoint; full 131.46s playback has not been validated."
|
||||
},
|
||||
"wave": {
|
||||
"checkpoint": "/home/cen/Embodied_Workspace/Mujoco_Projects/roboparty_train/logs/rsl_rl/rp1_24dof_beyondmimic_wave/2026-10-28_19-00-23_wave/model_7999.pt",
|
||||
"checkpoint_sha256": "14f33f4b20b7c64b371d4f15d2471d2c72e2fddf5d4a277efaa8f11b9abd8316",
|
||||
"iteration": 7999,
|
||||
"configured_iterations": 8000,
|
||||
"motion": "/home/cen/Embodied_Workspace/Mujoco_Projects/roboparty_train/robolab/data/motions/rp1_bm/wave_R_001__A428.npz",
|
||||
"motion_sha256": "6073c5db30e4dc5c66bb8dfe5b3debd5b7155cee4ad029f89ac03faf05756452",
|
||||
"frames": 218,
|
||||
"fps": 50.0,
|
||||
"actor_observation_group": "student",
|
||||
"export_max_abs_error": 1.9073486328125e-06,
|
||||
"training_params_sha256": {
|
||||
"env.yaml": "b33100d6fd34e79ac9b3e107d9a3eb6302c72c3f8d25e13fb09eaa5a389c4400",
|
||||
"agent.yaml": "1f87d8f271a74ce3872221243021ea71ad7ca28a4c8d95b48bf092f21d0b2947"
|
||||
},
|
||||
"deployed_duration": 4.36,
|
||||
"validation": "browser-wasm-three-headings-and-transitions-passed"
|
||||
}
|
||||
},
|
||||
"training_completed": true
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
"id": "arena",
|
||||
"type": "flat",
|
||||
"presentation": "arena-grid",
|
||||
"scale_to_robot": { "reference_height": 0.27 },
|
||||
"boundary": {
|
||||
"half_extent": 2.25,
|
||||
"wall_height": 0.25,
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Import the user-supplied, self-contained Microban visual GLBs only.
|
||||
|
||||
Usage: python3 app/scripts/import-microban-visuals.py /path/to/microban2.zip
|
||||
Does not modify MJCF, policies or the reviewed body transforms in robot.json.
|
||||
"""
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import struct
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
|
||||
def import_visuals(archive):
|
||||
target = Path(__file__).resolve().parents[1] / "public/robots/microban"
|
||||
links = ["BASE", *(f"LINK{i}" for i in range(1, 20))]
|
||||
names = [f"{link}__visual_0__{link}.glb" for link in links]
|
||||
with zipfile.ZipFile(archive) as source:
|
||||
if sorted(source.namelist()) != sorted(names):
|
||||
raise ValueError("Expected exactly BASE and LINK1..LINK19 GLBs")
|
||||
files = {name: source.read(name) for name in names}
|
||||
# Validate everything before copying any file. Never extract ZIP paths.
|
||||
for name, data in files.items():
|
||||
magic, version, length, json_length, chunk_type = struct.unpack_from(
|
||||
"<5I", data
|
||||
)
|
||||
if (magic, version, length, chunk_type) != (
|
||||
0x46546C67, 2, len(data), 0x4E4F534A
|
||||
):
|
||||
raise ValueError(f"{name}: invalid GLB")
|
||||
gltf = json.loads(data[20:20 + json_length])
|
||||
for asset in [*gltf.get("buffers", []), *gltf.get("images", [])]:
|
||||
if "uri" in asset and not asset["uri"].startswith("data:"):
|
||||
raise ValueError(f"{name}: external buffer/image is unsupported")
|
||||
(target / "visuals").mkdir(exist_ok=True)
|
||||
records = []
|
||||
for name, data in files.items():
|
||||
(target / "visuals" / name).write_bytes(data)
|
||||
records.append({
|
||||
"file": f"visuals/{name}",
|
||||
"sha256": hashlib.sha256(data).hexdigest(),
|
||||
})
|
||||
manifest = {
|
||||
"source": f"User-provided {archive.name} (textured visual replacement)",
|
||||
"archive_sha256": hashlib.sha256(archive.read_bytes()).hexdigest(),
|
||||
"license": "Not supplied in the archive; confirm redistribution rights with the asset owner.",
|
||||
"files": records,
|
||||
}
|
||||
(target / "visual-source-manifest.json").write_text(
|
||||
json.dumps(manifest, indent=2) + "\n"
|
||||
)
|
||||
print(f"Imported {len(records)} visual GLBs; physics/policy files unchanged")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import_visuals(Path(sys.argv[1]))
|
||||
@@ -0,0 +1,188 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Stage a completed RP1 BeyondMimic STUDENT actor + reference. Never starts training.
|
||||
|
||||
Use roboparty_train/.venv/bin/python. Stages skills disabled; enable only after
|
||||
real physics playback/transition validation. Trusted local checkpoints only.
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
|
||||
import numpy as np
|
||||
import onnx
|
||||
from onnx.reference import ReferenceEvaluator
|
||||
import torch
|
||||
import yaml
|
||||
|
||||
|
||||
def sha(path):
|
||||
return hashlib.sha256(path.read_bytes()).hexdigest()
|
||||
|
||||
|
||||
def dump(path, value):
|
||||
temp = path.with_suffix(path.suffix + ".tmp")
|
||||
temp.write_text(json.dumps(value, indent=2, ensure_ascii=False, allow_nan=False) + "\n")
|
||||
temp.replace(path)
|
||||
|
||||
|
||||
def parameter(value, name):
|
||||
if not isinstance(value, dict):
|
||||
return float(value)
|
||||
matches = [float(v) for p, v in value.items() if re.fullmatch(p, name)]
|
||||
if len(matches) != 1:
|
||||
raise ValueError(f"Actuator parameter is ambiguous/missing: {name}")
|
||||
return matches[0]
|
||||
|
||||
|
||||
def main():
|
||||
p = argparse.ArgumentParser(description=__doc__)
|
||||
p.add_argument("--checkpoint", type=Path, required=True)
|
||||
p.add_argument("--skill", choices=["dance", "wave"], required=True)
|
||||
p.add_argument("--duration", type=float, help="Episode seconds; dance defaults to the trained 10s horizon, wave to its full clip")
|
||||
p.add_argument("--package", type=Path, default=Path(__file__).resolve().parents[1] / "public/robots/rp1")
|
||||
args = p.parse_args()
|
||||
cp, target, skill_id = args.checkpoint.resolve(), args.package.resolve(), args.skill
|
||||
params = cp.parent / "params"
|
||||
env = yaml.load((params / "env.yaml").read_text(), Loader=yaml.BaseLoader)
|
||||
agent = yaml.load((params / "agent.yaml").read_text(), Loader=yaml.BaseLoader)
|
||||
config = json.loads((target / "robot.json").read_text())
|
||||
robot, group = env["scene"]["robot"], env["observations"]["student"]
|
||||
names = config["joints"]["groups"]["policy"]
|
||||
action = env["actions"]["joint_pos"]
|
||||
expected_terms = ["command", "base_ang_vel", "projected_gravity", "joint_pos", "joint_vel", "actions"]
|
||||
expected_funcs = ["generated_commands", "base_ang_vel", "projected_gravity", "joint_pos_rel", "joint_vel_rel", "last_action"]
|
||||
terms = [(k, v) for k, v in group.items() if isinstance(v, dict) and "func" in v]
|
||||
if not (
|
||||
agent["obs_groups"]["actor"] == ["student"]
|
||||
and group["history_length"] == "1"
|
||||
and group["concatenate_terms"] == "true"
|
||||
and [k for k, _ in terms] == expected_terms
|
||||
and [v["func"].split(":")[-1] for _, v in terms] == expected_funcs
|
||||
and all(v.get("scale") == "null" and v.get("clip") == "null"
|
||||
and v.get("modifiers") == "null" and v.get("delay_max_lag") == "0" for _, v in terms)
|
||||
and agent["actor"]["activation"] == "elu"
|
||||
and agent["actor"]["obs_normalization"] == "true"
|
||||
and agent["clip_actions"] == "null"
|
||||
and robot["joint_ordering"] == action["joint_names"] == names
|
||||
and action["preserve_order"] == action["use_default_offset"] == "true"
|
||||
and action["clip"] == "null" and float(action["offset"]) == 0
|
||||
and len(names) == 24
|
||||
and all(float(v) == 0 for v in robot["init_state"]["joint_vel"].values())
|
||||
and config["sim"] == {"timestep": float(env["sim"]["dt"]), "decimation": int(env["decimation"])}
|
||||
):
|
||||
raise ValueError("Unsupported logged actor/observation/action contract; update explicitly")
|
||||
actuator = robot["actuators"]["all_joints"]
|
||||
for n in names:
|
||||
for out, key in {"kp": "stiffness", "kd": "damping", "torque_limit": "actuator_effort_limit",
|
||||
"velocity_limit": "actuator_velocity_limit", "keep_velocity": "keep_velocity"}.items():
|
||||
if abs(config["actuation"]["joints"][n][out] - parameter(actuator[key], n)) > 1e-8:
|
||||
raise ValueError(f"Per-skill actuator contract differs: {n}/{out}")
|
||||
before = sha(cp)
|
||||
saved = torch.load(cp, map_location="cpu", weights_only=True)
|
||||
if int(saved["iter"]) < int(agent["max_iterations"]) - 1 or cp.stem != f"model_{saved['iter']}":
|
||||
raise ValueError("Only the final configured checkpoint may be imported")
|
||||
state = saved["actor_state_dict"]
|
||||
shapes = [(512, 126), (256, 512), (128, 256), (24, 128)]
|
||||
if any(tuple(state[f"mlp.{2*i}.weight"].shape) != shape for i, shape in enumerate(shapes)):
|
||||
raise ValueError("Unsupported actor architecture")
|
||||
if any(not torch.isfinite(v).all() for v in state.values()) or (state["obs_normalizer._std"] < 0).any():
|
||||
raise ValueError("Invalid checkpoint tensors")
|
||||
|
||||
class Actor(torch.nn.Module):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.register_buffer("mean", state["obs_normalizer._mean"])
|
||||
self.register_buffer("std", state["obs_normalizer._std"])
|
||||
layers = []
|
||||
for i, (out_size, in_size) in enumerate(shapes):
|
||||
layer = torch.nn.Linear(in_size, out_size)
|
||||
layer.load_state_dict({"weight": state[f"mlp.{2*i}.weight"], "bias": state[f"mlp.{2*i}.bias"]})
|
||||
layers.append(layer)
|
||||
if i < len(shapes) - 1:
|
||||
layers.append(torch.nn.ELU())
|
||||
self.mlp = torch.nn.Sequential(*layers)
|
||||
|
||||
def forward(self, obs):
|
||||
return self.mlp((obs - self.mean) / (self.std + 1e-2))
|
||||
|
||||
motion_file = Path(env["commands"]["motion"]["motion_file"])
|
||||
with np.load(motion_file, allow_pickle=False) as motion:
|
||||
source_names = list(motion["joint_names"].astype(str))
|
||||
order = [source_names.index(n) for n in names]
|
||||
pos, vel = motion["joint_pos"][:, order], motion["joint_vel"][:, order]
|
||||
fps = float(motion["fps"].item())
|
||||
dt = config["sim"]["timestep"] * config["sim"]["decimation"]
|
||||
if abs(fps * dt - 1) > 1e-9 or pos.shape != vel.shape or pos.shape[1] != 24 or len(pos) < 2:
|
||||
raise ValueError("Motion/control clock or shape mismatch (no silent resampling)")
|
||||
if not (np.isfinite(pos).all() and np.isfinite(vel).all()):
|
||||
raise ValueError("Non-finite motion")
|
||||
duration = args.duration if args.duration is not None else min(10.0, len(pos) * dt)
|
||||
if not np.isfinite(duration) or not 0 < duration <= len(pos) * dt:
|
||||
raise ValueError("Duration must be within the reference clip")
|
||||
defaults = {n: float(robot["init_state"]["joint_pos"][n]) for n in names}
|
||||
for folder in ["policies", "motions"]:
|
||||
(target / folder).mkdir(exist_ok=True)
|
||||
policy = target / f"policies/{skill_id}.export.onnx"
|
||||
actor = Actor().eval()
|
||||
torch.onnx.export(actor, torch.zeros(1, 126), str(policy), input_names=["obs"],
|
||||
output_names=["actions"], opset_version=17, dynamo=False)
|
||||
model = onnx.load(policy)
|
||||
onnx.helper.set_model_props(model, {"checkpoint": cp.name, "checkpoint_sha256": before,
|
||||
"iteration": str(saved["iter"]), "actor_observation_group": "student",
|
||||
"joint_names": ",".join(names), "default_joint_pos": ",".join(map(str, defaults.values())),
|
||||
"motion_sha256": sha(motion_file), "status": "completed-training"})
|
||||
onnx.checker.check_model(model)
|
||||
onnx.save(model, policy)
|
||||
evaluator = ReferenceEvaluator(model)
|
||||
rng = np.random.default_rng(42)
|
||||
samples = [np.zeros((1, 126), np.float32), *[rng.normal(size=(1, 126)).astype(np.float32) for _ in range(16)]]
|
||||
standing = np.r_[pos[0], vel[0], [0, 0, 0], [0, 0, -1], np.zeros(72)].astype(np.float32)[None]
|
||||
samples.append(standing)
|
||||
error = 0.0
|
||||
for obs in samples:
|
||||
with torch.no_grad():
|
||||
expected = actor(torch.from_numpy(obs)).numpy()
|
||||
actual = evaluator.run(None, {"obs": obs})[0]
|
||||
np.testing.assert_allclose(actual, expected, rtol=2e-4, atol=2e-5)
|
||||
error = max(error, float(np.max(np.abs(actual - expected))))
|
||||
if before != sha(cp):
|
||||
raise ValueError("Checkpoint changed during export")
|
||||
policy.replace(target / f"policies/{skill_id}.onnx")
|
||||
binary = target / f"motions/{skill_id}.f32"
|
||||
temp = binary.with_suffix(".tmp")
|
||||
temp.write_bytes(np.concatenate([pos.ravel(), vel.ravel()]).astype("<f4").tobytes())
|
||||
temp.replace(binary)
|
||||
dump(target / f"motions/{skill_id}.json", {"schema": 1, "layout": "positions_then_velocities",
|
||||
"dtype": "float32-le", "step_dt": dt, "frames": len(pos), "joint_names": names,
|
||||
"data": f"motions/{skill_id}.f32"})
|
||||
skill = next(s for s in config["skills"] if s["id"] == skill_id)
|
||||
skill.update({"available": False, "duration": duration, "blend": 0.5,
|
||||
"defaults": defaults, "reference": f"motions/{skill_id}.json",
|
||||
"observations": {"obs": {"terms": [{"type": "motion_command", "group": "policy"},
|
||||
{"type": "gyro", "sensor": config["observations"]["obs"]["terms"][0]["sensor"]},
|
||||
{"type": "projected_gravity", "body": "base_link"},
|
||||
{"type": "joint_pos_rel", "group": "policy"}, {"type": "joint_vel", "group": "policy"},
|
||||
{"type": "last_action", "group": "policy"}]}},
|
||||
"actions": [{"type": "joint_position", "group": "policy", "scale": float(action["scale"]), "offset": "default"}],
|
||||
"controller": {"type": "onnx", "policy": f"policies/{skill_id}.onnx"}})
|
||||
next(b for b in config["input"]["bindings"] if b["action"] == f"skill:{skill_id}")["disabled"] = True
|
||||
provenance_path = target / "source-manifest.json"
|
||||
provenance = json.loads(provenance_path.read_text())
|
||||
provenance.setdefault("skills", {})[skill_id] = {"checkpoint": str(cp), "checkpoint_sha256": before,
|
||||
"iteration": int(saved["iter"]), "configured_iterations": int(agent["max_iterations"]),
|
||||
"motion": str(motion_file), "motion_sha256": sha(motion_file), "frames": len(pos), "fps": fps,
|
||||
"actor_observation_group": "student", "export_max_abs_error": error,
|
||||
"training_params_sha256": {n: sha(params / n) for n in ["env.yaml", "agent.yaml"]},
|
||||
"deployed_duration": duration, "validation": "staged-disabled"}
|
||||
for f in [f"policies/{skill_id}.onnx", f"motions/{skill_id}.json", f"motions/{skill_id}.f32"]:
|
||||
provenance["files"] = [r for r in provenance["files"] if r["file"] != f]
|
||||
provenance["files"].append({"file": f, "sha256": sha(target / f)})
|
||||
dump(provenance_path, provenance)
|
||||
dump(target / "robot.json", config)
|
||||
print(f"Staged {skill_id}: final {saved['iter']}, 126→24, {len(pos)} frames / {len(pos)*dt:.2f}s, max error {error:.3g}. DISABLED pending playback validation.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,211 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Import a trusted RP1-Flat checkpoint without starting/stopping Isaac Lab.
|
||||
|
||||
Run with roboparty_train/.venv/bin/python. Never run on an untrusted .pt file.
|
||||
Only the logged 24-DOF Direct/term-major/ELU MLP contract is supported.
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
import numpy as np
|
||||
import onnx
|
||||
from onnx.reference import ReferenceEvaluator
|
||||
import torch
|
||||
import yaml
|
||||
|
||||
|
||||
def dump(path, value):
|
||||
path.write_text(json.dumps(value, indent=2, ensure_ascii=False) + "\n")
|
||||
|
||||
|
||||
def sha(path):
|
||||
return hashlib.sha256(path.read_bytes()).hexdigest()
|
||||
|
||||
|
||||
def resolve_parameter(value, name):
|
||||
if not isinstance(value, dict):
|
||||
return float(value)
|
||||
matches = [float(v) for pattern, v in value.items() if re.fullmatch(pattern, name)]
|
||||
if len(matches) != 1:
|
||||
raise ValueError(f"Ambiguous/missing actuator parameter: {name}")
|
||||
return matches[0]
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--source", type=Path, required=True)
|
||||
parser.add_argument("--checkpoint", type=Path, required=True)
|
||||
parser.add_argument("--policy-only", action="store_true", help="Preserve assets/other skills; replace walk ONNX and provenance only")
|
||||
parser.add_argument("--completed", action="store_true", help="Require final configured iteration and mark walking training complete")
|
||||
args = parser.parse_args()
|
||||
source, checkpoint = args.source.resolve(), args.checkpoint.resolve()
|
||||
public = Path(__file__).resolve().parents[1] / "public" / "robots"
|
||||
target = public / "rp1"
|
||||
params = checkpoint.parent / "params"
|
||||
# BaseLoader reads YAML data only, ignoring Python object construction tags.
|
||||
env = yaml.load((params / "env.yaml").read_text(), Loader=yaml.BaseLoader)
|
||||
agent = yaml.load((params / "agent.yaml").read_text(), Loader=yaml.BaseLoader)
|
||||
robot = env["scene_context"]["robot"]
|
||||
names = robot["joint_ordering"]
|
||||
if not (len(names) == 24 and env["robot"]["observation_history_layout"] == "term_major"
|
||||
and env["robot"]["actor_obs_history_length"] == "3"
|
||||
and agent["actor"]["activation"] == "elu"
|
||||
and agent["actor"]["obs_normalization"] == "true"
|
||||
and all(float(v) == 1 for v in env["normalization"]["obs_scales"].values())):
|
||||
raise ValueError("Unsupported training contract; update importer explicitly")
|
||||
defaults = {n: float(robot["init_state"]["joint_pos"][n]) for n in names}
|
||||
if args.policy_only:
|
||||
current = json.loads((target / "robot.json").read_text())
|
||||
if not (current["joints"]["groups"]["policy"] == names
|
||||
and current["joints"]["defaults"] == defaults
|
||||
and current["actions"][0]["scale"] == float(env["robot"]["action_scale"])
|
||||
and current["sim"] == {"timestep": float(env["sim"]["dt"]), "decimation": int(env["decimation"])}):
|
||||
raise ValueError("Training contract changed; full re-import/revalidation required")
|
||||
saved = torch.load(checkpoint, map_location="cpu", weights_only=True)
|
||||
if args.completed and int(saved["iter"]) < int(agent["max_iterations"]) - 1:
|
||||
raise ValueError("--completed requires the final configured training iteration")
|
||||
state = saved["actor_state_dict"]
|
||||
expected = [(512, 243), (256, 512), (128, 256), (24, 128)]
|
||||
if any(tuple(state[f"mlp.{2*i}.weight"].shape) != shape for i, shape in enumerate(expected)):
|
||||
raise ValueError("Unsupported actor architecture")
|
||||
if any(not torch.isfinite(v).all() for v in state.values()):
|
||||
raise ValueError("Non-finite checkpoint")
|
||||
|
||||
class Actor(torch.nn.Module):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.register_buffer("mean", state["obs_normalizer._mean"])
|
||||
self.register_buffer("std", state["obs_normalizer._std"])
|
||||
layers = []
|
||||
for i, (out_size, in_size) in enumerate(expected):
|
||||
layer = torch.nn.Linear(in_size, out_size)
|
||||
layer.load_state_dict({"weight": state[f"mlp.{2*i}.weight"], "bias": state[f"mlp.{2*i}.bias"]})
|
||||
layers.append(layer)
|
||||
if i < len(expected) - 1:
|
||||
layers.append(torch.nn.ELU())
|
||||
self.mlp = torch.nn.Sequential(*layers)
|
||||
|
||||
def forward(self, obs):
|
||||
# RSL-RL EmpiricalNormalization epsilon is 1e-2, not sqrt(var+eps).
|
||||
action = self.mlp((obs - self.mean) / (self.std + 1e-2))
|
||||
return action.clamp(-float(agent["clip_actions"]), float(agent["clip_actions"]))
|
||||
|
||||
for folder in ["policies", "meshes", "LICENSES"]:
|
||||
(target / folder).mkdir(parents=True, exist_ok=True)
|
||||
actor = Actor().eval()
|
||||
policy = target / "policies" / "walk.export.onnx"
|
||||
torch.onnx.export(actor, torch.zeros(1, 243), str(policy), input_names=["obs"],
|
||||
output_names=["actions"], opset_version=17, dynamo=False)
|
||||
model = onnx.load(policy)
|
||||
onnx.helper.set_model_props(model, {
|
||||
"checkpoint": checkpoint.name, "checkpoint_sha256": sha(checkpoint),
|
||||
"iteration": str(saved["iter"]), "joint_names": ",".join(names),
|
||||
"default_joint_pos": ",".join(str(robot["init_state"]["joint_pos"][n]) for n in names),
|
||||
"history_layout": "term_major", "history_length": "3", "status": "completed-training" if args.completed else "training-preview",
|
||||
})
|
||||
onnx.checker.check_model(model)
|
||||
onnx.save(model, policy)
|
||||
evaluator = ReferenceEvaluator(model)
|
||||
rng = np.random.default_rng(42)
|
||||
max_error = 0.0
|
||||
for obs in [np.zeros((1, 243), dtype=np.float32), *[rng.normal(size=(1, 243)).astype(np.float32) for _ in range(8)]]:
|
||||
with torch.no_grad():
|
||||
expected_action = actor(torch.from_numpy(obs)).numpy()
|
||||
actual = evaluator.run(None, {"obs": obs})[0]
|
||||
np.testing.assert_allclose(actual, expected_action, rtol=2e-4, atol=2e-5)
|
||||
max_error = max(max_error, float(np.abs(actual - expected_action).max()))
|
||||
|
||||
policy.replace(target / "policies" / "walk.onnx")
|
||||
if args.policy_only:
|
||||
provenance_file = target / "source-manifest.json"
|
||||
provenance = json.loads(provenance_file.read_text())
|
||||
provenance.update({"training_completed": args.completed, "checkpoint": str(checkpoint), "checkpoint_sha256": sha(checkpoint),
|
||||
"iteration": int(saved["iter"]), "export_max_abs_error": max_error,
|
||||
"training_params_sha256": {name: sha(params / name) for name in ["env.yaml", "agent.yaml"]}})
|
||||
for record in provenance["files"]:
|
||||
if record["file"] == "policies/walk.onnx":
|
||||
record["sha256"] = sha(target / record["file"])
|
||||
dump(provenance_file, provenance)
|
||||
if args.completed:
|
||||
current["name"] = "RP1"
|
||||
dump(target / "robot.json", current)
|
||||
print(f"Updated walk policy only: iteration {saved['iter']}, max error {max_error:.3g}")
|
||||
return
|
||||
|
||||
asset_root = source / "robolab" / "data" / "robots" / "roboparty" / "rp1"
|
||||
tree = ET.parse(asset_root / "mjcf" / "robot_24dof.xml")
|
||||
root = tree.getroot()
|
||||
root.find("compiler").set("meshdir", ".")
|
||||
assets = []
|
||||
for mesh in root.findall("./asset/mesh"):
|
||||
rel = mesh.attrib["file"]
|
||||
shutil.copyfile(asset_root / rel, target / rel)
|
||||
assets.append({"path": rel, "vfs": rel})
|
||||
tree.write(target / "model.xml", encoding="utf-8", xml_declaration=True)
|
||||
actuator = robot["actuators"]["all_joints"]
|
||||
parameters = {}
|
||||
for name in names:
|
||||
parameters[name] = {out: resolve_parameter(actuator[key], name) for out, key in {
|
||||
"kp": "stiffness", "kd": "damping", "torque_limit": "actuator_effort_limit",
|
||||
"velocity_limit": "actuator_velocity_limit", "keep_velocity": "keep_velocity",
|
||||
}.items()}
|
||||
config = json.loads((public / "microban" / "robot.json").read_text())
|
||||
config.update({
|
||||
"id": "rp1", "family": "rp1", "name": "RP1" if args.completed else "RP1 (training preview)",
|
||||
"dimensions": {"height": 1.32},
|
||||
"assets": assets,
|
||||
"base": {"type": "floating", "root_body": "base_link", "freejoint": "base_link_freejoint",
|
||||
"spawn": {"pos": [float(v) for v in robot["init_state"]["pos"]], "yaw": 0}, "initial": defaults},
|
||||
"sim": {"timestep": float(env["sim"]["dt"]), "decimation": int(env["decimation"])},
|
||||
"joints": {"groups": {"policy": names}, "defaults": defaults},
|
||||
"observations": {"obs": {"history": 3, "layout": "term_major", "terms": [
|
||||
{"type": "gyro", "sensor": "base_ang_vel"},
|
||||
{"type": "projected_gravity", "body": "base_link"},
|
||||
{"type": "command", "size": 3},
|
||||
{"type": "joint_pos_rel", "group": "policy"},
|
||||
{"type": "joint_vel", "group": "policy"},
|
||||
{"type": "last_action", "group": "policy"},
|
||||
]}},
|
||||
"actions": [{"type": "joint_position", "group": "policy", "scale": float(env["robot"]["action_scale"]), "offset": "default"}],
|
||||
"actuation": {"type": "joint_pd", "kp": 120, "kd": 7.5, "torque_limit": 140, "joints": parameters},
|
||||
"commands": {"size": 3, "limits": [0.4, -0.3, 0.6]},
|
||||
"skills": [{"id": "walk", "kind": "primary", "owns": "policy", "controller": {"type": "onnx", "policy": "policies/walk.onnx"}},
|
||||
*[{"id": s, "kind": "episodic", "owns": "policy", "available": False,
|
||||
"duration": d, "blend": 0.5, "controller": {"type": "onnx"}} for s, d in [("dance", 10), ("wave", 4)]]],
|
||||
"render": {"source": "mjcf_visual", "groups": [2], "camera": {"distance": 2.4}},
|
||||
"termination": {"tilt_z": -0.5, "min_height": 0.4, "on_fall": "hold"},
|
||||
"license": "Training preview; RP1 mesh license not supplied upstream. Local evaluation only; see SOURCE.md. Actuation omits randomized delay/domain randomization.",
|
||||
})
|
||||
config["input"]["bindings"] = [b for b in config["input"]["bindings"] if not b["action"].startswith("toggle:")]
|
||||
config["input"]["bindings"].extend([
|
||||
{"action": "skill:dance", "codes": ["KeyJ"], "label": "Dance", "disabled": True},
|
||||
{"action": "skill:wave", "codes": ["KeyH"], "label": "Wave", "disabled": True},
|
||||
])
|
||||
# Sensor name is read from the actual source model, not guessed from other robots.
|
||||
gyros = root.findall("./sensor/gyro")
|
||||
if len(gyros) != 1 or gyros[0].get("site") != "imu":
|
||||
raise ValueError("Expected root-frame IMU gyro")
|
||||
config["observations"]["obs"]["terms"][0]["sensor"] = gyros[0].get("name")
|
||||
dump(target / "robot.json", config)
|
||||
shutil.copyfile(source / "robolab" / "LICENSE", target / "LICENSES" / "RoboLab-BSD-3-Clause.txt")
|
||||
commit = subprocess.check_output(["git", "-C", str(asset_root), "rev-parse", "HEAD"], text=True).strip()
|
||||
files = ["model.xml", "policies/walk.onnx", "LICENSES/RoboLab-BSD-3-Clause.txt", *[a["path"] for a in assets]]
|
||||
dump(target / "source-manifest.json", {
|
||||
"source": "https://github.com/Roboparty/rp1_description", "commit": commit,
|
||||
"training_completed": args.completed, "checkpoint": str(checkpoint), "checkpoint_sha256": sha(checkpoint), "iteration": int(saved["iter"]),
|
||||
"training_params_sha256": {name: sha(params / name) for name in ["env.yaml", "agent.yaml"]},
|
||||
"source_model_sha256": sha(asset_root / "mjcf" / "robot_24dof.xml"),
|
||||
"export_max_abs_error": max_error,
|
||||
"files": [{"file": f, "sha256": sha(target / f)} for f in files],
|
||||
})
|
||||
print(f"Imported {target}: iteration {saved['iter']}, ONNX/PyTorch max error {max_error:.3g}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -7,6 +7,8 @@ import {
|
||||
validateWorld,
|
||||
} from "../src/platform/loader/SchemaValidator.js";
|
||||
import { resolveWorldId } from "../src/platform/worlds/arena.js";
|
||||
import { JointMotionReference } from "../src/platform/policy/JointMotionReference.js";
|
||||
import { validateBodyGlb } from "../src/platform/render/BodyVisuals.js";
|
||||
const root = fileURLToPath(new URL("../public/robots/", import.meta.url));
|
||||
const entries = JSON.parse(await readFile(resolve(root, "index.json"), "utf8"));
|
||||
for (const entry of entries) {
|
||||
@@ -17,11 +19,34 @@ for (const entry of entries) {
|
||||
const paths = [
|
||||
config.model,
|
||||
...config.assets.map((a) => a.path),
|
||||
...(config.render.body_visuals ?? []).map((v) => v.path),
|
||||
...config.skills
|
||||
.filter((s) => s.controller.type === "onnx")
|
||||
.filter((s) => s.controller.type === "onnx" && s.available !== false)
|
||||
.map((s) => s.controller.policy),
|
||||
];
|
||||
for (const skill of config.skills.filter((s) => s.reference)) {
|
||||
const spec = JSON.parse(
|
||||
await readFile(resolve(dirname(file), skill.reference), "utf8"),
|
||||
);
|
||||
const buffer = await readFile(resolve(dirname(file), spec.data));
|
||||
new JointMotionReference(
|
||||
spec,
|
||||
buffer.buffer.slice(
|
||||
buffer.byteOffset,
|
||||
buffer.byteOffset + buffer.byteLength,
|
||||
),
|
||||
config.joints.groups[skill.owns],
|
||||
config.sim.timestep * config.sim.decimation,
|
||||
);
|
||||
paths.push(skill.reference, spec.data);
|
||||
}
|
||||
for (const path of paths) await access(resolve(dirname(file), path));
|
||||
for (const visual of config.render.body_visuals ?? []) {
|
||||
const bytes = await readFile(resolve(dirname(file), visual.path));
|
||||
validateBodyGlb(
|
||||
bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength),
|
||||
);
|
||||
}
|
||||
validateWorld(
|
||||
JSON.parse(
|
||||
await readFile(
|
||||
@@ -30,15 +55,18 @@ for (const entry of entries) {
|
||||
),
|
||||
),
|
||||
);
|
||||
let provenance;
|
||||
try {
|
||||
provenance = JSON.parse(
|
||||
await readFile(resolve(dirname(file), "source-manifest.json"), "utf8"),
|
||||
);
|
||||
} catch (error) {
|
||||
if (error.code !== "ENOENT") throw error;
|
||||
}
|
||||
if (provenance)
|
||||
let hasProvenance = false;
|
||||
for (const name of ["source-manifest.json", "visual-source-manifest.json"]) {
|
||||
let provenance;
|
||||
try {
|
||||
provenance = JSON.parse(
|
||||
await readFile(resolve(dirname(file), name), "utf8"),
|
||||
);
|
||||
} catch (error) {
|
||||
if (error.code !== "ENOENT") throw error;
|
||||
continue;
|
||||
}
|
||||
hasProvenance = true;
|
||||
for (const record of [
|
||||
...provenance.files,
|
||||
...(provenance.additionalNotices ?? []),
|
||||
@@ -51,7 +79,8 @@ for (const entry of entries) {
|
||||
`${entry.id}/${record.file}: source SHA-256 mismatch (check git lfs pull or document asset changes)`,
|
||||
);
|
||||
}
|
||||
}
|
||||
console.log(
|
||||
`${config.id}: schema, World, ${paths.length} resource paths${provenance ? " and source hashes" : ""} OK`,
|
||||
`${config.id}: schema, World, ${paths.length} resource paths${hasProvenance ? " and source hashes" : ""} OK`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -19,13 +19,14 @@ export function createArenaFloorPresentation({ sim, rig, world }) {
|
||||
}
|
||||
const root = new THREE.Group();
|
||||
root.name = "arena-floor-presentation";
|
||||
const grid = makeInfiniteGrid({ subdivisions: 1 });
|
||||
const scale = world?.scale ?? 1;
|
||||
const grid = makeInfiniteGrid({ subdivisions: 1, scale });
|
||||
grid.name = "arena-grid";
|
||||
grid.material.uniforms.uReveal.value = 1;
|
||||
grid.material.uniforms.uTopoScale.value = 0;
|
||||
root.add(grid);
|
||||
const { wallMeshes, wallMats } = world?.boundary
|
||||
? makeArenaWalls(world.boundary)
|
||||
? makeArenaWalls(world.boundary, { scale })
|
||||
: { wallMeshes: [], wallMats: [] };
|
||||
wallMeshes.forEach((mesh, i) => {
|
||||
mesh.name = `arena-boundary-${i}`;
|
||||
|
||||
@@ -15,16 +15,16 @@ import {
|
||||
// Lines derive from world coordinates, so re-centering the mesh under the
|
||||
// camera target every frame makes the grid effectively infinite without any
|
||||
// visible swimming.
|
||||
export function makeInfiniteGrid({ subdivisions = 256 } = {}) {
|
||||
export function makeInfiniteGrid({ subdivisions = 256, scale = 1 } = {}) {
|
||||
const material = new THREE.ShaderMaterial({
|
||||
transparent: true,
|
||||
depthWrite: false,
|
||||
uniforms: {
|
||||
uCell: { value: 0.1 },
|
||||
uSection: { value: GRID_SECTION },
|
||||
uCell: { value: 0.1 * scale },
|
||||
uSection: { value: GRID_SECTION * scale },
|
||||
uCellColor: { value: new THREE.Color(0x8e8371) },
|
||||
uSectionColor: { value: new THREE.Color(0xffb366) },
|
||||
uFadeDist: { value: 3.0 },
|
||||
uFadeDist: { value: 3.0 * scale },
|
||||
uFocus: { value: new THREE.Vector3() },
|
||||
// Entrance draw-in progress; 1 = steady state (branch skipped).
|
||||
// Starts at 0: the world stays hidden behind the welcome modal and
|
||||
@@ -143,7 +143,7 @@ export function makeInfiniteGrid({ subdivisions = 256 } = {}) {
|
||||
// is computed in world space, so the per-frame recentering under the
|
||||
// camera target doesn't move the bumps.
|
||||
const mesh = new THREE.Mesh(
|
||||
new THREE.PlaneGeometry(30, 30, subdivisions, subdivisions),
|
||||
new THREE.PlaneGeometry(30 * scale, 30 * scale, subdivisions, subdivisions),
|
||||
material,
|
||||
);
|
||||
mesh.rotation.x = -Math.PI / 2;
|
||||
@@ -154,19 +154,19 @@ export function makeInfiniteGrid({ subdivisions = 256 } = {}) {
|
||||
// cell/section lines from world coordinates, same radial fade around the
|
||||
// duck, plus a vertical fade toward the top edge so the walls read as a
|
||||
// light enclosure instead of solid slabs.
|
||||
function makeWallGridMaterial(alongX, wallHeight = ARENA_WALL_H) {
|
||||
function makeWallGridMaterial(alongX, wallHeight = ARENA_WALL_H, scale = 1) {
|
||||
return new THREE.ShaderMaterial({
|
||||
transparent: true,
|
||||
depthWrite: false,
|
||||
side: THREE.DoubleSide,
|
||||
uniforms: {
|
||||
uCell: { value: 0.1 },
|
||||
uSection: { value: GRID_SECTION },
|
||||
uCell: { value: 0.1 * scale },
|
||||
uSection: { value: GRID_SECTION * scale },
|
||||
uCellColor: { value: new THREE.Color(0x8e8371) },
|
||||
uSectionColor: { value: new THREE.Color(0xffb366) },
|
||||
// Gentler radial fade than the floor: the walls sit 1.5+ m from the
|
||||
// duck by construction and would vanish with the floor's 3 m fade.
|
||||
uFadeDist: { value: 5.0 },
|
||||
uFadeDist: { value: 5.0 * scale },
|
||||
uFocus: { value: new THREE.Vector3() },
|
||||
uWallH: { value: wallHeight },
|
||||
uAlongX: { value: alongX ? 1.0 : 0.0 },
|
||||
@@ -286,11 +286,14 @@ export function entranceLineCues() {
|
||||
// The four wall planes at their inner faces (three coords: MJCF x -> x,
|
||||
// MJCF y -> -z). Returns the meshes plus their materials (the ceremony and
|
||||
// the per-frame focus update both need the material list).
|
||||
export function makeArenaWalls({
|
||||
half_extent = ARENA_HALF,
|
||||
wall_height = ARENA_WALL_H,
|
||||
wall_thickness = ARENA_WALL_T,
|
||||
} = {}) {
|
||||
export function makeArenaWalls(
|
||||
{
|
||||
half_extent = ARENA_HALF,
|
||||
wall_height = ARENA_WALL_H,
|
||||
wall_thickness = ARENA_WALL_T,
|
||||
} = {},
|
||||
{ scale = 1 } = {},
|
||||
) {
|
||||
const wallMats = [];
|
||||
const wallMeshes = [];
|
||||
const wallLen = 2 * (half_extent + wall_thickness);
|
||||
@@ -301,7 +304,7 @@ export function makeArenaWalls({
|
||||
{ x: 0, z: -half_extent, rotY: 0, alongX: true },
|
||||
];
|
||||
for (const [index, w] of wallDefs.entries()) {
|
||||
const mat = makeWallGridMaterial(w.alongX, wall_height);
|
||||
const mat = makeWallGridMaterial(w.alongX, wall_height, scale);
|
||||
wallMats.push(mat);
|
||||
const mesh = new THREE.Mesh(
|
||||
new THREE.PlaneGeometry(wallLen, wall_height),
|
||||
|
||||
@@ -28,7 +28,9 @@ export class InputRouter {
|
||||
constructor({ bindings, getVelocityLimits, isEnabled = () => true }) {
|
||||
Object.assign(this, { bindings, getVelocityLimits, isEnabled });
|
||||
this.byCode = new Map(
|
||||
bindings.flatMap((b) => b.codes.map((code) => [code, b.action])),
|
||||
bindings
|
||||
.filter((b) => !b.disabled)
|
||||
.flatMap((b) => b.codes.map((code) => [code, b.action])),
|
||||
);
|
||||
}
|
||||
init(target = window) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { validatePackage, validateWorld } from "./SchemaValidator.js";
|
||||
import { DEFAULT_WORLD } from "../worlds/arena.js";
|
||||
import { DEFAULT_WORLD, fitWorldToRobot } from "../worlds/arena.js";
|
||||
export function assetUrl(path, base, location = globalThis.location) {
|
||||
const url = new URL(path, base);
|
||||
if (location && url.origin !== location.origin)
|
||||
@@ -43,7 +43,7 @@ export async function loadIndex() {
|
||||
url: assetUrl(entry.manifest, base),
|
||||
}));
|
||||
}
|
||||
export async function loadWorld(id = DEFAULT_WORLD) {
|
||||
export async function loadWorld(id = DEFAULT_WORLD, config) {
|
||||
const base = new URL(
|
||||
`${import.meta.env.BASE_URL}worlds/${id}/`,
|
||||
location.origin,
|
||||
@@ -52,5 +52,5 @@ export async function loadWorld(id = DEFAULT_WORLD) {
|
||||
validateWorld(world);
|
||||
if (world.id !== id)
|
||||
throw new Error(`worlds/${id}: unsupported World schema`);
|
||||
return world;
|
||||
return fitWorldToRobot(world, config);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,10 @@ function assertSchema(check, value, label) {
|
||||
}
|
||||
export function validateWorld(world) {
|
||||
assertSchema(checkWorld, world, "world.json");
|
||||
if (world.scale_to_robot && (world.type !== "flat" || !world.boundary))
|
||||
throw new Error(
|
||||
"world.json /scale_to_robot: requires a flat World with boundary",
|
||||
);
|
||||
if (world.boundary && world.type !== "flat")
|
||||
throw new Error("world.json /boundary: requires a flat World");
|
||||
if (world.type === "flat" && !world.floor)
|
||||
@@ -37,7 +41,11 @@ export function validatePackage(config) {
|
||||
ids.add(skill.id);
|
||||
if (!groups[skill.owns])
|
||||
throw new Error(`skills.${skill.id}.owns: unknown group ${skill.owns}`);
|
||||
if (skill.controller.type === "onnx" && !skill.controller.policy)
|
||||
if (
|
||||
skill.controller.type === "onnx" &&
|
||||
skill.available !== false &&
|
||||
!skill.controller.policy
|
||||
)
|
||||
throw new Error(`skills.${skill.id}.controller.policy: required`);
|
||||
if (skill.kind === "primary") primaries++;
|
||||
if (skill.kind === "overlay")
|
||||
@@ -50,17 +58,92 @@ export function validatePackage(config) {
|
||||
if (
|
||||
config.adapter === "generic" &&
|
||||
(primaries !== 1 ||
|
||||
config.skills.some((s) => !["primary", "overlay"].includes(s.kind)))
|
||||
config.skills.some(
|
||||
(s) => !["primary", "overlay", "episodic"].includes(s.kind),
|
||||
))
|
||||
)
|
||||
throw new Error(
|
||||
"generic runtime requires one primary and disjoint overlays",
|
||||
"generic runtime requires one primary, disjoint overlays and optional episodic skills",
|
||||
);
|
||||
for (const obs of Object.values(config.observations))
|
||||
const primary = config.skills.find((s) => s.kind === "primary");
|
||||
if (config.adapter === "generic") {
|
||||
if (primary.available === false || primary.controller.type !== "onnx")
|
||||
throw new Error("primary: an available ONNX controller is required");
|
||||
for (const skill of config.skills) {
|
||||
if (skill.available === false && skill.kind !== "episodic")
|
||||
throw new Error(
|
||||
"available:false is only supported for episodic skills",
|
||||
);
|
||||
if (skill.kind === "overlay" && skill.controller.type !== "oscillator")
|
||||
throw new Error("overlay: oscillator required");
|
||||
if (
|
||||
skill.kind === "episodic" &&
|
||||
(skill.owns !== primary.owns ||
|
||||
skill.controller.type !== "onnx" ||
|
||||
!skill.duration ||
|
||||
!skill.blend)
|
||||
)
|
||||
throw new Error(
|
||||
"episodic: requires primary ownership, ONNX, duration and blend",
|
||||
);
|
||||
if (
|
||||
skill.kind !== "episodic" &&
|
||||
(skill.observations ||
|
||||
skill.actions ||
|
||||
skill.defaults ||
|
||||
skill.reference)
|
||||
)
|
||||
throw new Error(
|
||||
"per-skill observations/actions/defaults require an episodic skill",
|
||||
);
|
||||
const motionTerms = Object.values(
|
||||
skill.observations ?? config.observations,
|
||||
)
|
||||
.flatMap((spec) => spec.terms)
|
||||
.filter((term) => term.type === "motion_command");
|
||||
if (motionTerms.length && (!skill.reference || skill.kind !== "episodic"))
|
||||
throw new Error(
|
||||
`skills.${skill.id}: motion_command requires an episodic reference`,
|
||||
);
|
||||
if (motionTerms.some((term) => term.group !== skill.owns))
|
||||
throw new Error(
|
||||
`skills.${skill.id}: motion reference must use owned joint order`,
|
||||
);
|
||||
for (const name of Object.keys(skill.defaults ?? {}))
|
||||
if (!groups[skill.owns].includes(name))
|
||||
throw new Error(
|
||||
`skills.${skill.id}.defaults: unknown owned joint ${name}`,
|
||||
);
|
||||
}
|
||||
for (const skill of config.skills.filter((s) =>
|
||||
["primary", "episodic"].includes(s.kind),
|
||||
)) {
|
||||
for (const action of skill.actions ?? config.actions)
|
||||
if (!groups[action.group])
|
||||
throw new Error(`actions: unknown group ${action.group}`);
|
||||
const names = (skill.actions ?? config.actions).flatMap(
|
||||
(a) => groups[a.group],
|
||||
);
|
||||
if (JSON.stringify(names) !== JSON.stringify(groups[skill.owns]))
|
||||
throw new Error(
|
||||
`skills.${skill.id}: action order must match owned joints`,
|
||||
);
|
||||
}
|
||||
}
|
||||
for (const obs of [
|
||||
config.observations,
|
||||
...config.skills.map((s) => s.observations).filter(Boolean),
|
||||
].flatMap(Object.values))
|
||||
for (const term of obs.terms) {
|
||||
if (term.group && !groups[term.group])
|
||||
throw new Error(`observations: unknown group ${term.group}`);
|
||||
if (
|
||||
["joint_pos_rel", "joint_vel", "last_action"].includes(term.type) &&
|
||||
[
|
||||
"joint_pos_rel",
|
||||
"joint_vel",
|
||||
"last_action",
|
||||
"motion_command",
|
||||
].includes(term.type) &&
|
||||
!term.group
|
||||
)
|
||||
throw new Error(`${term.type}: group required`);
|
||||
@@ -76,7 +159,10 @@ export function validatePackage(config) {
|
||||
"observations.command: size missing or exceeds command buffer",
|
||||
);
|
||||
}
|
||||
for (const action of config.actions)
|
||||
for (const action of [
|
||||
config.actions,
|
||||
...config.skills.map((s) => s.actions).filter(Boolean),
|
||||
].flat())
|
||||
if (!groups[action.group])
|
||||
throw new Error(`actions: unknown group ${action.group}`);
|
||||
if (
|
||||
@@ -86,6 +172,17 @@ export function validatePackage(config) {
|
||||
)
|
||||
)
|
||||
throw new Error("actuation: PD gains and torque_limit required");
|
||||
for (const [name, p] of Object.entries(config.actuation.joints ?? {})) {
|
||||
if (!Object.values(groups).flat().includes(name))
|
||||
throw new Error(`actuation.joints: unknown joint ${name}`);
|
||||
if (
|
||||
(p.velocity_limit !== undefined || p.keep_velocity !== undefined) &&
|
||||
!(p.keep_velocity > 0 && p.keep_velocity < p.velocity_limit)
|
||||
)
|
||||
throw new Error(
|
||||
`actuation.${name}: keep_velocity must lie within velocity_limit`,
|
||||
);
|
||||
}
|
||||
const codes = new Set();
|
||||
for (const binding of config.input.bindings) {
|
||||
if (
|
||||
@@ -101,9 +198,19 @@ export function validatePackage(config) {
|
||||
...config.skills
|
||||
.filter((s) => s.kind === "overlay")
|
||||
.map((s) => `toggle:${s.id}`),
|
||||
...config.skills
|
||||
.filter((s) => s.kind === "episodic")
|
||||
.map((s) => `skill:${s.id}`),
|
||||
].includes(binding.action)
|
||||
)
|
||||
throw new Error(`input: unsupported action ${binding.action}`);
|
||||
if (binding.action.startsWith("skill:")) {
|
||||
const skill = config.skills.find((s) => s.id === binding.action.slice(6));
|
||||
if (skill && (skill.available === false) !== (binding.disabled === true))
|
||||
throw new Error(
|
||||
`input.${binding.action}: disabled must match skill availability`,
|
||||
);
|
||||
}
|
||||
for (const code of binding.codes) {
|
||||
if (codes.has(code)) throw new Error(`input: duplicate ${code}`);
|
||||
codes.add(code);
|
||||
@@ -111,6 +218,21 @@ export function validatePackage(config) {
|
||||
}
|
||||
if (config.adapter === "generic" && config.render.source !== "mjcf_visual")
|
||||
throw new Error("render.source: generic runtime requires mjcf_visual");
|
||||
const visualBodies = new Set();
|
||||
for (const visual of config.render.body_visuals ?? []) {
|
||||
if (config.adapter !== "generic")
|
||||
throw new Error("render.body_visuals: requires the generic runtime");
|
||||
if (visualBodies.has(visual.body))
|
||||
throw new Error(`render.body_visuals: duplicate body ${visual.body}`);
|
||||
visualBodies.add(visual.body);
|
||||
if (
|
||||
visual.quaternion &&
|
||||
Math.abs(Math.hypot(...visual.quaternion) - 1) > 1e-6
|
||||
)
|
||||
throw new Error(
|
||||
"render.body_visuals: quaternion must have unit length (xyzw)",
|
||||
);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
export { schema as robotSchema };
|
||||
|
||||
@@ -60,6 +60,14 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"dimensions": {
|
||||
"type": "object",
|
||||
"required": ["height"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"height": { "type": "number", "exclusiveMinimum": 0 }
|
||||
}
|
||||
},
|
||||
"base": {
|
||||
"type": "object",
|
||||
"required": ["type", "root_body", "freejoint", "spawn"],
|
||||
@@ -161,6 +169,8 @@
|
||||
"required": ["terms"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"history": { "type": "integer", "minimum": 1, "maximum": 64 },
|
||||
"layout": { "enum": ["frame_major", "term_major"] },
|
||||
"terms": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
@@ -176,6 +186,7 @@
|
||||
"joint_pos_rel",
|
||||
"joint_vel",
|
||||
"last_action",
|
||||
"motion_command",
|
||||
"command"
|
||||
]
|
||||
},
|
||||
@@ -240,6 +251,20 @@
|
||||
"torque_limit": {
|
||||
"type": "number",
|
||||
"exclusiveMinimum": 0
|
||||
},
|
||||
"joints": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"kp": { "type": "number", "minimum": 0 },
|
||||
"kd": { "type": "number", "minimum": 0 },
|
||||
"torque_limit": { "type": "number", "exclusiveMinimum": 0 },
|
||||
"velocity_limit": { "type": "number", "exclusiveMinimum": 0 },
|
||||
"keep_velocity": { "type": "number", "exclusiveMinimum": 0 }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -279,6 +304,13 @@
|
||||
"owns": {
|
||||
"type": "string"
|
||||
},
|
||||
"available": { "type": "boolean" },
|
||||
"duration": { "type": "number", "exclusiveMinimum": 0 },
|
||||
"blend": { "type": "number", "exclusiveMinimum": 0 },
|
||||
"observations": { "$ref": "#/properties/observations" },
|
||||
"actions": { "$ref": "#/properties/actions" },
|
||||
"defaults": { "$ref": "#/properties/joints/properties/defaults" },
|
||||
"reference": { "type": "string", "minLength": 1 },
|
||||
"controller": {
|
||||
"type": "object",
|
||||
"required": ["type"],
|
||||
@@ -332,7 +364,8 @@
|
||||
},
|
||||
"label": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"disabled": { "type": "boolean" }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -346,6 +379,34 @@
|
||||
"source": {
|
||||
"enum": ["glb", "mjcf_visual"]
|
||||
},
|
||||
"body_visuals": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["body", "path"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"body": { "type": "string", "minLength": 1 },
|
||||
"path": {
|
||||
"type": "string",
|
||||
"pattern": "^(?!/)(?!.*\\.\\.)[^\\\\:?#]+\\.glb$"
|
||||
},
|
||||
"position": {
|
||||
"type": "array",
|
||||
"minItems": 3,
|
||||
"maxItems": 3,
|
||||
"items": { "type": "number" }
|
||||
},
|
||||
"quaternion": {
|
||||
"type": "array",
|
||||
"minItems": 4,
|
||||
"maxItems": 4,
|
||||
"items": { "type": "number" }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"groups": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
|
||||
@@ -8,14 +8,22 @@
|
||||
"type": { "enum": ["flat", "adapter"] },
|
||||
"adapter": { "type": "string", "minLength": 1 },
|
||||
"presentation": { "enum": ["arena-grid"] },
|
||||
"scale_to_robot": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["reference_height"],
|
||||
"properties": {
|
||||
"reference_height": { "type": "number", "exclusiveMinimum": 0 }
|
||||
}
|
||||
},
|
||||
"boundary": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["half_extent", "wall_height", "wall_thickness"],
|
||||
"properties": {
|
||||
"half_extent": {"type":"number","exclusiveMinimum":0},
|
||||
"wall_height": {"type":"number","exclusiveMinimum":0},
|
||||
"wall_thickness": {"type":"number","exclusiveMinimum":0}
|
||||
"half_extent": { "type": "number", "exclusiveMinimum": 0 },
|
||||
"wall_height": { "type": "number", "exclusiveMinimum": 0 },
|
||||
"wall_thickness": { "type": "number", "exclusiveMinimum": 0 }
|
||||
}
|
||||
},
|
||||
"floor": {
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
import { fetchChecked } from "../loader/PackageLoader.js";
|
||||
|
||||
// A trained command stream, not a kinematic animation: only observations read
|
||||
// these samples. Neither qpos nor joint targets are written by this provider.
|
||||
export class JointMotionReference {
|
||||
static async load(pkg, path, names, dt) {
|
||||
const spec = await fetchChecked(pkg.asset(path), "json");
|
||||
const bytes = await fetchChecked(pkg.asset(spec.data), "bytes");
|
||||
return new JointMotionReference(spec, bytes, names, dt);
|
||||
}
|
||||
constructor(spec, bytes, names, dt) {
|
||||
if (
|
||||
spec.schema !== 1 ||
|
||||
spec.layout !== "positions_then_velocities" ||
|
||||
spec.dtype !== "float32-le" ||
|
||||
!Number.isInteger(spec.frames) ||
|
||||
spec.frames < 2 ||
|
||||
!Number.isFinite(spec.step_dt) ||
|
||||
spec.step_dt <= 0 ||
|
||||
Math.abs(spec.step_dt - dt) > 1e-9 ||
|
||||
JSON.stringify(spec.joint_names) !== JSON.stringify(names)
|
||||
)
|
||||
throw new Error(
|
||||
"Motion reference: unsupported layout, joint order or control clock",
|
||||
);
|
||||
const count = spec.frames * names.length;
|
||||
if (bytes.byteLength !== count * 2 * 4)
|
||||
throw new Error(
|
||||
"Motion reference: truncated/incorrect sample count (check git lfs pull)",
|
||||
);
|
||||
const view = new DataView(bytes);
|
||||
this.values = new Float32Array(count * 2);
|
||||
for (let i = 0; i < this.values.length; i++) {
|
||||
const v = view.getFloat32(i * 4, true);
|
||||
if (!Number.isFinite(v))
|
||||
throw new Error("Motion reference: non-finite sample");
|
||||
this.values[i] = v;
|
||||
}
|
||||
Object.assign(this, {
|
||||
frames: spec.frames,
|
||||
dt: spec.step_dt,
|
||||
width: names.length,
|
||||
count,
|
||||
});
|
||||
this.reset();
|
||||
}
|
||||
reset() {
|
||||
this.start = null;
|
||||
this.frame = 0;
|
||||
}
|
||||
sample(time) {
|
||||
if (!Number.isFinite(time))
|
||||
throw new Error("Motion reference: invalid simulation time");
|
||||
this.start ??= time;
|
||||
this.frame = Math.min(
|
||||
this.frames - 1,
|
||||
Math.max(0, Math.floor((time - this.start + 1e-9) / this.dt)),
|
||||
);
|
||||
}
|
||||
write(out, offset) {
|
||||
const a = this.frame * this.width;
|
||||
out.set(this.values.subarray(a, a + this.width), offset);
|
||||
out.set(
|
||||
this.values.subarray(this.count + a, this.count + a + this.width),
|
||||
offset + this.width,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ export class ObservationPipeline {
|
||||
this.inputs = {};
|
||||
this.ops = [];
|
||||
this.details = {};
|
||||
this.history = new Map();
|
||||
for (const [name, spec] of Object.entries(specs)) {
|
||||
let offset = 0;
|
||||
const terms = [];
|
||||
@@ -64,15 +65,64 @@ export class ObservationPipeline {
|
||||
});
|
||||
offset += size;
|
||||
}
|
||||
if (buffers[name] && buffers[name].length !== offset)
|
||||
const length = spec.history ?? 1;
|
||||
const size = offset * length;
|
||||
if (buffers[name] && buffers[name].length !== size)
|
||||
throw new Error(`Observation buffer ${name}: incorrect size`);
|
||||
this.inputs[name] = buffers[name] ?? new Float32Array(offset);
|
||||
this.inputs[name] = buffers[name] ?? new Float32Array(size);
|
||||
this.history.set(name, {
|
||||
length,
|
||||
layout: spec.layout ?? "frame_major",
|
||||
terms,
|
||||
frame: new Float32Array(offset),
|
||||
frames: new Float32Array(size),
|
||||
initialized: false,
|
||||
});
|
||||
this.details[name] = terms;
|
||||
}
|
||||
}
|
||||
write() {
|
||||
reset() {
|
||||
for (const h of this.history.values()) h.initialized = false;
|
||||
}
|
||||
write({ advance = true } = {}) {
|
||||
for (const op of this.ops)
|
||||
op.implementation.write(this.inputs[op.name], op.offset, this.ctx, op);
|
||||
op.implementation.write(
|
||||
this.history.get(op.name).frame,
|
||||
op.offset,
|
||||
this.ctx,
|
||||
op,
|
||||
);
|
||||
for (const [name, h] of this.history) {
|
||||
const size = h.frame.length;
|
||||
// Diagnostic reads sample live physics without pushing the history clock.
|
||||
const frames = advance ? h.frames : h.frames.slice();
|
||||
if (!h.initialized) {
|
||||
// Isaac Lab CircularBuffer backfills every slot on the first sample.
|
||||
for (let i = 0; i < h.length; i++) frames.set(h.frame, i * size);
|
||||
h.initialized = advance;
|
||||
} else {
|
||||
if (advance) frames.copyWithin(0, size);
|
||||
frames.set(h.frame, (h.length - 1) * size);
|
||||
}
|
||||
const out = this.inputs[name];
|
||||
if (h.layout === "frame_major") out.set(frames);
|
||||
else {
|
||||
let offset = 0;
|
||||
for (const term of h.terms)
|
||||
for (let i = 0; i < h.length; i++) {
|
||||
out.set(
|
||||
frames.subarray(
|
||||
i * size + term.offset,
|
||||
i * size + term.offset + term.size,
|
||||
),
|
||||
offset,
|
||||
);
|
||||
offset += term.size;
|
||||
}
|
||||
}
|
||||
if (!out.every(Number.isFinite))
|
||||
throw new Error(`observations.${name}: non-finite tensor`);
|
||||
}
|
||||
return this.inputs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,14 @@ observationTerms.register("command", {
|
||||
for (let i = 0; i < op.term.size; i++) out[offset + i] = c.command[i];
|
||||
},
|
||||
});
|
||||
observationTerms.register("motion_command", {
|
||||
size: (_term, _ctx, names) => names.length * 2,
|
||||
init: (_term, ctx) => {
|
||||
if (!ctx.reference)
|
||||
throw new Error("motion_command: missing per-skill reference");
|
||||
},
|
||||
write: (out, offset, ctx) => ctx.reference.write(out, offset),
|
||||
});
|
||||
for (const type of ["joint_pos_rel", "joint_vel", "last_action"])
|
||||
observationTerms.register(type, {
|
||||
size: (_term, _ctx, names) => names.length,
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import { ObservationPipeline } from "../ObservationPipeline.js";
|
||||
import { ActionPipeline } from "../ActionPipeline.js";
|
||||
import { OnnxController } from "./OnnxController.js";
|
||||
|
||||
// Common lifecycle for independently trained, feed-forward joint-target skills.
|
||||
export class OnnxPolicy {
|
||||
static async load(ort, bytes, config, shared, skill, reference = null) {
|
||||
let session;
|
||||
try {
|
||||
const ctx = {
|
||||
...shared,
|
||||
reference,
|
||||
defaults: new Map([
|
||||
...shared.defaults,
|
||||
...Object.entries(skill.defaults ?? {}),
|
||||
]),
|
||||
lastAction: new Float32Array(shared.policyNames.length),
|
||||
};
|
||||
const obs = new ObservationPipeline(
|
||||
skill.observations ?? config.observations,
|
||||
ctx,
|
||||
);
|
||||
const actions = new ActionPipeline(skill.actions ?? config.actions, ctx);
|
||||
session = await ort.InferenceSession.create(bytes, {
|
||||
executionProviders: ["wasm"],
|
||||
});
|
||||
const controller = new OnnxController(ort, session, obs, actions.size);
|
||||
obs.write();
|
||||
const smoke = await controller.run();
|
||||
if (smoke.length !== actions.size || !smoke.every(Number.isFinite))
|
||||
throw new Error(`ONNX ${skill.id}: standing-pose smoke test failed`);
|
||||
const policy = new OnnxPolicy();
|
||||
Object.assign(policy, { ctx, obs, actions, controller });
|
||||
policy.reset();
|
||||
return policy;
|
||||
} catch (error) {
|
||||
await session?.release();
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
reset() {
|
||||
this.ctx.lastAction.fill(0);
|
||||
this.ctx.reference?.reset();
|
||||
this.obs.reset();
|
||||
}
|
||||
async run() {
|
||||
this.ctx.reference?.sample(this.ctx.sim.data.time);
|
||||
this.obs.write();
|
||||
this.actions.apply(await this.controller.run());
|
||||
}
|
||||
dispose() {
|
||||
return this.controller.dispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
import * as THREE from "three";
|
||||
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
|
||||
import { fetchChecked } from "../loader/PackageLoader.js";
|
||||
|
||||
// Body GLBs must be self-contained: external image/buffer URIs would bypass
|
||||
// PackageLoader's same-origin, hosting-prefix and signed-URL handling.
|
||||
export function validateBodyGlb(buffer) {
|
||||
const view = new DataView(buffer);
|
||||
if (
|
||||
buffer.byteLength < 20 ||
|
||||
view.getUint32(0, true) !== 0x46546c67 ||
|
||||
view.getUint32(4, true) !== 2 ||
|
||||
view.getUint32(8, true) !== buffer.byteLength ||
|
||||
view.getUint32(16, true) !== 0x4e4f534a ||
|
||||
view.getUint32(12, true) > buffer.byteLength - 20
|
||||
)
|
||||
throw new Error("Body visual: invalid GLB (check git lfs pull)");
|
||||
const json = JSON.parse(
|
||||
new TextDecoder().decode(
|
||||
new Uint8Array(buffer, 20, view.getUint32(12, true)),
|
||||
),
|
||||
);
|
||||
for (const asset of [...(json.buffers ?? []), ...(json.images ?? [])])
|
||||
if (asset.uri && !asset.uri.startsWith("data:"))
|
||||
throw new Error("Body visual: GLB must embed all buffers and images");
|
||||
return json;
|
||||
}
|
||||
|
||||
// Visual-only layer. Nothing here changes the compiled model, qpos, collision
|
||||
// geoms or policy inputs. Each attachment follows a MuJoCo body, not an
|
||||
// independently animated skeleton or the compiler-recentered STL geom frame.
|
||||
export class BodyVisuals {
|
||||
static async load(mujoco, model, data, pkg) {
|
||||
const specs = pkg.config.render.body_visuals ?? [];
|
||||
const ids = specs.map(({ body }) => {
|
||||
const id = mujoco.mj_name2id(model, mujoco.mjtObj.mjOBJ_BODY.value, body);
|
||||
if (id <= 0) throw new Error(`Body visual: missing robot body ${body}`);
|
||||
return id;
|
||||
});
|
||||
const visuals = new BodyVisuals(data);
|
||||
const loader = new GLTFLoader();
|
||||
try {
|
||||
// Sequential parsing keeps ownership unambiguous on a failed candidate:
|
||||
// no outstanding parse may allocate resources after dispose() returns.
|
||||
for (let i = 0; i < specs.length; i++) {
|
||||
const spec = specs[i];
|
||||
const bytes = await fetchChecked(pkg.asset(spec.path), "bytes");
|
||||
validateBodyGlb(bytes);
|
||||
const gltf = await loader.parseAsync(bytes, "");
|
||||
// Retain every scene for cleanup, including non-default glTF scenes.
|
||||
visuals.scenes.push(...gltf.scenes);
|
||||
const frame = new THREE.Group();
|
||||
frame.name = `body-visual:${spec.body}`;
|
||||
gltf.scene.position.fromArray(spec.position ?? [0, 0, 0]);
|
||||
gltf.scene.quaternion.fromArray(spec.quaternion ?? [0, 0, 0, 1]);
|
||||
frame.add(gltf.scene);
|
||||
visuals.root.add(frame);
|
||||
visuals.items.push({ id: ids[i], frame });
|
||||
}
|
||||
visuals.sync();
|
||||
return visuals;
|
||||
} catch (error) {
|
||||
visuals.dispose();
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
constructor(data) {
|
||||
this.data = data;
|
||||
this.root = new THREE.Group();
|
||||
this.root.name = "body-visuals";
|
||||
this.items = [];
|
||||
this.scenes = [];
|
||||
}
|
||||
sync() {
|
||||
for (const { id, frame } of this.items) {
|
||||
frame.position.fromArray(this.data.xpos, id * 3);
|
||||
const a = id * 4,
|
||||
q = this.data.xquat;
|
||||
frame.quaternion.set(q[a + 1], q[a + 2], q[a + 3], q[a]);
|
||||
}
|
||||
}
|
||||
dispose() {
|
||||
if (this.disposed) return;
|
||||
this.disposed = true;
|
||||
const geometries = new Set(),
|
||||
materials = new Set(),
|
||||
textures = new Set(),
|
||||
images = new Set();
|
||||
for (const scene of this.scenes)
|
||||
scene.traverse((object) => {
|
||||
if (object.geometry) geometries.add(object.geometry);
|
||||
for (const material of [object.material].flat().filter(Boolean)) {
|
||||
materials.add(material);
|
||||
for (const value of Object.values(material))
|
||||
if (value?.isTexture) textures.add(value);
|
||||
}
|
||||
});
|
||||
for (const geometry of geometries) geometry.dispose();
|
||||
for (const material of materials) material.dispose();
|
||||
for (const texture of textures) {
|
||||
for (const image of [texture.source?.data].flat().filter(Boolean))
|
||||
images.add(image);
|
||||
texture.dispose();
|
||||
}
|
||||
for (const image of images) image.close?.();
|
||||
this.root.removeFromParent();
|
||||
this.root.clear();
|
||||
this.scenes = [];
|
||||
this.items = [];
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as THREE from "three";
|
||||
import { applyWorldGrid } from "./WorldRenderer.js";
|
||||
import { BodyVisuals } from "./BodyVisuals.js";
|
||||
// Geometry is compiled MuJoCo geometry, not raw STL: compiler-applied mesh
|
||||
// scale/centering is already represented by vertices + geom transforms.
|
||||
export class RigRenderer {
|
||||
@@ -91,7 +92,21 @@ export class RigRenderer {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
async loadBodyVisuals(mujoco, pkg) {
|
||||
if (!pkg.config.render.body_visuals?.length) return;
|
||||
this.bodyVisuals = await BodyVisuals.load(
|
||||
mujoco,
|
||||
this.model,
|
||||
this.data,
|
||||
pkg,
|
||||
);
|
||||
const replaced = new Set(this.bodyVisuals.items.map(({ id }) => id));
|
||||
for (const { id, mesh } of this.items)
|
||||
if (replaced.has(this.model.geom_bodyid[id])) mesh.visible = false;
|
||||
this.root.add(this.bodyVisuals.root);
|
||||
}
|
||||
sync() {
|
||||
this.bodyVisuals?.sync();
|
||||
const p = this.data.geom_xpos,
|
||||
r = this.data.geom_xmat,
|
||||
m = this.matrix;
|
||||
@@ -120,6 +135,7 @@ export class RigRenderer {
|
||||
}
|
||||
}
|
||||
dispose() {
|
||||
this.bodyVisuals?.dispose();
|
||||
for (const g of this.geometries.values()) g.dispose();
|
||||
for (const m of this.materials) m.dispose();
|
||||
this.geometries.clear();
|
||||
|
||||
@@ -9,9 +9,9 @@ import {
|
||||
JointPdActuation,
|
||||
NativeActuation,
|
||||
} from "../sim/actuation/JointPdActuation.js";
|
||||
import { ObservationPipeline } from "../policy/ObservationPipeline.js";
|
||||
import { ActionPipeline } from "../policy/ActionPipeline.js";
|
||||
import { OnnxController } from "../policy/controllers/OnnxController.js";
|
||||
import { OnnxPolicy } from "../policy/controllers/OnnxPolicy.js";
|
||||
import { JointMotionReference } from "../policy/JointMotionReference.js";
|
||||
import { PolicyStateMachine } from "../skills/PolicyStateMachine.js";
|
||||
import { SkillManager } from "../skills/SkillManager.js";
|
||||
import { InputRouter } from "../input/InputRouter.js";
|
||||
import { RigRenderer } from "../render/RigRenderer.js";
|
||||
@@ -22,7 +22,8 @@ export class RobotRuntime {
|
||||
const { pkg, world } = options,
|
||||
config = pkg.config,
|
||||
{ mujoco, ort } = await loadRuntimes();
|
||||
let sim, session, rig, worldPresentation;
|
||||
let sim, rig, worldPresentation;
|
||||
const policies = new Map();
|
||||
try {
|
||||
sim = await SimCore.load(mujoco, pkg, world);
|
||||
const primary = config.skills.find((s) => s.kind === "primary");
|
||||
@@ -47,10 +48,7 @@ export class RobotRuntime {
|
||||
if ([...defaults.values()].some((v) => !Number.isFinite(v)))
|
||||
throw new Error("joints.defaults: missing/invalid reference pose");
|
||||
sim.reset(defaults);
|
||||
session = await ort.InferenceSession.create(bytes, {
|
||||
executionProviders: ["wasm"],
|
||||
});
|
||||
const ctx = {
|
||||
const shared = {
|
||||
sim,
|
||||
config,
|
||||
defaults,
|
||||
@@ -61,14 +59,37 @@ export class RobotRuntime {
|
||||
names.map((n) => [n, sim.data.qpos[sim.joints.get(n).qpos]]),
|
||||
),
|
||||
};
|
||||
const obs = new ObservationPipeline(config.observations, ctx),
|
||||
actions = new ActionPipeline(config.actions, ctx);
|
||||
const controller = new OnnxController(ort, session, obs, actions.size);
|
||||
obs.write();
|
||||
const smoke = await controller.run();
|
||||
if (smoke.length !== actions.size || !smoke.every(Number.isFinite))
|
||||
throw new Error("ONNX: standing-pose smoke test failed");
|
||||
for (const skill of config.skills.filter(
|
||||
(s) =>
|
||||
["primary", "episodic"].includes(s.kind) && s.available !== false,
|
||||
)) {
|
||||
const policyBytes =
|
||||
skill === primary
|
||||
? bytes
|
||||
: await fetchChecked(pkg.asset(skill.controller.policy), "bytes");
|
||||
const reference = skill.reference
|
||||
? await JointMotionReference.load(
|
||||
pkg,
|
||||
skill.reference,
|
||||
shared.policyNames,
|
||||
config.sim.timestep * config.sim.decimation,
|
||||
)
|
||||
: null;
|
||||
policies.set(
|
||||
skill.id,
|
||||
await OnnxPolicy.load(
|
||||
ort,
|
||||
policyBytes,
|
||||
config,
|
||||
shared,
|
||||
skill,
|
||||
reference,
|
||||
),
|
||||
);
|
||||
}
|
||||
const { ctx, obs, actions, controller } = policies.get(primary.id);
|
||||
rig = new RigRenderer(sim.model, sim.data, { ...config.render, world });
|
||||
await rig.loadBodyVisuals(mujoco, pkg);
|
||||
worldPresentation = await options.createWorldPresentation?.({
|
||||
sim,
|
||||
rig,
|
||||
@@ -82,13 +103,14 @@ export class RobotRuntime {
|
||||
obs,
|
||||
actions,
|
||||
controller,
|
||||
policies,
|
||||
rig,
|
||||
worldPresentation,
|
||||
});
|
||||
} catch (error) {
|
||||
worldPresentation?.dispose();
|
||||
rig?.dispose();
|
||||
await session?.release();
|
||||
await Promise.allSettled([...policies.values()].map((p) => p.dispose()));
|
||||
sim?.dispose();
|
||||
throw error;
|
||||
}
|
||||
@@ -106,6 +128,8 @@ export class RobotRuntime {
|
||||
this.active = false;
|
||||
this.positions = new Map();
|
||||
this.skills = new SkillManager(this.config);
|
||||
this.policyState = new PolicyStateMachine(this.config);
|
||||
this.activePolicy = this.policyState.primary;
|
||||
this.actuation =
|
||||
this.config.actuation.type === "joint_pd"
|
||||
? new JointPdActuation(
|
||||
@@ -130,6 +154,8 @@ export class RobotRuntime {
|
||||
);
|
||||
else if (action === "chaseToggle") this.restoreCamera();
|
||||
else if (action.startsWith("toggle:")) this.toggle(action.slice(7));
|
||||
else if (action.startsWith("skill:"))
|
||||
this.policyState.request(action.slice(6), this.sim.data.time);
|
||||
};
|
||||
this.tickCount = 0;
|
||||
this.hzAt = performance.now();
|
||||
@@ -187,12 +213,25 @@ export class RobotRuntime {
|
||||
}
|
||||
status() {
|
||||
return {
|
||||
policyStatus: this.policyStatus(),
|
||||
actuationLabel:
|
||||
this.config.actuation.type === "joint_pd"
|
||||
? "Simplified actuation · joint PD"
|
||||
: "",
|
||||
};
|
||||
}
|
||||
policyStatus() {
|
||||
return this.policyState.episodes.size
|
||||
? `Skill: ${this.policyState.active} · ${this.policyState.state}`
|
||||
: "";
|
||||
}
|
||||
publishPolicyStatus() {
|
||||
const policyStatus = this.policyStatus();
|
||||
if (policyStatus !== this.lastPolicyStatus) {
|
||||
this.lastPolicyStatus = policyStatus;
|
||||
this.onStatus({ policyStatus });
|
||||
}
|
||||
}
|
||||
async deactivate() {
|
||||
this.active = false;
|
||||
await this.pause();
|
||||
@@ -223,7 +262,9 @@ export class RobotRuntime {
|
||||
await this.scheduler.pause();
|
||||
this.input.clear();
|
||||
this.ctx.command.fill(0);
|
||||
this.ctx.lastAction.fill(0);
|
||||
for (const policy of this.policies.values()) policy.reset();
|
||||
this.policyState.reset();
|
||||
this.activePolicy = this.policyState.primary;
|
||||
this.skills.reset();
|
||||
this.sim.reset(this.ctx.defaults);
|
||||
this.odo = 0;
|
||||
@@ -235,6 +276,7 @@ export class RobotRuntime {
|
||||
this.ctx.targets.set(name, this.sim.data.qpos[joint.qpos]);
|
||||
this.fallen = false;
|
||||
this.onStatus({ fallen: false });
|
||||
this.publishPolicyStatus();
|
||||
this.rig.sync();
|
||||
if (running) this.scheduler.start();
|
||||
}
|
||||
@@ -248,10 +290,26 @@ export class RobotRuntime {
|
||||
}
|
||||
async controlStep() {
|
||||
if (!this.fallen) {
|
||||
const v = this.sim.data.qvel,
|
||||
a = this.sim.rootDof;
|
||||
const id = this.policyState.step(
|
||||
this.sim.data.time,
|
||||
this.input.command,
|
||||
Math.hypot(v[a], v[a + 1]),
|
||||
Math.abs(v[a + 5]),
|
||||
this.ctx.targets,
|
||||
);
|
||||
this.publishPolicyStatus();
|
||||
const policy = this.policies.get(id);
|
||||
if (id !== this.activePolicy) {
|
||||
policy.reset();
|
||||
this.activePolicy = id;
|
||||
}
|
||||
this.ctx.command.set(this.input.command);
|
||||
this.obs.write();
|
||||
this.actions.apply(await this.controller.run());
|
||||
if (this.policyState.state !== "walk") this.ctx.command.fill(0);
|
||||
await policy.run();
|
||||
this.skills.update(this.sim.data.time, this.ctx.targets);
|
||||
this.policyState.blend(this.sim.data.time, this.ctx.targets);
|
||||
}
|
||||
for (let i = 0; i < this.config.sim.decimation; i++) {
|
||||
this.actuation.apply();
|
||||
@@ -338,11 +396,24 @@ export class RobotRuntime {
|
||||
scene: this.scene,
|
||||
world: this.world,
|
||||
command: this.input.command,
|
||||
lastAction: this.ctx.lastAction,
|
||||
get lastAction() {
|
||||
return self.policies.get(self.activePolicy).ctx.lastAction;
|
||||
},
|
||||
get referenceFrame() {
|
||||
return (
|
||||
self.policies.get(self.activePolicy).ctx.reference?.frame ?? null
|
||||
);
|
||||
},
|
||||
skills: this.skills,
|
||||
policyState: this.policyState,
|
||||
get activePolicy() {
|
||||
return self.activePolicy;
|
||||
},
|
||||
buildObs: () => {
|
||||
this.ctx.command.set(this.input.command);
|
||||
return Object.values(this.obs.write())[0];
|
||||
return Object.values(
|
||||
this.policies.get(this.activePolicy).obs.write({ advance: false }),
|
||||
)[0];
|
||||
},
|
||||
pause: () => this.pause(),
|
||||
resume: () => this.resume(),
|
||||
@@ -377,7 +448,9 @@ export class RobotRuntime {
|
||||
this.controls?.dispose();
|
||||
this.worldPresentation?.dispose();
|
||||
this.rig.dispose();
|
||||
await this.controller.dispose();
|
||||
await Promise.allSettled(
|
||||
[...this.policies.values()].map((p) => p.dispose()),
|
||||
);
|
||||
this.sim.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ export class RuntimeManager {
|
||||
const entry = this.entries.find((e) => e.id === id);
|
||||
if (!entry) throw new Error(`Unknown Package ${id}`);
|
||||
const pkg = await loadPackage(entry.url),
|
||||
world = await loadWorld(resolveWorldId(pkg.config));
|
||||
world = await loadWorld(resolveWorldId(pkg.config), pkg.config);
|
||||
const factory = this.factories[pkg.config.adapter];
|
||||
if (!factory)
|
||||
throw new Error(`Unregistered adapter ${pkg.config.adapter}`);
|
||||
@@ -111,6 +111,7 @@ export class RuntimeManager {
|
||||
inputBindings: pkg.config.input.bindings,
|
||||
runtimeCapabilities: {},
|
||||
actuationLabel: "",
|
||||
policyStatus: "",
|
||||
fallen: false,
|
||||
...candidate.status?.(),
|
||||
});
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
export class JointPdActuation {
|
||||
constructor(sim, targets, { kp, kd, torque_limit }) {
|
||||
constructor(sim, targets, { kp, kd, torque_limit, joints = {} }) {
|
||||
Object.assign(this, { sim, targets, kp, kd, limit: torque_limit });
|
||||
this.parameters = new Map(
|
||||
[...sim.joints.keys()].map((name) => [
|
||||
name,
|
||||
{
|
||||
kp,
|
||||
kd,
|
||||
torque_limit,
|
||||
...joints[name],
|
||||
},
|
||||
]),
|
||||
);
|
||||
this.pending = new Float64Array(sim.joints.size);
|
||||
this.clipped = new Uint8Array(sim.joints.size);
|
||||
this.streaks = new Uint32Array(sim.joints.size);
|
||||
@@ -22,11 +33,25 @@ export class JointPdActuation {
|
||||
const target = this.targets.get(name);
|
||||
if (!Number.isFinite(target))
|
||||
throw new Error(`actuation.${name}: non-finite target`);
|
||||
const torque = this.kp * (target - q[j.qpos]) - this.kd * v[j.dof];
|
||||
const p = this.parameters.get(name);
|
||||
const torque = p.kp * (target - q[j.qpos]) - p.kd * v[j.dof];
|
||||
if (!Number.isFinite(torque))
|
||||
throw new Error(`actuation.${name}: non-finite torque`);
|
||||
this.clipped[i] = Math.abs(torque) > this.limit ? 1 : 0;
|
||||
this.pending[i++] = Math.max(-this.limit, Math.min(this.limit, torque));
|
||||
let lower = -p.torque_limit,
|
||||
upper = p.torque_limit;
|
||||
if (p.velocity_limit) {
|
||||
const saturation =
|
||||
p.torque_limit / (1 - p.keep_velocity / p.velocity_limit);
|
||||
const corner = p.velocity_limit * (1 + p.torque_limit / saturation);
|
||||
const velocity = Math.max(-corner, Math.min(corner, v[j.dof]));
|
||||
lower = Math.max(
|
||||
saturation * (-1 - velocity / p.velocity_limit),
|
||||
lower,
|
||||
);
|
||||
upper = Math.min(saturation * (1 - velocity / p.velocity_limit), upper);
|
||||
}
|
||||
this.clipped[i] = torque < lower || torque > upper ? 1 : 0;
|
||||
this.pending[i++] = Math.max(lower, Math.min(upper, torque));
|
||||
}
|
||||
i = 0;
|
||||
for (const j of this.sim.joints.values()) {
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
// Full-body policies are exclusive, never overlays. All timing is simulation time.
|
||||
export class PolicyStateMachine {
|
||||
constructor(config) {
|
||||
const primary = config.skills.find((s) => s.kind === "primary");
|
||||
this.primary = primary.id;
|
||||
this.owned = new Set(config.joints.groups[primary.owns]);
|
||||
this.episodes = new Map(
|
||||
config.skills.filter((s) => s.kind === "episodic").map((s) => [s.id, s]),
|
||||
);
|
||||
this.reset();
|
||||
}
|
||||
reset() {
|
||||
this.state = "walk";
|
||||
this.active = this.primary;
|
||||
this.pending = null;
|
||||
this.stillSince = null;
|
||||
this.from = new Map();
|
||||
this.episode = null;
|
||||
this.episodeStart = 0;
|
||||
this.start = 0;
|
||||
}
|
||||
request(id, time) {
|
||||
if (
|
||||
!this.episodes.has(id) ||
|
||||
this.episodes.get(id).available === false ||
|
||||
this.state !== "walk"
|
||||
)
|
||||
return false;
|
||||
this.pending = id;
|
||||
this.state = "settling";
|
||||
this.start = time;
|
||||
this.stillSince = null;
|
||||
return true;
|
||||
}
|
||||
transition(state, active, time, targets) {
|
||||
this.state = state;
|
||||
this.active = active;
|
||||
this.start = time;
|
||||
this.from = new Map([...targets].filter(([name]) => this.owned.has(name)));
|
||||
}
|
||||
step(time, command, speed, angularSpeed, targets) {
|
||||
const moving = command.some((v) => Math.abs(v) > 0.01);
|
||||
if (this.state === "settling") {
|
||||
if (moving || time - this.start > 5) this.reset();
|
||||
else if (speed < 0.15 && angularSpeed < 0.2) {
|
||||
this.stillSince ??= time;
|
||||
if (time - this.stillSince >= 0.4) {
|
||||
this.episode = this.episodes.get(this.pending);
|
||||
this.episodeStart = time;
|
||||
this.transition("entering", this.pending, time, targets);
|
||||
}
|
||||
} else this.stillSince = null;
|
||||
} else if (["entering", "playing"].includes(this.state)) {
|
||||
if (moving || time - this.episodeStart >= this.episode.duration - 1e-9)
|
||||
this.transition("returning", this.primary, time, targets);
|
||||
else if (
|
||||
this.state === "entering" &&
|
||||
time - this.start >= this.episode.blend
|
||||
)
|
||||
this.state = "playing";
|
||||
} else if (
|
||||
this.state === "returning" &&
|
||||
time - this.start >= this.episode.blend
|
||||
)
|
||||
this.reset();
|
||||
return this.active;
|
||||
}
|
||||
blend(time, targets) {
|
||||
if (!["entering", "returning"].includes(this.state)) return;
|
||||
const alpha = Math.min(
|
||||
1,
|
||||
Math.max(0, (time - this.start) / this.episode.blend),
|
||||
);
|
||||
for (const [name, value] of this.from)
|
||||
if (targets.has(name))
|
||||
targets.set(name, value + (targets.get(name) - value) * alpha);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,27 @@
|
||||
export const DEFAULT_WORLD = "arena";
|
||||
export const resolveWorldId = (config) =>
|
||||
config.presentation?.world ?? DEFAULT_WORLD;
|
||||
// Authored World dimensions are Microduck-sized. Resolve once before physics
|
||||
// compilation so collision boxes and presentation share the same world units.
|
||||
export function fitWorldToRobot(world, config) {
|
||||
if (!world.scale_to_robot) return world;
|
||||
const reference = world.scale_to_robot.reference_height;
|
||||
const height = config?.dimensions?.height ?? reference;
|
||||
const scale = height / reference;
|
||||
if (!Number.isFinite(scale) || scale <= 0)
|
||||
throw new Error("World scale: invalid robot/reference height");
|
||||
const result = structuredClone(world);
|
||||
const factor = scale / (world.scale ?? 1);
|
||||
for (const key of ["half_extent", "wall_height", "wall_thickness"]) {
|
||||
result.boundary[key] *= factor;
|
||||
if (!Number.isFinite(result.boundary[key]) || result.boundary[key] <= 0)
|
||||
throw new Error(`World scale: invalid boundary.${key}`);
|
||||
}
|
||||
if (result.floor.grid) result.floor.grid.size *= factor;
|
||||
// Runtime-only metadata; robot.json/world.json cannot override this value.
|
||||
result.scale = scale;
|
||||
return result;
|
||||
}
|
||||
export function arenaWalls({ half_extent, wall_height, wall_thickness }) {
|
||||
const ht = wall_thickness / 2,
|
||||
hh = wall_height / 2,
|
||||
|
||||
@@ -139,7 +139,7 @@ export async function bootGame({
|
||||
pkg ??= await loadPackage(
|
||||
`${import.meta.env.BASE_URL}robots/microduck-legs/robot.json`,
|
||||
);
|
||||
world ??= await loadWorld(resolveWorldId(pkg.config));
|
||||
world ??= await loadWorld(resolveWorldId(pkg.config), pkg.config);
|
||||
return await boot({
|
||||
scene,
|
||||
camera,
|
||||
|
||||
@@ -24,6 +24,7 @@ export const useGame = create(
|
||||
presentationTheme: "comic",
|
||||
runtimeCapabilities: {},
|
||||
actuationLabel: '',
|
||||
policyStatus: '',
|
||||
robotLicense: "",
|
||||
fallen: false,
|
||||
// Adapter-compatible boot diagnostics (no alternate boot screen).
|
||||
|
||||
@@ -91,9 +91,8 @@ export default function ControlsHelp() {
|
||||
type={clickable ? "button" : undefined}
|
||||
disabled={
|
||||
clickable
|
||||
? row.action === "chaseToggle"
|
||||
? blocked
|
||||
: disabled
|
||||
? row.disabled ||
|
||||
(row.action === "chaseToggle" ? blocked : disabled)
|
||||
: undefined
|
||||
}
|
||||
onClick={
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user