Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Facebookresearch Habitat lab LabDriver init

From Leeroopedia
Knowledge Sources
Domains Human_in_the_Loop, Simulation
Last Updated 2026-02-15 02:00 GMT

Overview

Concrete driver class for managing the Habitat environment in human-in-the-loop interactive sessions, provided by habitat-hitl.

Description

The LabDriver initializes a full Habitat Env wrapped in GymHabitatEnv, creates per-agent controllers (GuiRobotController, GuiHumanoidController, or BaselinesController), sets up camera management, and provides the sim_update method that advances the simulation by one frame. It handles multi-agent scenarios, episode management, and rendering pipeline coordination.

Usage

Created by hitl_main or hitl_headed_main during application startup. The driver's sim_update method is called every frame by the application loop.

Code Reference

Source Location

  • Repository: habitat-lab
  • File: habitat-hitl/habitat_hitl/_internal/lab_driver.py
  • Lines: L59-198 (__init__), L399-479 (sim_update)

Signature

class LabDriver:
    def __init__(
        self,
        config,
        gui_input: GuiInput,
        line_render: Optional[DebugLineRender],
        text_drawer: AbstractTextDrawer,
        create_app_state_lambda: Callable,
    ):
        """
        Args:
            config: Composed HITL + Habitat config
            gui_input: Input handler for keyboard/mouse/VR
            line_render: Debug line renderer
            text_drawer: Text overlay renderer
            create_app_state_lambda: Factory for creating app state
        """

    def sim_update(self, dt: float) -> Dict[str, Any]:
        """
        Advance simulation by one frame.

        Args:
            dt: Frame delta time in seconds
        Returns:
            Dict with keyframes, debug_images, cam_transform
        """

Import

from habitat_hitl._internal.lab_driver import LabDriver

I/O Contract

Inputs

Name Type Required Description
config DictConfig Yes Composed HITL + Habitat config
gui_input GuiInput Yes Input handler for user interactions
create_app_state_lambda Callable Yes Factory for creating the application state machine

Outputs

Name Type Description
sim_update returns Dict[str, Any] Frame data: keyframes, debug_images, cam_transform

Usage Examples

LabDriver Creation (Inside hitl_main)

# LabDriver is typically created internally by hitl_main
# This shows the conceptual creation
driver = LabDriver(
    config=composed_config,
    gui_input=gui_input,
    line_render=debug_line_render,
    text_drawer=text_drawer,
    create_app_state_lambda=lambda app_service: MyAppState(app_service),
)

# Frame loop
while running:
    frame_data = driver.sim_update(dt=1.0/30.0)

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment