@hackbuild/humanoid 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Moheeb Zara
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,158 @@
1
- # Temporary Holding Version
1
+ # @hackbuild/humanoid
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Run a physics humanoid in the page: MuJoCo simulates a robot from its MJCF files, NVIDIA's GEAR-SONIC policy balances the Unitree G1, and you pose it, shove it and draw it.
4
+
5
+ [![npm](https://img.shields.io/npm/v/@hackbuild/humanoid)](https://www.npmjs.com/package/@hackbuild/humanoid) [![licence MIT](https://img.shields.io/badge/licence-MIT-blue)](../../LICENSE) ![gzip 6.0 kB measured](https://img.shields.io/badge/gzip-6.0%20kB-blue) ![types included](https://img.shields.io/badge/types-included-blue)
6
+
7
+ ## What it does
8
+
9
+ - Loads MuJoCo, Google DeepMind's WebAssembly build (`@mujoco/mujoco`, single threaded, so the page needs no cross-origin isolation), at run time: from a factory your bundler imports, or from a URL. It is never bundled.
10
+ - Reads a robot from the URL of its MJCF or from a dropped folder, with every file the MJCF names (includes, meshes, textures), keyed the way MuJoCo's virtual file system asks for them; files that do not arrive are listed.
11
+ - Steps the robot at the model's own timestep however the page's frames fall, resets it to a keyframe, writes joint targets to its position actuators, holds its current pose, shoves it, and reads any body's world pose.
12
+ - Draws it in three.js from the `./three` subpath: one mesh per visible geom, MuJoCo's meshes shared, turned from MuJoCo's z up into y up with the robot facing +Z.
13
+ - Names the Unitree G1 (29 joints) from MuJoCo Menagerie, pinned to one commit, as a ready robot; its files load from GitHub at run time.
14
+ - Runs GEAR-SONIC, NVIDIA's whole body controller for the G1, from the `./sonic` subpath: an encoder and a decoder 50 times a second through onnxruntime-web and a PD loop at every MuJoCo step, so the G1 stands, holds a crouch or a raised arm, and steps to catch a shove. The weights load from Hugging Face at run time.
15
+
16
+ ## Install
17
+
18
+ ```sh
19
+ npm install @hackbuild/humanoid
20
+ ```
21
+
22
+ It has no dependencies. MuJoCo, onnxruntime-web and three.js are optional peers: install `@mujoco/mujoco` to import its factory, or let `loadMujoco` load it from `https://cdn.jsdelivr.net/npm/@mujoco/mujoco@4.0.1/mujoco.js`, with `mujoco.wasm` read beside it. `onLicence` receives the line to show. The G1's files come from GitHub when you load it.
23
+
24
+ | download | size |
25
+ |---|---|
26
+ | mujoco.wasm | 11.2 MB, 2.8 MB gzip (measured) |
27
+ | the G1's meshes | 19.7 MB (vendor) |
28
+ | GEAR-SONIC encoder and decoder | 91.0 MB (vendor), from Hugging Face, pinned to one revision |
29
+
30
+ `Sonic.load` loads onnxruntime-web from jsDelivr when you pass no `ort` module, and the policy files from their pinned URLs when you pass no bytes.
31
+
32
+ ## Quick start
33
+
34
+ ```ts
35
+ import * as THREE from "three";
36
+ import { G1, Humanoid, fetchModel, loadMujoco } from "@hackbuild/humanoid";
37
+ import { HumanoidView } from "@hackbuild/humanoid/three";
38
+
39
+ const renderer = new THREE.WebGLRenderer({ antialias: true });
40
+ renderer.setSize(innerWidth, innerHeight);
41
+ document.body.append(renderer.domElement);
42
+ const scene = new THREE.Scene().add(new THREE.HemisphereLight(0xffffff, 0x887766, 2));
43
+ const camera = new THREE.PerspectiveCamera(35, innerWidth / innerHeight, 0.05, 50).translateZ(2.6).translateY(0.8);
44
+
45
+ // mujoco loads from jsdelivr and the g1's files from github, at run time
46
+ const mj = await loadMujoco({ onLicence: (line) => console.info(line) });
47
+ const robot = Humanoid.open(mj, await fetchModel(G1.url));
48
+ robot.reset(G1.keyframe); // upright, arms down
49
+ const view = new HumanoidView(robot);
50
+ scene.add(view.root);
51
+ // bend the knees through the position actuators, eased over 0.8 s
52
+ robot.moveTo({ left_knee_joint: 0.6, right_knee_joint: 0.6, left_hip_pitch_joint: -0.3, right_hip_pitch_joint: -0.3 }, 0.8);
53
+ renderer.setAnimationLoop(() => (robot.step(1 / 60), view.update(), renderer.render(scene, camera)));
54
+ ```
55
+
56
+ ## Live example
57
+
58
+ The demo page loads MuJoCo and the G1 when you press load, then stands it, crouches it, raises an arm and shoves it: [hackbuild-motion/humanoid](https://hackbuild.github.io/hackbuild-motion/humanoid/).
59
+
60
+ ## Concepts
61
+
62
+ ### the runtime
63
+
64
+ MuJoCo is Google DeepMind's physics engine, compiled to WebAssembly and published as `@mujoco/mujoco` under Apache-2.0. This package uses its single threaded build and never ships it. Every handle MuJoCo makes lives on the wasm heap, so `Humanoid.dispose()` frees the model and its data.
65
+
66
+ ### the files
67
+
68
+ An MJCF names other files relative to its compiler's directories: `meshdir` or `assetdir` for meshes, `texturedir` for textures, and includes by their own path. `fetchModel` reads the main file, follows includes, then fetches every named file beside the main one; `filesFrom` does the same over a dropped folder, taking the MJCF with a worldbody that no other file includes as the main one.
69
+
70
+ ### the policy
71
+
72
+ GEAR-SONIC turns a reference motion into a token (the encoder) and the token plus ten ticks of the robot's state into 29 joint actions (the decoder), 50 times a second; `SonicDriver` turns actions into joint targets (default angle plus action times the joint's action scale) and a PD loop into motor torques at every timestep. It needs the deploy model, `G1_SONIC`, whose joints are on motors; the menagerie G1's position actuators do not take it. `reference` is the pose it tracks, absolute angles in the model's joint order: the standing angles by default, or a crouch, or an arm raised. The code is written from NVIDIA's published deployment description and parameters; the details it leaves open (joint positions relative to the defaults, the reference absolute, histories oldest first, rotations read row by row, the anchor as the base's tilt against an upright reference) were settled by trial on the deploy model, where only that combination stands.
73
+
74
+ ### the robot
75
+
76
+ `Humanoid.open` compiles the files in MuJoCo's virtual file system. `targets` is the actuators' control array, a live view: for a position actuator it is the joint's target angle. `moveTo` eases targets in over simulated time; a sudden jump can topple a robot that a ramp of half a second leaves standing. `step(seconds)` runs whole timesteps and carries the remainder, at most 0.1 s a call, so a slow frame does not run away. Poses come back in MuJoCo's frame: z up, meters, quaternions w x y z.
77
+
78
+ ## API overview
79
+
80
+ | export | what it does |
81
+ |---|---|
82
+ | [`loadMujoco`](../../docs/api/humanoid/index.md#loadmujoco) | load MuJoCo once, from a factory or a URL |
83
+ | [`fetchModel`](../../docs/api/humanoid/index.md#fetchmodel) | a robot's files from the URL of its MJCF |
84
+ | [`filesFrom`](../../docs/api/humanoid/index.md#filesfrom) | a robot's files from a dropped folder |
85
+ | [`referencedFiles`](../../docs/api/humanoid/index.md#referencedfiles) | the includes and files one MJCF names |
86
+ | [`Humanoid`](../../docs/api/humanoid/index.md#humanoid) | step, reset, targets, moveTo, hold, push, poses, dispose |
87
+ | [`G1`](../../docs/api/humanoid/index.md#g1) | the Unitree G1 from MuJoCo Menagerie: url, joints, keyframe, licence |
88
+ | [`HumanoidView`](../../docs/api/humanoid/three.md#humanoidview) | the robot in three.js, from `@hackbuild/humanoid/three` |
89
+ | [`Sonic`](../../docs/api/humanoid/sonic.md#sonic) | load the GEAR-SONIC policy, from `@hackbuild/humanoid/sonic` |
90
+ | [`SonicDriver`](../../docs/api/humanoid/sonic.md#sonicdriver) | run it on a G1: advance, reference, reset |
91
+ | [`G1_SONIC`](../../docs/api/humanoid/sonic.md#g1_sonic) | the G1 deploy model the policy runs on: url, asset host, licence |
92
+ | [`SONIC_JOINTS`](../../docs/api/humanoid/sonic.md#sonic_joints) | standing angles, gains, torque limits, action scale and policy order per joint |
93
+ | [`HumanoidError`](../../docs/api/humanoid/index.md#humanoiderror) | a model or runtime this package cannot open, with the reason |
94
+
95
+ The full reference is in [docs/api/humanoid](../../docs/api/humanoid/README.md).
96
+
97
+ ## Browser support
98
+
99
+ | feature | needs | notes |
100
+ |---|---|---|
101
+ | MuJoCo | WebAssembly, a network fetch or the installed package | 206 ms to load from a local copy in headless Chrome on an Apple M1 (measured) |
102
+ | stepping | nothing more | 0.084 ms per 2 ms step for the G1, about 24 times real time (measured) |
103
+ | the policy | onnxruntime-web on wasm, one thread | 5.7 ms a 20 ms tick in headless Chrome on an Apple M1 (measured) |
104
+ | drawing | three.js 0.186 or later, WebGL | the G1 draws 35 meshes |
105
+ | single file build | `dist/humanoid.iife.js` | `HackbuildHumanoid` global with `THREE` from the page; MuJoCo still loads from its URL |
106
+
107
+ ## Errors and troubleshooting
108
+
109
+ | message | cause | what to do |
110
+ |---|---|---|
111
+ | `mujoco did not load from ...` | offline, or the URL is blocked | install `@mujoco/mujoco` and pass its factory, or serve it and pass `url` |
112
+ | `no actuator drives ... load the g1 deploy model` | the policy was given the menagerie G1 | load `G1_SONIC.url` with `assetBase: G1_SONIC.assetBase` |
113
+ | `onnxruntime-web did not load from ...` | offline, or jsDelivr is blocked | install `onnxruntime-web` and pass the module as `ort` |
114
+ | `mujoco could not compile the model: ...` | a named file is missing or the MJCF is invalid | keep the robot's folder structure; the message names files that did not arrive |
115
+ | `the model has no keyframe ...` | a keyframe name the model lacks | use one from `keyframes` |
116
+ | `no mjcf here` | the drop holds no MJCF with a worldbody | drop the robot's whole folder |
117
+
118
+ ## Works with
119
+
120
+ - [@hackbuild/avatar](../avatar/README.md) loads the VRM a later release will move with the robot's bodies.
121
+ - [@hackbuild/environment](../environment/README.md) gives the robot a lit set to stand in.
122
+
123
+ ## Changelog and licences
124
+
125
+ Changes are in the repository [CHANGELOG](../../CHANGELOG.md). Code is MIT ([LICENSE](../../LICENSE)); this README is CC-BY-4.0 with its code samples also MIT. MuJoCo is Google DeepMind's, Apache-2.0, and loads at run time. The G1 model and meshes are from MuJoCo Menagerie under BSD-3-Clause, copyright Unitree Robotics, and load at run time; the deploy model is from NVIDIA's GR00T-WholeBodyControl (Apache-2.0) with Unitree's meshes. The GEAR-SONIC weights are NVIDIA's: licensed by NVIDIA Corporation under the NVIDIA Open Model License; they load from Hugging Face at run time and are not part of this package. Robots you bring carry their own licences.
126
+
127
+ ## What is verified, and what is not
128
+
129
+ ### Verified on this machine
130
+
131
+ | check | result |
132
+ |---|---|
133
+ | `npx vitest run packages/humanoid` | 14 of 14 tests pass: the 7 below, and for the policy the gains and action scale from motor armature, the policy joint order, gravity in the body frame, the anchor ignoring heading, the encoder and decoder layouts, ten ticks oldest first, a driver on a 29 joint model with a stand in runtime, and the refusal of a robot without the G1's joints (counted) |
134
+ | the 7 runtime and view tests | 7 of 7 tests pass on MuJoCo 4.0.1 in node: references and compiler directories, a dropped folder with an include and a missing mesh, compiling through the virtual files, names, uneven frames stepped at the timestep, a fall under gravity, a keyframe's pose and controls, an actuator reaching its target, an eased move, hold, a push, the compile error naming missing files, the three.js view's meshes and their motion (counted) |
135
+ | the G1 from MuJoCo Menagerie in headless Chrome on an Apple M1 | MuJoCo loads in 206 ms, the G1's 36 files (19.7 MB) arrive in 886 ms with none missing, it compiles with 29 actuated joints and draws 35 meshes; on its stand keyframe the pelvis holds 0.792 m for 5 s; 0.084 ms per step (measured) |
136
+ | the demo page's own check, headless, MuJoCo from jsDelivr | loads in 362 ms, the G1's files in 528 ms; it stands at 0.792 m and eases into a crouch at 0.671 m at 59.9 frames a second (measured) |
137
+ | GEAR-SONIC on the deploy G1 in node, MuJoCo 4.0.1 and onnxruntime-web 1.23.2 | of seven guesses at the open layout details only one stands; with the tilt anchor it stands 30 s at 0.766 m within 1.1 degrees, steps 0.5 m to catch a 1.0 m/s shove and catches 1.5 m/s, where the position actuators alone fall at 0.3 m/s; it holds a crouch at 0.680 m and a raised arm; 2.6 to 4.5 ms a tick, 15 s simulated in 4.5 s (measured) |
138
+ | the demo page's policy check, headless Chrome | MuJoCo in 332 ms, the deploy G1 in 527 ms, the policy in 3,368 ms; it stands at 0.766 m and is at 0.766 m 4 s after a 1 m/s shove, at 59.9 frames a second, 5.7 ms a tick (measured) |
139
+ | crouches and shoves on the G1 in node | eased over 0.5 s or more, crouches from hips -0.2 to -0.6 radians all hold (pelvis 0.778 to 0.671 m); the same targets set at once topple it at two depths of five; a 0.3 m/s shove topples it (measured) |
140
+
141
+ ### Not verified by anything
142
+
143
+ - The policy tracks static poses only: no reference motion, walking command or the 774 MB planner runs, and the low latency and v1.1 variants are untried.
144
+ - On its actuators alone (no policy) the robot holds targets but does not balance; a shove topples it.
145
+ - No VRM follows the robot yet.
146
+ - Robots other than the G1 and the test model are untried, and so are textures in MJCF.
147
+ - Nobody has watched it at real frame rate in a visible browser; the checks are headless.
148
+
149
+ ## Size budget
150
+
151
+ | file | gzip (measured) | ceiling |
152
+ |---|---|---|
153
+ | `dist/index.js` (main entry, imports external) | 6,006 bytes | 6,306 bytes |
154
+ | `dist/humanoid.iife.js` (single file build) | 12,044 bytes | 12,646 bytes |
155
+
156
+ Measured 2026-11-30 by `node tools/lint-packages.mjs` (gzip level 9) from the packed
157
+ tarball. Generated from `tools/size-budget.json`; CI fails when a file moves more than
158
+ 5 percent from its row.
@@ -0,0 +1,38 @@
1
+ /**
2
+ * A robot as files: its MJCF and every file it names (included MJCF, meshes,
3
+ * textures, height fields, skins), from a URL or from files the person
4
+ * dropped. Paths are keyed the way MuJoCo looks them up in its virtual file
5
+ * system: an include by its own path, a mesh by meshdir (or assetdir) and
6
+ * its file, a texture by texturedir and its file. A file that does not
7
+ * arrive is listed in `missing`.
8
+ */
9
+ /** A robot's main MJCF and the files it names. */
10
+ export interface ModelFiles {
11
+ /** The main MJCF's text. */
12
+ xml: string;
13
+ /** Every other file by the path MuJoCo asks for. */
14
+ assets: Map<string, Uint8Array>;
15
+ /** Paths the MJCF names that did not arrive. */
16
+ missing: string[];
17
+ }
18
+ /** The files one MJCF names, split into includes and the rest, joined onto its compiler's directories. */
19
+ export declare function referencedFiles(xml: string, dirs?: {
20
+ meshdir?: string;
21
+ texturedir?: string;
22
+ assetdir?: string;
23
+ }): {
24
+ includes: string[];
25
+ files: string[];
26
+ };
27
+ /**
28
+ * A robot from the URL of its main MJCF; every file it names is fetched beside it, or for files that
29
+ * are not MJCF beside `assetBase` when given (a repository whose meshes live on another host, such as
30
+ * Git LFS).
31
+ */
32
+ export declare function fetchModel(url: string, o?: {
33
+ fetch?: typeof fetch;
34
+ assetBase?: string;
35
+ onFile?: (path: string, done: number, of: number) => void;
36
+ }): Promise<ModelFiles>;
37
+ /** A robot from dropped files (a folder keeps its paths): the main MJCF is the one with a worldbody that no other file includes. */
38
+ export declare function filesFrom(list: Iterable<File>): Promise<ModelFiles>;
package/dist/files.js ADDED
@@ -0,0 +1,130 @@
1
+ /**
2
+ * A robot as files: its MJCF and every file it names (included MJCF, meshes,
3
+ * textures, height fields, skins), from a URL or from files the person
4
+ * dropped. Paths are keyed the way MuJoCo looks them up in its virtual file
5
+ * system: an include by its own path, a mesh by meshdir (or assetdir) and
6
+ * its file, a texture by texturedir and its file. A file that does not
7
+ * arrive is listed in `missing`.
8
+ */
9
+ import { HumanoidError } from "./runtime.js";
10
+ const attrs = (tag) => Object.fromEntries([...tag.matchAll(/([A-Za-z_]+)\s*=\s*"([^"]*)"/g)].map((m) => [m[1], m[2]]));
11
+ const join = (dir, file) => (dir ? `${dir.replace(/\/+$/, "")}/${file}` : file).replace(/^\.\//, "");
12
+ /** The files one MJCF names, split into includes and the rest, joined onto its compiler's directories. */
13
+ export function referencedFiles(xml, dirs = {}) {
14
+ const d = { ...dirs };
15
+ for (const m of xml.matchAll(/<compiler\b[^>]*>/g)) {
16
+ const a = attrs(m[0]);
17
+ if (a.meshdir !== undefined)
18
+ d.meshdir = a.meshdir;
19
+ if (a.texturedir !== undefined)
20
+ d.texturedir = a.texturedir;
21
+ if (a.assetdir !== undefined)
22
+ d.assetdir = a.assetdir;
23
+ }
24
+ const includes = [...xml.matchAll(/<include\b[^>]*>/g)].map((m) => attrs(m[0]).file).filter((f) => !!f);
25
+ const files = [];
26
+ for (const m of xml.matchAll(/<(mesh|skin|hfield|texture)\b[^>]*>/g)) {
27
+ const f = attrs(m[0]).file;
28
+ if (!f)
29
+ continue;
30
+ const dir = m[1] === "texture" ? (d.texturedir ?? d.assetdir) : (d.meshdir ?? d.assetdir);
31
+ files.push(join(dir, f));
32
+ }
33
+ return { includes, files: [...new Set(files)] };
34
+ }
35
+ /** Compiler directories set anywhere in a set of MJCF texts: an included file's compiler applies to the whole model. */
36
+ function dirsOf(xmls) {
37
+ const d = {};
38
+ for (const x of xmls)
39
+ for (const m of x.matchAll(/<compiler\b[^>]*>/g)) {
40
+ const a = attrs(m[0]);
41
+ if (a.meshdir !== undefined)
42
+ d.meshdir = a.meshdir;
43
+ if (a.texturedir !== undefined)
44
+ d.texturedir = a.texturedir;
45
+ if (a.assetdir !== undefined)
46
+ d.assetdir = a.assetdir;
47
+ }
48
+ return d;
49
+ }
50
+ /** Reads an MJCF and everything it names through `read`, includes first; a file `read` cannot give is listed as missing. */
51
+ async function gather(main, read, onFile) {
52
+ const dec = new TextDecoder();
53
+ const first = await read(main);
54
+ if (!first)
55
+ throw new HumanoidError(`the model file ${main} did not load.`);
56
+ const xml = dec.decode(first);
57
+ const assets = new Map();
58
+ const missing = [];
59
+ const texts = [xml];
60
+ // includes, breadth first; each may include more
61
+ const queue = [...referencedFiles(xml).includes];
62
+ while (queue.length) {
63
+ const inc = queue.shift();
64
+ if (assets.has(inc))
65
+ continue;
66
+ const b = await read(inc);
67
+ if (!b) {
68
+ missing.push(inc);
69
+ continue;
70
+ }
71
+ assets.set(inc, b);
72
+ const t = dec.decode(b);
73
+ texts.push(t);
74
+ queue.push(...referencedFiles(t).includes);
75
+ }
76
+ const dirs = dirsOf(texts);
77
+ const wanted = [...new Set(texts.flatMap((t) => referencedFiles(t, dirs).files))].filter((f) => !assets.has(f));
78
+ let done = 0;
79
+ await Promise.all(wanted.map(async (f) => {
80
+ const b = await read(f);
81
+ if (b)
82
+ assets.set(f, b);
83
+ else
84
+ missing.push(f);
85
+ onFile?.(f, ++done, wanted.length);
86
+ }));
87
+ return { xml, assets, missing };
88
+ }
89
+ /**
90
+ * A robot from the URL of its main MJCF; every file it names is fetched beside it, or for files that
91
+ * are not MJCF beside `assetBase` when given (a repository whose meshes live on another host, such as
92
+ * Git LFS).
93
+ */
94
+ export function fetchModel(url, o = {}) {
95
+ const f = o.fetch ?? globalThis.fetch.bind(globalThis);
96
+ const here = globalThis.location?.href;
97
+ const base = new URL(url, here);
98
+ const assets = o.assetBase ? new URL(o.assetBase.endsWith("/") ? o.assetBase : `${o.assetBase}/`, here) : base;
99
+ const read = async (path) => {
100
+ try {
101
+ const r = await f(path === url ? base.href : new URL(path, /\.xml$/i.test(path) ? base : assets).href);
102
+ return r.ok ? new Uint8Array(await r.arrayBuffer()) : null;
103
+ }
104
+ catch {
105
+ return null;
106
+ }
107
+ };
108
+ return gather(url, read, o.onFile);
109
+ }
110
+ /** A robot from dropped files (a folder keeps its paths): the main MJCF is the one with a worldbody that no other file includes. */
111
+ export async function filesFrom(list) {
112
+ const files = new Map();
113
+ for (const f of list)
114
+ files.set((f.webkitRelativePath || f.name).replace(/\\/g, "/"), f);
115
+ // paths relative to the folder that holds the main file
116
+ const xmls = [...files.keys()].filter((p) => /\.xml$/i.test(p));
117
+ const texts = new Map();
118
+ for (const p of xmls)
119
+ texts.set(p, await files.get(p).text());
120
+ const included = new Set([...texts].flatMap(([p, t]) => referencedFiles(t).includes.map((i) => join(p.split("/").slice(0, -1).join("/"), i))));
121
+ const main = xmls.filter((p) => !included.has(p) && /<worldbody/.test(texts.get(p))).sort((a, b) => a.split("/").length - b.split("/").length || a.length - b.length)[0];
122
+ if (!main)
123
+ throw new HumanoidError("no mjcf here: drop the robot's folder, with an .xml that has a worldbody.");
124
+ const root = main.split("/").slice(0, -1).join("/");
125
+ const read = async (path) => {
126
+ const f = files.get(path === main ? main : join(root, path));
127
+ return f ? new Uint8Array(await f.arrayBuffer()) : null;
128
+ };
129
+ return gather(main, read);
130
+ }
package/dist/g1.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The Unitree G1 (29 joints) from MuJoCo Menagerie, pinned to one commit:
3
+ * its scene, model and 35 meshes load at run time from GitHub and are not
4
+ * part of this library. The model holds its pose with position actuators;
5
+ * its keyframe "stand" is the robot upright with its arms down.
6
+ */
7
+ /** The G1 from MuJoCo Menagerie, by URL, with its licence and download size. */
8
+ export declare const G1: {
9
+ readonly name: "unitree g1, 29 joints";
10
+ /** The scene (floor and light) that includes the robot, at menagerie commit 98a70c5. */
11
+ readonly url: "https://raw.githubusercontent.com/google-deepmind/mujoco_menagerie/98a70c569c4c1b6da467a20012f766ee1f8dc521/unitree_g1/scene.xml";
12
+ readonly licence: "unitree g1 model and meshes from mujoco menagerie, bsd-3-clause, copyright unitree robotics. they load at run time and are not part of this library.";
13
+ /** The meshes the model uses, in bytes (vendor: GitHub's sizes). */
14
+ readonly bytes: 19666440;
15
+ readonly keyframe: "stand";
16
+ /** The 29 actuated joints in the model's order: legs, waist, arms. */
17
+ readonly joints: readonly ["left_hip_pitch_joint", "left_hip_roll_joint", "left_hip_yaw_joint", "left_knee_joint", "left_ankle_pitch_joint", "left_ankle_roll_joint", "right_hip_pitch_joint", "right_hip_roll_joint", "right_hip_yaw_joint", "right_knee_joint", "right_ankle_pitch_joint", "right_ankle_roll_joint", "waist_yaw_joint", "waist_roll_joint", "waist_pitch_joint", "left_shoulder_pitch_joint", "left_shoulder_roll_joint", "left_shoulder_yaw_joint", "left_elbow_joint", "left_wrist_roll_joint", "left_wrist_pitch_joint", "left_wrist_yaw_joint", "right_shoulder_pitch_joint", "right_shoulder_roll_joint", "right_shoulder_yaw_joint", "right_elbow_joint", "right_wrist_roll_joint", "right_wrist_pitch_joint", "right_wrist_yaw_joint"];
18
+ };
package/dist/g1.js ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The Unitree G1 (29 joints) from MuJoCo Menagerie, pinned to one commit:
3
+ * its scene, model and 35 meshes load at run time from GitHub and are not
4
+ * part of this library. The model holds its pose with position actuators;
5
+ * its keyframe "stand" is the robot upright with its arms down.
6
+ */
7
+ /** The G1 from MuJoCo Menagerie, by URL, with its licence and download size. */
8
+ export const G1 = {
9
+ name: "unitree g1, 29 joints",
10
+ /** The scene (floor and light) that includes the robot, at menagerie commit 98a70c5. */
11
+ url: "https://raw.githubusercontent.com/google-deepmind/mujoco_menagerie/98a70c569c4c1b6da467a20012f766ee1f8dc521/unitree_g1/scene.xml",
12
+ licence: "unitree g1 model and meshes from mujoco menagerie, bsd-3-clause, copyright unitree robotics. they load at run time and are not part of this library.",
13
+ /** The meshes the model uses, in bytes (vendor: GitHub's sizes). */
14
+ bytes: 19_666_440,
15
+ keyframe: "stand",
16
+ /** The 29 actuated joints in the model's order: legs, waist, arms. */
17
+ joints: [
18
+ "left_hip_pitch_joint", "left_hip_roll_joint", "left_hip_yaw_joint", "left_knee_joint", "left_ankle_pitch_joint", "left_ankle_roll_joint",
19
+ "right_hip_pitch_joint", "right_hip_roll_joint", "right_hip_yaw_joint", "right_knee_joint", "right_ankle_pitch_joint", "right_ankle_roll_joint",
20
+ "waist_yaw_joint", "waist_roll_joint", "waist_pitch_joint",
21
+ "left_shoulder_pitch_joint", "left_shoulder_roll_joint", "left_shoulder_yaw_joint", "left_elbow_joint", "left_wrist_roll_joint", "left_wrist_pitch_joint", "left_wrist_yaw_joint",
22
+ "right_shoulder_pitch_joint", "right_shoulder_roll_joint", "right_shoulder_yaw_joint", "right_elbow_joint", "right_wrist_roll_joint", "right_wrist_pitch_joint", "right_wrist_yaw_joint",
23
+ ],
24
+ };