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 USD MJCF File Format

From Leeroopedia
Knowledge Sources
Domains USD, File Format Plugin
Last Updated 2026-02-15 04:00 GMT

Overview

Implements a USD file format plugin that enables transparent loading of MJCF (.xml) MuJoCo model files as USD stages through the Pixar USD asset resolution framework.

Description

mjcf_file_format.cc registers UsdMjcfFileFormat as an SdfFileFormat plugin with the USD TfType system, enabling USD to natively open MJCF XML files. When USD resolves a .xml asset, this plugin reads the file, parses it using tinyxml2, invokes the MuJoCo-to-USD conversion pipeline (mujoco_to_usd), and populates an SdfLayer with the resulting USD data. The file includes path resolution logic via IsAbsolutePath which handles scheme-based URIs, platform path separators, and MuJoCo resource provider paths. Error handling uses the USD TfEnum registry for structured error codes.

Usage

Loaded as a USD plugin at runtime. Once registered, any USD application can open MuJoCo MJCF files directly (e.g., UsdStage::Open("model.xml")) and the plugin will automatically convert the MJCF content to a USD representation on the fly.

Code Reference

Source Location

Key Functions

TF_DEFINE_PUBLIC_TOKENS(UsdMjcfFileFormatTokens, USD_MJCF_FILE_FORMAT_TOKENS);
TF_REGISTRY_FUNCTION(TfType) { SDF_DEFINE_FILE_FORMAT(UsdMjcfFileFormat, SdfFileFormat); }
enum ErrorCodes { XmlParsingError };
bool IsAbsolutePath(const std::string& path);
// SdfFileFormat::Read implementation using tinyxml2 + mujoco_to_usd

Import

#include "mjcf/mjcf_file_format.h"

I/O Contract

Inputs

Name Type Required Description
filePath std::string Yes Path to the MJCF .xml file to load
layer SdfLayerHandle Yes USD layer to populate with converted data

Outputs

Name Type Description
Populated layer SdfLayer USD layer containing the converted MuJoCo model hierarchy
bool bool Success/failure of the file format read operation

Related Pages

Page Connections

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