Skip to content
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

Sim settings update #1920

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5889712
camera specs to dictionary
Oct 28, 2022
7a4e545
updating tests
Oct 28, 2022
f9ad2ab
updating sensors tests
Oct 31, 2022
3707be8
fixing settings and sensor tests
Oct 31, 2022
c6b4947
fixed sensor and hfov errors
Oct 31, 2022
b5022e0
width/height putting back to its original place
Oct 31, 2022
b5dd880
i forgot orientation
Nov 2, 2022
49d9fb8
dict of dicts
Nov 8, 2022
1c1e9e8
dict of dicts
Nov 8, 2022
ced1280
dict of dicts
Nov 8, 2022
71280a7
fix failing tests
Nov 8, 2022
68e61df
fix example
Nov 8, 2022
8875866
update depth sensor stuff
Nov 8, 2022
b236eac
simulator test
Nov 8, 2022
85efe2c
test_sensors tests failing
Nov 8, 2022
b3142a2
merge from main and update submodules
jrreyna Nov 29, 2022
7dc8edb
added agent_id to default sensor settings.
jrreyna Dec 1, 2022
e5a5e6c
update tests/test_sensors.py to reflect sensor settings now having an…
jrreyna Dec 1, 2022
091a2a7
update ECCV_2020_Interactivity.py tutorial to use updated settings file
jrreyna Dec 1, 2022
b4bccac
updated ECCV_2020_Advanced_Features.py to use new settings update
jrreyna Dec 1, 2022
35601b6
made new function in settings.py to add or update sensor settings in …
jrreyna Dec 2, 2022
42e1181
removed debug print statement
jrreyna Dec 2, 2022
815b39b
updated example.py to use new 'update_sensor_settings' function
jrreyna Dec 2, 2022
9a7a9de
update ReplicaCAD_quickstart.py to use new update_sensor_settings fun…
jrreyna Dec 2, 2022
caaaa12
update ReplicaCAD_quickstart.py to use new settings.py refactor and u…
jrreyna Dec 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/demo_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,11 @@ def do_time_steps(self):
total_sim_step_time += self._sim._previous_step_time

if self._sim_settings["save_png"]:
if self._sim_settings["color_sensor"]:
if "color_sensor" in self._sim_settings["sensors"]:
self.save_color_observation(observations, total_frames)
if self._sim_settings["depth_sensor"]:
if "depth_sensor" in self._sim_settings["sensors"]:
self.save_depth_observation(observations, total_frames)
if self._sim_settings["semantic_sensor"]:
if "semantic_sensor" in self._sim_settings["sensors"]:
self.save_semantic_observation(observations, total_frames)

state = self._sim.last_state()
Expand All @@ -283,7 +283,7 @@ def do_time_steps(self):
print("len(action_path)", len(self._action_path))

if (
self._sim_settings["semantic_sensor"]
"semantic_sensor" in self._sim_settings["sensors"]
and self._sim_settings["print_semantic_mask_stats"]
):
self.output_semantic_mask_stats(observations, total_frames)
Expand Down
29 changes: 23 additions & 6 deletions examples/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

import demo_runner as dr

import habitat_sim
from habitat_sim.utils.settings import update_sensor_settings

parser = argparse.ArgumentParser()
parser.add_argument("--scene", type=str, default=dr.default_sim_settings["scene"])
parser.add_argument("--width", type=int, default=640)
Expand Down Expand Up @@ -44,10 +47,6 @@ def make_settings():
settings["height"] = args.height
settings["scene"] = args.scene
settings["save_png"] = args.save_png
settings["sensor_height"] = args.sensor_height
settings["color_sensor"] = not args.disable_color_sensor
settings["semantic_sensor"] = args.semantic_sensor
settings["depth_sensor"] = args.depth_sensor
settings["print_semantic_scene"] = args.print_semantic_scene
settings["print_semantic_mask_stats"] = args.print_semantic_mask_stats
settings["compute_shortest_path"] = args.compute_shortest_path
Expand All @@ -59,6 +58,25 @@ def make_settings():
settings["frustum_culling"] = not args.disable_frustum_culling
settings["recompute_navmesh"] = args.recompute_navmesh

# add sensor settings to simulator settings
if not args.disable_color_sensor:
update_sensor_settings(
settings, uuid="color_sensor", position=[0.0, args.sensor_height, 0.0]
)
if args.semantic_sensor:
update_sensor_settings(
settings,
uuid="semantic_sensor",
position=[0.0, args.sensor_height, 0.0],
sensor_type=habitat_sim.SensorType.SEMANTIC,
)
if args.depth_sensor:
update_sensor_settings(
settings,
uuid="depth_sensor",
position=[0.0, args.sensor_height, 0.0],
sensor_type=habitat_sim.SensorType.DEPTH,
)
return settings


Expand All @@ -72,8 +90,7 @@ def make_settings():

print(" ========================= Performance ======================== ")
print(
" %d x %d, total time %0.2f s,"
% (settings["width"], settings["height"], perf["total_time"]),
" %d x %d, total time %0.2f s," % (args.width, args.height, perf["total_time"]),
"frame time %0.3f ms (%0.1f FPS)" % (perf["frame_time"] * 1000.0, perf["fps"]),
)
print(" ============================================================== ")
Expand Down
139 changes: 30 additions & 109 deletions examples/tutorials/colabs/ECCV_2020_Advanced_Features.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
"import habitat_sim\n",
"from habitat_sim.utils import common as ut\n",
"from habitat_sim.utils import viz_utils as vut\n",
"from habitat_sim.utils.settings import (\n",
" default_sim_settings,\n",
" make_cfg,\n",
" update_sensor_settings,\n",
")\n",
"\n",
"try:\n",
" import ipywidgets as widgets\n",
Expand Down Expand Up @@ -413,117 +418,32 @@
"# @markdown (double click to show code)\n",
"\n",
"# @markdown This cell defines a number of utility functions used throughout the tutorial to make simulator reconstruction easy:\n",
"# @markdown - make_cfg\n",
"# @markdown - make_default_settings\n",
"# @markdown - make_custom_settings\n",
"# @markdown - make_simulator_from_settings\n",
"\n",
"\n",
"def make_cfg(settings):\n",
" sim_cfg = habitat_sim.SimulatorConfiguration()\n",
" sim_cfg.gpu_device_id = 0\n",
" sim_cfg.scene_id = settings[\"scene\"]\n",
" sim_cfg.enable_physics = settings[\"enable_physics\"]\n",
" # Optional; Specify the location of an existing scene dataset configuration\n",
" # that describes the locations and configurations of all the assets to be used\n",
" if \"scene_dataset_config\" in settings:\n",
" sim_cfg.scene_dataset_config_file = settings[\"scene_dataset_config\"]\n",
"\n",
" # Note: all sensors must have the same resolution\n",
" sensor_specs = []\n",
" if settings[\"color_sensor_1st_person\"]:\n",
" color_sensor_1st_person_spec = habitat_sim.CameraSensorSpec()\n",
" color_sensor_1st_person_spec.uuid = \"color_sensor_1st_person\"\n",
" color_sensor_1st_person_spec.sensor_type = habitat_sim.SensorType.COLOR\n",
" color_sensor_1st_person_spec.resolution = [\n",
" settings[\"height\"],\n",
" settings[\"width\"],\n",
" ]\n",
" color_sensor_1st_person_spec.position = [0.0, settings[\"sensor_height\"], 0.0]\n",
" color_sensor_1st_person_spec.orientation = [\n",
" settings[\"sensor_pitch\"],\n",
" 0.0,\n",
" 0.0,\n",
" ]\n",
" color_sensor_1st_person_spec.sensor_subtype = habitat_sim.SensorSubType.PINHOLE\n",
" sensor_specs.append(color_sensor_1st_person_spec)\n",
" if settings[\"depth_sensor_1st_person\"]:\n",
" depth_sensor_1st_person_spec = habitat_sim.CameraSensorSpec()\n",
" depth_sensor_1st_person_spec.uuid = \"depth_sensor_1st_person\"\n",
" depth_sensor_1st_person_spec.sensor_type = habitat_sim.SensorType.DEPTH\n",
" depth_sensor_1st_person_spec.resolution = [\n",
" settings[\"height\"],\n",
" settings[\"width\"],\n",
" ]\n",
" depth_sensor_1st_person_spec.position = [0.0, settings[\"sensor_height\"], 0.0]\n",
" depth_sensor_1st_person_spec.orientation = [\n",
" settings[\"sensor_pitch\"],\n",
" 0.0,\n",
" 0.0,\n",
" ]\n",
" depth_sensor_1st_person_spec.sensor_subtype = habitat_sim.SensorSubType.PINHOLE\n",
" sensor_specs.append(depth_sensor_1st_person_spec)\n",
" if settings[\"semantic_sensor_1st_person\"]:\n",
" semantic_sensor_1st_person_spec = habitat_sim.CameraSensorSpec()\n",
" semantic_sensor_1st_person_spec.uuid = \"semantic_sensor_1st_person\"\n",
" semantic_sensor_1st_person_spec.sensor_type = habitat_sim.SensorType.SEMANTIC\n",
" semantic_sensor_1st_person_spec.resolution = [\n",
" settings[\"height\"],\n",
" settings[\"width\"],\n",
" ]\n",
" semantic_sensor_1st_person_spec.position = [\n",
" 0.0,\n",
" settings[\"sensor_height\"],\n",
" 0.0,\n",
" ]\n",
" semantic_sensor_1st_person_spec.orientation = [\n",
" settings[\"sensor_pitch\"],\n",
" 0.0,\n",
" 0.0,\n",
" ]\n",
" semantic_sensor_1st_person_spec.sensor_subtype = (\n",
" habitat_sim.SensorSubType.PINHOLE\n",
" )\n",
" sensor_specs.append(semantic_sensor_1st_person_spec)\n",
" if settings[\"color_sensor_3rd_person\"]:\n",
" color_sensor_3rd_person_spec = habitat_sim.CameraSensorSpec()\n",
" color_sensor_3rd_person_spec.uuid = \"color_sensor_3rd_person\"\n",
" color_sensor_3rd_person_spec.sensor_type = habitat_sim.SensorType.COLOR\n",
" color_sensor_3rd_person_spec.resolution = [\n",
" settings[\"height\"],\n",
" settings[\"width\"],\n",
" ]\n",
" color_sensor_3rd_person_spec.position = [\n",
" 0.0,\n",
" settings[\"sensor_height\"] + 0.2,\n",
" 0.2,\n",
" ]\n",
" color_sensor_3rd_person_spec.orientation = [-math.pi / 4, 0, 0]\n",
" color_sensor_3rd_person_spec.sensor_subtype = habitat_sim.SensorSubType.PINHOLE\n",
" sensor_specs.append(color_sensor_3rd_person_spec)\n",
"\n",
" # Here you can specify the amount of displacement in a forward action and the turn angle\n",
" agent_cfg = habitat_sim.agent.AgentConfiguration()\n",
" agent_cfg.sensor_specifications = sensor_specs\n",
"\n",
" return habitat_sim.Configuration(sim_cfg, [agent_cfg])\n",
"\n",
"\n",
"def make_default_settings():\n",
"def make_custom_settings():\n",
" \"\"\"\n",
" create custom simulator settings. All sim settings not explicitly assigned are given default values\n",
" \"\"\"\n",
" settings = {\n",
" \"width\": 720, # Spatial resolution of the observations\n",
" \"height\": 544,\n",
" \"scene\": \"./data/scene_datasets/mp3d_example/17DRP5sb8fy/17DRP5sb8fy.glb\", # Scene path\n",
" \"scene_dataset\": \"./data/scene_datasets/mp3d_example/mp3d.scene_dataset_config.json\", # mp3d scene dataset\n",
" \"default_agent\": 0,\n",
" \"sensor_height\": 1.5, # Height of sensors in meters\n",
" \"sensor_pitch\": -math.pi / 8.0, # sensor pitch (x rotation in rads)\n",
" \"color_sensor_1st_person\": True, # RGB sensor\n",
" \"color_sensor_3rd_person\": False, # RGB sensor 3rd person\n",
" \"depth_sensor_1st_person\": False, # Depth sensor\n",
" \"semantic_sensor_1st_person\": False, # Semantic sensor\n",
" \"seed\": 1,\n",
" \"scene_dataset_config_file\": \"./data/scene_datasets/mp3d_example/mp3d.scene_dataset_config.json\", # mp3d scene dataset\n",
" \"enable_physics\": True, # enable dynamics simulation\n",
" }\n",
" # Instantiate all non-assigned elements of simulator settings to the default values\n",
" settings = {**default_sim_settings, **settings}\n",
"\n",
" # add settings for a new sensor to the simulator settings. All sensor settings not\n",
" # explicitly assigned are given default values\n",
" update_sensor_settings(\n",
" settings,\n",
" \"color_sensor_1st_person\",\n",
" position=[0, 1.5, 0],\n",
" orientation=[-math.pi / 8.0, 0.0, 0.0],\n",
" )\n",
" return settings\n",
"\n",
"\n",
Expand Down Expand Up @@ -885,9 +805,8 @@
"outputs": [],
"source": [
"# @title Initialize Simulator and Load Scene { display-mode: \"form\" }\n",
"sim_settings = make_default_settings()\n",
"sim_settings = make_custom_settings()\n",
"sim_settings[\"scene\"] = \"./data/scene_datasets/mp3d_example/17DRP5sb8fy/17DRP5sb8fy.glb\"\n",
"sim_settings[\"sensor_pitch\"] = 0\n",
"\n",
"make_simulator_from_settings(sim_settings)"
]
Expand Down Expand Up @@ -1074,10 +993,13 @@
"source": [
"# @markdown ###Configuring Object Semantic IDs:\n",
"\n",
"sim_settings = make_default_settings()\n",
"sim_settings = make_custom_settings()\n",
"sim_settings[\"scene\"] = \"./data/scene_datasets/mp3d_example/17DRP5sb8fy/17DRP5sb8fy.glb\"\n",
"sim_settings[\"sensor_pitch\"] = 0\n",
"sim_settings[\"semantic_sensor_1st_person\"] = True\n",
"update_sensor_settings(\n",
" sim_settings,\n",
" uuid=\"semantic_sensor_1st_person\",\n",
" sensor_type=habitat_sim.SensorType.SEMANTIC,\n",
")\n",
"\n",
"make_simulator_from_settings(sim_settings)\n",
"\n",
Expand Down Expand Up @@ -1177,9 +1099,8 @@
"source": [
"# @title Initialize Simulator and Load Scene { display-mode: \"form\" }\n",
"# @markdown (load the apartment_1 scene for object and primitive asset customization in an open space)\n",
"sim_settings = make_default_settings()\n",
"sim_settings = make_custom_settings()\n",
"sim_settings[\"scene\"] = \"./data/scene_datasets/habitat-test-scenes/apartment_1.glb\"\n",
"sim_settings[\"sensor_pitch\"] = 0\n",
"\n",
"make_simulator_from_settings(sim_settings)\n",
"\n",
Expand Down
Loading