@@ -599,126 +599,29 @@ Fast implicit-in-velocity (``implicitfast``)
599599 ``implicitfast `` yet conserves energy well under ``RK4 ``. Note that under ``implicit ``, this model doesn't diverge
600600 but rather loses energy.
601601
602- .. _geState :
603-
604- The State
605- ~~~~~~~~~
606-
607- To complete our description of the general framework we will now discuss the notion of *state *. MuJoCo has a compact,
608- well-defined internal state which, together with the :ref: `deterministic computational pipeline<piReproducibility> `,
609- means that operations like resetting the state and computing dynamics derivatives are also well-defined.
610-
611- The state is entirely encapsulated in the :ref: `mjData ` struct and consists of several components. The components are
612- enumerated in :ref: `mjtState ` as bit flags, along with several common combinations, corresponding to the groupings
613- below. Concatenated state vectors can be conveniently read from and written into :ref: `mjData ` using :ref: `mj_getState `
614- and :ref: `mj_setState `, respectively.
615602
603+ .. Leave links below to sections that were previously here and have moved to the simulation chapter.
616604 .. _gePhysicsState :
617-
618- Physics state
619- ^^^^^^^^^^^^^
620- The *physics state * (:ref: `mjSTATE_PHYSICS<mjtState> `) contains the main quantities which are time-integrated during
621- stepping. These are ``mjData.{qpos, qvel, act} ``:
622-
623- Position: ``qpos ``
624- The configuration in generalized coodinates, denoted above as :math: `q`.
625-
626- Velocity: ``qvel ``
627- The generalized velocities, denoted above as :math: `v`.
628-
629- Actuator activation: ``act ``
630- ``mjData.act `` contains the internal states of stateful actuators, denoted above as :math: `w`.
631-
632605.. _geFullPhysics :
633-
634- Full physics state
635- ^^^^^^^^^^^^^^^^^^
636-
637- The *full physics state * (:ref: `mjSTATE_FULLPHYSICS<mjtState> `) contains the physics state and two additional
638- components:
639-
640- Time: ``time ``
641- The simulation time is given by the scalar ``mjData.time ``. Since physics is time-invariant, it is
642- excluded from the *physics state *; exceptions include time-dependent user callbacks and plugins (e.g., an open-loop
643- controller), in which case time should be included.
644-
645- Plugin state: ``plugin_state ``
646- ``mjData.plugin_state `` are states declared by :ref: `engine plugins<exPlugin> `. Please see the :ref: `exPluginState `
647- section for more details.
648-
649606.. _geInput :
650-
651- User inputs
652- ^^^^^^^^^^^
653-
654- These input fields (:ref: `mjSTATE_USER<mjtState> `) are set by the user and affect the physics simulation, but are
655- untouched by the simulator. All input fields except for MoCap poses default to 0.
656-
657- Control: ``ctrl ``
658- Controls are defined by the :ref: `actuator<actuator> ` section of the XML. ``mjData.ctrl `` values either produce
659- generalized forces directly (stateless actuators), or affect the actuator activations in ``mjData.act ``, which then
660- produce forces.
661-
662- Auxiliary Controls: ``qfrc_applied `` and ``xfrc_applied ``
663- | ``mjData.qfrc_applied`` are directly applied generalized forces.
664- | ``mjData.xfrc_applied`` are Cartesian wrenches applied to the CoM of individual bodies. This field is used for
665- example, by the :ref:`native viewer<saSimulate>` to apply mouse perturbations.
666- | Note that the effects of ``qfrc_applied`` and ``xfrc_applied`` can usually be recreated by appropriate actuator
667- definitions.
668-
669- MoCap poses: ``mocap_pos `` and ``mocap_quat ``
670- ``mjData.mocap_pos `` and ``mjData.mocap_quat `` are special optional kinematic states :ref: `described here<CMocap> `,
671- which allow the user to set the positions and orientations of static bodies in real-time, for example when streaming
672- 6D poses from a motion-capture device. The default values set by :ref: `mj_resetData ` are the poses of the bodies at
673- the default configuration.
674-
675- Equality constraint toggle: ``eq_active ``
676- ``mjData.eq_active `` is a byte-valued array that allows the user to toggle the state of equality constraints at
677- runtime. The initial value of this array is ``mjModel.eq_active0 `` which can be set in XML using the
678- :ref: `active<equality-connect-active> ` attribute of :ref: `equality constraints<coEquality> `.
679-
680- User data: ``userdata ``
681- ``mjData.userdata `` acts as a user-defined memory space untouched by the engine. For example it can be used by
682- callbacks. This is described in more detail in the :ref: `Programming chapter<siSimulation> `.
683-
684607.. _geWarmstart :
685-
686- Warmstart acceleration
687- ^^^^^^^^^^^^^^^^^^^^^^
688-
689- ``qacc_warmstart ``
690- ``mjData.qacc_warmstart `` are accelerations used to warmstart the constraint solver, saved from the previous step.
691- When using a slowly-converging :ref: `constraint solver<Solver> ` like PGS, these can speed up simulation by reducing
692- the number of iterations required for convergence. Note however that the default Newton solver converges so quickly
693- (usually 2-3 iterations), that warmstarts often have no effect on speed and can be disabled.
694-
695- Different warmstarts have no perceptible effect on the dynamics but should be saved if perfect numerical
696- reproducibility is required when loading a non-initial state. Note that even though their effect on physics is
697- negligible, many physical systems will accumulate small differences `exponentially
698- <https://en.wikipedia.org/wiki/Lyapunov_exponent> `__ when time-stepping, quickly leading to divergent trajectories
699- for different warmstarts.
700-
701608.. _geIntegrationState :
609+ .. _geSimulationState :
702610
703- Integration state
704- ^^^^^^^^^^^^^^^^^
611+ .. _geState :
705612
706- The *integration state * (:ref: `mjSTATE_INTEGRATION<mjtState> `) is the union of all the above :ref: `mjData ` fields and
707- constitutes the entire set of inputs to the *forward dynamics *. In the case of *inverse dynamics *, ``mjData.qacc `` is
708- also treated as an input variable. All other :ref: `mjData ` fields are functions of the integration state.
613+ The State
614+ ~~~~~~~~~
709615
710- Note that the full integration state as given by :ref: ` mjSTATE_INTEGRATION<mjtState> ` is maximalist and includes fields
711- which are often unused. If a small state size is desired, it might be sensible to avoid saving unused fields.
712- In particular `` xfrc_applied `` can be quite large (`` 6 x nbody ``) yet is often unused .
616+ To complete our description of the general framework we will quickly discuss the notion of * state *. MuJoCo has a
617+ compact, well-defined internal state which, together with the :ref: ` deterministic pipeline<piReproducibility> `, means
618+ that operations like (re)setting the state and computing dynamics derivatives are also well-defined .
713619
714- .. _geSimulationState :
620+ The state is entirely encapsulated in the :ref: `mjData ` struct and consists of several components. The components are
621+ enumerated in :ref: `mjtState ` as bit flags. Concatenated state vectors can be conveniently read from and written into
622+ :ref: `mjData ` using :ref: `mj_getState ` and :ref: `mj_setState `, respectively.
715623
716- Simulation state: ``mjData ``
717- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
718- The *simulation state * is the entirety of the :ref: `mjData ` struct and associated memory buffer. This state includes
719- all derived quantities computed during dynamics computation. Because the :ref: `mjData ` buffers are preallocated for the
720- worst case, it is often significantly faster to recompute derived quantities from the *integration state * rather than
721- using :ref: `mj_copyData `.
624+ More detail can be found in the :ref: `State and Control<siStateControl> ` section in the Simulation chapter.
722625
723626.. _Constraint :
724627
@@ -1824,8 +1727,8 @@ Control callback
18241727
18251728Force/acceleration
18261729''''''''''''''''''
1827- The stages below compute quantities that depend on :ref: `user inputs<geInput > `. Due to the sequential nature
1828- of the pipeline, the actual dependence is on the entire :ref: `integration state<geIntegrationState > `.
1730+ The stages below compute quantities that depend on :ref: `user inputs<siInput > `. Due to the sequential nature
1731+ of the pipeline, the actual dependence is on the entire :ref: `integration state<siIntegrationState > `.
18291732
1830173320. Compute the actuator forces and activation dynamics if defined: :ref: `mj_fwdActuation `
1831173421. Compute the joint acceleration resulting from all forces except for the (still unknown) constraint forces:
@@ -1871,8 +1774,8 @@ MuJoCo's simulation pipeline is entirely deterministic and reproducible -- if a
18711774saved and reloaded and :ref: `mj_step ` called again, the resulting next state will be identical. However, there are some
18721775important caveats:
18731776
1874- - Save all the required :ref: `integration state<geIntegrationState > ` components. In particular :ref: `warmstart
1875- accelerations<geWarmstart >` have only a very small effect on the next state, but should be saved if bit-wise equality
1777+ - Save all the required :ref: `integration state<siIntegrationState > ` components. In particular :ref: `warmstart
1778+ accelerations<siWarmstart >` have only a very small effect on the next state, but should be saved if bit-wise equality
18761779 is required.
18771780- Any numerical difference between states, no matter how small, will become significant upon integration, especially for
18781781 systems with contact. Contact events have high `Lyapunov exponents
0 commit comments