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 Hitl main

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

Overview

Concrete top-level entry point for launching HITL applications in headed (windowed) or headless (server) mode, provided by habitat-hitl.

Description

The hitl_main function dispatches to either hitl_headed_main (Magnum windowed app) or hitl_headless_main (headless server) based on config. It creates the LabDriver, sets up rendering, initializes networking if enabled, and enters the application loop. The headed variant uses Magnum's Application class; the headless variant runs a timer-driven loop with WebSocket client connections.

Usage

Called as the final step in HITL application scripts after defining the create_app_state_lambda factory function.

Code Reference

Source Location

  • Repository: habitat-lab
  • File: habitat-hitl/habitat_hitl/core/hitl_main.py
  • Lines: L49-63 (hitl_main), L66-149 (hitl_headed_main), L205-253 (hitl_headless_main)

Signature

def hitl_main(
    app_config,
    create_app_state_lambda=None,
):
    """
    Top-level entry point for HITL applications.

    Args:
        app_config: Composed HITL application config
        create_app_state_lambda: Factory function that creates the root AppState
            Signature: (AppService) -> AppState
    """

Import

from habitat_hitl.core.hitl_main import hitl_main

I/O Contract

Inputs

Name Type Required Description
app_config DictConfig Yes Composed HITL + Habitat config
create_app_state_lambda Callable No Factory: (AppService) -> AppState

Outputs

Name Type Description
(side effects) None Runs the interactive application until exit; produces recordings/logs

Usage Examples

Launch Basic Viewer

import hydra
from habitat_hitl.core.hitl_main import hitl_main

@hydra.main(config_path="config", config_name="basic_viewer")
def main(config):
    hitl_main(config)

if __name__ == "__main__":
    main()

Launch with Custom AppState

from habitat_hitl.core.hitl_main import hitl_main
from my_app.states import MyStateMachine

def create_app_state(app_service):
    return MyStateMachine(app_service)

hitl_main(config, create_app_state_lambda=create_app_state)

Related Pages

Implements Principle

Requires Environment

Page Connections

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