Habitat-Sim

repository·main·Indexed 25 days ago

https://github.com/facebookresearch/habitat-sim

A high-performance 3D simulator for embodied AI research, providing fast physics-enabled environments and sensor simulation for robots interacting with 3D scans or CAD models. It supports rigid-body mechanics via Bullet physics and is designed to work alongside Habitat-Lab for agent training.

Tokens
40.9K
Snippets
87
Records
235
Agent score
84%

What's inside habitat-sim

  1. Overview of Habitat-Sim

    main

    Habitat-Sim is a high-performance, physics-enabled 3D simulator designed for embodied AI research. It prioritizes simulation speed, capable of achieving thousands of frames per second (FPS) for rendering and high steps per second (SPS) for rigid-body dynamics.

    Key capabilities include:

    • Support for 3D scans (HM3D, HSSD, MatterPort3D, Gibson, Replica) and CAD models (ReplicaCAD, YCB, Google Scanned Objects).
    • Configurable sensors like RGB-D cameras and egomotion sensing.
    • Robot simulation via URDF (e.g., Fetch, Franka, AlienGo).
    • Rigid-body mechanics powered by Bullet physics.

    It is designed to work alongside Habitat-Lab for high-level task definition and agent training.

  2. Understand Habitat-Sim architecture and resource management

    main

    The Habitat-Sim backend is implemented in C++ using the Magnum graphics middleware. Key architectural components include:

    • Simulator: The central orchestrator that delegates resource management to the ResourceManager.
    • ResourceManager: Responsible for loading and caching 3D environment data (triangle mesh geometry, textures, shaders) from various on-disk formats to ensure efficient memory usage.
    • SceneGraphs: A structured representation of 3D environments. Environments are composed of SceneNodes representing distinct objects or regions.
    • Agents and Sensors: These are instantiated by attaching them to specific SceneNodes within a SceneGraph.

    This design allows for programmatic manipulation of object states and the ability to combine objects from different environments.

  3. Understand SceneDataset and MetadataMediator

    main

    A SceneDataset is a metadata configuration structure that defines system parameters, links assets, and organizes them into scene descriptions for use in a Simulator.

    Key components:

    • Attributes: Objects detailing configurations for individual objects, stages, and scenes, imported from .json files.
    • AttributeManager: APIs used to manage these attributes via C++ and Python.
    • MetadataMediator: Aggregates all AttributeManagers and provides an API to swap the active SceneDataset. It can be passed into the Simulator constructor via SimulatorConfiguration or used independently for metadata management.
  4. Initialize a simulator with default settings

    main
    To quickly set up a simulator, use habitat_sim.utils.settings.default_sim_settings. This dictionary can be passed directly to settings.make_cfg() to create a default Configuration for an empty scene. You can modify this dictionary to customize the simulator before instantiation.
  5. Use the Asset Viewer to view assets in Habitat-Sim

    main

    The Asset Viewer is a tool available as both a Jupyter notebook and a pure Python utility used to visualize how assets (like stages or objects) will be rendered in the Habitat-Sim engine. You can run the utility directly from the command line to inspect assets.

    To run the asset viewer utility, use the following command:

    python path/to/habitat-sim/examples/tutorials/nb_python/asset_viewer.py
    $ python path/to/habitat-sim/examples/tutorials/nb_python/asset_viewer.py
  6. Install Habitat-Sim Nightly Builds

    main
    If you require features from the latest main branch that are not yet in a stable release, you can install the nightly conda build. To do this, replace the -c aihabitat channel with -c aihabitat-nightly in your conda install command.
  7. Implement custom agent actions using SceneNodeControl

    main

    To add new actions outside of the source code, implement a custom control functor by subclassing habitat_sim.agent.SceneNodeControl. The class must implement a __call__ method with the following signature:

    def __call__(self, scene_node: habitat_sim.SceneNode, actuation_spec: habitat_sim.ActuationSpec):
        pass
    • scene_node: The object being manipulated or controlled.
    • actuation_spec: Contains parameters required by the control function.

    For reference, existing implementations can be found in src_python/habitat_sim/agent/controls/default_controls.py.

    def __call__(self, scene_node: habitat_sim.SceneNode, actuation_spec: habitat_sim.ActuationSpec):
        pass
  8. Apply noise models to sensors

    main

    You can bridge the gap between simulated and real-world observations by applying noise models to sensors. To do this, specify the noise model name in the sensor.SensorSpec.noise_model field and provide any necessary constructor arguments via the sensor.SensorSpec.noise_model_kwargs field.

    Available noise models are accessible via a registry by their string names.

    sensor_spec.noise_model = "RedwoodDepthNoiseModel"
    sensor_spec.noise_model_kwargs = dict(noise_multiplier=5)