Switch mjData.{qH,qLD} from reduced ("C") to full ("M") inertia matrix structure. No performance impact of extra zeros because of existing "simple dof" skipping mechanism.

PiperOrigin-RevId: 733523931
Change-Id: Ic8d8a152dda5532331c239cb6b4ce7d8d09b7fff
This commit is contained in:
Yuval Tassa
2025-03-04 17:33:48 -08:00
committed by Copybara-Service
parent 51f6aa8b43
commit 0f563ecf31
20 changed files with 95 additions and 98 deletions
+2 -2
View File
@@ -372,7 +372,7 @@ def make_data(
'efc_aref': (nefc, float),
'efc_force': (nefc, float),
'_qM_sparse': (m.nM, float),
'_qLD_sparse': (m.nC, float),
'_qLD_sparse': (m.nM, float),
'_qLDiagInv_sparse': (m.nv, float),
}
@@ -511,7 +511,7 @@ def get_data_into(
value = value[dof_i, dof_j]
elif field.name == 'qLD' and not support.is_sparse(m):
# TODO(erikfrey): provide correct qLDs
value = np.zeros(m.nC)
value = np.zeros(m.nM)
elif field.name == 'qLDiagInv' and not support.is_sparse(m):
value = np.ones(m.nv)
+2 -2
View File
@@ -92,8 +92,8 @@ class SmoothTest(absltest.TestCase):
# factor_m
dx = jax.jit(mjx.factor_m)(mx, mjx.put_data(m, d))
qLDLegacy = np.zeros(mx.nM) # pylint:disable=invalid-name
for i in range(m.nC):
qLDLegacy[d.mapM2C[i]] = d.qLD[i]
for i in range(m.nM):
qLDLegacy[d.mapM2M[i]] = d.qLD[i]
_assert_eq(qLDLegacy, dx.qLD, 'qLD')
_assert_attr_eq(d, dx, 'qLDiagInv')
_assert_eq(dx._qLD_sparse, np.zeros(0), '_qLD_sparse')
+1 -1
View File
@@ -1352,7 +1352,7 @@ class Data(PyTreeNode):
efc_aref: reference pseudo-acceleration (nefc,)
efc_force: constraint force in constraint space (nefc,)
_qM_sparse: qM in sparse representation (nM,)
_qLD_sparse: qLD in sparse representation (nC,)
_qLD_sparse: qLD in sparse representation (nM,)
_qLDiagInv_sparse: qLDiagInv in sparse representation (nv,)
""" # fmt: skip
# constant sizes: