Implementation:Google deepmind Mujoco USD MJCF File Format
| 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
- Repository: Google_deepmind_Mujoco
- File: src/experimental/usd/plugins/mjcf/mjcf_file_format.cc
- Lines: 1-294
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 |