Implementation:Google deepmind Mujoco User Init
| Knowledge Sources | |
|---|---|
| Domains | Physics Simulation, Default Initialization |
| Last Updated | 2026-02-15 04:00 GMT |
Overview
Provides default initialization functions for all MuJoCo specification data structures in pure C.
Description
user_init.c defines default initializers for all major MuJoCo specification types including mjs_defaultSpec, mjs_defaultBody, mjs_defaultOrientation, and many others. It uses memset to zero-initialize structures, then sets specific defaults such as compiler settings (autolimits, euler sequence, threading), engine options (via mj_defaultOption and mj_defaultVisual), and per-element defaults like quaternion identity values. Being a C file, it serves as the foundation for ensuring all spec structures start in a well-defined state.
Usage
Called internally whenever a new specification element is created, ensuring all fields have sensible default values before user modifications.
Code Reference
Source Location
- Repository: Google_deepmind_Mujoco
- File: src/user/user_init.c
- Lines: 1-386
Key Functions
void mjs_defaultSpec(mjSpec* spec);
void mjs_defaultOrientation(mjsOrientation* orient);
void mjs_defaultBody(mjsBody* body);
Import
#include "user/user_api.h"
#include <mujoco/mjspec.h>
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| spec | mjSpec* | Yes | Specification structure to initialize with defaults |
| body | mjsBody* | Yes | Body structure to initialize with defaults |
| orient | mjsOrientation* | Yes | Orientation structure to initialize with defaults |
Outputs
| Name | Type | Description |
|---|---|---|
| void | void | Structures are modified in-place with default values |