Skip to content

Make JacobianType.auto switch to sparse in put_model #234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mujoco_warp/_src/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def put_model(mjm: mujoco.MjModel) -> types.Model:

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

# calculate some fields that cannot be easily computed inline
Expand Down
21 changes: 16 additions & 5 deletions mujoco_warp/_src/io_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ def test_geom_type(self):
with self.assertRaises(NotImplementedError):
mjwarp.put_model(mjm)

def test_dense(self):
with self.assertRaises(ValueError):
# dense not supported yet for large nv
test_util.fixture("humanoid/n_humanoids.xml")

def test_actuator_trntype(self):
mjm = mujoco.MjModel.from_xml_string("""
<mujoco>
Expand Down Expand Up @@ -243,6 +238,22 @@ def test_option_physical_constants(self):
with self.assertRaises(NotImplementedError):
mjwarp.put_model(mjm)

def test_jacobian_auto(self):
mjm = mujoco.MjModel.from_xml_string("""
<mujoco>
<option jacobian="auto"/>
<worldbody>
<replicate count="11">
<body>
<geom type="sphere" size=".1"/>
<freejoint/>
</body>
</replicate>
</worldbody>
</mujoco>
""")
mjwarp.put_model(mjm)


if __name__ == "__main__":
wp.init()
Expand Down
Loading