Skip to content

constants

Constant Definitions

get_class_name_to_class_id()

Get mapping from semantic class name to class id

Returns:

Name Type Description
dict

starting class id for scene objects

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

    Returns:
        dict: starting class id for scene objects
    """
    existing_classes = {item.value for item in SemanticClass}
    category_txt = os.path.join(omnigibson.og_dataset_path, "metadata/categories.txt")
    class_name_to_class_id = {"agent": SemanticClass.ROBOTS}  # Agents should have the robot semantic class.
    starting_class_id = 0
    if os.path.isfile(category_txt):
        with open(category_txt) as f:
            for line in f.readlines():
                while starting_class_id in existing_classes:
                    starting_class_id += 1
                assert starting_class_id < MAX_CLASS_COUNT, "Class ID overflow: MAX_CLASS_COUNT is {}.".format(
                    MAX_CLASS_COUNT
                )
                class_name_to_class_id[line.strip()] = starting_class_id
                starting_class_id += 1

    return class_name_to_class_id

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 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