habitat_sim.simulator.Simulator class

The core class of habitat-sim

The simulator ties together the backend, the agent, controls functions, NavMesh collision checking/pathfinding, attribute template management, object manipulation, and physics simulation.

Methods

def add_gradient_trajectory_object(self, traj_vis_name: str, points: typing.List[magnum.Vector3], colors: typing.List[magnum.Color3], num_segments: int = 3, radius: float = 0.001, smooth: bool = False, num_interpolations: int = 10) -> int
def add_sensor(self, sensor_spec: sensor.SensorSpec, agent_id: typing.Optional[int] = None) -> None
def add_trajectory_object(self, traj_vis_name: str, points: typing.List[magnum.Vector3], num_segments: int = 3, radius: float = 0.001, color: magnum.Color4 = Vector(0.9, 0.1, 0.1, 1), smooth: bool = False, num_interpolations: int = 10) -> int
Build a tube visualization around the passed trajectory of points. points : (list of 3-tuples of floats) key point locations to use to create trajectory tube. num_segments : (Integer) the number of segments around the tube to be used to make the visualization. radius : (Float) the radius of the resultant tube. color : (4-tuple of float) the color of the trajectory tube. smooth : (Bool) whether or not to smooth trajectory using a Catmull-Rom spline interpolating spline. num_interpolations : (Integer) the number of interpolation points to find between successive key points.
def build_semantic_CC_objects(self, /) -> typing.Dict[int, typing.List[habitat_sim._ext.habitat_sim_bindings.CCSemanticObject]]
Get a dictionary of the current semantic scene’s connected components keyed by color or id, where each value is a list of Semantic Objects corresponding to an individual connected component.
def build_vertex_color_map_report(self, /) -> typing.List[str]
Get a list of strings describing first each color found on vertices in the semantic mesh that is not present in the loaded semantic scene descriptor file, and then a list of each semantic object whose specified color is not found on any vertex in the mesh.
def cast_ray(self, ray: geo.Ray, max_distance: float = 100.0, buffer_distance: float = 0.08) -> physics.RaycastResults
Cast a ray into the collidable scene and return hit results. Physics must be enabled. max_distance in units of ray length.
def close(self, destroy: bool = True) -> None
Close the simulator instance.
def create_rigid_constraint(self, settings: physics.RigidConstraintSettings) -> int
Create a rigid constraint between two objects or an object and the world from a RigidConstraintsSettings.
def get_active_scene_graph(self, /) -> scene.SceneGraph
PYTHON DOES NOT GET OWNERSHIP
def get_active_semantic_scene_graph(self, /) -> scene.SceneGraph
PYTHON DOES NOT GET OWNERSHIP
def get_agent(self, agent_id: int) -> agent.Agent
def get_articulated_object_manager(self, /) -> physics.ArticulatedObjectManager
Get the manager responsible for organizing and accessing all the currently constructed articulated objects.
def get_asset_template_manager(self, /) -> attributes_managers.AssetAttributesManager
Get the current dataset’s AssetAttributesManager instance for configuring primitive asset templates.
def get_current_light_setup(self, /) -> typing.List[gfx.LightInfo]
Get a copy of the LightSetup used to create the current scene.
def get_debug_line_render(self, /) -> gfx.DebugLineRender
Get visualization helper for rendering lines.
def get_gravity(self, /) -> magnum.Vector3
Query the gravity vector for the scene.
def get_light_setup(self, key: str = '') -> typing.List[gfx.LightInfo]
Get a copy of the LightSetup registered with a specific key.
def get_lighting_template_manager(self, /) -> habitat_sim._ext.habitat_sim_bindings.LightLayoutAttributesManager
Get the current dataset’s LightLayoutAttributesManager instance for configuring light templates and layouts.
def get_object_template_manager(self, /) -> attributes_managers.ObjectAttributesManager
Get the current dataset’s ObjectAttributesManager instance for configuring object templates.
def get_physics_contact_points(self, /) -> typing.List[physics.ContactPointData]
Return a list of ContactPointData ” “objects describing the contacts from the most recent physics substep.
def get_physics_num_active_contact_points(self, /) -> int
The number of contact points that were active during the last step. An object resting on another object will involve several active contact points. Once both objects are asleep, the contact points are inactive. This count is a proxy for complexity/cost of collision-handling in the current scene.
def get_physics_num_active_overlapping_pairs(self, /) -> int
The number of active overlapping pairs during the last step. When object bounding boxes overlap and either object is active, additional “narrowphase” collision-detection must be run. This count is a proxy for complexity/cost of collision-handling in the current scene.
def get_physics_simulation_library(self, /) -> physics.PhysicsSimulationLibrary
Query the physics library implementation currently configured by this Simulator instance.
def get_physics_step_collision_summary(self, /) -> str
Get a summary of collision-processing from the last physics step.
def get_physics_template_manager(self, /) -> attributes_managers.PhysicsAttributesManager
Get the current PhysicsAttributesManager instance for configuring PhysicsManager templates.
def get_physics_time_step(self, /) -> float
Get the last used physics timestep
def get_rigid_constraint_settings(self, constraint_id: int) -> physics.RigidConstraintSettings
Get a copy of the settings for an existing rigid constraint.
def get_rigid_object_manager(self, /) -> physics.RigidObjectManager
Get the manager responsible for organizing and accessing all the currently constructed rigid objects.
def get_runtime_perf_stat_names(self, /) -> typing.List[str]
Runtime perf stats are various scalars helpful for troubleshooting runtime perf. This can be called once at startup. See also get_runtime_perf_stat_values.
def get_runtime_perf_stat_values(self, /) -> typing.List[float]
Runtime perf stats are various scalars helpful for troubleshooting runtime perf. These values generally change after every sim step. See also get_runtime_perf_stat_names.
def get_sensor_observations(self, agent_ids: typing.Union[int, typing.List[int]] = 0) -> typing.Union[typing.Dict[str, typing.Union[bool, numpy.ndarray, torch.Tensor]], typing.Dict[int, typing.Dict[str, typing.Union[bool, numpy.ndarray, torch.Tensor]]]]
def get_sensor_observations_async_finish(self) -> typing.Union[typing.Dict[str, typing.Union[numpy.ndarray, torch.Tensor]], typing.Dict[int, typing.Dict[str, typing.Union[numpy.ndarray, torch.Tensor]]]]
def get_stage_initialization_template(self, /) -> attributes.StageAttributes
Get a copy of the StageAttributes template used to instance a scene’s stage or None if it does not exist.
def get_stage_is_collidable(self, /) -> bool
Get whether or not the static stage is collidable.
def get_stage_template_manager(self, /) -> attributes_managers.StageAttributesManager
Get the current dataset’s StageAttributesManager instance for configuring simulation stage templates.
def get_world_time(self, /) -> float
Query the current simulation world time.
def initialize_agent(self, agent_id: int, initial_state: typing.Optional[agent.AgentState] = None) -> agent.Agent
def last_state(self, agent_id: typing.Optional[int] = None) -> agent.AgentState
def make_greedy_follower(self, agent_id: typing.Optional[int] = None, goal_radius: typing.Optional[float] = None, *, stop_key: typing.Optional[typing.Any] = None, forward_key: typing.Optional[typing.Any] = None, left_key: typing.Optional[typing.Any] = None, right_key: typing.Optional[typing.Any] = None, fix_thrashing: bool = True, thrashing_threshold: int = 16)
def perform_discrete_collision_detection(self, /) -> None
Perform discrete collision detection for the scene. Physics must be enabled. Warning: may break simulation determinism.
def physics_debug_draw(self, projMat: magnum.Matrix4) -> None
Render any debugging visualizations provided by the underlying physics simulator implementation given the composed projection and transformation matrix for the render camera.
def recompute_navmesh(self, pathfinder: nav.PathFinder, navmesh_settings: nav.NavMeshSettings) -> bool
Recompute the NavMesh for a given PathFinder instance using configured NavMeshSettings.
def reconfigure(self, config: Configuration) -> None
def remove_rigid_constraint(self, constraint_id: int) -> None
Remove a rigid constraint by id.
def reset(self, agent_ids: typing.Union[int, typing.List[int], None] = None) -> typing.Union[typing.Dict[str, typing.Union[bool, numpy.ndarray, torch.Tensor]], typing.Dict[int, typing.Dict[str, typing.Union[bool, numpy.ndarray, torch.Tensor]]]]
Reset the simulation state including the state of all physics objects, agents, and the default light setup. Sets the world time to 0.0, changes the physical state of all objects back to their initial states. Does not invalidate existing ManagedObject wrappers. Does not add or remove object instances. Only changes motion_type when scene_instance specified a motion type.
def reset_agent(self, agent_id: int) -> None
def save_current_scene_config(self, file_name: str) -> bool
Save the current simulation world’s state as a Scene Instance Config JSON using the passed name. This can be used to reload the stage, objects, articulated objects and other values as they currently are.
def save_current_scene_config(self, overwrite: bool = False) -> bool
Save the current simulation world’s state as a Scene Instance Config JSON using the name of the loaded scene, either overwritten, if overwrite is True, or with an incrementer in the file name of the form (copy xxxx) where xxxx is a number. This can be used to reload the stage, objects, articulated objects and other values as they currently are.
def seed(self, new_seed: int) -> None
def set_gravity(self, gravity: magnum.Vector3) -> None
Set the gravity vector for the scene.
def set_light_setup(self, light_setup: typing.List[gfx.LightInfo], key: str = '') -> None
Register a LightSetup with a specific key. If a LightSetup is already registered with this key, it will be overridden. All Drawables referencing the key will use the newly registered LightSetup.
def set_stage_is_collidable(self, collidable: bool) -> None
Set whether or not the static stage is collidable.
def start_async_render(self, agent_ids: typing.Union[int, typing.List[int]] = 0)
def start_async_render_and_step_physics(self, dt: float, agent_ids: typing.Union[int, typing.List[int]] = 0)
def step(self, action: typing.Union[str, int, typing.MutableMapping[int, typing.Union[str, int]]], dt: float = 0.016666666666666666) -> typing.Union[typing.Dict[str, typing.Union[bool, numpy.ndarray, torch.Tensor]], typing.Dict[int, typing.Dict[str, typing.Union[bool, numpy.ndarray, torch.Tensor]]]]
def step_filter(self, start_pos: magnum.Vector3, end_pos: magnum.Vector3) -> magnum.Vector3
Computes a valid navigable end point given a target translation on the NavMesh. Uses the configured sliding flag.
def step_physics(self, dt: float) -> None
def step_world(self, dt: float = 0.016666666666666666) -> float
Step the physics simulation by a desired timestep (dt). Note that resulting world time after step may not be exactly t+dt. Use get_world_time to query current simulation time.
def update_rigid_constraint(self, constraint_id: int, settings: physics.RigidConstraintSettings) -> None
Update the settings of a rigid constraint.

Special methods

def __attrs_post_init__(self) -> None
def __del__(self) -> None
def __enter__(self) -> Simulator
def __exit__(self, exc_type, exc_val, exc_tb)
def __init__(self, config: Configuration, async_draw_agent_ids: typing.Union[int, typing.List[int], None] = None) -> None
Method generated by attrs for class Simulator.

Properties

active_dataset: str get set
The currently active dataset being used. Will attempt to load configuration files specified if does not already exist.
curr_scene_name: str get
The simplified, but unique, name of the currently loaded scene.
frustum_culling: bool get set
Enable or disable the frustum culling
gfx_replay_manager: habitat_sim._ext.habitat_sim_bindings.ReplayManager get
Use gfx_replay_manager for replay recording and playback.
gpu_device: int get
metadata_mediator: metadata.MetadataMediator get set
This construct manages all configuration template managers and the Scene Dataset Configurations
Enable or disable wireframe visualization of current pathfinder’s NavMesh.
pathfinder: nav.PathFinder get set
random: habitat_sim._ext.habitat_sim_bindings.Random get
renderer: gfx.Renderer get
scene_aabb: magnum.Range3D get
Get the axis-aligned bounding box (AABB) of the scene in global space.
semantic_color_map get
The list of semantic colors being used for semantic rendering. The index in the list corresponds to the semantic ID.
semantic_scene: scene.SemanticScene get
The semantic scene graph
config: Configuration get set del
configuration for the simulator
agents: typing.List[agent.Agent] get set del

Method documentation

def habitat_sim.simulator.Simulator.close(self, destroy: bool = True) -> None

Close the simulator instance.

Parameters
destroy Whether or not to force the OpenGL context to be destroyed if async rendering was used. If async rendering wasn’t used, this has no effect.

def habitat_sim.simulator.Simulator.reset(self, agent_ids: typing.Union[int, typing.List[int], None] = None) -> typing.Union[typing.Dict[str, typing.Union[bool, numpy.ndarray, torch.Tensor]], typing.Dict[int, typing.Dict[str, typing.Union[bool, numpy.ndarray, torch.Tensor]]]]

Reset the simulation state including the state of all physics objects, agents, and the default light setup. Sets the world time to 0.0, changes the physical state of all objects back to their initial states. Does not invalidate existing ManagedObject wrappers. Does not add or remove object instances. Only changes motion_type when scene_instance specified a motion type.

Parameters
agent_ids An optional list of agent ids for which to return the sensor observations. If none is provide, default agent is used.

def habitat_sim.simulator.Simulator.step_filter(self, start_pos: magnum.Vector3, end_pos: magnum.Vector3) -> magnum.Vector3

Computes a valid navigable end point given a target translation on the NavMesh. Uses the configured sliding flag.

Parameters
start_pos The valid initial position of a translation.
end_pos The target end position of a translation.

Property documentation

habitat_sim.simulator.Simulator.semantic_scene: scene.SemanticScene get

The semantic scene graph