diff --git a/habitat/config/default.py b/habitat/config/default.py index 3a165ceca2487976daa5b72e16c6bf6b0d6482aa..18020b970babaf49e050333ff2c2ffa9b348eb73 100644 --- a/habitat/config/default.py +++ b/habitat/config/default.py @@ -37,6 +37,12 @@ _C.TASK.POINTGOAL_SENSOR = CN() _C.TASK.POINTGOAL_SENSOR.TYPE = "PointGoalSensor" _C.TASK.POINTGOAL_SENSOR.GOAL_FORMAT = "POLAR" # ----------------------------------------------------------------------------- +# # STATIC POINTGOAL SENSOR +# ----------------------------------------------------------------------------- +_C.TASK.STATIC_POINTGOAL_SENSOR = CN() +_C.TASK.STATIC_POINTGOAL_SENSOR.TYPE = "StaticPointGoalSensor" +_C.TASK.STATIC_POINTGOAL_SENSOR.GOAL_FORMAT = "CARTESIAN" +# ----------------------------------------------------------------------------- # # HEADING SENSOR # ----------------------------------------------------------------------------- _C.TASK.HEADING_SENSOR = CN() diff --git a/habitat/tasks/nav/nav_task.py b/habitat/tasks/nav/nav_task.py index d6c8382cb29ec12540a28c2d6a03c59ecac8ddca..4f5d8f823aeb166ad9ad7d1ef6a38d4c7fa0cd26 100644 --- a/habitat/tasks/nav/nav_task.py +++ b/habitat/tasks/nav/nav_task.py @@ -233,7 +233,7 @@ class StaticPointGoalSensor(habitat.Sensor): return "static_pointgoal" def _get_sensor_type(self, *args: Any, **kwargs: Any): - return SensorTypes.STATIC_GOAL_VECTOR + return SensorTypes.PATH def _get_observation_space(self, *args: Any, **kwargs: Any): if self._goal_format == "CARTESIAN": diff --git a/test/test_sensors.py b/test/test_sensors.py index 3dc5e5afb47e1e0d615e800bf52ab70fe6e0cea6..a24c978e5eeff3778bff9a780f8c44e3e883dcbf 100644 --- a/test/test_sensors.py +++ b/test/test_sensors.py @@ -14,10 +14,13 @@ from habitat.config.default import get_config from habitat.tasks.nav.nav_task import ( NavigationEpisode, COLLISION_PROXIMITY_TOLERANCE, + NavigationGoal, ) from habitat.sims.habitat_simulator import SimulatorActions -CFG_TEST = "configs/test/habitat_all_sensors_test.yaml" +NON_STOP_ACTIONS = [ + v for v in range(len(SimulatorActions)) if v != SimulatorActions.STOP.value +] def _random_episode(env, config): @@ -41,10 +44,9 @@ def _random_episode(env, config): def test_heading_sensor(): - config = get_config(CFG_TEST) + config = get_config() if not os.path.exists(config.SIMULATOR.SCENE): pytest.skip("Please download Habitat test data to data folder.") - config = get_config() config.defrost() config.TASK.SENSORS = ["HEADING_SENSOR"] config.freeze() @@ -79,10 +81,9 @@ def test_heading_sensor(): def test_tactile(): - config = get_config(CFG_TEST) + config = get_config() if not os.path.exists(config.SIMULATOR.SCENE): pytest.skip("Please download Habitat test data to data folder.") - config = get_config() config.defrost() config.TASK.SENSORS = ["PROXIMITY_SENSOR"] config.TASK.MEASUREMENTS = ["COLLISIONS"] @@ -111,10 +112,9 @@ def test_tactile(): def test_collisions(): - config = get_config(CFG_TEST) + config = get_config() if not os.path.exists(config.SIMULATOR.SCENE): pytest.skip("Please download Habitat test data to data folder.") - config = get_config() config.defrost() config.TASK.MEASUREMENTS = ["COLLISIONS"] config.freeze() @@ -156,3 +156,41 @@ def test_collisions(): prev_collisions = collisions env.close() + + +def test_static_pointgoal_sensor(): + config = get_config() + if not os.path.exists(config.SIMULATOR.SCENE): + pytest.skip("Please download Habitat test data to data folder.") + config.defrost() + config.TASK.SENSORS = ["STATIC_POINTGOAL_SENSOR"] + config.freeze() + env = habitat.Env(config=config, dataset=None) + + # start position is checked for validity for the specific test scene + valid_start_position = [-1.3731, 0.08431, 8.60692] + expected_static_pointgoal = [0.1, 0.2, 0.3] + goal_position = np.add(valid_start_position, expected_static_pointgoal) + + # starting quaternion is rotated 180 degree along z-axis, which + # corresponds to simulator using z-negative as forward action + start_rotation = [0, 0, 0, 1] + + env.episodes = [ + NavigationEpisode( + episode_id="0", + scene_id=config.SIMULATOR.SCENE, + start_position=valid_start_position, + start_rotation=start_rotation, + goals=[NavigationGoal(goal_position)], + ) + ] + + obs = env.reset() + for _ in range(5): + env.step(np.random.choice(NON_STOP_ACTIONS)) + static_pointgoal = obs["static_pointgoal"] + + # check to see if taking non-stop actions will affect static point_goal + assert np.allclose(static_pointgoal, expected_static_pointgoal) + env.close()