Add mjs_getParent to retrieve the parent body of an object.

PiperOrigin-RevId: 715794859
Change-Id: Ib9792787cdb966f579938dde3f94ebabca8ef1fc
This commit is contained in:
Alessio Quaglino
2025-01-15 07:41:45 -08:00
committed by Copybara-Service
parent 10c7207cea
commit 05d4c3d670
10 changed files with 116 additions and 0 deletions
+9
View File
@@ -4175,6 +4175,15 @@ Find element in spec by name.
Find child body by name.
.. _mjs_getParent:
`mjs_getParent <#mjs_getParent>`__
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. mujoco-include:: mjs_getParent
Get parent body.
.. _mjs_findFrame:
`mjs_findFrame <#mjs_findFrame>`__
+1
View File
@@ -3607,6 +3607,7 @@ mjSpec* mjs_findSpec(mjSpec* spec, const char* name);
mjsBody* mjs_findBody(mjSpec* s, const char* name);
mjsElement* mjs_findElement(mjSpec* s, mjtObj type, const char* name);
mjsBody* mjs_findChild(mjsBody* body, const char* name);
mjsBody* mjs_getParent(mjsElement* element);
mjsFrame* mjs_findFrame(mjSpec* s, const char* name);
mjsDefault* mjs_getDefault(mjsElement* element);
const mjsDefault* mjs_findDefault(mjSpec* s, const char* classname);
+2
View File
@@ -591,6 +591,8 @@ Recursive search:
``body.find_all(mujoco.mjtObj.mjOBJ_SITE)`` or ``body.find_all('site')`` will return a list of all sites under the
body.
Additionally, the parent body of a given element - including bodies and frames - can be accessed via the ``parent``
property. For example, the parent of a site can be accessed via ``site.parent``.
Relationship to ``PyMJCF``
--------------------------