habitat.datasets.rearrange.navmesh_utils module

Classes

class SimpleVelocityControlEnv
A simple environment to control the velocity of the robot.

Functions

def compute_turn(target: numpy.ndarray, turn_speed: float, robot_forward: numpy.ndarray) -> typing.List[float]
Computes the constant speed angular velocity about the Y axis to turn the 2D robot_forward vector toward the provided 2D target direction in global coordinates.
def get_largest_island_index(pathfinder: habitat_sim._ext.habitat_sim_bindings.PathFinder, sim: habitat_sim.simulator.Simulator, allow_outdoor: bool = True) -> int
Get the index of the largest NavMesh island. Optionally exclude outdoor islands.
def is_accessible(sim: habitat_sim.simulator.Simulator, point: _magnum.Vector3, height: float, nav_to_min_distance: float, nav_island: int = -1, target_object_ids: typing.Optional[typing.List[int]] = None) -> bool
def is_collision(pathfinder: habitat_sim._ext.habitat_sim_bindings.PathFinder, trans: _magnum.Matrix4, navmesh_offset: typing.List[typing.Tuple[float, float]], island_idx: int) -> bool
Checks the given transform and navmesh offset points for navigability on the provided navmesh island. Returns True if any point is non-navigable.
def is_outdoor(pathfinder: habitat_sim._ext.habitat_sim_bindings.PathFinder, sim: habitat_sim.simulator.Simulator, island_ix: int, num_samples: int = 100, indoor_ratio_threshold: float = 0.95, min_sample_dist: typing.Optional[float] = None, max_sample_attempts: int = 200) -> bool
Heuristic to check if the specified NavMesh island is outdoor or indoor.
def path_is_navigable_given_robot(sim: habitat_sim.simulator.Simulator, start_pos: _magnum.Vector3, goal_pos: _magnum.Vector3, robot_navmesh_offsets: typing.List[typing.Tuple[float, float]], collision_rate_threshold: float, selected_island: int = -1, angle_threshold: float = 0.05, angular_speed: float = 1.0, distance_threshold: float = 0.25, linear_speed: float = 1.0, dbv: typing.Optional[sims.habitat_simulator.debug_visualizer.DebugVisualizer] = None, render_debug_video: bool = False) -> bool
Compute the ratio of time-steps for which there were collisions detected while the robot navigated from start_pos to goal_pos given the configuration of the sim navmesh.
def record_robot_nav_debug_image(curr_path_points: typing.List[_magnum.Vector3], robot_transformation: _magnum.Matrix4, robot_navmesh_offsets: typing.List[typing.Tuple[float, float]], robot_navmesh_radius: float, in_collision: bool, dbv: sims.habitat_simulator.debug_visualizer.DebugVisualizer, obs_cache: typing.List[typing.Any]) -> None
Render a single frame 3rd person view of the robot embodiment approximation following a path with DebugVizualizer and cache it in obs_cache.
def snap_point_is_occluded(target: _magnum.Vector3, snap_point: _magnum.Vector3, height: float, sim: habitat_sim.simulator.Simulator, granularity: float = 0.2, target_object_ids: typing.Optional[typing.List[int]] = None) -> bool
def unoccluded_navmesh_snap(pos: _magnum.Vector3, height: float, pathfinder: habitat_sim._ext.habitat_sim_bindings.PathFinder, sim: habitat_sim.simulator.Simulator, target_object_ids: typing.Optional[typing.List[int]] = None, island_id: int = -1, search_offset: float = 1.5, test_batch_size: int = 20, max_samples: int = 200, min_sample_dist: float = 0.5) -> typing.Optional[_magnum.Vector3]

Function documentation

def habitat.datasets.rearrange.navmesh_utils.compute_turn(target: numpy.ndarray, turn_speed: float, robot_forward: numpy.ndarray) -> typing.List[float]

Computes the constant speed angular velocity about the Y axis to turn the 2D robot_forward vector toward the provided 2D target direction in global coordinates.

Parameters
target The 2D global target vector in XZ.
turn_speed The desired constant turn speed.
robot_forward The global 2D robot forward vector in XZ.

def habitat.datasets.rearrange.navmesh_utils.get_largest_island_index(pathfinder: habitat_sim._ext.habitat_sim_bindings.PathFinder, sim: habitat_sim.simulator.Simulator, allow_outdoor: bool = True) -> int

Get the index of the largest NavMesh island. Optionally exclude outdoor islands.

NOTE: outdoor heuristic may need to be tuned, but parameters are default here.

If no islands exist satisfying the indoor constraints, then the entire navmesh -1 is returned.

def habitat.datasets.rearrange.navmesh_utils.is_collision(pathfinder: habitat_sim._ext.habitat_sim_bindings.PathFinder, trans: _magnum.Matrix4, navmesh_offset: typing.List[typing.Tuple[float, float]], island_idx: int) -> bool

Checks the given transform and navmesh offset points for navigability on the provided navmesh island. Returns True if any point is non-navigable.

Parameters
pathfinder The PathFinder instance defining the NavMesh.
trans The current agent transformation matrix.
navmesh_offset A list of 2D navmesh offset points to check.
island_idx

def habitat.datasets.rearrange.navmesh_utils.is_outdoor(pathfinder: habitat_sim._ext.habitat_sim_bindings.PathFinder, sim: habitat_sim.simulator.Simulator, island_ix: int, num_samples: int = 100, indoor_ratio_threshold: float = 0.95, min_sample_dist: typing.Optional[float] = None, max_sample_attempts: int = 200) -> bool

Heuristic to check if the specified NavMesh island is outdoor or indoor.

Parameters
pathfinder The NavMesh to check.
sim The Simulator instance.
island_ix The index of the island to check. -1 for all islands.
num_samples The number of samples to take.
indoor_ratio_threshold The percentage of samples classified as indoor necessary to pass the test.
min_sample_dist (optional) The minimum distance between samples. Default is no minimum distance.
max_sample_attempts The maximum number of sample to attempt to satisfy minimum distance.
Assumptions:
  1. The scene must have ceiling collision geometry covering all indoor areas.
  2. Indoor and outdoor spaces are separate navmeshes. Mixed interior/exterior navmeshes may be classified incorrectly and non-deterministically as the heuristic is based on sampling and thresholding.

def habitat.datasets.rearrange.navmesh_utils.path_is_navigable_given_robot(sim: habitat_sim.simulator.Simulator, start_pos: _magnum.Vector3, goal_pos: _magnum.Vector3, robot_navmesh_offsets: typing.List[typing.Tuple[float, float]], collision_rate_threshold: float, selected_island: int = -1, angle_threshold: float = 0.05, angular_speed: float = 1.0, distance_threshold: float = 0.25, linear_speed: float = 1.0, dbv: typing.Optional[sims.habitat_simulator.debug_visualizer.DebugVisualizer] = None, render_debug_video: bool = False) -> bool

Compute the ratio of time-steps for which there were collisions detected while the robot navigated from start_pos to goal_pos given the configuration of the sim navmesh.

Parameters
sim Habitat Simulator instance.
start_pos Initial translation of the robot’s transform. The start of the navigation path.
goal_pos Target translation of the robot’s transform. The end of the navigation path.
robot_navmesh_offsets The list of 2D points XZ in robot local space which will be used represent the robot’s shape. Used to query the navmesh for navigability as a collision heuristic.
collision_rate_threshold The acceptable ratio of colliding to non-colliding steps in the navigation path. Collision is computed with a heuristic, so should be non-zero.
selected_island The navmesh island to which queries should be constrained. -1 denotes the full navmesh.
angle_threshold The error threshold in radians over which the robot should turn before moving straight.
angular_speed The constant angular speed for turning (radians/sec)
distance_threshold The euclidean distance between the robot and the target within which navigation is considered successful and the function returns.
linear_speed The constant linear speed for translation (meters/sec).
dbv An optional DebugVisualizer if rendering and video export are desired.
render_debug_video Whether or not to render and export a visualization of the navigation. If True, requires a DebugVisualizer instance.

def habitat.datasets.rearrange.navmesh_utils.record_robot_nav_debug_image(curr_path_points: typing.List[_magnum.Vector3], robot_transformation: _magnum.Matrix4, robot_navmesh_offsets: typing.List[typing.Tuple[float, float]], robot_navmesh_radius: float, in_collision: bool, dbv: sims.habitat_simulator.debug_visualizer.DebugVisualizer, obs_cache: typing.List[typing.Any]) -> None

Render a single frame 3rd person view of the robot embodiment approximation following a path with DebugVizualizer and cache it in obs_cache.

Parameters
curr_path_points List of current path points.
robot_transformation Current transformation of the robot.
robot_navmesh_offsets Robot embodiment approximation. List of 2D points XZ in robot local space.
robot_navmesh_radius The radius of each point approximating the robot embodiment.
in_collision Whether or not the robot is in collision with the environment. If so, embodiment is rendered red.
dbv The DebugVisualizer instance.
obs_cache The observation cache for later video rendering.