File Format Plugin#
What is an SdfFileFormat plugin?#
In the OpenUSD framework, Sdf stands for Scene Description Foundations. It’s the underlying layer that handles the
serialization and composition of scene data. A SdfFileFormat plugin is a component that teaches USD how to read and
write a specific file format.
By default, USD comes with plugins for its own formats (.usda, .usdc, .usdz) and the community has created
several plugin extension such as the Adobe File Format Plugins.
The MJCF SdfFileFormat plugin allows USD-aware applications to directly understand and interact with MuJoCo’s native
.xml (MJCF) files as if they were native USD files.
What does it enable?#
This plugin enables:
Referencing MJCF files in USD: Using standard USD composition arcs (like references, payloads) to include an MJCF file directly within a larger USD scene. For example, you can place a MuJoCo robot defined in an
.xmlfile into a room scene modeled in USD.Load MJCF files in USD tools: Tools like
usdviewor other USD-based applications can open, inspect, and render MJCF files, translating the MJCF elements into USD prims and attributes on the fly.Convert MJCF to USD: The plugin can be used as a basis for converting MJCF files to persistent USD files (e.g.,
.usdaor.usdc).
Essentially, it makes MJCF a first-class citizen in the USD ecosystem.
Usage#
Installation: refer to Building.
Referencing in a USD file (e.g., ``.usda``):
example.usda##usda 1.0 ( upAxis = "Z" ) def Xform "world" { def "robot" ( prepend references = @./my_robot.xml@ ) { } }
In this example,
my_robot.xmlis an MJCF file in the same directory. USD will use the plugin to load and interpret its contents.Opening in usdview:
usdview my_robot.xmlIf the plugin is correctly set up,
usdviewwill render the robot defined in the MJCF file.Using in Python (with USD API):
from pxr import Usd # Load an MJCF file as a USD stage stage = Usd.Stage.Open('my_robot.xml') if stage: print(f"Successfully opened {stage.GetRootLayer().identifier}") # You can now inspect the stage as any other USD stage for prim in stage.TraverseAll(): print(prim.GetPath()) else: print("Failed to open MJCF file")
This plugin significantly enhances the interoperability between MuJoCo and USD-based workflows, allowing seamless integration of physics assets defined in MJCF into broader 3D environments.