Document element name lookup in MjSpec.
PiperOrigin-RevId: 725258206 Change-Id: I5c9a85d25787eb38e9e8c3854eda2581700e188e
This commit is contained in:
committed by
Copybara-Service
parent
e54f3c222d
commit
a6dd5f086f
+13
-7
@@ -587,14 +587,19 @@ Convenience methods
|
|||||||
The Python bindings provide a number of convenience methods and attributes not directly available in the C API in order
|
The Python bindings provide a number of convenience methods and attributes not directly available in the C API in order
|
||||||
to make model editing easier:
|
to make model editing easier:
|
||||||
|
|
||||||
|
Finding elements
|
||||||
|
^^^^^^^^^^^^^^^^
|
||||||
|
The ``MjSpec`` object has methods like ``find_body(), find_joint(), find_site(), ...`` for every type of name-able
|
||||||
|
:ref:`mjtObj` type. These methods take a name string and return the element with that name or ``None`` if it does not
|
||||||
|
exist.
|
||||||
|
|
||||||
Element lists
|
Element lists
|
||||||
^^^^^^^^^^^^^
|
^^^^^^^^^^^^^
|
||||||
Lists of all elements in a spec can be accessed using named properties, using the plural form. For example,
|
Lists of all elements in a spec can be accessed using named properties, using the plural form. For example,
|
||||||
``spec.meshes`` returns a list of all meshes in the spec.
|
``spec.meshes`` returns a list of all meshes in the spec. The following properties are implemented: ``sites``,
|
||||||
|
``geoms``, ``joints``, ``lights``, ``cameras``, ``bodies``, ``frames``, ``materials``, ``meshes``, ``pairs``,
|
||||||
The following properties are implemented: ``sites``, ``geoms``, ``joints``, ``lights``, ``cameras``, ``bodies``,
|
``equalities``, ``tendons``, ``actuators``, ``skins``, ``textures``, ``texts``, ``tuples``, ``flexes``, ``hfields``,
|
||||||
``frames``, ``materials``, ``meshes``, ``pairs``, ``equalities``, ``tendons``, ``actuators``, ``skins``, ``textures``,
|
``keys``, ``numerics``, ``excludes``, ``sensors``, ``plugins``.
|
||||||
``texts``, ``tuples``, ``flexes``, ``hfields``, ``keys``, ``numerics``, ``excludes``, ``sensors``, ``plugins``.
|
|
||||||
|
|
||||||
Tree traversal
|
Tree traversal
|
||||||
^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^
|
||||||
@@ -611,8 +616,9 @@ Recursive search:
|
|||||||
``body.find_all(mujoco.mjtObj.mjOBJ_SITE)`` or ``body.find_all('site')`` will return a list of all sites under the
|
``body.find_all(mujoco.mjtObj.mjOBJ_SITE)`` or ``body.find_all('site')`` will return a list of all sites under the
|
||||||
body.
|
body.
|
||||||
|
|
||||||
Additionally, the parent body of a given element - including bodies and frames - can be accessed via the ``parent``
|
Parent:
|
||||||
property. For example, the parent of a site can be accessed via ``site.parent``.
|
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``
|
Relationship to ``PyMJCF``
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user