commit 1f7eaae62e0cd45a71cf7a593fa5605720765167 Author: Saran Tunyasuvunakool Date: Mon Oct 18 12:23:02 2021 +0100 Version 2.1: documentation, public API headers, and sample programs. PiperOrigin-RevId: 403900419 diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 00000000..a7590687 --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,15 @@ +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +version: 2 + +sphinx: + builder: html + configuration: doc/conf.py + fail_on_warning: false + +python: + version: 3.7 + install: + - requirements: doc/requirements.txt + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..257d2726 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,26 @@ +# How to Contribute + +We are in the process of preparing the MuJoCo codebase for open-sourcing. +When that happens, we will be grateful to receive your contributions. +Until then, you are welcome to participate in discussions, post +issues on our tracker, or send us pull requests to improve the sample program +code or documentation. + +## Contributor License Agreement + +Contributions to this project must be accompanied by a Contributor License +Agreement. You (or your employer) retain the copyright to your contribution, +this simply gives us permission to use and redistribute your contributions as +part of the project. Head over to to see +your current agreements on file or to sign a new one. + +You generally only need to submit a CLA once, so if you've already submitted one +(even if it was for a different project), you probably don't need to do it +again. + +## Code reviews + +All submissions require review. Please use GitHub pull requests for this +purpose. Consult +[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more +information on pull requests. diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 00000000..42023e43 --- /dev/null +++ b/README.md @@ -0,0 +1,106 @@ +# MuJoCo Physics + +**MuJoCo** stands for **Mu**lti-**Jo**int dynamics with **Co**ntact. It is a +general purpose physics engine that aims to facilitate research and development +in robotics, biomechanics, graphics and animation, machine learning, and other +areas which demand fast and accurate simulation of articulated structures +interacting with their environment. + +DeepMind has acquired MuJoCo, and we are currently making preparations to open +source the codebase. In the meantime, MuJoCo is available for download as a free +and unrestricted precompiled binary under the Apache 2.0 license from +[mujoco.org](https://mujoco.org/). + +MuJoCo's source code will be released through this GitHub repository once it is +ready. In the meantime, the repository hosts MuJoCo's documentation, C header +files for its public API, and sample program code. If you wish to report bugs or +make feature requests, please file them as [GitHub Issues]. You are also +welcome to make pull requests for the [documentation source files]. + +## Overview + +MuJoCo is a C/C++ library with a C API, intended for researchers and developers. +The runtime simulation module is tuned to maximize performance and operates on +low-level data structures which are preallocated by the built-in XML parser and +compiler. The user defines models in the native MJCF scene description language +-- an XML file format designed to be as human readable and editable as possible. +URDF model files can also be loaded. The library includes interactive +visualization with a native GUI, rendered in OpenGL. MuJoCo further exposes a +large number of utility functions for computing physics-related quantities, not +necessarily in a simulation loop. Features include + +- Simulation in generalized coordinates, avoiding joint violations. + +- Inverse dynamics that are well-defined even in the presence of contacts. + +- Unified continuous-time formulation of constraints via convex optimization. + +- Constraints include soft contacts, limits, dry friction, equality + constraints. + +- Simulation of particle systems, cloth, rope and soft objects. + +- Actuators including motors, cylinders, muscles, tendons, slider-cranks. + +- Choice of Newton, Conjugate Gradient, or Projected Gauss-Seidel solvers. + +- Choice of pyramidal or elliptic friction cones, dense or sparse Jacobians. + +- Choice of Euler or Runge-Kutta numerical integrators. + +- Multi-threaded sampling and finite-difference approximations. + +- Intuitive XML model format (called MJCF) and built-in model compiler. + +- Cross-platform GUI with interactive 3D visualization in OpenGL. + +- Run-time module written in ANSI C and hand-tuned for performance. + + +## Requirements + +MuJoCo binaries are currently built for Linux, macOS (Intel), and Windows. + + +## Documentation + +MuJoco's current documentation is available at [mujoco.org/book], which is +serving Sphinx-based webpages derived from the ReStructuredText +[documentation source files]. + + +## Citation + +If you use MuJoCo for published research, please cite: + +``` +@inproceedings{todorov2012mujoco, + title={Mujoco: A physics engine for model-based control}, + author={Todorov, Emanuel and Erez, Tom and Tassa, Yuval}, + booktitle={2012 IEEE/RSJ International Conference on Intelligent Robots and Systems}, + pages={5026--5033}, + year={2012}, + organization={IEEE} +} +``` + + +## License and Disclaimer + +Copyright 2021 DeepMind Technologies Limited + +ReStructuredText documents, images, and videos in the `doc` directory are made +available under the terms of the Creative Commons Attribution 4.0 (CC BY 4.0) +license. You may obtain a copy of the License at +https://creativecommons.org/licenses/by/4.0/legalcode. + +Source code is licensed under the Apache License, Version 2.0. You may obtain a +copy of the License at https://www.apache.org/licenses/LICENSE-2.0. + +This is not an officially supported Google product. + + +[GitHub Issues]: https://github.com/deepmind/mujoco/issues +[documentation source files]: https://github.com/deepmind/mujoco/tree/main/doc +[mujoco.org/book]: https://mujoco.org/book + diff --git a/doc/APIreference.rst b/doc/APIreference.rst new file mode 100644 index 00000000..d4cbbe3c --- /dev/null +++ b/doc/APIreference.rst @@ -0,0 +1,6545 @@ + +.. include:: includes/macros.rst +.. include:: includes/roles.rst + +============= +API Reference +============= + +Introduction +------------ + +This chapter is the reference manual for MuJoCo. It is generated from the header files included with MuJoCo, but also +contains additional text not available in the headers. + +.. _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 `mjmodel.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 ``mjmodel.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 +~~~~~~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtDisableBit + { + mjDSBL_CONSTRAINT = 1<<0, // entire constraint solver + mjDSBL_EQUALITY = 1<<1, // equality constraints + mjDSBL_FRICTIONLOSS = 1<<2, // joint and tendon frictionloss constraints + mjDSBL_LIMIT = 1<<3, // joint and tendon limit constraints + mjDSBL_CONTACT = 1<<4, // contact constraints + mjDSBL_PASSIVE = 1<<5, // passive forces + mjDSBL_GRAVITY = 1<<6, // gravitational forces + mjDSBL_CLAMPCTRL = 1<<7, // clamp control to specified range + mjDSBL_WARMSTART = 1<<8, // warmstart constraint solver + mjDSBL_FILTERPARENT = 1<<9, // remove collisions with parent body + mjDSBL_ACTUATION = 1<<10, // apply actuation forces + mjDSBL_REFSAFE = 1<<11, // integrator safety: make ref[0]>=2*timestep + + mjNDISABLE = 12 // number of disable flags + } 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 +~~~~~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtEnableBit + { + mjENBL_OVERRIDE = 1<<0, // override contact parameters + mjENBL_ENERGY = 1<<1, // energy computation + mjENBL_FWDINV = 1<<2, // compare forward and inverse dynamics + mjENBL_SENSORNOISE = 1<<3, // add noise to sensor data + + mjNENABLE = 4 // number of enable flags + } 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 +~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtJoint + { + mjJNT_FREE = 0, // global position and orientation (quat) (7) + mjJNT_BALL, // orientation (quat) relative to parent (4) + mjJNT_SLIDE, // sliding distance along body-fixed axis (1) + mjJNT_HINGE // rotation angle (rad) around body-fixed axis (1) + } 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 +~~~~~~~ + +.. code-block:: C + + typedef enum _mjtGeom + { + // regular geom types + mjGEOM_PLANE = 0, // plane + mjGEOM_HFIELD, // height field + mjGEOM_SPHERE, // sphere + mjGEOM_CAPSULE, // capsule + mjGEOM_ELLIPSOID, // ellipsoid + mjGEOM_CYLINDER, // cylinder + mjGEOM_BOX, // box + mjGEOM_MESH, // mesh + + mjNGEOMTYPES, // number of regular geom types + + // rendering-only geom types: not used in mjModel, not counted in mjNGEOMTYPES + mjGEOM_ARROW = 100, // arrow + mjGEOM_ARROW1, // arrow without wedges + mjGEOM_ARROW2, // arrow in both directions + mjGEOM_LINE, // line + mjGEOM_SKIN, // skin + mjGEOM_LABEL, // text label + + mjGEOM_NONE = 1001 // missing geom type + } 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 +~~~~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtCamLight + { + mjCAMLIGHT_FIXED = 0, // pos and rot fixed in body + mjCAMLIGHT_TRACK, // pos tracks body, rot fixed in global + mjCAMLIGHT_TRACKCOM, // pos tracks subtree com, rot fixed in body + mjCAMLIGHT_TARGETBODY, // pos fixed in body, rot tracks target body + mjCAMLIGHT_TARGETBODYCOM // pos fixed in body, rot tracks target subtree com + } 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 +~~~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtTexture + { + mjTEXTURE_2D = 0, // 2d texture, suitable for planes and hfields + mjTEXTURE_CUBE, // cube texture, suitable for all other geom types + mjTEXTURE_SKYBOX // cube texture used as skybox + } mjtTexture; + +| Defined in `mjmodel.h `_ +| Texture types, specifying how the texture will be mapped. These values are used in ``m->tex_type``. + +.. _mjtIntegrator: + +mjtIntegrator +~~~~~~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtIntegrator // integrator mode + { + mjINT_EULER = 0, // semi-implicit Euler + mjINT_RK4 // 4th-order Runge Kutta + } mjtIntegrator; + +| Defined in `mjmodel.h `_ +| Numerical integrator types. These values are used in ``m->opt.integrator``. + +.. _mjtCollision: + +mjtCollision +~~~~~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtCollision // collision mode for selecting geom pairs + { + mjCOL_ALL = 0, // test precomputed and dynamic pairs + mjCOL_PAIR, // test predefined pairs only + mjCOL_DYNAMIC // test dynamic pairs only + } mjtCollision; + +| Defined in `mjmodel.h `_ +| Collision modes specifying how candidate geom pair are generated for near-phase collision checking. These values are + used in ``m->opt.collision``. + +.. _mjtCone: + +mjtCone +~~~~~~~ + +.. code-block:: C + + typedef enum _mjtCone // type of friction cone + { + mjCONE_PYRAMIDAL = 0, // pyramidal + mjCONE_ELLIPTIC // elliptic + } mjtCone; + +| Defined in `mjmodel.h `_ +| Available friction cone types. These values are used in ``m->opt.cone``. + +.. _mjtJacobian: + +mjtJacobian +~~~~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtJacobian // type of constraint Jacobian + { + mjJAC_DENSE = 0, // dense + mjJAC_SPARSE, // sparse + mjJAC_AUTO // dense if nv<=60, sparse otherwise + } mjtJacobian; + +| Defined in `mjmodel.h `_ +| Available Jacobian types. These values are used in ``m->opt.jacobian``. + +.. _mjtSolver: + +mjtSolver +~~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtSolver // constraint solver algorithm + { + mjSOL_PGS = 0, // PGS (dual) + mjSOL_CG, // CG (primal) + mjSOL_NEWTON // Newton (primal) + } mjtSolver; + +| Defined in `mjmodel.h `_ +| Available constraint solver algorithms. These values are used in ``m->opt.solver``. + +.. _mjtEq: + +mjtEq +~~~~~ + +.. code-block:: C + + typedef enum _mjtEq + { + mjEQ_CONNECT = 0, // connect two bodies at a point (ball joint) + mjEQ_WELD, // fix relative position and orientation of two bodies + mjEQ_JOINT, // couple the values of two scalar joints with cubic + mjEQ_TENDON, // couple the lengths of two tendons with cubic + mjEQ_DISTANCE // fix the contact distance betweent two geoms + } mjtEq; + +| Defined in `mjmodel.h `_ +| Equality constraint types. These values are used in ``m->eq_type``. + +.. _mjtWrap: + +mjtWrap +~~~~~~~ + +.. code-block:: C + + typedef enum _mjtWrap + { + mjWRAP_NONE = 0, // null object + mjWRAP_JOINT, // constant moment arm + mjWRAP_PULLEY, // pulley used to split tendon + mjWRAP_SITE, // pass through site + mjWRAP_SPHERE, // wrap around sphere + mjWRAP_CYLINDER // wrap around (infinite) cylinder + } mjtWrap; + +| Defined in `mjmodel.h `_ +| Tendon wrapping object types. These values are used in ``m->wrap_type``. + +.. _mjtTrn: + +mjtTrn +~~~~~~ + +.. code-block:: C + + typedef enum _mjtTrn + { + mjTRN_JOINT = 0, // force on joint + mjTRN_JOINTINPARENT, // force on joint, expressed in parent frame + mjTRN_SLIDERCRANK, // force via slider-crank linkage + mjTRN_TENDON, // force on tendon + mjTRN_SITE, // force on site + + mjTRN_UNDEFINED = 1000 // undefined transmission type + } mjtTrn; + +| Defined in `mjmodel.h `_ +| Actuator transmission types. These values are used in ``m->actuator_trntype``. + +.. _mjtDyn: + +mjtDyn +~~~~~~ + +.. code-block:: C + + typedef enum _mjtDyn + { + mjDYN_NONE = 0, // no internal dynamics; ctrl specifies force + mjDYN_INTEGRATOR, // integrator: da/dt = u + mjDYN_FILTER, // linear filter: da/dt = (u-a) / tau + mjDYN_MUSCLE, // piece-wise linear filter with two time constants + mjDYN_USER // user-defined dynamics type + } mjtDyn; + +| Defined in `mjmodel.h `_ +| Actuator dynamics types. These values are used in ``m->actuator_dyntype``. + +.. _mjtGain: + +mjtGain +~~~~~~~ + +.. code-block:: C + + typedef enum _mjtGain + { + mjGAIN_FIXED = 0, // fixed gain + mjGAIN_MUSCLE, // muscle FLV curve computed by mju_muscleGain() + mjGAIN_USER // user-defined gain type + } mjtGain; + +| Defined in `mjmodel.h `_ +| Actuator gain types. These values are used in ``m->actuator_gaintype``. + +.. _mjtBias: + +mjtBias +~~~~~~~ + +.. code-block:: C + + typedef enum _mjtBias + { + mjBIAS_NONE = 0, // no bias + mjBIAS_AFFINE, // const + kp*length + kv*velocity + mjBIAS_MUSCLE, // muscle passive force computed by mju_muscleBias() + mjBIAS_USER // user-defined bias type + } mjtBias; + +| Defined in `mjmodel.h `_ +| Actuator bias types. These values are used in ``m->actuator_biastype``. + +.. _mjtObj: + +mjtObj +~~~~~~ + +.. code-block:: C + + typedef enum _mjtObj + { + mjOBJ_UNKNOWN = 0, // unknown object type + mjOBJ_BODY, // body + mjOBJ_XBODY, // body, used to access regular frame instead of i-frame + mjOBJ_JOINT, // joint + mjOBJ_DOF, // dof + mjOBJ_GEOM, // geom + mjOBJ_SITE, // site + mjOBJ_CAMERA, // camera + mjOBJ_LIGHT, // light + mjOBJ_MESH, // mesh + mjOBJ_SKIN, // skin + mjOBJ_HFIELD, // heightfield + mjOBJ_TEXTURE, // texture + mjOBJ_MATERIAL, // material for rendering + mjOBJ_PAIR, // geom pair to include + mjOBJ_EXCLUDE, // body pair to exclude + mjOBJ_EQUALITY, // equality constraint + mjOBJ_TENDON, // tendon + mjOBJ_ACTUATOR, // actuator + mjOBJ_SENSOR, // sensor + mjOBJ_NUMERIC, // numeric + mjOBJ_TEXT, // text + mjOBJ_TUPLE, // tuple + mjOBJ_KEY // keyframe + } 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 +~~~~~~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtConstraint + { + mjCNSTR_EQUALITY = 0, // equality constraint + mjCNSTR_FRICTION_DOF, // dof friction + mjCNSTR_FRICTION_TENDON, // tendon friction + mjCNSTR_LIMIT_JOINT, // joint limit + mjCNSTR_LIMIT_TENDON, // tendon limit + mjCNSTR_CONTACT_FRICTIONLESS, // frictionless contact + mjCNSTR_CONTACT_PYRAMIDAL, // frictional contact, pyramidal friction cone + mjCNSTR_CONTACT_ELLIPTIC // frictional contact, elliptic friction cone + } 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 +~~~~~~~~~~~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtConstraintState + { + mjCNSTRSTATE_SATISFIED = 0, // constraint satisfied, zero cost (limit, contact) + mjCNSTRSTATE_QUADRATIC, // quadratic cost (equality, friction, limit, contact) + mjCNSTRSTATE_LINEARNEG, // linear cost, negative side (friction) + mjCNSTRSTATE_LINEARPOS, // linear cost, positive side (friction) + mjCNSTRSTATE_CONE // squared distance to cone cost (elliptic contact) + } mjtConstraintState; + +| Defined in `mjmodel.h `_ +| These values are used by the solver internally to keep track of the constraint states. + +.. _mjtSensor: + +mjtSensor +~~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtSensor // type of sensor + { + // common robotic sensors, attached to a site + mjSENS_TOUCH = 0, // scalar contact normal forces summed over sensor zone + mjSENS_ACCELEROMETER, // 3D linear acceleration, in local frame + mjSENS_VELOCIMETER, // 3D linear velocity, in local frame + mjSENS_GYRO, // 3D angular velocity, in local frame + mjSENS_FORCE, // 3D force between site's body and its parent body + mjSENS_TORQUE, // 3D torque between site's body and its parent body + mjSENS_MAGNETOMETER, // 3D magnetometer + mjSENS_RANGEFINDER, // scalar distance to nearest geom or site along z-axis + + // sensors related to scalar joints, tendons, actuators + mjSENS_JOINTPOS, // scalar joint position (hinge and slide only) + mjSENS_JOINTVEL, // scalar joint velocity (hinge and slide only) + mjSENS_TENDONPOS, // scalar tendon position + mjSENS_TENDONVEL, // scalar tendon velocity + mjSENS_ACTUATORPOS, // scalar actuator position + mjSENS_ACTUATORVEL, // scalar actuator velocity + mjSENS_ACTUATORFRC, // scalar actuator force + + // sensors related to ball joints + mjSENS_BALLQUAT, // 4D ball joint quaterion + mjSENS_BALLANGVEL, // 3D ball joint angular velocity + + // joint and tendon limit sensors, in constraint space + mjSENS_JOINTLIMITPOS, // joint limit distance-margin + mjSENS_JOINTLIMITVEL, // joint limit velocity + mjSENS_JOINTLIMITFRC, // joint limit force + mjSENS_TENDONLIMITPOS, // tendon limit distance-margin + mjSENS_TENDONLIMITVEL, // tendon limit velocity + mjSENS_TENDONLIMITFRC, // tendon limit force + + // sensors attached to an object with spatial frame: (x)body, geom, site, camera + mjSENS_FRAMEPOS, // 3D position + mjSENS_FRAMEQUAT, // 4D unit quaternion orientation + mjSENS_FRAMEXAXIS, // 3D unit vector: x-axis of object's frame + mjSENS_FRAMEYAXIS, // 3D unit vector: y-axis of object's frame + mjSENS_FRAMEZAXIS, // 3D unit vector: z-axis of object's frame + mjSENS_FRAMELINVEL, // 3D linear velocity + mjSENS_FRAMEANGVEL, // 3D angular velocity + mjSENS_FRAMELINACC, // 3D linear acceleration + mjSENS_FRAMEANGACC, // 3D angular acceleration + + // sensors related to kinematic subtrees; attached to a body (which is the subtree root) + mjSENS_SUBTREECOM, // 3D center of mass of subtree + mjSENS_SUBTREELINVEL, // 3D linear velocity of subtree + mjSENS_SUBTREEANGMOM, // 3D angular momentum of subtree + + // user-defined sensor + mjSENS_USER // sensor data provided by mjcb_sensor callback + } mjtSensor; + +| Defined in `mjmodel.h `_ +| Sensor types. These values are used in ``m->sensor_type``. + +.. _mjtStage: + +mjtStage +~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtStage + { + mjSTAGE_NONE = 0, // no computations + mjSTAGE_POS, // position-dependent computations + mjSTAGE_VEL, // velocity-dependent computations + mjSTAGE_ACC // acceleration/force-dependent computations + } mjtStage; + +| Defined in `mjmodel.h `_ +| These are the compute stages for the skipstage parameters of :ref:`mj_forwardSkip` and + :ref:`mj_inverseSkip`. + +.. _mjtDataType: + +mjtDataType +~~~~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtDataType // data type for sensors + { + mjDATATYPE_REAL = 0, // real values, no constraints + mjDATATYPE_POSITIVE, // positive values; 0 or negative: inactive + mjDATATYPE_AXIS, // 3D unit vector + mjDATATYPE_QUATERNION // unit quaternion + } mjtDataType; + +| Defined in `mjmodel.h `_ +| These are the possible sensor data types, used in ``mjData.sensor_datatype``. + +.. _mjtWarning: + +mjtWarning +~~~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtWarning // warning types + { + mjWARN_INERTIA = 0, // (near) singular inertia matrix + mjWARN_CONTACTFULL, // too many contacts in contact list + mjWARN_CNSTRFULL, // too many constraints + mjWARN_VGEOMFULL, // too many visual geoms + mjWARN_BADQPOS, // bad number in qpos + mjWARN_BADQVEL, // bad number in qvel + mjWARN_BADQACC, // bad number in qacc + mjWARN_BADCTRL, // bad number in ctrl + + mjNWARNING // number of warnings + } 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 +~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtTimer + { + // main api + mjTIMER_STEP = 0, // step + mjTIMER_FORWARD, // forward + mjTIMER_INVERSE, // inverse + + // breakdown of step/forward + mjTIMER_POSITION, // fwdPosition + mjTIMER_VELOCITY, // fwdVelocity + mjTIMER_ACTUATION, // fwdActuation + mjTIMER_ACCELERATION, // fwdAcceleration + mjTIMER_CONSTRAINT, // fwdConstraint + + // breakdown of fwdPosition + mjTIMER_POS_KINEMATICS, // kinematics, com, tendon, transmission + mjTIMER_POS_INERTIA, // inertia computations + mjTIMER_POS_COLLISION, // collision detection + mjTIMER_POS_MAKE, // make constraints + mjTIMER_POS_PROJECT, // project constraints + + mjNTIMER // number of timers + } 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 +~~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtCatBit + { + mjCAT_STATIC = 1, // model elements in body 0 + mjCAT_DYNAMIC = 2, // model elements in all other bodies + mjCAT_DECOR = 4, // decorative geoms + mjCAT_ALL = 7 // select all categories + } 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 +~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtMouse + { + mjMOUSE_NONE = 0, // no action + mjMOUSE_ROTATE_V, // rotate, vertical plane + mjMOUSE_ROTATE_H, // rotate, horizontal plane + mjMOUSE_MOVE_V, // move, vertical plane + mjMOUSE_MOVE_H, // move, horizontal plane + mjMOUSE_ZOOM, // zoom + mjMOUSE_SELECT // selection + } 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 simulate.cc. + +.. _mjtPertBit: + +mjtPertBit +~~~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtPertBit + { + mjPERT_TRANSLATE = 1, // translation + mjPERT_ROTATE = 2 // rotation + } 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. Tehy are used + in ``mjvPerturb.active``. + +.. _mjtCamera: + +mjtCamera +~~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtCamera + { + mjCAMERA_FREE = 0, // free camera + mjCAMERA_TRACKING, // tracking camera; uses trackbodyid + mjCAMERA_FIXED, // fixed camera; uses fixedcamid + mjCAMERA_USER // user is responsible for setting OpenGL camera + } mjtCamera; + +| Defined in `mjvisualize.h `_ +| These are the possible camera types, used in ``mjvCamera.type``. + +.. _mjtLabel: + +mjtLabel +~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtLabel + { + mjLABEL_NONE = 0, // nothing + mjLABEL_BODY, // body labels + mjLABEL_JOINT, // joint labels + mjLABEL_GEOM, // geom labels + mjLABEL_SITE, // site labels + mjLABEL_CAMERA, // camera labels + mjLABEL_LIGHT, // light labels + mjLABEL_TENDON, // tendon labels + mjLABEL_ACTUATOR, // actuator labels + mjLABEL_CONSTRAINT, // constraint labels + mjLABEL_SKIN, // skin labels + mjLABEL_SELECTION, // selected object + mjLABEL_SELPNT, // coordinates of selection point + mjLABEL_CONTACTFORCE, // magnitude of contact force + + mjNLABEL // number of label types + } mjtLabel; + +| Defined in `mjvisualize.h `_ +| These are the abstract visualization elements that can have text labels. Used in ``mjvOption.label``. + +.. _mjtFrame: + +mjtFrame +~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtFrame + { + mjFRAME_NONE = 0, // no frames + mjFRAME_BODY, // body frames + mjFRAME_GEOM, // geom frames + mjFRAME_SITE, // site frames + mjFRAME_CAMERA, // camera frames + mjFRAME_LIGHT, // light frames + mjFRAME_WORLD, // world frame + + mjNFRAME // number of visualization frames + } mjtFrame; + +| Defined in `mjvisualize.h `_ +| These are the MuJoCo objects whose spatial frames can be rendered. Used in ``mjvOption.frame``. + +.. _mjtVisFlag: + +mjtVisFlag +~~~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtVisFlag + { + mjVIS_CONVEXHULL = 0, // mesh convex hull + mjVIS_TEXTURE, // textures + mjVIS_JOINT, // joints + mjVIS_ACTUATOR, // actuators + mjVIS_CAMERA, // cameras + mjVIS_LIGHT, // lights + mjVIS_TENDON, // tendons + mjVIS_RANGEFINDER, // rangefinder sensors + mjVIS_CONSTRAINT, // point constraints + mjVIS_INERTIA, // equivalent inertia boxes + mjVIS_SCLINERTIA, // scale equivalent inertia boxes with mass + mjVIS_PERTFORCE, // perturbation force + mjVIS_PERTOBJ, // perturbation object + mjVIS_CONTACTPOINT, // contact points + mjVIS_CONTACTFORCE, // contact force + mjVIS_CONTACTSPLIT, // split contact force into normal and tanget + mjVIS_TRANSPARENT, // make dynamic geoms more transparent + mjVIS_AUTOCONNECT, // auto connect joints and body coms + mjVIS_COM, // center of mass + mjVIS_SELECT, // selection point + mjVIS_STATIC, // static bodies + mjVIS_SKIN, // skin + + mjNVISFLAG // number of visualization flags + } 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 +~~~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtRndFlag + { + mjRND_SHADOW = 0, // shadows + mjRND_WIREFRAME, // wireframe + mjRND_REFLECTION, // reflections + mjRND_ADDITIVE, // additive transparency + mjRND_SKYBOX, // skybox + mjRND_FOG, // fog + mjRND_HAZE, // haze + mjRND_SEGMENT, // segmentation with random color + mjRND_IDCOLOR, // segmentation with segid color + + mjNRNDFLAG // number of rendering flags + } mjtRndFlag; + +| Defined in `mjvisualize.h `_ +| These are indices in the array ``mjvScene.flags``, whose elements enable/disable OpenGL rendering effects. + +.. _mjtStereo: + +mjtStereo +~~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtStereo + { + mjSTEREO_NONE = 0, // no stereo; use left eye only + mjSTEREO_QUADBUFFERED, // quad buffered; revert to side-by-side if no hardware support + mjSTEREO_SIDEBYSIDE // side-by-side + } mjtStereo; + +| Defined in `mjvisualize.h `_ +| These are the possible stereo rendering types. They are used in ``mjvScene.stereo``. + +.. _mjtGridPos: + +mjtGridPos +~~~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtGridPos + { + mjGRID_TOPLEFT = 0, // top left + mjGRID_TOPRIGHT, // top right + mjGRID_BOTTOMLEFT, // bottom left + mjGRID_BOTTOMRIGHT // bottom right + } 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 +~~~~~~~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtFramebuffer + { + mjFB_WINDOW = 0, // default/window buffer + mjFB_OFFSCREEN // offscreen buffer + } mjtFramebuffer; + +| Defined in `mjrender.h `_ +| These are the possible framebuffers. They are used as an argument to the function :ref:`mjr_setBuffer`. + +.. _mjtFontScale: + +mjtFontScale +~~~~~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtFontScale + { + mjFONTSCALE_50 = 50, // 50% scale, suitable for low-res rendering + mjFONTSCALE_100 = 100, // normal scale, suitable in the absence of DPI scaling + mjFONTSCALE_150 = 150, // 150% scale + mjFONTSCALE_200 = 200, // 200% scale + mjFONTSCALE_250 = 250, // 250% scale + mjFONTSCALE_300 = 300 // 300% scale + } 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 +~~~~~~~ + +.. code-block:: C + + typedef enum _mjtFont + { + mjFONT_NORMAL = 0, // normal font + mjFONT_SHADOW, // normal font with shadow (for higher contrast) + mjFONT_BIG // big font (for user alerts) + } mjtFont; + +| Defined in `mjrender.h `_ +| These are the possible font types. + +.. _mjtButton: + +mjtButton +~~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtButton // mouse button + { + mjBUTTON_NONE = 0, // no button + mjBUTTON_LEFT, // left button + mjBUTTON_RIGHT, // right button + mjBUTTON_MIDDLE // middle button + } mjtButton; + +| Defined in `mjui.h `_ +| Mouse button IDs used in the UI framework. + +.. _mjtEvent: + +mjtEvent +~~~~~~~~ + +.. code-block:: C + + typedef enum _mjtEvent // mouse and keyboard event type + { + mjEVENT_NONE = 0, // no event + mjEVENT_MOVE, // mouse move + mjEVENT_PRESS, // mouse button press + mjEVENT_RELEASE, // mouse button release + mjEVENT_SCROLL, // scroll + mjEVENT_KEY, // key press + mjEVENT_RESIZE // resize + } mjtEvent; + +| Defined in `mjui.h `_ +| Event types used in the UI framework. + +.. _mjtItem: + +mjtItem +~~~~~~~ + +.. code-block:: C + + typedef enum _mjtItem // UI item type + { + mjITEM_END = -2, // end of definition list (not an item) + mjITEM_SECTION = -1, // section (not an item) + mjITEM_SEPARATOR = 0, // separator + mjITEM_STATIC, // static text + mjITEM_BUTTON, // button + + // the rest have data pointer + mjITEM_CHECKINT, // check box, int value + mjITEM_CHECKBYTE, // check box, mjtByte value + mjITEM_RADIO, // radio group + mjITEM_SELECT, // selection box + mjITEM_SLIDERINT, // slider, int value + mjITEM_SLIDERNUM, // slider, mjtNum value + mjITEM_EDITINT, // editable array, int values + mjITEM_EDITNUM, // editable array, mjtNum values + mjITEM_EDITTXT, // editable text + + mjNITEM // number of item types + } 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 +~~~~~ + +.. code-block:: C + + struct _mjVFS // virtual file system for loading from memory + { + int nfile; // number of files present + char filename[mjMAXVFS][mjMAXVFSNAME]; // file name without path + int filesize[mjMAXVFS]; // file size in bytes + void* filedata[mjMAXVFS]; // buffer with file data + }; + typedef struct _mjVFS 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 +~~~~~~~~ + +.. code-block:: C + + struct _mjOption // physics options + { + // timing parameters + mjtNum timestep; // timestep + mjtNum apirate; // update rate for remote API (Hz) + + // solver parameters + mjtNum impratio; // ratio of friction-to-normal contact impedance + mjtNum tolerance; // main solver tolerance + mjtNum noslip_tolerance; // noslip solver tolerance + mjtNum mpr_tolerance; // MPR solver tolerance + + // physical constants + mjtNum gravity[3]; // gravitational acceleration + mjtNum wind[3]; // wind (for lift, drag and viscosity) + mjtNum magnetic[3]; // global magnetic flux + mjtNum density; // density of medium + mjtNum viscosity; // viscosity of medium + + // override contact solver parameters (if enabled) + mjtNum o_margin; // margin + mjtNum o_solref[mjNREF]; // solref + mjtNum o_solimp[mjNIMP]; // solimp + + // discrete settings + int integrator; // integration mode (mjtIntegrator) + int collision; // collision mode (mjtCollision) + int cone; // type of friction cone (mjtCone) + int jacobian; // type of Jacobian (mjtJacobian) + int solver; // solver algorithm (mjtSolver) + int iterations; // maximum number of main solver iterations + int noslip_iterations; // maximum number of noslip solver iterations + int mpr_iterations; // maximum number of MPR solver iterations + int disableflags; // bit flags for disabling standard features + int enableflags; // bit flags for enabling optional features + }; + typedef struct _mjOption mjOption; + +| Defined in `mjmodel.h `_ +| This is the data structure with simulation options. It corresponds to the MJCF element + :ref:`option