From 305b68ecbfd9e32d13d0c92c8d7b55743dcacb56 Mon Sep 17 00:00:00 2001 From: Yuval Tassa Date: Tue, 1 Apr 2025 07:14:00 -0700 Subject: [PATCH] Add tests for `body.find_all()` of joints and geoms, fix error message. Fixes #2525 PiperOrigin-RevId: 742685596 Change-Id: I5f0969967f2490d32e5691983e8d0c363d48a6bd --- python/mujoco/specs.cc | 2 +- python/mujoco/specs_test.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/python/mujoco/specs.cc b/python/mujoco/specs.cc index 3a834ff3..64afef62 100644 --- a/python/mujoco/specs.cc +++ b/python/mujoco/specs.cc @@ -261,7 +261,7 @@ py::list FindAllImpl(raw::MjsBody& body, mjtObj objtype, bool recursive) { // this should never happen throw pybind11::value_error( "body.find_all supports the types: body, frame, geom, site, " - "light, camera."); + "joint, light, camera."); break; } el = mjs_nextChild(&body, el, recursive); diff --git a/python/mujoco/specs_test.py b/python/mujoco/specs_test.py index f0c3bb6c..bfefd71f 100644 --- a/python/mujoco/specs_test.py +++ b/python/mujoco/specs_test.py @@ -636,6 +636,8 @@ class SpecsTest(absltest.TestCase): + + @@ -649,6 +651,8 @@ class SpecsTest(absltest.TestCase): self.assertLen(spec.sites, 5) self.assertLen(spec.worldbody.find_all('body'), 4) self.assertLen(spec.worldbody.find_all('site'), 5) + self.assertLen(spec.worldbody.find_all('joint'), 1) + self.assertLen(spec.worldbody.find_all('geom'), 1) self.assertEqual(spec.bodies[1].name, 'body1') self.assertEqual(spec.bodies[2].name, 'body2') self.assertEqual(spec.bodies[3].name, 'body3')