Implementation:Google deepmind Mujoco Platform Plugin Header
| Knowledge Sources | |
|---|---|
| Domains | Plugin System, API Declaration |
| Last Updated | 2026-02-15 04:00 GMT |
Overview
Declares the plugin interface for extending MuJoCo Studio with custom GUI windows and model-processing callbacks.
Description
plugin.h defines two plugin structs: GuiPlugin for custom ImGui windows and ModelPlugin for model lifecycle hooks. GuiPlugin provides an update callback invoked when the plugin's window is active, along with a name, active state, and optional data pointer. ModelPlugin provides three callbacks: get_model_to_load (returns a model buffer to load), post_model_loaded (notified after loading), and do_update (called each simulation step, returning whether to step). Both structs are final and copied by value -- they must not be subclassed. Registration functions (RegisterGuiPlugin, RegisterModelPlugin) add plugins to a global registry with case-insensitive unique names.
Usage
Included by plugin implementations that want to extend Studio's functionality. Plugins register themselves at process startup and are invoked by the Studio main loop during GUI building and simulation stepping.
Code Reference
Source Location
- Repository: Google_deepmind_Mujoco
- File: src/experimental/platform/plugin.h
- Lines: 1-94
Key Functions
struct GuiPlugin final {
using UpdateFn = void (*)(GuiPlugin* self);
bool active; const char* name; UpdateFn update; void* data;
};
struct ModelPlugin final {
using GetModelToLoadFn = const char* (*)(ModelPlugin* self, int* size, char* content_type, int content_type_size, char* model_name, int model_name_size);
using PostModelLoadedFn = void (*)(ModelPlugin* self, const char* model_path);
using DoUpdateFn = bool (*)(ModelPlugin* self, mjModel* model, mjData* data);
};
void RegisterGuiPlugin(const GuiPlugin* plugin);
void RegisterModelPlugin(const ModelPlugin* plugin);
Import
#include "experimental/platform/plugin.h"
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| plugin | const GuiPlugin* or const ModelPlugin* | Yes | Plugin struct to register with global registry |
Outputs
| Name | Type | Description |
|---|---|---|
| Registration | void | Plugin is added to the global registry and invoked by Studio |