Raise error when binding to a removed element.

PiperOrigin-RevId: 774462737
Change-Id: I820c0e1c010ae9fbf6d9667c3364d4b65bf21002
This commit is contained in:
Alessio Quaglino
2025-06-22 10:14:40 -07:00
committed by Copybara-Service
parent 419cdf1ff3
commit a00bfa819c
9 changed files with 19 additions and 77 deletions
+13
View File
@@ -379,6 +379,19 @@ class SupportTest(parameterized.TestCase):
' 15297169659434471387 != 2785811613804955188',
)
# what happens when we bind to an actuator that was removed?
bygone_actuators = []
for act in s.actuators:
bygone_actuators.append(act)
s.delete(act)
m = s.compile()
d = mujoco.MjData(m)
mx = mjx.put_model(m)
dx = mjx.put_data(m, d)
dx = mjx.step(mx, dx)
with self.assertRaisesRegex(KeyError, 'invalid id: -1'):
dx.bind(mx, bygone_actuators)
_CONTACTS = """
<mujoco>
<worldbody>