diff --git a/doc/APIreference/APIdatastructures.rst b/doc/APIreference/APIdatastructures.rst deleted file mode 100644 index 847c6bfe..00000000 --- a/doc/APIreference/APIdatastructures.rst +++ /dev/null @@ -1,1446 +0,0 @@ -=============== -Data Structures -=============== - -.. _Type: - -Type definitions ----------------- - -.. _tyPrimitive: - -Primitive types -^^^^^^^^^^^^^^^ - -MuJoCo defines a large number of primitive types described here. Except for :ref:`mjtNum` and -:ref:`mjtByte`, all other primitive types are C enums used to define various integer constants. Note that the -rest of the API does not use these enum types directly. Instead it uses ints, and only 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 we recommend using these -types when calling the API functions (and letting the compiler do the enum-to-int type cast). - -.. _mjtNum: - -mjtNum -~~~~~~ - -.. code-block:: C - - #ifdef mjUSEDOUBLE - typedef double mjtNum; - #else - typedef float mjtNum; - #endif - -| Defined in `mjtnum.h `_ - -| This is the floating-point type used throughout the simulator. If the symbol ``mjUSEDOUBLE`` is defined in - ``mjmodel.h``, this type is defined as ``double``, otherwise it 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 for efficiency reasons, 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 ``mjUSEDOUBLE`` 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. - -.. _mjtByte: - -mjtByte -~~~~~~~ - -.. code-block:: C - - typedef unsigned char mjtByte; - -| Defined in `mjmodel.h `_ - -| Byte type used to represent boolean variables. - -.. _mjtDisableBit: - -mjtDisableBit -~~~~~~~~~~~~~ - -.. mujoco-include:: mjtDisableBit - -| Defined in `mjmodel.h `_ - -| 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. - -.. _mjtEnableBit: - -mjtEnableBit -~~~~~~~~~~~~ - -.. mujoco-include:: mjtEnableBit - -| Defined in `mjmodel.h `_ - -| 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. - -.. _mjtJoint: - -mjtJoint -~~~~~~~~ - -.. mujoco-include:: mjtJoint - -| Defined in `mjmodel.h `_ - -| 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. - -.. _mjtGeom: - -mjtGeom -~~~~~~~ - -.. mujoco-include:: mjtGeom - -| Defined in `mjmodel.h `_ - -| 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``. - -.. _mjtCamLight: - -mjtCamLight -~~~~~~~~~~~ - -.. mujoco-include:: mjtCamLight - -| Defined in `mjmodel.h `_ - -| 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``. - -.. _mjtTexture: - -mjtTexture -~~~~~~~~~~ - -.. mujoco-include:: mjtTexture - -| Defined in `mjmodel.h `_ - -| Texture types, specifying how the texture will be mapped. These values are used in ``m->tex_type``. - -.. _mjtIntegrator: - -mjtIntegrator -~~~~~~~~~~~~~ - -.. mujoco-include:: mjtIntegrator - -| Defined in `mjmodel.h `_ - -| Numerical integrator types. These values are used in ``m->opt.integrator``. - -.. _mjtCollision: - -mjtCollision -~~~~~~~~~~~~ - -.. mujoco-include:: mjtCollision - -| Defined in `mjmodel.h `_ - -| Collision modes specifying how candidate geom pairs are generated for near-phase collision checking. These values are - used in ``m->opt.collision``. - -.. _mjtCone: - -mjtCone -~~~~~~~ - -.. mujoco-include:: mjtCone - -| Defined in `mjmodel.h `_ - -| Available friction cone types. These values are used in ``m->opt.cone``. - -.. _mjtJacobian: - -mjtJacobian -~~~~~~~~~~~ - -.. mujoco-include:: mjtJacobian - -| Defined in `mjmodel.h `_ - -| Available Jacobian types. These values are used in ``m->opt.jacobian``. - -.. _mjtSolver: - -mjtSolver -~~~~~~~~~ - -.. mujoco-include:: mjtSolver - -| Defined in `mjmodel.h `_ - -| Available constraint solver algorithms. These values are used in ``m->opt.solver``. - -.. _mjtEq: - -mjtEq -~~~~~ - -.. mujoco-include:: mjtEq - -| Defined in `mjmodel.h `_ - -| Equality constraint types. These values are used in ``m->eq_type``. - -.. _mjtWrap: - -mjtWrap -~~~~~~~ - -.. mujoco-include:: mjtWrap - -| Defined in `mjmodel.h `_ - -| Tendon wrapping object types. These values are used in ``m->wrap_type``. - -.. _mjtTrn: - -mjtTrn -~~~~~~ - -.. mujoco-include:: mjtTrn - -| Defined in `mjmodel.h `_ - -| Actuator transmission types. These values are used in ``m->actuator_trntype``. - -.. _mjtDyn: - -mjtDyn -~~~~~~ - -.. mujoco-include:: mjtDyn - -| Defined in `mjmodel.h `_ - -| Actuator dynamics types. These values are used in ``m->actuator_dyntype``. - -.. _mjtGain: - -mjtGain -~~~~~~~ - -.. mujoco-include:: mjtGain - -| Defined in `mjmodel.h `_ - -| Actuator gain types. These values are used in ``m->actuator_gaintype``. - -.. _mjtBias: - -mjtBias -~~~~~~~ - -.. mujoco-include:: mjtBias - -| Defined in `mjmodel.h `_ - -| Actuator bias types. These values are used in ``m->actuator_biastype``. - -.. _mjtObj: - -mjtObj -~~~~~~ - -.. mujoco-include:: mjtObj - -| Defined in `mjmodel.h `_ - -| MuJoCo object types. These values are used in the support functions :ref:`mj_name2id` and - :ref:`mj_id2name` to convert between object names and integer ids. - -.. _mjtConstraint: - -mjtConstraint -~~~~~~~~~~~~~ - -.. mujoco-include:: mjtConstraint - -| Defined in `mjmodel.h `_ - -| 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. - -.. _mjtConstraintState: - -mjtConstraintState -~~~~~~~~~~~~~~~~~~ - -.. mujoco-include:: mjtConstraintState - -| Defined in `mjmodel.h `_ - -| These values are used by the solver internally to keep track of the constraint states. - -.. _mjtSensor: - -mjtSensor -~~~~~~~~~ - -.. mujoco-include:: mjtSensor - -| Defined in `mjmodel.h `_ - -| Sensor types. These values are used in ``m->sensor_type``. - -.. _mjtStage: - -mjtStage -~~~~~~~~ - -.. mujoco-include:: mjtStage - -| Defined in `mjmodel.h `_ - -| These are the compute stages for the skipstage parameters of :ref:`mj_forwardSkip` and - :ref:`mj_inverseSkip`. - -.. _mjtDataType: - -mjtDataType -~~~~~~~~~~~ - -.. mujoco-include:: mjtDataType - -| Defined in `mjmodel.h `_ - -| These are the possible sensor data types, used in ``mjData.sensor_datatype``. - -.. _mjtWarning: - -mjtWarning -~~~~~~~~~~ - -.. mujoco-include:: mjtWarning - -| Defined in `mjdata.h `_ - -| Warning types. The number of warning types is given by ``mjNWARNING`` which is also the length of the array - ``mjData.warning``. - -.. _mjtTimer: - -mjtTimer -~~~~~~~~ - -.. mujoco-include:: mjtTimer - -| Defined in `mjdata.h `_ - -| 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. - -.. _mjtCatBit: - -mjtCatBit -~~~~~~~~~ - -.. mujoco-include:: mjtCatBit - -| Defined in `mjvisualize.h `_ - -| 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. - -.. _mjtMouse: - -mjtMouse -~~~~~~~~ - -.. mujoco-include:: mjtMouse - -| Defined in `mjvisualize.h `_ - -| 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 `. - -.. _mjtPertBit: - -mjtPertBit -~~~~~~~~~~ - -.. mujoco-include:: mjtPertBit - -| Defined in `mjvisualize.h `_ - -| 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``. - -.. _mjtCamera: - -mjtCamera -~~~~~~~~~ - -.. mujoco-include:: mjtCamera - -| Defined in `mjvisualize.h `_ - -| These are the possible camera types, used in ``mjvCamera.type``. - -.. _mjtLabel: - -mjtLabel -~~~~~~~~ - -.. mujoco-include:: mjtLabel - -| Defined in `mjvisualize.h `_ - -| These are the abstract visualization elements that can have text labels. Used in ``mjvOption.label``. - -.. _mjtFrame: - -mjtFrame -~~~~~~~~ - -.. mujoco-include:: mjtFrame - -| Defined in `mjvisualize.h `_ - -| These are the MuJoCo objects whose spatial frames can be rendered. Used in ``mjvOption.frame``. - -.. _mjtVisFlag: - -mjtVisFlag -~~~~~~~~~~ - -.. mujoco-include:: mjtVisFlag - -| Defined in `mjvisualize.h `_ - -| These are indices in the array ``mjvOption.flags``, whose elements enable/disable the visualization of the - corresponding model or decoration element. - -.. _mjtRndFlag: - -mjtRndFlag -~~~~~~~~~~ - -.. mujoco-include:: mjtRndFlag - -| Defined in `mjvisualize.h `_ - -| These are indices in the array ``mjvScene.flags``, whose elements enable/disable OpenGL rendering effects. - -.. _mjtStereo: - -mjtStereo -~~~~~~~~~ - -.. mujoco-include:: mjtStereo - -| Defined in `mjvisualize.h `_ - -| These are the possible stereo rendering types. They are used in ``mjvScene.stereo``. - -.. _mjtGridPos: - -mjtGridPos -~~~~~~~~~~ - -.. mujoco-include:: mjtGridPos - -| Defined in `mjrender.h `_ - -| These are the possible grid positions for text overlays. They are used as an argument to the function - :ref:`mjr_overlay`. - -.. _mjtFramebuffer: - -mjtFramebuffer -~~~~~~~~~~~~~~ - -.. mujoco-include:: mjtFramebuffer - -| Defined in `mjrender.h `_ - -| These are the possible framebuffers. They are used as an argument to the function :ref:`mjr_setBuffer`. - -.. _mjtFontScale: - -mjtFontScale -~~~~~~~~~~~~ - -.. mujoco-include:: mjtFontScale - -| Defined in `mjrender.h `_ - -| These are the possible font sizes. The fonts are predefined bitmaps stored in the dynamic library at three different - sizes. - -.. _mjtFont: - -mjtFont -~~~~~~~ - -.. mujoco-include:: mjtFont - -| Defined in `mjrender.h `_ - -| These are the possible font types. - -.. _mjtButton: - -mjtButton -~~~~~~~~~ - -.. mujoco-include:: mjtButton - -| Defined in `mjui.h `_ - -| Mouse button IDs used in the UI framework. - -.. _mjtEvent: - -mjtEvent -~~~~~~~~ - -.. mujoco-include:: mjtEvent - -| Defined in `mjui.h `_ - -| Event types used in the UI framework. - -.. _mjtItem: - -mjtItem -~~~~~~~ - -.. mujoco-include:: mjtItem - -| Defined in `mjui.h `_ - -| Item types used in the UI framework. - -.. _tyFunction: - -Function types -^^^^^^^^^^^^^^ - -MuJoCo callbacks have corresponding function types. They are defined in `mjdata.h `_ and in -`mjui.h `_. The actual callback functions are documented later. - -.. _mjfGeneric: - -mjfGeneric -~~~~~~~~~~ - -.. code-block:: C - - typedef void (*mjfGeneric)(const mjModel* m, mjData* d); - -This is the function type of the callbacks :ref:`mjcb_passive` and :ref:`mjcb_control`. - -.. _mjfConFilt: - -mjfConFilt -~~~~~~~~~~ - -.. code-block:: C - - typedef int (*mjfConFilt)(const mjModel* m, mjData* d, int geom1, int geom2); - -This is the function type of the callback :ref:`mjcb_contactfilter`. The return value is 1: discard, -0: proceed with collision check. - -.. _mjfSensor: - -mjfSensor -~~~~~~~~~ - -.. code-block:: C - - typedef void (*mjfSensor)(const mjModel* m, mjData* d, int stage); - -This is the function type of the callback :ref:`mjcb_sensor`. - -.. _mjfTime: - -mjfTime -~~~~~~~ - -.. code-block:: C - - typedef mjtNum (*mjfTime)(void); - -This is the function type of the callback :ref:`mjcb_time`. - -.. _mjfAct: - -mjfAct -~~~~~~ - -.. code-block:: C - - typedef mjtNum (*mjfAct)(const mjModel* m, const mjData* d, int id); - -This is the function type of the callbacks :ref:`mjcb_act_dyn`, :ref:`mjcb_act_gain` and -:ref:`mjcb_act_bias`. - -.. _mjfCollision: - -mjfCollision -~~~~~~~~~~~~ - -.. code-block:: C - - typedef int (*mjfCollision)(const mjModel* m, const mjData* d, - mjContact* con, int g1, int g2, mjtNum margin); - -This is the function type of the callbacks in the collision table :ref:`mjCOLLISIONFUNC`. - -.. _mjfItemEnable: - -mjfItemEnable -~~~~~~~~~~~~~ - -.. code-block:: C - - typedef int (*mjfItemEnable)(int category, void* data); - -This is the function type of the predicate function used by the UI framework to determine if each item is enabled or -disabled. - -.. _tyStructure: - -Data structures -^^^^^^^^^^^^^^^ - -MuJoCo uses several data structures shown below. They are taken directly from the header files which contain comments -for each field. - -.. _mjVFS: - -mjVFS -~~~~~ - -.. mujoco-include:: mjVFS - -| Defined in `mjmodel.h `_ - -| This is the data structure with the virtual file system. It can only be constructed programmatically, and does not - have an analog in MJCF. - -.. _mjOption: - -mjOption -~~~~~~~~ - -.. mujoco-include:: mjOption - -| Defined in `mjmodel.h `_ - -| This is the data structure with simulation options. It corresponds to the MJCF element - :ref:`option