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: rearrange_v2 example app and other features/fixes for Feb 12 demo #1810

Merged
merged 39 commits into from
Feb 20, 2024

Conversation

eundersander
Copy link
Contributor

@eundersander eundersander commented Feb 15, 2024

Motivation and Context

A big chunk of changes made in the last week leading up to our Feb 12/13 demo:

  • nicer instructions for installing Magnum on Mac
  • add MVP rearrange_v2 HITL app
  • add GuiPlacementHelper
  • add ClientHelper
  • changes to GuiPickHelper.
  • add config habitat_hitl.debug_line_width
  • changes to how connection_record/connection_params are handled
  • add config habitat_hitl.networking.wait_for_app_ready_signal
  • support for tracking client latency
  • add color and billboard-versus-up-facing options for highlight messages
  • minor bugfix to unity_dataset_processing.py
  • add hydra-core to requirements.txt

How Has This Been Tested

Some local testing with the various HITL apps.

Todo:

  • figure out why basic_viewer agents stopped moving (wrong config setting during my testing)
  • test Pick_throw_vr with the VR client Unity VR emulation

Types of changes

  • [HITL]

Checklist

  • My code follows the code style of this project.
  • I have updated the documentation if required.
  • I have read the CONTRIBUTING document.
  • I have completed my CLA (see CONTRIBUTING)
  • I have added tests to cover my changes if required.

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Feb 15, 2024
@eundersander eundersander force-pushed the eundersander/hitl-demo-feb12-refactored branch from 8e91e59 to 29c3abc Compare February 15, 2024 22:38
eundersander and others added 28 commits February 15, 2024 17:22
* support for processing new client connections, including the "connection record"
* changed client-ready message to instead be the connection record; see stub_client.html for reference
* RemoteGuiInput logic to clear input history when client changes (i.e. disconnect/reconnect)"
… for rearrange_v2; add ESC to AgnosticKeyNS; mypy/flake8 fixes
@eundersander eundersander force-pushed the eundersander/hitl-demo-feb12-refactored branch from 52a00fa to 666bc0b Compare February 15, 2024 23:36
Copy link
Contributor Author

@eundersander eundersander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments for reviewers.

@@ -450,15 +449,6 @@ def sim_update(self, dt):
+ dt * self._hitl_config.viz_animation_speed
) % 1.0

# Navmesh visualization only works in the debug third-person view
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of behavior tied to a keypress should be implemented in AppStates, not HitlDriver.

@@ -475,13 +465,6 @@ def sim_update(self, dt):
for keyframe in keyframes:
self._recording_keyframes.append(keyframe)

# Manually save recorded gfx-replay keyframes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like debug code. Removing it. It can be re-added to individual AppStates that need it.

@@ -10,6 +10,12 @@
import numpy as np

DIST_HIGHLIGHT: Final[float] = 0.15
COLOR_GRASPABLE: Final[mn.Color3] = mn.Color3(1, 0.75, 0)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class was not being used at all in main. I made some major changes to get it to work for rearrange_v2.

@eundersander eundersander requested a review from 0mdc February 15, 2024 23:46
Copy link
Contributor

@0mdc 0mdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice progress! I did a first pass and left some comments.


# physical key enum from USB HID Usage Tables
# https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf, page 53
# add misisng keys here as necessary
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: misisng

)
highlight_dict = {"t": [pos[0], pos[1], pos[2]], "r": radius}
if billboard:
highlight_dict["b"] = 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Billboarding could be driven by the server.

To be clear, I'm not suggesting any change here, the billboard parameter makes it easy to replace.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest doing billboarding on the client. In general, I don't always expect the server to drive the camera.


def conv(channel):
# sloppy: using int 0-255 to reduce serialized data size
return int(channel * 255.0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

def add_text(
self,
text_to_add,
alignment: TextOnScreenAlignment = TextOnScreenAlignment.TOP_LEFT,
text_delta_x: int = 0,
text_delta_y: int = 0,
):
pass
align_y, align_x = alignment.value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated: I find TextOnScreenAlignment being {y, x} hard to follow. It's probably worth a comment, rename or swap.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. The text layout system needs a large refactor at some point.

self._app_service = gui_service
self._gravity_dir = gravity_dir

def _find_snap_pos(self, ray, query_obj):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type annotations would be useful on this one because the return type is non-trivial.

self._gui_agent_ctrl._humanoid_controller.obj_transform_base.translation
)

def _get_gui_agent_feet_height(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, I would move this in GuiHumanoidController.

)
self._app_service.end_episode(do_reset=True)

def _update_placement(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rename this to something along the lines of _update_held_object_placement().


if self._placement_helper.update(ray, self._held_obj_id):
# sloppy: save another keyframe here since we just moved the held object
self.get_sim().gfx_replay_manager.save_keyframe()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Why is this required here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't add this, we see a lag between the camera movement and the snapped held object placement.

This is essentially part of a "post update" (after the underlying sim step). The sim step updates the agent pose. We update the camera from the updated agent pose, then we update the held object placement from the camera (since it uses a screen-relative raycast).

A gfx-replay keyframe is captured inside the sim step, but in this case we're manipulating the scene after the sim step.

self._app_service = gui_service
self._gravity_dir = gravity_dir

def _find_snap_pos(self, ray, query_obj):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rename this function to something like _try_snap_object_to_surface to convey that this applies a translation.

def is_user_idle_this_frame(self):
return not self._app_service.gui_input.get_any_key_down()

def _update_for_remote_client_connect_and_idle(self):
Copy link
Contributor

@0mdc 0mdc Feb 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be clearer to split this function into connection handling, idle timer handling and sps counter updating.

polish from PR feedback
@eundersander eundersander marked this pull request as ready for review February 20, 2024 15:39
Copy link
Contributor

@0mdc 0mdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I think that this is a good starting point for rearrange_v2.

class ClientHelper:
"""
Tracks connected remote clients. Displays client latency and kicks idle clients.
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that we're grouping this functionality here.

Nit: the name ClientHelper is vague in terms of what this class actually does.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah but I figure the functionality will grow.

@eundersander eundersander merged commit 03de61e into main Feb 20, 2024
4 checks passed
@eundersander eundersander deleted the eundersander/hitl-demo-feb12-refactored branch February 20, 2024 23:30
henrysamer pushed a commit that referenced this pull request Feb 21, 2024
…mo (#1810)

* nicer instructions for installing Magnum on Mac
* add MVP rearrange_v2 HITL app
* add GuiPlacementHelper
* add ClientHelper
* changes to GuiPickHelper.
* add config habitat_hitl.debug_line_width
* changes to how connection_record/connection_params are handled
* add config habitat_hitl.networking.wait_for_app_ready_signal
* support for tracking client latency
* add color and billboard-versus-up-facing options for highlight messages
* minor bugfix to unity_dataset_processing.py
* add hydra-core to requirements.txt
dannymcy pushed a commit to dannymcy/habitat-lab that referenced this pull request Jul 8, 2024
…mo (facebookresearch#1810)

* nicer instructions for installing Magnum on Mac
* add MVP rearrange_v2 HITL app
* add GuiPlacementHelper
* add ClientHelper
* changes to GuiPickHelper.
* add config habitat_hitl.debug_line_width
* changes to how connection_record/connection_params are handled
* add config habitat_hitl.networking.wait_for_app_ready_signal
* support for tracking client latency
* add color and billboard-versus-up-facing options for highlight messages
* minor bugfix to unity_dataset_processing.py
* add hydra-core to requirements.txt
HHYHRHY pushed a commit to SgtVincent/EMOS that referenced this pull request Aug 31, 2024
…mo (facebookresearch#1810)

* nicer instructions for installing Magnum on Mac
* add MVP rearrange_v2 HITL app
* add GuiPlacementHelper
* add ClientHelper
* changes to GuiPickHelper.
* add config habitat_hitl.debug_line_width
* changes to how connection_record/connection_params are handled
* add config habitat_hitl.networking.wait_for_app_ready_signal
* support for tracking client latency
* add color and billboard-versus-up-facing options for highlight messages
* minor bugfix to unity_dataset_processing.py
* add hydra-core to requirements.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants