Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Google deepmind Mujoco User VFS Header

From Leeroopedia
Revision as of 12:47, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Google_deepmind_Mujoco_User_VFS_Header.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Physics Simulation, Virtual File System
Last Updated 2026-02-15 04:00 GMT

Overview

Declares the VFS (Virtual File System) class that manages resource providers and file operations for MuJoCo.

Description

user_vfs.h defines the mujoco::user::VFS class, which is the underlying implementation for the opaque mjVFS struct. The VFS owns and manages all mjResource instances created via mju_openResource, routing open/read/close operations to the appropriate mjpResourceProvider based on mounted paths. Providers can be mounted explicitly (via mj_mountVFS) or implicitly (via mjp_registerResourceProvider), with a default file-based provider as fallback. The class supports a self-destruct mode for legacy cases where VFS is an optional argument. It provides status codes for operations and is thread-safe through mutex protection.

Usage

Included by resource management code to declare the VFS interface, which is used whenever MuJoCo needs to open, read, or close external file resources.

Code Reference

Source Location

Key Functions

namespace mujoco::user {
class VFS {
 public:
  explicit VFS(mjVFS* vfs);
  ~VFS();

  mjResource* Open(const char* dir, const char* name);
  int Read(mjResource* resource, const void** buffer);
  // Close, Mount, SetToSelfDestruct, Upcast, etc.

  enum Status {
    kSuccess = 0,
    kFailedToLoad = -1,
    kRepeatedName = 2,
    // ...
  };
};
}  // namespace mujoco::user

Import

#include "user/user_vfs.h"

I/O Contract

Inputs

Name Type Required Description
vfs mjVFS* Yes Opaque VFS struct to wrap
dir const char* No Base directory for resource path resolution
name const char* Yes Resource name to open

Outputs

Name Type Description
mjResource* mjResource* Opened resource handle, or nullptr on error
int int Bytes read from resource, or -1 on error
Status enum Operation result code

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment