Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Facebookresearch Habitat lab Rearrange V2 World

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

Overview

The World class encapsulates the global world state shared across all users in the rearrange_v2 HITL application, caching scene object information including pickable objects, interactable links, agent IDs, semantic regions, and object states.

Description

World serves as the central data model for the rearrange_v2 application. It maintains several caches that are populated on reset() and queried during each frame:

  • _pickable_object_ids: Set of rigid object IDs that can be picked up by users (derived from scene object IDs).
  • _interactable_object_ids: Set of articulated object link IDs that can be opened/closed (excludes agent links).
  • _agent_object_ids: Set of object IDs that belong to agents (used to ignore agents during raycasting and selection).
  • _all_held_object_ids: Tracks which objects are currently held by any user, preventing multiple users from grabbing the same object.
  • _opened_link_set: Tracks which articulated links are currently in the open state.
  • _link_id_to_ao_map: Maps link object IDs to their parent articulated object IDs for fast lookup.
  • _regions: Caches semantic regions from the scene for room identification.

The class also optionally integrates with the habitat_llm package to initialize an ObjectStateMachine that tracks boolean object states (e.g., is_powered_on, is_clean) and a MetadataInterface for semantic category lookups. If the external package is not available, these features degrade gracefully.

Key methods include get_states_for_object_handle() to retrieve all active states for an object, get_category_from_handle() for semantic categories, get_primary_object_region() to find which room an object is in, and is_any_agent_holding_object() to check hold status across all agents.

Usage

World is instantiated once and shared across all UI instances in the rearrange_v2 application. Call reset() whenever the scene changes (episode reset) and update(dt) every frame to keep object states current.

Code Reference

Source Location

Signature

@dataclass
class ObjectStateInfo:
    state_spec: ObjectStateSpec
    value: Any


class World:
    def __init__(
        self,
        sim: RearrangeSim,
        config: DictConfig,
    ):

Import

from world import World

I/O Contract

Inputs

Name Type Required Description
sim RearrangeSim Yes The rearrange simulator instance providing access to objects and scene
config DictConfig Yes Configuration containing habitat dataset settings for metadata loading

Outputs

Name Type Description
_pickable_object_ids Set[int] Set of object IDs that can be picked up
_interactable_object_ids Set[int] Set of articulated link IDs that can be opened/closed
_agent_object_ids Set[int] Set of object IDs belonging to agents
get_state_snapshot_dict() Dict[str, Dict[str, Any]] Snapshot of all object states keyed by state name then object handle

Usage Examples

Basic Usage

from world import World

# Initialize the world
world = World(sim=rearrange_sim, config=config)

# Reset when scene changes
world.reset()

# Update each frame
world.update(dt=1.0 / 60.0)

# Query object information
rigid_obj = world.get_rigid_object(object_id=42)
category = world.get_category_from_handle(rigid_obj.handle)
states = world.get_states_for_object_handle(rigid_obj.handle)

# Check if an object is held by any agent
is_held = world.is_any_agent_holding_object(object_id=42)

# Get the room an object is in
region = world.get_primary_object_region(rigid_obj)
if region is not None:
    print(f"Object is in: {region.category.name()}")

# Get all object states
snapshot = world.get_state_snapshot_dict()
for state_name, handles in snapshot.items():
    for handle, value in handles.items():
        print(f"{handle}: {state_name} = {value}")

Related Pages

Page Connections

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