feat: release v0.2 multi-robot simulator
Add declarative robot packages, shared simulation lifecycle and Microban ONNX/PD walking with independent head control. Unify comic UI and chase camera; default robot packages to a 4.5m arena with real collision walls. Include regression tests, asset provenance/licenses and verification evidence.
This commit is contained in:
@@ -37,4 +37,5 @@ saved_model/**/* 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
|
||||
*.webm filter=lfs diff=lfs merge=lfs -text
|
||||
*.glb filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
@@ -9,144 +9,107 @@ pinned: false
|
||||
license: apache-2.0
|
||||
---
|
||||
|
||||
# Microduck RL playground
|
||||
# Browser robot simulation platform
|
||||
|
||||
Real trained RL policies for the Microduck robot, running fully in the
|
||||
browser: MuJoCo compiled to WebAssembly steps the physics, onnxruntime-web
|
||||
runs the policy network at 50 Hz. No server, no backend.
|
||||
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.
|
||||
|
||||
Two locomotion variants of the same robot are included: **legs** (walking,
|
||||
the default) and **rollers** (the wheeled skating variant). Press `M` (or
|
||||
hold D-pad up ~1 s on a gamepad) to switch; the roller model, meshes and
|
||||
policies are lazy-loaded on the first switch.
|
||||
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.
|
||||
|
||||
## Policies
|
||||
## Robots
|
||||
|
||||
| Mode | Checkpoint | What it does |
|
||||
|--------|-----------|--------------|
|
||||
| Run (legs) | `BEST_alpha_walking.onnx` | Velocity-tracking locomotion (arrows / WASD to steer) |
|
||||
| Sit | `BEST_alpha_sitstand.onnx` | Sits down on its hull, stands back up |
|
||||
| Roll | `roulade.onnx` | Rolls over and recovers |
|
||||
| Kick | `ball_kick_left.onnx` / `ball_kick_right.onnx` | Blind one-shot kick (0.5 s window, zeroed commands), left or right leg |
|
||||
| Drive (rollers) | `BEST_roller.onnx` | Velocity-tracking skating on 4 passive wheels (higher top speed: 0.6 m/s) |
|
||||
| Crouch (rollers) | `BEST_roller_crouch.onnx` | One-shot crouch-glide: sinks low over ~3.5 s and stands back up (phase-encoded command) |
|
||||
| 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 |
|
||||
|
||||
Policies and MJCF model from
|
||||
[pollen-robotics/microduck](https://github.com/pollen-robotics/microduck)
|
||||
and [pollen-robotics/microduck_rl](https://github.com/pollen-robotics/microduck_rl).
|
||||
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.
|
||||
|
||||
## Controls
|
||||
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.
|
||||
|
||||
- Arrows or WASD / ZQSD: forward / back + turn
|
||||
- M: switch legs <-> rollers
|
||||
- Q / E (A / E on AZERTY): kick left / right (legs only)
|
||||
- F: alternate left / right kicks (legs only)
|
||||
- R: sit / stand (legs) / crouch-glide (rollers)
|
||||
- G: ground pick (legs only)
|
||||
- C: toggle the chase camera (on by default; dragging detaches it)
|
||||
- Space: reset
|
||||
- Drag to orbit, scroll to zoom
|
||||
- Colour dots: repaint the duck (it quacks)
|
||||
## Keyboard and mouse
|
||||
|
||||
In roller mode the legs-only actions (kicks, sit) are disabled and their
|
||||
hints fade out; play the ball by driving into it.
|
||||
| Action | Binding |
|
||||
|---|---|
|
||||
| Forward / backward / turn | Arrow keys or physical WASD positions (layout labels adapt when supported) |
|
||||
| Pause / continue | Esc or toolbar |
|
||||
| Reset current robot | Space or toolbar |
|
||||
| Orbit / zoom | Mouse drag / wheel |
|
||||
| Microduck left / right kick | Q / E |
|
||||
| Microduck alternate kick | F |
|
||||
| Microduck sit / stand; roller crouch | R |
|
||||
| Microduck ground pick | G |
|
||||
| Microduck forward roll; roller crouch | T |
|
||||
| Microduck feet / rollers | M or quickbar |
|
||||
| Restore rear chase camera (both robots) | C |
|
||||
| Microban independent head rotation | H |
|
||||
|
||||
### URL parameters
|
||||
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.
|
||||
|
||||
- `?boot=1`: skip the welcome modal and land straight on the BIOS console,
|
||||
which then shows the real loading progress live (honest loader) before
|
||||
the normal entrance plays. Boot failures (missing asset, policy fetch
|
||||
error...) freeze the console on a `SYSTEM HALTED` screen with the error
|
||||
detail - handy for debugging.
|
||||
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.
|
||||
|
||||
The ball's physics are local to your tab, but its pose is broadcast with
|
||||
your duck's, so other visitors see a translucent copy of your ball next
|
||||
to your ghost (and you see theirs). A square arena (3 x 3 m) fences the
|
||||
play area so neither the ball nor the duck can wander off.
|
||||
## Microban fidelity and limits
|
||||
|
||||
### Gamepad
|
||||
- Actual ONNX interface: `obs [1, 63]` → `actions [1, 18]`.
|
||||
- The model has 19 actuated joints; the policy controls 18 body joints, **not head**. Metadata's 19 names are resolved by name, not mistaken for actor output order.
|
||||
- Projected gravity uses the trunk frame; the gyro retains the original IMU-site frame. Current policy has no extra reference-phase input.
|
||||
- Physics timestep: 0.005 s; control decimation: 4 (50 Hz).
|
||||
- **Simplified actuation**, not BAM: joint PD at every physics substep, kp=0.3, kd=0.02, torque limit=0.65 Nm.
|
||||
- Default commands: forward 0.15 m/s, backward −0.1 m/s, turn ±0.6 rad/s. These are commanded, not guaranteed measured tracking speeds. Drift remains possible.
|
||||
- Head follows the source's 0.35 Hz / ±π/4 sinusoid, with 0.5 s start / stop blending. It does not restart the walking controller.
|
||||
- Falling stops policy updates and requests manual reset. There is no automatic stand-up policy for Microban.
|
||||
|
||||
Plug in a controller and the same mapping as the real robot runtime applies:
|
||||
|
||||
- Left stick: forward / back + turn
|
||||
- Right stick: orbit the camera (detaches the chase cam)
|
||||
- R3 (right stick click): toggle the chase cam back on
|
||||
- X or D-pad down: sit / stand (legs) / crouch-glide (rollers)
|
||||
- A: ground pick (legs only)
|
||||
- Y: toggle head control
|
||||
- RB / LB: right / left kick (legs only)
|
||||
- D-pad up: hold ~1 s to switch legs <-> rollers (the real robot uses a 3 s hold)
|
||||
- Right trigger: mouth (analog) + quack
|
||||
- Left trigger: hold for wheee
|
||||
- A: enter / resume the game while the title or pause overlay is up
|
||||
- Menu/Start (or Select): exit back to the title overlay while in-game
|
||||
|
||||
## Multiplayer ghosts
|
||||
|
||||
Other people visiting the Space at the same time show up as translucent
|
||||
ducks, live. Peer-to-peer WebRTC via [Trystero](https://github.com/dmotz/trystero)
|
||||
(serverless signaling over public Nostr relays), so it works from a static
|
||||
Space with no backend. Each tab broadcasts its duck's pose (trunk + 14
|
||||
joints + jaw + colour + locomotion variant) at 10 Hz; up to 3 ghosts are
|
||||
rendered, extra peers stay connected but invisible. The camcorder-style OSD
|
||||
in the top-right corner shows "N ONLINE" when peers are around.
|
||||
|
||||
Ghost limitations in v1: a peer in roller mode renders with the roller rig
|
||||
only if your tab has already loaded it (otherwise it falls back to the leg
|
||||
rig), and ghost wheels don't spin (passive wheel joints aren't broadcast).
|
||||
Old clients simply ignore the new variant flag.
|
||||
|
||||
## How it works
|
||||
|
||||
The app is a Vite + React + MUI shell around an imperative game core:
|
||||
React/MUI renders the UI chrome (title menu, BIOS console, HUD, touch
|
||||
overlay), react-three-fiber owns the canvas/lights/environment, and the
|
||||
physics/policy/rig loop lives in framework-agnostic modules under
|
||||
`app/src/game/`. A zustand store bridges the two (game state out,
|
||||
UI intents in).
|
||||
|
||||
- `app/src/game/game.js` fetches the MJCF (`robot_allcollisions.xml`, or
|
||||
`robot_allcollisions_rollers.xml` for the roller variant), strips the
|
||||
visual geoms, injects a floor, arena walls, a ball, a collision box for
|
||||
the arcade cabinet row and a STAND keyframe, and compiles it with the
|
||||
official `@mujoco/mujoco` WASM bindings.
|
||||
- Both variants share the exact same policy interface: 61D observation
|
||||
(gyro, projected gravity, 14 joint pos/vel, last action, 13D command)
|
||||
and 14 position-targets, matching [`microduck_rl/scripts/infer_policy.py`](https://github.com/pollen-robotics/microduck_rl/blob/main/scripts/infer_policy.py).
|
||||
The roller variant adds 4 passive wheel hinges that appear in `qpos`
|
||||
(zeroed in the keyframe) but not in the observation.
|
||||
- Rendering is a three.js rig built from `kinematics.json` /
|
||||
`kinematics_rollers.json` + decimated STL meshes, driven directly from
|
||||
MuJoCo `qpos` (including the passive wheel spin).
|
||||
- Switching variants swaps the compiled model + data + rig + ONNX sessions
|
||||
wholesale; both stay resident after the first load so toggling back and
|
||||
forth is instant.
|
||||
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.
|
||||
|
||||
## Development
|
||||
|
||||
Large binary assets (robot meshes, GLB models, ONNX policies) are stored
|
||||
with [Git LFS](https://git-lfs.com/). Clone with LFS installed, or pull
|
||||
the real files after a plain clone - otherwise the app boots against
|
||||
text pointer files and fails with errors like
|
||||
`SyntaxError: Unexpected token 'v', "version ht"... is not valid JSON`
|
||||
(that string is the start of an LFS pointer, not your model):
|
||||
Binary robot meshes and ONNX files use Git LFS:
|
||||
|
||||
```bash
|
||||
git lfs install # once per machine
|
||||
git lfs pull # fetch the actual binaries in an existing clone
|
||||
git lfs install
|
||||
git lfs pull
|
||||
cd app
|
||||
npm ci
|
||||
npm run dev # http://localhost:5173
|
||||
npm run build # app/dist/
|
||||
npm run preview # production bundle
|
||||
```
|
||||
|
||||
Use a Node version supported by Vite (this revision was tested with Node 24). The Dockerfile builds with Node 22 and serves the static bundle through nginx on port 8080; a Docker build itself is not part of the local browser verification.
|
||||
|
||||
### Verification
|
||||
|
||||
```bash
|
||||
cd app
|
||||
npm install
|
||||
npm run dev # dev server on http://localhost:5173
|
||||
npm run build # production bundle in app/dist/
|
||||
npm test # pure logic tests
|
||||
npm run validate:packages # schemas, World, paths, source hashes
|
||||
npx playwright install chromium
|
||||
npm run test:e2e # real browser / WASM + UI + regression + ownership tests
|
||||
npm run test:regression # accepted Microduck golden trajectories only
|
||||
npm run format:check
|
||||
npm audit
|
||||
```
|
||||
|
||||
The Space builds with the included `Dockerfile` (Vite build, served by
|
||||
nginx-unprivileged on port 8080). Static assets (meshes, policies, audio,
|
||||
images) live in `app/public/` and keep their historical URLs.
|
||||
`npm run baseline:record` writes **candidates** under `app/test-results/baseline-candidates/`; it never overwrites accepted fixtures. Review changes before accepting any new baseline. See [baseline provenance](app/test/fixtures/microduck/README.md).
|
||||
|
||||
For a running production server, set `TEST_BASE_URL` and run the product-facing tests, e.g. `TEST_BASE_URL=http://127.0.0.1:5175 npm run test:e2e -- chase-camera deployment simulation-shell robot-switching microban-walking microban-observation microduck-regression runtime-smoke`. Development-only fixture pages are deliberately not shipped in `dist/`.
|
||||
|
||||
For prefixed hosting, build and preview with `VITE_BASE=/play/`; `DEPLOY_PATH=/play/` selects that entry path for `deployment.spec.js`. Private HF authentication behavior beyond the retained same-origin asset signing has not been independently deployment-tested.
|
||||
|
||||
`?test=1` is an internal deterministic-step hook, not a normal launch mode. `?boot=1` is no longer required. Legacy `?move`, `?policy` and `?session` requests remain limited to the Microduck adapter; they do not load arbitrary Robot Packages or replace Microban's controller.
|
||||
|
||||
## Architecture and extension
|
||||
|
||||
- `app/public/robots/*/robot.json`: model, joint groups, observations, actions, skills, bindings and presentation.
|
||||
- `app/public/worlds/`: arena / flat World manifests.
|
||||
- `app/src/platform/`: schemas / loading, SimCore, observation and action pipelines, term registries, ONNX, PD backend, overlay skills, input, MJCF renderer and transactional runtime manager.
|
||||
- `app/src/robots/registry.js`: trusted bundled adapters; no remote JS execution.
|
||||
- `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.
|
||||
|
||||
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).
|
||||
|
||||
## License
|
||||
|
||||
The app code is released under the [Apache License 2.0](LICENSE).
|
||||
The original application code is [Apache-2.0](LICENSE). Bundled third-party models, meshes, policies and samples retain their respective licenses; do **not** assume that every asset is Apache-2.0. Microban's copied XML retains its Apache-2.0 notice, and its upstream repository's mixed-license text, provenance and additional Apache notice are included in [`app/public/robots/microban/`](app/public/robots/microban/). Review those file-specific terms before redistribution. The bundled Anton font is SIL OFL-1.1; its notice is included at [`app/public/licenses/Anton-OFL.txt`](app/public/licenses/Anton-OFL.txt).
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
node_modules/
|
||||
dist/
|
||||
test-results/
|
||||
playwright-report/
|
||||
.playwright-cli/
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
import { bootDuck } from "./support/simulation.js";
|
||||
test("arena appearance matches Microduck while Microban physics stays flat and World visuals dispose on switch", async ({
|
||||
page,
|
||||
}, info) => {
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
page.on("console", (m) => {
|
||||
if (m.type() === "error") errors.push(m.text());
|
||||
});
|
||||
await bootDuck(page);
|
||||
expect(
|
||||
await page.evaluate(() => window.__gameApi.switchRobot("microban")),
|
||||
).toBe(true);
|
||||
await page.evaluate(() => window.__gameApi.resume());
|
||||
await expect
|
||||
.poll(() => page.evaluate(() => window.rl.data.time))
|
||||
.toBeGreaterThan(1);
|
||||
await page.evaluate(() => window.__gameApi.pause());
|
||||
await expect
|
||||
.poll(() =>
|
||||
page.evaluate(
|
||||
() => !!window.rl.scene.getObjectByName("arena-floor-presentation"),
|
||||
),
|
||||
)
|
||||
.toBe(true);
|
||||
const state = await page.evaluate(() => {
|
||||
const r = window.rl,
|
||||
grid = r.scene.getObjectByName("arena-grid"),
|
||||
u = grid.material.uniforms,
|
||||
id = r.model.geom("platform_floor").id;
|
||||
let floor;
|
||||
r.scene.traverse((o) => {
|
||||
if (o.userData.geomId === id) floor = o;
|
||||
});
|
||||
window.__retiredArena = r.scene.getObjectByName("arena-floor-presentation");
|
||||
window.__arenaReleased = [];
|
||||
grid.geometry.addEventListener("dispose", () =>
|
||||
window.__arenaReleased.push("geometry"),
|
||||
);
|
||||
grid.material.addEventListener("dispose", () =>
|
||||
window.__arenaReleased.push("material"),
|
||||
);
|
||||
return {
|
||||
cell: u.uCell.value,
|
||||
section: u.uSection.value,
|
||||
color: u.uSectionColor.value.getHex(),
|
||||
reveal: u.uReveal.value,
|
||||
topo: u.uTopoScale.value,
|
||||
hiddenFloor: !floor.visible,
|
||||
floorType: r.model.geom_type[id],
|
||||
friction: Array.from(r.model.geom_friction.slice(id * 3, id * 3 + 3)),
|
||||
gravity: Array.from(r.model.opt.gravity),
|
||||
heightfields: r.model.nhfield,
|
||||
finite: Array.from(r.data.qpos).every(Number.isFinite),
|
||||
fallen: r.fallen,
|
||||
};
|
||||
});
|
||||
expect(state).toEqual({
|
||||
cell: 0.1,
|
||||
section: 0.6,
|
||||
color: 0xffb366,
|
||||
reveal: 1,
|
||||
topo: 0,
|
||||
hiddenFloor: true,
|
||||
floorType: 0,
|
||||
friction: [1, 0.005, 0.0001],
|
||||
gravity: [0, 0, -9.81],
|
||||
heightfields: 0,
|
||||
finite: true,
|
||||
fallen: false,
|
||||
});
|
||||
await page.screenshot({ path: info.outputPath("microban-arena.png") });
|
||||
await page.evaluate(() => {
|
||||
const r = window.rl;
|
||||
r.data.qpos[0] = 4;
|
||||
r.data.qpos[1] = -3;
|
||||
r.mujoco.mj_forward(r.model, r.data);
|
||||
});
|
||||
await expect
|
||||
.poll(() =>
|
||||
page.evaluate(() => {
|
||||
const g = window.rl.scene.getObjectByName("arena-grid");
|
||||
return [
|
||||
g.position.x,
|
||||
g.position.z,
|
||||
g.material.uniforms.uFocus.value.x,
|
||||
g.material.uniforms.uFocus.value.z,
|
||||
];
|
||||
}),
|
||||
)
|
||||
.toEqual([4, 3, 4, 3]);
|
||||
expect(
|
||||
await page.evaluate(() => window.__gameApi.switchRobot("microduck-legs")),
|
||||
).toBe(true);
|
||||
expect(await page.evaluate(() => window.__arenaReleased.sort())).toEqual([
|
||||
"geometry",
|
||||
"material",
|
||||
]);
|
||||
expect(await page.evaluate(() => window.__retiredArena.parent === null)).toBe(
|
||||
true,
|
||||
);
|
||||
expect(await page.evaluate(() => window.rl.chaseCam)).toBe(true);
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
@@ -0,0 +1,149 @@
|
||||
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 ({
|
||||
page,
|
||||
}, info) => {
|
||||
await bootDuck(page);
|
||||
for (const id of ["microduck-legs", "microban"]) {
|
||||
if (id === "microban")
|
||||
expect(
|
||||
await page.evaluate(() => window.__gameApi.switchRobot("microban")),
|
||||
).toBe(true);
|
||||
const state = await page.evaluate(() => {
|
||||
const r = window.rl;
|
||||
return {
|
||||
id: r.world.id,
|
||||
boundary: r.world.boundary,
|
||||
following: r.chaseCam,
|
||||
walls: ["wall_px", "wall_nx", "wall_py", "wall_ny"].map((name) => {
|
||||
const g = r.model.geom(name).id;
|
||||
return {
|
||||
name,
|
||||
pos: Array.from(r.model.geom_pos.slice(g * 3, g * 3 + 3)),
|
||||
size: Array.from(r.model.geom_size.slice(g * 3, g * 3 + 3)),
|
||||
type: r.model.geom_type[g],
|
||||
body: r.model.geom_bodyid[g],
|
||||
};
|
||||
}),
|
||||
visuals: [0, 1, 2, 3].map((i) =>
|
||||
r.scene.getObjectByName(`arena-boundary-${i}`).position.toArray(),
|
||||
),
|
||||
};
|
||||
});
|
||||
expect(state.id).toBe("arena");
|
||||
expect(state.boundary).toEqual(boundary);
|
||||
expect(state.following).toBe(true);
|
||||
expect(state.walls).toEqual(
|
||||
arenaWalls(boundary).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],
|
||||
]);
|
||||
}
|
||||
// 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);
|
||||
r.controls.target.set(0, 0, 0);
|
||||
r.controls.update();
|
||||
});
|
||||
await page.screenshot({ path: info.outputPath("bounded-arena.png") });
|
||||
});
|
||||
test("a future Package with no world field automatically loads the bounded default", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.route("**/robots/index.json*", async (route) => {
|
||||
const response = await route.fetch(),
|
||||
entries = await response.json();
|
||||
entries.push({
|
||||
id: "future-bot",
|
||||
family: "future-bot",
|
||||
name: "Future Robot",
|
||||
manifest: "microban/robot.json?future=1",
|
||||
});
|
||||
await route.fulfill({ response, json: entries });
|
||||
});
|
||||
await page.route("**/robots/microban/robot.json?future=1", async (route) => {
|
||||
const response = await route.fetch(),
|
||||
config = await response.json();
|
||||
config.id = config.family = "future-bot";
|
||||
delete config.presentation.world;
|
||||
await route.fulfill({ response, json: config });
|
||||
});
|
||||
await bootDuck(page);
|
||||
expect(
|
||||
await page.evaluate(() => window.__gameApi.switchRobot("future-bot")),
|
||||
).toBe(true);
|
||||
expect(
|
||||
await page.evaluate(() => ({
|
||||
id: window.__store.getState().robotId,
|
||||
world: window.rl.world.id,
|
||||
bounds: window.rl.world.boundary,
|
||||
})),
|
||||
).toEqual({ id: "future-bot", world: "arena", bounds: boundary });
|
||||
});
|
||||
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();
|
||||
}
|
||||
list.delete();
|
||||
}
|
||||
report.push({
|
||||
name,
|
||||
contacts,
|
||||
max,
|
||||
time: r.data.time,
|
||||
fallen: r.fallen,
|
||||
finite: Array.from(r.data.qpos).every(Number.isFinite),
|
||||
});
|
||||
}
|
||||
return report;
|
||||
});
|
||||
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",
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,125 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
import { bootDuck } from "./support/simulation.js";
|
||||
async function pose(page) {
|
||||
return page.evaluate(() => {
|
||||
const r = window.rl,
|
||||
q = r.data.qpos,
|
||||
offset = r.camera.position.clone().sub(r.controls.target),
|
||||
h = Math.hypot(offset.x, offset.z),
|
||||
yaw = Math.atan2(
|
||||
2 * (q[3] * q[6] + q[4] * q[5]),
|
||||
1 - 2 * (q[5] ** 2 + q[6] ** 2),
|
||||
);
|
||||
return {
|
||||
rear: (-Math.cos(yaw) * offset.x + Math.sin(yaw) * offset.z) / h,
|
||||
pitch: Math.atan2(offset.y, h),
|
||||
distance: offset.length(),
|
||||
following: r.chaseCam,
|
||||
time: r.data.time,
|
||||
};
|
||||
});
|
||||
}
|
||||
async function rear(page) {
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const p = await pose(page);
|
||||
return (
|
||||
p.following &&
|
||||
p.rear > 0.999 &&
|
||||
Math.abs(p.pitch - 0.42) < 0.005 &&
|
||||
Math.abs(p.distance - 0.8) < 0.005
|
||||
);
|
||||
})
|
||||
.toBe(true);
|
||||
}
|
||||
async function orbit(page) {
|
||||
const canvas = page.locator("canvas"),
|
||||
rect = await canvas.boundingBox();
|
||||
await page.mouse.move(rect.x + rect.width * 0.7, rect.y + rect.height * 0.55);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(
|
||||
rect.x + rect.width * 0.85,
|
||||
rect.y + rect.height * 0.7,
|
||||
{ steps: 8 },
|
||||
);
|
||||
await page.mouse.up();
|
||||
expect((await pose(page)).following).toBe(false);
|
||||
}
|
||||
test("both robots default to the same rear camera and comic UI; Microban keeps flat World and valid controls", async ({
|
||||
page,
|
||||
}, info) => {
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await bootDuck(page);
|
||||
await rear(page);
|
||||
await page.evaluate(() => window.__gameApi.switchRobot("microban"));
|
||||
await rear(page);
|
||||
expect(
|
||||
await page.evaluate(() => window.__store.getState().presentationTheme),
|
||||
).toBe("comic");
|
||||
await expect(
|
||||
page.getByRole("navigation", { name: "Simulation controls" }),
|
||||
).toHaveCSS("border-top-width", "2px");
|
||||
await expect(page.getByRole("group", { name: "Duck colours" })).toHaveCount(
|
||||
0,
|
||||
);
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Rollers", exact: true }),
|
||||
).toHaveCount(0);
|
||||
await expect(page.getByText("Drag robot / ball: apply force")).toHaveCount(0);
|
||||
await expect(page.getByRole("status")).toContainText("Simplified actuation");
|
||||
expect(
|
||||
await page.evaluate(() => window.rl.model.geom("platform_floor").id),
|
||||
).toBeGreaterThanOrEqual(0);
|
||||
await page.screenshot({ path: info.outputPath("microban-chase.png") });
|
||||
await page.evaluate(() => window.__gameApi.switchRobot("microduck-legs"));
|
||||
await rear(page);
|
||||
await expect(page.getByRole("group", { name: "Duck colours" })).toBeVisible();
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
for (const id of ["microban", "microduck-legs"])
|
||||
test(`${id}: orbit detaches; C restores behind current heading, repeatedly and while paused`, async ({
|
||||
page,
|
||||
}) => {
|
||||
await bootDuck(page);
|
||||
if (id === "microban")
|
||||
await page.evaluate(() => window.__gameApi.switchRobot("microban"));
|
||||
await page.evaluate(() => window.__gameApi.pause());
|
||||
await orbit(page);
|
||||
await page.evaluate(() => {
|
||||
const r = window.rl;
|
||||
r.data.qpos[0] = 1.25;
|
||||
r.data.qpos[1] = -0.5;
|
||||
r.data.qpos[3] = Math.cos(Math.PI / 4);
|
||||
r.data.qpos[4] = r.data.qpos[5] = 0;
|
||||
r.data.qpos[6] = Math.sin(Math.PI / 4);
|
||||
r.mujoco.mj_forward(r.model, r.data);
|
||||
});
|
||||
const time = (await pose(page)).time;
|
||||
await page.keyboard.press("c");
|
||||
await rear(page);
|
||||
expect((await pose(page)).time).toBe(time);
|
||||
await page.keyboard.press("c");
|
||||
await rear(page);
|
||||
await orbit(page);
|
||||
await page
|
||||
.getByRole("button", { name: "Restore chase camera", exact: false })
|
||||
.click();
|
||||
await rear(page);
|
||||
expect(await page.evaluate(() => window.__store.getState().paused)).toBe(
|
||||
true,
|
||||
);
|
||||
if (id === "microban") {
|
||||
await page.evaluate(() => {
|
||||
const r = window.rl;
|
||||
r.data.qpos[3] = 0;
|
||||
r.data.qpos[6] = 1;
|
||||
r.mujoco.mj_forward(r.model, r.data);
|
||||
});
|
||||
// Microduck-style yaw hysteresis suppresses gait wobble; continuous
|
||||
// following may settle a few degrees off yaw. C above is exact.
|
||||
await expect
|
||||
.poll(async () => (await pose(page)).rear)
|
||||
.toBeGreaterThan(0.99);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,42 @@
|
||||
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 ({
|
||||
page,
|
||||
}, info) => {
|
||||
const failures = [],
|
||||
errors = [],
|
||||
requests = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
page.on("response", (r) => {
|
||||
if (
|
||||
r.status() >= 400 &&
|
||||
new URL(r.url()).origin === new URL(page.url()).origin
|
||||
)
|
||||
failures.push(`${r.status()} ${r.url()}`);
|
||||
});
|
||||
page.on("request", (r) => requests.push(r.url()));
|
||||
const prefix = process.env.DEPLOY_PATH || "/";
|
||||
await page.goto(prefix);
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Pause", exact: true }),
|
||||
).toBeEnabled();
|
||||
await page.waitForTimeout(500); // capture after the ball's existing appear FX
|
||||
await page.screenshot({ path: info.outputPath("microduck.png") });
|
||||
await page.getByLabel("Robot", { exact: true }).selectOption("microban");
|
||||
await expect
|
||||
.poll(() => page.evaluate(() => window.__store.getState().robotId))
|
||||
.toBe("microban");
|
||||
await expect(page.getByRole("status")).toContainText("Simplified actuation");
|
||||
await page.waitForTimeout(500);
|
||||
await page.screenshot({ path: info.outputPath("microban.png") });
|
||||
expect(errors).toEqual([]);
|
||||
expect(failures).toEqual([]);
|
||||
const origin = new URL(page.url()).origin;
|
||||
expect(requests.filter((url) => new URL(url).origin !== origin)).toEqual([]);
|
||||
expect(
|
||||
requests.filter(
|
||||
(url) =>
|
||||
url.startsWith(origin) && !new URL(url).pathname.startsWith(prefix),
|
||||
),
|
||||
).toEqual([]);
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Microban WASM physics probe</title>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="status">Loading actual MuJoCo and ONNX WASM…</pre>
|
||||
<script type="module" src="./microban-probe.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,65 @@
|
||||
// Render-free integration probe uses the SAME runtime as the product; no
|
||||
// second observation builder/PD implementation can drift from production.
|
||||
import * as THREE from "three";
|
||||
import { RobotRuntime } from "../../src/platform/runtime/RobotRuntime.js";
|
||||
import {
|
||||
loadPackage,
|
||||
loadWorld,
|
||||
} from "../../src/platform/loader/PackageLoader.js";
|
||||
window.probeReady = (async () => {
|
||||
const pkg = await loadPackage(
|
||||
`${import.meta.env.BASE_URL}robots/microban/robot.json`,
|
||||
),
|
||||
world = await loadWorld("flat");
|
||||
const runtime = await RobotRuntime.load({
|
||||
pkg,
|
||||
world,
|
||||
scene: new THREE.Group(),
|
||||
camera: new THREE.PerspectiveCamera(),
|
||||
renderer: null,
|
||||
});
|
||||
const { sim, ctx } = runtime;
|
||||
const state = () => {
|
||||
const a = sim.rootQpos,
|
||||
q = sim.data.qpos,
|
||||
b = sim.root * 4,
|
||||
quat = sim.data.xquat,
|
||||
w = quat[b],
|
||||
x = quat[b + 1],
|
||||
y = quat[b + 2],
|
||||
z = quat[b + 3];
|
||||
return {
|
||||
time: sim.data.time,
|
||||
pos: Array.from(q.slice(a, a + 3)),
|
||||
gravity: [
|
||||
2 * (w * y - x * z),
|
||||
-2 * (y * z + w * x),
|
||||
-(1 - 2 * (x * x + y * y)),
|
||||
],
|
||||
yaw: Math.atan2(2 * (w * z + x * y), 1 - 2 * (y * y + z * z)),
|
||||
};
|
||||
};
|
||||
window.probe = {
|
||||
model: sim.model,
|
||||
data: sim.data,
|
||||
command: runtime.input.command,
|
||||
state,
|
||||
buildObs: () => {
|
||||
ctx.command.set(runtime.input.command);
|
||||
return runtime.obs.write().obs;
|
||||
},
|
||||
reset: () => runtime.reset(),
|
||||
step: async (count) => {
|
||||
await runtime.scheduler.step(count);
|
||||
if (runtime.fallen) throw new Error(`Fallen at ${sim.data.time}`);
|
||||
return state();
|
||||
},
|
||||
dispose: () => runtime.dispose(),
|
||||
};
|
||||
document.querySelector("#status").textContent =
|
||||
"Ready: generic runtime / 19 joints / 18 actor / 63 obs";
|
||||
})().catch((error) => {
|
||||
window.probeError = error.stack;
|
||||
document.querySelector("#status").textContent = error.stack;
|
||||
throw error;
|
||||
});
|
||||
@@ -0,0 +1,75 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<body>
|
||||
<script type="module">
|
||||
import { loadRuntimes } from "../../src/platform/runtime/runtimes.js";
|
||||
import { RigRenderer } from "../../src/platform/render/RigRenderer.js";
|
||||
import { resolveAddresses } from "../../src/platform/sim/SimCore.js";
|
||||
import * as THREE from "three";
|
||||
try {
|
||||
const { mujoco } = await loadRuntimes();
|
||||
const xml = `<mujoco><asset><mesh name="tetra" scale="2 1 1" vertex="0 0 0 .04 0 0 0 .04 0 0 0 .04" face="0 2 1 0 1 3 0 3 2 1 2 3"/></asset><worldbody><geom type="plane" size="1 1 .01"/><body pos="0 0 .4"><freejoint/><geom group="2" type="box" size=".02 .03 .04" rgba=".1 .2 .3 1"/><geom group="2" type="sphere" pos=".1 0 0" size=".02"/><geom group="2" type="mesh" pos=".2 0 0" mesh="tetra"/><geom group="2" type="capsule" pos=".3 0 0" size=".01 .03"/><geom group="2" type="cylinder" pos=".4 0 0" size=".02 .04"/><body pos="0 .1 0"><joint name="a"/><geom group="2" type="sphere" size=".01"/><body pos="0 .1 0"><joint name="b"/><geom group="2" type="sphere" size=".01"/></body></body></body></worldbody><actuator><motor name="motor_b" joint="b"/><motor name="motor_a" joint="a"/></actuator></mujoco>`;
|
||||
const model = mujoco.MjModel.from_xml_string(xml),
|
||||
data = new mujoco.MjData(model);
|
||||
data.qpos.set([1, 2, 3, Math.cos(0.3), 0, 0, Math.sin(0.3)], 0);
|
||||
mujoco.mj_forward(model, data);
|
||||
const rig = new RigRenderer(model, data, { groups: [2] });
|
||||
rig.root.updateMatrixWorld(true);
|
||||
let maxError = 0;
|
||||
for (const { id, mesh } of rig.items) {
|
||||
const p = new THREE.Vector3();
|
||||
mesh.getWorldPosition(p);
|
||||
const expected = new THREE.Vector3(
|
||||
data.geom_xpos[id * 3],
|
||||
data.geom_xpos[id * 3 + 2],
|
||||
-data.geom_xpos[id * 3 + 1],
|
||||
);
|
||||
maxError = Math.max(maxError, p.distanceTo(expected));
|
||||
if (model.geom_type[id] === 7) {
|
||||
const attr = mesh.geometry.getAttribute("position"),
|
||||
v = new THREE.Vector3(attr.getX(0), attr.getY(0), attr.getZ(0)),
|
||||
r = data.geom_xmat,
|
||||
a = id * 9,
|
||||
b = id * 3;
|
||||
const raw = new THREE.Vector3(
|
||||
r[a] * v.x + r[a + 1] * v.y + r[a + 2] * v.z + data.geom_xpos[b],
|
||||
r[a + 3] * v.x +
|
||||
r[a + 4] * v.y +
|
||||
r[a + 5] * v.z +
|
||||
data.geom_xpos[b + 1],
|
||||
r[a + 6] * v.x +
|
||||
r[a + 7] * v.y +
|
||||
r[a + 8] * v.z +
|
||||
data.geom_xpos[b + 2],
|
||||
);
|
||||
const actual = mesh.localToWorld(v);
|
||||
maxError = Math.max(
|
||||
maxError,
|
||||
actual.distanceTo(new THREE.Vector3(raw.x, raw.z, -raw.y)),
|
||||
);
|
||||
}
|
||||
}
|
||||
const addresses = resolveAddresses(mujoco, model, ["a", "b"]);
|
||||
let missing = "";
|
||||
try {
|
||||
resolveAddresses(mujoco, model, ["absent"]);
|
||||
} catch (e) {
|
||||
missing = e.message;
|
||||
}
|
||||
window.renderResult = {
|
||||
maxError,
|
||||
count: rig.items.length,
|
||||
a: addresses.get("a").actuator,
|
||||
b: addresses.get("b").actuator,
|
||||
missing,
|
||||
color: rig.items[1].mesh.material.color.toArray(),
|
||||
};
|
||||
rig.dispose();
|
||||
data.delete();
|
||||
model.delete();
|
||||
} catch (e) {
|
||||
window.renderError = e.stack;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,30 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
test("mounted IMU gyro stays in site frame while projected gravity uses trunk frame", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/");
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Pause", exact: true }),
|
||||
).toBeEnabled();
|
||||
await page.getByLabel("Robot", { exact: true }).selectOption("microban");
|
||||
await expect
|
||||
.poll(() => page.evaluate(() => window.__store.getState().robotId))
|
||||
.toBe("microban");
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Pause", exact: true }),
|
||||
).toBeEnabled();
|
||||
const obs = await page.evaluate(async () => {
|
||||
const r = window.rl;
|
||||
await r.pause();
|
||||
r.data.qpos.set([Math.cos(Math.PI / 8), 0, Math.sin(Math.PI / 8), 0], 3);
|
||||
r.data.qvel.set([1, 2, 3], 3);
|
||||
r.mujoco.mj_forward(r.model, r.data);
|
||||
return Array.from(r.buildObs());
|
||||
});
|
||||
expect(obs.length).toBe(63);
|
||||
for (const [i, value] of [2, -3, -1].entries())
|
||||
expect(obs[i]).toBeCloseTo(value, 5);
|
||||
expect(obs[3]).toBeCloseTo(Math.SQRT1_2, 5);
|
||||
expect(obs[4]).toBeCloseTo(0, 5);
|
||||
expect(obs[5]).toBeCloseTo(-Math.SQRT1_2, 5);
|
||||
});
|
||||
@@ -0,0 +1,37 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
test("Microban actual WASM simplified PD stands, walks and turns without reset", async ({
|
||||
page,
|
||||
}, testInfo) => {
|
||||
await page.goto("/e2e/fixtures/microban-probe.html");
|
||||
await page.waitForFunction(() => window.probe || window.probeError);
|
||||
expect(await page.evaluate(() => window.probeError)).toBeUndefined();
|
||||
const result = await page.evaluate(async () => {
|
||||
const p = window.probe,
|
||||
segments = [];
|
||||
for (const [name, seconds, vx, wz] of [
|
||||
["stand", 10, 0, 0],
|
||||
["forward", 20, 0.15, 0],
|
||||
["rest", 3, 0, 0],
|
||||
["backward", 10, -0.1, 0],
|
||||
["rest", 3, 0, 0],
|
||||
["left", 10, 0, 0.6],
|
||||
["rest", 3, 0, 0],
|
||||
["right", 10, 0, -0.6],
|
||||
]) {
|
||||
const before = p.state();
|
||||
p.command.set([vx, 0, wz]);
|
||||
await p.step(seconds * 50);
|
||||
segments.push({ name, before, after: p.state() });
|
||||
}
|
||||
return segments;
|
||||
});
|
||||
await testInfo.attach("microban-probe.json", {
|
||||
body: JSON.stringify(result, null, 2),
|
||||
contentType: "application/json",
|
||||
});
|
||||
const forward = result.find((s) => s.name === "forward");
|
||||
expect(forward.after.pos[0] - forward.before.pos[0]).toBeGreaterThan(0.5);
|
||||
const backward = result.find((s) => s.name === "backward");
|
||||
expect(backward.after.pos[0] - backward.before.pos[0]).toBeLessThan(-0.2);
|
||||
console.log(JSON.stringify(result));
|
||||
});
|
||||
@@ -0,0 +1,181 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
const boot = async (page, world) => {
|
||||
if (world)
|
||||
await page.route("**/robots/microban/robot.json*", async (route) => {
|
||||
const response = await route.fetch(),
|
||||
config = await response.json();
|
||||
config.presentation.world = world;
|
||||
await route.fulfill({ response, json: config });
|
||||
});
|
||||
await page.goto("/");
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Pause", exact: true }),
|
||||
).toBeEnabled();
|
||||
await page.getByLabel("Robot", { exact: true }).selectOption("microban");
|
||||
await expect
|
||||
.poll(() => page.evaluate(() => window.__store.getState().robotId))
|
||||
.toBe("microban");
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Pause", exact: true }),
|
||||
).toBeEnabled();
|
||||
};
|
||||
for (const mode of [
|
||||
{ id: "bounded", forward: 8, back: 8, seconds: 70 },
|
||||
{
|
||||
id: "unbounded-diagnostic",
|
||||
forward: 20,
|
||||
back: 10,
|
||||
seconds: 84,
|
||||
world: "flat",
|
||||
},
|
||||
])
|
||||
test(`three ${mode.seconds}s physics trials (${mode.id}): stand, forward, back, turn, and parallel head`, async ({
|
||||
page,
|
||||
}, info) => {
|
||||
await boot(page, mode.world);
|
||||
await page.evaluate(() => window.rl.pause());
|
||||
const report = await page.evaluate(async (mode) => {
|
||||
const results = [],
|
||||
r = window.rl;
|
||||
const pose = () => {
|
||||
const [w, x, y, z] = r.data.qpos.slice(3, 7);
|
||||
return {
|
||||
time: r.data.time,
|
||||
pos: Array.from(r.data.qpos.slice(0, 3)),
|
||||
yaw: Math.atan2(2 * (w * z + x * y), 1 - 2 * (y * y + z * z)),
|
||||
head: r.data.qpos[r.model.jnt("head").qposadr],
|
||||
};
|
||||
};
|
||||
for (let trial = 0; trial < 3; trial++) {
|
||||
await r.resetSim();
|
||||
const segments = [];
|
||||
for (const [name, seconds, vx, wz] of [
|
||||
["stand", 10, 0, 0],
|
||||
["forward", mode.forward, 0.15, 0],
|
||||
["rest", 3, 0, 0],
|
||||
["backward", mode.back, -0.1, 0],
|
||||
["rest", 3, 0, 0],
|
||||
["left", 10, 0, 0.6],
|
||||
["rest", 3, 0, 0],
|
||||
["right", 10, 0, -0.6],
|
||||
["rest", 3, 0, 0],
|
||||
["head_walk", 10, 0.15, 0],
|
||||
["head_stop", 2, 0.15, 0],
|
||||
]) {
|
||||
const before = pose();
|
||||
r.command.set([vx, 0, wz]);
|
||||
if (name.startsWith("head_")) {
|
||||
const previous = Array.from(r.lastAction);
|
||||
r.toggle("head");
|
||||
if (previous.some((v, i) => v !== r.lastAction[i]))
|
||||
throw new Error("head toggle mutated policy history");
|
||||
}
|
||||
let yaw = 0,
|
||||
previous = before.yaw,
|
||||
minHead = Infinity,
|
||||
maxHead = -Infinity,
|
||||
minHeight = Infinity;
|
||||
for (let i = 0; i < seconds * 10; i++) {
|
||||
await r.step(5);
|
||||
const p = pose();
|
||||
let delta = p.yaw - previous;
|
||||
while (delta > Math.PI) delta -= 2 * Math.PI;
|
||||
while (delta < -Math.PI) delta += 2 * Math.PI;
|
||||
yaw += delta;
|
||||
previous = p.yaw;
|
||||
minHead = Math.min(minHead, p.head);
|
||||
maxHead = Math.max(maxHead, p.head);
|
||||
minHeight = Math.min(minHeight, p.pos[2]);
|
||||
if (r.fallen)
|
||||
throw new Error(`Fallen trial ${trial} ${name} at ${p.time}`);
|
||||
if (
|
||||
mode.id === "bounded" &&
|
||||
Math.max(Math.abs(p.pos[0]), Math.abs(p.pos[1])) >
|
||||
r.world.boundary.half_extent - 0.05
|
||||
)
|
||||
throw new Error(
|
||||
`Bounded gait trial reached a wall: ${name} ${p.pos}`,
|
||||
);
|
||||
}
|
||||
const after = pose(),
|
||||
dx = after.pos[0] - before.pos[0],
|
||||
dy = after.pos[1] - before.pos[1];
|
||||
segments.push({
|
||||
name,
|
||||
before,
|
||||
after,
|
||||
localDisplacement:
|
||||
dx * Math.cos(before.yaw) + dy * Math.sin(before.yaw),
|
||||
yaw,
|
||||
minHead,
|
||||
maxHead,
|
||||
minHeight,
|
||||
});
|
||||
}
|
||||
results.push({ trial, segments, actuation: r.actuationStats });
|
||||
}
|
||||
return results;
|
||||
}, mode);
|
||||
for (const trial of report) {
|
||||
const find = (name) => trial.segments.find((s) => s.name === name);
|
||||
expect(find("forward").localDisplacement).toBeGreaterThan(0.5);
|
||||
expect(find("backward").localDisplacement).toBeLessThan(-0.2);
|
||||
expect(find("left").yaw).toBeGreaterThan(1);
|
||||
expect(find("right").yaw).toBeLessThan(-1);
|
||||
expect(
|
||||
find("head_walk").maxHead - find("head_walk").minHead,
|
||||
).toBeGreaterThan(1);
|
||||
expect(Math.abs(find("head_stop").after.head)).toBeLessThan(0.05);
|
||||
expect(trial.actuation.longestSaturatedSeconds).toBeLessThan(0.5);
|
||||
}
|
||||
await info.attach(`microban-${mode.id}-three-trials.json`, {
|
||||
body: JSON.stringify(report, null, 2),
|
||||
contentType: "application/json",
|
||||
});
|
||||
console.log(
|
||||
`Microban: 3 × ${mode.seconds}s ${mode.id}, no falls/resets, correct motion and independent head.`,
|
||||
);
|
||||
});
|
||||
test("keyboard H toggles head, fallen Space resets, and real-time control runs near 50Hz", async ({
|
||||
page,
|
||||
}, info) => {
|
||||
await boot(page);
|
||||
await page
|
||||
.locator("canvas")
|
||||
.first()
|
||||
.click({ position: { x: 700, y: 600 } });
|
||||
await page.keyboard.press("h");
|
||||
expect(
|
||||
await page.evaluate(() => window.rl.skills.overlays.get("head").enabled),
|
||||
).toBe(true);
|
||||
const first = await page.evaluate(() => ({
|
||||
sim: window.rl.data.time,
|
||||
wall: performance.now(),
|
||||
}));
|
||||
await page.waitForTimeout(5000);
|
||||
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.85);
|
||||
expect(ratio).toBeLessThan(1.15);
|
||||
await info.attach("real-time.json", {
|
||||
body: JSON.stringify({ first, second, ratio }),
|
||||
contentType: "application/json",
|
||||
});
|
||||
await page.evaluate(() => {
|
||||
const r = window.rl;
|
||||
r.data.qpos[3] = Math.SQRT1_2;
|
||||
r.data.qpos[4] = Math.SQRT1_2;
|
||||
r.data.qpos[5] = 0;
|
||||
r.data.qpos[6] = 0;
|
||||
r.mujoco.mj_forward(r.model, r.data);
|
||||
});
|
||||
await expect.poll(() => page.evaluate(() => window.rl.fallen)).toBe(true);
|
||||
await expect(page.getByRole("status")).toContainText("Robot fallen");
|
||||
await page.keyboard.press("Space");
|
||||
await expect.poll(() => page.evaluate(() => window.rl.fallen)).toBe(false);
|
||||
});
|
||||
@@ -0,0 +1,67 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
import { bootDuck } from "./support/simulation.js";
|
||||
test("orbit camera stays synchronized with waypoint picking and physical drag", async ({
|
||||
page,
|
||||
}) => {
|
||||
await bootDuck(page);
|
||||
await page.evaluate(() => {
|
||||
const r = window.rl;
|
||||
r.chaseCam = false;
|
||||
r.camera.position.set(-0.5, 0.6, 1.2);
|
||||
r.controls.target.set(-0.6, 0.12, 0);
|
||||
r.controls.update();
|
||||
r.camera.updateMatrixWorld();
|
||||
});
|
||||
await page.evaluate(
|
||||
() =>
|
||||
new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r))),
|
||||
);
|
||||
const floor = await page.evaluate(() => {
|
||||
const r = window.rl,
|
||||
p = r.controls.target.clone().set(-0.95, 0, 0.25).project(r.camera),
|
||||
rect = document.querySelector("canvas").getBoundingClientRect();
|
||||
return {
|
||||
x: rect.left + ((p.x + 1) * rect.width) / 2,
|
||||
y: rect.top + ((1 - p.y) * rect.height) / 2,
|
||||
};
|
||||
});
|
||||
await page.mouse.click(floor.x, floor.y);
|
||||
const target = await page.evaluate(
|
||||
() => window.rl.controller.sources.find((s) => s.id === "waypoint").target,
|
||||
);
|
||||
expect(target[0]).toBeCloseTo(-0.95, 3);
|
||||
expect(target[1]).toBeCloseTo(-0.25, 3);
|
||||
await page.evaluate(() =>
|
||||
window.rl.controller.sources.find((s) => s.id === "waypoint").cancel(),
|
||||
);
|
||||
const robot = await page.evaluate(() => {
|
||||
const r = window.rl,
|
||||
q = r.data.qpos,
|
||||
p = r.controls.target
|
||||
.clone()
|
||||
.set(q[0], q[2] + 0.02, -q[1])
|
||||
.project(r.camera),
|
||||
rect = document.querySelector("canvas").getBoundingClientRect();
|
||||
return {
|
||||
x: rect.left + ((p.x + 1) * rect.width) / 2,
|
||||
y: rect.top + ((1 - p.y) * rect.height) / 2,
|
||||
};
|
||||
});
|
||||
await page.mouse.move(robot.x, robot.y);
|
||||
await page.mouse.down();
|
||||
expect(await page.evaluate(() => window.rl.controls.enabled)).toBe(false);
|
||||
await page.mouse.move(robot.x, robot.y - 40, { steps: 3 });
|
||||
await page.evaluate(() => window.rl.step(2));
|
||||
expect(
|
||||
await page.evaluate(() =>
|
||||
Array.from(window.rl.data.xfrc_applied).some((v) => Math.abs(v) > 1e-6),
|
||||
),
|
||||
).toBe(true);
|
||||
await page.mouse.up();
|
||||
expect(await page.evaluate(() => window.rl.controls.enabled)).toBe(true);
|
||||
expect(
|
||||
await page.evaluate(() =>
|
||||
Array.from(window.rl.data.xfrc_applied).every((v) => v === 0),
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
@@ -0,0 +1,86 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
import fs from "node:fs/promises";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { bootDuck, snapshot } from "./support/simulation.js";
|
||||
|
||||
const fixtures = fileURLToPath(
|
||||
new URL("../test/fixtures/microduck/", import.meta.url),
|
||||
);
|
||||
for (const scenario of [
|
||||
"stand",
|
||||
"walk",
|
||||
"kick",
|
||||
"sitstand",
|
||||
"groundpick",
|
||||
"roll",
|
||||
"recovery",
|
||||
"rollers",
|
||||
"crouch",
|
||||
]) {
|
||||
test(`Microduck deterministic ${scenario}`, async ({ page }) => {
|
||||
// Keep the ORIGINAL 3m World for the accepted original-code oracle.
|
||||
// The current 4.5m production default is independently tested in bounded-world.
|
||||
await page.route("**/worlds/arena/world.json*", async (route) => {
|
||||
const response = await route.fetch(),
|
||||
world = await response.json();
|
||||
world.boundary.half_extent = 1.5;
|
||||
await route.fulfill({ response, json: world });
|
||||
});
|
||||
const errors = await bootDuck(page);
|
||||
await page.evaluate(async (scenario) => {
|
||||
const r = window.rl;
|
||||
if (scenario === "rollers" || scenario === "crouch") {
|
||||
await r.setLoco("rollers", { force: true });
|
||||
await r.prepareTest();
|
||||
}
|
||||
r.resetSim();
|
||||
await r.prepareTest();
|
||||
await r.step(50);
|
||||
if (scenario === "walk" || scenario === "rollers")
|
||||
r.velCmd[0] = scenario === "walk" ? 0.1 : 0.2;
|
||||
if (scenario === "kick") r.triggerKick("left");
|
||||
if (scenario === "sitstand") r.setMode("sit");
|
||||
if (scenario === "groundpick") r.triggerGroundPick();
|
||||
if (scenario === "roll") r.triggerRoll();
|
||||
if (scenario === "crouch") r.triggerCrouch();
|
||||
if (scenario === "recovery") {
|
||||
r.data.qpos[3] = Math.SQRT1_2;
|
||||
r.data.qpos[4] = Math.SQRT1_2;
|
||||
r.mujoco.mj_forward(r.model, r.data);
|
||||
}
|
||||
}, scenario);
|
||||
// Preserve the accepted input sequence: latch the sit flag before the
|
||||
// recorded physics interval. Timers now use a controllable sim clock.
|
||||
if (scenario === "sitstand")
|
||||
await page.evaluate(() => window.rl.advanceTimers(0.85));
|
||||
const trajectory = [];
|
||||
for (let i = 0; i < 6; i++) {
|
||||
await page.evaluate(() => window.rl.step(25));
|
||||
trajectory.push(await snapshot(page));
|
||||
}
|
||||
const path = `${fixtures}${scenario}.json`;
|
||||
if (process.env.RECORD_BASELINE === "1") {
|
||||
const candidates = fileURLToPath(
|
||||
new URL("../test-results/baseline-candidates/", import.meta.url),
|
||||
);
|
||||
await fs.mkdir(candidates, { recursive: true });
|
||||
// Never overwrite accepted goldens: candidates require explicit review.
|
||||
await fs.writeFile(
|
||||
`${candidates}${scenario}.json`,
|
||||
JSON.stringify(
|
||||
{
|
||||
scenario,
|
||||
backend: "mujoco-3.11.0/ort-wasm-single-thread",
|
||||
trajectory,
|
||||
},
|
||||
null,
|
||||
2,
|
||||
) + "\n",
|
||||
);
|
||||
} else {
|
||||
const expected = JSON.parse(await fs.readFile(path, "utf8"));
|
||||
expect(trajectory).toEqual(expected.trajectory);
|
||||
}
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
test("compiled mesh/primitive transforms and reversed actuator order are resolved correctly", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/e2e/fixtures/render-fixture.html");
|
||||
await page.waitForFunction(() => window.renderResult || window.renderError);
|
||||
expect(await page.evaluate(() => window.renderError)).toBeUndefined();
|
||||
const result = await page.evaluate(() => window.renderResult);
|
||||
expect(result.maxError).toBeLessThan(1e-12);
|
||||
expect(result.count).toBe(8);
|
||||
expect(result.a).toBe(1);
|
||||
expect(result.b).toBe(0);
|
||||
expect(result.missing).toContain("absent");
|
||||
expect(result.color[0]).toBeCloseTo(0.1, 6);
|
||||
expect(result.color[1]).toBeCloseTo(0.2, 6);
|
||||
expect(result.color[2]).toBeCloseTo(0.3, 6);
|
||||
});
|
||||
@@ -0,0 +1,64 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
async function ready(page) {
|
||||
await page.goto("/");
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Pause", exact: true }),
|
||||
).toBeEnabled();
|
||||
}
|
||||
test("Microduck → Microban → Microduck restores theme, colours and locomotion", async ({
|
||||
page,
|
||||
}) => {
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await ready(page);
|
||||
await page.getByRole("button", { name: "Lavender colours" }).click();
|
||||
await page.getByRole("button", { name: "Rollers", exact: true }).click();
|
||||
await page.waitForFunction(() => window.rl?.loco === "rollers");
|
||||
await page.getByLabel("Robot", { exact: true }).selectOption("microban");
|
||||
await page.waitForFunction(
|
||||
() =>
|
||||
window.__store.getState().robotId === "microban" ||
|
||||
window.__store.getState().runtimeError,
|
||||
);
|
||||
expect(
|
||||
await page.evaluate(() => window.__store.getState().runtimeError),
|
||||
).toBeNull();
|
||||
await expect(
|
||||
page.getByText("Toggle head rotation", { exact: false }),
|
||||
).toBeVisible();
|
||||
await expect(page.getByRole("group", { name: "Duck colours" })).toHaveCount(
|
||||
0,
|
||||
);
|
||||
expect(await page.evaluate(() => window.rl.buildObs().length)).toBe(63);
|
||||
await page.getByLabel("Robot", { exact: true }).selectOption("microduck");
|
||||
await page.waitForFunction(
|
||||
() =>
|
||||
window.__store.getState().presentationTheme === "comic" &&
|
||||
window.rl?.loco === "rollers",
|
||||
);
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Lavender colours" }),
|
||||
).toHaveAttribute("aria-pressed", "true");
|
||||
expect(await page.evaluate(() => window.rl.data.time)).toBeLessThan(3);
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
test("failed switch rolls back and retry does not reload the page", async ({
|
||||
page,
|
||||
}) => {
|
||||
await ready(page);
|
||||
let fail = true;
|
||||
await page.route("**/robots/microban/policies/walk.onnx", (route) =>
|
||||
fail ? route.fulfill({ status: 404, body: "missing" }) : route.continue(),
|
||||
);
|
||||
await page.getByLabel("Robot", { exact: true }).selectOption("microban");
|
||||
await expect(page.getByRole("alert")).toContainText("404");
|
||||
expect(await page.evaluate(() => window.__store.getState().robotId)).toBe(
|
||||
"microduck-legs",
|
||||
);
|
||||
expect(await page.evaluate(() => window.rl.running)).toBe(true);
|
||||
fail = false;
|
||||
await page.getByRole("button", { name: "Retry", exact: true }).click();
|
||||
await expect
|
||||
.poll(() => page.evaluate(() => window.__store.getState().robotId))
|
||||
.toBe("microban");
|
||||
});
|
||||
@@ -0,0 +1,84 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
// All twenty transitions run in one page and one shared WASM instance.
|
||||
test("20 robot transitions release old WASM objects and plateau scene/GPU/listeners", async ({
|
||||
page,
|
||||
}, info) => {
|
||||
test.setTimeout(180_000);
|
||||
await page.addInitScript(() => {
|
||||
const add = EventTarget.prototype.addEventListener,
|
||||
remove = EventTarget.prototype.removeEventListener,
|
||||
targets = new Map();
|
||||
const key = (type, options) =>
|
||||
`${type}:${typeof options === "boolean" ? options : !!options?.capture}`;
|
||||
EventTarget.prototype.addEventListener = function (type, cb, options) {
|
||||
if (this === window || this instanceof HTMLCanvasElement) {
|
||||
let entries = targets.get(this);
|
||||
if (!entries) {
|
||||
entries = new Map();
|
||||
targets.set(this, entries);
|
||||
}
|
||||
const k = key(type, options);
|
||||
if (!entries.has(k)) entries.set(k, new Set());
|
||||
entries.get(k).add(cb);
|
||||
}
|
||||
return add.call(this, type, cb, options);
|
||||
};
|
||||
EventTarget.prototype.removeEventListener = function (type, cb, options) {
|
||||
targets.get(this)?.get(key(type, options))?.delete(cb);
|
||||
return remove.call(this, type, cb, options);
|
||||
};
|
||||
window.listenerCount = () =>
|
||||
[...targets.values()].reduce(
|
||||
(n, entries) =>
|
||||
n + [...entries.values()].reduce((a, set) => a + set.size, 0),
|
||||
0,
|
||||
);
|
||||
});
|
||||
await page.goto("/");
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Pause", exact: true }),
|
||||
).toBeEnabled();
|
||||
await page.evaluate(() => window.__gameApi.pause());
|
||||
const measurements = [];
|
||||
for (let i = 0; i < 20; i++) {
|
||||
const id = i % 2 === 0 ? "microban" : "microduck-legs";
|
||||
console.log(`Ownership transition ${i + 1}/20: ${id}`);
|
||||
const sample = await page.evaluate(async (id) => {
|
||||
const model = window.rl.model,
|
||||
data = window.rl.data;
|
||||
const success = await window.__gameApi.switchRobot(id);
|
||||
await new Promise((r) =>
|
||||
requestAnimationFrame(() => requestAnimationFrame(r)),
|
||||
);
|
||||
return {
|
||||
id,
|
||||
success,
|
||||
modelDeleted: model.isDeleted(),
|
||||
dataDeleted: data.isDeleted(),
|
||||
...window.__gameApi.diagnostics(),
|
||||
listeners: window.listenerCount(),
|
||||
};
|
||||
}, id);
|
||||
expect(sample.success).toBe(true);
|
||||
expect(sample.modelDeleted).toBe(true);
|
||||
expect(sample.dataDeleted).toBe(true);
|
||||
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]) {
|
||||
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(
|
||||
samples[1].memory.geometries + 1,
|
||||
);
|
||||
expect(samples.at(-1).memory.textures).toBeLessThanOrEqual(
|
||||
samples[1].memory.textures + 1,
|
||||
);
|
||||
}
|
||||
await info.attach("runtime-ownership.json", {
|
||||
body: JSON.stringify(measurements, null, 2),
|
||||
contentType: "application/json",
|
||||
});
|
||||
console.log(JSON.stringify(measurements));
|
||||
});
|
||||
@@ -0,0 +1,61 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
test("switch is single-flight, drains old ticks, clears held keys and preserves pause intent", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/");
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Pause", exact: true }),
|
||||
).toBeEnabled();
|
||||
await page.evaluate(() => window.__gameApi.pause());
|
||||
let release,
|
||||
seen = false;
|
||||
const gate = new Promise((r) => (release = r));
|
||||
await page.route("**/robots/microban/model.xml", async (route) => {
|
||||
seen = true;
|
||||
await gate;
|
||||
await route.continue();
|
||||
});
|
||||
await page.evaluate(() => {
|
||||
window.switchPending = window.__gameApi.switchRobot("microban");
|
||||
});
|
||||
await expect.poll(() => seen).toBe(true);
|
||||
const time = await page.evaluate(() => window.rl.data.time);
|
||||
await page.waitForTimeout(150);
|
||||
expect(await page.evaluate(() => window.rl.data.time)).toBe(time);
|
||||
expect(
|
||||
await page.evaluate(() => window.__gameApi.switchRobot("microduck-legs")),
|
||||
).toBe(false);
|
||||
await page.keyboard.down("w");
|
||||
release();
|
||||
expect(await page.evaluate(() => window.switchPending)).toBe(true);
|
||||
expect(await page.evaluate(() => window.__store.getState().paused)).toBe(
|
||||
true,
|
||||
);
|
||||
expect(await page.evaluate(() => window.rl.running)).toBe(false);
|
||||
expect(await page.evaluate(() => Array.from(window.rl.command))).toEqual([
|
||||
0, 0, 0,
|
||||
]);
|
||||
await page.keyboard.up("w");
|
||||
await page.evaluate(() => window.rl.step(10));
|
||||
await page.keyboard.press("Space");
|
||||
await expect.poll(() => page.evaluate(() => window.rl.data.time)).toBe(0);
|
||||
expect(await page.evaluate(() => window.rl.running)).toBe(false);
|
||||
});
|
||||
test("GLB load failure can retry without poisoned shared cache", async ({
|
||||
page,
|
||||
}) => {
|
||||
let failed = false;
|
||||
await page.route("**/microduck.glb?*", (route) => {
|
||||
if (!failed) {
|
||||
failed = true;
|
||||
return route.fulfill({ status: 503, body: "missing" });
|
||||
}
|
||||
return route.continue();
|
||||
});
|
||||
await page.goto("/");
|
||||
await expect(page.getByRole("alert")).toContainText("Simulation error");
|
||||
await page.getByRole("button", { name: "Retry", exact: true }).click();
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Pause", exact: true }),
|
||||
).toBeEnabled();
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
import { bootDuck } from "./support/simulation.js";
|
||||
test("real WASM boots and manual steps exclusively own physics time", async ({
|
||||
page,
|
||||
}) => {
|
||||
const errors = await bootDuck(page);
|
||||
const result = await page.evaluate(async () => {
|
||||
const r = window.rl;
|
||||
const t0 = r.data.time;
|
||||
await r.step(10);
|
||||
const t1 = r.data.time;
|
||||
await new Promise((resolve) => setTimeout(resolve, 150));
|
||||
return {
|
||||
dt: t1 - t0,
|
||||
idleDt: r.data.time - t1,
|
||||
finite: [...r.data.qpos].every(Number.isFinite),
|
||||
};
|
||||
});
|
||||
expect(result.dt).toBeCloseTo(0.2, 10);
|
||||
expect(result.idleDt).toBe(0);
|
||||
expect(result.finite).toBe(true);
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
@@ -0,0 +1,92 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
test("automatically runs with inline pause, reset and keyboard help; no menu assets", async ({
|
||||
page,
|
||||
}) => {
|
||||
const errors = [],
|
||||
requests = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
page.on("request", (r) => requests.push(r.url()));
|
||||
await page.goto("/");
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Pause", exact: true }),
|
||||
).toBeEnabled();
|
||||
expect(await page.evaluate(() => window.rl.data.time)).toBeGreaterThanOrEqual(
|
||||
0,
|
||||
);
|
||||
await expect(page.getByRole("dialog")).toHaveCount(0);
|
||||
await expect(page.getByText("Waddle in", { exact: true })).toHaveCount(0);
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Keyboard controls", exact: false }),
|
||||
).toHaveAttribute("aria-expanded", "true");
|
||||
await page.getByRole("button", { name: "Pause", exact: true }).click();
|
||||
await page.evaluate(() => window.rl.pause());
|
||||
const time = await page.evaluate(() => window.rl.data.time);
|
||||
await page.waitForTimeout(400);
|
||||
expect(await page.evaluate(() => window.rl.data.time)).toBe(time);
|
||||
await expect(page.getByRole("status")).toHaveText(/Paused/);
|
||||
await page.keyboard.press("Escape");
|
||||
await expect
|
||||
.poll(() => page.evaluate(() => window.rl.data.time))
|
||||
.toBeGreaterThan(time);
|
||||
await page.getByRole("button", { name: "Pause", exact: true }).click();
|
||||
await page.evaluate(() => window.rl.pause());
|
||||
await page.getByRole("button", { name: "Reset", exact: true }).click();
|
||||
await expect.poll(() => page.evaluate(() => window.rl.data.time)).toBe(0);
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Continue", exact: true }),
|
||||
).toBeEnabled();
|
||||
await page
|
||||
.getByRole("button", { name: "Keyboard controls", exact: false })
|
||||
.click();
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Keyboard controls", exact: false }),
|
||||
).toHaveAttribute("aria-expanded", "false");
|
||||
expect(
|
||||
requests.filter(
|
||||
(url) => url.includes("nostr") || url.includes("duck-head-mark"),
|
||||
),
|
||||
).toEqual([]);
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
test("paused sit timer freezes; keyboard focus does not send robot commands", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/");
|
||||
await page.waitForFunction(() => window.rl);
|
||||
await page.evaluate(() => window.rl.setMode("sit"));
|
||||
await page.getByRole("button", { name: "Pause", exact: true }).click();
|
||||
await page.evaluate(() => window.rl.pause());
|
||||
const before = await page.evaluate(() => window.rl.sitFlag);
|
||||
await page.waitForTimeout(1100);
|
||||
expect(await page.evaluate(() => window.rl.sitFlag)).toBe(before);
|
||||
await page.keyboard.press("ArrowUp");
|
||||
expect(await page.evaluate(() => Array.from(window.rl.velCmd))).toEqual([
|
||||
0, 0, 0,
|
||||
]);
|
||||
// Native Space activates the focused Continue button, not robot reset.
|
||||
await page.keyboard.press("Space");
|
||||
await expect.poll(() => page.evaluate(() => window.rl.running)).toBe(true);
|
||||
expect(await page.evaluate(() => window.rl.mode)).toBe("sitstand");
|
||||
await page.keyboard.down("w");
|
||||
expect(await page.evaluate(() => window.rl.velCmd[0])).toBeGreaterThan(0);
|
||||
await page.keyboard.up("w");
|
||||
});
|
||||
test("load failure is inline and retry boots a clean instance", async ({
|
||||
page,
|
||||
}) => {
|
||||
let failed = false;
|
||||
await page.route("**/policies/BEST_alpha_walking.onnx", (route) => {
|
||||
if (!failed) {
|
||||
failed = true;
|
||||
return route.fulfill({ status: 404, body: "not found" });
|
||||
}
|
||||
return route.continue();
|
||||
});
|
||||
await page.goto("/");
|
||||
await expect(page.getByRole("alert")).toContainText("Simulation error");
|
||||
await page.getByRole("button", { name: "Retry", exact: true }).click();
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Pause", exact: true }),
|
||||
).toBeEnabled();
|
||||
await expect(page.getByRole("alert")).toHaveCount(0);
|
||||
});
|
||||
@@ -0,0 +1,39 @@
|
||||
import { expect } from "@playwright/test";
|
||||
export async function bootDuck(page) {
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.addInitScript(() => {
|
||||
let seed = 123456789;
|
||||
Math.random = () =>
|
||||
(seed = (1664525 * seed + 1013904223) >>> 0) / 4294967296;
|
||||
});
|
||||
await page.goto("/?boot=1&test=1");
|
||||
await page.waitForFunction(
|
||||
() => window.rl?.prepareTest || window.__store?.getState().bootFailed,
|
||||
);
|
||||
const failed = await page.evaluate(
|
||||
() => window.__store.getState().bootFailed,
|
||||
);
|
||||
expect(
|
||||
failed,
|
||||
JSON.stringify(await page.evaluate(() => window.__store.getState())),
|
||||
).toBe(false);
|
||||
await page.evaluate(() => window.rl.prepareTest());
|
||||
expect(errors).toEqual([]);
|
||||
return errors;
|
||||
}
|
||||
export async function snapshot(page) {
|
||||
return page.evaluate(() => {
|
||||
const r = window.rl;
|
||||
return {
|
||||
time: r.data.time,
|
||||
mode: r.mode,
|
||||
recovery: r.recovery,
|
||||
qpos: Array.from(r.data.qpos),
|
||||
qvel: Array.from(r.data.qvel),
|
||||
ctrl: Array.from(r.data.ctrl),
|
||||
lastAction: Array.from(r.lastAction),
|
||||
obs: Array.from(r.buildObs()),
|
||||
};
|
||||
});
|
||||
}
|
||||
+1
-8
@@ -4,14 +4,7 @@
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Microduck</title>
|
||||
<!-- Anton: the landing's brutal print display voice (FancyTitle /
|
||||
ComicButton on the pollen-website Microduck pages). -->
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Anton&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<!-- Anton is bundled locally by main.jsx; no blocking external font CSS. -->
|
||||
<style>
|
||||
:root {
|
||||
--ink: #08080c;
|
||||
|
||||
Generated
+237
-92
@@ -1,18 +1,20 @@
|
||||
{
|
||||
"name": "microduck-sandbox",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "microduck-sandbox",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.0",
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.14.0",
|
||||
"@emotion/styled": "^11.14.1",
|
||||
"@fontsource/anton": "^5.3.0",
|
||||
"@mui/material": "^9.3.1",
|
||||
"@mujoco/mujoco": "^3.11.0",
|
||||
"@react-three/fiber": "^9.7.0",
|
||||
"ajv": "^8.20.0",
|
||||
"onnxruntime-web": "^1.27.0",
|
||||
"react": "^19.2.8",
|
||||
"react-dom": "^19.2.8",
|
||||
@@ -21,8 +23,10 @@
|
||||
"zustand": "^5.0.15"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.64.1",
|
||||
"@vitejs/plugin-react": "^6.1.0",
|
||||
"vite": "^8.2.2"
|
||||
"prettier": "^3.9.10",
|
||||
"vite": "^8.3.5"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/code-frame": {
|
||||
@@ -310,6 +314,15 @@
|
||||
"integrity": "sha512-snKqtPW01tN0ui7yu9rGv69aJXr/a/Ywvl11sUjNtEcRc+ng/mQriFL0wLXMef74iHa/EkftbDzU9F8iFbH+zg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@fontsource/anton": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@fontsource/anton/-/anton-5.3.0.tgz",
|
||||
"integrity": "sha512-OR1D5n124n2XRs66SbX7IjcOSptljEJE8FcDNnlni2y1/M6KpTx7cU2PIWzTSsBj4WFkHPw24On8qw3qkQZuTw==",
|
||||
"license": "OFL-1.1",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ayuhito"
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/gen-mapping": {
|
||||
"version": "0.3.13",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
|
||||
@@ -568,13 +581,29 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@oxc-project/types": {
|
||||
"version": "0.146.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.146.0.tgz",
|
||||
"integrity": "sha512-XC0QsnnhVe7sLIWmYmdPw7x5P0h4W8vUU3Nv1ySgWXtvCz8NizoAEpGXA0sOYoJQV2Rl13LgURAHQ5cI5ILCSA==",
|
||||
"version": "0.155.0",
|
||||
"resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.155.0.tgz",
|
||||
"integrity": "sha512-SeE8JPwW1xs1tHeNycjUtUBdhorRa8o4jlvjwk49R7/Z291i+4DQa7JJIgOm/TaYQZx+QrPQbVJ/9c8dMIZN8Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/Boshen"
|
||||
"url": "https://github.com/sponsors/oxc-project"
|
||||
}
|
||||
},
|
||||
"node_modules/@playwright/test": {
|
||||
"version": "1.64.1",
|
||||
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.64.1.tgz",
|
||||
"integrity": "sha512-IaYGml/nSOiZWROfPtuIL7neuu9qDOZ3TNvNljUIrhDMxiGTgPjzj/g9p9RxpS2tSepPDRY+UwAaEeiKtUvIAg==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"playwright": "1.64.1"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/@popperjs/core": {
|
||||
@@ -693,9 +722,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-android-arm-eabi": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.5.tgz",
|
||||
"integrity": "sha512-DLe/i+l8ynIBY7XEQ191TeZvCoowIGa18R+dIV30GW7DiOtp74i/xX8hs8GUjW5ARV7VZuie3d6AumSmCwbeRA==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.15.tgz",
|
||||
"integrity": "sha512-aLcgK9gIJ3YRvrrtfSBbRa27F5WrpiTaPulnFpsHPxpUHgFlSgnU4854MHwoRGEBhfRJDWCS2WQ7lIjskE9Olw==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
@@ -710,9 +739,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-android-arm64": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.5.tgz",
|
||||
"integrity": "sha512-zXcwKlQApYAOELHd8PwKDFkagYF9Wy4e0RJ+0qnzl9Pjnpj75TEG8ufv40p2J7kCEfwZAsNiuzRIyNNMWT38ig==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.15.tgz",
|
||||
"integrity": "sha512-xD7DdZCrbThKuxNg7ooQmvp07ys4J/pnSEMTG3/OdOWl6daC67m/Q4fL78sRHMxTH/N4fGUbYhcPM0MF5WFHkg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -727,9 +756,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-darwin-arm64": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.5.tgz",
|
||||
"integrity": "sha512-dK4QakI42nzWgJT5sm4y4y/O//D4OxM75/cH28RLV+nzIN9AY+YsbuUVrUTjlLjXR6vpyxFbSsbmNuJ6BP9sww==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.15.tgz",
|
||||
"integrity": "sha512-m2WuQ6r0B4OTYxyPpNLtXaMRbRDUbG8YQV2Q3KTdSSK8Th6KHCnC8jVCJt8bvYeSB5WivkkNbc85mKadaSdOxA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -744,9 +773,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-darwin-x64": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.5.tgz",
|
||||
"integrity": "sha512-fqSALaUu1Wjd1nK2uW2kJDWdLCc8lx1IcY+MTY26Aurfdx19anlzhqXOgCFbBFQnlFDTn4TC1/7Nz4Bl2mLP3A==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.15.tgz",
|
||||
"integrity": "sha512-5RtnsHM36nodM9WbMy+zip0LGS/G+y5wro5RHrpOlr4ac24+1zSi9kiV2MP1myZeZ/ifEHfulQcWjnAXzc2C2A==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@@ -761,9 +790,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-freebsd-x64": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.5.tgz",
|
||||
"integrity": "sha512-/vCnNxlkxs9tKxNDcyWUePpJ/PgTzxIaVhoM5SmG8UV+GR/IcPam4VYxi7GIMo7PSDuNqlJqvprqii9NqqVCMw==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.15.tgz",
|
||||
"integrity": "sha512-g3l09pyFqhu+135JKkbkwiKGQmwU5hUMUPJ4VdBADvuqR8d33L6H578rh8m7rtxbdp+VmX/+nzI7nvhSZlzpUQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@@ -778,9 +807,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-linux-arm-gnueabihf": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.5.tgz",
|
||||
"integrity": "sha512-abk0NLA519LxRCszmbE0jYKuQ9YPocOXTiOXOo6Yr+YAT95VH+PtqYAjOJvGKt3viEd/x4qzabAlwd5bHOOARg==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.15.tgz",
|
||||
"integrity": "sha512-nIe3VugI97nGQtspPxDqA4sXMUpeiocKIP/CqpY/u/vgbT+alX+cVxu1C/oVBPKg4feNTmYovE91v4DgXvXNwQ==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
@@ -795,13 +824,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-linux-arm64-gnu": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.5.tgz",
|
||||
"integrity": "sha512-Y7eALiJ8lr0M2HH103Js+g7V34wf6snlpZLAsHI90uLhr3PVlNsbFVAXJC9d/V6BnPyKtpSwI+NcB/RLxsQxuA==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.15.tgz",
|
||||
"integrity": "sha512-iTBjXx+B5QSvgI89lJfmqh4wTh8NabR1YZIIN3hNx4zSG0EVfVqkOvLulNpG4251pbd6/IAmZ/LefVk1Y4rPhw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"libc": [
|
||||
"glibc"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -812,13 +844,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-linux-arm64-musl": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.5.tgz",
|
||||
"integrity": "sha512-xMvZgnbZg4YVnR/AX2b3oOPDTFYJvUVaJg5FedA/LuvexAtXibZQej4cnTkw3rjsJ/ggUROB64TdtETiim+FYA==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.15.tgz",
|
||||
"integrity": "sha512-uN26XOnVR7rqQupG3V9oAG2EGGatWjcJHOeDOHUFCh4TBWmP2tHTFoVN13aYbwfm0aHqJAEmcwhAu6sooIjfqQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"libc": [
|
||||
"musl"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -829,13 +864,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-linux-ppc64-gnu": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.5.tgz",
|
||||
"integrity": "sha512-GRjeqTUDHTo5GwntsLaAMcBahG3nlpjftXWZLN73HiYQlhwEowvarFgQnRnQZtIp4keXX7quXFbG38uPZBa2EA==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.15.tgz",
|
||||
"integrity": "sha512-9nWkcdd+H+XhaA3fQIwpHnKIrfx/PQ6rO0pivr78Og07tXlUlctBBJoEYLPfhTmCR/QxEVdn6uPjHV5SymPhdw==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
"dev": true,
|
||||
"libc": [
|
||||
"glibc"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -846,13 +884,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-linux-s390x-gnu": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.5.tgz",
|
||||
"integrity": "sha512-vLNTR45F2Uwc8AufkNXPmB4VliaXs+FvcheEogIzOXzO4l+LzieXF5A/TWxLy5HtqpsRCHUfd0lPVrrdgXdLHQ==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.15.tgz",
|
||||
"integrity": "sha512-Ggh0ciFjLwIusLSLz7LZYEaGdxOAUJXI+Qu5JCbhPJJHEt8vP+IjRATTJheiJsdzzTYgUiHUiw3X1Ea3ZpMBdA==",
|
||||
"cpu": [
|
||||
"s390x"
|
||||
],
|
||||
"dev": true,
|
||||
"libc": [
|
||||
"glibc"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -863,13 +904,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-linux-x64-gnu": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.5.tgz",
|
||||
"integrity": "sha512-Mgj59/HTuYeK9Gz2MA+mBWKnHsAgkBSec15ZMb1st3oIfFbX7gCjOae7GydHhzcyQi9Z/7M1QuN9bR3oFqF0jQ==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.15.tgz",
|
||||
"integrity": "sha512-FHg60rS6DBePAYZ9X9F67x+JObFdmgn6tupA1C/a3B+CufFmTD4mX+e8M75tCiAO3foR/6xwVBI0KQiI7sn/rw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"libc": [
|
||||
"glibc"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -880,13 +924,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-linux-x64-musl": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.5.tgz",
|
||||
"integrity": "sha512-mY8AP0/ichsbhAxGnLa3d3+MwV0EfgrPND2bplI3Ym8T6R2pJ0N87bvrKVwNXmdy3jnr6eQBecdqx/HMknBmpA==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.15.tgz",
|
||||
"integrity": "sha512-/cvV/7v5VGz/moiz0XKRj2dE8DzsKyhIu1KpOvJGPjRywg3yscON889UGvAe8zfiJLHup7VLjBduoGWi3HusWQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"libc": [
|
||||
"musl"
|
||||
],
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
@@ -897,9 +944,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-openharmony-arm64": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.5.tgz",
|
||||
"integrity": "sha512-8SLssA2oweAxyRgDp789ACfRb/3P+zNRJpzZxSizxF9m8NUDQ4+3xjo8ttjhVGGw6Qxb70oZiEtIjaKikCO7Yw==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.15.tgz",
|
||||
"integrity": "sha512-MyzC5Hrv/sm+Z7TSGKP/j8001RO2xQm1zOpCNVL4j0cY/VhBZviludA2YFQ7i4lH6ZAXxQm0lcMdBzM+99mE7w==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -914,9 +961,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-win32-arm64-msvc": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.5.tgz",
|
||||
"integrity": "sha512-vGbruD5zquhoc8D9SViXgN2FBJtNdTyQ4DtG+SWiEGlJiAzoKcZ2xp+xuXCffhubVdt0NJlTZqkeRuERy7g8Cw==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.15.tgz",
|
||||
"integrity": "sha512-+PgYiS+AH5omy6L45ZLxybasauJaj3M8buoT83D+nzPmCayXlxUV9hydhciCKVyIg0B/v0BtXPDE1uGqNwCPpg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
@@ -931,9 +978,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@rolldown/binding-win32-x64-msvc": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.5.tgz",
|
||||
"integrity": "sha512-e/SXpgISz+IoqVcSSI0rx/d/he8zqLex+/rCWpnHpmVfmPIUjag9H6P7zotf0gJHwPUhQxZ/mF8tr6acebT9yw==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.15.tgz",
|
||||
"integrity": "sha512-HFZd2QNQYn1JbIi+Hpd7H+r/lkWxcfIu28nirZ6eCn2LafuvmExMlb/P96Sfx5tf7pPArw39IdhmCF8vmV+NhQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
@@ -1055,6 +1102,22 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/ajv": {
|
||||
"version": "8.20.0",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz",
|
||||
"integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"fast-uri": "^3.0.1",
|
||||
"json-schema-traverse": "^1.0.0",
|
||||
"require-from-string": "^2.0.2"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/epoberezkin"
|
||||
}
|
||||
},
|
||||
"node_modules/babel-plugin-macros": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/babel-plugin-macros/-/babel-plugin-macros-3.1.0.tgz",
|
||||
@@ -1236,6 +1299,28 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/fast-deep-equal": {
|
||||
"version": "3.1.3",
|
||||
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
|
||||
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/fast-uri": {
|
||||
"version": "3.1.9",
|
||||
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.9.tgz",
|
||||
"integrity": "sha512-hS/0Wt3Ya043oKXs0sIxrMpKQITXhMLIrVAKKXi4gozGC9v7YRWVnXIZzjNPTO02M9BdxLCWqK1yRXgNziVyJQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/fastify"
|
||||
},
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/fastify"
|
||||
}
|
||||
],
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/fdir": {
|
||||
"version": "6.5.0",
|
||||
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
|
||||
@@ -1416,6 +1501,12 @@
|
||||
"integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/json-schema-traverse": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
|
||||
"integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/lightningcss": {
|
||||
"version": "1.33.0",
|
||||
"resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz",
|
||||
@@ -1708,9 +1799,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/nanoid": {
|
||||
"version": "3.3.18",
|
||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.18.tgz",
|
||||
"integrity": "sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w==",
|
||||
"version": "3.3.20",
|
||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz",
|
||||
"integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
@@ -1807,9 +1898,9 @@
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/picomatch": {
|
||||
"version": "4.0.5",
|
||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz",
|
||||
"integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==",
|
||||
"version": "4.0.7",
|
||||
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz",
|
||||
"integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -1825,10 +1916,39 @@
|
||||
"integrity": "sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/playwright": {
|
||||
"version": "1.64.1",
|
||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.64.1.tgz",
|
||||
"integrity": "sha512-HCrVhHr5QQuwYoswEUGTb7gGp522yflbv/ST8nF4sFWGuLjQCt17Q/EubpGGSNKYn1tsTCPZxqHhHCfVURu7UA==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"playwright-core": "1.64.1"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/playwright-core": {
|
||||
"version": "1.64.1",
|
||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.64.1.tgz",
|
||||
"integrity": "sha512-BC4s8y6SEVA6Q1rSxZTto8hI1KUI3xXlHGZgvGqP4IqPdI/a6FX9H29IDNz7vKo9l21b6LfYosScPL6M3xxyDQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"playwright-core": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/postcss": {
|
||||
"version": "8.5.26",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.26.tgz",
|
||||
"integrity": "sha512-u82N74LFzG8ca+dD8puPnplTXoGH4fTPpVGuIbt36G3qvNlkvfD0lEAZSxaly3KX8TS/L1A1gsCEmvKmBcVbkQ==",
|
||||
"version": "8.5.32",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.32.tgz",
|
||||
"integrity": "sha512-LJlKCCAUFKOuZxipUdYw1NzIITEsPcgyOG9LkvRJvuKj/bRzbuRY0ARXvL0pWGpsZvn8jku+LMep2eU0seHp8g==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
@@ -1846,14 +1966,30 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"nanoid": "^3.3.17",
|
||||
"nanoid": "^3.3.20",
|
||||
"picocolors": "^1.1.1",
|
||||
"source-map-js": "^1.2.1"
|
||||
"source-map-js": "^1.2.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^10 || ^12 || >=14"
|
||||
}
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "3.9.10",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.9.10.tgz",
|
||||
"integrity": "sha512-skGHTH1Yb9QvaTC4hWnRTzEYtCpApF0UMBPz+t/0ZPzP8ihefo/btKd+QA7pUE0fEwA1SbS/NmhyEcstdXOIdA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"prettier": "bin/prettier.cjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/prop-types": {
|
||||
"version": "15.8.1",
|
||||
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
|
||||
@@ -1952,6 +2088,15 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/require-from-string": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
|
||||
"integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/resolve": {
|
||||
"version": "1.22.12",
|
||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.12.tgz",
|
||||
@@ -1983,13 +2128,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/rolldown": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.5.tgz",
|
||||
"integrity": "sha512-VD2IE5PUG4Oj8zz2VGykiYd5wbnjdIiSsNQb8Qu5B+noEp+A78mu2iVvpp27g8es14Tk9rofNs5Tku9iQCS4fA==",
|
||||
"version": "1.2.15",
|
||||
"resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.15.tgz",
|
||||
"integrity": "sha512-6odND+fel5zVw3I4Yc2e69gvguDnX0CAAGiNDZSq4ik5WUcaLrkD2GLuog0XcODbor31hZ5ayEMgVDno+KPV5g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@oxc-project/types": "=0.146.0",
|
||||
"@oxc-project/types": "=0.155.0",
|
||||
"@rolldown/pluginutils": "^1.0.0"
|
||||
},
|
||||
"bin": {
|
||||
@@ -1999,21 +2144,21 @@
|
||||
"node": "^20.19.0 || >=22.12.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@rolldown/binding-android-arm-eabi": "1.2.5",
|
||||
"@rolldown/binding-android-arm64": "1.2.5",
|
||||
"@rolldown/binding-darwin-arm64": "1.2.5",
|
||||
"@rolldown/binding-darwin-x64": "1.2.5",
|
||||
"@rolldown/binding-freebsd-x64": "1.2.5",
|
||||
"@rolldown/binding-linux-arm-gnueabihf": "1.2.5",
|
||||
"@rolldown/binding-linux-arm64-gnu": "1.2.5",
|
||||
"@rolldown/binding-linux-arm64-musl": "1.2.5",
|
||||
"@rolldown/binding-linux-ppc64-gnu": "1.2.5",
|
||||
"@rolldown/binding-linux-s390x-gnu": "1.2.5",
|
||||
"@rolldown/binding-linux-x64-gnu": "1.2.5",
|
||||
"@rolldown/binding-linux-x64-musl": "1.2.5",
|
||||
"@rolldown/binding-openharmony-arm64": "1.2.5",
|
||||
"@rolldown/binding-win32-arm64-msvc": "1.2.5",
|
||||
"@rolldown/binding-win32-x64-msvc": "1.2.5"
|
||||
"@rolldown/binding-android-arm-eabi": "1.2.15",
|
||||
"@rolldown/binding-android-arm64": "1.2.15",
|
||||
"@rolldown/binding-darwin-arm64": "1.2.15",
|
||||
"@rolldown/binding-darwin-x64": "1.2.15",
|
||||
"@rolldown/binding-freebsd-x64": "1.2.15",
|
||||
"@rolldown/binding-linux-arm-gnueabihf": "1.2.15",
|
||||
"@rolldown/binding-linux-arm64-gnu": "1.2.15",
|
||||
"@rolldown/binding-linux-arm64-musl": "1.2.15",
|
||||
"@rolldown/binding-linux-ppc64-gnu": "1.2.15",
|
||||
"@rolldown/binding-linux-s390x-gnu": "1.2.15",
|
||||
"@rolldown/binding-linux-x64-gnu": "1.2.15",
|
||||
"@rolldown/binding-linux-x64-musl": "1.2.15",
|
||||
"@rolldown/binding-openharmony-arm64": "1.2.15",
|
||||
"@rolldown/binding-win32-arm64-msvc": "1.2.15",
|
||||
"@rolldown/binding-win32-x64-msvc": "1.2.15"
|
||||
}
|
||||
},
|
||||
"node_modules/scheduler": {
|
||||
@@ -2032,9 +2177,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/source-map-js": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
|
||||
"integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz",
|
||||
"integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==",
|
||||
"dev": true,
|
||||
"license": "BSD-3-Clause",
|
||||
"engines": {
|
||||
@@ -2116,16 +2261,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "8.2.2",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-8.2.2.tgz",
|
||||
"integrity": "sha512-cFKLV/PRgAUlIRm5WjMjJ86jrftzpqcgH+Us+DS8mI3CDNiH30Whrz8uHL3+MOLPAgqbMBAqWdAHAphOAM+z/Q==",
|
||||
"version": "8.3.5",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-8.3.5.tgz",
|
||||
"integrity": "sha512-z1YpjieJ9g0ebTmQpLBv/oq9E3F9EIlOe+7LahW8SrE3LTiG3udBRUXQOlYXP9b+IC2q2phHeVxj9xGlw34OEQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"lightningcss": "^1.33.0",
|
||||
"picomatch": "^4.0.5",
|
||||
"postcss": "^8.5.26",
|
||||
"rolldown": "~1.2.4",
|
||||
"picomatch": "^4.0.7",
|
||||
"postcss": "^8.5.30",
|
||||
"rolldown": "~1.2.14",
|
||||
"tinyglobby": "^0.2.17"
|
||||
},
|
||||
"bin": {
|
||||
@@ -2142,7 +2287,7 @@
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/node": "^20.19.0 || >=22.12.0",
|
||||
"@vitejs/devtools": "^0.4.0 || ^0.5.0",
|
||||
"@vitejs/devtools": "^0.7.1 || ^0.8.0",
|
||||
"esbuild": "^0.27.0 || ^0.28.0",
|
||||
"jiti": ">=1.21.0",
|
||||
"less": "^4.0.0",
|
||||
|
||||
+12
-3
@@ -1,20 +1,27 @@
|
||||
{
|
||||
"name": "microduck-sandbox",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"test": "node --test \"test/**/*.test.js\"",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
"preview": "vite preview",
|
||||
"test:e2e": "playwright test",
|
||||
"test:regression": "playwright test microduck-regression",
|
||||
"baseline:record": "RECORD_BASELINE=1 playwright test microduck-regression",
|
||||
"validate:packages": "node scripts/validate-packages.mjs",
|
||||
"format:check": "prettier --check \"src/platform/**/*.js\" \"src/robots/**/*.js\" \"e2e/**/*.{js,html}\" \"scripts/*.mjs\" \"test/*.test.js\" \"src/ui/{ControlsHelp,SimulationToolbar,RuntimeStatus}.jsx\" \"src/{App,scene/GameCanvas}.jsx\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.14.0",
|
||||
"@emotion/styled": "^11.14.1",
|
||||
"@fontsource/anton": "^5.3.0",
|
||||
"@mui/material": "^9.3.1",
|
||||
"@mujoco/mujoco": "^3.11.0",
|
||||
"@react-three/fiber": "^9.7.0",
|
||||
"ajv": "^8.20.0",
|
||||
"onnxruntime-web": "^1.27.0",
|
||||
"react": "^19.2.8",
|
||||
"react-dom": "^19.2.8",
|
||||
@@ -23,7 +30,9 @@
|
||||
"zustand": "^5.0.15"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.64.1",
|
||||
"@vitejs/plugin-react": "^6.1.0",
|
||||
"vite": "^8.2.2"
|
||||
"prettier": "^3.9.10",
|
||||
"vite": "^8.3.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { defineConfig } from "@playwright/test";
|
||||
export default defineConfig({
|
||||
testDir: "./e2e",
|
||||
timeout: 180_000,
|
||||
workers: 1,
|
||||
reporter: [["list"], ["json", { outputFile: "test-results/results.json" }]],
|
||||
expect: { timeout: 30_000 },
|
||||
use: {
|
||||
baseURL: process.env.TEST_BASE_URL || "http://127.0.0.1:5173",
|
||||
headless: true,
|
||||
viewport: { width: 1440, height: 900 },
|
||||
launchOptions: {
|
||||
args: [
|
||||
"--use-gl=angle",
|
||||
"--use-angle=swiftshader",
|
||||
"--enable-unsafe-swiftshader",
|
||||
],
|
||||
},
|
||||
trace: "retain-on-failure",
|
||||
screenshot: "only-on-failure",
|
||||
},
|
||||
webServer: process.env.TEST_BASE_URL
|
||||
? undefined
|
||||
: {
|
||||
command: "npm run dev -- --host 127.0.0.1",
|
||||
url: "http://127.0.0.1:5173",
|
||||
reuseExistingServer: true,
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,93 @@
|
||||
Copyright 2020 The Anton Project Authors (https://github.com/googlefonts/AntonFont.git)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
@@ -0,0 +1,20 @@
|
||||
[
|
||||
{
|
||||
"id": "microduck-legs",
|
||||
"family": "microduck",
|
||||
"name": "Microduck",
|
||||
"manifest": "microduck-legs/robot.json"
|
||||
},
|
||||
{
|
||||
"id": "microduck-rollers",
|
||||
"family": "microduck",
|
||||
"name": "Microduck",
|
||||
"manifest": "microduck-rollers/robot.json"
|
||||
},
|
||||
{
|
||||
"id": "microban",
|
||||
"family": "microban",
|
||||
"name": "Microban",
|
||||
"manifest": "microban/robot.json"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,14 @@
|
||||
# Microban bundled source assets
|
||||
|
||||
Imported with `python3 app/scripts/import-microban.py /path/to/microban`.
|
||||
|
||||
The precise origin remote, HEAD, dirty-worktree flag, per-file SHA-256 and behavior-reference hashes are in `source-manifest.json`. The source worktree was dirty at import: the HEAD alone is **not** a complete description of the behavior used as reference. Runtime does not read that worktree or require Python.
|
||||
|
||||
- `model.xml`: copied from `src/model/mjcf/robot.xml`, unmodified; its Apache-2.0 copyright/license header is retained.
|
||||
- `assets/*.stl`: only the 25 mesh files actually declared by that MJCF, copied byte-for-byte from the source model asset directory (not the separate `cad/` directory).
|
||||
- `policies/walk.onnx`: copied byte-for-byte from `src/agents/walk.onnx`.
|
||||
- `LICENSES/SOURCE-LICENSE.txt`: entire upstream license/attribution notice. The upstream summary assigns GPL-3.0 to control software outside `cad/` and CC-BY-NC-SA-4.0 to `cad/`. Model-file-specific notices take precedence for their respective files. No assertion is made that all files have one uniform license. Preserve these notices when redistributing, and check upstream terms for intended distribution.
|
||||
|
||||
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.
|
||||
|
||||
No Placo, real-robot control, source Python code, CAD project, BAM battery model or communication delays are bundled into the browser runtime.
|
||||
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,618 @@
|
||||
<!--
|
||||
Copyright 2026 Marc Duclusaud
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
-->
|
||||
|
||||
<!-- Generated using onshape-to-robot -->
|
||||
<!-- Onshape https://cad.onshape.com/documents/d424992a192a8ce34ffce163/v/d1df625a85f2de984257464b/e/b34620a03cc3a684006c5867 -->
|
||||
<mujoco model="microban">
|
||||
<compiler angle="radian" meshdir="assets" autolimits="true"/>
|
||||
<default>
|
||||
<default class="microban">
|
||||
<joint frictionloss="0.1" armature="0.005"/>
|
||||
<position kp="50" dampratio="1"/>
|
||||
<default class="visual">
|
||||
<geom type="mesh" contype="0" conaffinity="0" group="2"/>
|
||||
</default>
|
||||
<default class="collision">
|
||||
<geom group="3"/>
|
||||
</default>
|
||||
</default>
|
||||
<default class="xl330">
|
||||
<joint damping="0.041" frictionloss="0.013" armature="0.0018"/>
|
||||
<motor gear="1"/>
|
||||
</default>
|
||||
</default>
|
||||
<sensor>
|
||||
<framequat name="orientation" objtype="site" noise="0.001" objname="imu"/>
|
||||
<gyro name="angular-velocity" site="imu" noise="0.005"/>
|
||||
<gyro name="imu_ang_vel" site="imu"/>
|
||||
<velocimeter name="imu_lin_vel" site="imu"/>
|
||||
<accelerometer name="imu_accel" site="imu"/>
|
||||
<subtreeangmom name="root_angmom" body="trunk"/>
|
||||
</sensor>
|
||||
<worldbody>
|
||||
<!-- Link trunk -->
|
||||
<body name="trunk" pos="0 0 0" quat="1 0 0 0" childclass="microban">
|
||||
<freejoint name="trunk_freejoint"/>
|
||||
<inertial pos="-0.00454781 -0.000104579 0.053896" mass="0.347283" fullinertia="0.000608722 0.000477224 0.000357224 -5.1387e-07 -1.16287e-05 1.9299e-06"/>
|
||||
<!-- Part stp39__configuration__2_2x8 -->
|
||||
<!-- Part stp39__configuration__2_2x8_2 -->
|
||||
<!-- Part arm_bearing_support__configuration_right -->
|
||||
<geom type="mesh" class="visual" pos="0.00575 -0.036 -0.0484" quat="0.707107 0 0 0.707107" mesh="arm_bearing_support__configuration_right" material="arm_bearing_support__configuration_right_material"/>
|
||||
<!-- Part xl330_without_horn -->
|
||||
<geom type="mesh" class="visual" pos="0 -0.044 0.081" quat="0.707107 0.707107 0 0" mesh="xl330_without_horn" material="xl330_without_horn_material"/>
|
||||
<!-- Part steel_shim -->
|
||||
<!-- Part pelvis__configuration_right -->
|
||||
<geom class="collision" pos="0 0 0.05375" quat="0.707107 0 0 0.707107" type="box" size="0.054 0.008 0.05375"/>
|
||||
<geom class="collision" pos="0 0 0.05775" quat="0.707107 0 0 0.707107" type="box" size="0.029 0.033 0.04275"/>
|
||||
<geom type="mesh" class="visual" pos="0.00575 -0.036 -0.0484" quat="0.707107 0 0 0.707107" mesh="pelvis__configuration_right" material="pelvis__configuration_right_material"/>
|
||||
<!-- Part stp39__configuration__2_2x8_3 -->
|
||||
<!-- Part arm_bearing_support__configuration_right_2 -->
|
||||
<geom type="mesh" class="visual" pos="-0.00575 0.036 -0.0484" quat="0.707107 -0 0 -0.707107" mesh="arm_bearing_support__configuration_right" material="arm_bearing_support__configuration_right_material"/>
|
||||
<!-- Part xl330_without_horn_2 -->
|
||||
<geom type="mesh" class="visual" pos="-0.00204165 -0 0.1195" quat="0.707107 0 0 0.707107" mesh="xl330_without_horn" material="xl330_without_horn_material"/>
|
||||
<!-- Part stp39__configuration__2_2x8_4 -->
|
||||
<!-- Part hat -->
|
||||
<!-- Part xl330_without_horn_3 -->
|
||||
<geom type="mesh" class="visual" pos="-0 0.036 0.0065" quat="0 0 -1 0" mesh="xl330_without_horn" material="xl330_without_horn_material"/>
|
||||
<!-- Part steel_shim_2 -->
|
||||
<!-- Part washer -->
|
||||
<!-- Part xl330_without_horn_4 -->
|
||||
<geom type="mesh" class="visual" pos="-0 0.044 0.081" quat="0 0 -0.707107 -0.707107" mesh="xl330_without_horn" material="xl330_without_horn_material"/>
|
||||
<!-- Part stp39__configuration__2_2x8_5 -->
|
||||
<!-- Part steel_shim_3 -->
|
||||
<!-- Part steel_shim_4 -->
|
||||
<!-- Part stp39__configuration__2_2x8_6 -->
|
||||
<!-- Part chest__configuration_right -->
|
||||
<geom type="mesh" class="visual" pos="0.00575 -0.036 -0.0484" quat="0.707107 0 0 0.707107" mesh="chest__configuration_right" material="chest__configuration_right_material"/>
|
||||
<!-- Part trunk_top__configuration_right -->
|
||||
<geom type="mesh" class="visual" pos="0.00575 -0.036 -0.0484" quat="0.707107 0 0 0.707107" mesh="trunk_top__configuration_right" material="trunk_top__configuration_right_material"/>
|
||||
<!-- Part stp39__configuration__2_2x8_7 -->
|
||||
<!-- Part washer_2 -->
|
||||
<!-- Part pom_shim -->
|
||||
<!-- Part pom_shim_2 -->
|
||||
<!-- Part stp39__configuration__2_2x8_8 -->
|
||||
<!-- Part stp39__configuration__2_2x8_9 -->
|
||||
<!-- Part stp39__configuration__2_2x8_10 -->
|
||||
<!-- Part stp39__configuration__2_2x8_11 -->
|
||||
<!-- Part steel_shim_5 -->
|
||||
<!-- Part steel_shim_6 -->
|
||||
<!-- Part battery -->
|
||||
<geom type="mesh" class="visual" pos="-0.01 -0 0.05115" quat="0.5 0.5 -0.5 -0.5" mesh="battery" material="battery_material"/>
|
||||
<!-- Part bms -->
|
||||
<!-- Part steel_shim_7 -->
|
||||
<!-- Part stp39__configuration__2_2x8_12 -->
|
||||
<!-- Part pom_shim_3 -->
|
||||
<!-- Part switch -->
|
||||
<geom type="mesh" class="visual" pos="-0.014 0.02 0.1075" quat="1 0 0 0" mesh="switch" material="switch_material"/>
|
||||
<!-- Part stp39__configuration__2_2x8_13 -->
|
||||
<!-- Part stp39__configuration__2_2x8_14 -->
|
||||
<!-- Part stp39__configuration__2_2x8_15 -->
|
||||
<!-- Part raspberry_pi_zero_2w -->
|
||||
<!-- Part washer_3 -->
|
||||
<!-- Part stp39__configuration__2_2x8_16 -->
|
||||
<!-- Part washer_4 -->
|
||||
<!-- Part steel_shim_8 -->
|
||||
<!-- Part stp39__configuration__2_2x8_17 -->
|
||||
<!-- Part xl330_without_horn_5 -->
|
||||
<geom type="mesh" class="visual" pos="0 -0.036 0.0065" quat="0 1 0 -0" mesh="xl330_without_horn" material="xl330_without_horn_material"/>
|
||||
<!-- Part pom_shim_4 -->
|
||||
<!-- Part stp39__configuration__2_2x8_18 -->
|
||||
<!-- Part charger -->
|
||||
<!-- Frame body -->
|
||||
<site group="3" name="body" pos="0 0 0" quat="1 -0 -0 -0"/>
|
||||
<!-- Frame imu -->
|
||||
<site group="3" name="imu" pos="0.01483 -0.002 0.0675" quat="0.5 -0.5 -0.5 0.5"/>
|
||||
<!-- Link head -->
|
||||
<body name="head" pos="-0.00204165 -0 0.126" quat="0.707107 0 0 0.707107">
|
||||
<!-- Joint from trunk to head -->
|
||||
<joint axis="0 0 1" name="head" type="hinge" range="-1.5707963267949783 1.5707963267948148" class="xl330"/>
|
||||
<inertial pos="5.1303e-08 -0.0074561 0.0161837" mass="0.0166215" fullinertia="2.92963e-06 3.58354e-06 4.24694e-06 -1.6e-11 4e-12 2.61187e-07"/>
|
||||
<!-- Part stp39__configuration__2x6 -->
|
||||
<!-- Part stp39__configuration__2x6_2 -->
|
||||
<!-- Part head__configuration_right -->
|
||||
<geom type="mesh" class="visual" pos="-0.036 -0.00779165 -0.1744" quat="1 -0 -0 0" mesh="head__configuration_right" material="head__configuration_right_material"/>
|
||||
<!-- Part stp39__configuration__2x6_3 -->
|
||||
<!-- Part stp39__configuration__2x6_4 -->
|
||||
</body>
|
||||
<!-- Link shoulder -->
|
||||
<body name="shoulder" pos="0 -0.0505 0.081" quat="0.707107 -0.707107 -0 0">
|
||||
<!-- Joint from trunk to shoulder -->
|
||||
<joint axis="0 0 1" name="right_shoulder_pitch" type="hinge" range="-3.141592653589793 3.141592653589793" class="xl330"/>
|
||||
<inertial pos="4.19e-10 2.814e-09 -0.00850029" mass="0.00898451" fullinertia="1.06003e-06 1.78233e-06 1.86739e-06 0 0 -0"/>
|
||||
<!-- Part stp39__configuration__2x6_5 -->
|
||||
<!-- Part stp39__configuration__2x6_6 -->
|
||||
<!-- Part stp39__configuration__2x6_7 -->
|
||||
<!-- Part stp39__configuration__2x6_8 -->
|
||||
<!-- Part stp39__configuration__2x6_9 -->
|
||||
<!-- Part stp39__configuration__2x6_10 -->
|
||||
<!-- Part stp39__configuration__2x6_11 -->
|
||||
<!-- Part stp39__configuration__2x6_12 -->
|
||||
<!-- Part stp39__configuration__2x6_13 -->
|
||||
<!-- Part shoulder -->
|
||||
<geom type="mesh" class="visual" pos="-0 -0.0245 0.0132" quat="0.5 -0.5 -0.5 -0.5" mesh="shoulder" material="shoulder_material"/>
|
||||
<!-- Part stp39__configuration__2x6_14 -->
|
||||
<!-- Part stp39__configuration__2x6_15 -->
|
||||
<!-- Part stp39__configuration__2x6_16 -->
|
||||
<!-- Link humerus__configuration_right -->
|
||||
<body name="humerus__configuration_right" pos="0.0145 0 -0.0195" quat="0 0.707107 0 0.707107">
|
||||
<!-- Joint from shoulder to humerus__configuration_right -->
|
||||
<joint axis="0 0 1" name="right_shoulder_roll" type="hinge" range="-3.1415926535897922 8.881784197001252e-16" class="xl330"/>
|
||||
<inertial pos="-0.000309872 -0.0252784 -0.0143918" mass="0.0416867" fullinertia="1.76899e-05 3.95132e-06 1.75854e-05 -3.03216e-07 -2.278e-09 -7.8184e-08"/>
|
||||
<!-- Part stp39__configuration__2_2x8_19 -->
|
||||
<!-- Part stp39__configuration__2_2x8_20 -->
|
||||
<!-- Part stp39__configuration__2_2x8_21 -->
|
||||
<!-- Part stp39__configuration__2_2x8_22 -->
|
||||
<!-- Part xl330 -->
|
||||
<geom type="mesh" class="visual" pos="0 0 -0.0065" quat="1 -0 -0 0" mesh="xl330" material="xl330_material"/>
|
||||
<!-- Part stp39__configuration__2_2x8_23 -->
|
||||
<!-- Part stp39__configuration__2_2x8_24 -->
|
||||
<!-- Part xl330_without_horn_6 -->
|
||||
<geom type="mesh" class="visual" pos="-0.008 -0.0515 -0.0145" quat="0 0.707107 0 -0.707107" mesh="xl330_without_horn" material="xl330_without_horn_material"/>
|
||||
<!-- Part stp39__configuration__2_2x8_25 -->
|
||||
<!-- Part stp39__configuration__2_2x8_26 -->
|
||||
<!-- Part humerus -->
|
||||
<geom type="mesh" class="visual" pos="-0.0327 -0.0245 -0.0145" quat="0 0 0.707107 0.707107" mesh="humerus" material="humerus_material"/>
|
||||
<!-- Link radius -->
|
||||
<body name="radius" pos="-0.0145 -0.0515 -0.0145" quat="0.707107 0 0.707107 -0">
|
||||
<!-- Joint from humerus__configuration_right to radius -->
|
||||
<joint axis="0 0 1" name="right_elbow" type="hinge" range="-2.181661564992912 2.181661564992912" class="xl330"/>
|
||||
<inertial pos="-4.0628e-08 -0.0310611 0.0130165" mass="0.0115415" fullinertia="5.26775e-06 1.21602e-06 4.45903e-06 -4e-12 -1.2e-11 1.7157e-07"/>
|
||||
<!-- Part stp39__configuration__2x6_17 -->
|
||||
<!-- Part stp39__configuration__2x6_18 -->
|
||||
<!-- Part radius -->
|
||||
<geom class="collision" pos="-0 0 0.0135" quat="0.707107 -0 -0 -0.707107" type="cylinder" size="0.009 0.01675"/>
|
||||
<geom class="collision" pos="-0 -0.067014 0.0135" quat="0.707107 -0 -0 -0.707107" type="cylinder" size="0.00525 0.008"/>
|
||||
<geom type="mesh" class="visual" pos="0 0.027 0.0472" quat="0.5 -0.5 -0.5 -0.5" mesh="radius" material="radius_material"/>
|
||||
<!-- Part stp39__configuration__2x6_19 -->
|
||||
<!-- Part dc15_a01_idle_cap_dummy -->
|
||||
<geom type="mesh" class="visual" pos="0 0 0.0065" quat="0 0.707107 0.707107 -0" mesh="dc15_a01_idle_cap_dummy" material="dc15_a01_idle_cap_dummy_material"/>
|
||||
<!-- Part bts2_m2_6x8 -->
|
||||
<geom type="mesh" class="visual" pos="0 0 0.0065" quat="0 0.707107 0.707107 -0" mesh="bts2_m2_6x8" material="bts2_m2_6x8_material"/>
|
||||
<!-- Part stp39__configuration__2x6_20 -->
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
<!-- Link hip -->
|
||||
<body name="hip" pos="0 -0.036 0" quat="1 -0 -0 0">
|
||||
<!-- Joint from trunk to hip -->
|
||||
<joint axis="0 0 1" name="right_hip_yaw" type="hinge" range="-4.188790204786353 1.047197551196635" class="xl330"/>
|
||||
<inertial pos="0.00421822 1.46909e-07 -0.00948697" mass="0.00884451" fullinertia="9.36719e-07 4.32505e-06 4.03697e-06 -3.3e-11 1.95496e-07 0"/>
|
||||
<!-- Part hip__configuration_right -->
|
||||
<geom type="mesh" class="visual" pos="0.00575 -0 -0.0484" quat="0.707107 0 0 0.707107" mesh="hip__configuration_right" material="hip__configuration_right_material"/>
|
||||
<!-- Part stp39__configuration__2x6_21 -->
|
||||
<!-- Part stp39__configuration__2x6_22 -->
|
||||
<!-- Part stp39__configuration__2x6_23 -->
|
||||
<!-- Part stp39__configuration__2x6_24 -->
|
||||
<!-- Part stp39__configuration__2x6_25 -->
|
||||
<!-- Part stp39__configuration__2x6_26 -->
|
||||
<!-- Part stp39__configuration__2x6_27 -->
|
||||
<!-- Part stp39__configuration__2x6_28 -->
|
||||
<!-- Part stp39__configuration__2x6_29 -->
|
||||
<!-- Part stp39__configuration__2x6_30 -->
|
||||
<!-- Part stp39__configuration__2x6_31 -->
|
||||
<!-- Part stp39__configuration__2x6_32 -->
|
||||
<!-- Link hip_block__configuration_right -->
|
||||
<body name="hip_block__configuration_right" pos="-0.02 0 -0.0214" quat="0.5 -0.5 0.5 -0.5">
|
||||
<!-- Joint from hip to hip_block__configuration_right -->
|
||||
<joint axis="0 0 1" name="right_hip_roll" type="hinge" range="-0.610865238197994 0.6108652381980366" class="xl330"/>
|
||||
<inertial pos="-5.75932e-05 0.00982795 0.0271518" mass="0.04763" fullinertia="1.64064e-05 1.33088e-05 7.85889e-06 -9.153e-09 7.8745e-08 6.63067e-07"/>
|
||||
<!-- Part stp39__configuration__2_2x8_27 -->
|
||||
<!-- Part xl330_2 -->
|
||||
<geom type="mesh" class="visual" pos="-0.008 -0 0.0385" quat="0 0.707107 0 -0.707107" mesh="xl330" material="xl330_material"/>
|
||||
<!-- Part dc15_a01_horn_idle2_dummy -->
|
||||
<geom type="mesh" class="visual" pos="0 -0 0.033" quat="0 -0 1 0" mesh="dc15_a01_horn_idle2_dummy" material="dc15_a01_horn_idle2_dummy_material"/>
|
||||
<!-- Part stp39__configuration__2_2x8_28 -->
|
||||
<!-- Part stp39__configuration__2_2x8_29 -->
|
||||
<!-- Part stp39__configuration__2_2x8_30 -->
|
||||
<!-- Part hip_dbl_block__configuration_right -->
|
||||
<geom class="collision" pos="-0 0.02075 0.02575" quat="0 -0 0.707107 -0.707107" type="box" size="0.0135 0.02525 0.00625"/>
|
||||
<geom type="mesh" class="visual" pos="0 0.027 0.02575" quat="0 -0 0.707107 -0.707107" mesh="hip_dbl_block__configuration_right" material="hip_dbl_block__configuration_right_material"/>
|
||||
<!-- Part stp39__configuration__2_2x8_31 -->
|
||||
<!-- Part xl330_without_horn_7 -->
|
||||
<geom type="mesh" class="visual" pos="-0 0 0.0065" quat="0 1 0 0" mesh="xl330_without_horn" material="xl330_without_horn_material"/>
|
||||
<!-- Part bts2_m2_6x8_2 -->
|
||||
<geom type="mesh" class="visual" pos="0 -0 0.033" quat="0 -0 1 0" mesh="bts2_m2_6x8" material="bts2_m2_6x8_material"/>
|
||||
<!-- Part dc15_a01_idle_cap_dummy_2 -->
|
||||
<geom type="mesh" class="visual" pos="0 -0 0.033" quat="0 -0 1 0" mesh="dc15_a01_idle_cap_dummy" material="dc15_a01_idle_cap_dummy_material"/>
|
||||
<!-- Part stp39__configuration__2_2x8_32 -->
|
||||
<!-- Part spacer__configuration_right -->
|
||||
<geom type="mesh" class="visual" pos="-0 -0.0095 0.0385" quat="0 0 -0.707107 -0.707107" mesh="spacer__configuration_right" material="spacer__configuration_right_material"/>
|
||||
<!-- Link femur__configuration_right -->
|
||||
<body name="femur__configuration_right" pos="-0.0145 -0 0.0385" quat="0 0.707107 0 -0.707107">
|
||||
<!-- Joint from hip_block__configuration_right to femur__configuration_right -->
|
||||
<joint axis="0 0 1" name="right_hip_pitch" type="hinge" range="-1.5707963267948974 1.5707963267948957" class="xl330"/>
|
||||
<inertial pos="-0.0109472 -0.0366847 -0.0147025" mass="0.014726" fullinertia="1.12665e-05 4.38335e-06 8.95932e-06 -1.12592e-06 1.333e-09 -4.521e-09"/>
|
||||
<!-- Part stp39__configuration__2x6_33 -->
|
||||
<!-- Part femur__configuration_right -->
|
||||
<geom class="collision" pos="-0.015 -0.0335001 0.00275" quat="0.5 -0.5 0.5 0.5" type="box" size="0.00125 0.009 0.022228"/>
|
||||
<geom class="collision" pos="-0.008818 -0.00881806 0.00275" quat="0.653281 -0.270598 0.653281 0.270598" type="box" size="0.00125 0.009 0.0124705"/>
|
||||
<geom class="collision" pos="-0.011318 -0.0556821 0.00275" quat="0.270598 -0.653281 0.270598 0.653281" type="box" size="0.00125 0.009 0.008935"/>
|
||||
<geom type="mesh" class="visual" pos="0.003 -0.132713 -0.0145" quat="0.5 -0.5 0.5 0.5" mesh="femur__configuration_right" material="femur__configuration_right_material"/>
|
||||
<!-- Part stp39__configuration__2x6_34 -->
|
||||
<!-- Part stp39__configuration__2x6_35 -->
|
||||
<!-- Part stp39__configuration__2x6_36 -->
|
||||
<!-- Part stp39__configuration__2x6_37 -->
|
||||
<!-- Part stp39__configuration__2x6_38 -->
|
||||
<!-- Part stp39__configuration__2x6_39 -->
|
||||
<!-- Part stp39__configuration__2x6_40 -->
|
||||
<!-- Part stp39__configuration__2x6_41 -->
|
||||
<!-- Part stp39__configuration__2x6_42 -->
|
||||
<!-- Part stp39__configuration__2x6_43 -->
|
||||
<!-- Part stp39__configuration__2x6_44 -->
|
||||
<!-- Part stp39__configuration__2x6_45 -->
|
||||
<!-- Part stp39__configuration__2x6_46 -->
|
||||
<!-- Part stp39__configuration__2x6_47 -->
|
||||
<!-- Part stp39__configuration__2x6_48 -->
|
||||
<!-- Link tibia__configuration_right -->
|
||||
<body name="tibia__configuration_right" pos="-0.005 -0.062 -0" quat="1 -0 0 -0">
|
||||
<!-- Joint from femur__configuration_right to tibia__configuration_right -->
|
||||
<joint axis="0 0 1" name="right_knee" type="hinge" range="-0.7853981633977201 2.356194490192073" class="xl330"/>
|
||||
<inertial pos="0.00276278 -0.0196679 -0.0144621" mass="0.0300463" fullinertia="1.53882e-05 5.3311e-06 1.38581e-05 2.25674e-06 7.6682e-08 -1.37001e-07"/>
|
||||
<!-- Part stp39__configuration__2x6_49 -->
|
||||
<!-- Part stp39__configuration__2x6_50 -->
|
||||
<!-- Part stp39__configuration__2x6_51 -->
|
||||
<!-- Part stp39__configuration__2x6_52 -->
|
||||
<!-- Part stp39__configuration__2_2x8_33 -->
|
||||
<!-- Part xl330_3 -->
|
||||
<geom type="mesh" class="visual" pos="0 -0 -0.0065" quat="1 -0 -0 0" mesh="xl330" material="xl330_material"/>
|
||||
<!-- Part tibia__configuration_right -->
|
||||
<geom class="collision" pos="0.017 -0.0444631 0.00275" quat="0.5 -0.5 0.5 0.5" type="box" size="0.00125 0.009 0.0115"/>
|
||||
<geom class="collision" pos="0.0138 -0.0554431 0.00275" quat="0.653281 -0.270598 0.653281 0.270598" type="box" size="0.00125 0.009 0.00825"/>
|
||||
<geom class="collision" pos="0.00675 -0.0287131 0.00275" quat="0.270598 -0.653281 0.270598 0.653281" type="box" size="0.00125 0.0106065 0.016617"/>
|
||||
<geom class="collision" pos="0.0117 -0.0236231 -0.0145" quat="0.270598 -0.653281 0.270598 0.653281" type="box" size="0.0185 0.0035 0.0023295"/>
|
||||
<geom type="mesh" class="visual" pos="0.008 -0.0707131 -0.0145" quat="0.5 -0.5 0.5 0.5" mesh="tibia__configuration_right" material="tibia__configuration_right_material"/>
|
||||
<!-- Part stp39__configuration__2x6_53 -->
|
||||
<!-- Part stp39__configuration__2_2x8_34 -->
|
||||
<!-- Part stp39__configuration__2x6_54 -->
|
||||
<!-- Part stp39__configuration__2_2x8_35 -->
|
||||
<!-- Part stp39__configuration__2_2x8_36 -->
|
||||
<!-- Part stp39__configuration__2x6_55 -->
|
||||
<!-- Part stp39__configuration__2x6_56 -->
|
||||
<!-- Link ankle_block__configuration_left -->
|
||||
<body name="ankle_block__configuration_left" pos="0.008 -0.0612131 -0" quat="0 -0 -0 1">
|
||||
<!-- Joint from tibia__configuration_right to ankle_block__configuration_left -->
|
||||
<joint axis="0 0 1" name="right_ankle_pitch" type="hinge" range="-1.5707963267948077 0.6108652381981041" class="xl330"/>
|
||||
<inertial pos="-0.0110676 -0.00979852 -0.0144015" mass="0.04722" fullinertia="7.83993e-06 1.29837e-05 1.60971e-05 -6.00742e-07 -4.9782e-08 -6.127e-09"/>
|
||||
<!-- Part stp39__configuration__2_2x8_37 -->
|
||||
<!-- Part xl330_4 -->
|
||||
<geom type="mesh" class="visual" pos="0 0 -0.0065" quat="1 0 -0 0" mesh="xl330" material="xl330_material"/>
|
||||
<!-- Part dc15_a01_horn_idle2_dummy_2 -->
|
||||
<geom type="mesh" class="visual" pos="-0.0055 0 -0.0145" quat="0 -0.707107 -0 0.707107" mesh="dc15_a01_horn_idle2_dummy" material="dc15_a01_horn_idle2_dummy_material"/>
|
||||
<!-- Part stp39__configuration__2_2x8_38 -->
|
||||
<!-- Part stp39__configuration__2_2x8_39 -->
|
||||
<!-- Part stp39__configuration__2_2x8_40 -->
|
||||
<!-- Part ankle_dbl_block__configuration_right -->
|
||||
<geom class="collision" pos="-0.01275 -0.02075 -0.0145" quat="0.5 0.5 0.5 -0.5" type="box" size="0.0135 0.02525 0.00625"/>
|
||||
<geom type="mesh" class="visual" pos="0 0.0095 -0.0145" quat="0.5 0.5 0.5 -0.5" mesh="ankle_dbl_block__configuration_right" material="ankle_dbl_block__configuration_right_material"/>
|
||||
<!-- Part stp39__configuration__2_2x8_41 -->
|
||||
<!-- Part xl330_without_horn_8 -->
|
||||
<geom type="mesh" class="visual" pos="-0.032 0 -0.0145" quat="0.707107 0 -0.707107 -0" mesh="xl330_without_horn" material="xl330_without_horn_material"/>
|
||||
<!-- Part bts2_m2_6x8_3 -->
|
||||
<geom type="mesh" class="visual" pos="-0.0055 0 -0.0145" quat="0 -0.707107 -0 0.707107" mesh="bts2_m2_6x8" material="bts2_m2_6x8_material"/>
|
||||
<!-- Part dc15_a01_idle_cap_dummy_3 -->
|
||||
<geom type="mesh" class="visual" pos="-0.0055 0 -0.0145" quat="0 -0.707107 -0 0.707107" mesh="dc15_a01_idle_cap_dummy" material="dc15_a01_idle_cap_dummy_material"/>
|
||||
<!-- Part stp39__configuration__2_2x8_42 -->
|
||||
<!-- Part spacer__configuration_right_2 -->
|
||||
<geom type="mesh" class="visual" pos="0 0.0095 -0.0145" quat="0.5 0.5 0.5 -0.5" mesh="spacer__configuration_right" material="spacer__configuration_right_material"/>
|
||||
<!-- Link foot -->
|
||||
<body name="foot" pos="-0.0385 0 -0.0145" quat="0 -0.707107 0 -0.707107">
|
||||
<!-- Joint from ankle_block__configuration_left to foot -->
|
||||
<joint axis="0 0 1" name="right_ankle_roll" type="hinge" range="-0.610865238197748 0.6108652381982826" class="xl330"/>
|
||||
<inertial pos="-0 -0.0168869 0.0347422" mass="0.016823" fullinertia="1.15605e-05 1.2167e-05 2.53496e-06 0 -0 5.67932e-07"/>
|
||||
<!-- Part stp39__configuration__2x6_57 -->
|
||||
<!-- Part stp39__configuration__2x6_58 -->
|
||||
<!-- Part stp39__configuration__2x6_59 -->
|
||||
<!-- Part stp39__configuration__2x6_60 -->
|
||||
<!-- Part stp39__configuration__2x6_61 -->
|
||||
<!-- Part foot__configuration_right -->
|
||||
<geom name="right_foot_collision_1" class="collision" pos="-0 -0.02175 0.042" quat="0 0 0.707107 0.707107" type="box" size="0.0225 0.04 0.00125"/>
|
||||
<geom name="right_foot_collision_2" class="collision" pos="-0 -0.02175 0.042" quat="0 0 0.707107 0.707107" type="box" size="0.0175 0.045 0.00125"/>
|
||||
<geom name="right_foot_collision_3" class="collision" pos="-0.0175 -0.02175 0.002" quat="0.270598 -0.270598 -0.653281 -0.653281" type="box" size="0.00353553 0.00353553 0.00125"/>
|
||||
<geom name="right_foot_collision_4" class="collision" pos="0.0175 -0.02175 0.002" quat="0.270598 -0.270598 -0.653281 -0.653281" type="box" size="0.00353553 0.00353553 0.00125"/>
|
||||
<geom name="right_foot_collision_5" class="collision" pos="-0.0175 -0.02175 0.082" quat="0.270598 -0.270598 -0.653281 -0.653281" type="box" size="0.00353553 0.00353553 0.00125"/>
|
||||
<geom name="right_foot_collision_6" class="collision" pos="0.0175 -0.02175 0.082" quat="0.270598 -0.270598 -0.653281 -0.653281" type="box" size="0.00353553 0.00353553 0.00125"/>
|
||||
<geom type="mesh" class="visual" pos="-0 -0.0095 0.0385" quat="0 0 0.707107 0.707107" mesh="foot__configuration_right" material="foot__configuration_right_material"/>
|
||||
<!-- Part stp39__configuration__2x6_62 -->
|
||||
<!-- Part stp39__configuration__2x6_63 -->
|
||||
<!-- Part stp39__configuration__2x6_64 -->
|
||||
<!-- Frame right_foot -->
|
||||
<site group="3" name="right_foot" pos="-0 -0.023 0.042" quat="0.5 -0.5 -0.5 -0.5"/>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
<!-- Link shoulder_2 -->
|
||||
<body name="shoulder_2" pos="-0 0.0505 0.081" quat="0 0 -0.707107 -0.707107">
|
||||
<!-- Joint from trunk to shoulder_2 -->
|
||||
<joint axis="0 0 1" name="left_shoulder_pitch" type="hinge" range="-3.141592653589793 3.141592653589793" class="xl330"/>
|
||||
<inertial pos="-4.19e-10 2.814e-09 0.00850029" mass="0.00898451" fullinertia="1.06003e-06 1.78233e-06 1.86739e-06 -0 0 0"/>
|
||||
<!-- Part stp39__configuration__2x6_65 -->
|
||||
<!-- Part stp39__configuration__2x6_66 -->
|
||||
<!-- Part stp39__configuration__2x6_67 -->
|
||||
<!-- Part stp39__configuration__2x6_68 -->
|
||||
<!-- Part stp39__configuration__2x6_69 -->
|
||||
<!-- Part stp39__configuration__2x6_70 -->
|
||||
<!-- Part stp39__configuration__2x6_71 -->
|
||||
<!-- Part stp39__configuration__2x6_72 -->
|
||||
<!-- Part stp39__configuration__2x6_73 -->
|
||||
<!-- Part shoulder_2 -->
|
||||
<geom type="mesh" class="visual" pos="0 -0.0245 -0.0132" quat="0.5 -0.5 0.5 0.5" mesh="shoulder" material="shoulder_material"/>
|
||||
<!-- Part stp39__configuration__2x6_74 -->
|
||||
<!-- Part stp39__configuration__2x6_75 -->
|
||||
<!-- Part stp39__configuration__2x6_76 -->
|
||||
<!-- Link humerus__configuration_left -->
|
||||
<body name="humerus__configuration_left" pos="-0.0145 0 0.0195" quat="0 -0.707107 -0 0.707107">
|
||||
<!-- Joint from shoulder_2 to humerus__configuration_left -->
|
||||
<joint axis="0 0 1" name="left_shoulder_roll" type="hinge" range="0.0 3.141592653589793" class="xl330"/>
|
||||
<inertial pos="-0.000313281 0.0252784 -0.0143884" mass="0.0416867" fullinertia="1.76899e-05 3.9512e-06 1.75853e-05 3.01684e-07 -5.77e-10 7.6531e-08"/>
|
||||
<!-- Part stp39__configuration__2_2x8_43 -->
|
||||
<!-- Part stp39__configuration__2_2x8_44 -->
|
||||
<!-- Part stp39__configuration__2_2x8_45 -->
|
||||
<!-- Part stp39__configuration__2_2x8_46 -->
|
||||
<!-- Part xl330_5 -->
|
||||
<geom type="mesh" class="visual" pos="0 0 -0.0065" quat="0 -0 -0 -1" mesh="xl330" material="xl330_material"/>
|
||||
<!-- Part stp39__configuration__2_2x8_47 -->
|
||||
<!-- Part stp39__configuration__2_2x8_48 -->
|
||||
<!-- Part xl330_without_horn_9 -->
|
||||
<geom type="mesh" class="visual" pos="-0.008 0.0515 -0.0145" quat="0.707107 0 -0.707107 -0" mesh="xl330_without_horn" material="xl330_without_horn_material"/>
|
||||
<!-- Part stp39__configuration__2_2x8_49 -->
|
||||
<!-- Part stp39__configuration__2_2x8_50 -->
|
||||
<!-- Part humerus_2 -->
|
||||
<geom type="mesh" class="visual" pos="0.0327 0.0245 -0.0145" quat="0.707107 0.707107 0 0" mesh="humerus" material="humerus_material"/>
|
||||
<!-- Link radius_2 -->
|
||||
<body name="radius_2" pos="-0.0145 0.0515 -0.0145" quat="0.707107 0 -0.707107 0">
|
||||
<!-- Joint from humerus__configuration_left to radius_2 -->
|
||||
<joint axis="0 0 1" name="left_elbow" type="hinge" range="-2.1816615649929156 2.1816615649929085" class="xl330"/>
|
||||
<inertial pos="-4.0628e-08 0.0310611 -0.0130165" mass="0.0115415" fullinertia="5.26775e-06 1.21602e-06 4.45903e-06 4e-12 1.2e-11 1.7157e-07"/>
|
||||
<!-- Part stp39__configuration__2x6_77 -->
|
||||
<!-- Part stp39__configuration__2x6_78 -->
|
||||
<!-- Part radius_2 -->
|
||||
<geom class="collision" pos="-0 -0 -0.0135" quat="0 0.707107 0.707107 -0" type="cylinder" size="0.009 0.01675"/>
|
||||
<geom class="collision" pos="-0 0.067014 -0.0135" quat="0 0.707107 0.707107 -0" type="cylinder" size="0.00525 0.008"/>
|
||||
<geom type="mesh" class="visual" pos="-0 -0.027 -0.0472" quat="0.5 0.5 0.5 -0.5" mesh="radius" material="radius_material"/>
|
||||
<!-- Part stp39__configuration__2x6_79 -->
|
||||
<!-- Part dc15_a01_idle_cap_dummy_4 -->
|
||||
<geom type="mesh" class="visual" pos="-0 0 -0.0065" quat="0.707107 -0 -0 -0.707107" mesh="dc15_a01_idle_cap_dummy" material="dc15_a01_idle_cap_dummy_material"/>
|
||||
<!-- Part bts2_m2_6x8_4 -->
|
||||
<geom type="mesh" class="visual" pos="-0 0 -0.0065" quat="0.707107 -0 -0 -0.707107" mesh="bts2_m2_6x8" material="bts2_m2_6x8_material"/>
|
||||
<!-- Part stp39__configuration__2x6_80 -->
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
<!-- Link hip_2 -->
|
||||
<body name="hip_2" pos="-0 0.036 0" quat="0 -0 0 -1">
|
||||
<!-- Joint from trunk to hip_2 -->
|
||||
<joint axis="0 0 1" name="left_hip_yaw" type="hinge" range="-1.0471975511965976 4.1887902047863905" class="xl330"/>
|
||||
<inertial pos="-0.00421822 -1.46909e-07 -0.00948697" mass="0.00884451" fullinertia="9.36719e-07 4.32505e-06 4.03697e-06 -3.3e-11 -1.95496e-07 -0"/>
|
||||
<!-- Part hip__configuration_right_2 -->
|
||||
<geom type="mesh" class="visual" pos="-0.00575 -0 -0.0484" quat="0.707107 -0 -0 -0.707107" mesh="hip__configuration_right" material="hip__configuration_right_material"/>
|
||||
<!-- Part stp39__configuration__2x6_81 -->
|
||||
<!-- Part stp39__configuration__2x6_82 -->
|
||||
<!-- Part stp39__configuration__2x6_83 -->
|
||||
<!-- Part stp39__configuration__2x6_84 -->
|
||||
<!-- Part stp39__configuration__2x6_85 -->
|
||||
<!-- Part stp39__configuration__2x6_86 -->
|
||||
<!-- Part stp39__configuration__2x6_87 -->
|
||||
<!-- Part stp39__configuration__2x6_88 -->
|
||||
<!-- Part stp39__configuration__2x6_89 -->
|
||||
<!-- Part stp39__configuration__2x6_90 -->
|
||||
<!-- Part stp39__configuration__2x6_91 -->
|
||||
<!-- Part stp39__configuration__2x6_92 -->
|
||||
<!-- Link hip_block__configuration_left -->
|
||||
<body name="hip_block__configuration_left" pos="0.02 0 -0.0214" quat="0.5 -0.5 -0.5 0.5">
|
||||
<!-- Joint from hip_2 to hip_block__configuration_left -->
|
||||
<joint axis="0 0 1" name="left_hip_roll" type="hinge" range="-0.6108652381980162 0.6108652381980144" class="xl330"/>
|
||||
<inertial pos="6.0554e-05 0.00982795 0.0271548" mass="0.04763" fullinertia="1.64096e-05 1.3312e-05 7.85888e-06 8.495e-09 -7.6959e-08 6.62404e-07"/>
|
||||
<!-- Part stp39__configuration__2_2x8_51 -->
|
||||
<!-- Part xl330_6 -->
|
||||
<geom type="mesh" class="visual" pos="0.008 -0 0.0385" quat="0 0.707107 0 0.707107" mesh="xl330" material="xl330_material"/>
|
||||
<!-- Part dc15_a01_horn_idle2_dummy_3 -->
|
||||
<geom type="mesh" class="visual" pos="-0 0 0.033" quat="0 -0 -1 -0" mesh="dc15_a01_horn_idle2_dummy" material="dc15_a01_horn_idle2_dummy_material"/>
|
||||
<!-- Part stp39__configuration__2_2x8_52 -->
|
||||
<!-- Part stp39__configuration__2_2x8_53 -->
|
||||
<!-- Part stp39__configuration__2_2x8_54 -->
|
||||
<!-- Part hip_dbl_block__configuration_left -->
|
||||
<geom class="collision" pos="-0 0.02075 0.02575" quat="0 -0 0.707107 -0.707107" type="box" size="0.0135 0.02525 0.00625"/>
|
||||
<geom type="mesh" class="visual" pos="0.027 0.027 0.02575" quat="0 -0 0.707107 -0.707107" mesh="hip_dbl_block__configuration_left" material="hip_dbl_block__configuration_left_material"/>
|
||||
<!-- Part stp39__configuration__2_2x8_55 -->
|
||||
<!-- Part xl330_without_horn_10 -->
|
||||
<geom type="mesh" class="visual" pos="0 0 0.0065" quat="0 1 0 0" mesh="xl330_without_horn" material="xl330_without_horn_material"/>
|
||||
<!-- Part bts2_m2_6x8_5 -->
|
||||
<geom type="mesh" class="visual" pos="-0 0 0.033" quat="0 -0 -1 -0" mesh="bts2_m2_6x8" material="bts2_m2_6x8_material"/>
|
||||
<!-- Part dc15_a01_idle_cap_dummy_5 -->
|
||||
<geom type="mesh" class="visual" pos="-0 0 0.033" quat="0 -0 -1 -0" mesh="dc15_a01_idle_cap_dummy" material="dc15_a01_idle_cap_dummy_material"/>
|
||||
<!-- Part stp39__configuration__2_2x8_56 -->
|
||||
<!-- Part spacer__configuration_right_3 -->
|
||||
<geom type="mesh" class="visual" pos="-0 -0.0095 0.0385" quat="0 0 -0.707107 -0.707107" mesh="spacer__configuration_right" material="spacer__configuration_right_material"/>
|
||||
<!-- Link femur__configuration_left -->
|
||||
<body name="femur__configuration_left" pos="-0.0145 -0 0.0385" quat="0.707107 -0 -0.707107 0">
|
||||
<!-- Joint from hip_block__configuration_left to femur__configuration_left -->
|
||||
<joint axis="0 0 1" name="left_hip_pitch" type="hinge" range="-1.5707963267948974 1.5707963267948957" class="xl330"/>
|
||||
<inertial pos="0.0109472 0.0366847 -0.0142975" mass="0.014726" fullinertia="1.12665e-05 4.38335e-06 8.95932e-06 -1.12592e-06 1.333e-09 -4.521e-09"/>
|
||||
<!-- Part stp39__configuration__2x6_93 -->
|
||||
<!-- Part femur__configuration_left -->
|
||||
<geom class="collision" pos="0.015 0.0335001 -0.03175" quat="0.5 0.5 0.5 -0.5" type="box" size="0.00125 0.009 0.022228"/>
|
||||
<geom class="collision" pos="0.008818 0.00881806 -0.03175" quat="0.270598 0.653281 0.270598 -0.653281" type="box" size="0.00125 0.009 0.0124705"/>
|
||||
<geom class="collision" pos="0.011318 0.0556821 -0.03175" quat="0.653281 0.270598 0.653281 -0.270598" type="box" size="0.00125 0.009 0.008935"/>
|
||||
<geom type="mesh" class="visual" pos="-0.003 0.132713 -0.0515" quat="0.5 0.5 0.5 -0.5" mesh="femur__configuration_left" material="femur__configuration_left_material"/>
|
||||
<!-- Part stp39__configuration__2x6_94 -->
|
||||
<!-- Part stp39__configuration__2x6_95 -->
|
||||
<!-- Part stp39__configuration__2x6_96 -->
|
||||
<!-- Part stp39__configuration__2x6_97 -->
|
||||
<!-- Part stp39__configuration__2x6_98 -->
|
||||
<!-- Part stp39__configuration__2x6_99 -->
|
||||
<!-- Part stp39__configuration__2x6_100 -->
|
||||
<!-- Part stp39__configuration__2x6_101 -->
|
||||
<!-- Part stp39__configuration__2x6_102 -->
|
||||
<!-- Part stp39__configuration__2x6_103 -->
|
||||
<!-- Part stp39__configuration__2x6_104 -->
|
||||
<!-- Part stp39__configuration__2x6_105 -->
|
||||
<!-- Part stp39__configuration__2x6_106 -->
|
||||
<!-- Part stp39__configuration__2x6_107 -->
|
||||
<!-- Part stp39__configuration__2x6_108 -->
|
||||
<!-- Link tibia__configuration_left -->
|
||||
<body name="tibia__configuration_left" pos="0.005 0.062 0" quat="1 -0 -0 -0">
|
||||
<!-- Joint from femur__configuration_left to tibia__configuration_left -->
|
||||
<joint axis="0 0 1" name="left_knee" type="hinge" range="-0.7853981633974314 2.3561944901923617" class="xl330"/>
|
||||
<inertial pos="-0.00275805 0.0196679 -0.0145379" mass="0.0300463" fullinertia="1.53882e-05 5.33188e-06 1.38589e-05 2.25747e-06 7.7561e-08 -1.37001e-07"/>
|
||||
<!-- Part stp39__configuration__2x6_109 -->
|
||||
<!-- Part stp39__configuration__2x6_110 -->
|
||||
<!-- Part stp39__configuration__2x6_111 -->
|
||||
<!-- Part stp39__configuration__2x6_112 -->
|
||||
<!-- Part stp39__configuration__2_2x8_57 -->
|
||||
<!-- Part xl330_7 -->
|
||||
<geom type="mesh" class="visual" pos="-0 0 -0.0225" quat="0 1 0 0" mesh="xl330" material="xl330_material"/>
|
||||
<!-- Part tibia__configuration_left -->
|
||||
<geom class="collision" pos="-0.017 0.0444631 -0.0317" quat="0.5 0.5 0.5 -0.5" type="box" size="0.00125 0.009 0.0115"/>
|
||||
<geom class="collision" pos="-0.0138 0.0554431 -0.03175" quat="0.270598 0.653281 0.270598 -0.653281" type="box" size="0.00125 0.009 0.00825"/>
|
||||
<geom class="collision" pos="-0.00675 0.0287131 -0.03175" quat="0.653281 0.270598 0.653281 -0.270598" type="box" size="0.00125 0.0106065 0.016617"/>
|
||||
<geom class="collision" pos="-0.0117 0.0236231 -0.0145" quat="0.653281 0.270598 0.653281 -0.270598" type="box" size="0.0185 0.0035 0.0023295"/>
|
||||
<geom type="mesh" class="visual" pos="-0.008 0.0707131 -0.0515" quat="0.5 0.5 0.5 -0.5" mesh="tibia__configuration_left" material="tibia__configuration_left_material"/>
|
||||
<!-- Part stp39__configuration__2x6_113 -->
|
||||
<!-- Part stp39__configuration__2_2x8_58 -->
|
||||
<!-- Part stp39__configuration__2x6_114 -->
|
||||
<!-- Part stp39__configuration__2_2x8_59 -->
|
||||
<!-- Part stp39__configuration__2_2x8_60 -->
|
||||
<!-- Part stp39__configuration__2x6_115 -->
|
||||
<!-- Part stp39__configuration__2x6_116 -->
|
||||
<!-- Link ankle_block__configuration_right -->
|
||||
<body name="ankle_block__configuration_right" pos="-0.008 0.0612131 -0" quat="0 0 -0 1">
|
||||
<!-- Joint from tibia__configuration_left to ankle_block__configuration_right -->
|
||||
<joint axis="0 0 1" name="left_ankle_pitch" type="hinge" range="-1.5707963267948744 0.6108652381980375" class="xl330"/>
|
||||
<inertial pos="0.0110706 0.00979852 -0.0145955" mass="0.04722" fullinertia="7.83996e-06 1.29805e-05 1.6094e-05 -6.01409e-07 -5.1613e-08 -6.789e-09"/>
|
||||
<!-- Part stp39__configuration__2_2x8_61 -->
|
||||
<!-- Part xl330_8 -->
|
||||
<geom type="mesh" class="visual" pos="0 0 -0.0225" quat="0 1 0 0" mesh="xl330" material="xl330_material"/>
|
||||
<!-- Part dc15_a01_horn_idle2_dummy_4 -->
|
||||
<geom type="mesh" class="visual" pos="0.0055 0 -0.0145" quat="0.707107 -0 0.707107 0" mesh="dc15_a01_horn_idle2_dummy" material="dc15_a01_horn_idle2_dummy_material"/>
|
||||
<!-- Part stp39__configuration__2_2x8_62 -->
|
||||
<!-- Part stp39__configuration__2_2x8_63 -->
|
||||
<!-- Part stp39__configuration__2_2x8_64 -->
|
||||
<!-- Part ankle_dbl_block__configuration_right_2 -->
|
||||
<geom class="collision" pos="0.01275 0.02075 -0.0145" quat="0.5 -0.5 0.5 0.5" type="box" size="0.0135 0.02525 0.00625"/>
|
||||
<geom type="mesh" class="visual" pos="-0 -0.0095 -0.0145" quat="0.5 -0.5 0.5 0.5" mesh="ankle_dbl_block__configuration_right" material="ankle_dbl_block__configuration_right_material"/>
|
||||
<!-- Part stp39__configuration__2_2x8_65 -->
|
||||
<!-- Part xl330_without_horn_11 -->
|
||||
<geom type="mesh" class="visual" pos="0.032 0 -0.0145" quat="0 0.707107 0 0.707107" mesh="xl330_without_horn" material="xl330_without_horn_material"/>
|
||||
<!-- Part bts2_m2_6x8_6 -->
|
||||
<geom type="mesh" class="visual" pos="0.0055 0 -0.0145" quat="0.707107 -0 0.707107 0" mesh="bts2_m2_6x8" material="bts2_m2_6x8_material"/>
|
||||
<!-- Part dc15_a01_idle_cap_dummy_6 -->
|
||||
<geom type="mesh" class="visual" pos="0.0055 0 -0.0145" quat="0.707107 -0 0.707107 0" mesh="dc15_a01_idle_cap_dummy" material="dc15_a01_idle_cap_dummy_material"/>
|
||||
<!-- Part stp39__configuration__2_2x8_66 -->
|
||||
<!-- Part spacer__configuration_right_4 -->
|
||||
<geom type="mesh" class="visual" pos="-0 -0.0095 -0.0145" quat="0.5 -0.5 0.5 0.5" mesh="spacer__configuration_right" material="spacer__configuration_right_material"/>
|
||||
<!-- Link foot_2 -->
|
||||
<body name="foot_2" pos="0.0385 0 -0.0145" quat="0.707107 -0 -0.707107 0">
|
||||
<!-- Joint from ankle_block__configuration_right to foot_2 -->
|
||||
<joint axis="0 0 1" name="left_ankle_roll" type="hinge" range="-0.6108652381980109 0.6108652381980197" class="xl330"/>
|
||||
<inertial pos="-0 -0.0168869 0.0347422" mass="0.016823" fullinertia="1.15605e-05 1.2167e-05 2.53496e-06 0 -0 5.67932e-07"/>
|
||||
<!-- Part stp39__configuration__2x6_117 -->
|
||||
<!-- Part stp39__configuration__2x6_118 -->
|
||||
<!-- Part stp39__configuration__2x6_119 -->
|
||||
<!-- Part stp39__configuration__2x6_120 -->
|
||||
<!-- Part stp39__configuration__2x6_121 -->
|
||||
<!-- Part foot__configuration_right_2 -->
|
||||
<geom name="left_foot_collision_1" class="collision" pos="-0 -0.02175 0.042" quat="0 0 0.707107 0.707107" type="box" size="0.0225 0.04 0.00125"/>
|
||||
<geom name="left_foot_collision_2" class="collision" pos="-0 -0.02175 0.042" quat="0 0 0.707107 0.707107" type="box" size="0.0175 0.045 0.00125"/>
|
||||
<geom name="left_foot_collision_3" class="collision" pos="-0.0175 -0.02175 0.002" quat="0.270598 -0.270598 -0.653281 -0.653281" type="box" size="0.00353553 0.00353553 0.00125"/>
|
||||
<geom name="left_foot_collision_4" class="collision" pos="0.0175 -0.02175 0.002" quat="0.270598 -0.270598 -0.653281 -0.653281" type="box" size="0.00353553 0.00353553 0.00125"/>
|
||||
<geom name="left_foot_collision_5" class="collision" pos="-0.0175 -0.02175 0.082" quat="0.270598 -0.270598 -0.653281 -0.653281" type="box" size="0.00353553 0.00353553 0.00125"/>
|
||||
<geom name="left_foot_collision_6" class="collision" pos="0.0175 -0.02175 0.082" quat="0.270598 -0.270598 -0.653281 -0.653281" type="box" size="0.00353553 0.00353553 0.00125"/>
|
||||
<geom type="mesh" class="visual" pos="-0 -0.0095 0.0385" quat="0 0 0.707107 0.707107" mesh="foot__configuration_right" material="foot__configuration_right_material"/>
|
||||
<!-- Part stp39__configuration__2x6_122 -->
|
||||
<!-- Part stp39__configuration__2x6_123 -->
|
||||
<!-- Part stp39__configuration__2x6_124 -->
|
||||
<!-- Frame left_foot -->
|
||||
<site group="3" name="left_foot" pos="-0 -0.023 0.042" quat="0.5 -0.5 -0.5 -0.5"/>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
</worldbody>
|
||||
<asset>
|
||||
<mesh file="hip_dbl_block__configuration_right.stl"/>
|
||||
<mesh file="ankle_dbl_block__configuration_right.stl"/>
|
||||
<mesh file="arm_bearing_support__configuration_right.stl"/>
|
||||
<mesh file="dc15_a01_idle_cap_dummy.stl"/>
|
||||
<mesh file="head__configuration_right.stl"/>
|
||||
<mesh file="shoulder.stl"/>
|
||||
<mesh file="xl330_without_horn.stl"/>
|
||||
<mesh file="humerus.stl"/>
|
||||
<mesh file="pelvis__configuration_right.stl"/>
|
||||
<mesh file="dc15_a01_horn_idle2_dummy.stl"/>
|
||||
<mesh file="spacer__configuration_right.stl"/>
|
||||
<mesh file="battery.stl"/>
|
||||
<mesh file="tibia__configuration_right.stl"/>
|
||||
<mesh file="tibia__configuration_left.stl"/>
|
||||
<mesh file="bts2_m2_6x8.stl"/>
|
||||
<mesh file="radius.stl"/>
|
||||
<mesh file="xl330.stl"/>
|
||||
<mesh file="hip__configuration_right.stl"/>
|
||||
<mesh file="femur__configuration_left.stl"/>
|
||||
<mesh file="femur__configuration_right.stl"/>
|
||||
<mesh file="switch.stl"/>
|
||||
<mesh file="hip_dbl_block__configuration_left.stl"/>
|
||||
<mesh file="chest__configuration_right.stl"/>
|
||||
<mesh file="foot__configuration_right.stl"/>
|
||||
<mesh file="trunk_top__configuration_right.stl"/>
|
||||
<material name="arm_bearing_support__configuration_right_material" rgba="0.501961 0.501961 0.501961 1"/>
|
||||
<material name="xl330_without_horn_material" rgba="0.301961 0.301961 0.301961 1"/>
|
||||
<material name="pelvis__configuration_right_material" rgba="0.501961 0.501961 0.501961 1"/>
|
||||
<material name="chest__configuration_right_material" rgba="0.501961 0.501961 0.501961 1"/>
|
||||
<material name="trunk_top__configuration_right_material" rgba="0.501961 0.501961 0.501961 1"/>
|
||||
<material name="battery_material" rgba="0.647059 0.647059 0.647059 1"/>
|
||||
<material name="switch_material" rgba="0.498039 0.498039 0.498039 1"/>
|
||||
<material name="head__configuration_right_material" rgba="0.501961 0.501961 0.501961 1"/>
|
||||
<material name="shoulder_material" rgba="0.501961 0.501961 0.501961 1"/>
|
||||
<material name="xl330_material" rgba="0.301961 0.301961 0.301961 1"/>
|
||||
<material name="humerus_material" rgba="0.501961 0.501961 0.501961 1"/>
|
||||
<material name="radius_material" rgba="0.501961 0.501961 0.501961 1"/>
|
||||
<material name="dc15_a01_idle_cap_dummy_material" rgba="0.301961 0.301961 0.301961 1"/>
|
||||
<material name="bts2_m2_6x8_material" rgba="0.301961 0.301961 0.301961 1"/>
|
||||
<material name="hip__configuration_right_material" rgba="0.501961 0.501961 0.501961 1"/>
|
||||
<material name="dc15_a01_horn_idle2_dummy_material" rgba="0.6 0.6 0.6 1"/>
|
||||
<material name="hip_dbl_block__configuration_right_material" rgba="0.501961 0.501961 0.501961 1"/>
|
||||
<material name="spacer__configuration_right_material" rgba="0.501961 0.501961 0.501961 1"/>
|
||||
<material name="femur__configuration_right_material" rgba="0.501961 0.501961 0.501961 1"/>
|
||||
<material name="tibia__configuration_right_material" rgba="0.501961 0.501961 0.501961 1"/>
|
||||
<material name="ankle_dbl_block__configuration_right_material" rgba="0.501961 0.501961 0.501961 1"/>
|
||||
<material name="foot__configuration_right_material" rgba="0.501961 0.501961 0.501961 1"/>
|
||||
<material name="hip_dbl_block__configuration_left_material" rgba="0.501961 0.501961 0.501961 1"/>
|
||||
<material name="femur__configuration_left_material" rgba="0.501961 0.501961 0.501961 1"/>
|
||||
<material name="tibia__configuration_left_material" rgba="0.501961 0.501961 0.501961 1"/>
|
||||
</asset>
|
||||
<actuator>
|
||||
<motor class="xl330" name="head" joint="head"/>
|
||||
<motor class="xl330" name="right_shoulder_pitch" joint="right_shoulder_pitch"/>
|
||||
<motor class="xl330" name="right_shoulder_roll" joint="right_shoulder_roll"/>
|
||||
<motor class="xl330" name="right_elbow" joint="right_elbow"/>
|
||||
<motor class="xl330" name="right_hip_yaw" joint="right_hip_yaw"/>
|
||||
<motor class="xl330" name="right_hip_roll" joint="right_hip_roll"/>
|
||||
<motor class="xl330" name="right_hip_pitch" joint="right_hip_pitch"/>
|
||||
<motor class="xl330" name="right_knee" joint="right_knee"/>
|
||||
<motor class="xl330" name="right_ankle_pitch" joint="right_ankle_pitch"/>
|
||||
<motor class="xl330" name="right_ankle_roll" joint="right_ankle_roll"/>
|
||||
<motor class="xl330" name="left_shoulder_pitch" joint="left_shoulder_pitch"/>
|
||||
<motor class="xl330" name="left_shoulder_roll" joint="left_shoulder_roll"/>
|
||||
<motor class="xl330" name="left_elbow" joint="left_elbow"/>
|
||||
<motor class="xl330" name="left_hip_yaw" joint="left_hip_yaw"/>
|
||||
<motor class="xl330" name="left_hip_roll" joint="left_hip_roll"/>
|
||||
<motor class="xl330" name="left_hip_pitch" joint="left_hip_pitch"/>
|
||||
<motor class="xl330" name="left_knee" joint="left_knee"/>
|
||||
<motor class="xl330" name="left_ankle_pitch" joint="left_ankle_pitch"/>
|
||||
<motor class="xl330" name="left_ankle_roll" joint="left_ankle_roll"/>
|
||||
</actuator>
|
||||
<equality/>
|
||||
</mujoco>
|
||||
Binary file not shown.
@@ -0,0 +1,333 @@
|
||||
{
|
||||
"schema": 1,
|
||||
"id": "microban",
|
||||
"name": "Microban",
|
||||
"family": "microban",
|
||||
"adapter": "generic",
|
||||
"model": "model.xml",
|
||||
"assets": [
|
||||
{
|
||||
"path": "assets/hip_dbl_block__configuration_right.stl",
|
||||
"vfs": "assets/hip_dbl_block__configuration_right.stl"
|
||||
},
|
||||
{
|
||||
"path": "assets/ankle_dbl_block__configuration_right.stl",
|
||||
"vfs": "assets/ankle_dbl_block__configuration_right.stl"
|
||||
},
|
||||
{
|
||||
"path": "assets/arm_bearing_support__configuration_right.stl",
|
||||
"vfs": "assets/arm_bearing_support__configuration_right.stl"
|
||||
},
|
||||
{
|
||||
"path": "assets/dc15_a01_idle_cap_dummy.stl",
|
||||
"vfs": "assets/dc15_a01_idle_cap_dummy.stl"
|
||||
},
|
||||
{
|
||||
"path": "assets/head__configuration_right.stl",
|
||||
"vfs": "assets/head__configuration_right.stl"
|
||||
},
|
||||
{
|
||||
"path": "assets/shoulder.stl",
|
||||
"vfs": "assets/shoulder.stl"
|
||||
},
|
||||
{
|
||||
"path": "assets/xl330_without_horn.stl",
|
||||
"vfs": "assets/xl330_without_horn.stl"
|
||||
},
|
||||
{
|
||||
"path": "assets/humerus.stl",
|
||||
"vfs": "assets/humerus.stl"
|
||||
},
|
||||
{
|
||||
"path": "assets/pelvis__configuration_right.stl",
|
||||
"vfs": "assets/pelvis__configuration_right.stl"
|
||||
},
|
||||
{
|
||||
"path": "assets/dc15_a01_horn_idle2_dummy.stl",
|
||||
"vfs": "assets/dc15_a01_horn_idle2_dummy.stl"
|
||||
},
|
||||
{
|
||||
"path": "assets/spacer__configuration_right.stl",
|
||||
"vfs": "assets/spacer__configuration_right.stl"
|
||||
},
|
||||
{
|
||||
"path": "assets/battery.stl",
|
||||
"vfs": "assets/battery.stl"
|
||||
},
|
||||
{
|
||||
"path": "assets/tibia__configuration_right.stl",
|
||||
"vfs": "assets/tibia__configuration_right.stl"
|
||||
},
|
||||
{
|
||||
"path": "assets/tibia__configuration_left.stl",
|
||||
"vfs": "assets/tibia__configuration_left.stl"
|
||||
},
|
||||
{
|
||||
"path": "assets/bts2_m2_6x8.stl",
|
||||
"vfs": "assets/bts2_m2_6x8.stl"
|
||||
},
|
||||
{
|
||||
"path": "assets/radius.stl",
|
||||
"vfs": "assets/radius.stl"
|
||||
},
|
||||
{
|
||||
"path": "assets/xl330.stl",
|
||||
"vfs": "assets/xl330.stl"
|
||||
},
|
||||
{
|
||||
"path": "assets/hip__configuration_right.stl",
|
||||
"vfs": "assets/hip__configuration_right.stl"
|
||||
},
|
||||
{
|
||||
"path": "assets/femur__configuration_left.stl",
|
||||
"vfs": "assets/femur__configuration_left.stl"
|
||||
},
|
||||
{
|
||||
"path": "assets/femur__configuration_right.stl",
|
||||
"vfs": "assets/femur__configuration_right.stl"
|
||||
},
|
||||
{
|
||||
"path": "assets/switch.stl",
|
||||
"vfs": "assets/switch.stl"
|
||||
},
|
||||
{
|
||||
"path": "assets/hip_dbl_block__configuration_left.stl",
|
||||
"vfs": "assets/hip_dbl_block__configuration_left.stl"
|
||||
},
|
||||
{
|
||||
"path": "assets/chest__configuration_right.stl",
|
||||
"vfs": "assets/chest__configuration_right.stl"
|
||||
},
|
||||
{
|
||||
"path": "assets/foot__configuration_right.stl",
|
||||
"vfs": "assets/foot__configuration_right.stl"
|
||||
},
|
||||
{
|
||||
"path": "assets/trunk_top__configuration_right.stl",
|
||||
"vfs": "assets/trunk_top__configuration_right.stl"
|
||||
}
|
||||
],
|
||||
"base": {
|
||||
"type": "floating",
|
||||
"root_body": "trunk",
|
||||
"freejoint": "trunk_freejoint",
|
||||
"spawn": {
|
||||
"pos": [
|
||||
0,
|
||||
0,
|
||||
0.165
|
||||
],
|
||||
"yaw": 0
|
||||
},
|
||||
"initial": {
|
||||
"head": 0,
|
||||
"right_shoulder_pitch": 0.17453292519943295,
|
||||
"right_shoulder_roll": -0.17453292519943295,
|
||||
"right_elbow": -0.3490658503988659,
|
||||
"right_hip_yaw": 0,
|
||||
"right_hip_roll": -0.08726646259971647,
|
||||
"right_hip_pitch": -0.17453292519943295,
|
||||
"right_knee": 0,
|
||||
"right_ankle_pitch": 0,
|
||||
"right_ankle_roll": 0.08726646259971647,
|
||||
"left_shoulder_pitch": 0.17453292519943295,
|
||||
"left_shoulder_roll": 0.17453292519943295,
|
||||
"left_elbow": -0.3490658503988659,
|
||||
"left_hip_yaw": 0,
|
||||
"left_hip_roll": 0.08726646259971647,
|
||||
"left_hip_pitch": -0.17453292519943295,
|
||||
"left_knee": 0,
|
||||
"left_ankle_pitch": 0,
|
||||
"left_ankle_roll": -0.08726646259971647
|
||||
}
|
||||
},
|
||||
"sim": {
|
||||
"timestep": 0.005,
|
||||
"decimation": 4
|
||||
},
|
||||
"joints": {
|
||||
"groups": {
|
||||
"policy": [
|
||||
"right_shoulder_pitch",
|
||||
"right_shoulder_roll",
|
||||
"right_elbow",
|
||||
"right_hip_yaw",
|
||||
"right_hip_roll",
|
||||
"right_hip_pitch",
|
||||
"right_knee",
|
||||
"right_ankle_pitch",
|
||||
"right_ankle_roll",
|
||||
"left_shoulder_pitch",
|
||||
"left_shoulder_roll",
|
||||
"left_elbow",
|
||||
"left_hip_yaw",
|
||||
"left_hip_roll",
|
||||
"left_hip_pitch",
|
||||
"left_knee",
|
||||
"left_ankle_pitch",
|
||||
"left_ankle_roll"
|
||||
],
|
||||
"head": [
|
||||
"head"
|
||||
]
|
||||
},
|
||||
"defaults": {
|
||||
"head": 0
|
||||
},
|
||||
"source": "onnx_metadata"
|
||||
},
|
||||
"observations": {
|
||||
"obs": {
|
||||
"terms": [
|
||||
{
|
||||
"type": "gyro",
|
||||
"sensor": "angular-velocity"
|
||||
},
|
||||
{
|
||||
"type": "projected_gravity",
|
||||
"body": "trunk"
|
||||
},
|
||||
{
|
||||
"type": "joint_pos_rel",
|
||||
"group": "policy"
|
||||
},
|
||||
{
|
||||
"type": "joint_vel",
|
||||
"group": "policy"
|
||||
},
|
||||
{
|
||||
"type": "last_action",
|
||||
"group": "policy"
|
||||
},
|
||||
{
|
||||
"type": "command",
|
||||
"size": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "joint_position",
|
||||
"group": "policy",
|
||||
"scale": 1,
|
||||
"offset": "default"
|
||||
}
|
||||
],
|
||||
"actuation": {
|
||||
"type": "joint_pd",
|
||||
"kp": 0.3,
|
||||
"kd": 0.02,
|
||||
"torque_limit": 0.65
|
||||
},
|
||||
"commands": {
|
||||
"size": 3,
|
||||
"limits": [
|
||||
0.15,
|
||||
-0.1,
|
||||
0.6
|
||||
]
|
||||
},
|
||||
"skills": [
|
||||
{
|
||||
"id": "walk",
|
||||
"kind": "primary",
|
||||
"owns": "policy",
|
||||
"controller": {
|
||||
"type": "onnx",
|
||||
"policy": "policies/walk.onnx"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "head",
|
||||
"kind": "overlay",
|
||||
"owns": "head",
|
||||
"controller": {
|
||||
"type": "oscillator",
|
||||
"frequency": 0.35,
|
||||
"amplitude": 0.7853981633974483,
|
||||
"blend": 0.5
|
||||
}
|
||||
}
|
||||
],
|
||||
"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": "toggle:head",
|
||||
"codes": [
|
||||
"KeyH"
|
||||
],
|
||||
"label": "Toggle head rotation"
|
||||
},
|
||||
{
|
||||
"action": "chaseToggle",
|
||||
"codes": ["KeyC"],
|
||||
"label": "Restore chase camera"
|
||||
}
|
||||
]
|
||||
},
|
||||
"render": {
|
||||
"source": "mjcf_visual",
|
||||
"groups": [
|
||||
2
|
||||
],
|
||||
"camera": {
|
||||
"distance": 0.8
|
||||
}
|
||||
},
|
||||
"presentation": {
|
||||
"theme": "comic"
|
||||
},
|
||||
"termination": {
|
||||
"tilt_z": -0.5,
|
||||
"min_height": 0.06,
|
||||
"on_fall": "hold"
|
||||
},
|
||||
"license": "See LICENSES/SOURCE-LICENSE.txt and SOURCE.md (file-specific notices apply)"
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
{
|
||||
"head": "d0a128d180ecfce69eaaf31b295a0fce31280bfd",
|
||||
"dirty": true,
|
||||
"files": [
|
||||
{
|
||||
"source": "src/model/mjcf/robot.xml",
|
||||
"file": "model.xml",
|
||||
"sha256": "467b02e6d897d5871e0ec753016c0b1c87482ae0584ca7b760b9f5a2b435a797",
|
||||
"bytes": 46845
|
||||
},
|
||||
{
|
||||
"source": "src/agents/walk.onnx",
|
||||
"file": "policies/walk.onnx",
|
||||
"sha256": "e016ba7693a4c768e91625167244a08cee1667f188472d51ebdb6024bccfea7b",
|
||||
"bytes": 800059
|
||||
},
|
||||
{
|
||||
"source": "LICENSE",
|
||||
"file": "LICENSES/SOURCE-LICENSE.txt",
|
||||
"sha256": "f882cb4ee533a88e73fec57c75ddb63bdd204480e1dd5f663975e9d4c6751bf0",
|
||||
"bytes": 56954
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/hip_dbl_block__configuration_right.stl",
|
||||
"file": "assets/hip_dbl_block__configuration_right.stl",
|
||||
"sha256": "219aea2aa6a786bd4d181a2324c5e101c2ce29b3b6f0078579f85f49a8145d7d",
|
||||
"bytes": 206684
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/ankle_dbl_block__configuration_right.stl",
|
||||
"file": "assets/ankle_dbl_block__configuration_right.stl",
|
||||
"sha256": "7fe7356ac4d07fe93040be68af210d55ab6a0dcdfa4d9882768b8feff7e2a905",
|
||||
"bytes": 203084
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/arm_bearing_support__configuration_right.stl",
|
||||
"file": "assets/arm_bearing_support__configuration_right.stl",
|
||||
"sha256": "75b936438bdb6b62736d6b7b10b46ce877d4370727faceae027b1141abca68c0",
|
||||
"bytes": 55284
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/dc15_a01_idle_cap_dummy.stl",
|
||||
"file": "assets/dc15_a01_idle_cap_dummy.stl",
|
||||
"sha256": "b5a94e1d09efe5c0b754fcfd7dfc3bbb3c8e48ba531659f1c27dec6e9b15108b",
|
||||
"bytes": 201784
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/head__configuration_right.stl",
|
||||
"file": "assets/head__configuration_right.stl",
|
||||
"sha256": "44499a31f1c8c9a85433bbfd7ce12859eb1e841c632afde7c8e6eb8e2a259cfc",
|
||||
"bytes": 497084
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/shoulder.stl",
|
||||
"file": "assets/shoulder.stl",
|
||||
"sha256": "e71d55164ab9fd127fdae44669a951d9b1ac239f3c62e6bfdd266d418525c5bd",
|
||||
"bytes": 315184
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/xl330_without_horn.stl",
|
||||
"file": "assets/xl330_without_horn.stl",
|
||||
"sha256": "7b83cfc45390aea5852464ba4194b2c75ac9a1976039db7f7fa8830d48860947",
|
||||
"bytes": 535584
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/humerus.stl",
|
||||
"file": "assets/humerus.stl",
|
||||
"sha256": "b614448aec0afb1ff6a1a41bd7900ddeb43d0fe98b2a6cd8994b0a8efe9f29b9",
|
||||
"bytes": 121484
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/pelvis__configuration_right.stl",
|
||||
"file": "assets/pelvis__configuration_right.stl",
|
||||
"sha256": "0d8e1fa5ffc4e03c7ece6b5741813f6d35e7f8941e67fff12cf800f5625289a5",
|
||||
"bytes": 296484
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/dc15_a01_horn_idle2_dummy.stl",
|
||||
"file": "assets/dc15_a01_horn_idle2_dummy.stl",
|
||||
"sha256": "40455b774c89c23a68b34056e6cc0587b4c23ea2ecfac4e5b4b713d1b2e23ce9",
|
||||
"bytes": 282584
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/spacer__configuration_right.stl",
|
||||
"file": "assets/spacer__configuration_right.stl",
|
||||
"sha256": "001b2d16c008b50570a6deabf6e66aa6ee8736655eab1376d87bbc60e8db2813",
|
||||
"bytes": 44884
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/battery.stl",
|
||||
"file": "assets/battery.stl",
|
||||
"sha256": "46bfa2a22ba14628af86fd82f412b9e6ac7c2934171872b2851f6acffdef7d11",
|
||||
"bytes": 684
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/tibia__configuration_right.stl",
|
||||
"file": "assets/tibia__configuration_right.stl",
|
||||
"sha256": "88f47086845e52bf1334b4f74ea086dc647c3f738b23d502f86b3bbf6fa43251",
|
||||
"bytes": 398984
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/tibia__configuration_left.stl",
|
||||
"file": "assets/tibia__configuration_left.stl",
|
||||
"sha256": "62c50f2c718ede723f9db50c97825c4655edc4986feadb558c976f5d30eb15dc",
|
||||
"bytes": 399284
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/bts2_m2_6x8.stl",
|
||||
"file": "assets/bts2_m2_6x8.stl",
|
||||
"sha256": "93816c7bc9f389e788c7c96f15be96efc7f6ae64c60232d312c04e316bfec940",
|
||||
"bytes": 269584
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/radius.stl",
|
||||
"file": "assets/radius.stl",
|
||||
"sha256": "fde50ad5c63a5bb2a35fcf950d24f34731a4cbdae04ad6e74d36477b3d56addf",
|
||||
"bytes": 529984
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/xl330.stl",
|
||||
"file": "assets/xl330.stl",
|
||||
"sha256": "0aca2dcb9f30e0bb7c435cc74f115cce7314b51851bc57e103397108bdaeab35",
|
||||
"bytes": 674484
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/hip__configuration_right.stl",
|
||||
"file": "assets/hip__configuration_right.stl",
|
||||
"sha256": "6ad9a9afe37826f11ab041fb02853c1e90e6d1ae0cdd0158a48bf6e13d496277",
|
||||
"bytes": 1048584
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/femur__configuration_left.stl",
|
||||
"file": "assets/femur__configuration_left.stl",
|
||||
"sha256": "3a06675c2b266d2ba2c760e0b6211edd8f628eb69563a8df47d3f5edc8f2f432",
|
||||
"bytes": 629884
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/femur__configuration_right.stl",
|
||||
"file": "assets/femur__configuration_right.stl",
|
||||
"sha256": "5ebf1d61d9e2f00f1ab5de8596965e16098e9253efe019e254d72b6b75dfe617",
|
||||
"bytes": 628384
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/switch.stl",
|
||||
"file": "assets/switch.stl",
|
||||
"sha256": "2908d7222f24c93f639e4e546f76f3b2cea08de983da6c643b926a3f97177e38",
|
||||
"bytes": 2084
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/hip_dbl_block__configuration_left.stl",
|
||||
"file": "assets/hip_dbl_block__configuration_left.stl",
|
||||
"sha256": "f70a7b8dfb4dd6d05233f102457db085b38150e460fc59a1a2bb8bab11df9a18",
|
||||
"bytes": 206684
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/chest__configuration_right.stl",
|
||||
"file": "assets/chest__configuration_right.stl",
|
||||
"sha256": "d9a6cd9b153ef75913aad9a16461e947499e583a02275c10407aea5c2e3f309e",
|
||||
"bytes": 444684
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/foot__configuration_right.stl",
|
||||
"file": "assets/foot__configuration_right.stl",
|
||||
"sha256": "e157450cd49fddd719db849e2e5494533b823a01c7443142fea7fb10eb56c4cb",
|
||||
"bytes": 166084
|
||||
},
|
||||
{
|
||||
"source": "src/model/mjcf/assets/trunk_top__configuration_right.stl",
|
||||
"file": "assets/trunk_top__configuration_right.stl",
|
||||
"sha256": "f1fc9c48cb2a241084048cdd439fa6edccb409281f0c1f585f143f16b4aa98c0",
|
||||
"bytes": 365884
|
||||
}
|
||||
],
|
||||
"behaviorReferences": [
|
||||
{
|
||||
"file": "src/constants.py",
|
||||
"sha256": "6625c127e80cee2f41086c39c997aba1169f8e4c63eac3b1f9748312b47733c0"
|
||||
},
|
||||
{
|
||||
"file": "src/moves/walk.py",
|
||||
"sha256": "fb866ef2a96254a462fd1a99e68637498d1bbcee76802c467a3dce5c3ed98d8e"
|
||||
},
|
||||
{
|
||||
"file": "src/moves/rotate_head.py",
|
||||
"sha256": "027831ec4ed15544f22877ea89c0fdfeece6990d2ea55816a405c1b94e709d4e"
|
||||
},
|
||||
{
|
||||
"file": "src/observer.py",
|
||||
"sha256": "e9d98708f00f2d14acb26e64eefc0282dcc327b00a780a5f59899ce8faeeb7c2"
|
||||
},
|
||||
{
|
||||
"file": "src/imu_reader.py",
|
||||
"sha256": "69f82911920e186345be13664b3cf52c2de8f05f13f4cd9ce09cccb0fb4eefc3"
|
||||
},
|
||||
{
|
||||
"file": "src/sim/mujoco_controller.py",
|
||||
"sha256": "cd9d3fb59e195775aec2a60fb6e8335ee410f39e44f0204f16952fa8827bc057"
|
||||
},
|
||||
{
|
||||
"file": "src/sim/sim_main.py",
|
||||
"sha256": "5218a64a979132d4cee6f8b113adaa7bc4dc81d389d0985e8bafc2ac17def907"
|
||||
}
|
||||
],
|
||||
"source": "https://github.com/Rhoban/microban.git",
|
||||
"additionalNotices": [
|
||||
{
|
||||
"file": "LICENSES/Apache-2.0.txt",
|
||||
"origin": "Apache-2.0 license text (model.xml notice)",
|
||||
"sha256": "cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,320 @@
|
||||
{
|
||||
"schema": 1,
|
||||
"id": "microduck-legs",
|
||||
"name": "Microduck",
|
||||
"family": "microduck",
|
||||
"adapter": "microduck",
|
||||
"model": "../../robot/mjlab/robot_allcollisions.xml",
|
||||
"assets": [],
|
||||
"base": {
|
||||
"type": "floating",
|
||||
"root_body": "trunk_base",
|
||||
"freejoint": "trunk_base_freejoint",
|
||||
"spawn": {
|
||||
"pos": [
|
||||
-0.6000000000000001,
|
||||
0,
|
||||
0.12
|
||||
],
|
||||
"yaw": 0
|
||||
}
|
||||
},
|
||||
"sim": {
|
||||
"timestep": 0.005,
|
||||
"decimation": 4
|
||||
},
|
||||
"joints": {
|
||||
"groups": {
|
||||
"policy": [
|
||||
"left_hip_yaw",
|
||||
"left_hip_roll",
|
||||
"left_hip_pitch",
|
||||
"left_knee",
|
||||
"left_ankle",
|
||||
"neck_pitch",
|
||||
"head_pitch",
|
||||
"head_yaw",
|
||||
"head_roll",
|
||||
"right_hip_yaw",
|
||||
"right_hip_roll",
|
||||
"right_hip_pitch",
|
||||
"right_knee",
|
||||
"right_ankle"
|
||||
]
|
||||
},
|
||||
"defaults": {
|
||||
"left_hip_yaw": 0,
|
||||
"left_hip_roll": -0.0872664600610733,
|
||||
"left_hip_pitch": -0.4579240083694458,
|
||||
"left_knee": -0.004939999897032976,
|
||||
"left_ankle": 0.4529840052127838,
|
||||
"neck_pitch": 0.3490658402442932,
|
||||
"head_pitch": 0.3490658402442932,
|
||||
"head_yaw": 0,
|
||||
"head_roll": 0,
|
||||
"right_hip_yaw": 0,
|
||||
"right_hip_roll": 0.0872664600610733,
|
||||
"right_hip_pitch": 0.4579240083694458,
|
||||
"right_knee": 0.004939999897032976,
|
||||
"right_ankle": -0.4529840052127838
|
||||
}
|
||||
},
|
||||
"observations": {
|
||||
"obs": {
|
||||
"terms": [
|
||||
{
|
||||
"type": "gyro",
|
||||
"sensor": "imu_ang_vel"
|
||||
},
|
||||
{
|
||||
"type": "projected_gravity",
|
||||
"body": "trunk_base"
|
||||
},
|
||||
{
|
||||
"type": "joint_pos_rel",
|
||||
"group": "policy"
|
||||
},
|
||||
{
|
||||
"type": "joint_vel",
|
||||
"group": "policy"
|
||||
},
|
||||
{
|
||||
"type": "last_action",
|
||||
"group": "policy"
|
||||
},
|
||||
{
|
||||
"type": "command",
|
||||
"size": 13
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "joint_position",
|
||||
"group": "policy",
|
||||
"scale": 1,
|
||||
"offset": "default"
|
||||
}
|
||||
],
|
||||
"actuation": {
|
||||
"type": "native_position"
|
||||
},
|
||||
"commands": {
|
||||
"size": 13,
|
||||
"limits": [
|
||||
0.25,
|
||||
-0.2,
|
||||
1
|
||||
]
|
||||
},
|
||||
"skills": [
|
||||
{
|
||||
"id": "walk",
|
||||
"kind": "primary",
|
||||
"owns": "policy",
|
||||
"controller": {
|
||||
"type": "onnx",
|
||||
"policy": "../../policies/BEST_alpha_walking.onnx"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "sitstand",
|
||||
"kind": "episodic",
|
||||
"owns": "policy",
|
||||
"controller": {
|
||||
"type": "onnx",
|
||||
"policy": "../../policies/BEST_alpha_sitstand.onnx"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "roll",
|
||||
"kind": "episodic",
|
||||
"owns": "policy",
|
||||
"controller": {
|
||||
"type": "onnx",
|
||||
"policy": "../../policies/roulade.onnx"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "kickL",
|
||||
"kind": "episodic",
|
||||
"owns": "policy",
|
||||
"controller": {
|
||||
"type": "onnx",
|
||||
"policy": "../../policies/ball_kick_left.onnx"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "kickR",
|
||||
"kind": "episodic",
|
||||
"owns": "policy",
|
||||
"controller": {
|
||||
"type": "onnx",
|
||||
"policy": "../../policies/ball_kick_right.onnx"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "groundpick",
|
||||
"kind": "episodic",
|
||||
"owns": "policy",
|
||||
"controller": {
|
||||
"type": "onnx",
|
||||
"policy": "../../policies/alpha_ground_pick.onnx"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "stand",
|
||||
"kind": "recovery",
|
||||
"owns": "policy",
|
||||
"controller": {
|
||||
"type": "onnx",
|
||||
"policy": "../../policies/BEST_alpha_stand.onnx"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "drive",
|
||||
"kind": "primary",
|
||||
"owns": "policy",
|
||||
"controller": {
|
||||
"type": "onnx",
|
||||
"policy": "../../policies/BEST_roller.onnx"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "crouch",
|
||||
"kind": "episodic",
|
||||
"owns": "policy",
|
||||
"controller": {
|
||||
"type": "onnx",
|
||||
"policy": "../../policies/BEST_roller_crouch.onnx"
|
||||
}
|
||||
}
|
||||
],
|
||||
"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": "kickL",
|
||||
"codes": [
|
||||
"KeyQ"
|
||||
],
|
||||
"label": "Left kick"
|
||||
},
|
||||
{
|
||||
"action": "kickR",
|
||||
"codes": [
|
||||
"KeyE"
|
||||
],
|
||||
"label": "Right kick"
|
||||
},
|
||||
{
|
||||
"action": "alternateKick",
|
||||
"codes": [
|
||||
"KeyF"
|
||||
],
|
||||
"label": "Alternate kick"
|
||||
},
|
||||
{
|
||||
"action": "sitToggle",
|
||||
"codes": [
|
||||
"KeyR"
|
||||
],
|
||||
"label": "Sit / stand · roller crouch"
|
||||
},
|
||||
{
|
||||
"action": "groundPick",
|
||||
"codes": [
|
||||
"KeyG"
|
||||
],
|
||||
"label": "Ground pick"
|
||||
},
|
||||
{
|
||||
"action": "locoToggle",
|
||||
"codes": [
|
||||
"KeyM"
|
||||
],
|
||||
"label": "Feet / rollers"
|
||||
},
|
||||
{
|
||||
"action": "chaseToggle",
|
||||
"codes": [
|
||||
"KeyC"
|
||||
],
|
||||
"label": "Restore chase camera"
|
||||
},
|
||||
{
|
||||
"action": "roll",
|
||||
"codes": ["KeyT"],
|
||||
"label": "Forward roll / roller crouch"
|
||||
},
|
||||
{
|
||||
"action": "reset",
|
||||
"codes": [
|
||||
"Space"
|
||||
],
|
||||
"label": "Reset"
|
||||
},
|
||||
{
|
||||
"action": "pause",
|
||||
"codes": [
|
||||
"Escape"
|
||||
],
|
||||
"label": "Pause / continue"
|
||||
}
|
||||
]
|
||||
},
|
||||
"render": {
|
||||
"source": "glb",
|
||||
"camera": {
|
||||
"distance": 0.8
|
||||
}
|
||||
},
|
||||
"presentation": {
|
||||
"theme": "comic"
|
||||
},
|
||||
"termination": {
|
||||
"tilt_z": -0.5,
|
||||
"min_height": 0.02,
|
||||
"on_fall": "recovery"
|
||||
},
|
||||
"legacy": {
|
||||
"loco": "legs",
|
||||
"crouch_period": 5,
|
||||
"crouch_end": 0.7,
|
||||
"groundpick_period": 4,
|
||||
"groundpick_end": 0.7
|
||||
},
|
||||
"license": "Apache-2.0; retain existing policy and asset notices"
|
||||
}
|
||||
@@ -0,0 +1,320 @@
|
||||
{
|
||||
"schema": 1,
|
||||
"id": "microduck-rollers",
|
||||
"name": "Microduck",
|
||||
"family": "microduck",
|
||||
"adapter": "microduck",
|
||||
"model": "../../robot/mjlab/robot_allcollisions_rollers.xml",
|
||||
"assets": [],
|
||||
"base": {
|
||||
"type": "floating",
|
||||
"root_body": "trunk_base",
|
||||
"freejoint": "trunk_base_freejoint",
|
||||
"spawn": {
|
||||
"pos": [
|
||||
-0.6000000000000001,
|
||||
0,
|
||||
0.12
|
||||
],
|
||||
"yaw": 0
|
||||
}
|
||||
},
|
||||
"sim": {
|
||||
"timestep": 0.005,
|
||||
"decimation": 4
|
||||
},
|
||||
"joints": {
|
||||
"groups": {
|
||||
"policy": [
|
||||
"left_hip_yaw",
|
||||
"left_hip_roll",
|
||||
"left_hip_pitch",
|
||||
"left_knee",
|
||||
"left_ankle",
|
||||
"neck_pitch",
|
||||
"head_pitch",
|
||||
"head_yaw",
|
||||
"head_roll",
|
||||
"right_hip_yaw",
|
||||
"right_hip_roll",
|
||||
"right_hip_pitch",
|
||||
"right_knee",
|
||||
"right_ankle"
|
||||
]
|
||||
},
|
||||
"defaults": {
|
||||
"left_hip_yaw": 0,
|
||||
"left_hip_roll": -0.0872664600610733,
|
||||
"left_hip_pitch": -0.4579240083694458,
|
||||
"left_knee": -0.004939999897032976,
|
||||
"left_ankle": 0.4529840052127838,
|
||||
"neck_pitch": 0.3490658402442932,
|
||||
"head_pitch": 0.3490658402442932,
|
||||
"head_yaw": 0,
|
||||
"head_roll": 0,
|
||||
"right_hip_yaw": 0,
|
||||
"right_hip_roll": 0.0872664600610733,
|
||||
"right_hip_pitch": 0.4579240083694458,
|
||||
"right_knee": 0.004939999897032976,
|
||||
"right_ankle": -0.4529840052127838
|
||||
}
|
||||
},
|
||||
"observations": {
|
||||
"obs": {
|
||||
"terms": [
|
||||
{
|
||||
"type": "gyro",
|
||||
"sensor": "imu_ang_vel"
|
||||
},
|
||||
{
|
||||
"type": "projected_gravity",
|
||||
"body": "trunk_base"
|
||||
},
|
||||
{
|
||||
"type": "joint_pos_rel",
|
||||
"group": "policy"
|
||||
},
|
||||
{
|
||||
"type": "joint_vel",
|
||||
"group": "policy"
|
||||
},
|
||||
{
|
||||
"type": "last_action",
|
||||
"group": "policy"
|
||||
},
|
||||
{
|
||||
"type": "command",
|
||||
"size": 13
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "joint_position",
|
||||
"group": "policy",
|
||||
"scale": 1,
|
||||
"offset": "default"
|
||||
}
|
||||
],
|
||||
"actuation": {
|
||||
"type": "native_position"
|
||||
},
|
||||
"commands": {
|
||||
"size": 13,
|
||||
"limits": [
|
||||
0.6,
|
||||
-0.5,
|
||||
0.3
|
||||
]
|
||||
},
|
||||
"skills": [
|
||||
{
|
||||
"id": "walk",
|
||||
"kind": "primary",
|
||||
"owns": "policy",
|
||||
"controller": {
|
||||
"type": "onnx",
|
||||
"policy": "../../policies/BEST_alpha_walking.onnx"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "sitstand",
|
||||
"kind": "episodic",
|
||||
"owns": "policy",
|
||||
"controller": {
|
||||
"type": "onnx",
|
||||
"policy": "../../policies/BEST_alpha_sitstand.onnx"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "roll",
|
||||
"kind": "episodic",
|
||||
"owns": "policy",
|
||||
"controller": {
|
||||
"type": "onnx",
|
||||
"policy": "../../policies/roulade.onnx"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "kickL",
|
||||
"kind": "episodic",
|
||||
"owns": "policy",
|
||||
"controller": {
|
||||
"type": "onnx",
|
||||
"policy": "../../policies/ball_kick_left.onnx"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "kickR",
|
||||
"kind": "episodic",
|
||||
"owns": "policy",
|
||||
"controller": {
|
||||
"type": "onnx",
|
||||
"policy": "../../policies/ball_kick_right.onnx"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "groundpick",
|
||||
"kind": "episodic",
|
||||
"owns": "policy",
|
||||
"controller": {
|
||||
"type": "onnx",
|
||||
"policy": "../../policies/alpha_ground_pick.onnx"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "stand",
|
||||
"kind": "recovery",
|
||||
"owns": "policy",
|
||||
"controller": {
|
||||
"type": "onnx",
|
||||
"policy": "../../policies/BEST_alpha_stand.onnx"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "drive",
|
||||
"kind": "primary",
|
||||
"owns": "policy",
|
||||
"controller": {
|
||||
"type": "onnx",
|
||||
"policy": "../../policies/BEST_roller.onnx"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "crouch",
|
||||
"kind": "episodic",
|
||||
"owns": "policy",
|
||||
"controller": {
|
||||
"type": "onnx",
|
||||
"policy": "../../policies/BEST_roller_crouch.onnx"
|
||||
}
|
||||
}
|
||||
],
|
||||
"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": "kickL",
|
||||
"codes": [
|
||||
"KeyQ"
|
||||
],
|
||||
"label": "Left kick"
|
||||
},
|
||||
{
|
||||
"action": "kickR",
|
||||
"codes": [
|
||||
"KeyE"
|
||||
],
|
||||
"label": "Right kick"
|
||||
},
|
||||
{
|
||||
"action": "alternateKick",
|
||||
"codes": [
|
||||
"KeyF"
|
||||
],
|
||||
"label": "Alternate kick"
|
||||
},
|
||||
{
|
||||
"action": "sitToggle",
|
||||
"codes": [
|
||||
"KeyR"
|
||||
],
|
||||
"label": "Sit / stand · roller crouch"
|
||||
},
|
||||
{
|
||||
"action": "groundPick",
|
||||
"codes": [
|
||||
"KeyG"
|
||||
],
|
||||
"label": "Ground pick"
|
||||
},
|
||||
{
|
||||
"action": "locoToggle",
|
||||
"codes": [
|
||||
"KeyM"
|
||||
],
|
||||
"label": "Feet / rollers"
|
||||
},
|
||||
{
|
||||
"action": "chaseToggle",
|
||||
"codes": [
|
||||
"KeyC"
|
||||
],
|
||||
"label": "Restore chase camera"
|
||||
},
|
||||
{
|
||||
"action": "roll",
|
||||
"codes": ["KeyT"],
|
||||
"label": "Forward roll / roller crouch"
|
||||
},
|
||||
{
|
||||
"action": "reset",
|
||||
"codes": [
|
||||
"Space"
|
||||
],
|
||||
"label": "Reset"
|
||||
},
|
||||
{
|
||||
"action": "pause",
|
||||
"codes": [
|
||||
"Escape"
|
||||
],
|
||||
"label": "Pause / continue"
|
||||
}
|
||||
]
|
||||
},
|
||||
"render": {
|
||||
"source": "glb",
|
||||
"camera": {
|
||||
"distance": 0.8
|
||||
}
|
||||
},
|
||||
"presentation": {
|
||||
"theme": "comic"
|
||||
},
|
||||
"termination": {
|
||||
"tilt_z": -0.5,
|
||||
"min_height": 0.02,
|
||||
"on_fall": "recovery"
|
||||
},
|
||||
"legacy": {
|
||||
"loco": "rollers",
|
||||
"crouch_period": 5,
|
||||
"crouch_end": 0.7,
|
||||
"groundpick_period": 4,
|
||||
"groundpick_end": 0.7
|
||||
},
|
||||
"license": "Apache-2.0; retain existing policy and asset notices"
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"schema": 1,
|
||||
"id": "arena",
|
||||
"type": "flat",
|
||||
"presentation": "arena-grid",
|
||||
"boundary": {
|
||||
"half_extent": 2.25,
|
||||
"wall_height": 0.25,
|
||||
"wall_thickness": 0.05
|
||||
},
|
||||
"floor": {
|
||||
"rgba": [0.22, 0.27, 0.33, 1],
|
||||
"friction": [1, 0.005, 0.0001]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"schema": 1,
|
||||
"id": "flat",
|
||||
"type": "flat",
|
||||
"presentation": "arena-grid",
|
||||
"floor": {
|
||||
"rgba": [
|
||||
0.22,
|
||||
0.27,
|
||||
0.33,
|
||||
1
|
||||
],
|
||||
"friction": [
|
||||
1,
|
||||
0.005,
|
||||
0.0001
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Explicit, offline asset import; never needed to run the browser app.
|
||||
Usage: python3 app/scripts/import-microban.py /path/to/microban
|
||||
"""
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
source = Path(sys.argv[1]).resolve()
|
||||
target = Path(__file__).resolve().parents[1] / 'public/robots/microban'
|
||||
target.mkdir(parents=True, exist_ok=True)
|
||||
xml = source / 'src/model/mjcf/robot.xml'
|
||||
files = [('src/model/mjcf/robot.xml', 'model.xml'), ('src/agents/walk.onnx', 'policies/walk.onnx'), ('LICENSE', 'LICENSES/SOURCE-LICENSE.txt')]
|
||||
for mesh in ET.parse(xml).getroot().findall('./asset/mesh'):
|
||||
name = mesh.attrib['file']
|
||||
files.append((f'src/model/mjcf/assets/{name}', f'assets/{name}'))
|
||||
records = []
|
||||
for src, dst in files:
|
||||
data = (source / src).read_bytes()
|
||||
dest = target / dst
|
||||
dest.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copyfile(source / src, dest)
|
||||
records.append({'source': src, 'file': dst, 'sha256': hashlib.sha256(data).hexdigest(), 'bytes': len(data)})
|
||||
# Control sources are not copied into the product, but their working-tree
|
||||
# hashes pin the behavior used to build the adapter/reference fixtures.
|
||||
refs = ['src/constants.py', 'src/moves/walk.py', 'src/moves/rotate_head.py', 'src/observer.py', 'src/imu_reader.py', 'src/sim/mujoco_controller.py', 'src/sim/sim_main.py']
|
||||
manifest = {'head': subprocess.check_output(['git', '-C', str(source), 'rev-parse', 'HEAD'], text=True).strip(), 'dirty': bool(subprocess.check_output(['git', '-C', str(source), 'status', '--porcelain'], text=True)), 'files': records, 'behaviorReferences': [{'file': name, 'sha256': hashlib.sha256((source / name).read_bytes()).hexdigest()} for name in refs]}
|
||||
# Do not guess a remote URL: preserve the actual configured source instead.
|
||||
manifest['source'] = subprocess.check_output(['git', '-C', str(source), 'remote', 'get-url', 'origin'], text=True).strip()
|
||||
apache = Path(__file__).resolve().parents[2] / 'LICENSE'
|
||||
notice = target / 'LICENSES/Apache-2.0.txt'
|
||||
shutil.copyfile(apache, notice)
|
||||
manifest['additionalNotices'] = [{'file': 'LICENSES/Apache-2.0.txt', 'origin': 'Apache-2.0 license text (model.xml notice)', 'sha256': hashlib.sha256(apache.read_bytes()).hexdigest()}]
|
||||
(target / 'source-manifest.json').write_text(json.dumps(manifest, indent=2) + '\n')
|
||||
print(f'Copied {len(records)} files ({sum(r["bytes"] for r in records)} bytes) to {target}')
|
||||
@@ -0,0 +1,57 @@
|
||||
import { readFile, access } from "node:fs/promises";
|
||||
import { resolve, dirname } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { createHash } from "node:crypto";
|
||||
import {
|
||||
validatePackage,
|
||||
validateWorld,
|
||||
} from "../src/platform/loader/SchemaValidator.js";
|
||||
import { resolveWorldId } from "../src/platform/worlds/arena.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) {
|
||||
const file = resolve(root, entry.manifest),
|
||||
config = validatePackage(JSON.parse(await readFile(file, "utf8")));
|
||||
if (config.id !== entry.id || config.family !== entry.family)
|
||||
throw new Error(`Index identity mismatch ${entry.id}`);
|
||||
const paths = [
|
||||
config.model,
|
||||
...config.assets.map((a) => a.path),
|
||||
...config.skills
|
||||
.filter((s) => s.controller.type === "onnx")
|
||||
.map((s) => s.controller.policy),
|
||||
];
|
||||
for (const path of paths) await access(resolve(dirname(file), path));
|
||||
validateWorld(
|
||||
JSON.parse(
|
||||
await readFile(
|
||||
resolve(root, `../worlds/${resolveWorldId(config)}/world.json`),
|
||||
"utf8",
|
||||
),
|
||||
),
|
||||
);
|
||||
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)
|
||||
for (const record of [
|
||||
...provenance.files,
|
||||
...(provenance.additionalNotices ?? []),
|
||||
]) {
|
||||
const hash = createHash("sha256")
|
||||
.update(await readFile(resolve(dirname(file), record.file)))
|
||||
.digest("hex");
|
||||
if (hash !== record.sha256)
|
||||
throw new Error(
|
||||
`${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`,
|
||||
);
|
||||
}
|
||||
+37
-72
@@ -1,89 +1,54 @@
|
||||
// App shell: layers in z order - scene canvas (1), halftone (2), CRT (5),
|
||||
// HUD + touch overlay (9-12), BIOS readout (20), title menu (30). Also owns
|
||||
// the pre-game device detection (gamepad, touch) and the title -> enter
|
||||
// flow. The title menu carries its own loading gate (single central
|
||||
// spinner), so no separate preboot veil.
|
||||
// A single simulation surface: loading, errors and pause are inline states,
|
||||
// never separate title/pause/BIOS screens.
|
||||
import { useEffect } from "react";
|
||||
import GameCanvas from "./scene/GameCanvas.jsx";
|
||||
import { Halftone, CrtOverlay } from "./ui/Overlays.jsx";
|
||||
import Hud from "./ui/Hud.jsx";
|
||||
import TouchOverlay from "./ui/TouchOverlay.jsx";
|
||||
import BiosOverlay from "./ui/BiosOverlay.jsx";
|
||||
import TitleMenu from "./ui/TitleMenu.jsx";
|
||||
import { useGame } from "./store.js";
|
||||
import SimulationToolbar from "./ui/SimulationToolbar.jsx";
|
||||
import ControlsHelp from "./ui/ControlsHelp.jsx";
|
||||
import RuntimeStatus from "./ui/RuntimeStatus.jsx";
|
||||
import { useGame, gameApi } from "./store.js";
|
||||
|
||||
export default function App() {
|
||||
const comic = useGame((s) => s.presentationTheme === "comic");
|
||||
useEffect(() => {
|
||||
const params = new URLSearchParams(location.search);
|
||||
|
||||
// Gamepad presence for the tutorial variant, before the game controller
|
||||
// takes over polling (the game loop keeps mirroring it afterwards).
|
||||
const pollPad = () => {
|
||||
const gp = [...(navigator.getGamepads?.() ?? [])].find((p) => p && p.connected);
|
||||
useGame.setState({ padConnected: !!gp });
|
||||
};
|
||||
window.addEventListener("gamepadconnected", pollPad);
|
||||
window.addEventListener("gamepaddisconnected", pollPad);
|
||||
pollPad();
|
||||
|
||||
// Touch detection, latching: (pointer: coarse) OR any real touch proves
|
||||
// the device (DevTools device modes and hybrid laptops often fail the
|
||||
// media query). __microduckTouched hands the proof to controls/touch.js
|
||||
// which boots later. ?touch=1 forces the thumbs on any device.
|
||||
const coarse = matchMedia("(pointer: coarse)");
|
||||
const armTouch = () => {
|
||||
window.__microduckTouched = true;
|
||||
useGame.setState({ touchMode: true });
|
||||
};
|
||||
const onCoarse = () => coarse.matches && armTouch();
|
||||
if (coarse.matches) armTouch();
|
||||
else coarse.addEventListener("change", onCoarse);
|
||||
window.addEventListener("touchstart", armTouch, { once: true, passive: true });
|
||||
if (params.get("touch") === "1") armTouch();
|
||||
|
||||
// ?move=<ref>: request a community move (Academy D7). ref is an
|
||||
// "org/repo" Hub move, "session:<id>[:<round>]" (a private Academy run,
|
||||
// served same-origin) or a direct .onnx URL. ?policy= is the legacy
|
||||
// alias, and ?session=<id>[&round=<r>] is sugar for move=session:<id>:<r>.
|
||||
// Only the request is recorded here; the game loads it after boot
|
||||
// (never blocking it) and flips the status to active/error itself.
|
||||
let moveRef = params.get("move") || params.get("policy");
|
||||
if (!moveRef && params.get("session")) {
|
||||
const round = params.get("round");
|
||||
moveRef = `session:${params.get("session")}${round ? `:${round}` : ""}`;
|
||||
}
|
||||
if (moveRef) {
|
||||
useGame.setState({
|
||||
customPolicy: { ref: moveRef, name: moveRef, status: "loading" },
|
||||
});
|
||||
}
|
||||
|
||||
// The title menu opens right away and holds its own loading gate
|
||||
// (central spinner) until logo, fonts, duck stage and game boot are
|
||||
// in. ?boot=1 skips the title entirely - testing hook.
|
||||
if (params.get("boot") === "1") {
|
||||
useGame.setState({ prebootDone: true, entered: true, menuOpen: false });
|
||||
} else {
|
||||
useGame.setState({ prebootDone: true, menuOpen: true });
|
||||
}
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("gamepadconnected", pollPad);
|
||||
window.removeEventListener("gamepaddisconnected", pollPad);
|
||||
coarse.removeEventListener("change", onCoarse);
|
||||
window.removeEventListener("touchstart", armTouch);
|
||||
let ref = params.get("move") || params.get("policy");
|
||||
if (!ref && params.get("session"))
|
||||
ref = `session:${params.get("session")}${params.get("round") ? `:${params.get("round")}` : ""}`;
|
||||
if (ref)
|
||||
useGame.setState({ customPolicy: { ref, name: ref, status: "loading" } });
|
||||
const onKey = (event) => {
|
||||
if (
|
||||
event.code !== "Escape" ||
|
||||
event.repeat ||
|
||||
event.target?.closest?.(
|
||||
'input,textarea,select,[contenteditable="true"]',
|
||||
)
|
||||
)
|
||||
return;
|
||||
event.preventDefault();
|
||||
if (useGame.getState().runtimePhase === "ready") {
|
||||
if (useGame.getState().paused) gameApi.resume?.();
|
||||
else gameApi.pause?.();
|
||||
}
|
||||
};
|
||||
window.addEventListener("keydown", onKey);
|
||||
return () => window.removeEventListener("keydown", onKey);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<GameCanvas />
|
||||
<Halftone />
|
||||
<CrtOverlay />
|
||||
{comic && (
|
||||
<>
|
||||
<Halftone />
|
||||
<CrtOverlay />
|
||||
</>
|
||||
)}
|
||||
<Hud />
|
||||
<TouchOverlay />
|
||||
<BiosOverlay />
|
||||
<TitleMenu />
|
||||
<SimulationToolbar />
|
||||
<ControlsHelp />
|
||||
<RuntimeStatus />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
+2
-301
@@ -1,301 +1,2 @@
|
||||
// Arena visuals: the infinite Tron grid floor and the four wall grid
|
||||
// planes, ported verbatim from the pre-React rl.js. Both carry a uReveal
|
||||
// uniform for the entrance draw-in (driven by ceremony.js).
|
||||
import * as THREE from "three";
|
||||
import {
|
||||
ARENA_HALF, ARENA_WALL_H, ARENA_WALL_T, GRID_SECTION, RELIEF_BUMPS,
|
||||
} from "./constants.js";
|
||||
|
||||
// Infinite shader grid, ported from drei's <Grid>: anti-aliased world-space
|
||||
// lines at cell/section frequencies with a radial fade around the duck.
|
||||
// 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() {
|
||||
const material = new THREE.ShaderMaterial({
|
||||
transparent: true,
|
||||
depthWrite: false,
|
||||
uniforms: {
|
||||
uCell: { value: 0.1 },
|
||||
uSection: { value: GRID_SECTION },
|
||||
uCellColor: { value: new THREE.Color(0x8e8371) },
|
||||
uSectionColor: { value: new THREE.Color(0xffb366) },
|
||||
uFadeDist: { value: 3.0 },
|
||||
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
|
||||
// the BIOS readout until playBios cues startEntrance.
|
||||
uReveal: { value: 0.0 },
|
||||
// Relief: 0 = flat, 1 = bumps at full height. Driven by the game's
|
||||
// relief toggle, mirroring the MuJoCo heightfield's z-size so the
|
||||
// visual surface and the physics surface are the same function.
|
||||
uTopoScale: { value: 0.0 },
|
||||
// (cx, cz, height, radius) per bump, in three.js world coords
|
||||
// (MJCF y -> -z done here once).
|
||||
uBumps: {
|
||||
value: RELIEF_BUMPS.map(
|
||||
([cx, cy, h, r]) => new THREE.Vector4(cx, -cy, h, r),
|
||||
),
|
||||
},
|
||||
},
|
||||
vertexShader: /* glsl */ `
|
||||
#define NBUMPS ${RELIEF_BUMPS.length}
|
||||
varying vec3 vWorld;
|
||||
uniform float uTopoScale;
|
||||
uniform vec4 uBumps[NBUMPS];
|
||||
// Same analytic relief as the physics heightfield (game.js topoH):
|
||||
// a sum of cosine bumps, displacing the grid surface itself so the
|
||||
// floor genuinely deforms - lines flow up the slopes for free since
|
||||
// the fragment shader draws them from world xz.
|
||||
float topoH(vec2 p) {
|
||||
float H = 0.0;
|
||||
for (int i = 0; i < NBUMPS; i++) {
|
||||
float u = distance(p, uBumps[i].xy) / uBumps[i].w;
|
||||
if (u < 1.0) H += uBumps[i].z * (0.5 + 0.5 * cos(3.14159265 * u));
|
||||
}
|
||||
return H;
|
||||
}
|
||||
void main() {
|
||||
vec4 w = modelMatrix * vec4(position, 1.0);
|
||||
if (uTopoScale > 0.0) w.y += topoH(w.xz) * uTopoScale;
|
||||
vWorld = w.xyz;
|
||||
gl_Position = projectionMatrix * viewMatrix * w;
|
||||
}
|
||||
`,
|
||||
fragmentShader: /* glsl */ `
|
||||
varying vec3 vWorld;
|
||||
uniform float uCell, uSection, uFadeDist, uReveal;
|
||||
uniform vec3 uCellColor, uSectionColor, uFocus;
|
||||
// Tron-style line: a thicker antialiased core plus a faint, much
|
||||
// wider halo added on top (squared falloff keeps it a whisper of a
|
||||
// glow rather than a bloom wash).
|
||||
float lineProf(float g) {
|
||||
float core = 1.0 - smoothstep(0.0, 1.8, g);
|
||||
float halo = 1.0 - smoothstep(0.0, 7.0, g);
|
||||
return core + halo * halo * 0.22;
|
||||
}
|
||||
float gridLine(vec2 p, float size) {
|
||||
vec2 r = p / size;
|
||||
vec2 g = abs(fract(r - 0.5) - 0.5) / fwidth(r);
|
||||
return lineProf(min(g.x, g.y));
|
||||
}
|
||||
// Entrance draw-in: one family of parallel lines, drawn line by line.
|
||||
// id picks the line, "along" runs down its length. Each line waits
|
||||
// out its own hashed delay, then extends from the origin outward with
|
||||
// a hard front. Returns (mask, head): head marks the bright segment
|
||||
// right behind the draw front while the line is still growing.
|
||||
vec2 drawLine(float id, float along, float t0, float spread, float dur, float maxLen) {
|
||||
float jit = fract(sin(id * 127.1) * 43758.5453);
|
||||
float grow = clamp((uReveal - t0 - jit * spread) / dur, 0.0, 1.0);
|
||||
float len = grow * maxLen;
|
||||
float a = abs(along);
|
||||
float mask = 1.0 - smoothstep(len - 0.05, len, a);
|
||||
float head = (1.0 - smoothstep(0.0, 0.6, len - a)) * mask
|
||||
* step(0.001, grow) * (1.0 - step(0.999, grow));
|
||||
return vec2(mask, head);
|
||||
}
|
||||
void main() {
|
||||
float cell = gridLine(vWorld.xz, uCell);
|
||||
// Section lattice shifted half a cell: with 5 sections across the
|
||||
// 3 m arena (odd count) this centers a CELL on the origin and puts
|
||||
// section lines exactly on the walls at +-1.5.
|
||||
vec2 pSec = vWorld.xz + 0.5 * uSection;
|
||||
float section = gridLine(pSec, uSection);
|
||||
float d = distance(vWorld.xz, uFocus.xz);
|
||||
float fade = pow(clamp(1.0 - d / uFadeDist, 0.0, 1.0), 1.6);
|
||||
vec3 col = mix(uCellColor, uSectionColor, clamp(section, 0.0, 1.0));
|
||||
float alpha = min(max(section * 0.6, cell * 0.4) * fade, 1.0);
|
||||
// Entrance: only the bright section lines get the line-by-line draw
|
||||
// (staggered, with a hot draw head); the fine cells just fade in
|
||||
// over the reveal's second half - drawing every small line reads as
|
||||
// visual noise. lineProf(min(gx, gy)) == max of per-axis profiles
|
||||
// (profile is monotonic) and the cell fade lands on exactly the
|
||||
// steady-state cell term, so at uReveal 1 this branch equals the
|
||||
// formula above exactly (and is skipped).
|
||||
if (uReveal < 1.0) {
|
||||
vec2 rs = pSec / uSection;
|
||||
vec2 gs = abs(fract(rs - 0.5) - 0.5) / fwidth(rs);
|
||||
// Const-x lines run along z and vice versa; the offset
|
||||
// decorrelates the two families' hashed delays.
|
||||
vec2 sx = drawLine(floor(rs.x + 0.5), vWorld.z, 0.00, 0.30, 0.35, 8.0);
|
||||
vec2 sz = drawLine(floor(rs.y + 0.5) + 57.0, vWorld.x, 0.05, 0.30, 0.35, 8.0);
|
||||
float secR = max(lineProf(gs.x) * sx.x, lineProf(gs.y) * sz.x);
|
||||
float cellR = cell * smoothstep(0.5, 1.0, uReveal);
|
||||
float headGlow = max(lineProf(gs.x) * sx.y, lineProf(gs.y) * sz.y);
|
||||
col = mix(uCellColor, uSectionColor, clamp(secR, 0.0, 1.0));
|
||||
alpha = min(max(secR * 0.6, cellR * 0.4) * fade, 1.0);
|
||||
// Bright draw head: a short white-hot tip sells the "drawing" read.
|
||||
headGlow = clamp(headGlow, 0.0, 1.0);
|
||||
col = mix(col, vec3(1.0, 0.86, 0.55), headGlow * 0.8);
|
||||
alpha = min(alpha + headGlow * fade * 0.5, 1.0);
|
||||
}
|
||||
if (alpha < 0.004) discard;
|
||||
gl_FragColor = vec4(col, alpha);
|
||||
}
|
||||
`,
|
||||
});
|
||||
// Subdivided so the relief displacement has vertices to push: ~12 cm
|
||||
// steps, plenty for the gentle bump radii (>= 0.5 m). The displacement
|
||||
// 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, 256, 256), material);
|
||||
mesh.rotation.x = -Math.PI / 2;
|
||||
return mesh;
|
||||
}
|
||||
|
||||
// Arena walls, drawn in the same grid language as the floor: identical
|
||||
// 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) {
|
||||
return new THREE.ShaderMaterial({
|
||||
transparent: true,
|
||||
depthWrite: false,
|
||||
side: THREE.DoubleSide,
|
||||
uniforms: {
|
||||
uCell: { value: 0.1 },
|
||||
uSection: { value: GRID_SECTION },
|
||||
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 },
|
||||
uFocus: { value: new THREE.Vector3() },
|
||||
uWallH: { value: ARENA_WALL_H },
|
||||
uAlongX: { value: alongX ? 1.0 : 0.0 },
|
||||
// Entrance draw-in progress; 1 = steady state (branch skipped).
|
||||
// Starts at 0, same as the floor grid: hidden until startEntrance.
|
||||
uReveal: { value: 0.0 },
|
||||
},
|
||||
vertexShader: /* glsl */ `
|
||||
varying vec3 vWorld;
|
||||
void main() {
|
||||
vec4 w = modelMatrix * vec4(position, 1.0);
|
||||
vWorld = w.xyz;
|
||||
gl_Position = projectionMatrix * viewMatrix * w;
|
||||
}
|
||||
`,
|
||||
fragmentShader: /* glsl */ `
|
||||
varying vec3 vWorld;
|
||||
uniform float uCell, uSection, uFadeDist, uWallH, uAlongX, uReveal;
|
||||
uniform vec3 uCellColor, uSectionColor, uFocus;
|
||||
// Same Tron-style core + faint halo as the floor grid.
|
||||
float lineProf(float g) {
|
||||
float core = 1.0 - smoothstep(0.0, 1.8, g);
|
||||
float halo = 1.0 - smoothstep(0.0, 7.0, g);
|
||||
return core + halo * halo * 0.22;
|
||||
}
|
||||
float gridLine(vec2 p, float size) {
|
||||
vec2 r = p / size;
|
||||
vec2 g = abs(fract(r - 0.5) - 0.5) / fwidth(r);
|
||||
return lineProf(min(g.x, g.y));
|
||||
}
|
||||
// Same line-by-line draw as the floor grid (see its comments).
|
||||
vec2 drawLine(float id, float along, float t0, float spread, float dur, float maxLen) {
|
||||
float jit = fract(sin(id * 127.1) * 43758.5453);
|
||||
float grow = clamp((uReveal - t0 - jit * spread) / dur, 0.0, 1.0);
|
||||
float len = grow * maxLen;
|
||||
float a = abs(along);
|
||||
float mask = 1.0 - smoothstep(len - 0.05, len, a);
|
||||
float head = (1.0 - smoothstep(0.0, 0.35, len - a)) * mask
|
||||
* step(0.001, grow) * (1.0 - step(0.999, grow));
|
||||
return vec2(mask, head);
|
||||
}
|
||||
void main() {
|
||||
// Wall surface coords: the in-plane horizontal world axis + height.
|
||||
float h = mix(vWorld.z, vWorld.x, uAlongX);
|
||||
vec2 p = vec2(h, vWorld.y);
|
||||
float cell = gridLine(p, uCell);
|
||||
// Horizontal axis shifted half a section to match the floor's odd
|
||||
// lattice (vertical section lines meet the floor's at the base);
|
||||
// the height axis keeps its base line at y = 0.
|
||||
vec2 pSec = vec2(p.x + 0.5 * uSection, p.y);
|
||||
float section = gridLine(pSec, uSection);
|
||||
float d = distance(vWorld.xz, uFocus.xz);
|
||||
float fade = pow(clamp(1.0 - d / uFadeDist, 0.0, 1.0), 1.6);
|
||||
float vert = 1.0 - clamp(vWorld.y / uWallH, 0.0, 1.0);
|
||||
vec3 col = mix(uCellColor, uSectionColor, clamp(section, 0.0, 1.0));
|
||||
float alpha = min(max(section * 0.9, cell * 0.6) * fade * (0.3 + 0.7 * vert), 1.0);
|
||||
// Entrance: section lines only - horizontals zip out from the
|
||||
// wall's center, verticals rise from the ground, each with a
|
||||
// hashed delay; the fine cells fade in over the reveal's second
|
||||
// half. Same steady-state equivalence argument as the floor grid.
|
||||
if (uReveal < 1.0) {
|
||||
vec2 rs = pSec / uSection;
|
||||
vec2 gs = abs(fract(rs - 0.5) - 0.5) / fwidth(rs);
|
||||
// Const-height lines run along h (grow from center outward);
|
||||
// const-h lines run along y (grow up from the ground).
|
||||
vec2 sh = drawLine(floor(rs.y + 0.5), p.x, 0.00, 0.30, 0.40, 2.0);
|
||||
vec2 sv = drawLine(floor(rs.x + 0.5) + 31.0, p.y, 0.30, 0.30, 0.30, uWallH);
|
||||
float secR = max(lineProf(gs.y) * sh.x, lineProf(gs.x) * sv.x);
|
||||
float cellR = cell * smoothstep(0.5, 1.0, uReveal);
|
||||
float headGlow = max(lineProf(gs.y) * sh.y, lineProf(gs.x) * sv.y);
|
||||
col = mix(uCellColor, uSectionColor, clamp(secR, 0.0, 1.0));
|
||||
alpha = min(max(secR * 0.9, cellR * 0.6) * fade * (0.3 + 0.7 * vert), 1.0);
|
||||
headGlow = clamp(headGlow, 0.0, 1.0);
|
||||
col = mix(col, vec3(1.0, 0.86, 0.55), headGlow * 0.8);
|
||||
alpha = min(alpha + headGlow * fade * 0.5, 1.0);
|
||||
}
|
||||
if (alpha < 0.004) discard;
|
||||
gl_FragColor = vec4(col, alpha);
|
||||
}
|
||||
`,
|
||||
});
|
||||
}
|
||||
|
||||
// Entrance draw-in cue schedule, for the ceremony's per-line audio blips.
|
||||
// Replicates the shaders' hashed stagger EXACTLY (same hash, same t0 /
|
||||
// spread constants, same line ids as drawLine's floor(rs + 0.5)), so each
|
||||
// blip lands the instant its line starts drawing. Times are normalized to
|
||||
// the respective reveal (0..1); the ceremony maps them to seconds with its
|
||||
// own grid/wall reveal durations. `u` is the line's jitter, reused by the
|
||||
// audio side for per-line pitch variation. The four walls share one id
|
||||
// space, so their lines draw (and blip) in unison - one cue each.
|
||||
const jitHash = (x) => {
|
||||
const s = Math.sin(x * 127.1) * 43758.5453;
|
||||
return s - Math.floor(s);
|
||||
};
|
||||
export function entranceLineCues() {
|
||||
const grid = [];
|
||||
const walls = [];
|
||||
// Floor: 6 section lines per axis (world x in {-1.5..1.5} step 0.6 maps
|
||||
// to ids -2..3); the z family is offset by 57 in the shader.
|
||||
for (let i = -2; i <= 3; i++) {
|
||||
const jx = jitHash(i);
|
||||
const jz = jitHash(i + 57);
|
||||
grid.push({ at: 0.00 + jx * 0.30, u: jx });
|
||||
grid.push({ at: 0.05 + jz * 0.30, u: jz });
|
||||
}
|
||||
// Walls: one horizontal section line (the y = 0 base, id 0) and 6
|
||||
// verticals (ids -2..3 offset by 31), per the 0.25 m wall height.
|
||||
walls.push({ at: 0.00 + jitHash(0) * 0.30, u: jitHash(0) });
|
||||
for (let i = -2; i <= 3; i++) {
|
||||
const j = jitHash(i + 31);
|
||||
walls.push({ at: 0.30 + j * 0.30, u: j });
|
||||
}
|
||||
return { grid, walls };
|
||||
}
|
||||
|
||||
// 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() {
|
||||
const wallMats = [];
|
||||
const wallMeshes = [];
|
||||
const wallLen = 2 * (ARENA_HALF + ARENA_WALL_T);
|
||||
const wallDefs = [
|
||||
{ x: ARENA_HALF, z: 0, rotY: -Math.PI / 2, alongX: false },
|
||||
{ x: -ARENA_HALF, z: 0, rotY: Math.PI / 2, alongX: false },
|
||||
{ x: 0, z: ARENA_HALF, rotY: Math.PI, alongX: true },
|
||||
{ x: 0, z: -ARENA_HALF, rotY: 0, alongX: true },
|
||||
];
|
||||
for (const w of wallDefs) {
|
||||
const mat = makeWallGridMaterial(w.alongX);
|
||||
wallMats.push(mat);
|
||||
const mesh = new THREE.Mesh(new THREE.PlaneGeometry(wallLen, ARENA_WALL_H), mat);
|
||||
mesh.position.set(w.x, ARENA_WALL_H / 2, w.z);
|
||||
mesh.rotation.y = w.rotY;
|
||||
wallMeshes.push(mesh);
|
||||
}
|
||||
return { wallMats, wallMeshes };
|
||||
}
|
||||
// Compatibility surface for Microduck effects; World rendering lives with arena.
|
||||
export * from './worlds/arena/render.js';
|
||||
|
||||
@@ -98,5 +98,6 @@ export function createBallActor({ THREE, scene, camera, renderer, fxModule, mesh
|
||||
sync,
|
||||
drive,
|
||||
get visual() { return visual; },
|
||||
dispose: () => fx.dispose(),
|
||||
};
|
||||
}
|
||||
|
||||
+19
-111
@@ -1,117 +1,25 @@
|
||||
// Shared sim constants, lifted verbatim from the pre-React rl.js.
|
||||
|
||||
export const POLICY_DIR = "./policies";
|
||||
export const POLICIES = {
|
||||
walk: `${POLICY_DIR}/BEST_alpha_walking.onnx`,
|
||||
sitstand: `${POLICY_DIR}/BEST_alpha_sitstand.onnx`,
|
||||
roll: `${POLICY_DIR}/roulade.onnx`,
|
||||
// Blind one-shot kicks (the operator aims the robot, no ball in obs):
|
||||
// the runtime swaps these in for a 0.5 s window, commands zeroed.
|
||||
kickL: `${POLICY_DIR}/ball_kick_left.onnx`,
|
||||
kickR: `${POLICY_DIR}/ball_kick_right.onnx`,
|
||||
// One-shot ground pick (runtime A button): peck the ground and stand
|
||||
// back up, phase-driven via [cos, sin, 0] in the command vel slots.
|
||||
groundpick: `${POLICY_DIR}/alpha_ground_pick.onnx`,
|
||||
// Get-up policy for the automatic fall recovery (runtime --fall-detect):
|
||||
// same 61D obs layout as the other alpha policies, commands all zeroed.
|
||||
stand: `${POLICY_DIR}/BEST_alpha_stand.onnx`,
|
||||
// Roller variant (lazy-loaded on first switch, never at boot):
|
||||
// drive = velocity-tracking skating, crouch = one-shot crouch-glide
|
||||
// driven by a phase encoding in the command slots (ground-pick style).
|
||||
drive: `${POLICY_DIR}/BEST_roller.onnx`,
|
||||
crouch: `${POLICY_DIR}/BEST_roller_crouch.onnx`,
|
||||
};
|
||||
|
||||
// From the ONNX metadata (identical for all alpha policies) and the STAND
|
||||
// keyframe in mjlab's scene_walk.xml. Order matches the actuators in
|
||||
// the MJCF.
|
||||
export const JOINT_NAMES = [
|
||||
"left_hip_yaw", "left_hip_roll", "left_hip_pitch", "left_knee", "left_ankle",
|
||||
"neck_pitch", "head_pitch", "head_yaw", "head_roll",
|
||||
"right_hip_yaw", "right_hip_roll", "right_hip_pitch", "right_knee", "right_ankle",
|
||||
];
|
||||
export const DEFAULT_POSE = new Float32Array([
|
||||
0, -0.08726646259971647, -0.457924, -0.004940, 0.452984,
|
||||
0.3490658503988659, 0.3490658503988659, 0, 0,
|
||||
0, 0.08726646259971647, 0.457924, 0.004940, -0.452984,
|
||||
]);
|
||||
export const NUM_JOINTS = 14;
|
||||
export const OBS_SIZE = 61;
|
||||
export const CMD_SIZE = 13;
|
||||
export const ACTION_SCALE = 1.0;
|
||||
export const TIMESTEP = 0.005;
|
||||
export const DECIMATION = 4;
|
||||
export const CTRL_DT = TIMESTEP * DECIMATION; // 50 Hz
|
||||
|
||||
// Velocity command limits, same as infer_policy.py's keyboard mapping.
|
||||
// No strafe input anymore: the lateral cmd slot stays zeroed for the obs.
|
||||
export const VEL_FWD = 0.25, VEL_BACK = -0.2, VEL_ANG = 1.0;
|
||||
// Roller mode limits, from the runtime's roller branch: asymmetric vx
|
||||
// (0.6 push / 0.5 brake), no lateral. The real runtime launches rollers
|
||||
// with --max-angular-vel 0.3: faster commanded turns tip the robot over,
|
||||
// so the playground clamps wz the same way.
|
||||
export const RVEL_FWD = 0.6, RVEL_BACK = -0.5, RVEL_ANG = 0.3;
|
||||
// Crouch-glide one-shot: command = [cos(2pi*phase), sin(2pi*phase), 0],
|
||||
// phase advancing at 1/CROUCH_PERIOD_S per second and the cycle exiting
|
||||
// at 0.7 - exactly the runtime's ground-pick slot the policy was trained
|
||||
// against (mjlab CROUCH_PERIOD = 5.0, cycle end 0.7 => 3.5 s gesture).
|
||||
export const CROUCH_PERIOD_S = 5.0;
|
||||
export const CROUCH_END_PHASE = 0.7;
|
||||
// Ground-pick one-shot (legs): same phase encoding, from the runtime's
|
||||
// defaults (--ground-pick-period 4.0, cycle exiting at 0.7 => ~2.8 s
|
||||
// gesture, action scale and kP untouched at their 1.0 defaults).
|
||||
export const GROUND_PICK_PERIOD_S = 4.0;
|
||||
export const GROUND_PICK_END_PHASE = 0.7;
|
||||
|
||||
// Kickable ball: radius and parking spot (far away = hidden by default).
|
||||
// Arena-only compatibility constants. Robot parameters live in robot.json.
|
||||
export const BALL_RADIUS = 0.05;
|
||||
export const BALL_PARK_POS = "50 0 0.05";
|
||||
|
||||
// Square arena boxing the play area: static walls at +-ARENA_HALF keep
|
||||
// the ball (and the duck) inside. Tall enough that neither steps over.
|
||||
export const ARENA_HALF = 1.5; // inner half-size, m
|
||||
export const BALL_PARK_POS = '50 0 0.05';
|
||||
export const ARENA_HALF = 1.5;
|
||||
export const ARENA_WALL_H = 0.25;
|
||||
export const ARENA_WALL_T = 0.05;
|
||||
// Section grid: 5 cells across the 3 m arena (ODD, so a true middle
|
||||
// column/row of cells exists; the lattice is shifted half a cell in the
|
||||
// shaders so the walls land exactly on section lines).
|
||||
export const GRID_SECTION = (2 * ARENA_HALF) / 5; // 0.6 m
|
||||
// Arcade cabinet row: three cabinets side by side against the front (+X)
|
||||
// wall, screens facing the arena. Consumed by the prop library (props.js
|
||||
// "arcade" def - currently benched, enabled: false) for both the clone
|
||||
// placements and the row's single static collision box. Proportions
|
||||
// measured from the GLB's natural size (0.524 x 0.587 x 1.0 m, w x d x h).
|
||||
// Slightly surreal scale: ~2.8x the 0.25 m duck (a real 1.73 m cabinet
|
||||
// felt overwhelming in the 3 m arena). Big enough to read as oversized
|
||||
// furniture, small enough that the row (~1.15 m wide, 0.41 m deep)
|
||||
// leaves the play area open.
|
||||
export const ARCADE_H = 0.7; // target height, m
|
||||
export const ARCADE_W = ARCADE_H * 0.524; // footprint width, ~0.22 m
|
||||
export const ARCADE_D = ARCADE_H * 0.5876; // footprint depth, ~0.247 m
|
||||
export const ARCADE_GAP = 0.02; // gap between neighbouring cabinets
|
||||
export const ARCADE_WALL_GAP = 0.01; // clearance between backs and the wall
|
||||
|
||||
// Relief (prototype): gentle cosine bumps baked into the level itself.
|
||||
// One shared analytic height function drives BOTH the physics (a MuJoCo
|
||||
// heightfield covering the arena) and the visuals (vertex displacement
|
||||
// of the grid floor shader), so the grid genuinely deforms instead of
|
||||
// boxes popping out of it. Entries are [cx, cy, height, radius] in MJCF
|
||||
// coords; slopes stay mild (max grade ~20%) so the blind walking policy
|
||||
// has a chance, and the spawn cell + arcade row stay flat.
|
||||
export const GRID_SECTION = (2 * ARENA_HALF) / 5;
|
||||
export const ARCADE_H = 0.7;
|
||||
export const ARCADE_W = ARCADE_H * 0.524;
|
||||
export const ARCADE_D = ARCADE_H * 0.5876;
|
||||
export const ARCADE_GAP = 0.02;
|
||||
export const ARCADE_WALL_GAP = 0.01;
|
||||
// Same analytic bumps drive the arena shader and physics heightfield.
|
||||
export const RELIEF_BUMPS = [
|
||||
[0.3, -0.9, 0.06, 0.55],
|
||||
[-0.9, 0.75, 0.05, 0.5],
|
||||
[0.6, 0.9, 0.07, 0.55],
|
||||
[0.3,-0.9,0.06,0.55],
|
||||
[-0.9,0.75,0.05,0.5],
|
||||
[0.6,0.9,0.07,0.55],
|
||||
];
|
||||
export const RELIEF_HMAX = 0.07; // tallest bump, scales the hfield z-size
|
||||
export const RELIEF_GRID = 65; // hfield rows/cols over the 3x3 m arena
|
||||
export const RELIEF_SINK = 0.003; // hfield geom buried below the floor
|
||||
export const RELIEF_RATE = 0.6; // raise/sink rate, scale units per second
|
||||
|
||||
// Spawn: center of the middle section cell in the SECOND ROW FROM THE
|
||||
// BACK wall. The duck faces +X (identity freejoint quat, walks toward
|
||||
// local +X), so "back" is the -X wall: row centers sit at x = -1.2,
|
||||
// -0.6, 0, 0.6, 1.2 -> second row is -0.6; middle column is y = 0.
|
||||
// MJCF coordinates (three.js: x -> x, y -> -z).
|
||||
export const SPAWN_X = -ARENA_HALF + 1.5 * GRID_SECTION; // -0.6
|
||||
export const RELIEF_HMAX = 0.07;
|
||||
export const RELIEF_GRID = 65;
|
||||
export const RELIEF_SINK = 0.003;
|
||||
export const RELIEF_RATE = 0.6;
|
||||
// Second row from the back; keep arithmetic unchanged for golden snapshots.
|
||||
export const SPAWN_X = -ARENA_HALF + 1.5 * GRID_SECTION;
|
||||
export const SPAWN_Y = 0;
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
// headToggle HEAD mode on/off (pad Y): sticks drive the head
|
||||
// sitToggle sit <-> stand (game gates it to legs mode)
|
||||
// locoToggle legs <-> rollers switch
|
||||
// chaseToggle chase camera on/off
|
||||
// chaseToggle restore rear chase camera (legacy action name)
|
||||
// reset full sim reset (Space)
|
||||
// walk back to the walk/run mode (pad DpadUp short press)
|
||||
// quack chirp + jaw flap (pad RT edge, Schmitt-triggered)
|
||||
|
||||
@@ -1,118 +1,3 @@
|
||||
// Keyboard input source (see controller.js for the source interface
|
||||
// contract). Hold-to-command movement keys plus one-shot action keys.
|
||||
//
|
||||
// e.code is the PHYSICAL key position, so one map covers QWERTY and AZERTY:
|
||||
// arrows / WASD (ZQSD) run + turn. No strafe - vy stays 0.
|
||||
|
||||
const KEYMAP = {
|
||||
ArrowUp: "fwd", KeyW: "fwd",
|
||||
ArrowDown: "back", KeyS: "back",
|
||||
ArrowLeft: "turnl", KeyA: "turnl",
|
||||
ArrowRight: "turnr", KeyD: "turnr",
|
||||
};
|
||||
|
||||
// One-shot keys -> controller actions. Physical Q/E (A/E on AZERTY) are the
|
||||
// explicit left / right kicks, mirroring the pad's LB / RB; F alternates.
|
||||
// R sits (crouch-glide in roller mode - the game decides, same way the
|
||||
// roll action used to). Nothing dispatches "roll" any more.
|
||||
const ACTION_KEYS = {
|
||||
KeyC: "chaseToggle",
|
||||
KeyG: "groundPick",
|
||||
KeyM: "locoToggle",
|
||||
KeyR: "sitToggle",
|
||||
KeyQ: "kickL",
|
||||
KeyE: "kickR",
|
||||
KeyF: "alternateKick",
|
||||
};
|
||||
|
||||
export class KeyboardSource {
|
||||
id = "keyboard";
|
||||
connected = true; // a keyboard is always assumed present
|
||||
command = new Float32Array(3); // [vx, 0, wz], scaled to velocity limits
|
||||
axes = { jaw: 0, orbitX: 0, orbitY: 0 }; // keyboard drives none of these
|
||||
pressed = { fwd: false, back: false, turnl: false, turnr: false };
|
||||
onAction = () => {}; // assigned by the Controller at registration
|
||||
|
||||
#held = new Set();
|
||||
#getVelocityLimits;
|
||||
// Limits snapshot so poll() only re-maps held keys when they actually
|
||||
// change (the legs <-> rollers switch); event handlers do the live work.
|
||||
#lims = [NaN, NaN, NaN];
|
||||
#onKeyDown = null;
|
||||
#onKeyUp = null;
|
||||
#onBlur = null;
|
||||
|
||||
constructor({ getVelocityLimits }) {
|
||||
this.#getVelocityLimits = getVelocityLimits;
|
||||
}
|
||||
|
||||
init() {
|
||||
this.#onKeyDown = (e) => {
|
||||
if (e.repeat) return;
|
||||
// Space always resets, and must not scroll the page.
|
||||
if (e.code === "Space") {
|
||||
e.preventDefault();
|
||||
this.onAction("reset");
|
||||
return;
|
||||
}
|
||||
const action = ACTION_KEYS[e.code];
|
||||
if (action) {
|
||||
this.onAction(action);
|
||||
return;
|
||||
}
|
||||
const move = KEYMAP[e.code];
|
||||
if (!move) return;
|
||||
e.preventDefault();
|
||||
this.#held.add(move);
|
||||
this.#refresh();
|
||||
};
|
||||
this.#onKeyUp = (e) => {
|
||||
const move = KEYMAP[e.code];
|
||||
if (!move) return;
|
||||
this.#held.delete(move);
|
||||
this.#refresh();
|
||||
};
|
||||
// Losing window focus drops every held key (keyup events are missed).
|
||||
this.#onBlur = () => {
|
||||
this.#held.clear();
|
||||
this.#refresh();
|
||||
};
|
||||
window.addEventListener("keydown", this.#onKeyDown);
|
||||
window.addEventListener("keyup", this.#onKeyUp);
|
||||
window.addEventListener("blur", this.#onBlur);
|
||||
}
|
||||
|
||||
dispose() {
|
||||
window.removeEventListener("keydown", this.#onKeyDown);
|
||||
window.removeEventListener("keyup", this.#onKeyUp);
|
||||
window.removeEventListener("blur", this.#onBlur);
|
||||
}
|
||||
|
||||
// Claims twist authority while any movement key is held.
|
||||
isActive() {
|
||||
return this.#held.size > 0;
|
||||
}
|
||||
|
||||
// The command is event-driven (recomputed on keydown/keyup/blur, so a
|
||||
// press lands the same tick, not on the next frame); poll only re-maps
|
||||
// held keys onto fresh velocity limits after a locomotion switch.
|
||||
poll() {
|
||||
const [limF, limB, limA] = this.#getVelocityLimits();
|
||||
if (limF !== this.#lims[0] || limB !== this.#lims[1] || limA !== this.#lims[2]) {
|
||||
this.#refresh();
|
||||
}
|
||||
}
|
||||
|
||||
#refresh() {
|
||||
const lims = this.#getVelocityLimits();
|
||||
const [limF, limB, limA] = lims;
|
||||
this.#lims = lims;
|
||||
const held = this.#held;
|
||||
this.command[0] = held.has("fwd") ? limF : held.has("back") ? limB : 0;
|
||||
this.command[2] = held.has("turnl") ? limA : held.has("turnr") ? -limA : 0;
|
||||
this.pressed.fwd = held.has("fwd");
|
||||
this.pressed.back = held.has("back");
|
||||
this.pressed.turnl = held.has("turnl");
|
||||
this.pressed.turnr = held.has("turnr");
|
||||
}
|
||||
}
|
||||
// Compatibility name for the old Microduck controller. Bindings and hints
|
||||
// now share the Robot Package and the generic keyboard router.
|
||||
export { InputRouter as KeyboardSource, isEditingTarget } from '../../platform/input/InputRouter.js';
|
||||
|
||||
@@ -42,6 +42,7 @@ export class WaypointSource {
|
||||
#getVelocityLimits;
|
||||
#getDuckPose; // () => [x, y, yaw] MJCF ground pose
|
||||
#isSuppressed; // () => true while a click must not arm (grabbing, locked, wrong mode)
|
||||
#getArenaHalf;
|
||||
#getManualOverride; // () => true while another source is actively driving
|
||||
#target = null; // [x, y] MJCF, or null when idle
|
||||
#active = false;
|
||||
@@ -52,13 +53,14 @@ export class WaypointSource {
|
||||
#onDown = null;
|
||||
#onUp = null;
|
||||
|
||||
constructor({ camera, renderer, getVelocityLimits, getDuckPose, isSuppressed, getManualOverride }) {
|
||||
constructor({ camera, renderer, getVelocityLimits, getDuckPose, isSuppressed, getManualOverride, getArenaHalf=()=>ARENA_HALF }) {
|
||||
this.#camera = camera;
|
||||
this.#renderer = renderer;
|
||||
this.#getVelocityLimits = getVelocityLimits;
|
||||
this.#getDuckPose = getDuckPose;
|
||||
this.#isSuppressed = isSuppressed;
|
||||
this.#getManualOverride = getManualOverride;
|
||||
this.#getArenaHalf = getArenaHalf;
|
||||
}
|
||||
|
||||
init() {
|
||||
@@ -144,7 +146,7 @@ export class WaypointSource {
|
||||
);
|
||||
this.#raycaster.setFromCamera(this.#ndc, this.#camera);
|
||||
if (!this.#raycaster.ray.intersectPlane(FLOOR_PLANE, this.#hit)) return;
|
||||
const lim = ARENA_HALF - 0.05;
|
||||
const lim = this.#getArenaHalf() - 0.05;
|
||||
this.#target = [
|
||||
Math.min(lim, Math.max(-lim, this.#hit.x)),
|
||||
Math.min(lim, Math.max(-lim, -this.#hit.z)), // three -> MJCF
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
// manifestIncompatibility are reusable by standalone pages without pulling
|
||||
// the game bundle in.
|
||||
|
||||
import { OBS_SIZE, NUM_JOINTS, CMD_SIZE } from "./constants.js";
|
||||
// Dimensions are supplied by the active Robot Package, never global constants.
|
||||
|
||||
const HUB_BASE = "https://huggingface.co";
|
||||
// Same-origin Academy endpoints (backend/play_api.py) for private moves.
|
||||
@@ -39,7 +39,7 @@ export function slotForManifest(manifest) {
|
||||
// Manifest claims the sim cannot satisfy (schema 2). Only present-and-wrong
|
||||
// claims reject: an absent field is trusted to match the microduck defaults.
|
||||
// Returns a human-readable reason, or null when the manifest is acceptable.
|
||||
export function manifestIncompatibility(manifest) {
|
||||
export function manifestIncompatibility(manifest, {obsSize:OBS_SIZE,actionSize:NUM_JOINTS}={}) {
|
||||
if (!manifest || typeof manifest !== "object") return null;
|
||||
if (Array.isArray(manifest.policies)) {
|
||||
return "multi-policy set: not loadable in v1 (pick a single-policy repo)";
|
||||
@@ -187,7 +187,8 @@ async function fetchOptionalManifest(url) {
|
||||
|
||||
// Command script (kind "script"): {duration_s, loop, keyframes:[{t, cmd[13]}]}.
|
||||
// Keyframes are sorted by t and every cmd is padded/truncated to CMD_SIZE.
|
||||
export function normalizeMoveScript(raw) {
|
||||
export function normalizeMoveScript(raw, CMD_SIZE) {
|
||||
if(!Number.isInteger(CMD_SIZE)||CMD_SIZE<1)throw new Error('Robot command size required');
|
||||
if (!raw || typeof raw !== "object" || !Array.isArray(raw.keyframes) || !raw.keyframes.length) {
|
||||
throw new Error("move_script.json has no keyframes");
|
||||
}
|
||||
@@ -221,7 +222,7 @@ export function scriptCommandAt(script, t, out) {
|
||||
const a = keyframes[i], b = keyframes[i + 1];
|
||||
if (tt >= a.t && tt <= b.t) {
|
||||
const u = (tt - a.t) / Math.max(b.t - a.t, 1e-6);
|
||||
for (let c = 0; c < CMD_SIZE; c++) out[c] = (1 - u) * a.cmd[c] + u * b.cmd[c];
|
||||
for (let c = 0; c < out.length; c++) out[c] = (1 - u) * a.cmd[c] + u * b.cmd[c];
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -232,7 +233,7 @@ export function scriptCommandAt(script, t, out) {
|
||||
// Publish-pipeline smoke run: 1 input / 1 output, a zeros pass plus two
|
||||
// small-noise passes; every output must be [1,14], finite, and the noisy
|
||||
// passes must not produce identical actions (a constant net is a dud).
|
||||
async function validateSession(ort, session) {
|
||||
async function validateSession(ort, session, {obsSize:OBS_SIZE,actionSize:NUM_JOINTS}) {
|
||||
const { inputNames, outputNames } = session;
|
||||
if (inputNames.length !== 1 || outputNames.length !== 1) {
|
||||
throw new Error(
|
||||
@@ -279,7 +280,8 @@ async function fetchOrThrow(url, what) {
|
||||
//
|
||||
// Result: { kind, slot, name, title, author, academy, ref, actionScale,
|
||||
// durationS, session?, inputName?, outputName?, script? }
|
||||
export async function loadCustomPolicy(ref, { ort, onProgress = () => {} } = {}) {
|
||||
export async function loadCustomPolicy(ref, { ort, dimensions, onProgress = () => {} } = {}) {
|
||||
if(!dimensions||!['obsSize','actionSize','commandSize'].every(k=>Number.isInteger(dimensions[k])&&dimensions[k]>0))throw new Error('Active Robot Package dimensions required');
|
||||
const resolved = resolvePolicyRef(ref);
|
||||
let name = resolved.name;
|
||||
let author = resolved.author;
|
||||
@@ -303,7 +305,7 @@ export async function loadCustomPolicy(ref, { ort, onProgress = () => {} } = {})
|
||||
}
|
||||
}
|
||||
if (manifest) {
|
||||
const reason = manifestIncompatibility(manifest);
|
||||
const reason = manifestIncompatibility(manifest,dimensions);
|
||||
if (reason) throw new Error(reason);
|
||||
if (typeof manifest.name === "string" && manifest.name) name = manifest.name;
|
||||
if (Number.isFinite(manifest.action_scale)) actionScale = manifest.action_scale;
|
||||
@@ -331,7 +333,7 @@ export async function loadCustomPolicy(ref, { ort, onProgress = () => {} } = {})
|
||||
} catch {
|
||||
throw new Error("move_script.json is not valid JSON");
|
||||
}
|
||||
const script = normalizeMoveScript(raw);
|
||||
const script = normalizeMoveScript(raw,dimensions.commandSize);
|
||||
return { ...base, script, durationS: script.durationS };
|
||||
}
|
||||
|
||||
@@ -348,7 +350,8 @@ export async function loadCustomPolicy(ref, { ort, onProgress = () => {} } = {})
|
||||
}
|
||||
|
||||
onProgress("validate");
|
||||
await validateSession(ort, session);
|
||||
try { await validateSession(ort, session, dimensions); }
|
||||
catch(error){await session.release();throw error;}
|
||||
|
||||
const claimed = Number(manifest?.duration_s ?? manifest?.episode_s ?? manifest?.episode?.duration_s);
|
||||
const durationS = slot === "trick"
|
||||
|
||||
+14
-2
@@ -80,7 +80,7 @@ export function loadGlbGeometries() {
|
||||
if (o.name && o.name !== name) map.set(o.name, entry);
|
||||
});
|
||||
return map;
|
||||
});
|
||||
}).catch(error=>{glbGeomsPromise=null;throw error;});
|
||||
}
|
||||
return glbGeomsPromise;
|
||||
}
|
||||
@@ -277,7 +277,19 @@ export async function buildRig(k, opts = {}) {
|
||||
}
|
||||
await Promise.all(pending);
|
||||
|
||||
const rig = { placer, root, bodies, joints };
|
||||
placer.userData.robotRig = true;
|
||||
const rig = { placer, root, bodies, joints,
|
||||
dispose: async () => {
|
||||
for (const material of matCache.values()) material.dispose();
|
||||
inkMat?.dispose();
|
||||
for (const geometry of edgeCache.values()) geometry.dispose();
|
||||
for (const promise of extraStlCache.values()) {
|
||||
const entry=await promise.catch(()=>null);
|
||||
entry?.display.dispose(); entry?.welded.dispose();
|
||||
}
|
||||
placer.removeFromParent();
|
||||
},
|
||||
};
|
||||
setupJawPivot(rig);
|
||||
return rig;
|
||||
}
|
||||
|
||||
+3
-2311
File diff suppressed because it is too large
Load Diff
@@ -316,6 +316,14 @@ function driveFades() {
|
||||
fadeRaf = fades.size ? requestAnimationFrame(driveFades) : 0;
|
||||
}
|
||||
|
||||
export function disposeVariantFades(rig) {
|
||||
rig.root.traverse(mesh => {
|
||||
const fade=fades.get(mesh);
|
||||
if(fade){ fades.delete(mesh); fade.mat.dispose(); }
|
||||
});
|
||||
if(!fades.size&&fadeRaf){cancelAnimationFrame(fadeRaf);fadeRaf=0;}
|
||||
}
|
||||
|
||||
export function applyVariant(rig, variant) {
|
||||
const v = typeof variant === "string" ? VARIANTS[variant] : variant;
|
||||
const map = meshMaterialsFor(v);
|
||||
@@ -332,6 +340,7 @@ export function applyVariant(rig, variant) {
|
||||
// Already resting on the target material and not mid-fade: no-op.
|
||||
if (o.material === target && !fades.has(o)) return;
|
||||
const from = o.material;
|
||||
fades.get(o)?.mat.dispose();
|
||||
const m = target.clone();
|
||||
m.color.copy(from.color);
|
||||
m.roughness = from.roughness;
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
import { propColliders } from "../../props.js";
|
||||
import { arenaWalls } from "../../../platform/worlds/arena.js";
|
||||
import {
|
||||
ARENA_HALF,
|
||||
BALL_PARK_POS,
|
||||
BALL_RADIUS,
|
||||
RELIEF_GRID,
|
||||
RELIEF_HMAX,
|
||||
RELIEF_SINK,
|
||||
} from "../../constants.js";
|
||||
// World contribution only. The adapter has already selected/stripped its
|
||||
// Robot MJCF. Preserve insertion order for existing Microduck keyframes.
|
||||
export function composeArenaPhysics(
|
||||
doc,
|
||||
{
|
||||
timestep,
|
||||
jointNames,
|
||||
defaultPose,
|
||||
spawn,
|
||||
boundary = {
|
||||
half_extent: ARENA_HALF,
|
||||
wall_height: 0.25,
|
||||
wall_thickness: 0.05,
|
||||
},
|
||||
},
|
||||
) {
|
||||
const root = doc.documentElement;
|
||||
const el = (tag, attrs) => {
|
||||
const e = doc.createElement(tag);
|
||||
for (const [k, v] of Object.entries(attrs)) e.setAttribute(k, v);
|
||||
return e;
|
||||
};
|
||||
root.appendChild(el("option", { timestep: String(timestep) }));
|
||||
const body = doc.querySelector("worldbody");
|
||||
body.appendChild(
|
||||
el("geom", {
|
||||
name: "floor",
|
||||
type: "plane",
|
||||
size: "0 0 0.05",
|
||||
pos: "0 0 0",
|
||||
}),
|
||||
);
|
||||
for (const wall of arenaWalls(boundary))
|
||||
body.appendChild(
|
||||
el("geom", {
|
||||
name: wall.name,
|
||||
type: "box",
|
||||
pos: wall.pos.join(" "),
|
||||
size: wall.size.join(" "),
|
||||
}),
|
||||
);
|
||||
for (const c of propColliders()) {
|
||||
const attrs = { name: c.name, type: "box", pos: c.pos, size: c.size };
|
||||
if (c.euler) attrs.euler = c.euler;
|
||||
body.appendChild(el("geom", attrs));
|
||||
}
|
||||
const ball = el("body", { name: "ball", pos: BALL_PARK_POS });
|
||||
ball.appendChild(el("freejoint", { name: "ball_freejoint" }));
|
||||
ball.appendChild(
|
||||
el("geom", {
|
||||
name: "ball_geom",
|
||||
type: "sphere",
|
||||
size: String(BALL_RADIUS),
|
||||
mass: "0.03",
|
||||
friction: "0.4 0.01 0.003",
|
||||
solref: "0.03 0.4",
|
||||
condim: "6",
|
||||
}),
|
||||
);
|
||||
body.appendChild(ball);
|
||||
doc.querySelector("asset").appendChild(
|
||||
el("hfield", {
|
||||
name: "terrain",
|
||||
nrow: String(RELIEF_GRID),
|
||||
ncol: String(RELIEF_GRID),
|
||||
size: `${boundary.half_extent} ${boundary.half_extent} ${RELIEF_HMAX} 0.1`,
|
||||
}),
|
||||
);
|
||||
body.appendChild(
|
||||
el("geom", {
|
||||
name: "terrain",
|
||||
type: "hfield",
|
||||
hfield: "terrain",
|
||||
pos: `0 0 ${-RELIEF_SINK}`,
|
||||
}),
|
||||
);
|
||||
const poseByName = new Map(jointNames.map((n, i) => [n, defaultPose[i]]));
|
||||
const qposJoints = [...doc.querySelectorAll("body > joint")]
|
||||
.map((j) => poseByName.get(j.getAttribute("name")) ?? 0)
|
||||
.join(" ");
|
||||
const qposFree = `${spawn.pos.join(" ")} ${Math.cos(spawn.yaw / 2)} 0 0 ${Math.sin(spawn.yaw / 2)}`;
|
||||
const keyframe = doc.createElement("keyframe");
|
||||
keyframe.appendChild(
|
||||
el("key", {
|
||||
name: "STAND",
|
||||
qpos: `${qposFree} ${qposJoints} ${BALL_PARK_POS} 1 0 0 0`,
|
||||
ctrl: Array.from(defaultPose).join(" "),
|
||||
}),
|
||||
);
|
||||
root.appendChild(keyframe);
|
||||
return {
|
||||
xml: new XMLSerializer().serializeToString(doc),
|
||||
meshFiles: [...doc.querySelectorAll("asset > mesh")].map((m) =>
|
||||
m.getAttribute("file"),
|
||||
),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import * as THREE from "three";
|
||||
import { makeInfiniteGrid, makeArenaWalls } from "./render.js";
|
||||
import { arenaWalls } from "../../../platform/worlds/arena.js";
|
||||
// Shared appearance; physical collision boxes come only from the World composer.
|
||||
export function createArenaFloorPresentation({ sim, rig, world }) {
|
||||
const names = [
|
||||
"platform_floor",
|
||||
...(world?.boundary ? arenaWalls(world.boundary).map((w) => w.name) : []),
|
||||
];
|
||||
const hidden = [];
|
||||
for (const name of names) {
|
||||
const id = sim.model.geom(name).id,
|
||||
mesh = rig.items.find((item) => item.id === id)?.mesh;
|
||||
if (mesh) hidden.push({ mesh, visible: mesh.visible });
|
||||
else if (name === "platform_floor")
|
||||
throw new Error(
|
||||
"arena-grid presentation requires a rendered flat World floor",
|
||||
);
|
||||
}
|
||||
const root = new THREE.Group();
|
||||
root.name = "arena-floor-presentation";
|
||||
const grid = makeInfiniteGrid({ subdivisions: 1 });
|
||||
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)
|
||||
: { wallMeshes: [], wallMats: [] };
|
||||
wallMeshes.forEach((mesh, i) => {
|
||||
mesh.name = `arena-boundary-${i}`;
|
||||
root.add(mesh);
|
||||
});
|
||||
wallMats.forEach((mat) => {
|
||||
mat.uniforms.uReveal.value = 1;
|
||||
});
|
||||
hidden.forEach(({ mesh }) => {
|
||||
mesh.visible = false;
|
||||
});
|
||||
let disposed = false;
|
||||
return {
|
||||
root,
|
||||
grid,
|
||||
walls: wallMeshes,
|
||||
update(position) {
|
||||
grid.position.set(position.x, 0, position.z);
|
||||
grid.material.uniforms.uFocus.value.copy(position);
|
||||
wallMats.forEach((mat) => mat.uniforms.uFocus.value.copy(position));
|
||||
},
|
||||
dispose() {
|
||||
if (disposed) return;
|
||||
disposed = true;
|
||||
root.removeFromParent();
|
||||
for (const mesh of [grid, ...wallMeshes]) {
|
||||
mesh.geometry.dispose();
|
||||
mesh.material.dispose();
|
||||
}
|
||||
hidden.forEach(({ mesh, visible }) => {
|
||||
mesh.visible = visible;
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
// Arena visuals: the infinite Tron grid floor and the four wall grid
|
||||
// planes, ported verbatim from the pre-React rl.js. Both carry a uReveal
|
||||
// uniform for the entrance draw-in (driven by ceremony.js).
|
||||
import * as THREE from "three";
|
||||
import {
|
||||
ARENA_HALF,
|
||||
ARENA_WALL_H,
|
||||
ARENA_WALL_T,
|
||||
GRID_SECTION,
|
||||
RELIEF_BUMPS,
|
||||
} from "../../constants.js";
|
||||
|
||||
// Infinite shader grid, ported from drei's <Grid>: anti-aliased world-space
|
||||
// lines at cell/section frequencies with a radial fade around the duck.
|
||||
// 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 } = {}) {
|
||||
const material = new THREE.ShaderMaterial({
|
||||
transparent: true,
|
||||
depthWrite: false,
|
||||
uniforms: {
|
||||
uCell: { value: 0.1 },
|
||||
uSection: { value: GRID_SECTION },
|
||||
uCellColor: { value: new THREE.Color(0x8e8371) },
|
||||
uSectionColor: { value: new THREE.Color(0xffb366) },
|
||||
uFadeDist: { value: 3.0 },
|
||||
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
|
||||
// the BIOS readout until playBios cues startEntrance.
|
||||
uReveal: { value: 0.0 },
|
||||
// Relief: 0 = flat, 1 = bumps at full height. Driven by the game's
|
||||
// relief toggle, mirroring the MuJoCo heightfield's z-size so the
|
||||
// visual surface and the physics surface are the same function.
|
||||
uTopoScale: { value: 0.0 },
|
||||
// (cx, cz, height, radius) per bump, in three.js world coords
|
||||
// (MJCF y -> -z done here once).
|
||||
uBumps: {
|
||||
value: RELIEF_BUMPS.map(
|
||||
([cx, cy, h, r]) => new THREE.Vector4(cx, -cy, h, r),
|
||||
),
|
||||
},
|
||||
},
|
||||
vertexShader: /* glsl */ `
|
||||
#define NBUMPS ${RELIEF_BUMPS.length}
|
||||
varying vec3 vWorld;
|
||||
uniform float uTopoScale;
|
||||
uniform vec4 uBumps[NBUMPS];
|
||||
// Same analytic relief as the physics heightfield (game.js topoH):
|
||||
// a sum of cosine bumps, displacing the grid surface itself so the
|
||||
// floor genuinely deforms - lines flow up the slopes for free since
|
||||
// the fragment shader draws them from world xz.
|
||||
float topoH(vec2 p) {
|
||||
float H = 0.0;
|
||||
for (int i = 0; i < NBUMPS; i++) {
|
||||
float u = distance(p, uBumps[i].xy) / uBumps[i].w;
|
||||
if (u < 1.0) H += uBumps[i].z * (0.5 + 0.5 * cos(3.14159265 * u));
|
||||
}
|
||||
return H;
|
||||
}
|
||||
void main() {
|
||||
vec4 w = modelMatrix * vec4(position, 1.0);
|
||||
if (uTopoScale > 0.0) w.y += topoH(w.xz) * uTopoScale;
|
||||
vWorld = w.xyz;
|
||||
gl_Position = projectionMatrix * viewMatrix * w;
|
||||
}
|
||||
`,
|
||||
fragmentShader: /* glsl */ `
|
||||
varying vec3 vWorld;
|
||||
uniform float uCell, uSection, uFadeDist, uReveal;
|
||||
uniform vec3 uCellColor, uSectionColor, uFocus;
|
||||
// Tron-style line: a thicker antialiased core plus a faint, much
|
||||
// wider halo added on top (squared falloff keeps it a whisper of a
|
||||
// glow rather than a bloom wash).
|
||||
float lineProf(float g) {
|
||||
float core = 1.0 - smoothstep(0.0, 1.8, g);
|
||||
float halo = 1.0 - smoothstep(0.0, 7.0, g);
|
||||
return core + halo * halo * 0.22;
|
||||
}
|
||||
float gridLine(vec2 p, float size) {
|
||||
vec2 r = p / size;
|
||||
vec2 g = abs(fract(r - 0.5) - 0.5) / fwidth(r);
|
||||
return lineProf(min(g.x, g.y));
|
||||
}
|
||||
// Entrance draw-in: one family of parallel lines, drawn line by line.
|
||||
// id picks the line, "along" runs down its length. Each line waits
|
||||
// out its own hashed delay, then extends from the origin outward with
|
||||
// a hard front. Returns (mask, head): head marks the bright segment
|
||||
// right behind the draw front while the line is still growing.
|
||||
vec2 drawLine(float id, float along, float t0, float spread, float dur, float maxLen) {
|
||||
float jit = fract(sin(id * 127.1) * 43758.5453);
|
||||
float grow = clamp((uReveal - t0 - jit * spread) / dur, 0.0, 1.0);
|
||||
float len = grow * maxLen;
|
||||
float a = abs(along);
|
||||
float mask = 1.0 - smoothstep(len - 0.05, len, a);
|
||||
float head = (1.0 - smoothstep(0.0, 0.6, len - a)) * mask
|
||||
* step(0.001, grow) * (1.0 - step(0.999, grow));
|
||||
return vec2(mask, head);
|
||||
}
|
||||
void main() {
|
||||
float cell = gridLine(vWorld.xz, uCell);
|
||||
// Section lattice shifted half a cell: with 5 sections across the
|
||||
// 3 m arena (odd count) this centers a CELL on the origin and puts
|
||||
// section lines exactly on the walls at +-1.5.
|
||||
vec2 pSec = vWorld.xz + 0.5 * uSection;
|
||||
float section = gridLine(pSec, uSection);
|
||||
float d = distance(vWorld.xz, uFocus.xz);
|
||||
float fade = pow(clamp(1.0 - d / uFadeDist, 0.0, 1.0), 1.6);
|
||||
vec3 col = mix(uCellColor, uSectionColor, clamp(section, 0.0, 1.0));
|
||||
float alpha = min(max(section * 0.6, cell * 0.4) * fade, 1.0);
|
||||
// Entrance: only the bright section lines get the line-by-line draw
|
||||
// (staggered, with a hot draw head); the fine cells just fade in
|
||||
// over the reveal's second half - drawing every small line reads as
|
||||
// visual noise. lineProf(min(gx, gy)) == max of per-axis profiles
|
||||
// (profile is monotonic) and the cell fade lands on exactly the
|
||||
// steady-state cell term, so at uReveal 1 this branch equals the
|
||||
// formula above exactly (and is skipped).
|
||||
if (uReveal < 1.0) {
|
||||
vec2 rs = pSec / uSection;
|
||||
vec2 gs = abs(fract(rs - 0.5) - 0.5) / fwidth(rs);
|
||||
// Const-x lines run along z and vice versa; the offset
|
||||
// decorrelates the two families' hashed delays.
|
||||
vec2 sx = drawLine(floor(rs.x + 0.5), vWorld.z, 0.00, 0.30, 0.35, 8.0);
|
||||
vec2 sz = drawLine(floor(rs.y + 0.5) + 57.0, vWorld.x, 0.05, 0.30, 0.35, 8.0);
|
||||
float secR = max(lineProf(gs.x) * sx.x, lineProf(gs.y) * sz.x);
|
||||
float cellR = cell * smoothstep(0.5, 1.0, uReveal);
|
||||
float headGlow = max(lineProf(gs.x) * sx.y, lineProf(gs.y) * sz.y);
|
||||
col = mix(uCellColor, uSectionColor, clamp(secR, 0.0, 1.0));
|
||||
alpha = min(max(secR * 0.6, cellR * 0.4) * fade, 1.0);
|
||||
// Bright draw head: a short white-hot tip sells the "drawing" read.
|
||||
headGlow = clamp(headGlow, 0.0, 1.0);
|
||||
col = mix(col, vec3(1.0, 0.86, 0.55), headGlow * 0.8);
|
||||
alpha = min(alpha + headGlow * fade * 0.5, 1.0);
|
||||
}
|
||||
if (alpha < 0.004) discard;
|
||||
gl_FragColor = vec4(col, alpha);
|
||||
}
|
||||
`,
|
||||
});
|
||||
// Subdivided so the relief displacement has vertices to push: ~12 cm
|
||||
// steps, plenty for the gentle bump radii (>= 0.5 m). The displacement
|
||||
// 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),
|
||||
material,
|
||||
);
|
||||
mesh.rotation.x = -Math.PI / 2;
|
||||
return mesh;
|
||||
}
|
||||
|
||||
// Arena walls, drawn in the same grid language as the floor: identical
|
||||
// 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) {
|
||||
return new THREE.ShaderMaterial({
|
||||
transparent: true,
|
||||
depthWrite: false,
|
||||
side: THREE.DoubleSide,
|
||||
uniforms: {
|
||||
uCell: { value: 0.1 },
|
||||
uSection: { value: GRID_SECTION },
|
||||
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 },
|
||||
uFocus: { value: new THREE.Vector3() },
|
||||
uWallH: { value: wallHeight },
|
||||
uAlongX: { value: alongX ? 1.0 : 0.0 },
|
||||
// Entrance draw-in progress; 1 = steady state (branch skipped).
|
||||
// Starts at 0, same as the floor grid: hidden until startEntrance.
|
||||
uReveal: { value: 0.0 },
|
||||
},
|
||||
vertexShader: /* glsl */ `
|
||||
varying vec3 vWorld;
|
||||
void main() {
|
||||
vec4 w = modelMatrix * vec4(position, 1.0);
|
||||
vWorld = w.xyz;
|
||||
gl_Position = projectionMatrix * viewMatrix * w;
|
||||
}
|
||||
`,
|
||||
fragmentShader: /* glsl */ `
|
||||
varying vec3 vWorld;
|
||||
uniform float uCell, uSection, uFadeDist, uWallH, uAlongX, uReveal;
|
||||
uniform vec3 uCellColor, uSectionColor, uFocus;
|
||||
// Same Tron-style core + faint halo as the floor grid.
|
||||
float lineProf(float g) {
|
||||
float core = 1.0 - smoothstep(0.0, 1.8, g);
|
||||
float halo = 1.0 - smoothstep(0.0, 7.0, g);
|
||||
return core + halo * halo * 0.22;
|
||||
}
|
||||
float gridLine(vec2 p, float size) {
|
||||
vec2 r = p / size;
|
||||
vec2 g = abs(fract(r - 0.5) - 0.5) / fwidth(r);
|
||||
return lineProf(min(g.x, g.y));
|
||||
}
|
||||
// Same line-by-line draw as the floor grid (see its comments).
|
||||
vec2 drawLine(float id, float along, float t0, float spread, float dur, float maxLen) {
|
||||
float jit = fract(sin(id * 127.1) * 43758.5453);
|
||||
float grow = clamp((uReveal - t0 - jit * spread) / dur, 0.0, 1.0);
|
||||
float len = grow * maxLen;
|
||||
float a = abs(along);
|
||||
float mask = 1.0 - smoothstep(len - 0.05, len, a);
|
||||
float head = (1.0 - smoothstep(0.0, 0.35, len - a)) * mask
|
||||
* step(0.001, grow) * (1.0 - step(0.999, grow));
|
||||
return vec2(mask, head);
|
||||
}
|
||||
void main() {
|
||||
// Wall surface coords: the in-plane horizontal world axis + height.
|
||||
float h = mix(vWorld.z, vWorld.x, uAlongX);
|
||||
vec2 p = vec2(h, vWorld.y);
|
||||
float cell = gridLine(p, uCell);
|
||||
// Horizontal axis shifted half a section to match the floor's odd
|
||||
// lattice (vertical section lines meet the floor's at the base);
|
||||
// the height axis keeps its base line at y = 0.
|
||||
vec2 pSec = vec2(p.x + 0.5 * uSection, p.y);
|
||||
float section = gridLine(pSec, uSection);
|
||||
float d = distance(vWorld.xz, uFocus.xz);
|
||||
float fade = pow(clamp(1.0 - d / uFadeDist, 0.0, 1.0), 1.6);
|
||||
float vert = 1.0 - clamp(vWorld.y / uWallH, 0.0, 1.0);
|
||||
vec3 col = mix(uCellColor, uSectionColor, clamp(section, 0.0, 1.0));
|
||||
float alpha = min(max(section * 0.9, cell * 0.6) * fade * (0.3 + 0.7 * vert), 1.0);
|
||||
// Entrance: section lines only - horizontals zip out from the
|
||||
// wall's center, verticals rise from the ground, each with a
|
||||
// hashed delay; the fine cells fade in over the reveal's second
|
||||
// half. Same steady-state equivalence argument as the floor grid.
|
||||
if (uReveal < 1.0) {
|
||||
vec2 rs = pSec / uSection;
|
||||
vec2 gs = abs(fract(rs - 0.5) - 0.5) / fwidth(rs);
|
||||
// Const-height lines run along h (grow from center outward);
|
||||
// const-h lines run along y (grow up from the ground).
|
||||
vec2 sh = drawLine(floor(rs.y + 0.5), p.x, 0.00, 0.30, 0.40, 2.0);
|
||||
vec2 sv = drawLine(floor(rs.x + 0.5) + 31.0, p.y, 0.30, 0.30, 0.30, uWallH);
|
||||
float secR = max(lineProf(gs.y) * sh.x, lineProf(gs.x) * sv.x);
|
||||
float cellR = cell * smoothstep(0.5, 1.0, uReveal);
|
||||
float headGlow = max(lineProf(gs.y) * sh.y, lineProf(gs.x) * sv.y);
|
||||
col = mix(uCellColor, uSectionColor, clamp(secR, 0.0, 1.0));
|
||||
alpha = min(max(secR * 0.9, cellR * 0.6) * fade * (0.3 + 0.7 * vert), 1.0);
|
||||
headGlow = clamp(headGlow, 0.0, 1.0);
|
||||
col = mix(col, vec3(1.0, 0.86, 0.55), headGlow * 0.8);
|
||||
alpha = min(alpha + headGlow * fade * 0.5, 1.0);
|
||||
}
|
||||
if (alpha < 0.004) discard;
|
||||
gl_FragColor = vec4(col, alpha);
|
||||
}
|
||||
`,
|
||||
});
|
||||
}
|
||||
|
||||
// Entrance draw-in cue schedule, for the ceremony's per-line audio blips.
|
||||
// Replicates the shaders' hashed stagger EXACTLY (same hash, same t0 /
|
||||
// spread constants, same line ids as drawLine's floor(rs + 0.5)), so each
|
||||
// blip lands the instant its line starts drawing. Times are normalized to
|
||||
// the respective reveal (0..1); the ceremony maps them to seconds with its
|
||||
// own grid/wall reveal durations. `u` is the line's jitter, reused by the
|
||||
// audio side for per-line pitch variation. The four walls share one id
|
||||
// space, so their lines draw (and blip) in unison - one cue each.
|
||||
const jitHash = (x) => {
|
||||
const s = Math.sin(x * 127.1) * 43758.5453;
|
||||
return s - Math.floor(s);
|
||||
};
|
||||
export function entranceLineCues() {
|
||||
const grid = [];
|
||||
const walls = [];
|
||||
// Floor: 6 section lines per axis (world x in {-1.5..1.5} step 0.6 maps
|
||||
// to ids -2..3); the z family is offset by 57 in the shader.
|
||||
for (let i = -2; i <= 3; i++) {
|
||||
const jx = jitHash(i);
|
||||
const jz = jitHash(i + 57);
|
||||
grid.push({ at: 0.0 + jx * 0.3, u: jx });
|
||||
grid.push({ at: 0.05 + jz * 0.3, u: jz });
|
||||
}
|
||||
// Walls: one horizontal section line (the y = 0 base, id 0) and 6
|
||||
// verticals (ids -2..3 offset by 31), per the 0.25 m wall height.
|
||||
walls.push({ at: 0.0 + jitHash(0) * 0.3, u: jitHash(0) });
|
||||
for (let i = -2; i <= 3; i++) {
|
||||
const j = jitHash(i + 31);
|
||||
walls.push({ at: 0.3 + j * 0.3, u: j });
|
||||
}
|
||||
return { grid, walls };
|
||||
}
|
||||
|
||||
// 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,
|
||||
} = {}) {
|
||||
const wallMats = [];
|
||||
const wallMeshes = [];
|
||||
const wallLen = 2 * (half_extent + wall_thickness);
|
||||
const wallDefs = [
|
||||
{ x: half_extent, z: 0, rotY: -Math.PI / 2, alongX: false },
|
||||
{ x: -half_extent, z: 0, rotY: Math.PI / 2, alongX: false },
|
||||
{ x: 0, z: half_extent, rotY: Math.PI, alongX: true },
|
||||
{ x: 0, z: -half_extent, rotY: 0, alongX: true },
|
||||
];
|
||||
for (const [index, w] of wallDefs.entries()) {
|
||||
const mat = makeWallGridMaterial(w.alongX, wall_height);
|
||||
wallMats.push(mat);
|
||||
const mesh = new THREE.Mesh(
|
||||
new THREE.PlaneGeometry(wallLen, wall_height),
|
||||
mat,
|
||||
);
|
||||
mesh.name = `arena-boundary-${index}`;
|
||||
mesh.position.set(w.x, wall_height / 2, w.z);
|
||||
mesh.rotation.y = w.rotY;
|
||||
wallMeshes.push(mesh);
|
||||
}
|
||||
return { wallMats, wallMeshes };
|
||||
}
|
||||
+5
-3
@@ -1,3 +1,4 @@
|
||||
import "@fontsource/anton/latin-400.css";
|
||||
import { lazy, Suspense } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import { ThemeProvider } from "@mui/material/styles";
|
||||
@@ -6,9 +7,10 @@ import { theme } from "./theme.js";
|
||||
|
||||
// ?soundboard=1: standalone audio A/B experiment page instead of the game
|
||||
// (lazy on both sides so the soundboard never pulls the game bundle in).
|
||||
const App = new URLSearchParams(location.search).get("soundboard") === "1"
|
||||
? lazy(() => import("./ui/Soundboard.jsx"))
|
||||
: lazy(() => import("./App.jsx"));
|
||||
const App =
|
||||
new URLSearchParams(location.search).get("soundboard") === "1"
|
||||
? lazy(() => import("./ui/Soundboard.jsx"))
|
||||
: lazy(() => import("./App.jsx"));
|
||||
|
||||
// Build tag: bump to change the bundle's content hash, e.g. to bust a stale
|
||||
// edge-cached asset URL on the HF Space.
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
export function isEditingTarget(target, code) {
|
||||
if (
|
||||
target?.closest?.(
|
||||
'input, textarea, select, [contenteditable]:not([contenteditable="false"])',
|
||||
)
|
||||
)
|
||||
return true;
|
||||
return (
|
||||
(code === "Space" || code === "Enter") && !!target?.closest?.("button")
|
||||
);
|
||||
}
|
||||
const moves = {
|
||||
move_forward: "fwd",
|
||||
move_backward: "back",
|
||||
turn_left: "turnl",
|
||||
turn_right: "turnr",
|
||||
};
|
||||
export class InputRouter {
|
||||
id = "keyboard";
|
||||
connected = true;
|
||||
command = new Float32Array(3);
|
||||
axes = { jaw: 0, orbitX: 0, orbitY: 0 };
|
||||
pressed = { fwd: false, back: false, turnl: false, turnr: false };
|
||||
onAction = () => {};
|
||||
#held = new Set();
|
||||
#handlers = [];
|
||||
#limits = [NaN, NaN, NaN];
|
||||
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])),
|
||||
);
|
||||
}
|
||||
init(target = window) {
|
||||
const listen = (type, cb) => {
|
||||
target.addEventListener(type, cb);
|
||||
this.#handlers.push(() => target.removeEventListener(type, cb));
|
||||
};
|
||||
listen("keydown", (e) => {
|
||||
if (e.repeat || isEditingTarget(e.target, e.code)) return;
|
||||
const action = this.byCode.get(e.code);
|
||||
if (!action || action === "pause" || !this.isEnabled(action)) return;
|
||||
e.preventDefault();
|
||||
if (moves[action]) {
|
||||
this.#held.add(e.code);
|
||||
this.#refresh();
|
||||
} else this.onAction(action);
|
||||
});
|
||||
listen("keyup", (e) => {
|
||||
this.#held.delete(e.code);
|
||||
this.#refresh();
|
||||
});
|
||||
listen("blur", () => this.clear());
|
||||
}
|
||||
poll() {
|
||||
const limits = this.getVelocityLimits();
|
||||
if (limits.some((v, i) => v !== this.#limits[i])) this.#refresh();
|
||||
}
|
||||
#refresh() {
|
||||
for (const key of Object.keys(this.pressed)) this.pressed[key] = false;
|
||||
for (const code of this.#held) {
|
||||
const name = moves[this.byCode.get(code)];
|
||||
if (name) this.pressed[name] = true;
|
||||
}
|
||||
const [fwd, back, ang] = this.getVelocityLimits(),
|
||||
p = this.pressed;
|
||||
this.#limits = [fwd, back, ang];
|
||||
this.command[0] = p.fwd ? fwd : p.back ? back : 0;
|
||||
this.command[1] = 0;
|
||||
this.command[2] = p.turnl ? ang : p.turnr ? -ang : 0;
|
||||
}
|
||||
isActive() {
|
||||
return this.#held.size > 0;
|
||||
}
|
||||
clear() {
|
||||
this.#held.clear();
|
||||
this.#refresh();
|
||||
}
|
||||
dispose() {
|
||||
for (const off of this.#handlers.splice(0)) off();
|
||||
this.clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import { validatePackage, validateWorld } from "./SchemaValidator.js";
|
||||
import { DEFAULT_WORLD } from "../worlds/arena.js";
|
||||
export function assetUrl(path, base, location = globalThis.location) {
|
||||
const url = new URL(path, base);
|
||||
if (location && url.origin !== location.origin)
|
||||
throw new Error(`External asset origin not allowed: ${url.origin}`);
|
||||
const sign = location
|
||||
? new URLSearchParams(location.search).get("__sign")
|
||||
: null;
|
||||
if (sign) url.searchParams.set("__sign", sign);
|
||||
return url.href;
|
||||
}
|
||||
export async function fetchChecked(url, kind = "text") {
|
||||
const response = await fetch(url);
|
||||
if (!response.ok)
|
||||
throw new Error(`${url.split("?")[0]}: HTTP ${response.status}`);
|
||||
return kind === "json"
|
||||
? response.json()
|
||||
: kind === "bytes"
|
||||
? response.arrayBuffer()
|
||||
: response.text();
|
||||
}
|
||||
export async function loadPackage(url) {
|
||||
const config = validatePackage(
|
||||
await fetchChecked(assetUrl(url, document.baseURI), "json"),
|
||||
);
|
||||
const base = new URL(".", new URL(url, document.baseURI)).href;
|
||||
return {
|
||||
config,
|
||||
base,
|
||||
url: assetUrl(url, document.baseURI),
|
||||
asset: (path) => assetUrl(path, base),
|
||||
};
|
||||
}
|
||||
export async function loadIndex() {
|
||||
const base = new URL(`${import.meta.env.BASE_URL}robots/`, location.origin)
|
||||
.href;
|
||||
const entries = await fetchChecked(assetUrl("index.json", base), "json");
|
||||
if (!Array.isArray(entries) || !entries.length)
|
||||
throw new Error("robots/index.json: nonempty list required");
|
||||
return entries.map((entry) => ({
|
||||
...entry,
|
||||
url: assetUrl(entry.manifest, base),
|
||||
}));
|
||||
}
|
||||
export async function loadWorld(id = DEFAULT_WORLD) {
|
||||
const base = new URL(
|
||||
`${import.meta.env.BASE_URL}worlds/${id}/`,
|
||||
location.origin,
|
||||
).href;
|
||||
const world = await fetchChecked(assetUrl("world.json", base), "json");
|
||||
validateWorld(world);
|
||||
if (world.id !== id)
|
||||
throw new Error(`worlds/${id}: unsupported World schema`);
|
||||
return world;
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
import Ajv from "ajv";
|
||||
import schema from "./robot.schema.json" with { type: "json" };
|
||||
import worldSchema from "./world.schema.json" with { type: "json" };
|
||||
const ajv = new Ajv({ allErrors: true, strict: true }),
|
||||
check = ajv.compile(schema),
|
||||
checkWorld = ajv.compile(worldSchema);
|
||||
function assertSchema(check, value, label) {
|
||||
if (!check(value))
|
||||
throw new Error(
|
||||
`${label}: ${check.errors.map((e) => `${e.instancePath || "/"} ${e.message}`).join("; ")}`,
|
||||
);
|
||||
}
|
||||
export function validateWorld(world) {
|
||||
assertSchema(checkWorld, world, "world.json");
|
||||
if (world.boundary && world.type !== "flat")
|
||||
throw new Error("world.json /boundary: requires a flat World");
|
||||
if (world.type === "flat" && !world.floor)
|
||||
throw new Error("world.json /floor: required for flat World");
|
||||
if (world.presentation && world.type !== "flat")
|
||||
throw new Error("world.json /presentation: requires a flat World");
|
||||
if (world.type === "adapter" && !world.adapter)
|
||||
throw new Error("world.json /adapter: required for adapter World");
|
||||
return world;
|
||||
}
|
||||
export function validatePackage(config) {
|
||||
assertSchema(check, config, "robot.json");
|
||||
const groups = config.joints.groups;
|
||||
const owners = new Set(
|
||||
config.skills
|
||||
.filter((s) => s.kind === "primary")
|
||||
.flatMap((s) => groups[s.owns] ?? []),
|
||||
),
|
||||
ids = new Set();
|
||||
let primaries = 0;
|
||||
for (const skill of config.skills) {
|
||||
if (ids.has(skill.id)) throw new Error(`skills: duplicate ${skill.id}`);
|
||||
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)
|
||||
throw new Error(`skills.${skill.id}.controller.policy: required`);
|
||||
if (skill.kind === "primary") primaries++;
|
||||
if (skill.kind === "overlay")
|
||||
for (const joint of groups[skill.owns]) {
|
||||
if (owners.has(joint))
|
||||
throw new Error(`skills: overlapping ownership of ${joint}`);
|
||||
owners.add(joint);
|
||||
}
|
||||
}
|
||||
if (
|
||||
config.adapter === "generic" &&
|
||||
(primaries !== 1 ||
|
||||
config.skills.some((s) => !["primary", "overlay"].includes(s.kind)))
|
||||
)
|
||||
throw new Error(
|
||||
"generic runtime requires one primary and disjoint overlays",
|
||||
);
|
||||
for (const obs of Object.values(config.observations))
|
||||
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) &&
|
||||
!term.group
|
||||
)
|
||||
throw new Error(`${term.type}: group required`);
|
||||
if (term.type === "gyro" && !term.sensor)
|
||||
throw new Error("gyro: sensor required");
|
||||
if (term.type === "projected_gravity" && !term.body)
|
||||
throw new Error("projected_gravity: body required");
|
||||
if (
|
||||
term.type === "command" &&
|
||||
(!term.size || term.size > config.commands.size)
|
||||
)
|
||||
throw new Error(
|
||||
"observations.command: size missing or exceeds command buffer",
|
||||
);
|
||||
}
|
||||
for (const action of config.actions)
|
||||
if (!groups[action.group])
|
||||
throw new Error(`actions: unknown group ${action.group}`);
|
||||
if (
|
||||
config.actuation.type === "joint_pd" &&
|
||||
!["kp", "kd", "torque_limit"].every((k) =>
|
||||
Number.isFinite(config.actuation[k]),
|
||||
)
|
||||
)
|
||||
throw new Error("actuation: PD gains and torque_limit required");
|
||||
const codes = new Set();
|
||||
for (const binding of config.input.bindings) {
|
||||
if (
|
||||
config.adapter === "generic" &&
|
||||
![
|
||||
"move_forward",
|
||||
"move_backward",
|
||||
"turn_left",
|
||||
"turn_right",
|
||||
"reset",
|
||||
"pause",
|
||||
"chaseToggle",
|
||||
...config.skills
|
||||
.filter((s) => s.kind === "overlay")
|
||||
.map((s) => `toggle:${s.id}`),
|
||||
].includes(binding.action)
|
||||
)
|
||||
throw new Error(`input: unsupported action ${binding.action}`);
|
||||
for (const code of binding.codes) {
|
||||
if (codes.has(code)) throw new Error(`input: duplicate ${code}`);
|
||||
codes.add(code);
|
||||
}
|
||||
}
|
||||
if (config.adapter === "generic" && config.render.source !== "mjcf_visual")
|
||||
throw new Error("render.source: generic runtime requires mjcf_visual");
|
||||
return config;
|
||||
}
|
||||
export { schema as robotSchema };
|
||||
@@ -0,0 +1,77 @@
|
||||
// ONNX ModelProto.metadata_props (field 14). Parse only protobuf wire
|
||||
// framing; no graph deserialization or dependency on Python at runtime.
|
||||
export function readOnnxMetadata(buffer) {
|
||||
const bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
||||
const decoder = new TextDecoder();
|
||||
if (
|
||||
decoder.decode(bytes.subarray(0, 40)).startsWith("version https://git-lfs")
|
||||
)
|
||||
throw new Error("ONNX is a Git LFS pointer: run git lfs pull");
|
||||
const fields = (start, end) => {
|
||||
let cursor = start;
|
||||
const varint = () => {
|
||||
let value = 0,
|
||||
shift = 0;
|
||||
while (cursor < end && shift <= 49) {
|
||||
const byte = bytes[cursor++];
|
||||
value += (byte & 127) * 2 ** shift;
|
||||
if (!(byte & 128)) return value;
|
||||
shift += 7;
|
||||
}
|
||||
throw new Error("Invalid ONNX protobuf varint");
|
||||
};
|
||||
const result = [];
|
||||
while (cursor < end) {
|
||||
const tag = varint(),
|
||||
id = Math.floor(tag / 8),
|
||||
wire = tag & 7;
|
||||
if (wire === 0) {
|
||||
varint();
|
||||
continue;
|
||||
}
|
||||
if (wire === 1 || wire === 5) {
|
||||
cursor += wire === 1 ? 8 : 4;
|
||||
} else if (wire === 2) {
|
||||
const size = varint(),
|
||||
begin = cursor;
|
||||
cursor += size;
|
||||
if (cursor > end) throw new Error("Truncated ONNX protobuf");
|
||||
result.push({ id, begin, end: cursor });
|
||||
} else throw new Error(`Unsupported ONNX protobuf wire type ${wire}`);
|
||||
if (cursor > end) throw new Error("Truncated ONNX protobuf");
|
||||
}
|
||||
return result;
|
||||
};
|
||||
const metadata = Object.create(null);
|
||||
for (const entry of fields(0, bytes.length).filter((f) => f.id === 14)) {
|
||||
const pair = fields(entry.begin, entry.end);
|
||||
const key = pair.find((f) => f.id === 1),
|
||||
val = pair.find((f) => f.id === 2);
|
||||
if (!key || !val) throw new Error("Invalid ONNX metadata entry");
|
||||
const name = decoder.decode(bytes.subarray(key.begin, key.end));
|
||||
if (Object.hasOwn(metadata, name))
|
||||
throw new Error(`Duplicate ONNX metadata ${name}`);
|
||||
metadata[name] = decoder.decode(bytes.subarray(val.begin, val.end));
|
||||
}
|
||||
return metadata;
|
||||
}
|
||||
export function resolveJointDefaults(metadata, group) {
|
||||
const names = metadata.joint_names?.split(",").map((n) => n.trim());
|
||||
const values = metadata.default_joint_pos?.split(",").map(Number);
|
||||
if (
|
||||
!names ||
|
||||
!values ||
|
||||
names.some((n) => !n) ||
|
||||
metadata.default_joint_pos.split(",").some((v) => !v.trim()) ||
|
||||
names.length !== values.length ||
|
||||
new Set(names).size !== names.length ||
|
||||
!values.every(Number.isFinite)
|
||||
) {
|
||||
throw new Error("Invalid ONNX joint_names/default_joint_pos metadata");
|
||||
}
|
||||
return group.map((name) => {
|
||||
const index = names.indexOf(name);
|
||||
if (index < 0) throw new Error(`ONNX metadata missing joint ${name}`);
|
||||
return values[index];
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,409 @@
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"schema",
|
||||
"id",
|
||||
"name",
|
||||
"family",
|
||||
"adapter",
|
||||
"model",
|
||||
"assets",
|
||||
"base",
|
||||
"sim",
|
||||
"joints",
|
||||
"observations",
|
||||
"actions",
|
||||
"actuation",
|
||||
"commands",
|
||||
"skills",
|
||||
"input",
|
||||
"render",
|
||||
"presentation",
|
||||
"termination",
|
||||
"license"
|
||||
],
|
||||
"properties": {
|
||||
"schema": {
|
||||
"const": 1
|
||||
},
|
||||
"id": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-z0-9-]+$"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"family": {
|
||||
"type": "string"
|
||||
},
|
||||
"adapter": {
|
||||
"enum": ["generic", "microduck"]
|
||||
},
|
||||
"model": {
|
||||
"type": "string"
|
||||
},
|
||||
"assets": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["path", "vfs"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"path": {
|
||||
"type": "string"
|
||||
},
|
||||
"vfs": {
|
||||
"type": "string",
|
||||
"pattern": "^(?!/)(?!.*\\.\\.)[^\\\\]+$"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"base": {
|
||||
"type": "object",
|
||||
"required": ["type", "root_body", "freejoint", "spawn"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"type": {
|
||||
"const": "floating"
|
||||
},
|
||||
"root_body": {
|
||||
"type": "string"
|
||||
},
|
||||
"freejoint": {
|
||||
"type": "string"
|
||||
},
|
||||
"spawn": {
|
||||
"type": "object",
|
||||
"required": ["pos", "yaw"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"pos": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "number"
|
||||
},
|
||||
"minItems": 3,
|
||||
"maxItems": 3
|
||||
},
|
||||
"yaw": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
},
|
||||
"initial": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"sim": {
|
||||
"type": "object",
|
||||
"required": ["timestep", "decimation"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"timestep": {
|
||||
"type": "number",
|
||||
"exclusiveMinimum": 0
|
||||
},
|
||||
"decimation": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"joints": {
|
||||
"type": "object",
|
||||
"required": ["groups", "defaults"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"source": {
|
||||
"const": "onnx_metadata"
|
||||
},
|
||||
"groups": {
|
||||
"type": "object",
|
||||
"required": ["policy"],
|
||||
"properties": {
|
||||
"policy": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"minItems": 1,
|
||||
"uniqueItems": true
|
||||
}
|
||||
},
|
||||
"additionalProperties": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"minItems": 1,
|
||||
"uniqueItems": true
|
||||
}
|
||||
},
|
||||
"defaults": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"observations": {
|
||||
"type": "object",
|
||||
"minProperties": 1,
|
||||
"additionalProperties": {
|
||||
"type": "object",
|
||||
"required": ["terms"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"terms": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["type"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"type": {
|
||||
"enum": [
|
||||
"gyro",
|
||||
"projected_gravity",
|
||||
"joint_pos_rel",
|
||||
"joint_vel",
|
||||
"last_action",
|
||||
"command"
|
||||
]
|
||||
},
|
||||
"sensor": {
|
||||
"type": "string"
|
||||
},
|
||||
"body": {
|
||||
"type": "string"
|
||||
},
|
||||
"group": {
|
||||
"type": "string"
|
||||
},
|
||||
"size": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"actions": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["type", "group", "scale", "offset"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"type": {
|
||||
"const": "joint_position"
|
||||
},
|
||||
"group": {
|
||||
"type": "string"
|
||||
},
|
||||
"scale": {
|
||||
"type": "number"
|
||||
},
|
||||
"offset": {
|
||||
"const": "default"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"actuation": {
|
||||
"type": "object",
|
||||
"required": ["type"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"type": {
|
||||
"enum": ["native_position", "joint_pd"]
|
||||
},
|
||||
"kp": {
|
||||
"type": "number",
|
||||
"minimum": 0
|
||||
},
|
||||
"kd": {
|
||||
"type": "number",
|
||||
"minimum": 0
|
||||
},
|
||||
"torque_limit": {
|
||||
"type": "number",
|
||||
"exclusiveMinimum": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
"commands": {
|
||||
"type": "object",
|
||||
"required": ["size", "limits"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"size": {
|
||||
"type": "integer",
|
||||
"minimum": 3
|
||||
},
|
||||
"limits": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "number"
|
||||
},
|
||||
"minItems": 3,
|
||||
"maxItems": 3
|
||||
}
|
||||
}
|
||||
},
|
||||
"skills": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["id", "kind", "owns", "controller"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"kind": {
|
||||
"enum": ["primary", "overlay", "episodic", "recovery"]
|
||||
},
|
||||
"owns": {
|
||||
"type": "string"
|
||||
},
|
||||
"controller": {
|
||||
"type": "object",
|
||||
"required": ["type"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"type": {
|
||||
"enum": ["onnx", "oscillator"]
|
||||
},
|
||||
"policy": {
|
||||
"type": "string"
|
||||
},
|
||||
"frequency": {
|
||||
"type": "number",
|
||||
"exclusiveMinimum": 0
|
||||
},
|
||||
"amplitude": {
|
||||
"type": "number",
|
||||
"minimum": 0
|
||||
},
|
||||
"blend": {
|
||||
"type": "number",
|
||||
"exclusiveMinimum": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"input": {
|
||||
"type": "object",
|
||||
"required": ["bindings"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"bindings": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["action", "codes", "label"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"action": {
|
||||
"type": "string"
|
||||
},
|
||||
"codes": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"minItems": 1,
|
||||
"uniqueItems": true
|
||||
},
|
||||
"label": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"render": {
|
||||
"type": "object",
|
||||
"required": ["source", "camera"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"source": {
|
||||
"enum": ["glb", "mjcf_visual"]
|
||||
},
|
||||
"groups": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer",
|
||||
"minimum": 0
|
||||
}
|
||||
},
|
||||
"camera": {
|
||||
"type": "object",
|
||||
"required": ["distance"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"distance": {
|
||||
"type": "number",
|
||||
"exclusiveMinimum": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"presentation": {
|
||||
"type": "object",
|
||||
"required": ["theme"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"world": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-z0-9-]+$"
|
||||
},
|
||||
"theme": {
|
||||
"enum": ["comic", "neutral"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"termination": {
|
||||
"type": "object",
|
||||
"required": ["tilt_z", "min_height", "on_fall"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"tilt_z": {
|
||||
"type": "number",
|
||||
"minimum": -1,
|
||||
"maximum": 1
|
||||
},
|
||||
"min_height": {
|
||||
"type": "number"
|
||||
},
|
||||
"on_fall": {
|
||||
"enum": ["recovery", "hold"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"legacy": {
|
||||
"type": "object"
|
||||
},
|
||||
"license": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["schema", "id", "type"],
|
||||
"properties": {
|
||||
"schema": { "const": 1 },
|
||||
"id": { "type": "string", "pattern": "^[a-z0-9-]+$" },
|
||||
"type": { "enum": ["flat", "adapter"] },
|
||||
"adapter": { "type": "string", "minLength": 1 },
|
||||
"presentation": { "enum": ["arena-grid"] },
|
||||
"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}
|
||||
}
|
||||
},
|
||||
"floor": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["rgba", "friction"],
|
||||
"properties": {
|
||||
"grid": {
|
||||
"type": "object",
|
||||
"required": ["size", "divisions", "color"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"size": { "type": "number", "exclusiveMinimum": 0 },
|
||||
"divisions": { "type": "integer", "minimum": 1, "maximum": 1000 },
|
||||
"color": { "type": "string", "pattern": "^#[0-9a-fA-F]{6}$" }
|
||||
}
|
||||
},
|
||||
"rgba": {
|
||||
"type": "array",
|
||||
"minItems": 4,
|
||||
"maxItems": 4,
|
||||
"items": { "type": "number", "minimum": 0, "maximum": 1 }
|
||||
},
|
||||
"friction": {
|
||||
"type": "array",
|
||||
"minItems": 3,
|
||||
"maxItems": 3,
|
||||
"items": { "type": "number", "minimum": 0 }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { actionTerms } from "./TermRegistry.js";
|
||||
export class ActionPipeline {
|
||||
constructor(specs, ctx, { registry = actionTerms } = {}) {
|
||||
this.ctx = ctx;
|
||||
this.ops = [];
|
||||
for (const spec of specs)
|
||||
this.ops.push(
|
||||
...registry.get(spec.type ?? "joint_position").compile(spec, ctx),
|
||||
);
|
||||
this.size = this.ops.length;
|
||||
this.pending = new Float64Array(this.size);
|
||||
if (new Set(this.ops.map((op) => op.name)).size !== this.size)
|
||||
throw new Error("actions: duplicate joint ownership");
|
||||
if (
|
||||
this.ops.some(
|
||||
(op) => !Number.isFinite(op.scale) || !Number.isFinite(op.offset),
|
||||
)
|
||||
)
|
||||
throw new Error("actions: invalid scale/default");
|
||||
}
|
||||
apply(action, scaleOverride) {
|
||||
if (action.length !== this.size)
|
||||
throw new Error(`actions: expected ${this.size}, got ${action.length}`);
|
||||
if (!action.every(Number.isFinite))
|
||||
throw new Error("actions: non-finite tensor");
|
||||
for (let i = 0; i < this.ops.length; i++) {
|
||||
const op = this.ops[i],
|
||||
value = op.offset + action[i] * (scaleOverride ?? op.scale);
|
||||
if (!Number.isFinite(value))
|
||||
throw new Error(`actions.${op.name}: non-finite target`);
|
||||
this.pending[i] = value;
|
||||
}
|
||||
for (let i = 0; i < this.ops.length; i++)
|
||||
this.ctx.targets.set(this.ops[i].name, this.pending[i]);
|
||||
this.ctx.lastAction.set(action);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
import { observationTerms } from "./TermRegistry.js";
|
||||
// Compiled term writers keep the policy joint order independent of model order.
|
||||
export class ObservationPipeline {
|
||||
constructor(specs, ctx, { buffers = {}, registry = observationTerms } = {}) {
|
||||
this.ctx = ctx;
|
||||
this.inputs = {};
|
||||
this.ops = [];
|
||||
this.details = {};
|
||||
for (const [name, spec] of Object.entries(specs)) {
|
||||
let offset = 0;
|
||||
const terms = [];
|
||||
for (const term of spec.terms) {
|
||||
const names = term.group ? ctx.config.joints.groups[term.group] : null;
|
||||
const implementation = registry.get(term.type),
|
||||
size = implementation.size(term, ctx, names);
|
||||
let sensor, body;
|
||||
if (term.type === "gyro") {
|
||||
const id = ctx.sim.mujoco.mj_name2id(
|
||||
ctx.sim.model,
|
||||
ctx.sim.mujoco.mjtObj.mjOBJ_SENSOR.value,
|
||||
term.sensor,
|
||||
);
|
||||
if (id < 0)
|
||||
throw new Error(
|
||||
`observations.${name}: missing sensor ${term.sensor}`,
|
||||
);
|
||||
sensor = {
|
||||
adr: ctx.sim.model.sensor_adr[id],
|
||||
dim: ctx.sim.model.sensor_dim[id],
|
||||
};
|
||||
if (sensor.dim !== 3)
|
||||
throw new Error(
|
||||
`observations.${name}: gyro ${term.sensor} must have dimension 3`,
|
||||
);
|
||||
}
|
||||
if (term.type === "projected_gravity") {
|
||||
body = ctx.sim.mujoco.mj_name2id(
|
||||
ctx.sim.model,
|
||||
ctx.sim.mujoco.mjtObj.mjOBJ_BODY.value,
|
||||
term.body,
|
||||
);
|
||||
if (body < 0)
|
||||
throw new Error(`observations.${name}: missing body ${term.body}`);
|
||||
}
|
||||
const indices =
|
||||
term.type === "last_action"
|
||||
? names.map((n) => ctx.policyNames.indexOf(n))
|
||||
: null;
|
||||
if (indices?.some((i) => i < 0))
|
||||
throw new Error(
|
||||
`observations.${name}: last_action group is not actor-controlled`,
|
||||
);
|
||||
terms.push({ ...term, size, offset });
|
||||
this.ops.push({
|
||||
name,
|
||||
term,
|
||||
names,
|
||||
sensorAdr: sensor?.adr,
|
||||
body,
|
||||
indices,
|
||||
offset,
|
||||
implementation,
|
||||
...implementation.init?.(term, ctx),
|
||||
});
|
||||
offset += size;
|
||||
}
|
||||
if (buffers[name] && buffers[name].length !== offset)
|
||||
throw new Error(`Observation buffer ${name}: incorrect size`);
|
||||
this.inputs[name] = buffers[name] ?? new Float32Array(offset);
|
||||
this.details[name] = terms;
|
||||
}
|
||||
}
|
||||
write() {
|
||||
for (const op of this.ops)
|
||||
op.implementation.write(this.inputs[op.name], op.offset, this.ctx, op);
|
||||
return this.inputs;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
export class TermRegistry {
|
||||
constructor(entries = []) {
|
||||
this.terms = new Map(entries);
|
||||
}
|
||||
register(type, implementation) {
|
||||
if (this.terms.has(type)) throw new Error(`Duplicate term ${type}`);
|
||||
this.terms.set(type, implementation);
|
||||
return this;
|
||||
}
|
||||
get(type) {
|
||||
const term = this.terms.get(type);
|
||||
if (!term) throw new Error(`Unsupported term ${type}`);
|
||||
return term;
|
||||
}
|
||||
clone() {
|
||||
return new TermRegistry(this.terms);
|
||||
}
|
||||
}
|
||||
export const actionTerms = new TermRegistry();
|
||||
actionTerms.register("joint_position", {
|
||||
compile: (spec, ctx) =>
|
||||
ctx.config.joints.groups[spec.group].map((name) => ({
|
||||
name,
|
||||
scale: spec.scale,
|
||||
offset: ctx.defaults.get(name),
|
||||
})),
|
||||
});
|
||||
export const observationTerms = new TermRegistry();
|
||||
observationTerms.register("gyro", {
|
||||
size: () => 3,
|
||||
write: (out, offset, c, op) => {
|
||||
for (let i = 0; i < 3; i++)
|
||||
out[offset + i] = c.sim.data.sensordata[op.sensorAdr + i];
|
||||
},
|
||||
});
|
||||
observationTerms.register("projected_gravity", {
|
||||
size: () => 3,
|
||||
write: (out, offset, c, op) => {
|
||||
if (c.gravityWriter) {
|
||||
c.gravityWriter(out, offset, op.body);
|
||||
return;
|
||||
}
|
||||
const q = c.sim.data.xquat,
|
||||
a = op.body * 4,
|
||||
w = q[a],
|
||||
x = q[a + 1],
|
||||
y = q[a + 2],
|
||||
z = q[a + 3];
|
||||
out[offset] = 2 * (w * y - x * z);
|
||||
out[offset + 1] = -2 * (y * z + w * x);
|
||||
out[offset + 2] = -(1 - 2 * (x * x + y * y));
|
||||
},
|
||||
});
|
||||
observationTerms.register("command", {
|
||||
size: (term) => term.size,
|
||||
write: (out, offset, c, op) => {
|
||||
for (let i = 0; i < op.term.size; i++) out[offset + i] = c.command[i];
|
||||
},
|
||||
});
|
||||
for (const type of ["joint_pos_rel", "joint_vel", "last_action"])
|
||||
observationTerms.register(type, {
|
||||
size: (_term, _ctx, names) => names.length,
|
||||
write: (out, offset, c, op) => {
|
||||
for (let i = 0; i < op.names.length; i++) {
|
||||
const joint = c.sim.joints.get(op.names[i]);
|
||||
out[offset + i] =
|
||||
type === "joint_pos_rel"
|
||||
? c.sim.data.qpos[joint.qpos] - c.defaults.get(op.names[i])
|
||||
: type === "joint_vel"
|
||||
? c.sim.data.qvel[joint.dof]
|
||||
: c.lastAction[op.indices[i]];
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,50 @@
|
||||
export class OnnxController {
|
||||
constructor(ort, session, observations, actionSize) {
|
||||
this.session = session;
|
||||
this.feeds = {};
|
||||
const groups = Object.keys(observations.inputs);
|
||||
if (session.inputNames.length !== groups.length)
|
||||
throw new Error(
|
||||
`ONNX inputs: expected ${groups.length}, got ${session.inputNames.length}`,
|
||||
);
|
||||
for (const name of session.inputNames) {
|
||||
const group = Object.hasOwn(observations.inputs, name)
|
||||
? name
|
||||
: groups.length === 1
|
||||
? groups[0]
|
||||
: null;
|
||||
if (!group)
|
||||
throw new Error(`ONNX input ${name}: missing observation group`);
|
||||
const input = observations.inputs[group],
|
||||
meta = session.inputMetadata.find((m) => m.name === name);
|
||||
if (
|
||||
!meta?.isTensor ||
|
||||
meta.type !== "float32" ||
|
||||
meta.shape.length !== 2 ||
|
||||
typeof meta.shape[1] !== "number" ||
|
||||
meta.shape[1] !== input.length
|
||||
)
|
||||
throw new Error(
|
||||
`ONNX input ${name}: ${JSON.stringify(meta?.shape)} vs terms ${JSON.stringify(observations.details[group])}`,
|
||||
);
|
||||
this.feeds[name] = new ort.Tensor("float32", input, [1, input.length]);
|
||||
}
|
||||
this.output = session.outputNames[0];
|
||||
const meta = session.outputMetadata[0];
|
||||
if (
|
||||
!meta?.isTensor ||
|
||||
meta.type !== "float32" ||
|
||||
meta.shape.length !== 2 ||
|
||||
meta.shape[1] !== actionSize
|
||||
)
|
||||
throw new Error(
|
||||
`ONNX output ${this.output}: expected [1,${actionSize}], got ${JSON.stringify(meta?.shape)}`,
|
||||
);
|
||||
}
|
||||
async run() {
|
||||
return (await this.session.run(this.feeds))[this.output].data;
|
||||
}
|
||||
dispose() {
|
||||
return this.session.release();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
import * as THREE from "three";
|
||||
const wrapPi = (angle) => Math.atan2(Math.sin(angle), Math.cos(angle));
|
||||
// Same rear framing and yaw hysteresis as Microduck. Only presentation state:
|
||||
// mouse orbit detaches; restoring never toggles follow off or touches physics.
|
||||
export class ChaseCamera {
|
||||
constructor(camera, controls, { distance, pitch = 0.42 }) {
|
||||
Object.assign(this, { camera, controls, distance, pitch });
|
||||
this.enabled = true;
|
||||
this.previous = new THREE.Vector3();
|
||||
this.delta = new THREE.Vector3();
|
||||
this.goal = new THREE.Vector3();
|
||||
this.direction = new THREE.Vector3();
|
||||
this.detach = () => {
|
||||
this.enabled = false;
|
||||
};
|
||||
controls.domElement.addEventListener("pointerdown", this.detach);
|
||||
}
|
||||
restore(position, yaw) {
|
||||
const damping = this.controls.enableDamping;
|
||||
this.controls.enableDamping = false;
|
||||
this.controls.update(); // consume any residual orbit inertia before restoring
|
||||
this.controls.enableDamping = damping;
|
||||
this.previous.copy(position);
|
||||
this.controls.target.copy(position);
|
||||
this.smoothYaw = this.followYaw = yaw;
|
||||
this.tracking = false;
|
||||
this.enabled = true;
|
||||
this.#behind(yaw, this.distance);
|
||||
this.camera.position.copy(this.goal);
|
||||
this.controls.update();
|
||||
this.camera.lookAt(this.controls.target);
|
||||
}
|
||||
#behind(yaw, distance) {
|
||||
const horizontal = distance * Math.cos(this.pitch);
|
||||
this.goal
|
||||
.copy(this.controls.target)
|
||||
.add(
|
||||
this.direction.set(
|
||||
-Math.cos(yaw) * horizontal,
|
||||
distance * Math.sin(this.pitch),
|
||||
Math.sin(yaw) * horizontal,
|
||||
),
|
||||
);
|
||||
}
|
||||
update(position, yaw, { turning = false } = {}) {
|
||||
this.delta.copy(position).sub(this.previous);
|
||||
this.camera.position.add(this.delta);
|
||||
this.controls.target.add(this.delta);
|
||||
this.previous.copy(position);
|
||||
this.controls.update();
|
||||
if (!this.enabled) return;
|
||||
this.smoothYaw = wrapPi(
|
||||
this.smoothYaw + wrapPi(yaw - this.smoothYaw) * (turning ? 0.5 : 0.04),
|
||||
);
|
||||
const error = wrapPi(this.smoothYaw - this.followYaw);
|
||||
if (turning || Math.abs(error) > 0.17) this.tracking = true;
|
||||
if (this.tracking) {
|
||||
this.followYaw = wrapPi(this.followYaw + error * (turning ? 0.5 : 0.1));
|
||||
if (!turning && Math.abs(error) < 0.03) this.tracking = false;
|
||||
}
|
||||
const distance = this.camera.position.distanceTo(this.controls.target);
|
||||
this.#behind(this.followYaw, distance);
|
||||
this.camera.position.lerp(this.goal, 0.05);
|
||||
this.direction.copy(this.camera.position).sub(this.controls.target);
|
||||
const length = this.direction.length();
|
||||
if (length > 1e-6)
|
||||
this.camera.position
|
||||
.copy(this.controls.target)
|
||||
.addScaledVector(this.direction, distance / length);
|
||||
this.camera.lookAt(this.controls.target);
|
||||
}
|
||||
dispose() {
|
||||
this.controls.domElement.removeEventListener("pointerdown", this.detach);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
import * as THREE from "three";
|
||||
import { applyWorldGrid } from "./WorldRenderer.js";
|
||||
// Geometry is compiled MuJoCo geometry, not raw STL: compiler-applied mesh
|
||||
// scale/centering is already represented by vertices + geom transforms.
|
||||
export class RigRenderer {
|
||||
constructor(model, data, { groups = [2], world } = {}) {
|
||||
this.model = model;
|
||||
this.data = data;
|
||||
this.root = new THREE.Group();
|
||||
this.root.rotation.x = -Math.PI / 2;
|
||||
this.geometries = new Map();
|
||||
this.materials = [];
|
||||
this.items = [];
|
||||
this.matrix = new THREE.Matrix4();
|
||||
try {
|
||||
for (let id = 0; id < model.ngeom; id++) {
|
||||
if (!groups.includes(model.geom_group[id]) && model.geom_type[id] !== 0)
|
||||
continue;
|
||||
const type = model.geom_type[id],
|
||||
size = Array.from(model.geom_size.slice(id * 3, id * 3 + 3));
|
||||
let geometry,
|
||||
key = type === 7 ? `mesh:${model.geom_dataid[id]}` : `geom:${id}`;
|
||||
geometry = this.geometries.get(key);
|
||||
if (!geometry) {
|
||||
if (type === 7) {
|
||||
const mesh = model.geom_dataid[id],
|
||||
v0 = model.mesh_vertadr[mesh] * 3,
|
||||
vn = model.mesh_vertnum[mesh] * 3;
|
||||
const f0 = model.mesh_faceadr[mesh] * 3,
|
||||
fn = model.mesh_facenum[mesh] * 3;
|
||||
geometry = new THREE.BufferGeometry();
|
||||
geometry.setAttribute(
|
||||
"position",
|
||||
new THREE.BufferAttribute(
|
||||
new Float32Array(model.mesh_vert.slice(v0, v0 + vn)),
|
||||
3,
|
||||
),
|
||||
);
|
||||
geometry.setIndex(
|
||||
new THREE.BufferAttribute(
|
||||
new Uint32Array(model.mesh_face.slice(f0, f0 + fn)),
|
||||
1,
|
||||
),
|
||||
);
|
||||
geometry.computeVertexNormals();
|
||||
} else if (type === 0) geometry = new THREE.PlaneGeometry(200, 200);
|
||||
else if (type === 2)
|
||||
geometry = new THREE.SphereGeometry(size[0], 20, 12);
|
||||
else if (type === 6)
|
||||
geometry = new THREE.BoxGeometry(...size.map((v) => v * 2));
|
||||
else if (type === 4) {
|
||||
geometry = new THREE.SphereGeometry(1, 20, 12);
|
||||
geometry.scale(...size);
|
||||
} else if (type === 5) {
|
||||
geometry = new THREE.CylinderGeometry(
|
||||
size[0],
|
||||
size[0],
|
||||
size[1] * 2,
|
||||
20,
|
||||
);
|
||||
geometry.rotateX(Math.PI / 2);
|
||||
} else if (type === 3) {
|
||||
geometry = new THREE.CapsuleGeometry(size[0], size[1] * 2, 6, 12);
|
||||
geometry.rotateX(Math.PI / 2);
|
||||
} else throw new Error(`RigRenderer: unsupported geom type ${type}`);
|
||||
this.geometries.set(key, geometry);
|
||||
}
|
||||
const mat = model.geom_matid[id],
|
||||
rgba =
|
||||
mat >= 0
|
||||
? model.mat_rgba.slice(mat * 4, mat * 4 + 4)
|
||||
: model.geom_rgba.slice(id * 4, id * 4 + 4);
|
||||
const material = new THREE.MeshStandardMaterial({
|
||||
color: new THREE.Color(rgba[0], rgba[1], rgba[2]),
|
||||
opacity: rgba[3],
|
||||
transparent: rgba[3] < 1,
|
||||
roughness: 0.65,
|
||||
metalness: 0.05,
|
||||
side: type === 0 ? THREE.DoubleSide : THREE.FrontSide,
|
||||
});
|
||||
if (type === 0) applyWorldGrid(material, world?.floor?.grid);
|
||||
this.materials.push(material);
|
||||
const mesh = new THREE.Mesh(geometry, material);
|
||||
mesh.userData.geomId = id;
|
||||
this.root.add(mesh);
|
||||
this.items.push({ id, mesh });
|
||||
}
|
||||
this.sync();
|
||||
} catch (error) {
|
||||
this.dispose();
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
sync() {
|
||||
const p = this.data.geom_xpos,
|
||||
r = this.data.geom_xmat,
|
||||
m = this.matrix;
|
||||
for (const { id, mesh } of this.items) {
|
||||
mesh.position.set(p[id * 3], p[id * 3 + 1], p[id * 3 + 2]);
|
||||
const a = id * 9;
|
||||
m.set(
|
||||
r[a],
|
||||
r[a + 1],
|
||||
r[a + 2],
|
||||
0,
|
||||
r[a + 3],
|
||||
r[a + 4],
|
||||
r[a + 5],
|
||||
0,
|
||||
r[a + 6],
|
||||
r[a + 7],
|
||||
r[a + 8],
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
);
|
||||
mesh.quaternion.setFromRotationMatrix(m);
|
||||
}
|
||||
}
|
||||
dispose() {
|
||||
for (const g of this.geometries.values()) g.dispose();
|
||||
for (const m of this.materials) m.dispose();
|
||||
this.geometries.clear();
|
||||
this.materials = [];
|
||||
this.root.removeFromParent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import * as THREE from "three";
|
||||
// Shade the compiled World floor itself instead of overlaying long GL lines.
|
||||
// This preserves robot occlusion and avoids line-clipping/depth artifacts at
|
||||
// the tiny scale of these robots. It has no effect on the physical floor.
|
||||
export function applyWorldGrid(material, spec) {
|
||||
if (!spec) return;
|
||||
material.onBeforeCompile = (shader) => {
|
||||
shader.uniforms.uPlatformGridSpacing = {
|
||||
value: spec.size / spec.divisions,
|
||||
};
|
||||
shader.uniforms.uPlatformGridColor = { value: new THREE.Color(spec.color) };
|
||||
shader.vertexShader =
|
||||
"varying vec2 vPlatformGrid;\n" +
|
||||
shader.vertexShader.replace(
|
||||
"#include <project_vertex>",
|
||||
"#include <project_vertex>\nvPlatformGrid = (modelMatrix * vec4(transformed, 1.0)).xz;",
|
||||
);
|
||||
shader.fragmentShader =
|
||||
"varying vec2 vPlatformGrid;\nuniform float uPlatformGridSpacing;\nuniform vec3 uPlatformGridColor;\n" +
|
||||
shader.fragmentShader.replace(
|
||||
"#include <color_fragment>",
|
||||
`#include <color_fragment>
|
||||
vec2 platformCell = vPlatformGrid / uPlatformGridSpacing;
|
||||
vec2 platformWidth = max(fwidth(platformCell), vec2(0.00001));
|
||||
vec2 platformDistance = abs(fract(platformCell - 0.5) - 0.5) / platformWidth;
|
||||
float platformLine = 1.0 - min(min(platformDistance.x, platformDistance.y), 1.0);
|
||||
diffuseColor.rgb = mix(diffuseColor.rgb, uPlatformGridColor, platformLine * 0.7);
|
||||
`,
|
||||
);
|
||||
};
|
||||
material.customProgramCacheKey = () => "platform-world-grid-v1";
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// Dispose per-instance World geometry/materials, but leave shared Robot GLB
|
||||
// caches alone. Robot adapters own their own rig-specific resources.
|
||||
export function disposeWorld(root) {
|
||||
const geometries = new Set(),
|
||||
materials = new Set(),
|
||||
textures = new Set();
|
||||
root.traverse((object) => {
|
||||
for (let p = object; p; p = p.parent) if (p.userData.robotRig) return;
|
||||
if (object.geometry) geometries.add(object.geometry);
|
||||
if (object.userData.fxWireGeometry)
|
||||
geometries.add(object.userData.fxWireGeometry);
|
||||
for (const material of [object.material].flat().filter(Boolean))
|
||||
materials.add(material);
|
||||
});
|
||||
for (const material of materials) {
|
||||
for (const value of Object.values(material))
|
||||
if (value?.isTexture) textures.add(value);
|
||||
material.dispose();
|
||||
}
|
||||
for (const geometry of geometries) geometry.dispose();
|
||||
for (const texture of textures) texture.dispose();
|
||||
root.clear();
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
// One owner for async control ticks. Pausing drains the current tick; it
|
||||
// never abandons an inference halfway through a physics control interval.
|
||||
export class ControlScheduler {
|
||||
#tick;
|
||||
#dt;
|
||||
#onError;
|
||||
#timer = null;
|
||||
#tail = Promise.resolve();
|
||||
#running = false;
|
||||
#disposed = false;
|
||||
#generation = 0;
|
||||
constructor(tick, { dt = 0.02, onError = console.error } = {}) {
|
||||
if (!(dt > 0 && Number.isFinite(dt))) throw new Error("Invalid control dt");
|
||||
this.#tick = tick;
|
||||
this.#dt = dt * 1000;
|
||||
this.#onError = onError;
|
||||
}
|
||||
get running() {
|
||||
return this.#running;
|
||||
}
|
||||
start() {
|
||||
if (this.#disposed) throw new Error("Scheduler disposed");
|
||||
if (this.#running) return;
|
||||
this.#running = true;
|
||||
const generation = ++this.#generation;
|
||||
const run = async () => {
|
||||
if (!this.#running || generation !== this.#generation) return;
|
||||
const begin = performance.now();
|
||||
try {
|
||||
await this.#enqueue(1);
|
||||
} catch (error) {
|
||||
this.#running = false;
|
||||
this.#onError(error);
|
||||
return;
|
||||
}
|
||||
if (this.#running && generation === this.#generation) {
|
||||
this.#timer = setTimeout(
|
||||
run,
|
||||
Math.max(0, this.#dt - (performance.now() - begin)),
|
||||
);
|
||||
}
|
||||
};
|
||||
// Queueing also prevents start() from racing a previously queued step.
|
||||
this.#timer = setTimeout(run, 0);
|
||||
}
|
||||
async pause() {
|
||||
this.#running = false;
|
||||
this.#generation++;
|
||||
clearTimeout(this.#timer);
|
||||
this.#timer = null;
|
||||
await this.#tail;
|
||||
}
|
||||
async step(count = 1) {
|
||||
if (this.#disposed) throw new Error("Scheduler disposed");
|
||||
if (this.#running) throw new Error("Must pause before manual stepping");
|
||||
if (!Number.isInteger(count) || count < 0)
|
||||
throw new Error("Invalid step count");
|
||||
await this.#enqueue(count);
|
||||
}
|
||||
#enqueue(count) {
|
||||
const next = this.#tail.then(async () => {
|
||||
for (let i = 0; i < count; i++) await this.#tick();
|
||||
});
|
||||
this.#tail = next.catch(() => {});
|
||||
return next;
|
||||
}
|
||||
async dispose() {
|
||||
this.#disposed = true;
|
||||
await this.pause();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// LIFO ownership scope. Async resources acquired after disposal are released
|
||||
// immediately too, so failed/cancelled boot cannot strand late sessions.
|
||||
export class Disposables {
|
||||
#callbacks = [];
|
||||
#disposed = false;
|
||||
#pending;
|
||||
get disposed() {
|
||||
return this.#disposed;
|
||||
}
|
||||
add(callback) {
|
||||
if (this.#disposed) return Promise.resolve().then(callback);
|
||||
this.#callbacks.push(callback);
|
||||
return callback;
|
||||
}
|
||||
listen(target, event, callback, options) {
|
||||
target.addEventListener(event, callback, options);
|
||||
this.add(() => target.removeEventListener(event, callback, options));
|
||||
return callback;
|
||||
}
|
||||
dispose() {
|
||||
if (this.#pending) return this.#pending;
|
||||
this.#disposed = true;
|
||||
this.#pending = (async () => {
|
||||
const errors = [];
|
||||
for (const release of this.#callbacks.splice(0).reverse()) {
|
||||
try {
|
||||
await release();
|
||||
} catch (error) {
|
||||
errors.push(error);
|
||||
}
|
||||
}
|
||||
if (errors.length)
|
||||
throw new AggregateError(errors, "Resource cleanup failed");
|
||||
})();
|
||||
return this.#pending;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,383 @@
|
||||
import * as THREE from "three";
|
||||
import { OrbitControls } from "three/addons/controls/OrbitControls.js";
|
||||
import { loadRuntimes } from "./runtimes.js";
|
||||
import { ControlScheduler } from "./ControlScheduler.js";
|
||||
import { fetchChecked } from "../loader/PackageLoader.js";
|
||||
import { readOnnxMetadata, resolveJointDefaults } from "../loader/metadata.js";
|
||||
import { SimCore } from "../sim/SimCore.js";
|
||||
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 { SkillManager } from "../skills/SkillManager.js";
|
||||
import { InputRouter } from "../input/InputRouter.js";
|
||||
import { RigRenderer } from "../render/RigRenderer.js";
|
||||
import { ChaseCamera } from "../render/ChaseCamera.js";
|
||||
|
||||
export class RobotRuntime {
|
||||
static async load(options) {
|
||||
const { pkg, world } = options,
|
||||
config = pkg.config,
|
||||
{ mujoco, ort } = await loadRuntimes();
|
||||
let sim, session, rig, worldPresentation;
|
||||
try {
|
||||
sim = await SimCore.load(mujoco, pkg, world);
|
||||
const primary = config.skills.find((s) => s.kind === "primary");
|
||||
if (primary.controller.type !== "onnx")
|
||||
throw new Error("Primary controller must be ONNX");
|
||||
const bytes = await fetchChecked(
|
||||
pkg.asset(primary.controller.policy),
|
||||
"bytes",
|
||||
);
|
||||
const metadata = readOnnxMetadata(bytes),
|
||||
names = [...sim.joints.keys()];
|
||||
const values =
|
||||
config.joints.source === "onnx_metadata"
|
||||
? resolveJointDefaults(metadata, names)
|
||||
: names.map((n) => config.joints.defaults[n]);
|
||||
const defaults = new Map(names.map((n, i) => [n, values[i]]));
|
||||
for (const [name, value] of Object.entries(config.joints.defaults)) {
|
||||
if (defaults.has(name) && Math.abs(defaults.get(name) - value) > 1e-6)
|
||||
throw new Error(`joints.defaults.${name}: metadata conflict`);
|
||||
defaults.set(name, value);
|
||||
}
|
||||
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 = {
|
||||
sim,
|
||||
config,
|
||||
defaults,
|
||||
policyNames: config.joints.groups[primary.owns],
|
||||
lastAction: new Float32Array(config.joints.groups[primary.owns].length),
|
||||
command: new Float32Array(config.commands.size),
|
||||
targets: new Map(
|
||||
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");
|
||||
rig = new RigRenderer(sim.model, sim.data, { ...config.render, world });
|
||||
worldPresentation = await options.createWorldPresentation?.({
|
||||
sim,
|
||||
rig,
|
||||
world,
|
||||
});
|
||||
return new RobotRuntime({
|
||||
...options,
|
||||
config,
|
||||
sim,
|
||||
ctx,
|
||||
obs,
|
||||
actions,
|
||||
controller,
|
||||
rig,
|
||||
worldPresentation,
|
||||
});
|
||||
} catch (error) {
|
||||
worldPresentation?.dispose();
|
||||
rig?.dispose();
|
||||
await session?.release();
|
||||
sim?.dispose();
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
constructor(options) {
|
||||
Object.assign(this, options);
|
||||
this.onStatus ??= () => {};
|
||||
this.onTelemetry ??= () => {};
|
||||
this.fallen = false;
|
||||
this.odo = 0;
|
||||
this.lastPosition = new Float64Array(
|
||||
this.sim.data.qpos.slice(this.sim.rootQpos, this.sim.rootQpos + 2),
|
||||
);
|
||||
this.disposed = false;
|
||||
this.active = false;
|
||||
this.positions = new Map();
|
||||
this.skills = new SkillManager(this.config);
|
||||
this.actuation =
|
||||
this.config.actuation.type === "joint_pd"
|
||||
? new JointPdActuation(
|
||||
this.sim,
|
||||
this.ctx.targets,
|
||||
this.config.actuation,
|
||||
)
|
||||
: new NativeActuation(this.sim, this.ctx.targets);
|
||||
this.input = new InputRouter({
|
||||
bindings: this.config.input.bindings,
|
||||
getVelocityLimits: () => this.config.commands.limits,
|
||||
isEnabled: (action) =>
|
||||
this.active &&
|
||||
(action === "reset" ||
|
||||
action === "chaseToggle" ||
|
||||
(this.scheduler.running && !this.fallen)),
|
||||
});
|
||||
this.input.onAction = (action) => {
|
||||
if (action === "reset")
|
||||
this.reset().catch((error) =>
|
||||
this.onStatus({ runtimeError: error.message }),
|
||||
);
|
||||
else if (action === "chaseToggle") this.restoreCamera();
|
||||
else if (action.startsWith("toggle:")) this.toggle(action.slice(7));
|
||||
};
|
||||
this.tickCount = 0;
|
||||
this.hzAt = performance.now();
|
||||
this.ctrlHz = 0;
|
||||
this.frames = 0;
|
||||
this.fpsAt = this.hzAt;
|
||||
this.telemetryAt = 0;
|
||||
this.scheduler = new ControlScheduler(() => this.controlStep(), {
|
||||
dt: this.config.sim.timestep * this.config.sim.decimation,
|
||||
onError: (error) => {
|
||||
this.input.clear();
|
||||
this.onStatus({
|
||||
runtimeError: error.message,
|
||||
paused: true,
|
||||
runtimePhase: "error",
|
||||
});
|
||||
},
|
||||
});
|
||||
this.scene.add(this.rig.root);
|
||||
if (this.worldPresentation) this.scene.add(this.worldPresentation.root);
|
||||
this.follow = new THREE.Vector3();
|
||||
}
|
||||
activate({ paused = false } = {}) {
|
||||
if (this.disposed) throw new Error("Runtime disposed");
|
||||
this.active = true;
|
||||
this.controls = new OrbitControls(this.camera, this.renderer.domElement);
|
||||
this.controls.enableDamping = true;
|
||||
this.controls.minDistance = 0.2;
|
||||
this.controls.maxDistance = 4;
|
||||
this.controls.maxPolarAngle = Math.PI / 2 - 0.02;
|
||||
this.chaseCamera = new ChaseCamera(
|
||||
this.camera,
|
||||
this.controls,
|
||||
this.config.render.camera,
|
||||
);
|
||||
this.restoreCamera();
|
||||
this.input.init();
|
||||
if (!paused) this.resume();
|
||||
else this.onStatus({ paused: true });
|
||||
}
|
||||
cameraPose() {
|
||||
const q = this.sim.data.qpos,
|
||||
a = this.sim.rootQpos,
|
||||
quat = this.sim.data.xquat,
|
||||
b = this.sim.root * 4;
|
||||
this.follow.set(q[a], q[a + 2], -q[a + 1]);
|
||||
return Math.atan2(
|
||||
2 * (quat[b] * quat[b + 3] + quat[b + 1] * quat[b + 2]),
|
||||
1 - 2 * (quat[b + 2] ** 2 + quat[b + 3] ** 2),
|
||||
);
|
||||
}
|
||||
restoreCamera() {
|
||||
const yaw = this.cameraPose();
|
||||
this.chaseCamera.restore(this.follow, yaw);
|
||||
}
|
||||
status() {
|
||||
return {
|
||||
actuationLabel:
|
||||
this.config.actuation.type === "joint_pd"
|
||||
? "Simplified actuation · joint PD"
|
||||
: "",
|
||||
};
|
||||
}
|
||||
async deactivate() {
|
||||
this.active = false;
|
||||
await this.pause();
|
||||
}
|
||||
reactivate({ paused = false } = {}) {
|
||||
this.active = true;
|
||||
if (!paused) this.resume();
|
||||
}
|
||||
async pause() {
|
||||
this.input.clear();
|
||||
await this.scheduler.pause();
|
||||
this.onStatus({ paused: true });
|
||||
}
|
||||
resume() {
|
||||
if (this.disposed) return;
|
||||
this.active = true;
|
||||
this.input.clear();
|
||||
this.scheduler.start();
|
||||
this.onStatus({ paused: false });
|
||||
}
|
||||
reset() {
|
||||
return (this.resetPending ??= this.#reset().finally(() => {
|
||||
this.resetPending = null;
|
||||
}));
|
||||
}
|
||||
async #reset() {
|
||||
const running = this.scheduler.running;
|
||||
await this.scheduler.pause();
|
||||
this.input.clear();
|
||||
this.ctx.command.fill(0);
|
||||
this.ctx.lastAction.fill(0);
|
||||
this.skills.reset();
|
||||
this.sim.reset(this.ctx.defaults);
|
||||
this.odo = 0;
|
||||
this.actuation.resetStats?.();
|
||||
this.lastPosition.set(
|
||||
this.sim.data.qpos.subarray(this.sim.rootQpos, this.sim.rootQpos + 2),
|
||||
);
|
||||
for (const [name, joint] of this.sim.joints)
|
||||
this.ctx.targets.set(name, this.sim.data.qpos[joint.qpos]);
|
||||
this.fallen = false;
|
||||
this.onStatus({ fallen: false });
|
||||
this.rig.sync();
|
||||
if (running) this.scheduler.start();
|
||||
}
|
||||
triggerAction(action) {
|
||||
if (this.input.isEnabled(action)) this.input.onAction(action);
|
||||
}
|
||||
toggle(id) {
|
||||
for (const [name, j] of this.sim.joints)
|
||||
this.positions.set(name, this.sim.data.qpos[j.qpos]);
|
||||
this.skills.toggle(id, this.sim.data.time, this.positions);
|
||||
}
|
||||
async controlStep() {
|
||||
if (!this.fallen) {
|
||||
this.ctx.command.set(this.input.command);
|
||||
this.obs.write();
|
||||
this.actions.apply(await this.controller.run());
|
||||
this.skills.update(this.sim.data.time, this.ctx.targets);
|
||||
}
|
||||
for (let i = 0; i < this.config.sim.decimation; i++) {
|
||||
this.actuation.apply();
|
||||
this.sim.step();
|
||||
}
|
||||
const q = this.sim.data.qpos,
|
||||
a = this.sim.rootQpos,
|
||||
quat = this.sim.data.xquat,
|
||||
b = this.sim.root * 4,
|
||||
x = quat[b + 1],
|
||||
y = quat[b + 2];
|
||||
const gz = -(1 - 2 * (x * x + y * y));
|
||||
if (
|
||||
!q.every(Number.isFinite) ||
|
||||
!this.sim.data.qvel.every(Number.isFinite) ||
|
||||
!Number.isFinite(gz)
|
||||
)
|
||||
throw new Error("Physics produced non-finite state");
|
||||
if (
|
||||
!this.fallen &&
|
||||
(gz > this.config.termination.tilt_z ||
|
||||
q[a + 2] < this.config.termination.min_height)
|
||||
) {
|
||||
this.fallen = true;
|
||||
this.input.clear();
|
||||
for (const [name, j] of this.sim.joints)
|
||||
this.ctx.targets.set(name, q[j.qpos]);
|
||||
this.onStatus({ fallen: true });
|
||||
}
|
||||
this.odo += Math.hypot(
|
||||
q[a] - this.lastPosition[0],
|
||||
q[a + 1] - this.lastPosition[1],
|
||||
);
|
||||
this.lastPosition[0] = q[a];
|
||||
this.lastPosition[1] = q[a + 1];
|
||||
this.tickCount++;
|
||||
const now = performance.now();
|
||||
if (now - this.hzAt >= 1000) {
|
||||
this.ctrlHz = Math.round((this.tickCount * 1000) / (now - this.hzAt));
|
||||
this.tickCount = 0;
|
||||
this.hzAt = now;
|
||||
}
|
||||
}
|
||||
frame() {
|
||||
if (this.disposed) return;
|
||||
this.rig.sync();
|
||||
if (this.chaseCamera) {
|
||||
const yaw = this.cameraPose();
|
||||
this.worldPresentation?.update(this.follow);
|
||||
this.chaseCamera.update(this.follow, yaw, {
|
||||
turning: Math.abs(this.input.command[2]) > 0.05,
|
||||
});
|
||||
}
|
||||
const now = performance.now();
|
||||
this.frames++;
|
||||
if (now - this.telemetryAt > 250) {
|
||||
const v = this.sim.data.qvel,
|
||||
a = this.sim.rootDof;
|
||||
this.onTelemetry({
|
||||
fps: Math.round((this.frames * 1000) / (now - this.fpsAt)),
|
||||
ctrlHz: this.ctrlHz,
|
||||
speed: Math.hypot(v[a], v[a + 1]),
|
||||
odo: this.odo,
|
||||
peers: 0,
|
||||
});
|
||||
this.telemetryAt = now;
|
||||
}
|
||||
}
|
||||
debug() {
|
||||
const self = this;
|
||||
return {
|
||||
get model() {
|
||||
return self.sim.model;
|
||||
},
|
||||
get data() {
|
||||
return self.sim.data;
|
||||
},
|
||||
mujoco: this.sim.mujoco,
|
||||
camera: this.camera,
|
||||
controls: this.controls,
|
||||
get chaseCam() {
|
||||
return self.chaseCamera.enabled;
|
||||
},
|
||||
scene: this.scene,
|
||||
world: this.world,
|
||||
command: this.input.command,
|
||||
lastAction: this.ctx.lastAction,
|
||||
skills: this.skills,
|
||||
buildObs: () => {
|
||||
this.ctx.command.set(this.input.command);
|
||||
return Object.values(this.obs.write())[0];
|
||||
},
|
||||
pause: () => this.pause(),
|
||||
resume: () => this.resume(),
|
||||
step: (n) => this.scheduler.step(n),
|
||||
resetSim: () => this.reset(),
|
||||
toggle: (id) => this.toggle(id),
|
||||
get fallen() {
|
||||
return self.fallen;
|
||||
},
|
||||
get actuationStats() {
|
||||
const a = self.actuation;
|
||||
return {
|
||||
samples: a.samples ?? 0,
|
||||
saturated: a.saturated ?? 0,
|
||||
saturationRatio: a.samples ? a.saturated / a.samples : 0,
|
||||
longestSaturatedSeconds:
|
||||
(a.maxStreak ?? 0) * self.config.sim.timestep,
|
||||
};
|
||||
},
|
||||
get running() {
|
||||
return self.scheduler.running;
|
||||
},
|
||||
};
|
||||
}
|
||||
async dispose() {
|
||||
if (this.disposed) return;
|
||||
this.disposed = true;
|
||||
this.active = false;
|
||||
await this.scheduler.dispose();
|
||||
this.input.dispose();
|
||||
this.chaseCamera?.dispose();
|
||||
this.controls?.dispose();
|
||||
this.worldPresentation?.dispose();
|
||||
this.rig.dispose();
|
||||
await this.controller.dispose();
|
||||
this.sim.dispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
import * as THREE from "three";
|
||||
import { loadIndex, loadPackage, loadWorld } from "../loader/PackageLoader.js";
|
||||
import { resolveWorldId } from "../worlds/arena.js";
|
||||
// Factories are registered by the application, not selected by robot-id checks.
|
||||
export class RuntimeManager {
|
||||
constructor({
|
||||
scene,
|
||||
camera,
|
||||
renderer,
|
||||
factories,
|
||||
publish,
|
||||
getState,
|
||||
runOnReady = true,
|
||||
}) {
|
||||
Object.assign(this, {
|
||||
scene,
|
||||
camera,
|
||||
renderer,
|
||||
factories,
|
||||
publish,
|
||||
getState,
|
||||
runOnReady,
|
||||
});
|
||||
this.active = null;
|
||||
this.busy = false;
|
||||
this.disposed = false;
|
||||
this.generation = 0;
|
||||
this.memory = new Map();
|
||||
this.pending = Promise.resolve();
|
||||
}
|
||||
async init() {
|
||||
this.entries = await loadIndex();
|
||||
if (this.disposed) return;
|
||||
this.publish({ robots: this.entries });
|
||||
return this.switchTo(this.entries[0].id);
|
||||
}
|
||||
switchTo(id) {
|
||||
if (this.busy || this.disposed) return Promise.resolve(false);
|
||||
this.busy = true;
|
||||
this.retryId = id;
|
||||
this.pending = this.#switch(id).finally(() => {
|
||||
this.busy = false;
|
||||
});
|
||||
return this.pending;
|
||||
}
|
||||
async #switch(id) {
|
||||
const token = ++this.generation,
|
||||
old = this.active,
|
||||
{ paused, fallen } = this.getState();
|
||||
let candidate, root;
|
||||
const previousCamera = this.camera.clone();
|
||||
this.publish({
|
||||
runtimePhase: old ? "switching" : "loading",
|
||||
runtimeError: null,
|
||||
fallen: false,
|
||||
bootFailed: false,
|
||||
});
|
||||
try {
|
||||
if (old) {
|
||||
this.memory.set(old.pkg.config.family, old.runtime.saveSettings?.());
|
||||
await old.runtime.deactivate?.();
|
||||
await old.runtime.pause();
|
||||
}
|
||||
this.publish({ paused });
|
||||
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));
|
||||
const factory = this.factories[pkg.config.adapter];
|
||||
if (!factory)
|
||||
throw new Error(`Unregistered adapter ${pkg.config.adapter}`);
|
||||
root = new THREE.Group();
|
||||
const camera = this.camera.clone();
|
||||
const publish = (patch) => {
|
||||
if (!this.disposed && !this.busy && this.active?.runtime === candidate)
|
||||
this.publish(patch);
|
||||
};
|
||||
candidate = await factory({
|
||||
pkg,
|
||||
world,
|
||||
scene: root,
|
||||
camera,
|
||||
renderer: this.renderer,
|
||||
autoStart: false,
|
||||
publish,
|
||||
onStatus: publish,
|
||||
onTelemetry: (telemetry) => publish({ telemetry }),
|
||||
});
|
||||
await candidate.restoreSettings?.(this.memory.get(pkg.config.family));
|
||||
if (this.disposed || token !== this.generation) {
|
||||
await candidate.dispose();
|
||||
return false;
|
||||
}
|
||||
// Nothing rendering/controlling the candidate was made visible until now.
|
||||
this.camera.copy(camera);
|
||||
candidate.bindCamera?.(this.camera);
|
||||
if (!candidate.bindCamera) candidate.camera = this.camera;
|
||||
this.scene.add(root);
|
||||
this.active = { runtime: candidate, root, pkg };
|
||||
candidate.activate({ paused: true });
|
||||
window.rl = candidate.debug();
|
||||
this.publish({
|
||||
runtimePhase: old ? "switching" : "loading",
|
||||
runtimeError: null,
|
||||
bootDone: true,
|
||||
bootFailed: false,
|
||||
paused,
|
||||
robotId: pkg.config.id,
|
||||
presentationTheme: pkg.config.presentation.theme,
|
||||
robotLicense: pkg.config.license,
|
||||
inputBindings: pkg.config.input.bindings,
|
||||
runtimeCapabilities: {},
|
||||
actuationLabel: "",
|
||||
fallen: false,
|
||||
...candidate.status?.(),
|
||||
});
|
||||
if (old) {
|
||||
old.root.removeFromParent();
|
||||
await old.runtime
|
||||
.dispose()
|
||||
.catch((error) => console.error("[retired cleanup]", error));
|
||||
}
|
||||
if (this.disposed) return false;
|
||||
this.publish({ runtimePhase: "ready" });
|
||||
if (!paused && this.runOnReady) candidate.resume();
|
||||
return true;
|
||||
} catch (error) {
|
||||
if (candidate) await candidate.dispose().catch(console.error);
|
||||
root?.removeFromParent();
|
||||
this.active = old;
|
||||
if (this.disposed) return false;
|
||||
this.camera.copy(previousCamera);
|
||||
// Keep a known-good instance even when compilation or inference failed.
|
||||
if (old) {
|
||||
this.active = old;
|
||||
old.runtime.reactivate({ paused });
|
||||
window.rl = old.runtime.debug();
|
||||
}
|
||||
this.publish({
|
||||
runtimePhase: old ? "ready" : "error",
|
||||
paused,
|
||||
runtimeError: error.message,
|
||||
fallen,
|
||||
bootFailed: !old,
|
||||
bootDone: !!old,
|
||||
});
|
||||
console.error("[package load]", error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
frame(dt) {
|
||||
this.active?.runtime.frame?.(dt);
|
||||
}
|
||||
async pause() {
|
||||
if (this.busy || this.disposed) return;
|
||||
await this.active?.runtime.pause();
|
||||
this.publish({ paused: true });
|
||||
}
|
||||
resume() {
|
||||
if (this.busy || this.disposed) return;
|
||||
this.active?.runtime.resume();
|
||||
this.publish({ paused: false });
|
||||
}
|
||||
async reset() {
|
||||
if (this.busy || this.disposed) return;
|
||||
try {
|
||||
await this.active?.runtime.reset();
|
||||
} catch (e) {
|
||||
this.publish({ runtimeError: e.message });
|
||||
}
|
||||
}
|
||||
retry() {
|
||||
return this.entries
|
||||
? this.switchTo(this.retryId ?? this.entries[0]?.id)
|
||||
: this.init();
|
||||
}
|
||||
async dispose() {
|
||||
if (this.disposed) return;
|
||||
this.disposed = true;
|
||||
this.generation++;
|
||||
await this.pending;
|
||||
const active = this.active;
|
||||
this.active = null;
|
||||
if (active) {
|
||||
active.root.removeFromParent();
|
||||
await active.runtime.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// Timers advance only with simulation control intervals. UI/render clocks
|
||||
// remain wall-clock driven and are deliberately not part of this class.
|
||||
export class SimulationClock {
|
||||
time = 0;
|
||||
#next = 0;
|
||||
#timers = new Map();
|
||||
setTimeout(callback, milliseconds) {
|
||||
const id = ++this.#next;
|
||||
this.#timers.set(id, { due: this.time + milliseconds, callback });
|
||||
return id;
|
||||
}
|
||||
clearTimeout(id) {
|
||||
this.#timers.delete(id);
|
||||
}
|
||||
advance(seconds) {
|
||||
if (!(seconds >= 0 && Number.isFinite(seconds)))
|
||||
throw new Error("Invalid clock dt");
|
||||
this.time += seconds * 1000;
|
||||
for (const [id, timer] of [...this.#timers]) {
|
||||
if (timer.due <= this.time + 1e-8) {
|
||||
this.#timers.delete(id);
|
||||
timer.callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
reset() {
|
||||
this.time = 0;
|
||||
this.#timers.clear();
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user