diff --git a/vlfm/mapping/obstacle_map.py b/vlfm/mapping/obstacle_map.py index 29840b2..c840347 100644 --- a/vlfm/mapping/obstacle_map.py +++ b/vlfm/mapping/obstacle_map.py @@ -1,8 +1,9 @@ # Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved. +from typing import Any, Union + import cv2 import numpy as np -from typing import Union, Any from frontier_exploration.frontier_detection import detect_frontier_waypoints from frontier_exploration.utils.fog_of_war import reveal_fog_of_war diff --git a/vlfm/mapping/traj_visualizer.py b/vlfm/mapping/traj_visualizer.py index 11a4a14..661c0cb 100644 --- a/vlfm/mapping/traj_visualizer.py +++ b/vlfm/mapping/traj_visualizer.py @@ -36,7 +36,9 @@ def draw_trajectory( img = self._draw_agent(img, camera_positions[-1], camera_yaw) return img - def _draw_path(self, img: np.ndarray, camera_positions: Union[np.ndarray, List[np.ndarray]]) -> np.ndarray: + def _draw_path( + self, img: np.ndarray, camera_positions: Union[np.ndarray, List[np.ndarray]] + ) -> np.ndarray: """Draws the path on the image and returns it""" if len(camera_positions) < 2: return img diff --git a/vlfm/policy/reality_policies.py b/vlfm/policy/reality_policies.py index c863fd5..6711dff 100644 --- a/vlfm/policy/reality_policies.py +++ b/vlfm/policy/reality_policies.py @@ -1,7 +1,7 @@ # Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved. from dataclasses import dataclass -from typing import Any, Dict, List, Tuple, Union, Optional +from typing import Any, Dict, List, Tuple, Union import numpy as np import torch diff --git a/vlfm/policy/utils/non_habitat_policy/resnet.py b/vlfm/policy/utils/non_habitat_policy/resnet.py index 73e03be..e1a18c2 100755 --- a/vlfm/policy/utils/non_habitat_policy/resnet.py +++ b/vlfm/policy/utils/non_habitat_policy/resnet.py @@ -6,7 +6,7 @@ # https://github.com/facebookresearch/habitat-lab/blob/main/habitat-baselines/habitat_baselines/rl/ddppo/policy/resnet.py # This is a filtered down version that only support ResNet-18 -from typing import List, Optional, Type, cast +from typing import List, Optional, Type from torch import Tensor from torch import nn as nn diff --git a/vlfm/policy/utils/non_habitat_policy/rnn_state_encoder.py b/vlfm/policy/utils/non_habitat_policy/rnn_state_encoder.py index 7fa7469..66e121f 100755 --- a/vlfm/policy/utils/non_habitat_policy/rnn_state_encoder.py +++ b/vlfm/policy/utils/non_habitat_policy/rnn_state_encoder.py @@ -6,7 +6,7 @@ # https://github.com/facebookresearch/habitat-lab/blob/main/habitat-baselines/habitat_baselines/rl/models/rnn_state_encoder.py # This is a filtered down version that only supports LSTM -from typing import Dict, Optional, Tuple, Any +from typing import Any, Dict, Optional, Tuple import torch import torch.nn as nn @@ -20,6 +20,7 @@ class RNNStateEncoder(nn.Module): is that it takes an addition masks input that resets the hidden state between two adjacent timesteps to handle episodes ending in the middle of a rollout. """ + def __init__( self, input_size: int, @@ -131,16 +132,16 @@ def __init__( ): super().__init__(input_size, hidden_size, num_layers) - # Note: Type handling mypy errors in pytorch libraries prevent + # Note: Type handling mypy errors in pytorch libraries prevent # directly setting hidden_states type def pack_hidden( - self, hidden_states: Any # type is Tuple[torch.Tensor, torch.Tensor] + self, hidden_states: Any # type is Tuple[torch.Tensor, torch.Tensor] ) -> torch.Tensor: return torch.cat(hidden_states, 0) def unpack_hidden( self, hidden_states: torch.Tensor - ) -> Any: # type is Tuple[torch.Tensor, torch.Tensor] + ) -> Any: # type is Tuple[torch.Tensor, torch.Tensor] lstm_states = torch.chunk(hidden_states.contiguous(), 2, 0) return (lstm_states[0], lstm_states[1]) diff --git a/vlfm/reality/pointnav_env.py b/vlfm/reality/pointnav_env.py index 7d1bc45..ee5dfbf 100644 --- a/vlfm/reality/pointnav_env.py +++ b/vlfm/reality/pointnav_env.py @@ -106,9 +106,7 @@ def _compute_velocities(self, action: Dict[str, Any]) -> Tuple[float, float]: lin_vel = lin_dist / self._time_step return ang_vel, lin_vel - def _compute_displacements( - self, action: Dict[str, Any] - ) -> Tuple[float, float]: + def _compute_displacements(self, action: Dict[str, Any]) -> Tuple[float, float]: displacements = [] for action_key, max_dist in ( ("angular", self._max_ang_dist), diff --git a/vlfm/utils/geometry_utils.py b/vlfm/utils/geometry_utils.py index e600d2b..9a66882 100644 --- a/vlfm/utils/geometry_utils.py +++ b/vlfm/utils/geometry_utils.py @@ -1,7 +1,7 @@ # Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved. import math -from typing import Tuple, Union +from typing import Tuple import numpy as np