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

Method __init__

dm_control/mjcf/element.py:1050–1077  ·  view source on GitHub ↗
(self, parent, site, attachment)

Source from the content-addressed store, hash-verified

1048 __slots__ = ['_site', '_attachment']
1049
1050 def __init__(self, parent, site, attachment):
1051 if parent.tag == constants.WORLDBODY:
1052 spec = schema.WORLD_ATTACHMENT_FRAME
1053 else:
1054 spec = schema.ATTACHMENT_FRAME
1055
1056 spec_is_copied = False
1057 for child_name, child_spec in spec.children.items():
1058 if child_spec.namespace:
1059 if not spec_is_copied:
1060 spec = copy.deepcopy(spec)
1061 spec_is_copied = True
1062 spec_as_dict = child_spec._asdict()
1063 spec_as_dict['namespace'] = '{}{}attachment_frame_{}'.format(
1064 child_spec.namespace, constants.NAMESPACE_SEPARATOR, id(self))
1065 spec.children[child_name] = type(child_spec)(**spec_as_dict)
1066
1067 attributes = {}
1068 with debugging.freeze_current_stack_trace():
1069 for attribute_name in spec.attributes.keys():
1070 if hasattr(site, attribute_name):
1071 attributes[attribute_name] = getattr(site, attribute_name)
1072 super().__init__(spec, parent, attributes)
1073 self._site = site
1074 self._attachment = attachment
1075 self._attachments[attachment.namescope] = attachment.worldbody
1076 self.namescope.add('attachment_frame', attachment.namescope.name, self)
1077 self.namescope.add('attached_model', attachment.namescope.name, attachment)
1078
1079 def prefixed_identifier(self, prefix_root=None):
1080 prefix = self.namescope.full_prefix(prefix_root)

Callers

nothing calls this directly

Calls 5

itemsMethod · 0.80
_asdictMethod · 0.80
keysMethod · 0.45
__init__Method · 0.45
addMethod · 0.45

Tested by

no test coverage detected