===== Types ===== MuJoCo defines a large number of types: - Two :ref:`primitive types`. - :ref:`C enum types` used to define categorical values. These can be classified as: - Enums used in :ref:`mjModel`. - Enums used in :ref:`mjData`. - Enums for abstract :ref:`visualization`. - Enums used by the :ref:`openGL renderer`. - Enums used by the :ref:`mjUI` user interface package. - Enums used by :ref:`engine plugins`. - Enums used for :ref:`procedural model manipulation`. Note that the API does not use these enum types directly. Instead it uses ints, and the documentation/comments state that certain ints correspond to certain enum types. This is because we want the API to be compiler-independent, and the C standard does not dictate how many bytes must be used to represent an enum type. Nevertheless, for improved readability, we recommend using these types when calling API functions which take them as arguments. - :ref:`C struct types`. These can be classified as: - Main structs: - :ref:`mjModel`. - :ref:`mjOption` (embedded in :ref:`mjModel`). - :ref:`mjData`. - :ref:`Auxiliary struct types`, also used by the engine. - Structs for collecting :ref:`simulation statistics`. - Structs for :ref:`abstract visualization`. - Structs used by the :ref:`openGL renderer`. - Structs used by the :ref:`UI framework`. - Structs used for :ref:`procedural model manipulation`. - Structs used by :ref:`engine plugins`. - Several :ref:`function types` for user-defined callbacks. - :ref:`tyNotes` regarding specific data structures that require detailed description. .. _tyPrimitive: Primitive types --------------- The two types below are defined in `mjtnum.h `__. .. _mjtNum: mjtNum ^^^^^^ This is the floating-point type used throughout the simulator. When using the default build configuration, ``mjtNum`` is defined as ``double``. If the symbol ``mjUSESINGLE`` is defined, ``mjtNum`` is defined as ``float``. Currently only the double-precision version of MuJoCo is distributed, although the entire code base works with single-precision as well. We may release the single-precision version in the future, but the double-precision version will always be available. Thus it is safe to write user code assuming double precision. However, our preference is to write code that works with either single or double precision. To this end we provide math utility functions that are always defined with the correct floating-point type. Note that changing ``mjUSESINGLE`` in ``mjtnum.h`` will not change how the library was compiled, and instead will result in numerous link errors. In general, the header files distributed with precompiled MuJoCo should never be changed by the user. .. code-block:: C // floating point data type and minval #ifndef mjUSESINGLE typedef double mjtNum; #define mjMINVAL 1E-15 // minimum value in any denominator #else typedef float mjtNum; #define mjMINVAL 1E-15f #endif .. _mjtByte: mjtByte ^^^^^^^ Byte type used to represent boolean variables. .. code-block:: C typedef unsigned char mjtByte; .. _mjtSize: mjtSize ^^^^^^^ Size type used to represent buffer sizes. .. code-block:: C typedef int64_t mjtSize; .. _tyEnums: Enum types ---------- All enum types use the ``mjt`` prefix. .. _tyModelEnums: Model ^^^^^ The enums below are defined in `mjmodel.h `__. .. _mjtDisableBit: mjtDisableBit ~~~~~~~~~~~~~ Constants which are powers of 2. They are used as bitmasks for the field ``disableflags`` of :ref:`mjOption`. At runtime this field is ``m->opt.disableflags``. The number of these constants is given by ``mjNDISABLE`` which is also the length of the global string array :ref:`mjDISABLESTRING` with text descriptions of these flags. .. mujoco-include:: mjtDisableBit .. _mjtEnableBit: mjtEnableBit ~~~~~~~~~~~~ Constants which are powers of 2. They are used as bitmasks for the field ``enableflags`` of :ref:`mjOption`. At runtime this field is ``m->opt.enableflags``. The number of these constants is given by ``mjNENABLE`` which is also the length of the global string array :ref:`mjENABLESTRING` with text descriptions of these flags. .. mujoco-include:: mjtEnableBit .. _mjtJoint: mjtJoint ~~~~~~~~ Primitive joint types. These values are used in ``m->jnt_type``. The numbers in the comments indicate how many positional coordinates each joint type has. Note that ball joints and rotational components of free joints are represented as unit quaternions - which have 4 positional coordinates but 3 degrees of freedom each. .. mujoco-include:: mjtJoint .. _mjtGeom: mjtGeom ~~~~~~~ Geometric types supported by MuJoCo. The first group are "official" geom types that can be used in the model. The second group are geom types that cannot be used in the model but are used by the visualizer to add decorative elements. These values are used in ``m->geom_type`` and ``m->site_type``. .. mujoco-include:: mjtGeom .. _mjtProjection: mjtProjection ~~~~~~~~~~~~~ Type of camera projection. Used in ``m->cam_projection``. .. mujoco-include:: mjtProjection .. _mjtCamLight: mjtCamLight ~~~~~~~~~~~ Dynamic modes for cameras and lights, specifying how the camera/light position and orientation are computed. These values are used in ``m->cam_mode`` and ``m->light_mode``. .. mujoco-include:: mjtCamLight .. _mjtLightType: mjtLightType ~~~~~~~~~~~~ The type of a light source describing how its position, orientation and other properties will interact with the objects in the scene. These values are used in ``m->light_type``. .. mujoco-include:: mjtLightType .. _mjtTexture: mjtTexture ~~~~~~~~~~ Texture types, specifying how the texture will be mapped. These values are used in ``m->tex_type``. .. mujoco-include:: mjtTexture .. _mjtTextureRole: mjtTextureRole ~~~~~~~~~~~~~~ Texture roles, specifying how the renderer should interpret the texture. Note that the MuJoCo built-in renderer only uses RGB textures. These values are used to store the texture index in the material's array ``m->mat_texid``. .. mujoco-include:: mjtTextureRole .. _mjtColorSpace: mjtColorSpace ~~~~~~~~~~~~~ Type of color space encoding for textures. .. mujoco-include:: mjtColorSpace .. _mjtIntegrator: mjtIntegrator ~~~~~~~~~~~~~ Numerical integrator types. These values are used in ``m->opt.integrator``. .. mujoco-include:: mjtIntegrator .. _mjtCone: mjtCone ~~~~~~~ Available friction cone types. These values are used in ``m->opt.cone``. .. mujoco-include:: mjtCone .. _mjtJacobian: mjtJacobian ~~~~~~~~~~~ Available Jacobian types. These values are used in ``m->opt.jacobian``. .. mujoco-include:: mjtJacobian .. _mjtSolver: mjtSolver ~~~~~~~~~ Available constraint solver algorithms. These values are used in ``m->opt.solver``. .. mujoco-include:: mjtSolver .. _mjtEq: mjtEq ~~~~~ Equality constraint types. These values are used in ``m->eq_type``. .. mujoco-include:: mjtEq .. _mjtWrap: mjtWrap ~~~~~~~ Tendon wrapping object types. These values are used in ``m->wrap_type``. .. mujoco-include:: mjtWrap .. _mjtTrn: mjtTrn ~~~~~~ Actuator transmission types. These values are used in ``m->actuator_trntype``. .. mujoco-include:: mjtTrn .. _mjtDyn: mjtDyn ~~~~~~ Actuator dynamics types. These values are used in ``m->actuator_dyntype``. .. mujoco-include:: mjtDyn .. _mjtGain: mjtGain ~~~~~~~ Actuator gain types. These values are used in ``m->actuator_gaintype``. .. mujoco-include:: mjtGain .. _mjtBias: mjtBias ~~~~~~~ Actuator bias types. These values are used in ``m->actuator_biastype``. .. mujoco-include:: mjtBias .. _mjtObj: mjtObj ~~~~~~ MuJoCo object types. These are used, for example, in the support functions :ref:`mj_name2id` and :ref:`mj_id2name` to convert between object names and integer ids. .. mujoco-include:: mjtObj .. _mjtSensor: mjtSensor ~~~~~~~~~ Sensor types. These values are used in ``m->sensor_type``. .. mujoco-include:: mjtSensor .. _mjtStage: mjtStage ~~~~~~~~ These are the compute stages for the skipstage parameters of :ref:`mj_forwardSkip` and :ref:`mj_inverseSkip`. .. mujoco-include:: mjtStage .. _mjtDataType: mjtDataType ~~~~~~~~~~~ These are the possible sensor data types, used in ``mjData.sensor_datatype``. .. mujoco-include:: mjtDataType .. _mjtConDataField: mjtConDataField ~~~~~~~~~~~~~~~ Types of data fields returned by contact sensors. .. mujoco-include:: mjtConDataField .. _mjtSameFrame: mjtSameFrame ~~~~~~~~~~~~ Types of frame alignment of elements with their parent bodies. Used as shortcuts during :ref:`mj_kinematics` in the last argument to :ref:`mj_local2global`. .. mujoco-include:: mjtSameFrame .. _mjtSleepPolicy: mjtSleepPolicy ~~~~~~~~~~~~~~ Sleep policy associated with a tree. The compiler automatically chooses between ``NEVER`` and ``ALLOWED``, but the user can override this choice. Only the user can set the ``INIT`` policy (initialized as asleep). .. mujoco-include:: mjtSleepPolicy .. _mjtFlexSelf: mjtFlexSelf ~~~~~~~~~~~~ Types of flex self-collisions midphase. .. mujoco-include:: mjtFlexSelf .. _mjtSDFType: mjtSDFType ~~~~~~~~~~~ Formulas used to combine SDFs when calling mjc_distance and mjc_gradient. .. mujoco-include:: mjtSDFType .. _tyDataEnums: Data ^^^^ The enums below are defined in `mjdata.h `__. .. _mjtState: mjtState ~~~~~~~~ State component elements as integer bitflags and several convenient combinations of these flags. Used by :ref:`mj_getState`, :ref:`mj_setState` and :ref:`mj_stateSize`. .. mujoco-include:: mjtState .. _mjtConstraint: mjtConstraint ~~~~~~~~~~~~~ Constraint types. These values are not used in mjModel, but are used in the mjData field ``d->efc_type`` when the list of active constraints is constructed at each simulation time step. .. mujoco-include:: mjtConstraint .. _mjtConstraintState: mjtConstraintState ~~~~~~~~~~~~~~~~~~ These values are used by the solver internally to keep track of the constraint states. .. mujoco-include:: mjtConstraintState .. _mjtWarning: mjtWarning ~~~~~~~~~~ Warning types. The number of warning types is given by ``mjNWARNING`` which is also the length of the array ``mjData.warning``. .. mujoco-include:: mjtWarning .. _mjtTimer: mjtTimer ~~~~~~~~ Timer types. The number of timer types is given by ``mjNTIMER`` which is also the length of the array ``mjData.timer``, as well as the length of the string array :ref:`mjTIMERSTRING` with timer names. .. mujoco-include:: mjtTimer .. _mjtSleepState: mjtSleepState ~~~~~~~~~~~~~ Sleep state of an object. .. mujoco-include:: mjtSleepState .. _tyVisEnums: Visualization ^^^^^^^^^^^^^ The enums below are defined in `mjvisualize.h `__. .. _mjtCatBit: mjtCatBit ~~~~~~~~~ These are the available categories of geoms in the abstract visualizer. The bitmask can be used in the function :ref:`mjr_render` to specify which categories should be rendered. .. mujoco-include:: mjtCatBit .. _mjtMouse: mjtMouse ~~~~~~~~ These are the mouse actions that the abstract visualizer recognizes. It is up to the user to intercept mouse events and translate them into these actions, as illustrated in :ref:`simulate.cc `. .. mujoco-include:: mjtMouse .. _mjtPertBit: mjtPertBit ~~~~~~~~~~ These bitmasks enable the translational and rotational components of the mouse perturbation. For the regular mouse, only one can be enabled at a time. For the 3D mouse (SpaceNavigator) both can be enabled simultaneously. They are used in ``mjvPerturb.active``. .. mujoco-include:: mjtPertBit .. _mjtCamera: mjtCamera ~~~~~~~~~ These are the possible camera types, used in ``mjvCamera.type``. .. mujoco-include:: mjtCamera .. _mjtLabel: mjtLabel ~~~~~~~~ These are the abstract visualization elements that can have text labels. Used in ``mjvOption.label``. .. mujoco-include:: mjtLabel .. _mjtFrame: mjtFrame ~~~~~~~~ These are the MuJoCo objects whose spatial frames can be rendered. Used in ``mjvOption.frame``. .. mujoco-include:: mjtFrame .. _mjtVisFlag: mjtVisFlag ~~~~~~~~~~ These are indices in the array ``mjvOption.flags``, whose elements enable/disable the visualization of the corresponding model or decoration element. .. mujoco-include:: mjtVisFlag .. _mjtRndFlag: mjtRndFlag ~~~~~~~~~~ These are indices in the array ``mjvScene.flags``, whose elements enable/disable OpenGL rendering effects. .. mujoco-include:: mjtRndFlag .. _mjtStereo: mjtStereo ~~~~~~~~~ These are the possible stereo rendering types. They are used in ``mjvScene.stereo``. .. mujoco-include:: mjtStereo .. _tyRenderEnums: Rendering ^^^^^^^^^ The enums below are defined in `mjrender.h `__. .. _mjtGridPos: mjtGridPos ~~~~~~~~~~ These are the possible grid positions for text overlays. They are used as an argument to the function :ref:`mjr_overlay`. .. mujoco-include:: mjtGridPos .. _mjtFramebuffer: mjtFramebuffer ~~~~~~~~~~~~~~ These are the possible framebuffers. They are used as an argument to the function :ref:`mjr_setBuffer`. .. mujoco-include:: mjtFramebuffer .. _mjtDepthMap: mjtDepthMap ~~~~~~~~~~~ These are the depth mapping options. They are used as a value for the ``readPixelDepth`` attribute of the :ref:`mjrContext` struct, to control how the depth returned by :ref:`mjr_readPixels` is mapped from ``znear`` to ``zfar``. .. mujoco-include:: mjtDepthMap .. _mjtFontScale: mjtFontScale ~~~~~~~~~~~~ These are the possible font sizes. The fonts are predefined bitmaps stored in the dynamic library at three different sizes. .. mujoco-include:: mjtFontScale .. _mjtFont: mjtFont ~~~~~~~ These are the possible font types. .. mujoco-include:: mjtFont .. _tyUIEnums: User Interface ^^^^^^^^^^^^^^ The enums below are defined in `mjui.h `__. .. _mjtButton: mjtButton ~~~~~~~~~ Mouse button IDs used in the UI framework. .. mujoco-include:: mjtButton .. _mjtEvent: mjtEvent ~~~~~~~~ Event types used in the UI framework. .. mujoco-include:: mjtEvent .. _mjtItem: mjtItem ~~~~~~~ Item types used in the UI framework. .. mujoco-include:: mjtItem .. _mjtSection: mjtSection ~~~~~~~~~~ State of a UI section. .. mujoco-include:: mjtSection .. _tySpecEnums: Spec ^^^^ The enums below are defined in `mjspec.h `__. .. _mjtGeomInertia: mjtGeomInertia ~~~~~~~~~~~~~~ Type of inertia inference. .. mujoco-include:: mjtGeomInertia .. _mjtBuiltin: mjtBuiltin ~~~~~~~~~~ Type of built-in procedural texture. .. mujoco-include:: mjtBuiltin .. _mjtMark: mjtMark ~~~~~~~ Mark type for procedural textures. .. mujoco-include:: mjtMark .. _mjtLimited: mjtLimited ~~~~~~~~~~ Type of limit specification. .. mujoco-include:: mjtLimited .. _mjtAlignFree: mjtAlignFree ~~~~~~~~~~~~ Whether to align free joints with the inertial frame. .. mujoco-include:: mjtAlignFree .. _mjtInertiaFromGeom: mjtInertiaFromGeom ~~~~~~~~~~~~~~~~~~ Whether to infer body inertias from child geoms. .. mujoco-include:: mjtInertiaFromGeom .. _mjtOrientation: mjtOrientation ~~~~~~~~~~~~~~ Type of orientation specifier. .. mujoco-include:: mjtOrientation .. _tyPluginEnums: Plugins ^^^^^^^ The enums below are defined in `mjplugin.h `__. See :ref:`exPlugin` for details. .. _mjtPluginCapabilityBit: mjtPluginCapabilityBit ~~~~~~~~~~~~~~~~~~~~~~ Capabilities declared by an engine plugin. .. mujoco-include:: mjtPluginCapabilityBit .. _tyStructure: Struct types ------------ The three central struct types for physics simulation are :ref:`mjModel`, :ref:`mjOption` (embedded in :ref:`mjModel`) and :ref:`mjData`. An introductory discussion of these structures can be found in the :ref:`Overview`. .. _mjModel: mjModel ^^^^^^^ This is the main data structure holding the MuJoCo model. It is treated as constant by the simulator. Some specific details regarding datastructures in :ref:`mjModel` can be found below in :ref:`tyNotes`. .. mujoco-include:: mjModel .. _mjOption: mjOption ^^^^^^^^ This is the data structure with simulation options. It corresponds to the MJCF element :ref:`option