From 6a346c42e82312508ed28155cd5bf7de7af73f9b Mon Sep 17 00:00:00 2001 From: Erik Frey Date: Thu, 15 Feb 2024 14:27:34 -0800 Subject: [PATCH] Adds support for mjOption.impratio to MJX. PiperOrigin-RevId: 607456034 Change-Id: I7f6549a4332fd2bc0331d76a8906b971ce28dbcf --- doc/changelog.rst | 1 + mjx/mujoco/mjx/_src/constraint.py | 2 +- mjx/mujoco/mjx/_src/types.py | 5 ++++- mjx/mujoco/mjx/test_data/constraints.xml | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/changelog.rst b/doc/changelog.rst index 14608cee..b7f33c2e 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -18,6 +18,7 @@ MJX ``mjx.get_data_into`` function call. 3. Fixed a bug in ``mjx.euler`` that applied incorrect damping when using dense mass matrices. 4. Fixed a bug in ``mjx.solve`` that was causing slow convergence when using ``mjSOL_NEWTON`` in :ref:`mjtSolver`. +5. Added support for :ref:`mjOption.impratio` to ``mjx.Model``. Version 3.1.2 (February 05, 2024) ----------------------------------- diff --git a/mjx/mujoco/mjx/_src/constraint.py b/mjx/mujoco/mjx/_src/constraint.py index 85df7e18..50aee9b3 100644 --- a/mjx/mujoco/mjx/_src/constraint.py +++ b/mjx/mujoco/mjx/_src/constraint.py @@ -297,7 +297,7 @@ def _instantiate_contact(m: Model, d: Data) -> Optional[_Efc]: for diff_tan, friction in zip(diff_con[1:], c.friction[:2]): for f in (friction, -friction): js.append(diff_con[0] + diff_tan * f) - invweights.append((t + f * f * t) * 2 * f * f) + invweights.append((t + f * f * t) * 2 * f * f / m.opt.impratio) active = dist < 0 j, invweight = jp.stack(js) * active, jp.stack(invweights) diff --git a/mjx/mujoco/mjx/_src/types.py b/mjx/mujoco/mjx/_src/types.py index 69878e67..578f78b6 100644 --- a/mjx/mujoco/mjx/_src/types.py +++ b/mjx/mujoco/mjx/_src/types.py @@ -218,6 +218,7 @@ class Option(PyTreeNode): Attributes: timestep: timestep + impratio: ratio of friction-to-normal contact impedance tolerance: main solver tolerance ls_tolerance: CG/Newton linesearch tolerance gravity: gravitational acceleration (3,) @@ -238,9 +239,11 @@ class Option(PyTreeNode): disableflags: bit flags for disabling standard features """ timestep: jax.Array + # unsupported: apirate + impratio: jax.Array tolerance: jax.Array ls_tolerance: jax.Array - # unsupported: apirate, impratio, noslip_tolerance, mpr_tolerance + # unsupported: noslip_tolerance, mpr_tolerance gravity: jax.Array wind: jax.Array density: jax.Array diff --git a/mjx/mujoco/mjx/test_data/constraints.xml b/mjx/mujoco/mjx/test_data/constraints.xml index c7a9cd04..42294b50 100644 --- a/mjx/mujoco/mjx/test_data/constraints.xml +++ b/mjx/mujoco/mjx/test_data/constraints.xml @@ -5,7 +5,7 @@ * solref, solimp --> -