def make_cfg(settings):
    sim_cfg = hsim.SimulatorConfiguration()
    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"]
            if not settings["silent"]:
                print("==== Initialized Sensor Spec: =====")
                print("Sensor uuid: ", sensor_spec.uuid)
                print("Sensor type: ", sensor_spec.sensor_type)
                print("Sensor position: ", sensor_spec.position)
                print("===================================")

            sensor_specs.append(sensor_spec)

    # create agent specifications
    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=10.0)),
        "turn_right":
        habitat_sim.agent.ActionSpec(
            "turn_right", habitat_sim.agent.ActuationSpec(amount=10.0)),
    }

    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])
class AgentConfiguration(object):
    height: float = 1.5
    radius: float = 0.1
    mass: float = 32.0
    linear_acceleration: float = 20.0
    angular_acceleration: float = 4 * np.pi
    linear_friction: float = 0.5
    angular_friction: float = 1.0
    coefficient_of_restitution: float = 0.0
    sensor_specifications: List[hsim.SensorSpec] = attr.Factory(
        lambda: [hsim.SensorSpec()])
    action_space: Dict[Any, ActionSpec] = attr.Factory(_default_action_space)
    body_type: str = "cylinder"
def make_cfg(scene):
    default_sim_settings["scene"] = scene
    settings = default_sim_settings
    sim_cfg = hsim.SimulatorConfiguration()
    if "enable_physics" in settings.keys():
        sim_cfg.enable_physics = settings["enable_physics"]
    else:
        sim_cfg.enable_physics = False
    if "physics_config_file" in settings.keys():
        sim_cfg.physics_config_file = settings["physics_config_file"]
    print("sim_cfg.physics_config_file = " + sim_cfg.physics_config_file)
    sim_cfg.gpu_device_id = 1
    #print(settings["scene"])
    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
            if not settings["silent"]:
                print("==== Initialized Sensor Spec: =====")
                print("Sensor uuid: ", sensor_spec.uuid)
                print("Sensor type: ", sensor_spec.sensor_type)
                print("Sensor position: ", sensor_spec.position)
                print("===================================")

            sensor_specs.append(sensor_spec)

    # create agent specifications
    agent_cfg = habitat_sim.agent.AgentConfiguration()
    agent_cfg.sensor_specifications = sensor_specs
    agent_cfg.action_space = {
        "PositiveSurge": habitat_sim.agent.ActionSpec(
            "Surge", MoveSpec(forward_amount=0.1)
        ),
        "NegativeSurge": habitat_sim.ActionSpec(
            "Surge", MoveSpec(forward_amount=-0.1)
        ),
        "PositiveSway": habitat_sim.agent.ActionSpec(
            "Sway", MoveSpec(forward_amount=0.1)
        ),
        "NegativeSway": habitat_sim.ActionSpec(
            "Sway", MoveSpec(forward_amount=-0.1)
        ),
        "PositiveHeave": habitat_sim.agent.ActionSpec(
            "Heave", MoveSpec(forward_amount=0.1)
        ),
        "NegativeHeave": habitat_sim.ActionSpec(
            "Heave", MoveSpec(forward_amount=-0.1)
        ),
        "PositiveRoll": habitat_sim.ActionSpec(
            "Roll", SpinSpec(0.1)
        ),
        "NegativeRoll": habitat_sim.ActionSpec(
            "Roll", SpinSpec(-0.1)
        ),
        "PositivePitch": habitat_sim.ActionSpec(
            "Pitch", SpinSpec(5)
        ),
        "NegativePitch": habitat_sim.ActionSpec(
            "Pitch", SpinSpec(-5)
        ),
        "PositiveYaw": habitat_sim.ActionSpec(
            "Yaw", SpinSpec(5)
        ),
        "NegativeYaw": habitat_sim.ActionSpec(
            "Yaw", SpinSpec(-5)
        )
    }

    # override action space to no-op to test physics
    if sim_cfg.enable_physics:
            agent_cfg.action_space = {
            "move_forward": habitat_sim.agent.ActionSpec(
                "move_forward", habitat_sim.agent.ActuationSpec(amount=0.0)
            )
        }

    return habitat_sim.Configuration(sim_cfg, [agent_cfg])
Exemple #5
0
def make_cfg(settings):
    sim_cfg = hsim.SimulatorConfiguration()
    if "frustum_culling" in settings:
        sim_cfg.frustum_culling = settings["frustum_culling"]
    else:
        sim_cfg.frustum_culling = False
    if "enable_physics" in settings:
        sim_cfg.enable_physics = settings["enable_physics"]
    if "physics_config_file" in settings:
        sim_cfg.physics_config_file = settings["physics_config_file"]
    if not settings["silent"]:
        print("sim_cfg.physics_config_file = " + sim_cfg.physics_config_file)
    if "scene_light_setup" in settings:
        sim_cfg.scene_light_setup = settings["scene_light_setup"]
    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
            if not settings["silent"]:
                print("==== Initialized Sensor Spec: =====")
                print("Sensor uuid: ", sensor_spec.uuid)
                print("Sensor type: ", sensor_spec.sensor_type)
                print("Sensor position: ", sensor_spec.position)
                print("===================================")

            sensor_specs.append(sensor_spec)

    # create agent specifications
    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=10.0)),
        "turn_right":
        habitat_sim.agent.ActionSpec(
            "turn_right", habitat_sim.agent.ActuationSpec(amount=10.0)),
    }

    # override action space to no-op to test physics
    if sim_cfg.enable_physics:
        agent_cfg.action_space = {
            "move_forward":
            habitat_sim.agent.ActionSpec(
                "move_forward", habitat_sim.agent.ActuationSpec(amount=0.0))
        }

    return habitat_sim.Configuration(sim_cfg, [agent_cfg])
Exemple #6
0
    def make_cfg(self, settings, Vx, Vy, Vz, Wx, Wy, Wz):
        sim_cfg = hsim.SimulatorConfiguration()
        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"]
                if not self._sim_settings["silent"]:
                    print("==== Initialized Sensor Spec: =====")
                    print("Sensor uuid: ", sensor_spec.uuid)
                    print("Sensor type: ", sensor_spec.sensor_type)
                    print("Sensor position: ", sensor_spec.position)
                    print("===================================")

                sensor_specs.append(sensor_spec)

        # create agent specifications
        agent_cfg = habitat_sim.agent.AgentConfiguration()
        agent_cfg.sensor_specifications = sensor_specs
        agent_cfg.action_space = {
            "move_right":
            habitat_sim.agent.ActionSpec("moveRight", {"amount": -0.1 * Vx}),
            "move_left":
            habitat_sim.agent.ActionSpec("moveLeft", {"amount": 0}),
            "move_up":
            habitat_sim.agent.ActionSpec("moveUp",
                                         {"amount": -0.09883337089 * Vy}),
            "move_down":
            habitat_sim.agent.ActionSpec("moveDown", {"amount": 0}),
            "move_forward":
            habitat_sim.agent.ActionSpec("moveForward", {"amount": 0}),
            "move_backward":
            habitat_sim.agent.ActionSpec("moveBackward",
                                         {"amount": -0.09 * Vz}),
            "look_left":
            habitat_sim.agent.ActionSpec("lookLeft", {"amount": 1 * Wy}),
            "look_right":
            habitat_sim.agent.ActionSpec("lookRight", {"amount": 0}),
            "look_up":
            habitat_sim.agent.ActionSpec("lookUp", {"amount": -1 * Wx}),
            "look_down":
            habitat_sim.agent.ActionSpec("lookDown", {"amount": 0}),
            "look_anti":
            habitat_sim.agent.ActionSpec("lookAnti", {"amount": 1 * Wz}),
            "look_clock":
            habitat_sim.agent.ActionSpec("lookClock", {"amount": 0}),
        }
        return habitat_sim.Configuration(sim_cfg, [agent_cfg])
Exemple #7
0
def make_cfg(SIM):
    sim_cfg = hsim.SimulatorConfiguration()

    if SIM.SCENE_ID == "none":
        SIM.SCENE_ID = "data/scene_datasets/habitat-test-scenes/skokloster-castle.glb"
    sim_cfg.scene.id = SIM.SCENE_ID

    sim_cfg.enable_physics = SIM.PHYSICS
    if SIM.PHYSICS:
        sim_cfg.physics_config_file = SIM.PHYSICS_CONFIG_FILE
    # sim_cfg.gpu_device_id = 0
    # sim_cfg.scene.id = settings["scene"]

    # define default sensor parameters (see src/esp/Sensor/Sensor.h)
    sensors = dict()
    for i in range(len(SIM.AGENT.SENSORS.NAMES)):
        sensors[SIM.AGENT.SENSORS.NAMES[i]] = {
            "sensor_type":
            getattr(hsim.SensorType, SIM.AGENT.SENSORS.TYPES[i]),
            "resolution": [
                SIM.AGENT.SENSORS.RESOLUTIONS[i][0],
                SIM.AGENT.SENSORS.RESOLUTIONS[i][1],
            ],
            "position": [
                SIM.AGENT.SENSORS.POSES[i][0],
                SIM.AGENT.SENSORS.POSES[i][1],
                SIM.AGENT.SENSORS.POSES[i][2],
            ],
            "orientation": [
                SIM.AGENT.SENSORS.POSES[i][3],
                SIM.AGENT.SENSORS.POSES[i][4],
                SIM.AGENT.SENSORS.POSES[i][5],
            ],
        }

    # create sensor specifications
    sensor_specs = []
    for sensor_uuid, sensor_params in sensors.items():
        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  # Todo: Move this to config

        print("==== Initialized Sensor Spec: =====")
        print("Sensor uuid: ", sensor_spec.uuid)
        print("Sensor type: ", sensor_spec.sensor_type)
        print("Sensor position: ", sensor_spec.position)
        print("===================================")

        sensor_specs.append(sensor_spec)

    # create agent specifications
    # TODO: Accomodate more agents
    agent_cfg = habitat_sim.agent.AgentConfiguration()
    agent_cfg.sensor_specifications = sensor_specs
    # TODO: Move agent actions to config
    agent_cfg.action_space = {
        "move_forward":
        habitat_sim.agent.ActionSpec(
            "move_forward", habitat_sim.agent.ActuationSpec(amount=1.0)),
        "turn_left":
        habitat_sim.agent.ActionSpec(
            "turn_left", habitat_sim.agent.ActuationSpec(amount=10.0)),
        "turn_right":
        habitat_sim.agent.ActionSpec(
            "turn_right", habitat_sim.agent.ActuationSpec(amount=10.0)),
    }
    sim_cfg.default_agent_id = SIM.DEFAULT_AGENT_ID
    # # override action space to no-op to test physics
    # if sim_cfg.enable_physics:
    #     agent_cfg.action_space = {
    #         "move_forward": habitat_sim.agent.ActionSpec(
    #             "move_forward", habitat_sim.agent.ActuationSpec(amount=0.0)
    #         )
    #     }

    return habitat_sim.Configuration(sim_cfg, [agent_cfg])