Implementation:Facebookresearch Habitat lab GuiDrawer
| Knowledge Sources | |
|---|---|
| Domains | Embodied_AI, Human_in_the_Loop |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
GuiDrawer renders debug UI elements such as lines, boxes, and circles both on the server viewport (via habitat-sim DebugLineRender) and on remote clients (via ClientMessageManager).
Description
The GuiDrawer class provides a unified drawing API for rendering debug geometry in HITL applications. It supports dual rendering targets: a local server viewport using habitat-sim's DebugLineRender and remote clients via a ClientMessageManager. All drawing methods accept an optional destination_mask parameter (of type Mask) to control which users see the drawn elements.
The class supports a transform stack (push/pop) to enable local-space drawing. For remote clients, the transform stack is maintained per user. Drawing primitives include:
- draw_box: Wireframe box defined by min/max extents.
- draw_circle: Approximate circle defined by position, radius, normal, and segment count.
- draw_transformed_line: Line segment with optional color interpolation.
- draw_path_with_endpoint_circles: Sequence of line segments with circles at the endpoints.
Usage
Use GuiDrawer when you need to render visual debug overlays (e.g., object highlights, navigation paths, selection indicators) in the HITL application, whether rendering locally on the server or sending visual data to remote clients.
Code Reference
Source Location
- Repository: Facebookresearch_Habitat_lab
- File: habitat-hitl/habitat_hitl/core/gui_drawer.py
- Lines: 1-272
Signature
class GuiDrawer:
DEFAULT_SEGMENT_COUNT: Final[int] = 24
DEFAULT_NORMAL: mn.Vector3 = mn.Vector3(0.0, 1.0, 0.0)
def __init__(
self,
sim_debug_line_render: Optional[DebugLineRender],
client_message_manager: Optional[ClientMessageManager],
) -> None:
...
def get_sim_debug_line_render(self) -> Optional[DebugLineRender]:
...
def set_line_width(self, line_width: float, destination_mask: Mask = Mask.ALL) -> None:
...
def push_transform(self, transform: mn.Matrix4, destination_mask: Mask = Mask.ALL) -> None:
...
def pop_transform(self, destination_mask: Mask = Mask.ALL) -> None:
...
def draw_box(self, min_extent: mn.Vector3, max_extent: mn.Vector3, color: mn.Color4, destination_mask: Mask = Mask.ALL) -> None:
...
def draw_circle(self, translation: mn.Vector3, radius: float, color: mn.Color4, num_segments: int = DEFAULT_SEGMENT_COUNT, normal: mn.Vector3 = DEFAULT_NORMAL, billboard: bool = False, destination_mask: Mask = Mask.ALL) -> None:
...
def draw_transformed_line(self, from_pos: mn.Vector3, to_pos: mn.Vector3, from_color: mn.Color4, to_color: mn.Color4 = None, destination_mask: Mask = Mask.ALL) -> None:
...
def draw_path_with_endpoint_circles(self, points: List[mn.Vector3], radius: float, color: mn.Color4, num_segments: int = DEFAULT_SEGMENT_COUNT, normal: mn.Vector3 = DEFAULT_NORMAL, destination_mask: Mask = Mask.ALL) -> None:
...
Import
from habitat_hitl.core.gui_drawer import GuiDrawer
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| sim_debug_line_render | Optional[DebugLineRender] | No | The habitat-sim debug line renderer for server-side viewport rendering. Pass None to disable server rendering. |
| client_message_manager | Optional[ClientMessageManager] | No | The client message manager for sending drawing commands to remote clients. Pass None to disable remote rendering. |
Outputs
| Name | Type | Description |
|---|---|---|
| (visual output) | Rendered geometry | Lines, boxes, circles, and paths rendered on the server viewport and/or sent to remote clients. |
Usage Examples
Basic Usage
import magnum as mn
from habitat_hitl.core.gui_drawer import GuiDrawer
from habitat_hitl.core.user_mask import Mask
# Create a GuiDrawer with server-side rendering
gui_drawer = GuiDrawer(
sim_debug_line_render=sim.get_debug_line_render(),
client_message_manager=client_msg_mgr,
)
# Draw a red wireframe box
gui_drawer.draw_box(
min_extent=mn.Vector3(-0.5, 0.0, -0.5),
max_extent=mn.Vector3(0.5, 1.0, 0.5),
color=mn.Color4(1.0, 0.0, 0.0, 1.0),
)
# Draw a circle on the ground plane for user 0 only
gui_drawer.draw_circle(
translation=mn.Vector3(0.0, 0.01, 0.0),
radius=1.0,
color=mn.Color4(0.0, 1.0, 0.0, 1.0),
destination_mask=Mask.from_index(0),
)
# Draw a line with color interpolation
gui_drawer.draw_transformed_line(
from_pos=mn.Vector3(0, 0, 0),
to_pos=mn.Vector3(1, 1, 1),
from_color=mn.Color4(1, 0, 0, 1),
to_color=mn.Color4(0, 0, 1, 1),
)