MCPcopy Create free account
hub / github.com/google-deepmind/dm_control / _make_element

Function _make_element

dm_control/mjcf/element.py:114–128  ·  view source on GitHub ↗

Helper function to generate the right kind of Element given a spec.

(spec, parent, attributes=None)

Source from the content-addressed store, hash-verified

112
113
114def _make_element(spec, parent, attributes=None):
115 """Helper function to generate the right kind of Element given a spec."""
116 if (spec.name == constants.WORLDBODY
117 or (spec.name == constants.SITE
118 and (parent.tag == constants.BODY
119 or parent.tag == constants.WORLDBODY))):
120 return _AttachableElement(spec, parent, attributes)
121 elif isinstance(parent, _AttachmentFrame):
122 return _AttachmentFrameChild(spec, parent, attributes)
123 elif spec.name == constants.DEFAULT:
124 return _DefaultElement(spec, parent, attributes)
125 elif spec.name == constants.ACTUATOR:
126 return _ActuatorElement(spec, parent, attributes)
127 else:
128 return _ElementImpl(spec, parent, attributes)
129
130
131_DEFAULT_NAME_FROM_FILENAME = frozenset(['mesh', 'hfield', 'texture'])

Callers 2

__init__Method · 0.85
insertMethod · 0.85

Calls 5

_AttachableElementClass · 0.85
_DefaultElementClass · 0.85
_ActuatorElementClass · 0.85
_ElementImplClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…