Replay and depth¶
The published videos hold only the front camera and no depth. Every episode stores the full
MuJoCo state of every frame (states.npz) and the scene model (model.xml.gz), so any camera,
at any resolution, with metric depth, can be re-rendered afterwards. scripts/replay_episode.py
does this in plain MuJoCo; it imports neither robosuite, robocasa nor the robocasa_relations
package.
Requirements¶
- Python 3.10 or newer with
mujoco,numpy,pandas,Pillowandav(pyav). Tested with mujoco 3.3.1, the version the data were recorded with (use the same minor version). - robosuite and RoboCasa installed at the pinned commits, with the RoboCasa kitchen assets
downloaded (code repository README). The model xml names its meshes and textures as
$PKG_ROOT/<package>/models/assets/..., where<package>isrobosuiteorrobocasaand$PKG_ROOTis a placeholder for the directory that contains the package (it is not an environment variable and is never expanded by MuJoCo).--asset-root autoresolves it to the installed packages (found without importing them),--asset-root robocasa=DIRand--asset-root robosuite=DIRto given package directories (the directories that containmodels/assets); without--asset-rootthe model does not load. No environment script is needed. - An OpenGL context:
MUJOCO_GL=eglon a node with a GPU (MUJOCO_EGL_DEVICE_IDpicks the card).
env -u PYTHONPATH MUJOCO_GL=egl python scripts/replay_episode.py \
<dataset root>/base/val 3 \
--camera side_low --width 640 --height 480 --frames 0:400:10 \
--out out/ --rgb-png --depth-png --asset-root auto
Arguments: the dataset directory (<root>/<family>/<split>), the episode_index, --camera
(robot_and_counter, side_low, robot_left, robot_right, robot0_eye_in_hand), --width
and --height, --frames start:stop[:step] (frame indices of the episode, stop exclusive),
--out with --rgb-png and/or --depth-png, --asset-root, and --verify.
What it does¶
- Loads
model.xml.gzandcamera_calibration.npz. The scene cameras are not in the xml, so the script inserts a fixed<camera>for each calibrated one.camera_to_worldis in the OpenCV convention (x right, y down, z forward); MuJoCo cameras look along -z with +y up, so the rotation is multiplied bydiag(1, -1, -1). The vertical field of view is2 atan(cy / fy)from the intrinsics, which is how the original cameras were defined. The wrist camerarobot0_eye_in_handis in the model and moves with the hand. - For each requested frame
t, setstime,qposandqvelfrom rowtofstatesand runsmj_forward. The states array has one row more than the video (rowTis the final state); frametof the video is rowt. - Renders RGB (uint8) with the collision geoms hidden (geom group 0), as the collection renderer did, and, if asked, metric depth.
Depth: units, near and far¶
MuJoCo's renderer returns depth in metres along the camera's optical axis (the z coordinate in the camera frame, not the distance along the pixel ray). The conversion from the OpenGL depth buffer uses the clipping planes
znear = model.vis.map.znear * model.stat.extent(about 0.029 to 0.031 m in these scenes),zfar = model.vis.map.zfar * model.stat.extent(about 1,400 to 1,550 m),
which the script prints. Pixels at or beyond zfar (nothing hit) are set to 0. The depth PNGs are
16-bit, one channel, millimetres (round(depth_m * 1000), saturating at 65.535 m, 0 = no
surface); read them back with np.array(Image.open(path)).astype(np.float32) / 1000. To project a
pixel (u, v) with depth z into the camera frame use the pinhole intrinsics at the rendered
size (camera_calibration.npz holds them at 640x480; halve them for 320x240):
x = (u - cx) z / fx, y = (v - cy) z / fy, then camera_to_world (OpenCV axes).
Typical values for the front and side cameras are 0.9 to 2.5 m.
Parity with the published video¶
--verify renders the published camera (robot_and_counter) at 320x240 and compares each frame
with the decoded published video. On three episodes from three groups (base/val 0,
composition/composition 3, order/train task 2step_lemon_corn_in_pot_medium__order_10 demo 0; frames 0 to 600 every 75 to 100) the mean PSNR was
32.5, 32.1 and 32.0 dB. The geometry matches exactly; the
remaining difference is the lossy h264 encoding of the published video.
Cost¶
Measured on one RTX A5000 (EGL, one process), steady state after the first frame:
| Per frame | 320x240 | 640x480 |
|---|---|---|
set state (mj_forward) |
1.7 ms | 1.9 ms |
| render RGB + depth | 2.0 ms | 3.5 ms |
| total | about 3.7 ms | about 5.4 ms |
The 4.59 M frames of the whole dataset therefore take about 5 h (320x240) or 7 h (640x480) of one GPU process per camera; the 6,358 episodes parallelise trivially across processes and GPUs. Writing PNGs adds the encoding time.
Disk, as 16-bit depth PNG (measured on 25 frames of one episode; the dataset has 722 frames per episode on average):
| Per camera | per frame | per episode (722 frames) | whole dataset (4.59 M frames) |
|---|---|---|---|
| depth 320x240 | 15 kB | 11 MB | 69 GB |
| depth 640x480 | 41 kB | 30 MB | 190 GB |
| RGB 320x240 (PNG, for comparison) | 107 kB | 77 MB | 495 GB |
| RGB 640x480 (PNG, for comparison) | 375 kB | 271 MB | 1.7 TB |
Store RGB as video, not PNG, if you keep it at all. Depth compresses well because it is smooth; cropping to the counter region or writing every second frame halves the size again.