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

Class _DefaultElement

dm_control/mjcf/element.py:1142–1183  ·  view source on GitHub ↗

Specialized object representing a element. This is necessary for the proper handling of global defaults.

Source from the content-addressed store, hash-verified

1140
1141
1142class _DefaultElement(_ElementImpl):
1143 """Specialized object representing a <default> element.
1144
1145 This is necessary for the proper handling of global defaults.
1146 """
1147 __slots__ = []
1148
1149 def _attach(self, other, exclude_worldbody=False, dry_run=False):
1150 self._check_valid_attachment(other)
1151 if ((not isinstance(self._parent, RootElement))
1152 or (not isinstance(other.parent, RootElement))):
1153 raise ValueError('Only global <{}> can be attached'
1154 .format(constants.DEFAULT))
1155 if not dry_run:
1156 self._attachments[other.namescope] = other
1157
1158 def all_children(self):
1159 return [child for child in self._children]
1160
1161 def to_xml(self, prefix_root=None, debug_context=None,
1162 *,
1163 precision=constants.XML_DEFAULT_PRECISION,
1164 zero_threshold=0,
1165 filename_with_hash=True):
1166 prefix_root = prefix_root or self.namescope
1167 xml_element = (super().to_xml(prefix_root, debug_context,
1168 precision=precision,
1169 zero_threshold=zero_threshold,
1170 filename_with_hash=filename_with_hash))
1171 if isinstance(self._parent, RootElement):
1172 root_default = etree.Element(self._spec.name)
1173 root_default.append(xml_element)
1174 for attachment in self._attachments.values():
1175 attachment_xml = attachment.to_xml(
1176 prefix_root, debug_context,
1177 precision=precision,
1178 zero_threshold=zero_threshold,
1179 filename_with_hash=filename_with_hash)
1180 for attachment_child_xml in attachment_xml:
1181 root_default.append(attachment_child_xml)
1182 xml_element = root_default
1183 return xml_element
1184
1185
1186class _ActuatorElement(_ElementImpl):

Callers 1

_make_elementFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…