Merge pull request #3439 from smallquail:flex-metric-blocks

PiperOrigin-RevId: 957063540
Change-Id: I86e7b2ec92c7b2acd1f1f7140e3b8a7578c48dbf
This commit is contained in:
Copybara-Service
2026-07-31 08:07:22 -07:00
18 changed files with 4932 additions and 488 deletions
+28
View File
@@ -2,6 +2,34 @@
Changelog
=========
Upcoming version (not yet released)
-----------------------------------
Engine
^^^^^^
- Replaced the per-step sparse Cholesky factorization of the flex block of the implicit effective metric M + K with
its prefactored per-vertex 3x3 diagonal blocks. The blocks precondition the CG constraint solver and drive an
iterative solve for ``qacc_smooth``, which now converges on :ref:`tolerance<option-tolerance>` rather than a fixed
threshold. Flexes with :ref:`elastic2d<flex-elasticity-elastic2d>` stretch stiffness step roughly twice as fast;
bending-only flexes keep the exact constant factor and are unchanged.
.. admonition:: Breaking API changes
:class: attention
- Removed ``mjData.efm_L_rownnz``, ``mjData.efm_L_rowadr`` and ``mjData.efm_L_colind``. They described the sparsity
of the effective-metric Cholesky factor, which no longer exists; ``mjData.efm_L`` now holds dense 3x3 blocks,
9 numbers per covered vertex. ``mjData.efm_active`` no longer takes the value 2: nothing selects a solve path on
preconditioner exactness, so it is now a plain 0/1 flag.
Models
^^^^^^
- Added `bag <https://github.com/google-deepmind/mujoco/blob/main/model/flex/bag.xml>`__ example model: a cloth bag,
held open by pinning the ring of vertices around its mouth, catching the standard humanoid dropped in from above.
Unlike the poncho models, which are bending-only, this model exercises the 2D
:ref:`stretch<flex-elasticity-elastic2d>` elasticity of a flex.
Version 3.11.0 (July 27, 2026)
------------------------------
+5 -8
View File
@@ -112,10 +112,10 @@ typedef struct mjData_ {
int nl; // number of limit constraints
int nefc; // number of constraints
int nJ; // number of non-zeros in constraint Jacobian
int efm_active; // implicit effective metric M+K: 0 inactive, 1 active, 2 active + preconditioner exact
int efm_active; // implicit effective metric M+K is active (see mjd_effBuild)
int nefmK; // number of non-zeros in effective-stiffness CSR
int nefmdof; // number of rows in effective-metric factor
int nefmL; // number of non-zeros in the effective-metric factor
int nefmdof; // number of 3x3 blocks in the effective-metric preconditioner
int nefmL; // size of the effective-metric block storage (9*nefmdof)
int nY; // number of non-zeros in constraint inverse inertia square root
int nA; // number of non-zeros in constraint inverse inertia matrix
int nisland; // number of detected constraint islands
@@ -382,11 +382,8 @@ typedef struct mjData_ {
int* efm_K_rowadr; // effective-stiffness CSR row addresses (nv x 1)
int* efm_K_colind; // effective-stiffness CSR column indices (nefmK x 1)
mjtNum* efm_K_val; // effective-stiffness CSR values (nefmK x 1)
int* efm_dofid; // factor row -> dof address (nefmdof x 1)
int* efm_L_rownnz; // factor row nonzeros (nefmdof x 1)
int* efm_L_rowadr; // factor row addresses (nefmdof x 1)
int* efm_L_colind; // factor column indices (nefmL x 1)
mjtNum* efm_L; // Cholesky factor of diag(M)+K, covered dofs (nefmL x 1)
int* efm_dofid; // block k -> dof address of its vertex triple (nefmdof x 1)
mjtNum* efm_L; // factored 3x3 diagonal blocks of M+K (nefmL x 1)
//-------------------- arena-allocated: POSITION, VELOCITY, CONTROL/ACCELERATION dependent