def test_config_eq(): cfg1 = habitat_sim.Configuration(habitat_sim.SimulatorConfiguration(), [habitat_sim.AgentConfiguration()]) cfg2 = habitat_sim.Configuration(habitat_sim.SimulatorConfiguration(), [habitat_sim.AgentConfiguration()]) assert cfg1 == cfg2
def make_cfg(settings): sim_cfg = habitat_sim.SimulatorConfiguration() sim_cfg.gpu_device_id = 0 sim_cfg.scene.id = settings["scene"] # Note: all sensors must have the same resolution sensors = { "color_sensor": { "sensor_type": habitat_sim.SensorType.COLOR, "resolution": [settings["height"], settings["width"]], "position": [0.0, settings["sensor_height"], 0.0], }, "depth_sensor": { "sensor_type": habitat_sim.SensorType.DEPTH, "resolution": [settings["height"], settings["width"]], "position": [0.0, settings["sensor_height"], 0.0], }, "semantic_sensor": { "sensor_type": habitat_sim.SensorType.SEMANTIC, "resolution": [settings["height"], settings["width"]], "position": [0.0, settings["sensor_height"], 0.0], }, } sensor_specs = [] for sensor_uuid, sensor_params in sensors.items(): if settings[sensor_uuid]: sensor_spec = habitat_sim.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_specs.append(sensor_spec) # Here you can specify the amount of displacement in a forward action and the turn angle agent_cfg = habitat_sim.agent.AgentConfiguration() agent_cfg.sensor_specifications = sensor_specs agent_cfg.action_space = { "move_forward": habitat_sim.agent.ActionSpec( "move_forward", habitat_sim.agent.ActuationSpec(amount=0.05)), "move_back": habitat_sim.agent.ActionSpec( "move_forward", habitat_sim.agent.ActuationSpec(amount=-0.05)), "turn_left": habitat_sim.agent.ActionSpec( "turn_left", habitat_sim.agent.ActuationSpec(amount=2.0)), "turn_right": habitat_sim.agent.ActionSpec( "turn_right", habitat_sim.agent.ActuationSpec(amount=2.0)), "look_up": habitat_sim.ActionSpec("look_up", habitat_sim.ActuationSpec(amount=2.0)), "look_down": habitat_sim.ActionSpec("look_down", habitat_sim.ActuationSpec(amount=2.0)) } return habitat_sim.Configuration(sim_cfg, [agent_cfg])
def confSim(settings): sim_config = habitat_sim.SimulatorConfiguration() sim_config.scene_id = settings["scene"] #Configuration for Sensors sensor_spec = [] color_sensor_spec = habitat_sim.SensorSpec() 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.position = [0.0, settings["sensor_height"], 0.0] sensor_spec.append(color_sensor_spec) depth_sensor_spec = habitat_sim.SensorSpec() 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.position = [0.0, settings["sensor_height"], 0.0] sensor_spec.append(depth_sensor_spec) #Configure Agent agent_config = habitat_sim.AgentConfiguration() agent_config.sensor_specifications = sensor_spec return habitat_sim.Configuration(sim_config,[agent_config])
def setup_sim_and_sensors(): left_rgb_sensor = create_sensor(orientation=[0.0, 0.0, 0.0], position=[eye_seperation / 2, 0, 0], sensor_uuid="left_rgb_sensor") right_rgb_sensor = create_sensor(position=[-eye_seperation / 2, 0, 0], sensor_uuid="right_rgb_sensor") depth_sensor = create_sensor(sensor_uuid="depth_sensor", camera_type="D") # agent configuration has the sensor_specifications objects as a list new_agent_config = habitat_sim.AgentConfiguration() new_agent_config.sensor_specifications = [ left_rgb_sensor, right_rgb_sensor, depth_sensor ] # Configuration of the backend of the simulator includes default_agent_id set to 0 backend_cfg = habitat_sim.SimulatorConfiguration() default_agent_id = backend_cfg.default_agent_id backend_cfg.foveation_distortion = True backend_cfg.scene.id = ("../multi_agent/data_files/skokloster-castle.glb") # backend_cfg.scene.id = ( # "/Users/rajan/My_Replica/replica_v1/room_2/mesh.ply" # ) # Tie the backend of the simulator and a list of agent configurations new_Configuration = habitat_sim.Configuration(backend_cfg, [new_agent_config]) # When Simulator is called the agent configuration becomes Agents (only one agent in our case] new_sim = habitat_sim.Simulator(new_Configuration) return new_sim, default_agent_id
def create_sim_config( self, _sensor_suite: SensorSuite) -> habitat_sim.Configuration: sim_config = habitat_sim.SimulatorConfiguration() sim_config.scene.id = self.config.SCENE sim_config.gpu_device_id = self.config.HABITAT_SIM_V0.GPU_DEVICE_ID sim_config.allow_sliding = self.config.HABITAT_SIM_V0.ALLOW_SLIDING sim_config.enable_physics = self.config.HABITAT_SIM_V0.ENABLE_PHYSICS sim_config.physics_config_file = ( self.config.HABITAT_SIM_V0.PHYSICS_CONFIG_FILE) agent_config = habitat_sim.AgentConfiguration() overwrite_config(config_from=self._get_agent_config(), config_to=agent_config) sensor_specifications = [] for sensor in _sensor_suite.sensors.values(): sim_sensor_cfg = habitat_sim.SensorSpec() sim_sensor_cfg.uuid = sensor.uuid sim_sensor_cfg.resolution = list( sensor.observation_space.shape[:2]) sim_sensor_cfg.parameters["hfov"] = str(sensor.config.HFOV) sim_sensor_cfg.position = sensor.config.POSITION # TODO(maksymets): Add configure method to Sensor API to avoid # accessing child attributes through parent interface sim_sensor_cfg.sensor_type = sensor.sim_sensor_type # type: ignore sim_sensor_cfg.gpu2gpu_transfer = ( self.config.HABITAT_SIM_V0.GPU_GPU) sensor_specifications.append(sim_sensor_cfg) agent_config.sensor_specifications = sensor_specifications agent_config.action_space = registry.get_action_space_configuration( self.config.ACTION_SPACE_CONFIG)(self.config).get() return habitat_sim.Configuration(sim_config, [agent_config])
def create_sim_config( self, _sensor_suite: SensorSuite) -> habitat_sim.Configuration: sim_config = habitat_sim.SimulatorConfiguration() # sim_config.scene.id = '/private/home/medhini/navigation-analysis-habitat/habitat-api/' + self.config.SCENE sim_config.scene.id = self.config.SCENE sim_config.gpu_device_id = self.config.HABITAT_SIM_V0.GPU_DEVICE_ID agent_config = habitat_sim.AgentConfiguration() overwrite_config(config_from=self._get_agent_config(), config_to=agent_config) sensor_specifications = [] for sensor in _sensor_suite.sensors.values(): sim_sensor_cfg = habitat_sim.SensorSpec() sim_sensor_cfg.uuid = sensor.uuid sim_sensor_cfg.resolution = list( sensor.observation_space.shape[:2]) sim_sensor_cfg.parameters["hfov"] = str(sensor.config.HFOV) sim_sensor_cfg.position = sensor.config.POSITION # TODO(maksymets): Add configure method to Sensor API to avoid # accessing child attributes through parent interface sim_sensor_cfg.sensor_type = sensor.sim_sensor_type # type: ignore sensor_specifications.append(sim_sensor_cfg) # If there is no sensors specified create a dummy sensor so simulator # won't throw an error if not _sensor_suite.sensors.values(): sim_sensor_cfg = habitat_sim.SensorSpec() sim_sensor_cfg.resolution = [1, 1] sensor_specifications.append(sim_sensor_cfg) agent_config.sensor_specifications = sensor_specifications agent_config.action_space = registry.get_action_space_configuration( self.config.ACTION_SPACE_CONFIG)(self.config).get() return habitat_sim.Configuration(sim_config, [agent_config])
def make_cfg(settings, intrinsics=None): sim_cfg = habitat_sim.SimulatorConfiguration() sim_cfg.gpu_device_id = 0 sim_cfg.scene_id = settings["scene"] if intrinsics is None: hfov = 63.414969 # use suncg else: hfov = get_hfov(intrinsics, settings['width']) # Note: all sensors must have the same resolution sensors = { "color_sensor": { "sensor_type": habitat_sim.SensorType.COLOR, "resolution": [settings["height"], settings["width"]], "position": [0.0, settings["sensor_height"], 0.0], "hfov": str(hfov) }, "depth_sensor": { "sensor_type": habitat_sim.SensorType.DEPTH, "resolution": [settings["height"], settings["width"]], "position": [0.0, settings["sensor_height"], 0.0], "hfov": str(hfov) }, "semantic_sensor": { "sensor_type": habitat_sim.SensorType.SEMANTIC, "resolution": [settings["height"], settings["width"]], "position": [0.0, settings["sensor_height"], 0.0], "hfov": str(hfov) }, } sensor_specs = [] for sensor_uuid, sensor_params in sensors.items(): if settings[sensor_uuid]: sensor_spec = habitat_sim.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.parameters['hfov'] = sensor_params["hfov"] sensor_specs.append(sensor_spec) # Here you can specify the amount of displacement in a forward action and the turn angle agent_cfg = habitat_sim.agent.AgentConfiguration() agent_cfg.sensor_specifications = sensor_specs agent_cfg.action_space = { "move_forward": habitat_sim.agent.ActionSpec( "move_forward", habitat_sim.agent.ActuationSpec(amount=0.25)), "turn_left": habitat_sim.agent.ActionSpec( "turn_left", habitat_sim.agent.ActuationSpec(amount=30.0)), "turn_right": habitat_sim.agent.ActionSpec( "turn_right", habitat_sim.agent.ActuationSpec(amount=30.0)), } return habitat_sim.Configuration(sim_cfg, [agent_cfg])
def create_sim_config( self, _sensor_suite: SensorSuite) -> habitat_sim.Configuration: sim_config = habitat_sim.SimulatorConfiguration() overwrite_config(config_from=self.config.HABITAT_SIM_V0, config_to=sim_config) sim_config.scene.id = self.config.SCENE agent_config = habitat_sim.AgentConfiguration() overwrite_config(config_from=self._get_agent_config(), config_to=agent_config) sensor_specifications = [] for sensor in _sensor_suite.sensors.values(): sim_sensor_cfg = habitat_sim.SensorSpec() overwrite_config(config_from=sensor.config, config_to=sim_sensor_cfg) sim_sensor_cfg.uuid = sensor.uuid sim_sensor_cfg.resolution = list( sensor.observation_space.shape[:2]) sim_sensor_cfg.parameters["hfov"] = str(sensor.config.HFOV) # TODO(maksymets): Add configure method to Sensor API to avoid # accessing child attributes through parent interface sim_sensor_cfg.sensor_type = sensor.sim_sensor_type # type: ignore sim_sensor_cfg.gpu2gpu_transfer = ( self.config.HABITAT_SIM_V0.GPU_GPU) sensor_specifications.append(sim_sensor_cfg) agent_config.sensor_specifications = sensor_specifications agent_config.action_space = registry.get_action_space_configuration( self.config.ACTION_SPACE_CONFIG)(self.config).get() return habitat_sim.Configuration(sim_config, [agent_config])
def make_configuration(scene_file): # simulator configuration backend_cfg = habitat_sim.SimulatorConfiguration() backend_cfg.scene_id = scene_file backend_cfg.enable_physics = True # sensor configurations # Note: all sensors must have the same resolution # setup rgb and semantic sensors camera_resolution = [1080, 960] sensor_specs = [] rgba_camera_spec = habitat_sim.CameraSensorSpec() rgba_camera_spec.uuid = "rgba_camera" rgba_camera_spec.sensor_type = habitat_sim.SensorType.COLOR rgba_camera_spec.resolution = camera_resolution rgba_camera_spec.postition = [0.0, 1.5, 0.0] # ::: fix y to be 0 later rgba_camera_spec.sensor_subtype = habitat_sim.SensorSubType.PINHOLE sensor_specs.append(rgba_camera_spec) semantic_camera_spec = habitat_sim.CameraSensorSpec() semantic_camera_spec.uuid = "semantic_camera" semantic_camera_spec.sensor_type = habitat_sim.SensorType.SEMANTIC semantic_camera_spec.resolution = camera_resolution semantic_camera_spec.postition = [0.0, 1.5, 0.0] semantic_camera_spec.sensor_subtype = habitat_sim.SensorSubType.PINHOLE sensor_specs.append(semantic_camera_spec) # agent configuration agent_cfg = habitat_sim.agent.AgentConfiguration() agent_cfg.sensor_specifications = sensor_specs return habitat_sim.Configuration(backend_cfg, [agent_cfg])
def test_multiple_construct_destroy(): sim_cfg = habitat_sim.SimulatorConfiguration() agent_config = habitat_sim.AgentConfiguration() sim_cfg.scene.id = "data/scene_datasets/habitat-test-scenes/van-gogh-room.glb" for _ in range(3): with habitat_sim.Simulator(habitat_sim.Configuration(sim_cfg, [agent_config])): pass
def setup_agent(dataset_path, random_pos, image_size, focal): random_up, random_left, random_back = random_pos backend_cfg = habitat_sim.SimulatorConfiguration() backend_cfg.scene.id = (dataset_path) hfov = 2 * np.arctan(0.5 * image_size[1] / focal) / np.pi * 180 # First, let's create a stereo RGB agent left_rgb_sensor = habitat_sim.SensorSpec() # Give it the uuid of left_sensor, this will also be how we # index the observations to retrieve the rendering from this sensor left_rgb_sensor.uuid = "left_rgb_sensor" left_rgb_sensor.resolution = image_size # The left RGB sensor will be 1.5 meters off the ground # and 0.25 meters to the left of the center of the agent left_rgb_sensor.position = random_up * habitat_sim.geo.UP + random_left * habitat_sim.geo.LEFT + random_back * habitat_sim.geo.BACK left_rgb_sensor.parameters["hfov"] = str(hfov) # Same deal with the right sensor right_rgb_sensor = habitat_sim.SensorSpec() right_rgb_sensor.uuid = "right_rgb_sensor" right_rgb_sensor.resolution = image_size # The right RGB sensor will be 1.5 meters off the ground # and 0.25 meters to the right of the center of the agent right_rgb_sensor.position = left_rgb_sensor.position + 0.5 * habitat_sim.geo.RIGHT right_rgb_sensor.parameters["hfov"] = str(hfov) # Now let's do the exact same thing but for a depth camera stereo pair! left_depth_sensor = habitat_sim.SensorSpec() left_depth_sensor.uuid = "left_depth_sensor" left_depth_sensor.resolution = image_size left_depth_sensor.position = left_rgb_sensor.position # The only difference is that we set the sensor type to DEPTH left_depth_sensor.sensor_type = habitat_sim.SensorType.DEPTH left_depth_sensor.parameters["hfov"] = str(hfov) right_depth_sensor = habitat_sim.SensorSpec() right_depth_sensor.uuid = "right_depth_sensor" right_depth_sensor.resolution = image_size right_depth_sensor.position = right_rgb_sensor.position # The only difference is that we set the sensor type to DEPTH right_depth_sensor.sensor_type = habitat_sim.SensorType.DEPTH right_depth_sensor.parameters["hfov"] = str(hfov) # Now we simly set the agent's list of sensor specs to be the two specs for our two sensors agent_config = habitat_sim.AgentConfiguration() agent_config.sensor_specifications = [ left_rgb_sensor, right_rgb_sensor, left_depth_sensor, right_depth_sensor ] sim = habitat_sim.Simulator( habitat_sim.Configuration(backend_cfg, [agent_config])) return sim
def make_cfg(settings): sim_cfg = habitat_sim.SimulatorConfiguration() sim_cfg.gpu_device_id = 0 sim_cfg.scene_id = settings["scene"] sim_cfg.enable_physics = settings["enable_physics"] # Note: all sensors must have the same resolution sensor_specs = [] # First, let's create a stereo RGB agent left_rgb_sensor = habitat_sim.bindings.CameraSensorSpec() # Give it the uuid of left_sensor, this will also be how we # index the observations to retrieve the rendering from this sensor left_rgb_sensor.uuid = "left_sensor" left_rgb_sensor.resolution = [settings["height"], settings["width"]] # The left RGB sensor will be 1.5 meters off the ground # and 0.25 meters to the left of the center of the agent left_rgb_sensor.position = 1.5 * habitat_sim.geo.UP + 0.05 * habitat_sim.geo.LEFT sensor_specs.append(left_rgb_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 = 1.5 * habitat_sim.geo.UP + 0.05 * habitat_sim.geo.LEFT depth_sensor_spec.sensor_subtype = habitat_sim.SensorSubType.PINHOLE sensor_specs.append(depth_sensor_spec) # Same deal with the right sensor right_rgb_sensor = habitat_sim.CameraSensorSpec() right_rgb_sensor.uuid = "right_sensor" right_rgb_sensor.resolution = [settings["height"], settings["width"]] # The right RGB sensor will be 1.5 meters off the ground # and 0.25 meters to the right of the center of the agent right_rgb_sensor.position = 1.5 * habitat_sim.geo.UP + 0.05 * habitat_sim.geo.RIGHT sensor_specs.append(right_rgb_sensor) # Here you can specify the amount of displacement in a forward action and the turn angle agent_cfg = habitat_sim.agent.AgentConfiguration() agent_cfg.sensor_specifications = sensor_specs agent_cfg.action_space = { "move_forward": habitat_sim.agent.ActionSpec( "move_forward", habitat_sim.agent.ActuationSpec(amount=0.05)), "turn_left": habitat_sim.agent.ActionSpec( "turn_left", habitat_sim.agent.ActuationSpec(amount=1.5)), "turn_right": habitat_sim.agent.ActionSpec( "turn_right", habitat_sim.agent.ActuationSpec(amount=1.5)), "do_nothing": habitat_sim.agent.ActionSpec( "turn_right", habitat_sim.agent.ActuationSpec(amount=0.0)) } return habitat_sim.Configuration(sim_cfg, [agent_cfg])
def _test_keep_agent_tgt(): sim_cfg = habitat_sim.SimulatorConfiguration() agent_config = habitat_sim.AgentConfiguration() sim_cfg.scene.id = "data/scene_datasets/habitat-test-scenes/van-gogh-room.glb" agents = [] for _ in range(3): with habitat_sim.Simulator( habitat_sim.Configuration(sim_cfg, [agent_config])) as sim: agents.append(sim.get_agent(0))
def sim_config(settings): sim_cfg = habitat_sim.SimulatorConfiguration() sim_cfg.scene_id = settings["scene"] agent = habitat_sim.agent.AgentConfiguration() rgb_sensor = habitat_sim.sensor.SensorSpec() rgb_sensor.uuid = "color_sensor" rgb_sensor.sensor_type = habitat_sim.SensorType.COLOR rgb_sensor.resolution = [settings["height"], settings["width"]] agent.sensor_specifications = [rgb_sensor] return habitat_sim.Configuration(sim_cfg, [agent])
def create_sim_config( self, _sensor_suite: SensorSuite) -> habitat_sim.Configuration: sim_config = habitat_sim.SimulatorConfiguration() sim_config.scene.id = self.config.SCENE sim_config.gpu_device_id = self.config.HABITAT_SIM_V0.GPU_DEVICE_ID agent_config = habitat_sim.AgentConfiguration() overwrite_config(config_from=self._get_agent_config(), config_to=agent_config) sensor_specifications = [] for sensor in _sensor_suite.sensors.values(): sim_sensor_cfg = habitat_sim.SensorSpec() sim_sensor_cfg.uuid = sensor.uuid sim_sensor_cfg.resolution = list( sensor.observation_space.shape[:2]) sim_sensor_cfg.parameters["hfov"] = str(sensor.config.HFOV) sim_sensor_cfg.position = sensor.config.POSITION # TODO(maksymets): Add configure method to Sensor API to avoid # accessing child attributes through parent interface sim_sensor_cfg.sensor_type = sensor.sim_sensor_type # type: ignore sensor_specifications.append(sim_sensor_cfg) # If there is no sensors specified create a dummy sensor so simulator # won't throw an error if not _sensor_suite.sensors.values(): sim_sensor_cfg = habitat_sim.SensorSpec() sim_sensor_cfg.resolution = [1, 1] sensor_specifications.append(sim_sensor_cfg) agent_config.sensor_specifications = sensor_specifications agent_config.action_space = { SimulatorActions.LEFT.value: habitat_sim.ActionSpec( "turn_left", habitat_sim.ActuationSpec(amount=self.config.TURN_ANGLE), ), SimulatorActions.RIGHT.value: habitat_sim.ActionSpec( "turn_right", habitat_sim.ActuationSpec(amount=self.config.TURN_ANGLE), ), SimulatorActions.FORWARD.value: habitat_sim.ActionSpec( "move_forward", habitat_sim.ActuationSpec( amount=self.config.FORWARD_STEP_SIZE), ), SimulatorActions.STOP.value: habitat_sim.ActionSpec("stop"), } return habitat_sim.Configuration(sim_config, [agent_config])
def make_cfg(settings): sim_cfg = habitat_sim.SimulatorConfiguration() sim_cfg.gpu_device_id = 0 sim_cfg.scene_id = settings["scene"] sim_cfg.enable_physics = settings["enable_physics"] # Note: all sensors must have the same resolution sensors = { "color_sensor_1st_person": { "sensor_type": habitat_sim.SensorType.COLOR, "resolution": [settings["height"], settings["width"]], "position": [0.0, settings["sensor_height"], 0.0], "orientation": [settings["sensor_pitch"], 0.0, 0.0], }, "depth_sensor_1st_person": { "sensor_type": habitat_sim.SensorType.DEPTH, "resolution": [settings["height"], settings["width"]], "position": [0.0, settings["sensor_height"], 0.0], "orientation": [settings["sensor_pitch"], 0.0, 0.0], }, "semantic_sensor_1st_person": { "sensor_type": habitat_sim.SensorType.SEMANTIC, "resolution": [settings["height"], settings["width"]], "position": [0.0, settings["sensor_height"], 0.0], "orientation": [settings["sensor_pitch"], 0.0, 0.0], }, # configure the 3rd person cam specifically: "color_sensor_3rd_person": { "sensor_type": habitat_sim.SensorType.COLOR, "resolution": [settings["height"], settings["width"]], "position": [0.0, settings["sensor_height"] + 0.2, 0.2], "orientation": np.array([-math.pi / 4, 0, 0]), }, } sensor_specs = [] for sensor_uuid, sensor_params in sensors.items(): if settings[sensor_uuid]: sensor_spec = habitat_sim.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.orientation = sensor_params["orientation"] sensor_specs.append(sensor_spec) # Here you can specify the amount of displacement in a forward action and the turn angle agent_cfg = habitat_sim.agent.AgentConfiguration() agent_cfg.sensor_specifications = sensor_specs return habitat_sim.Configuration(sim_cfg, [agent_cfg])
def make_cfg(settings): sim_cfg = habitat_sim.SimulatorConfiguration() sim_cfg.gpu_device_id = 0 sim_cfg.scene_id = settings["scene"] sim_cfg.enable_physics = settings["enable_physics"] # Note: all sensors must have the same resolution sensor_specs = [] 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) 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) 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) # Here you can specify the amount of displacement in a forward action and the turn angle agent_cfg = habitat_sim.agent.AgentConfiguration() agent_cfg.sensor_specifications = sensor_specs agent_cfg.action_space = { "move_forward": habitat_sim.agent.ActionSpec( "move_forward", habitat_sim.agent.ActuationSpec(amount=0.03)), "turn_left": habitat_sim.agent.ActionSpec( "turn_left", habitat_sim.agent.ActuationSpec(amount=0.5)), "turn_right": habitat_sim.agent.ActionSpec( "turn_right", habitat_sim.agent.ActuationSpec(amount=0.5)), "do_nothing": habitat_sim.agent.ActionSpec( "turn_right", habitat_sim.agent.ActuationSpec(amount=0.0)) } return habitat_sim.Configuration(sim_cfg, [agent_cfg])
def make_configuration(): # simulator configuration backend_cfg = habitat_sim.SimulatorConfiguration() backend_cfg.scene.id = "data/scene_datasets/habitat-test-scenes/van-gogh-room.glb" backend_cfg.enable_physics = True # agent configuration sensor_cfg = habitat_sim.SensorSpec() sensor_cfg.resolution = [1080, 960] agent_cfg = habitat_sim.agent.AgentConfiguration() agent_cfg.sensor_specifications = [sensor_cfg] return habitat_sim.Configuration(backend_cfg, [agent_cfg])
def test_multiple_construct_destroy(): sim_cfg = habitat_sim.SimulatorConfiguration() agent_config = habitat_sim.AgentConfiguration() sim_cfg.scene_id = "data/scene_datasets/habitat-test-scenes/van-gogh-room.glb" hab_cfg = habitat_sim.Configuration(sim_cfg, [agent_config]) mm = habitat_sim.metadata.MetadataMediator(sim_cfg) hab_cfg_mm = habitat_sim.Configuration(sim_cfg, [agent_config], mm) test_list = [hab_cfg, hab_cfg_mm] for ctor_arg in test_list: for _ in range(3): with habitat_sim.Simulator(ctor_arg): pass
def make_configuration(): # simulator configuration backend_cfg = habitat_sim.SimulatorConfiguration() backend_cfg.scene_id = os.path.join( data_path, "scene_datasets/mp3d/x8F5xyUWy9e/x8F5xyUWy9e.glb" ) assert os.path.exists(backend_cfg.scene_id) backend_cfg.enable_physics = True # sensor configurations # Note: all sensors must have the same resolution # setup 2 rgb sensors for 1st and 3rd person views camera_resolution = [544, 720] sensors = { "rgba_camera_1stperson": { "sensor_type": habitat_sim.SensorType.COLOR, "resolution": camera_resolution, "position": [0.0, 0.6, 0.0], "orientation": [0.0, 0.0, 0.0], }, "depth_camera_1stperson": { "sensor_type": habitat_sim.SensorType.DEPTH, "resolution": camera_resolution, "position": [0.0, 0.6, 0.0], "orientation": [0.0, 0.0, 0.0], }, "semantic_camera_1stperson": { "sensor_type": habitat_sim.SensorType.SEMANTIC, "resolution": camera_resolution, "position": [0.0, 1.0, 0.3], "orientation": [-45, 0.0, 0.0], }, } sensor_specs = [] for sensor_uuid, sensor_params in sensors.items(): sensor_spec = habitat_sim.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.orientation = sensor_params["orientation"] sensor_specs.append(sensor_spec) # agent configuration agent_cfg = habitat_sim.agent.AgentConfiguration() agent_cfg.sensor_specifications = sensor_specs return habitat_sim.Configuration(backend_cfg, [agent_cfg])
def _make_cfg(self, settings): sim_cfg = habitat_sim.SimulatorConfiguration() sim_cfg.gpu_device_id = int(self.params.get('gpu', _DEFAULT_GPU_DEVICE)) sim_cfg.scene.id = settings["scene"] # Setup Sensors # ------------------------------------------------------------ # Note: all sensors must have the same resolution sensors = { "color_sensor": { "sensor_type": habitat_sim.SensorType.COLOR, "resolution": [settings["height"], settings["width"]], "position": [0.0, settings["sensor_height"], 0.0], }, "semantic_sensor": { "sensor_type": habitat_sim.SensorType.SEMANTIC, "resolution": [settings["height"], settings["width"]], "position": [0.0, settings["sensor_height"], 0.0], } } if self.sim_settings['depth_sensor']: sensors["depth_sensor"] = { "sensor_type": habitat_sim.SensorType.DEPTH, "resolution": [settings["height"], settings["width"]], "position": [0.0, settings["sensor_height"], 0.0], } sensor_specs = [] for sensor_uuid, sensor_params in sensors.items(): if settings[sensor_uuid]: sensor_spec = habitat_sim.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.parameters["hfov"] = str(settings["hfov"]) sensor_specs.append(sensor_spec) # ------------------------------------------------------------ # Setup Agent # ------------------------------------------------------------ agent_cfg = habitat_sim.AgentConfiguration() agent_cfg.sensor_specifications = sensor_specs agent_cfg.action_space = {} # ------------------------------------------------------------ return habitat_sim.Configuration(sim_cfg, [agent_cfg])
def test_keep_agent(): sim_cfg = habitat_sim.SimulatorConfiguration() agent_config = habitat_sim.AgentConfiguration() sim_cfg.scene_id = "data/scene_datasets/habitat-test-scenes/van-gogh-room.glb" agents = [] hab_cfg = habitat_sim.Configuration(sim_cfg, [agent_config]) mm = habitat_sim.metadata.MetadataMediator(sim_cfg) hab_cfg_mm = habitat_sim.Configuration(sim_cfg, [agent_config], mm) test_list = [hab_cfg, hab_cfg_mm] for ctor_arg in test_list: for _ in range(3): with habitat_sim.Simulator(ctor_arg) as sim: agents.append(sim.get_agent(0))
def create_sim_config( self, _sensor_suite: SensorSuite ) -> habitat_sim.Configuration: sim_config = habitat_sim.SimulatorConfiguration() # Check if Habitat-Sim is post Scene Config Update if not hasattr(sim_config, "scene_id"): raise RuntimeError( "Incompatible version of Habitat-Sim detected, please upgrade habitat_sim" ) overwrite_config( config_from=self.habitat_config.HABITAT_SIM_V0, config_to=sim_config, ) sim_config.scene_id = self.habitat_config.SCENE agent_config = habitat_sim.AgentConfiguration() overwrite_config( config_from=self._get_agent_config(), config_to=agent_config ) sensor_specifications = [] for sensor in _sensor_suite.sensors.values(): sim_sensor_cfg = habitat_sim.SensorSpec() overwrite_config( config_from=sensor.config, config_to=sim_sensor_cfg ) sim_sensor_cfg.uuid = sensor.uuid sim_sensor_cfg.resolution = list( sensor.observation_space.shape[:2] ) sim_sensor_cfg.parameters["hfov"] = str(sensor.config.HFOV) # TODO(maksymets): Add configure method to Sensor API to avoid # accessing child attributes through parent interface # We know that the Sensor has to be one of these Sensors sensor = cast(HabitatSimVizSensors, sensor) sim_sensor_cfg.sensor_type = sensor.sim_sensor_type sim_sensor_cfg.gpu2gpu_transfer = ( self.habitat_config.HABITAT_SIM_V0.GPU_GPU ) sensor_specifications.append(sim_sensor_cfg) agent_config.sensor_specifications = sensor_specifications agent_config.action_space = registry.get_action_space_configuration( self.habitat_config.ACTION_SPACE_CONFIG )(self.habitat_config).get() return habitat_sim.Configuration(sim_config, [agent_config])
def make_configuration(): # simulator configuration backend_cfg = habitat_sim.SimulatorConfiguration() backend_cfg.scene_id = os.path.join( data_path, "scene_datasets/habitat-test-scenes/apartment_1.glb") assert os.path.exists(backend_cfg.scene_id) backend_cfg.enable_physics = True # sensor configurations # Note: all sensors must have the same resolution # setup 2 rgb sensors for 1st and 3rd person views camera_resolution = [544, 720] sensor_specs = [] rgba_camera_1stperson_spec = habitat_sim.CameraSensorSpec() rgba_camera_1stperson_spec.uuid = "rgba_camera_1stperson" rgba_camera_1stperson_spec.sensor_type = habitat_sim.SensorType.COLOR rgba_camera_1stperson_spec.resolution = camera_resolution rgba_camera_1stperson_spec.postition = [0.0, 0.6, 0.0] rgba_camera_1stperson_spec.orientation = [0.0, 0.0, 0.0] rgba_camera_1stperson_spec.sensor_subtype = habitat_sim.SensorSubType.PINHOLE sensor_specs.append(rgba_camera_1stperson_spec) depth_camera_1stperson_spec = habitat_sim.CameraSensorSpec() depth_camera_1stperson_spec.uuid = "depth_camera_1stperson" depth_camera_1stperson_spec.sensor_type = habitat_sim.SensorType.DEPTH depth_camera_1stperson_spec.resolution = camera_resolution depth_camera_1stperson_spec.postition = [0.0, 0.6, 0.0] depth_camera_1stperson_spec.orientation = [0.0, 0.0, 0.0] depth_camera_1stperson_spec.sensor_subtype = habitat_sim.SensorSubType.PINHOLE sensor_specs.append(depth_camera_1stperson_spec) rgba_camera_3rdperson_spec = habitat_sim.CameraSensorSpec() rgba_camera_3rdperson_spec.uuid = "rgba_camera_3rdperson" rgba_camera_3rdperson_spec.sensor_type = habitat_sim.SensorType.COLOR rgba_camera_3rdperson_spec.resolution = camera_resolution rgba_camera_3rdperson_spec.postition = [0.0, 1.0, 0.3] rgba_camera_3rdperson_spec.orientation = [-45, 0.0, 0.0] rgba_camera_3rdperson_spec.sensor_subtype = habitat_sim.SensorSubType.PINHOLE sensor_specs.append(rgba_camera_3rdperson_spec) # agent configuration agent_cfg = habitat_sim.agent.AgentConfiguration() agent_cfg.sensor_specifications = sensor_specs return habitat_sim.Configuration(backend_cfg, [agent_cfg])
def make_configuration(): # simulator configuration backend_cfg = habitat_sim.SimulatorConfiguration() backend_cfg.scene.id = "data/scene_datasets/habitat-test-scenes/apartment_1.glb" backend_cfg.enable_physics = True # sensor configurations # Note: all sensors must have the same resolution # setup 2 rgb sensors for 1st and 3rd person views camera_resolution = [540, 720] sensors = { "rgba_camera_1stperson": { "sensor_type": habitat_sim.SensorType.COLOR, "resolution": camera_resolution, "position": [0.0, 0.6, 0.0], "orientation": [0.0, 0.0, 0.0], }, "depth_camera_1stperson": { "sensor_type": habitat_sim.SensorType.DEPTH, "resolution": camera_resolution, "position": [0.0, 0.6, 0.0], "orientation": [0.0, 0.0, 0.0], }, "rgba_camera_3rdperson": { "sensor_type": habitat_sim.SensorType.COLOR, "resolution": camera_resolution, "position": [0.0, 1.0, 0.3], "orientation": [-45, 0.0, 0.0], }, } sensor_specs = [] for sensor_uuid, sensor_params in sensors.items(): sensor_spec = habitat_sim.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.orientation = sensor_params["orientation"] sensor_specs.append(sensor_spec) # agent configuration agent_cfg = habitat_sim.agent.AgentConfiguration() agent_cfg.sensor_specifications = sensor_specs return habitat_sim.Configuration(backend_cfg, [agent_cfg])
def make_configuration(): # simulator configuration backend_cfg = habitat_sim.SimulatorConfiguration() backend_cfg.scene_id = os.path.join( data_path, "scene_datasets/habitat-test-scenes/apartment_1.glb") assert os.path.exists(backend_cfg.scene_id) backend_cfg.enable_physics = True # Enable gfx replay save. See also our call to sim.gfx_replay_manager.save_keyframe() # below. backend_cfg.enable_gfx_replay_save = True sensor_cfg = habitat_sim.SensorSpec() sensor_cfg.resolution = [544, 720] agent_cfg = habitat_sim.agent.AgentConfiguration() agent_cfg.sensor_specifications = [sensor_cfg] return habitat_sim.Configuration(backend_cfg, [agent_cfg])
def make_simple_cfg(settings): # simulator backend sim_cfg = habitat_sim.SimulatorConfiguration() sim_cfg.scene.id = settings["scene"] # agent agent_cfg = habitat_sim.agent.AgentConfiguration() # In the 1st example, we attach only one sensor, # a RGB visual sensor, to the agent rgb_sensor_spec = habitat_sim.SensorSpec() rgb_sensor_spec.uuid = "color_sensor" rgb_sensor_spec.sensor_type = habitat_sim.SensorType.COLOR rgb_sensor_spec.resolution = [settings["height"], settings["width"]] rgb_sensor_spec.position = [0.0, settings["sensor_height"], 0.0] agent_cfg.sensor_specifications = [rgb_sensor_spec] return habitat_sim.Configuration(sim_cfg, [agent_cfg])
def test_no_navmesh_smoke(): sim_cfg = habitat_sim.SimulatorConfiguration() agent_config = habitat_sim.AgentConfiguration() # No sensors as we are only testing to see if things work # with no navmesh and the navmesh isn't used for any exisitng sensors agent_config.sensor_specifications = [] sim_cfg.scene_id = "data/test_assets/scenes/stage_floor1.glb" with habitat_sim.Simulator( habitat_sim.Configuration(sim_cfg, [agent_config]) ) as sim: sim.initialize_agent(0) random.seed(0) for _ in range(50): obs = sim.step(random.choice(list(agent_config.action_space.keys()))) # Can't collide with no navmesh assert not obs["collided"]
def make_configuration(): # simulator configuration backend_cfg = habitat_sim.SimulatorConfiguration() backend_cfg.scene_id = "NONE" backend_cfg.enable_physics = True # sensor configurations sensor_specs = [] sensor_spec = habitat_sim.SensorSpec() sensor_spec.uuid = "rgba_camera_1stperson" sensor_spec.sensor_type = habitat_sim.SensorType.COLOR sensor_spec.resolution = [544, 720] sensor_specs.append(sensor_spec) # agent configuration agent_cfg = habitat_sim.agent.AgentConfiguration() agent_cfg.sensor_specifications = sensor_specs return habitat_sim.Configuration(backend_cfg, [agent_cfg])
def test_no_navmesh_smoke(sim): sim_cfg = habitat_sim.SimulatorConfiguration() agent_config = habitat_sim.AgentConfiguration() # No sensors as we are only testing to see if things work # with no navmesh and the navmesh isn't used for any exisitng sensors agent_config.sensor_specifications = [] sim_cfg.scene.id = "data/scene_datasets/habitat-test-scenes/van-gogh-room.glb" # Make it try to load a navmesh that doesn't exists sim_cfg.scene.filepaths["navmesh"] = "/tmp/dne.navmesh" sim.reconfigure(habitat_sim.Configuration(sim_cfg, [agent_config])) sim.initialize_agent(0) random.seed(0) for _ in range(50): obs = sim.step(random.choice(list(agent_config.action_space.keys()))) # Can't collide with no navmesh assert not obs["collided"]