habitat_sim.simulator.Simulator class

The core class of habitat-sim

Contents

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_object(self, object_lib_id: int, attachment_node: scene.SceneNode = None, light_setup_key: str = '', scene_id: int = 0) -> int
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Instance an object into the scene via a template referenced by library id. Optionally attach the object to an existing SceneNode and assign its initial LightSetup key.
def add_object_by_handle(self, object_lib_handle: str, attachment_node: scene.SceneNode = None, light_setup_key: str = '', scene_id: int = 0) -> int
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Instance an object into the scene via a template referenced by its handle. Optionally attach the object to an existing SceneNode and assign its initial LightSetup key.
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 apply_convex_hull_decomposition(self, filename: str, vhacd_params: habitat_sim._ext.habitat_sim_bindings.VHACDParameters = <habitat_sim._ext.habitat_sim_bindings.VHACDParameters object at 0x7fdbd043fdf8>, render_chd_result: bool = False, save_chd_to_obj: bool = False) -> str
Decomposite an object into its constituent convex hulls with specified VHACD parameters.
def apply_force(self, force: magnum.Vector3, relative_position: magnum.Vector3, object_id: int, scene_id: int = 0) -> None
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Apply an external force to an object at a specific point relative to the object’s center of mass in global coordinates. Only applies to MotionType::DYNAMIC objects.
def apply_torque(self, torque: magnum.Vector3, object_id: int, scene_id: int = 0) -> None
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Apply torque to an object. Only applies to MotionType::DYNAMIC objects.
def cast_ray(self, ray: geo.Ray, max_distance: float = 100.0, scene_id: int = 0) -> 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) -> None
def contact_test(self, object_id: int, scene_id: int = 0) -> bool
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Run collision detection and return a binary indicator of penetration between the specified object and any other collision object. Physics must be enabled.
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_angular_velocity(self, object_id: int, scene_id: int = 0) -> magnum.Vector3
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Get the angular component of an object’s velocity. Only non-zero for MotionType::DYNAMIC objects.
def get_asset_template_manager(self, /) -> attributes_managers.AssetAttributesManager
Get the current dataset’s AssetAttributesManager instance for configuring primitive asset templates.
def get_existing_object_ids(self, scene_id: int = 0) -> typing.List[int]
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Get the list of ids for all objects currently instanced in the scene.
def get_gravity(self, scene_id: int = 0) -> magnum.Vector3
Query the gravity vector for a 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_linear_velocity(self, object_id: int, scene_id: int = 0) -> magnum.Vector3
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Get the linear component of an object’s velocity. Only non-zero for MotionType::DYNAMIC objects.
def get_object_initialization_template(self, object_id: int, scene_id: int = 0) -> attributes.ObjectAttributes
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Get a copy of the ObjectAttributes template used to instance an object.
def get_object_is_collidable(self, object_id: int) -> bool
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Get whether or not an object is collidable.
def get_object_motion_type(self, object_id: int, scene_id: int = 0) -> physics.MotionType
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Get the MotionType of an object.
def get_object_scene_node(self, object_id: int, scene_id: int = 0) -> scene.SceneNode
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Get a reference to the root SceneNode of an object’s SceneGraph subtree.
def get_object_template_manager(self, /) -> attributes_managers.ObjectAttributesManager
Get the current dataset’s ObjectAttributesManager instance for configuring object templates.
def get_object_velocity_control(self, object_id: int, scene_id: int = 0) -> physics.VelocityControl
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Get a reference to an object’s VelocityControl struct. Use this to set constant control velocities for MotionType::KINEMATIC and MotionType::DYNAMIC objects.
def get_object_visual_scene_nodes(self, object_id: int, scene_id: int = 0) -> typing.List[scene.SceneNode]
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Get a list of references to the SceneNodes with an object’s render assets attached. Use this to manipulate the visual state of an object. Changes to these nodes will not affect physics simulation.
def get_physics_contact_points(self, /) -> typing.List[habitat_sim._ext.habitat_sim_bindings.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_simulation_library(self, /) -> physics.PhysicsSimulationLibrary
Query the physics library implementation currently configured by this Simulator instance.
def get_physics_template_manager(self, /) -> attributes_managers.PhysicsAttributesManager
Get the current PhysicsAttributesManager instance for configuring PhysicsManager templates.
def get_rigid_object_manager(self, /) -> physics.RigidObjectManager
Get the manager responsible for organizing and accessing all the currently constructed rigid objects.
def get_rigid_state(self, object_id: int, scene_id: int = 0) -> habitat_sim._ext.habitat_sim_bindings.RigidState
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Get an object’s transformation as a RigidState (i.e. vector, quaternion).
def get_rotation(self, object_id: int, scene_id: int = 0) -> magnum.Quaternion
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Get an object’s orientation.
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_stage_initialization_template(self, scene_id: int = 0) -> 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_transformation(self, object_id: int, scene_id: int = 0) -> magnum.Matrix4
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Get the transformation matrix of an object’s root SceneNode.
def get_translation(self, object_id: int, scene_id: int = 0) -> magnum.Vector3
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Get an object’s translation.
def get_world_time(self, /) -> float
Query the current simualtion 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 recompute_navmesh(self, pathfinder: nav.PathFinder, navmesh_settings: nav.NavMeshSettings, include_static_objects: bool = False) -> bool
Recompute the NavMesh for a given PathFinder instance using configured NavMeshSettings. Optionally include all MotionType::STATIC objects in the navigability constraints.
def reconfigure(self, config: Configuration) -> None
def remove_object(self, object_id: int, delete_object_node: bool = True, delete_visual_node: bool = True, scene_id: int = 0) -> None
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Remove an object instance from the scene. Optionally leave its root SceneNode and visual SceneNode on the SceneGraph.
def reset(self, agent_ids: typing.Union[int, None, typing.List[int]] = 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]]]]
def reset_agent(self, agent_id: int) -> None
def seed(self, new_seed: int) -> None
def set_angular_velocity(self, angVel: magnum.Vector3, object_id: int, scene_id: int = 0) -> None
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Set the angular component of an object’s velocity. Only applies to MotionType::DYNAMIC objects.
def set_gravity(self, gravity: magnum.Vector3, scene_id: int = 0) -> None
Set the gravity vector for a 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 overriden. All Drawables referencing the key will use the newly registered LightSetup.
def set_linear_velocity(self, linVel: magnum.Vector3, object_id: int, scene_id: int = 0) -> None
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Set the linear component of an object’s velocity. Only applies to MotionType::DYNAMIC objects.
def set_object_bb_draw(self, draw_bb: bool, object_id: int, scene_id: int = 0) -> None
Enable or disable bounding box visualization for an object.
def set_object_is_collidable(self, collidable: bool, object_id: int) -> None
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Set whether or not an object is collidable.
def set_object_light_setup(self, object_id: int, light_setup_key: str, scene_id: int = 0) -> None
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Modify the LightSetup used to the render all components of an object by setting the LightSetup key referenced by all Drawables attached to the object’s visual SceneNodes.
def set_object_motion_type(self, motion_type: physics.MotionType, object_id: int, scene_id: int = 0) -> None
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Set the MotionType of an object.
def set_object_semantic_id(self, semantic_id: int, object_id: int, scene_id: int = 0) -> None
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Convenience function to set the semanticId for all visual SceneNodes belonging to an object.
def set_rigid_state(self, rigid_state: habitat_sim._ext.habitat_sim_bindings.RigidState, object_id: int, scene_id: int = 0) -> None
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Set the transformation of an object from a RigidState and update its simulation state.
def set_rotation(self, rotation: magnum.Quaternion, object_id: int, scene_id: int = 0) -> None
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Set an object’s orientation and update its simulation state.
def set_stage_is_collidable(self, collidable: bool) -> None
Set whether or not the static stage is collidable.
def set_transformation(self, transform: magnum.Matrix4, object_id: int, scene_id: int = 0) -> None
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Set the transformation matrix of an object’s root SceneNode and update its simulation state.
def set_translation(self, translation: magnum.Vector3, object_id: int, scene_id: int = 0) -> None
DEPRECATED AND WILL BE REMOVED IN HABITAT-SIM 2.0. Use rigid object manager to directly access objects instead. Set an object’s translation and update its simulation state.
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, scene_id: int = 0) -> 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.

Special methods

def __attrs_post_init__(self) -> None
def __del__(self) -> None
def __enter__(self) -> Simulator
def __eq__(self, other)
Method generated by attrs for class Simulator.
def __exit__(self, exc_type, exc_val, exc_tb)
def __ge__(self, other)
Method generated by attrs for class Simulator.
def __gt__(self, other)
Method generated by attrs for class Simulator.
def __init__(self, config: Configuration) -> None
Method generated by attrs for class Simulator.
def __le__(self, other)
Method generated by attrs for class Simulator.
def __lt__(self, other)
Method generated by attrs for class Simulator.
def __ne__(self, other)
Method generated by attrs for class Simulator.
def __repr__(self)
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.
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
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.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