Skip to content

Commit

Permalink
Add missing typing information to articulated agent manager. (faceboo…
Browse files Browse the repository at this point in the history
  • Loading branch information
0mdc authored and dannymcy committed Jun 26, 2024
1 parent 4804fc6 commit d41ddcb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions habitat-lab/habitat/tasks/rearrange/articulated_agent_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# LICENSE file in the root directory of this source tree.

from dataclasses import dataclass
from typing import TYPE_CHECKING, Iterator, List, Optional
from typing import TYPE_CHECKING, Any, Dict, Iterator, List, Optional

import magnum as mn
import numpy as np
Expand Down Expand Up @@ -33,6 +33,8 @@
if TYPE_CHECKING:
from omegaconf import DictConfig

from habitat_sim.simulator import Simulator


@dataclass
class ArticulatedAgentData:
Expand Down Expand Up @@ -67,11 +69,11 @@ class ArticulatedAgentManager:
Handles creating, updating and managing all agent instances.
"""

def __init__(self, cfg, sim):
def __init__(self, cfg: "DictConfig", sim: "Simulator"):
self._sim = sim
self._all_agent_data = []
self._all_agent_data: List[ArticulatedAgentData] = []
self._is_pb_installed = is_pb_installed()
self.agent_names = cfg.agents
self.agent_names: Dict[str, Any] = cfg.agents

for agent_name in cfg.agents_order:
agent_cfg = cfg.agents[agent_name]
Expand All @@ -80,10 +82,10 @@ def __init__(self, cfg, sim):
agent = agent_cls(agent_cfg, sim)
grasp_managers = []
for grasp_manager_id in range(agent_cfg.grasp_managers):
graps_mgr = RearrangeGraspManager(
grasp_mgr = RearrangeGraspManager(
sim, cfg, agent, grasp_manager_id
)
grasp_managers.append(graps_mgr)
grasp_managers.append(grasp_mgr)

if len(cfg.agents) > 1:
# Prefix sensors if there is more than 1 agent in the scene.
Expand Down Expand Up @@ -170,7 +172,7 @@ def post_obj_load_reconfigure(self):
)
agent_data.articulated_agent.reset()

# consume a fixed position from SIMUALTOR.agent_0 if configured
# Consume a fixed position from SIMULATOR.agent_0 if configured
if agent_data.cfg.is_set_start_state:
agent_data.articulated_agent.base_pos = mn.Vector3(
agent_data.cfg.start_position
Expand All @@ -180,14 +182,14 @@ def post_obj_load_reconfigure(self):
mn.Vector3(agent_rot[:3]), agent_rot[3]
)

def __getitem__(self, key: int):
def __getitem__(self, key: int) -> ArticulatedAgentData:
"""
Fetches the agent data at the agent index.
"""

return self._all_agent_data[key]

def __len__(self):
def __len__(self) -> int:
"""
The number of agents.
"""
Expand Down
2 changes: 1 addition & 1 deletion habitat-lab/habitat/tasks/rearrange/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def batch_transform_point(
p = None


def is_pb_installed():
def is_pb_installed() -> bool:
return p is not None


Expand Down

0 comments on commit d41ddcb

Please sign in to comment.