feat(scenegraph): add depth-based 3D positioning via pinhole projection

- Add bbox_depth_center position strategy in SceneGraphBuilder using depth
  at bbox centre and configurable camera_hfov_degrees for pinhole projection.
- Add optional depth_sensor_uuid to HabitatSimulatorConfig; create depth
  sensor spec alongside RGB sensor.
- Add camera_position/camera_rotation fields to RoomView; capture pose from
  sensor_states when depth sensor is available.
- Update flatten_room_views for backward compatibility with legacy tuple
  format.
- Wired in depth sensor and bbox_depth_center strategy in verification
  notebook.
- Add tests for depth sensor support and new position strategies.
This commit is contained in:
2026-05-31 14:29:05 +08:00
parent a127032e18
commit 7a1e1ccf3f
7 changed files with 1729 additions and 38 deletions

View File

@@ -15,6 +15,26 @@ class HabitatSimulatorConfig:
enable_physics: bool = False
sensor_uuid: str = "color_sensor"
agent_id: int = 0
depth_sensor_uuid: str | None = "depth_sensor"
hfov_degrees: float = 90.0
def _camera_sensor_spec(
habitat_sim_module: Any,
*,
uuid: str,
sensor_type: Any,
image_size: int,
sensor_height: float,
hfov_degrees: float,
) -> Any:
spec = habitat_sim_module.CameraSensorSpec()
spec.uuid = uuid
spec.sensor_type = sensor_type
spec.resolution = [image_size, image_size]
spec.position = [0.0, sensor_height, 0.0]
spec.hfov = float(hfov_degrees)
return spec
def create_habitat_simulator(
@@ -30,6 +50,11 @@ def create_habitat_simulator(
if config.move_forward_step <= 0:
raise ValueError("move_forward_step must be greater than 0")
if not (0 < config.hfov_degrees < 180):
raise ValueError(
f"hfov_degrees must be in (0, 180), got {config.hfov_degrees}"
)
if habitat_sim_module is None:
habitat_sim_module = import_module("habitat_sim")
@@ -38,12 +63,31 @@ def create_habitat_simulator(
sim_cfg.enable_physics = config.enable_physics
agent_cfg = habitat_sim_module.agent.AgentConfiguration()
rgb_sensor_spec = habitat_sim_module.CameraSensorSpec()
rgb_sensor_spec.uuid = config.sensor_uuid
rgb_sensor_spec.sensor_type = habitat_sim_module.SensorType.COLOR
rgb_sensor_spec.resolution = [config.image_size, config.image_size]
rgb_sensor_spec.position = [0.0, config.sensor_height, 0.0]
agent_cfg.sensor_specifications = [rgb_sensor_spec]
sensor_specs = [
_camera_sensor_spec(
habitat_sim_module,
uuid=config.sensor_uuid,
sensor_type=habitat_sim_module.SensorType.COLOR,
image_size=config.image_size,
sensor_height=config.sensor_height,
hfov_degrees=config.hfov_degrees,
),
]
if config.depth_sensor_uuid is not None:
sensor_specs.append(
_camera_sensor_spec(
habitat_sim_module,
uuid=config.depth_sensor_uuid,
sensor_type=habitat_sim_module.SensorType.DEPTH,
image_size=config.image_size,
sensor_height=config.sensor_height,
hfov_degrees=config.hfov_degrees,
),
)
agent_cfg.sensor_specifications = sensor_specs
turn_angle = 360.0 / config.views_per_room
agent_cfg.action_space = {