-
Notifications
You must be signed in to change notification settings - Fork 491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Lab interactive viewer extending sim viewer #1099
Draft
aclegg3
wants to merge
1
commit into
main
Choose a base branch
from
lab-viewer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# Copyright (c) Meta Platforms, Inc. and its affiliates. | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
import ctypes | ||
import os | ||
import sys | ||
from typing import Any, Dict | ||
|
||
import git | ||
|
||
flags = sys.getdlopenflags() | ||
sys.setdlopenflags(flags | ctypes.RTLD_GLOBAL) | ||
|
||
from habitat_sim.utils.settings import default_sim_settings | ||
from habitat_sim.viewer import viewer as sim_viewer | ||
|
||
repo = git.Repo(".", search_parent_directories=True) | ||
dir_path = repo.working_tree_dir | ||
# %cd $dir_path | ||
data_path = os.path.join(dir_path, "data") | ||
|
||
|
||
class HabitatLabInteractiveViewer(sim_viewer.HabitatSimInteractiveViewer): | ||
def __init__(self, sim_settings: Dict[str, Any]) -> None: | ||
sim_viewer.HabitatSimInteractiveViewer.__init__(self, sim_settings) | ||
|
||
|
||
if __name__ == "__main__": | ||
import argparse | ||
|
||
parser = argparse.ArgumentParser() | ||
|
||
# optional arguments | ||
parser.add_argument( | ||
"--scene", | ||
default="./data/test_assets/scenes/simple_room.glb", | ||
type=str, | ||
help='scene/stage file to load (default: "./data/test_assets/scenes/simple_room.glb")', | ||
) | ||
parser.add_argument( | ||
"--dataset", | ||
default="./data/objects/ycb/ycb.scene_dataset_config.json", | ||
type=str, | ||
metavar="DATASET", | ||
help='dataset configuration file to use (default: "./data/objects/ycb/ycb.scene_dataset_config.json")', | ||
) | ||
parser.add_argument( | ||
"--disable-physics", | ||
action="store_true", | ||
help="disable physics simulation (default: False)", | ||
) | ||
parser.add_argument( | ||
"--stage-requires-lighting", | ||
action="store_true", | ||
help="Override configured lighting to use synthetic lighting for the stage.", | ||
) | ||
parser.add_argument( | ||
"--enable-batch-renderer", | ||
action="store_true", | ||
help="Enable batch rendering mode. The number of concurrent environments is specified with the num-environments parameter.", | ||
) | ||
parser.add_argument( | ||
"--num-environments", | ||
default=1, | ||
type=int, | ||
help="Number of concurrent environments to batch render. Note that only the first environment simulates physics and can be controlled.", | ||
) | ||
parser.add_argument( | ||
"--composite-files", | ||
type=str, | ||
nargs="*", | ||
help="Composite files that the batch renderer will use in-place of simulation assets to improve memory usage and performance. If none is specified, the original scene files will be loaded from disk.", | ||
) | ||
parser.add_argument( | ||
"--width", | ||
default=800, | ||
type=int, | ||
help="Horizontal resolution of the window.", | ||
) | ||
parser.add_argument( | ||
"--height", | ||
default=600, | ||
type=int, | ||
help="Vertical resolution of the window.", | ||
) | ||
|
||
args = parser.parse_args() | ||
|
||
if args.num_environments < 1: | ||
parser.error("num-environments must be a positive non-zero integer.") | ||
if args.width < 1: | ||
parser.error("width must be a positive non-zero integer.") | ||
if args.height < 1: | ||
parser.error("height must be a positive non-zero integer.") | ||
|
||
# Setting up sim_settings | ||
sim_settings: Dict[str, Any] = default_sim_settings.copy() | ||
sim_settings["scene"] = args.scene | ||
sim_settings["scene_dataset_config_file"] = args.dataset | ||
sim_settings["enable_physics"] = not args.disable_physics | ||
sim_settings["stage_requires_lighting"] = args.stage_requires_lighting | ||
sim_settings["enable_batch_renderer"] = args.enable_batch_renderer | ||
sim_settings["num_environments"] = args.num_environments | ||
sim_settings["composite_files"] = args.composite_files | ||
sim_settings["window_width"] = args.width | ||
sim_settings["window_height"] = args.height | ||
# setup the font path relative to the current file | ||
sim_settings["font_path"] = os.path.join( | ||
data_path, "fonts/ProggyClean.ttf" | ||
) | ||
|
||
# start the application | ||
HabitatLabInteractiveViewer(sim_settings).exec() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mosra this was necessary here to avoid the EGL issues running this file.