From 2e123320f66d485c99b5745e0ee2547671f227e5 Mon Sep 17 00:00:00 2001 From: Abhishek Kadian <abhishekkadiyan@gmail.com> Date: Thu, 19 Sep 2019 15:08:47 -0700 Subject: [PATCH] Simple NavigationEnv --- habitat/config/default.py | 1 + navigation.py | 57 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 navigation.py diff --git a/habitat/config/default.py b/habitat/config/default.py index 4352f26b1..2150f23ac 100644 --- a/habitat/config/default.py +++ b/habitat/config/default.py @@ -170,6 +170,7 @@ _C.PYROBOT.ROBOTS = ["locobot"] # types of robots supported _C.PYROBOT.ROBOT = "locobot" _C.PYROBOT.SENSORS = ["RGB_SENSOR", "DEPTH_SENSOR"] _C.PYROBOT.BASE_CONTROLLER = "proportional" +_C.PYROBOT.BASE_PLANNER = "none" # ----------------------------------------------------------------------------- # SENSORS # ----------------------------------------------------------------------------- diff --git a/navigation.py b/navigation.py new file mode 100644 index 000000000..aba2f5ddf --- /dev/null +++ b/navigation.py @@ -0,0 +1,57 @@ +import numpy as np + +import habitat +from habitat.sims import make_sim + + +class NavEnv: + def __init__(self, forward_step, angle_step, base_controller): + config = habitat.get_config() + + config.defrost() + config.PYROBOT.BASE_CONTROLLER = base_controller + config.freeze() + + self._reality = make_sim(id_sim="PyRobot-v0", config=config.PYROBOT) + + self._angle = (angle_step / 180) * np.pi + + self._actions = { + "forward": [forward_step, 0, 0], + "left": [0, 0, self._angle], + "right": [0, 0, -self._angle], + "stop": [0, 0, 0], + } + + def reset(self): + return self._reality.reset() + + @property + def reality(self): + return self._reality + + def step(self, action): + if action not in self._actions: + raise ValueError("Invalid action type {}".format(action)) + if action == "stop": + raise NotImplementedError("stop action not implemented") + + observations = self._reality.step( + "go_to_relative", + { + "xyt_position": self._actions[action], + "use_map": False, + "close_loop": True, + "smooth": False + } + ) + + return observations + + +def main(): + env = NavEnv() + + +if __name__ == "__main__": + main() -- GitLab