in mujoco_worldgen/objs/obj.py [0:0]
def mark(self, mark_name, relative_xyz=(0.5, 0.5, 0.5), absolute_xyz=None, rgba=None,
geom_type="sphere", size=np.array([0.1, 0.1, 0.1])):
'''
Similar to append(), but with markers (named sites)
mark_name - (string) name for the mark site
placement_name - name of the placement to use
common placements are "top" and "inside",
If None, reference base object coordinates.
placement_xyz - ratio position of (x, y, z), in between 0 and 1
specifies location as fraction of full extents
e.g. placement_xyz=(0.5, 0.5, 0.5) is the center
of the volume of the placement.
rgba - RGBA value of the mark (default is blue)
geom_type - Geom type, like "sphere" or "box"
Note: append() uses xy because objects always rest on the ground, but
mark() uses xyz because sites are unaffected by gravity.
'''
if not self.placeable:
print("Don't mark %s. It doesn't make sense." % self.__module__)
exit(-1)
assert mark_name not in [m['name'] for m in self.markers], \
"Marker with name {} already exists".format(mark_name)
if rgba is None:
rgba = np.array([0., 0., 1., 1.])
else:
if isinstance(rgba, tuple):
rgba = list(rgba)
if isinstance(rgba, list):
rgba = np.array(rgba)
assert len(rgba.shape) == 1 and rgba.shape[0] in [3, 4], "rgba has incorrect shape"
if rgba.shape[0] == 3:
rgba = np.concatenate([rgba, np.ones(1)])
rgba = rgba.astype(np.float32)
marker = {'name': mark_name,
'relative_xyz': relative_xyz,
'absolute_xyz': absolute_xyz,
'rgba': rgba,
'type': geom_type,
'size': size}
# TODO: use Maker() class of some form,
# The old one isn't suitable, so maybe a new one derived from Obj?
# For now a dictionary approximates it
self.markers.append(marker)