Implementation:Facebookresearch Habitat lab AppService init
| Knowledge Sources | |
|---|---|
| Domains | Human_in_the_Loop, Software_Architecture |
| Last Updated | 2026-02-15 02:00 GMT |
Overview
Concrete dependency injection container for HITL application states, providing access to all framework services without tight coupling, provided by habitat-hitl.
Description
The AppService class aggregates all HITL framework services into a single container passed to each AppState. It provides access to the environment, simulator, GUI input, controllers, episode management, recording, and UI utilities. This decouples application logic from framework internals.
Usage
Created by LabDriver during initialization and passed to the create_app_state_lambda factory. Application states access services through the AppService instance.
Code Reference
Source Location
- Repository: habitat-lab
- File: habitat-hitl/habitat_hitl/app_states/app_service.py
- Lines: L30-77
Signature
class AppService:
def __init__(
self,
*,
config,
hitl_config,
users,
gui_input,
remote_client_state,
gui_drawer,
text_drawer,
ui_manager,
get_anim_fraction,
env,
sim,
compute_action_and_step_env,
step_recorder,
get_metrics,
end_episode,
set_cursor_style,
episode_helper,
client_message_manager,
gui_agent_controllers,
all_agent_controllers,
reconfigure_sim,
):
"""
Dependency injection container for HITL app states.
All parameters are keyword-only.
"""
Import
from habitat_hitl.app_states.app_service import AppService
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| config | DictConfig | Yes | Full application config |
| env | Env | Yes | Habitat environment instance |
| sim | Simulator | Yes | Habitat simulator instance |
| gui_input | GuiInput | Yes | User input handler |
| gui_agent_controllers | List | Yes | Per-agent GUI controllers |
| all_agent_controllers | List | Yes | All agent controllers (GUI + AI) |
Outputs
| Name | Type | Description |
|---|---|---|
| app_service | AppService | Container with all framework services accessible as attributes |
Usage Examples
Access Services in AppState
from habitat_hitl.app_states.app_state_abc import AppState
class MyGameplayState(AppState):
def __init__(self, app_service: AppService):
self._app_service = app_service
def sim_update(self, dt, post_sim_update_dict):
# Access framework services
env = self._app_service.env
sim = self._app_service.sim
metrics = self._app_service.get_metrics()
self._app_service.end_episode(do_reset=True)