def _config_sim(self, scene_filepath, img_size): settings = { "width": img_size[1], # Spatial resolution of the observations "height": img_size[0], "scene": scene_filepath, # Scene path "default_agent": 0, "sensor_height": 1.5, # Height of sensors in meters "color_sensor": True, # RGBA sensor "semantic_sensor": True, # Semantic sensor "depth_sensor": True, # Depth sensor "silent": True, } sim_cfg = hsim.SimulatorConfiguration() sim_cfg.enable_physics = False sim_cfg.gpu_device_id = 0 sim_cfg.scene_id = settings["scene"] # define default sensor parameters (see src/esp/Sensor/Sensor.h) sensor_specs = [] if settings["color_sensor"]: color_sensor_spec = habitat_sim.CameraSensorSpec() color_sensor_spec.uuid = "color_sensor" color_sensor_spec.sensor_type = habitat_sim.SensorType.COLOR color_sensor_spec.resolution = [ settings["height"], settings["width"] ] color_sensor_spec.postition = [0.0, settings["sensor_height"], 0.0] color_sensor_spec.sensor_subtype = habitat_sim.SensorSubType.PINHOLE sensor_specs.append(color_sensor_spec) if settings["depth_sensor"]: depth_sensor_spec = habitat_sim.CameraSensorSpec() depth_sensor_spec.uuid = "depth_sensor" depth_sensor_spec.sensor_type = habitat_sim.SensorType.DEPTH depth_sensor_spec.resolution = [ settings["height"], settings["width"] ] depth_sensor_spec.postition = [0.0, settings["sensor_height"], 0.0] depth_sensor_spec.sensor_subtype = habitat_sim.SensorSubType.PINHOLE sensor_specs.append(depth_sensor_spec) if settings["semantic_sensor"]: semantic_sensor_spec = habitat_sim.CameraSensorSpec() semantic_sensor_spec.uuid = "semantic_sensor" semantic_sensor_spec.sensor_type = habitat_sim.SensorType.SEMANTIC semantic_sensor_spec.resolution = [ settings["height"], settings["width"] ] semantic_sensor_spec.postition = [ 0.0, settings["sensor_height"], 0.0 ] semantic_sensor_spec.sensor_subtype = habitat_sim.SensorSubType.PINHOLE sensor_specs.append(semantic_sensor_spec) # create agent specifications agent_cfg = AgentConfiguration() agent_cfg.sensor_specifications = sensor_specs return habitat_sim.Configuration(sim_cfg, [agent_cfg])
def _config_sim(self, scene_filepath, img_size): settings = { "width": img_size[1], # Spatial resolution of the observations "height": img_size[0], "scene": scene_filepath, # Scene path "default_agent": 0, "sensor_height": 1.5, # Height of sensors in meters "color_sensor": True, # RGBA sensor "semantic_sensor": True, # Semantic sensor "depth_sensor": True, # Depth sensor "silent": True, } sim_cfg = hsim.SimulatorConfiguration() sim_cfg.enable_physics = False sim_cfg.gpu_device_id = 0 sim_cfg.scene.id = settings["scene"] # define default sensor parameters (see src/esp/Sensor/Sensor.h) sensors = { "color_sensor": { # active if sim_settings["color_sensor"] "sensor_type": hsim.SensorType.COLOR, "resolution": [settings["height"], settings["width"]], "position": [0.0, settings["sensor_height"], 0.0], }, "depth_sensor": { # active if sim_settings["depth_sensor"] "sensor_type": hsim.SensorType.DEPTH, "resolution": [settings["height"], settings["width"]], "position": [0.0, settings["sensor_height"], 0.0], }, "semantic_sensor": { # active if sim_settings["semantic_sensor"] "sensor_type": hsim.SensorType.SEMANTIC, "resolution": [settings["height"], settings["width"]], "position": [0.0, settings["sensor_height"], 0.0], }, } # create sensor specifications sensor_specs = [] for sensor_uuid, sensor_params in sensors.items(): if settings[sensor_uuid]: sensor_spec = hsim.SensorSpec() sensor_spec.uuid = sensor_uuid sensor_spec.sensor_type = sensor_params["sensor_type"] sensor_spec.resolution = sensor_params["resolution"] sensor_spec.position = sensor_params["position"] sensor_spec.gpu2gpu_transfer = False sensor_specs.append(sensor_spec) # create agent specifications agent_cfg = AgentConfiguration() agent_cfg.sensor_specifications = sensor_specs return habitat_sim.Configuration(sim_cfg, [agent_cfg])
def _config_pathfinder(self, config: Configuration) -> None: if "navmesh" in config.sim_cfg.scene.filepaths: navmesh_filenname = config.sim_cfg.scene.filepaths["navmesh"] else: scene_basename = osp.basename(config.sim_cfg.scene.id) # "mesh.ply" is identified as a replica model, whose navmesh # is named as "mesh_semantic.navmesh" and is placed in the # subfolder called "habitat" (a level deeper than the "mesh.ply") if scene_basename == "mesh.ply": scene_dir = osp.dirname(config.sim_cfg.scene.id) navmesh_filenname = osp.join( scene_dir, "habitat", "mesh_semantic.navmesh" ) else: navmesh_filenname = ( osp.splitext(config.sim_cfg.scene.id)[0] + ".navmesh" ) self.pathfinder = PathFinder() if osp.exists(navmesh_filenname): self.pathfinder.load_nav_mesh(navmesh_filenname) logger.info(f"Loaded navmesh {navmesh_filenname}") else: logger.warning( f"Could not find navmesh {navmesh_filenname}, no collision checking will be done" ) agent_legacy_config = AgentConfiguration() default_agent_config = config.agents[config.sim_cfg.default_agent_id] if not np.isclose( agent_legacy_config.radius, default_agent_config.radius ) or not np.isclose(agent_legacy_config.height, default_agent_config.height): logger.info( f"Recomputing navmesh for agent's height {default_agent_config.height} and radius" f" {default_agent_config.radius}." ) navmesh_settings = NavMeshSettings() navmesh_settings.set_defaults() navmesh_settings.agent_radius = default_agent_config.radius navmesh_settings.agent_height = default_agent_config.height self.recompute_navmesh(self.pathfinder, navmesh_settings) self.pathfinder.seed(config.sim_cfg.random_seed)