Skip to content

Commit 7479312

Browse files
yuvaltassacopybara-github
authored andcommitted
Use LaTeX macros for prettier uppercase subscripts in documentation.
PiperOrigin-RevId: 798547203 Change-Id: I039886fd15ee022de780a19d0ad6e17d01c306f4
1 parent a230aa6 commit 7479312

File tree

2 files changed

+37
-34
lines changed

2 files changed

+37
-34
lines changed

doc/computation/index.rst

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -151,68 +151,68 @@ mathematical notation.
151151
- Size
152152
- Description
153153
- MuJoCo field
154-
* - :math:`n_Q`
154+
* - :math:`\nq`
155155
-
156156
- number of position coordinates
157157
- ``mjModel.nq``
158-
* - :math:`n_V`
158+
* - :math:`\nv`
159159
-
160160
- number of degrees of freedom
161161
- ``mjModel.nv``
162-
* - :math:`n_C`
162+
* - :math:`\nc`
163163
-
164164
- number of active constraints
165165
- ``mjData.nefc``
166166
* - :math:`q`
167-
- :math:`n_Q`
167+
- :math:`\nq`
168168
- joint position
169169
- ``mjData.qpos``
170170
* - :math:`v`
171-
- :math:`n_V`
171+
- :math:`\nv`
172172
- joint velocity
173173
- ``mjData.qvel``
174174
* - :math:`\tau`
175-
- :math:`n_V`
175+
- :math:`\nv`
176176
- applied force: passive, actuation, external
177177
- ``mjData.qfrc_passive`` + ``mjData.qfrc_actuator`` + ``mjData.qfrc_applied``
178178
* - :math:`c(q, v)`
179-
- :math:`n_V`
179+
- :math:`\nv`
180180
- bias force: Coriolis, centrifugal, gravitational
181181
- ``mjData.qfrc_bias``
182182
* - :math:`M(q)`
183-
- :math:`n_V \times n_V`
183+
- :math:`\nv \times \nv`
184184
- inertia in joint space
185185
- ``mjData.qM``
186186
* - :math:`J(q)`
187-
- :math:`n_C \times n_V`
187+
- :math:`\nq \times \nv`
188188
- constraint
189189
Jacobian
190190
- ``mjData.efc_J``
191191
* - :math:`r(q)`
192-
- :math:`n_C`
192+
- :math:`\nq`
193193
- constraint residual
194194
- ``mjData.efc_pos``
195195
* - :math:`f(q, v,\tau)`
196-
- :math:`n_C`
196+
- :math:`\nq`
197197
- constraint force
198198
- ``mjData.efc_force``
199199

200200
All model elements are enumerated at compile time and assembled into the above system-level vectors and matrices. In our
201-
earlier arm model :ref:`example <Examples>` the model has :math:`n_V = 13` degrees of freedom: 3 for the ball joint, one
201+
earlier arm model :ref:`example <Examples>` the model has :math:`\nv = 13` degrees of freedom: 3 for the ball joint, one
202202
for each of the 4 hinge joints, and 6 for the free-floating object. They appear in the same order in all system-level
203-
vectors and matrices whose dimensionality is :math:`n_V`. The data corresponding to a given model element can be
203+
vectors and matrices whose dimensionality is :math:`\nv`. The data corresponding to a given model element can be
204204
recovered via indexing operations as illustrated in the :ref:`Clarifications` section in the Overview chapter. Vectors
205-
and matrices with dimensionality :math:`n_C` are somewhat different because the active :ref:`constraints <Constraint>`
205+
and matrices with dimensionality :math:`\nq` are somewhat different because the active :ref:`constraints <Constraint>`
206206
change at runtime. In that case there is still a fixed enumeration order (corresponding to the order in which the model
207207
elements appear in ``mjModel``) but any inactive constraints are omitted.
208208

209-
The number of position coordinates :math:`n_Q` is larger than the number of degrees of freedom :math:`n_V` whenever
209+
The number of position coordinates :math:`\nq` is larger than the number of degrees of freedom :math:`\nv` whenever
210210
quaternions are used to represent 3D orientations. This occurs when the model contains ball joints or free joints (i.e.,
211211
in most models). In that case :math:`\dot{q}` does not equal :math:`v`, at least not in the usual sense. Instead one has
212212
to consider the group of rigid body orientations :math:`SO(3)` - which has the geometry of a unit sphere in 4D space.
213213
Velocities live in the 3D tangent space to this sphere. This is taken into account by all internal computations. For
214214
custom computations, MuJoCo provides the function :ref:`mj_differentiatePos` which "subtracts" two position vectors with
215-
dimensionality :math:`n_Q` and returns a velocity vector with dimensionality :math:`n_V`. A number of quaternion-related
215+
dimensionality :math:`\nq` and returns a velocity vector with dimensionality :math:`\nv`. A number of quaternion-related
216216
utility functions are also provided.
217217

218218
MuJoCo computes both forward and inverse dynamics in continuous time. Forward dynamics are then integrated over the
@@ -279,7 +279,7 @@ Transmission
279279
^^^^^^^^^^^^
280280

281281
Each actuator has a scalar length :math:`l_i(q)` defined by the type of transmission and its parameters. The gradient
282-
:math:`\nabla l_i` is an :math:`n_V`-dimensional vector of moment arms. It determines the mapping from scalar
282+
:math:`\nabla l_i` is an :math:`\nv`-dimensional vector of moment arms. It determines the mapping from scalar
283283
actuator force to joint force. The transmission properties are determined by the MuJoCo object to which the actuator
284284
is attached; the possible attachment object types are :at:`joint`, :at:`tendon`, :at:`jointinparent`,
285285
:at:`slider-crank`, :at:`site`, and :at:`body`.
@@ -727,8 +727,8 @@ Constraint model
727727

728728
MuJoCo has a very flexible constraint model, which is nevertheless handled in a uniform way by the
729729
:ref:`solver <Solver>` described later. Here we explain what the individual constraints are conceptually, and how they
730-
are laid out in the system-level vector and matrices with dimensionality :math:`n_C`. Each conceptual constraint can
731-
contribute one or more scalar constraints towards the total count :math:`n_C`, and each scalar constraint has a
730+
are laid out in the system-level vector and matrices with dimensionality :math:`\nq`. Each conceptual constraint can
731+
contribute one or more scalar constraints towards the total count :math:`\nq`, and each scalar constraint has a
732732
corresponding row in the constraint Jacobian :math:`J`. Active constraints are ordered by type in the order in which the
733733
types are described below, and then by model element within each type. The types are: equality, friction loss, limit,
734734
contact. Limits are handled as frictionless contacts by the solver and are not treated as a separate type internally. We
@@ -742,10 +742,10 @@ Equality
742742
MuJoCo can model equality constraints in the general form :math:`r(q) = 0` where :math:`r` can be any differentiable
743743
scalar or vector function of the position vector :math:`q`. It has the semantics of a residual. The solver can actually
744744
work with non-holonomic constraints as well, but we do not yet have such constraint types defined. Each equality
745-
constraint contributes :math:`\dim(r)` elements to the total constraint count :math:`n_C`. The corresponding block in
745+
constraint contributes :math:`\dim(r)` elements to the total constraint count :math:`\nq`. The corresponding block in
746746
:math:`J` is simply the Jacobian of the residual, namely :math:`\partial r / \partial q`. Note that due to the
747-
properties of quaternions, differentiation with respect to :math:`q` produces vectors of size :math:`n_V` rather than
748-
:math:`n_Q`.
747+
properties of quaternions, differentiation with respect to :math:`q` produces vectors of size :math:`\nv` rather than
748+
:math:`\nq`.
749749

750750
Among other applications, equality constraints can be used to create "loop joints", i.e., joints that cannot be modeled
751751
via the kinematic tree. Gaming engines represent all joints in this way. The same can be done in MuJoCo but is not
@@ -999,7 +999,7 @@ vectors correspond to the edges of a pyramid. Each vector combines a normal forc
999999
force or a frictional torque component. The scaling by the friction coefficients ensures that all basis vectors lie
10001000
within the elliptic friction cone we are approximating. The same holds for any convex combination of these vectors.
10011001

1002-
Finally we specify how the contact Jacobian is computed. First we construct the :math:`6`-by-:math:`n_V` matrix
1002+
Finally we specify how the contact Jacobian is computed. First we construct the :math:`6`-by-:math:`\nv` matrix
10031003
:math:`S` which maps joint velocities :math:`v` to spatial velocities :math:`S v` expressed in the contact frame. This
10041004
is done by considering the contact point as belonging to one or the other geom, computing its spatial Jacobian, and
10051005
subtracting these two Jacobians to obtain :math:`S`. The convention we use is that the contact force acts from the first
@@ -1046,34 +1046,34 @@ We will use the following notation beyond the notation introduced earlier:
10461046
- Size
10471047
- Description
10481048
* - :math:`z`
1049-
- :math:`n_C`
1049+
- :math:`\nq`
10501050
- constraint deformations
10511051
* - :math:`\omega`
1052-
- :math:`n_C`
1052+
- :math:`\nq`
10531053
- velocity of constraint deformations
10541054
* - :math:`k`
1055-
- :math:`n_C`
1055+
- :math:`\nq`
10561056
- virtual constraint stiffness
10571057
* - :math:`b`
1058-
- :math:`n_C`
1058+
- :math:`\nq`
10591059
- virtual constraint damping
10601060
* - :math:`d`
1061-
- :math:`n_C`
1061+
- :math:`\nq`
10621062
- constraint impedance
10631063
* - :math:`A(q)`
1064-
- :math:`n_C \times n_C`
1064+
- :math:`\nq \times \nq`
10651065
- inverse inertia in constraint space
10661066
* - :math:`R(q)`
1067-
- :math:`n_C \times n_C`
1067+
- :math:`\nq \times \nq`
10681068
- diagonal regularizer in constraint space
10691069
* - :math:`\ar`
1070-
- :math:`n_C`
1070+
- :math:`\nq`
10711071
- reference acceleration in constraint space
10721072
* - :math:`\au(q, v, \tau)`
1073-
- :math:`n_C`
1073+
- :math:`\nq`
10741074
- unconstrained acceleration in constraint space
10751075
* - :math:`\ac(q, v, \dot{v})`
1076-
- :math:`n_C`
1076+
- :math:`\nq`
10771077
- constrained acceleration in constraint space
10781078
* - :math:`\mathcal{K}(q)`
10791079
-
@@ -1395,7 +1395,7 @@ Thus the constrained acceleration interpolates between the unconstrained and the
13951395
in the limit :math:`R \to 0` we have a hard constraint and :math:`\ac = \ar`, while in the limit :math:`R \to \infty` we
13961396
have have an infinitely soft constraint (i.e., no constraint) and :math:`\ac = \au`. It is then natural to introduce a
13971397
model parameter which directly controls the interpolation. We call this parameter *impedance* and denote it :math:`d`.
1398-
It is a vector with dimensionality :math:`n_C` satisfying :math:`0<d<1` element-wise. Once it is specified, we compute
1398+
It is a vector with dimensionality :math:`\nq` satisfying :math:`0<d<1` element-wise. Once it is specified, we compute
13991399
the diagonal elements of the regularizer as
14001400

14011401
.. math::

doc/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@
206206
\def \ari {a_{{\rm ref},i}}
207207
\def \aui {a_{0,i}}
208208
\def \aci {a_{1,i}}
209+
\def \nv {n_{\scriptscriptstyle V}}
210+
\def \nc {n_{\scriptscriptstyle C}}
211+
\def \nq {n_{\scriptscriptstyle Q}}
209212
"""
210213

211214
# Translate LaTeX macros to KaTeX and add to options for HTML builder

0 commit comments

Comments
 (0)