Add tests for body.find_all() of joints and geoms, fix error message.
Fixes #2525 PiperOrigin-RevId: 742685596 Change-Id: I5f0969967f2490d32e5691983e8d0c363d48a6bd
This commit is contained in:
committed by
Copybara-Service
parent
c0a7ea1edb
commit
305b68ecbf
@@ -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);
|
||||
|
||||
@@ -636,6 +636,8 @@ class SpecsTest(absltest.TestCase):
|
||||
<site name="site4"/>
|
||||
<body name="body4">
|
||||
<site name="site5"/>
|
||||
<joint name="joint1"/>
|
||||
<geom name="geom1" size="1"/>
|
||||
</body>
|
||||
</body>
|
||||
</body>
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user