habitat.datasets.rearrange.navmesh_utils module

Classes

class SimpleVelocityControlEnv
A simple environment to control the velocity of the robot. Assumes x-forward in robot local space.

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 embodied_unoccluded_navmesh_snap(target_position: _magnum.Vector3, height: float, sim: habitat_sim.simulator.Simulator, pathfinder: typing.Optional[habitat_sim._ext.habitat_sim_bindings.PathFinder] = None, target_object_ids: typing.Optional[typing.List[int]] = None, ignore_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, embodiment_heuristic_offsets: typing.Optional[typing.List[_magnum.Vector2]] = None, agent_embodiment: typing.Optional[articulated_agents.MobileManipulator] = None, orientation_noise: float = 0, max_orientation_samples: int = 5, data_out: typing.Optional[typing.Dict[typing.Any, typing.Any]] = None) -> typing.Tuple[_magnum.Vector3, float, bool]
Snap a robot embodiment close to a target point considering embodied constraints via the navmesh and raycasting for point visibility.
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
Return True if the point is within a threshold distance (in XZ plane) of the nearest unoccluded navigable point on the selected island.
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, ignore_object_ids: typing.Optional[typing.List[int]] = None) -> bool
Uses raycasting to check whether a target is occluded given a navmesh snap point.
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, ignore_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]
Snap a point to the navmesh considering point visibility via raycasting.

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.embodied_unoccluded_navmesh_snap(target_position: _magnum.Vector3, height: float, sim: habitat_sim.simulator.Simulator, pathfinder: typing.Optional[habitat_sim._ext.habitat_sim_bindings.PathFinder] = None, target_object_ids: typing.Optional[typing.List[int]] = None, ignore_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, embodiment_heuristic_offsets: typing.Optional[typing.List[_magnum.Vector2]] = None, agent_embodiment: typing.Optional[articulated_agents.MobileManipulator] = None, orientation_noise: float = 0, max_orientation_samples: int = 5, data_out: typing.Optional[typing.Dict[typing.Any, typing.Any]] = None) -> typing.Tuple[_magnum.Vector3, float, bool]

Snap a robot embodiment close to a target point considering embodied constraints via the navmesh and raycasting for point visibility.

Parameters
target_position The 3D target position to snap.
height The height of the agent above the navmesh. Assumes the navmesh snap point is on the ground. Should be the maximum relative distance from navmesh ground to which a visibility check should indicate non-occlusion. The first check starts from this height. (E.g. agent_eyes_y - agent_base_y)
sim The RearrangeSimulator or Simulator instance. This choice will dictate the collision detection routine.
pathfinder The PathFinder defining the NavMesh to use.
target_object_ids An optional set of object ids which indicate the target. If one of these objects is hit before any non-ignored object, the test is successful. For example, when pos is an object’s COM, that object should not occlude the point.
ignore_object_ids An optional set of object ids which should be ignored in occlusion check. These objects should not stop the check. For example, the body and links of a robot.
island_id Optionally restrict the search to a single navmesh island. Default -1 is the full navmesh.
search_offset The additional radius to search for navmesh points around the target position. Added to the minimum distance from pos to navmesh.
test_batch_size The number of sample navmesh points to consider when testing for occlusion.
max_samples The maximum number of attempts to sample navmesh points for the test batch.
min_sample_dist The minimum allowed L2 distance between samples in the test batch.
embodiment_heuristic_offsets A set of 2D offsets describing navmesh cylinder center points forming a proxy for agent embodiment. Assumes x-forward, y to the side and 3D height fixed to navmesh. If provided, this proxy embodiment will be used for collision checking. If provided with an agent_embodiment, will be used instead of the MobileManipulatorParams.navmesh_offsets
agent_embodiment The MobileManipulator to be used for collision checking if provided.
orientation_noise Standard deviation of the gaussian used to sample orientation noise. If 0, states always face the target point. Noise is applied delta to this “target facing” orientation.
max_orientation_samples The number of orientation noise samples to try for each candidate point.
data_out Optionally provide a dictionary which can be filled with arbitrary detail data for external debugging and visualization.

NOTE: this function is based on sampling and does not guarantee the closest point.

return:
A Tuple containing: 1) An approximation of the closest unoccluded snap point to pos or None if an unoccluded point could not be found, 2) the sampled orientation if found or None, 3) a boolean success flag.

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_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

Return True if the point is within a threshold distance (in XZ plane) of the nearest unoccluded navigable point on the selected island.

Parameters
sim Habitat Simulator instance.
point The query point.
height The height of the agent. Given navmesh snap point is grounded, the maximum height from which a visibility check should indicate non-occlusion. First check starts from this height.
nav_to_min_distance Minimum distance threshold. -1 opts out of the test and returns True (i.e. no minimum distance).
nav_island The NavMesh island on which to check accessibility. Default -1 is the full NavMesh.
target_object_ids

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.

def habitat.datasets.rearrange.navmesh_utils.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, ignore_object_ids: typing.Optional[typing.List[int]] = None) -> bool

Uses raycasting to check whether a target is occluded given a navmesh snap point.

Parameters
target The 3D position which should be unoccluded from the snap point.
snap_point The navmesh snap point under consideration.
height The height of the agent above the navmesh. Assumes the navmesh snap point is on the ground. Should be the maximum relative distance from navmesh ground to which a visibility check should indicate non-occlusion. The first check starts from this height. (E.g. agent_eyes_y - agent_base_y)
sim The Simulator instance.
granularity The distance between raycast samples. Finer granularity is more accurate, but more expensive.
target_object_ids An optional set of object ids which indicate the target. If one of these objects is hit before any non-ignored object, the test is successful.
ignore_object_ids An optional set of object ids which should be ignored in occlusion check.

NOTE: If agent’s eye height is known and only that height should be considered, provide eye height and granularity > height for fastest check.

return:
whether or not the target is considered occluded from the snap_point.

def habitat.datasets.rearrange.navmesh_utils.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, ignore_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]

Snap a point to the navmesh considering point visibility via raycasting.

Parameters
pos The 3D position to snap.
height The height of the agent above the navmesh. Assumes the navmesh snap point is on the ground. Should be the maximum relative distance from navmesh ground to which a visibility check should indicate non-occlusion. The first check starts from this height. (E.g. agent_eyes_y - agent_base_y)
pathfinder The PathFinder defining the NavMesh to use.
sim The Simulator instance.
target_object_ids An optional set of object ids which indicate the target. If one of these objects is hit before any non-ignored object, the test is successful. For example, when pos is an object’s COM, that object should not occlude the point.
ignore_object_ids An optional set of object ids which should be ignored in occlusion check. These objects should not stop the check. For example, the body and links of a robot.
island_id Optionally restrict the search to a single navmesh island. Default -1 is the full navmesh.
search_offset The additional radius to search for navmesh points around the target position. Added to the minimum distance from pos to navmesh.
test_batch_size The number of sample navmesh points to consider when testing for occlusion.
max_samples The maximum number of attempts to sample navmesh points for the test batch.
min_sample_dist The minimum allowed L2 distance between samples in the test batch.

NOTE: this function is based on sampling and does not guarantee the closest point.

return:
An approximation of the closest unoccluded snap point to pos or None if an unoccluded point could not be found.