diff --git a/habitat/sims/pyrobot/__init__.py b/habitat/sims/pyrobot/__init__.py index 91bfd32df7548b22c7dc8f02d07e0d16c4c84515..0ee95858f9a1534d1bfaa0de95636d4fd5865e0a 100644 --- a/habitat/sims/pyrobot/__init__.py +++ b/habitat/sims/pyrobot/__init__.py @@ -1,2 +1,2 @@ # TODO(akadian): come up with better module structure -from habitat.sims.pyrobot.pyrobot import PyRobot \ No newline at end of file +from habitat.sims.pyrobot.pyrobot import PyRobot diff --git a/habitat/sims/pyrobot/pyrobot.py b/habitat/sims/pyrobot/pyrobot.py index ca1d480589b766b48db78af08974032578ef2c01..a4b2389a7add7a6d756fd760ff8fe0cdf2a5a5d6 100644 --- a/habitat/sims/pyrobot/pyrobot.py +++ b/habitat/sims/pyrobot/pyrobot.py @@ -20,7 +20,8 @@ import numpy as np # TODO(akadian): remove the below pyrobot hack import sys -ros_path = '/opt/ros/kinetic/lib/python2.7/dist-packages' + +ros_path = "/opt/ros/kinetic/lib/python2.7/dist-packages" if ros_path in sys.path: sys.path.remove(ros_path) import cv2 @@ -41,12 +42,20 @@ class PyRobotRGBSensor(RGBSensor): ) def get_observation(self, robot_obs): - obs = robot_obs.get(self.uuid, None) + obs = robot_obs.get(self.uuid, None) - assert obs is not None, "Invalid observation for {} sensor".format(self.uuid) + assert obs is not None, "Invalid observation for {} sensor".format( + self.uuid + ) if obs.shape != self.observation_space.shape: - obs = cv2.resize(obs, (self.observation_space.shape[1], self.observation_space.shape[0])) + obs = cv2.resize( + obs, + ( + self.observation_space.shape[1], + self.observation_space.shape[0], + ), + ) return obs @@ -74,10 +83,18 @@ class PyRobotDepthSensor(DepthSensor): def get_observation(self, robot_obs): obs = robot_obs.get(self.uuid, None) - assert obs is not None, "Invalid observation for {} sensor".format(self.uuid) + assert obs is not None, "Invalid observation for {} sensor".format( + self.uuid + ) if obs.shape != self.observation_space.shape: - obs = cv2.resize(obs, (self.observation_space.shape[1], self.observation_space.shape[0])) + obs = cv2.resize( + obs, + ( + self.observation_space.shape[1], + self.observation_space.shape[0], + ), + ) obs = np.clip(obs, self.config.MIN_DEPTH, self.config.MAX_DEPTH) if self.config.NORMALIZE_DEPTH: @@ -93,11 +110,11 @@ class PyRobotDepthSensor(DepthSensor): class PyRobot(Simulator): def __init__(self, config: Config) -> None: self._config = config - + robot_sensors = [] for sensor_name in self._config.SENSORS: sensor_cfg = getattr(self._config, sensor_name) - sensor_type = registry.get_sensor(sensor_cfg.TYPE) + sensor_type = registry.get_sensor(sensor_cfg.TYPE) assert sensor_type is not None, "invalid sensor type {}".format( sensor_cfg.TYPE @@ -105,17 +122,16 @@ class PyRobot(Simulator): robot_sensors.append(sensor_type(sensor_cfg)) self._sensor_suite = SensorSuite(robot_sensors) - config_pyrobot = { - "base_controller": self._config.BASE_CONTROLLER - } + config_pyrobot = {"base_controller": self._config.BASE_CONTROLLER} - assert self._config.ROBOT in self._config.ROBOTS, "Invalid robot type {}".format(self._config.ROBOT) - self._robot_config = getattr( - self._config, - self._config.ROBOT.upper() - ) + assert ( + self._config.ROBOT in self._config.ROBOTS + ), "Invalid robot type {}".format(self._config.ROBOT) + self._robot_config = getattr(self._config, self._config.ROBOT.upper()) - self._robot = pyrobot.Robot(self._config.ROBOT, base_config=config_pyrobot) + self._robot = pyrobot.Robot( + self._config.ROBOT, base_config=config_pyrobot + ) def _degree_to_radian(self, degrees): return (degrees / 180) * np.pi diff --git a/habitat/tasks/nav/nav_task.py b/habitat/tasks/nav/nav_task.py index 0c67b8c7a15e4fa99f34d74206ef09a8c7ee3de2..f0bce6488f29e1c3c37b63a1b2962dbe9e58a736 100644 --- a/habitat/tasks/nav/nav_task.py +++ b/habitat/tasks/nav/nav_task.py @@ -7,9 +7,11 @@ from typing import Any, List, Optional, Type import attr + # TODO(akadian): remove the below pyrobot hack import sys -ros_path = '/opt/ros/kinetic/lib/python2.7/dist-packages' + +ros_path = "/opt/ros/kinetic/lib/python2.7/dist-packages" if ros_path in sys.path: sys.path.remove(ros_path) import cv2 diff --git a/habitat/utils/visualizations/maps.py b/habitat/utils/visualizations/maps.py index a46f4e695698827f71a0e200cad2dbab8e386acc..fc87e26ecbeee43a308138d41f6aa076f11d61db 100644 --- a/habitat/utils/visualizations/maps.py +++ b/habitat/utils/visualizations/maps.py @@ -9,7 +9,8 @@ from typing import List, Optional, Tuple # TODO(akadian): remove the below pyrobot hack import sys -ros_path = '/opt/ros/kinetic/lib/python2.7/dist-packages' + +ros_path = "/opt/ros/kinetic/lib/python2.7/dist-packages" if ros_path in sys.path: sys.path.remove(ros_path) import cv2 diff --git a/habitat/utils/visualizations/utils.py b/habitat/utils/visualizations/utils.py index 687558a1f0584bc35f10e2e04bef3052b8fcaf82..d42491dea8ded1f383fe2ea5b77d40ba52099f76 100644 --- a/habitat/utils/visualizations/utils.py +++ b/habitat/utils/visualizations/utils.py @@ -9,7 +9,8 @@ from typing import Dict, List, Optional, Tuple # TODO(akadian): remove the below pyrobot hack import sys -ros_path = '/opt/ros/kinetic/lib/python2.7/dist-packages' + +ros_path = "/opt/ros/kinetic/lib/python2.7/dist-packages" if ros_path in sys.path: sys.path.remove(ros_path) import cv2