Implementation:Google deepmind Mujoco User API Header
| Knowledge Sources | |
|---|---|
| Domains | Physics Simulation, Model Specification API |
| Last Updated | 2026-02-15 04:00 GMT |
Overview
Declares the public C API for MuJoCo model specification creation, compilation, attachment, and element manipulation.
Description
user_api.h is the header file that declares all public C-facing functions for the MuJoCo specification system. It covers top-level spec manipulation (mj_makeSpec, mj_compile, mj_recompile, mj_copySpec, mj_deleteSpec), attachment operations (mjs_attach), and functions for adding tree elements like bodies, joints, geoms, sites, cameras, and lights. The header uses MJAPI export macros and wraps declarations in extern "C" for C compatibility, with the mjNAN sentinel used to mark undefined fields.
Usage
Included by any C or C++ code that needs to interact with the MuJoCo specification API for building or modifying model descriptions programmatically.
Code Reference
Source Location
- Repository: Google_deepmind_Mujoco
- File: src/user/user_api.h
- Lines: 1-544
Key Functions
MJAPI mjSpec* mj_makeSpec(void);
MJAPI mjModel* mj_compile(mjSpec* s, const mjVFS* vfs);
MJAPI int mj_recompile(mjSpec* s, const mjVFS* vfs, mjModel* m, mjData* d);
MJAPI mjSpec* mj_copySpec(const mjSpec* s);
MJAPI void mj_deleteSpec(mjSpec* s);
MJAPI mjsElement* mjs_attach(mjsElement* parent, const mjsElement* child,
const char* prefix, const char* suffix);
Import
#include "user/user_api.h"
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| s | mjSpec* | Yes | Model specification to compile, copy, or delete |
| vfs | const mjVFS* | No | Virtual file system for resource lookups during compilation |
| parent | mjsElement* | Yes (for attach) | Parent element for attachment operations |
| child | const mjsElement* | Yes (for attach) | Child element to attach |
Outputs
| Name | Type | Description |
|---|---|---|
| mjSpec* | mjSpec* | Created or copied model specification |
| mjModel* | mjModel* | Compiled runtime model |
| int | int | Return code (0 on success for recompile) |