Skip to content

constants

Constant Definitions

get_collision_group_mask(groups_to_exclude=[])

Get a collision group mask that has collisions enabled for every group except those in groups_to_exclude.

Source code in omnigibson/utils/constants.py
def get_collision_group_mask(groups_to_exclude=[]):
    """Get a collision group mask that has collisions enabled for every group except those in groups_to_exclude."""
    collision_mask = ALL_COLLISION_GROUPS_MASK
    for group in groups_to_exclude:
        collision_mask &= ~(1 << group)
    return collision_mask

semantic_class_id_to_name() cached

Get mapping from semantic class id to class name

Returns:

Name Type Description
dict

class id to class name

Source code in omnigibson/utils/constants.py
@cache
def semantic_class_id_to_name():
    """
    Get mapping from semantic class id to class name

    Returns:
        dict: class id to class name
    """
    return {v: k for k, v in semantic_class_name_to_id().items()}

semantic_class_name_to_id() cached

Get mapping from semantic class name to class id

Returns:

Name Type Description
dict

class name to class id

Source code in omnigibson/utils/constants.py
@cache
def semantic_class_name_to_id():
    """
    Get mapping from semantic class name to class id

    Returns:
        dict: class name to class id
    """
    categories = get_all_object_categories()
    from omnigibson.systems.system_base import REGISTERED_SYSTEMS
    systems = sorted(REGISTERED_SYSTEMS)
    all_semantics = sorted(set(categories + systems + ["background", "unlabelled", "object", "light", "agent"]))

    # Assign a unique class id to each class name with hashing
    class_name_to_class_id = {s: int(hashlib.md5(s.encode()).hexdigest(), 16) % (2 ** 32) for s in all_semantics}

    return class_name_to_class_id