Implementation:Google deepmind Mujoco USD Layer Sink
| Knowledge Sources | |
|---|---|
| Domains | USD, Animation Export |
| Last Updated | 2026-02-15 04:00 GMT |
Overview
Writes MuJoCo simulation body transforms as time-sampled USD transform operations on a USD stage layer for animation export.
Description
layer_sink.cc implements the LayerSink class which authors animated body transforms into a USD stage's edit target layer. For each simulation frame, Update iterates over body paths, reads pose data from mjData, converts positions and quaternions to GfMatrix4d transforms, and writes them as time-coded xformOp:transform:mujoco attribute samples using Pixar's SdfChangeBlock for batched edits. The class uses GetOrCreateAttribute to lazily create SdfAttributeSpec entries for transform attributes. Time codes are computed from simulation time multiplied by the layer's time codes per second.
Usage
Used when recording MuJoCo simulation trajectories to USD format. Each call to Update adds a new time sample for all body transforms, building up an animated USD stage that can be played back in USD-compatible viewers or further processed in VFX pipelines.
Code Reference
Source Location
- Repository: Google_deepmind_Mujoco
- File: src/experimental/usd/layer_sink.cc
- Lines: 1-131
Key Functions
LayerSink::LayerSink(pxr::UsdStageRefPtr stage);
void LayerSink::Update(const mjData* const data, std::vector<pxr::SdfPath> body_paths);
static pxr::SdfAttributeSpecHandle GetOrCreateAttribute(pxr::SdfLayerHandle layer, pxr::SdfPrimSpecHandle prim_spec, const pxr::SdfPath& path, const pxr::TfToken& token, const pxr::SdfValueTypeName& type, pxr::SdfVariability variability);
// Private token: xformOp:transform:mujoco
Import
#include <mujoco/experimental/usd/layer_sink.h>
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| stage | pxr::UsdStageRefPtr | Yes | USD stage to write transform samples to |
| data | const mjData* | Yes | MuJoCo simulation data with body poses |
| body_paths | std::vector<pxr::SdfPath> | Yes | USD paths for each body to update |
Outputs
| Name | Type | Description |
|---|---|---|
| Time samples | USD layer | Transform time samples authored on the stage's edit target layer |