Skip to content

Commit dc2d4d9

Browse files
Make JacobianType.auto switch to sparse in put_model (#234)
* make jac_auto switch to sparse * remove old test * review feedback
1 parent 6f5a1e8 commit dc2d4d9

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

mujoco_warp/_src/io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def put_model(mjm: mujoco.MjModel) -> types.Model:
6464

6565
# TODO(team): remove after solver._update_gradient for Newton solver utilizes tile operations for islands
6666
nv_max = 60
67-
if mjm.nv > nv_max and (not mjm.opt.jacobian == mujoco.mjtJacobian.mjJAC_SPARSE):
67+
if mjm.nv > nv_max and mjm.opt.jacobian == mujoco.mjtJacobian.mjJAC_DENSE:
6868
raise ValueError(f"Dense is unsupported for nv > {nv_max} (nv = {mjm.nv}).")
6969

7070
# calculate some fields that cannot be easily computed inline

mujoco_warp/_src/io_test.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ def test_geom_type(self):
8989
with self.assertRaises(NotImplementedError):
9090
mjwarp.put_model(mjm)
9191

92-
def test_dense(self):
93-
with self.assertRaises(ValueError):
94-
# dense not supported yet for large nv
95-
test_util.fixture("humanoid/n_humanoids.xml")
96-
9792
def test_actuator_trntype(self):
9893
mjm = mujoco.MjModel.from_xml_string("""
9994
<mujoco>
@@ -243,6 +238,22 @@ def test_option_physical_constants(self):
243238
with self.assertRaises(NotImplementedError):
244239
mjwarp.put_model(mjm)
245240

241+
def test_jacobian_auto(self):
242+
mjm = mujoco.MjModel.from_xml_string("""
243+
<mujoco>
244+
<option jacobian="auto"/>
245+
<worldbody>
246+
<replicate count="11">
247+
<body>
248+
<geom type="sphere" size=".1"/>
249+
<freejoint/>
250+
</body>
251+
</replicate>
252+
</worldbody>
253+
</mujoco>
254+
""")
255+
mjwarp.put_model(mjm)
256+
246257

247258
if __name__ == "__main__":
248259
wp.init()

0 commit comments

Comments
 (0)