Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Google deepmind Mujoco MjModel from xml path

From Leeroopedia
Knowledge Sources
Domains Physics_Simulation, Python_API, Model_IO
Last Updated 2026-02-15 06:00 GMT

Overview

Wrapper for loading MuJoCo models via the official Python bindings package used as the CPU-side entry point for MJX workflows.

Description

The mujoco.MjModel.from_xml_path class method loads an MJCF XML model file and returns a Python MjModel object. This wraps the C mj_loadXML function and provides Pythonic attribute access to all model fields. This is the standard way to load models in MJX pipelines before GPU transfer.

Usage

Call as the first step in MJX workflows. The returned MjModel is passed to mjx.put_model for GPU transfer.

External Reference

Code Reference

Source Location

  • Repository: External (mujoco Python bindings pip package)
  • File: Part of the mujoco pip package (not in this repository)

Signature

@classmethod
def MjModel.from_xml_path(path: str) -> mujoco.MjModel

Import

import mujoco

I/O Contract

Inputs

Name Type Required Description
path str Yes Filesystem path to MJCF XML model file

Outputs

Name Type Description
return mujoco.MjModel CPU-resident model object wrapping C mjModel struct

Usage Examples

import mujoco
import mujoco.mjx as mjx

# Load model on CPU
model = mujoco.MjModel.from_xml_path("humanoid.xml")

# Transfer to GPU for MJX
mx = mjx.put_model(model)

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment