Skip to content

Commit

Permalink
--properly initialize magnum vectors for sensor spec pos and orientat…
Browse files Browse the repository at this point in the history
…ion.

--Need floating point values for list/np.array initialization.
  • Loading branch information
jturner65 committed Feb 5, 2024
1 parent 8740a27 commit 0160f2a
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 40 deletions.
6 changes: 2 additions & 4 deletions examples/motion_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import time
from typing import Any, Callable, Dict, Optional, Tuple

import numpy as np

flags = sys.getdlopenflags()
sys.setdlopenflags(flags | ctypes.RTLD_GLOBAL)

Expand Down Expand Up @@ -121,8 +119,8 @@ def reconfigure_sim(self) -> None:
self.sim_settings["height"],
self.sim_settings["width"],
]
camera_sensor_spec.position = np.array([0, 0, 0])
camera_sensor_spec.orientation = np.array([0, 0, 0])
camera_sensor_spec.position = mn.Vector3([0, 0, 0])
camera_sensor_spec.orientation = mn.Vector3([0, 0, 0])
camera_sensor_spec.uuid = "fpov_sensor"

agent_config = habitat_sim.agent.AgentConfiguration(
Expand Down
16 changes: 8 additions & 8 deletions examples/tutorials/nb_python/ECCV_2020_Advanced_Features.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def make_cfg(settings):
settings["sensor_height"] + 0.2,
0.2,
]
color_sensor_3rd_person_spec.orientation = [-math.pi / 4, 0, 0]
color_sensor_3rd_person_spec.orientation = [-math.pi / 4, 0.0, 0.0]
color_sensor_3rd_person_spec.sensor_subtype = habitat_sim.SensorSubType.PINHOLE
sensor_specs.append(color_sensor_3rd_person_spec)

Expand Down Expand Up @@ -574,8 +574,8 @@ def init_camera_track_config(sim, sensor_name="color_sensor_1st_person", agent_I
init_state["position"] = np.array(visual_sensor._spec.position)
init_state["orientation"] = np.array(visual_sensor._spec.orientation)
# set the color sensor transform to be the agent transform
visual_sensor._spec.position = np.array([0, 0, 0])
visual_sensor._spec.orientation = np.array([0, 0, 0])
visual_sensor._spec.position = np.array([0.0, 0.0, 0.0])
visual_sensor._spec.orientation = np.array([0.0, 0.0, 0.0])
visual_sensor._sensor_object.set_transformation_from_spec()
# save ID of agent being modified
init_state["agent_ID"] = agent_ID
Expand Down Expand Up @@ -848,7 +848,7 @@ def build_widget_ui(obj_attr_mgr, prim_attr_mgr):
sim_settings["scene"] = os.path.join(
data_path, "scene_datasets/mp3d_example/17DRP5sb8fy/17DRP5sb8fy.glb"
)
sim_settings["sensor_pitch"] = 0
sim_settings["sensor_pitch"] = 0.0

make_simulator_from_settings(sim_settings)

Expand All @@ -870,8 +870,8 @@ def build_widget_ui(obj_attr_mgr, prim_attr_mgr):
initial_sensor_position = np.array(visual_sensor._spec.position)
initial_sensor_orientation = np.array(visual_sensor._spec.orientation)
# set the color sensor transform to be the agent transform
visual_sensor._spec.position = np.array([0, 0, 0])
visual_sensor._spec.orientation = np.array([0, 0, 0])
visual_sensor._spec.position = np.array([0.0, 0.0, 0.0])
visual_sensor._spec.orientation = np.array([0.0, 0.0, 0.0])
visual_sensor._sensor_object.set_transformation_from_spec()

# boost the agent off the floor
Expand Down Expand Up @@ -1006,7 +1006,7 @@ def get_2d_point(sim, sensor_name, point_3d):
sim_settings["scene"] = os.path.join(
data_path, "scene_datasets/mp3d_example/17DRP5sb8fy/17DRP5sb8fy.glb"
)
sim_settings["sensor_pitch"] = 0
sim_settings["sensor_pitch"] = 0.0
sim_settings["semantic_sensor_1st_person"] = True

make_simulator_from_settings(sim_settings)
Expand Down Expand Up @@ -1097,7 +1097,7 @@ def get_2d_point(sim, sensor_name, point_3d):
sim_settings["scene"] = os.path.join(
data_path, "scene_datasets/habitat-test-scenes/apartment_1.glb"
)
sim_settings["sensor_pitch"] = 0
sim_settings["sensor_pitch"] = 0.0

make_simulator_from_settings(sim_settings)

Expand Down
6 changes: 3 additions & 3 deletions examples/tutorials/nb_python/ECCV_2020_Interactivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def make_cfg(settings):
settings["sensor_height"] + 0.2,
0.2,
]
color_sensor_3rd_person_spec.orientation = [-math.pi / 4, 0, 0]
color_sensor_3rd_person_spec.orientation = [-math.pi / 4, 0.0, 0.0]
color_sensor_3rd_person_spec.sensor_subtype = habitat_sim.SensorSubType.PINHOLE
sensor_specs.append(color_sensor_3rd_person_spec)

Expand Down Expand Up @@ -887,7 +887,7 @@ def build_widget_ui(obj_attr_mgr, prim_attr_mgr):
sim_settings["scene"] = os.path.join(
data_path, "scene_datasets/habitat-test-scenes/apartment_1.glb"
)
sim_settings["sensor_pitch"] = 0
sim_settings["sensor_pitch"] = 0.0

make_simulator_from_settings(sim_settings)

Expand Down Expand Up @@ -1180,7 +1180,7 @@ def release(self):
# fmt: off
sim_settings["scene"] = os.path.join(data_path, "scene_datasets/mp3d_example/17DRP5sb8fy/17DRP5sb8fy.glb") # @param{type:"string"}
# fmt: on
sim_settings["sensor_pitch"] = 0
sim_settings["sensor_pitch"] = 0.0
sim_settings["sensor_height"] = 0.6
sim_settings["color_sensor_3rd_person"] = True
sim_settings["depth_sensor_1st_person"] = True
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/nb_python/ReplicaCAD_quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def make_default_settings():
"scene": "NONE", # Scene path
"default_agent": 0,
"sensor_height": 1.5, # Height of sensors in meters
"sensor_pitch": 0, # sensor pitch (x rotation in rads)
"sensor_pitch": 0.0, # sensor pitch (x rotation in rads)
"seed": 1,
"enable_physics": True, # enable dynamics simulation
}
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorials/nb_python/asset_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def make_cfg(settings):
settings["sensor_height"] + 0.2,
0.2,
]
color_sensor_3rd_person_spec.orientation = [-math.pi / 4, 0, 0]
color_sensor_3rd_person_spec.orientation = [-math.pi / 4, 0.0, 0.0]
color_sensor_3rd_person_spec.sensor_subtype = habitat_sim.SensorSubType.PINHOLE
sensor_specs.append(color_sensor_3rd_person_spec)

Expand Down Expand Up @@ -720,7 +720,7 @@ def build_widget_ui(obj_attr_mgr, prim_attr_mgr):

sim_settings = make_default_settings()
sim_settings["scene"] = "none"
sim_settings["sensor_pitch"] = 0
sim_settings["sensor_pitch"] = 0.0
sim_settings["override_scene_light_defaults"] = True
sim_settings["scene_light_setup"] = ""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def make_configuration():
rgba_camera_3rdperson_spec.sensor_type = habitat_sim.SensorType.COLOR
rgba_camera_3rdperson_spec.resolution = camera_resolution
rgba_camera_3rdperson_spec.position = [0.0, 1.0, 0.3]
rgba_camera_3rdperson_spec.orientation = [-45, 0.0, 0.0]
rgba_camera_3rdperson_spec.orientation = [-45.0, 0.0, 0.0]
rgba_camera_3rdperson_spec.sensor_subtype = habitat_sim.SensorSubType.PINHOLE
sensor_specs.append(rgba_camera_3rdperson_spec)

Expand Down
16 changes: 8 additions & 8 deletions examples/tutorials/notebooks/ECCV_2020_Advanced_Features.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@
" 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.orientation = [-math.pi / 4, 0.0, 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",
Expand Down Expand Up @@ -580,8 +580,8 @@
" init_state[\"position\"] = np.array(visual_sensor._spec.position)\n",
" init_state[\"orientation\"] = np.array(visual_sensor._spec.orientation)\n",
" # set the color sensor transform to be the agent transform\n",
" visual_sensor._spec.position = np.array([0, 0, 0])\n",
" visual_sensor._spec.orientation = np.array([0, 0, 0])\n",
" visual_sensor._spec.position = np.array([0.0, 0.0, 0.0])\n",
" visual_sensor._spec.orientation = np.array([0.0, 0.0, 0.0])\n",
" visual_sensor._sensor_object.set_transformation_from_spec()\n",
" # save ID of agent being modified\n",
" init_state[\"agent_ID\"] = agent_ID\n",
Expand Down Expand Up @@ -875,7 +875,7 @@
"sim_settings[\"scene\"] = os.path.join(\n",
" data_path, \"scene_datasets/mp3d_example/17DRP5sb8fy/17DRP5sb8fy.glb\"\n",
")\n",
"sim_settings[\"sensor_pitch\"] = 0\n",
"sim_settings[\"sensor_pitch\"] = 0.0\n",
"\n",
"make_simulator_from_settings(sim_settings)"
]
Expand Down Expand Up @@ -915,8 +915,8 @@
"initial_sensor_position = np.array(visual_sensor._spec.position)\n",
"initial_sensor_orientation = np.array(visual_sensor._spec.orientation)\n",
"# set the color sensor transform to be the agent transform\n",
"visual_sensor._spec.position = np.array([0, 0, 0])\n",
"visual_sensor._spec.orientation = np.array([0, 0, 0])\n",
"visual_sensor._spec.position = np.array([0.0, 0.0, 0.0])\n",
"visual_sensor._spec.orientation = np.array([0.0, 0.0, 0.0])\n",
"visual_sensor._sensor_object.set_transformation_from_spec()\n",
"\n",
"# boost the agent off the floor\n",
Expand Down Expand Up @@ -1070,7 +1070,7 @@
"sim_settings[\"scene\"] = os.path.join(\n",
" data_path, \"scene_datasets/mp3d_example/17DRP5sb8fy/17DRP5sb8fy.glb\"\n",
")\n",
"sim_settings[\"sensor_pitch\"] = 0\n",
"sim_settings[\"sensor_pitch\"] = 0.0\n",
"sim_settings[\"semantic_sensor_1st_person\"] = True\n",
"\n",
"make_simulator_from_settings(sim_settings)\n",
Expand Down Expand Up @@ -1175,7 +1175,7 @@
"sim_settings[\"scene\"] = os.path.join(\n",
" data_path, \"scene_datasets/habitat-test-scenes/apartment_1.glb\"\n",
")\n",
"sim_settings[\"sensor_pitch\"] = 0\n",
"sim_settings[\"sensor_pitch\"] = 0.0\n",
"\n",
"make_simulator_from_settings(sim_settings)\n",
"\n",
Expand Down
6 changes: 3 additions & 3 deletions examples/tutorials/notebooks/ECCV_2020_Interactivity.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
" 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.orientation = [-math.pi / 4, 0.0, 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",
Expand Down Expand Up @@ -973,7 +973,7 @@
"sim_settings[\"scene\"] = os.path.join(\n",
" data_path, \"scene_datasets/habitat-test-scenes/apartment_1.glb\"\n",
")\n",
"sim_settings[\"sensor_pitch\"] = 0\n",
"sim_settings[\"sensor_pitch\"] = 0.0\n",
"\n",
"make_simulator_from_settings(sim_settings)"
]
Expand Down Expand Up @@ -1304,7 +1304,7 @@
"# fmt: off\n",
"sim_settings[\"scene\"] = os.path.join(data_path, \"scene_datasets/mp3d_example/17DRP5sb8fy/17DRP5sb8fy.glb\") # @param{type:\"string\"}\n",
"# fmt: on\n",
"sim_settings[\"sensor_pitch\"] = 0\n",
"sim_settings[\"sensor_pitch\"] = 0.0\n",
"sim_settings[\"sensor_height\"] = 0.6\n",
"sim_settings[\"color_sensor_3rd_person\"] = True\n",
"sim_settings[\"depth_sensor_1st_person\"] = True\n",
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/notebooks/ReplicaCAD_quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
" \"scene\": \"NONE\", # Scene path\n",
" \"default_agent\": 0,\n",
" \"sensor_height\": 1.5, # Height of sensors in meters\n",
" \"sensor_pitch\": 0, # sensor pitch (x rotation in rads)\n",
" \"sensor_pitch\": 0.0, # sensor pitch (x rotation in rads)\n",
" \"seed\": 1,\n",
" \"enable_physics\": True, # enable dynamics simulation\n",
" }\n",
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorials/notebooks/asset_viewer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
" 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.orientation = [-math.pi / 4, 0.0, 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",
Expand Down Expand Up @@ -733,7 +733,7 @@
"\n",
"sim_settings = make_default_settings()\n",
"sim_settings[\"scene\"] = \"none\"\n",
"sim_settings[\"sensor_pitch\"] = 0\n",
"sim_settings[\"sensor_pitch\"] = 0.0\n",
"sim_settings[\"override_scene_light_defaults\"] = True\n",
"sim_settings[\"scene_light_setup\"] = \"\"\n",
"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
" rgba_camera_3rdperson_spec.sensor_type = habitat_sim.SensorType.COLOR\n",
" rgba_camera_3rdperson_spec.resolution = camera_resolution\n",
" rgba_camera_3rdperson_spec.position = [0.0, 1.0, 0.3]\n",
" rgba_camera_3rdperson_spec.orientation = [-45, 0.0, 0.0]\n",
" rgba_camera_3rdperson_spec.orientation = [-45.0, 0.0, 0.0]\n",
" rgba_camera_3rdperson_spec.sensor_subtype = habitat_sim.SensorSubType.PINHOLE\n",
" sensor_specs.append(rgba_camera_3rdperson_spec)\n",
"\n",
Expand Down
18 changes: 12 additions & 6 deletions src_python/habitat_sim/utils/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ def make_cfg(settings: Dict[str, Any]):
def create_camera_spec(**kw_args):
camera_sensor_spec = habitat_sim.CameraSensorSpec()
camera_sensor_spec.sensor_type = habitat_sim.SensorType.COLOR
camera_sensor_spec.resolution = [settings["height"], settings["width"]]
camera_sensor_spec.position = [0, settings["sensor_height"], 0]
camera_sensor_spec.resolution = mn.Vector2i(
[settings["height"], settings["width"]]
)
camera_sensor_spec.position = mn.Vector3(0, settings["sensor_height"], 0)
for k in kw_args:
setattr(camera_sensor_spec, k, kw_args[k])
return camera_sensor_spec
Expand Down Expand Up @@ -186,11 +188,13 @@ def create_fisheye_spec(**kw_args):
fisheye_sensor_spec.alpha = 0.57
fisheye_sensor_spec.focal_length = [364.84, 364.86]

fisheye_sensor_spec.resolution = [settings["height"], settings["width"]]
fisheye_sensor_spec.resolution = mn.Vector2i(
[settings["height"], settings["width"]]
)
# The default principal_point_offset is the middle of the image
fisheye_sensor_spec.principal_point_offset = None
# default: fisheye_sensor_spec.principal_point_offset = [i/2 for i in fisheye_sensor_spec.resolution]
fisheye_sensor_spec.position = [0, settings["sensor_height"], 0]
fisheye_sensor_spec.position = mn.Vector3(0, settings["sensor_height"], 0)
for k in kw_args:
setattr(fisheye_sensor_spec, k, kw_args[k])
return fisheye_sensor_spec
Expand Down Expand Up @@ -218,8 +222,10 @@ def create_equirect_spec(**kw_args):
equirect_sensor_spec = habitat_sim.EquirectangularSensorSpec()
equirect_sensor_spec.uuid = "equirect_rgba_sensor"
equirect_sensor_spec.sensor_type = habitat_sim.SensorType.COLOR
equirect_sensor_spec.resolution = [settings["height"], settings["width"]]
equirect_sensor_spec.position = [0, settings["sensor_height"], 0]
equirect_sensor_spec.resolution = mn.Vector2i(
[settings["height"], settings["width"]]
)
equirect_sensor_spec.position = mn.Vector3(0, settings["sensor_height"], 0)
for k in kw_args:
setattr(equirect_sensor_spec, k, kw_args[k])
return equirect_sensor_spec
Expand Down

0 comments on commit 0160f2a

Please sign in to comment.