From 2f37147fc00ce1d7db5ead236705fd19ea22eed8 Mon Sep 17 00:00:00 2001 From: Erik Frey Date: Tue, 28 Nov 2023 10:11:12 -0800 Subject: [PATCH] Guard against NaNs in MJX solver when no cost is imposed. Fixes #1225. PiperOrigin-RevId: 586020958 Change-Id: I82f398b1538d2c3801a35c80c862e49be3b110a2 --- mjx/mujoco/mjx/_src/solver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mjx/mujoco/mjx/_src/solver.py b/mjx/mujoco/mjx/_src/solver.py index 567cb709..c3f5b7c1 100644 --- a/mjx/mujoco/mjx/_src/solver.py +++ b/mjx/mujoco/mjx/_src/solver.py @@ -128,7 +128,7 @@ class _LSPoint(PyTreeNode): cost = alpha * alpha * quad_total[2] + alpha * quad_total[1] + quad_total[0] deriv_0 = 2 * alpha * quad_total[2] + quad_total[1] - deriv_1 = 2 * quad_total[2] + deriv_1 = 2 * quad_total[2] + (quad_total[2] == 0) * mujoco.mjMINVAL return _LSPoint(alpha=alpha, cost=cost, deriv_0=deriv_0, deriv_1=deriv_1)