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

Method name2id

dm_control/mujoco/wrapper/core.py:339–360  ·  view source on GitHub ↗

Returns the integer ID of a specified MuJoCo object. Args: name: String specifying the name of the object to query. object_type: The type of the object. Can be either a lowercase string (e.g. 'body', 'geom') or an `mjtObj` enum value. Returns: An integer object ID

(self, name, object_type)

Source from the content-addressed store, hash-verified

337 del self._ptr
338
339 def name2id(self, name, object_type):
340 """Returns the integer ID of a specified MuJoCo object.
341
342 Args:
343 name: String specifying the name of the object to query.
344 object_type: The type of the object. Can be either a lowercase string
345 (e.g. 'body', 'geom') or an `mjtObj` enum value.
346
347 Returns:
348 An integer object ID.
349
350 Raises:
351 Error: If `object_type` is not a valid MuJoCo object type, or if no object
352 with the corresponding name and type was found.
353 """
354 if isinstance(object_type, str):
355 object_type = _str2type(object_type)
356 obj_id = mujoco.mj_name2id(self.ptr, object_type, name)
357 if obj_id == -1:
358 raise Error("Object of type {!r} with name {!r} does not exist.".format(
359 _type2str(object_type), name))
360 return obj_id
361
362 def id2name(self, object_id, object_type):
363 """Returns the name associated with a MuJoCo object ID, if there is one.

Callers 12

qpos_from_site_poseFunction · 0.80
test_idMethod · 0.80
element_idMethod · 0.80
initialize_episodeMethod · 0.80
initialize_episodeMethod · 0.80
initialize_episodeMethod · 0.80
__init__Method · 0.80
object_velocityMethod · 0.80
testNamesIdsMethod · 0.80

Calls 3

_str2typeFunction · 0.85
ErrorClass · 0.85
_type2strFunction · 0.85

Tested by 4

test_idMethod · 0.64
testNamesIdsMethod · 0.64