Skip to content

Commit 952a28a

Browse files
aclegg3joannetruong
authored andcommitted
rearrange_sim no navmesh caching (#2088)
* clean up and rename the _load_navmesh function now that we have changed the behavior to recompute every time
1 parent 9d207ae commit 952a28a

File tree

1 file changed

+21
-31
lines changed

1 file changed

+21
-31
lines changed

habitat-lab/habitat/tasks/rearrange/rearrange_sim.py

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
# This source code is licensed under the MIT license found in the
55
# LICENSE file in the root directory of this source tree.
66

7-
import os
8-
import os.path as osp
97
import time
108
from collections import defaultdict
119
from typing import (
@@ -373,7 +371,7 @@ def reconfigure(self, config: "DictConfig", ep_info: RearrangeEpisode):
373371
}
374372

375373
if new_scene:
376-
self._load_navmesh(ep_info)
374+
self._recompute_navmesh()
377375

378376
# Get the starting positions of the target objects.
379377
scene_pos = self.get_scene_pos()
@@ -476,37 +474,29 @@ def _setup_targets(self, ep_info: RearrangeEpisode):
476474
)
477475

478476
@add_perf_timing_func()
479-
def _load_navmesh(self, ep_info: RearrangeEpisode):
480-
scene_name = ep_info.scene_id.split("/")[-1].split(".")[0]
481-
base_dir = osp.join(*ep_info.scene_id.split("/")[:2])
477+
def _recompute_navmesh(self) -> None:
478+
"""
479+
Recompute the navmesh including STATIC objects and using agent parameters.
480+
"""
482481

483-
navmesh_path = osp.join(base_dir, "navmeshes", scene_name + ".navmesh")
482+
navmesh_settings = NavMeshSettings()
483+
navmesh_settings.set_defaults()
484484

485-
if osp.exists(navmesh_path):
486-
self.pathfinder.load_nav_mesh(navmesh_path)
487-
logger.info(f"Loaded navmesh from {navmesh_path}")
485+
agent_config = None
486+
if hasattr(self.habitat_config.agents, "agent_0"):
487+
agent_config = self.habitat_config.agents.agent_0
488+
elif hasattr(self.habitat_config.agents, "main_agent"):
489+
agent_config = self.habitat_config.agents.main_agent
488490
else:
489-
logger.warning(
490-
f"Requested navmesh to load from {navmesh_path} does not exist. Recomputing from configured values and caching."
491-
)
492-
navmesh_settings = NavMeshSettings()
493-
navmesh_settings.set_defaults()
494-
495-
agent_config = None
496-
if hasattr(self.habitat_config.agents, "agent_0"):
497-
agent_config = self.habitat_config.agents.agent_0
498-
elif hasattr(self.habitat_config.agents, "main_agent"):
499-
agent_config = self.habitat_config.agents.main_agent
500-
else:
501-
raise ValueError("Cannot find agent parameters.")
502-
navmesh_settings.agent_radius = agent_config.radius
503-
navmesh_settings.agent_height = agent_config.height
504-
navmesh_settings.agent_max_climb = agent_config.max_climb
505-
navmesh_settings.agent_max_slope = agent_config.max_slope
506-
navmesh_settings.include_static_objects = True
507-
self.recompute_navmesh(self.pathfinder, navmesh_settings)
508-
os.makedirs(osp.dirname(navmesh_path), exist_ok=True)
509-
self.pathfinder.save_nav_mesh(navmesh_path)
491+
raise ValueError("Cannot find agent parameters.")
492+
navmesh_settings.agent_radius = agent_config.radius
493+
navmesh_settings.agent_height = agent_config.height
494+
navmesh_settings.agent_max_climb = agent_config.max_climb
495+
navmesh_settings.agent_max_slope = agent_config.max_slope
496+
navmesh_settings.include_static_objects = True
497+
498+
# recompute the navmesh
499+
self.recompute_navmesh(self.pathfinder, navmesh_settings)
510500

511501
# NOTE: allowing indoor islands only
512502
self._largest_indoor_island_idx = get_largest_island_index(

0 commit comments

Comments
 (0)