Finds an element with a particular identifier. This function allows the direct access to an arbitrarily deeply nested child element by name, without the need to manually traverse through the object tree. The `namespace` argument specifies the kind of element to find. In most cases,
(self, namespace, identifier)
| 106 | |
| 107 | @abc.abstractmethod |
| 108 | def find(self, namespace, identifier): |
| 109 | """Finds an element with a particular identifier. |
| 110 | |
| 111 | This function allows the direct access to an arbitrarily deeply nested |
| 112 | child element by name, without the need to manually traverse through the |
| 113 | object tree. The `namespace` argument specifies the kind of element to |
| 114 | find. In most cases, this corresponds to the element's XML tag name. |
| 115 | However, if an element has multiple specialized tags, then the namespace |
| 116 | corresponds to the tag name of the most general element of that kind. |
| 117 | For example, `namespace='joint'` would search for `<joint>` and |
| 118 | `<freejoint>`, while `namespace='actuator'` would search for `<general>`, |
| 119 | `<motor>`, `<position>`, `<velocity>`, and `<cylinder>`. |
| 120 | |
| 121 | Args: |
| 122 | namespace: A string specifying the namespace being searched. See the |
| 123 | docstring above for explanation. |
| 124 | identifier: The identifier string of the desired element. |
| 125 | |
| 126 | Returns: |
| 127 | An `mjcf.Element` object, or `None` if an element with the specified |
| 128 | identifier is not found. |
| 129 | |
| 130 | Raises: |
| 131 | ValueError: if either `namespace` or `identifier` is not a string, or if |
| 132 | `namespace` is not a valid namespace. |
| 133 | """ |
| 134 | |
| 135 | @abc.abstractmethod |
| 136 | def find_all(self, namespace, |
no outgoing calls