Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing typing hints to articulated agent manager. #1977

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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