Prompts the user to select any available interactive scene and loads it.
Source code in OmniGibson/omnigibson/examples/scenes/scene_selector.py
| def main(random_selection=False, headless=False, short_exec=False):
"""
Prompts the user to select any available interactive scene and loads it.
"""
og.log.info(f"Demo {__file__}\n " + "*" * 80 + "\n Description:\n" + main.__doc__ + "*" * 80)
# Choose the scene model to load
scenes = get_available_behavior_1k_scenes()
scene_model = choose_from_options(options=scenes, name="scene model", random_selection=random_selection)
cfg = {
"scene": {
"type": "InteractiveTraversableScene",
"scene_model": scene_model,
},
}
# Check if we want to quick load or full load the scene
load_options = {
"Quick": "Only load the building assets (i.e.: the floors, walls, ceilings)",
"Full": "Load all interactive objects in the scene",
}
load_mode = choose_from_options(options=load_options, name="load mode", random_selection=random_selection)
if load_mode == "Quick":
cfg["scene"]["load_object_categories"] = list(STRUCTURE_CATEGORIES)
# Load the environment
env = og.Environment(configs=cfg)
# Allow user to move camera more easily
if not gm.HEADLESS:
og.sim.enable_viewer_camera_teleoperation()
KeyboardEventHandler.add_keyboard_callback(
key=lazy.carb.input.KeyboardInput.ESCAPE,
callback_fn=lambda: og.shutdown(),
)
print("Running demo.")
print("Press ESC to quit")
# Loop indefinitely
steps = 0
max_steps = -1 if not short_exec else 100
while steps != max_steps:
env.step([])
steps += 1
og.shutdown()
|