Fix computation of tangential contact forces in MJX _decode_pyramid.

PiperOrigin-RevId: 685665382
Change-Id: Icdbba4a3ee5fec804340d73d525a36ee570c2aa8
This commit is contained in:
Taylor Howell
2024-10-14 05:00:07 -07:00
committed by Copybara-Service
parent 766cd20273
commit 1945926351
3 changed files with 7 additions and 1 deletions
+1
View File
@@ -25,6 +25,7 @@ MJX
- Added sphere-cylinder and sphere-ellipsoid collision functions (:github:issue:`2126`).
- Fixed a bug with frictionloss constraints.
- Added ``TENDONPOS`` sensor.
- Fixed a bug with the computation of tangential contact forces in ``_decode_pyramid``.
Bug fixes
^^^^^^^^^
+1 -1
View File
@@ -295,7 +295,7 @@ def _decode_pyramid(
force = force.at[0].set(pyramid[0 : 2 * (condim - 1)].sum())
# force_tangent_i = (pyramid0_i - pyramid1_i) * mu_i
i = np.arange(0, condim)
i = np.arange(0, condim - 1)
force = force.at[i + 1].set((pyramid[2 * i] - pyramid[2 * i + 1]) * mu[i])
return force
+5
View File
@@ -203,6 +203,11 @@ class SupportTest(parameterized.TestCase):
force = jax.jit(support.contact_force, static_argnums=(2,))(mx, dx, j)
np.testing.assert_allclose(result, force, rtol=1e-5, atol=2)
# check for zeros after first condim elements
condim = dx.contact.dim[j]
if condim < 6:
np.testing.assert_allclose(force[condim:], 0, rtol=1e-5, atol=1e-5)
# test world conversion
force = jax.jit(
support.contact_force,