Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HITL - Make client loading state available to applications. #1955

Merged
merged 2 commits into from
May 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions habitat-hitl/habitat_hitl/core/remote_client_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def __init__(
self._client_state_history.append([])
self._receive_rate_trackers.append(AverageRateTracker(2.0))

self._client_loading: List[bool] = [False] * users.max_user_count

# temp map VR button to key
self._button_map = {
0: GuiInput.KeyNS.ZERO,
Expand All @@ -81,6 +83,10 @@ def get_gui_inputs(self) -> List[GuiInput]:
"""Get a list of all GuiInputs indexed by user index."""
return self._gui_inputs

def is_user_loading(self, user_index: int) -> bool:
"""Return true if the specified user's client is in a loading state."""
return self._client_loading[user_index]

def bind_gui_input(self, gui_input: GuiInput, user_index: int) -> None:
"""
Bind the specified GuiInput to a specified user, allowing the associated remote client to control it.
Expand Down Expand Up @@ -282,6 +288,11 @@ def _update_input_state(
# frame and other ways that keyHeld, keyDown, and keyUp can be inconsistent.
last_client_state = client_states[-1]

# Loading states.
self._client_loading[user_index] = last_client_state.get(
"isLoading", False
)

input_json = (
last_client_state["input"]
if "input" in last_client_state
Expand Down