Add WASM binding for mj_compile.

It does not support model assets management via VFS yet.

PiperOrigin-RevId: 844864882
Change-Id: I422d7896ed024fc6f5c3fa923a58cdc9059f3bee
This commit is contained in:
Google DeepMind
2025-12-15 11:56:41 -08:00
committed by Copybara-Service
parent eef71832db
commit 477a14dcb2
4 changed files with 46 additions and 1 deletions
+24
View File
@@ -1802,4 +1802,28 @@ describe('MuJoCo WASM Bindings', () => {
unlinkXMLFile(tempXmlFilename);
}
});
it('should compile a spec from XML string', () => {
let spec = null;
let model = null;
try {
spec = mujoco.parseXMLString(TEST_XML);
expect(spec).not.toBeNull();
model = mujoco.mj_compile(spec);
expect(model).not.toBeNull();
expect(model.nq).toBeGreaterThan(0);
const jointId =
mujoco.mj_name2id(model, mujoco.mjtObj.mjOBJ_JOINT.value, 'myhinge');
expect(jointId).toBeGreaterThanOrEqual(0);
} finally {
if (spec) {
spec.delete();
}
if (model) {
model.delete();
}
}
});
});