Files
Mujoco_WASM/python/mujoco/experimental/studio/parser.py
T
Matija Kecman 91d78346e1 Replace the Studio parser module with a pure Python implementation
PiperOrigin-RevId: 953181335
Change-Id: I1d2ce6f27f50aa4c30cce6d43caed80186ddef42
2026-07-23 23:52:56 -07:00

25 lines
896 B
Python

# Copyright 2026 DeepMind Technologies Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Loads and compiles MuJoCo models for the studio viewer."""
import mujoco
def parse(filepath: str) -> mujoco.MjData:
if filepath.endswith('.mjb'):
model = mujoco.MjModel.from_binary_path(filepath)
else:
model = mujoco.MjSpec.from_file(filepath).compile()
return mujoco.MjData(model)