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

Method get_assets

dm_control/mjcf/element.py:1279–1305  ·  view source on GitHub ↗

Returns a dict containing the binary assets referenced in this model. This will contain `{vfs_filename: contents}` pairs. `vfs_filename` will be the name of the asset in MuJoCo's Virtual File System, which corresponds to the filename given in the XML returned by `to_xml_string()`. `cont

(self)

Source from the content-addressed store, hash-verified

1277 return self.parent_model.root_model if self.parent_model else self
1278
1279 def get_assets(self):
1280 """Returns a dict containing the binary assets referenced in this model.
1281
1282 This will contain `{vfs_filename: contents}` pairs. `vfs_filename` will be
1283 the name of the asset in MuJoCo's Virtual File System, which corresponds to
1284 the filename given in the XML returned by `to_xml_string()`. `contents` is a
1285 bytestring.
1286
1287 This dict can be used together with the result of `to_xml_string()` to
1288 construct a `mujoco.Physics` instance:
1289
1290 ```python
1291 physics = mujoco.Physics.from_xml_string(
1292 xml_string=mjcf_model.to_xml_string(),
1293 assets=mjcf_model.get_assets())
1294 ```
1295 """
1296 # Get the assets referenced within this `RootElement`'s namescope.
1297 assets = {file_obj.to_xml_string(): file_obj.get_contents()
1298 for file_obj in self.namescope.files
1299 if file_obj.value}
1300
1301 # Recursively add assets belonging to attachments.
1302 for attached_model in self._attachments.values():
1303 assets.update(attached_model.get_assets())
1304
1305 return assets
1306
1307 @property
1308 def full_identifier(self):

Callers 14

testAssetInheritanceMethod · 0.95
testGetAssetFromFileMethod · 0.80
testGetAssetsFromDictMethod · 0.80
testAssetsCanBeCopiedMethod · 0.80
export_with_assetsFunction · 0.80
test_export_modelMethod · 0.80
setUpMethod · 0.80
test_cachingMethod · 0.80
from_mjcf_modelMethod · 0.80

Calls 4

get_contentsMethod · 0.80
valuesMethod · 0.80
to_xml_stringMethod · 0.45
updateMethod · 0.45

Tested by 10

testAssetInheritanceMethod · 0.76
testGetAssetFromFileMethod · 0.64
testGetAssetsFromDictMethod · 0.64
testAssetsCanBeCopiedMethod · 0.64
test_export_modelMethod · 0.64
setUpMethod · 0.64
test_cachingMethod · 0.64
testXmlFromZipMethod · 0.64
test_export_modelMethod · 0.64