Support parsing .mjz files in the Studio parser module
PiperOrigin-RevId: 957616406 Change-Id: I582d23039b4aec745e0525392c062102f4d9ae25
This commit is contained in:
committed by
Copybara-Service
parent
2bb152b77b
commit
b389b28b87
@@ -19,6 +19,12 @@ import mujoco
|
||||
def parse(filepath: str) -> mujoco.MjData:
|
||||
if filepath.endswith('.mjb'):
|
||||
model = mujoco.MjModel.from_binary_path(filepath)
|
||||
elif filepath.endswith(('.mjz', '.zip')):
|
||||
# .mjz archives mount assets into a VFS during parsing; the same VFS must
|
||||
# be passed to compile() so the assets remain accessible.
|
||||
with mujoco.MjVfs() as vfs:
|
||||
spec = mujoco.MjSpec.from_file(filepath, vfs=vfs)
|
||||
model = spec.compile(vfs=vfs)
|
||||
else:
|
||||
model = mujoco.MjSpec.from_file(filepath).compile()
|
||||
return mujoco.MjData(model)
|
||||
|
||||
Reference in New Issue
Block a user