Ejemplo n.º 1
0
    def sound20k_set(self) -> None:
        """
        Generate a dataset analogous to Sound20K.
        """

        sound20k_init_commands = [
            {
                "$type": "load_scene"
            },
            TDWUtils.create_empty_room(12, 12), {
                "$type": "set_proc_gen_walls_scale",
                "walls": TDWUtils.get_box(12, 12),
                "scale": {
                    "x": 1,
                    "y": 4,
                    "z": 1
                }
            }, {
                "$type": "set_reverb_space_simple",
                "env_id": 0,
                "reverb_floor_material": "parquet",
                "reverb_ceiling_material": "acousticTile",
                "reverb_front_wall_material": "smoothPlaster",
                "reverb_back_wall_material": "smoothPlaster",
                "reverb_left_wall_material": "smoothPlaster",
                "reverb_right_wall_material": "smoothPlaster"
            }, {
                "$type": "create_avatar",
                "type": "A_Img_Caps_Kinematic",
                "id": "a"
            }, {
                "$type": "add_environ_audio_sensor"
            }, {
                "$type": "toggle_image_sensor"
            }
        ]

        self.process_sub_set("Sound20K", "models_per_material_sound20k",
                             sound20k_init_commands, get_sound20k_scenes())
Ejemplo n.º 2
0
def create_office(width, length, corridor_width, min_room_length,
                  max_room_length):
    """
    Generate a simple office.

    :param width: Width of the room.
    :param length: Length of the room.
    :param corridor_width: Width of the central corridor.
    :param min_room_length: Minimum length of a room.
    :param max_room_length: Maximum length of a room.
    :return The commands to create the office.
    """

    # Create the exterior walls.
    exterior_walls = TDWUtils.get_box(width, length)

    interior_walls = []

    doorway_length = 2
    width = max([w["x"] for w in exterior_walls])
    length = max([w["y"] for w in exterior_walls])

    # Go north.
    corridor_x = int(width / 2) - int(corridor_width / 2)
    next_start_doorway = random.randint(min_room_length, max_room_length)
    next_end_doorway = next_start_doorway + doorway_length
    for y in range(length):
        if not (next_end_doorway >= y > next_start_doorway):
            interior_walls.append({"x": corridor_x, "y": y})
        # Build a perpendicular wall at the doorway.
        if y == next_end_doorway + 1:
            for x in range(0, corridor_x):
                interior_walls.append({"x": x, "y": y})
            next_start_doorway = y + random.randint(min_room_length,
                                                    max_room_length)
            next_end_doorway = next_start_doorway + doorway_length

    # Go south.
    corridor_x = int(width / 2) + int(corridor_width / 2)
    next_start_doorway = random.randint(min_room_length, max_room_length)
    next_end_doorway = next_start_doorway + doorway_length
    for y in range(length):
        if not (next_end_doorway >= y > next_start_doorway):
            interior_walls.append({"x": corridor_x, "y": y})
        # Build a perpendicular wall at the doorway.
        if y == next_end_doorway + 1:
            for x in range(corridor_x, width):
                interior_walls.append({"x": x, "y": y})
            next_start_doorway = y + random.randint(min_room_length,
                                                    max_room_length)
            next_end_doorway = next_start_doorway + doorway_length

    # Remove bad interior walls.
    interior_walls = [
        i for i in interior_walls
        if i["y"] < length - doorway_length or i["x"] == 0 or i["x"] == width
    ]
    walls = []
    walls.extend(exterior_walls)
    walls.extend(interior_walls)

    return [{
        "$type": "create_exterior_walls",
        "walls": exterior_walls
    }, {
        "$type": "create_interior_walls",
        "walls": interior_walls
    }]