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

Port polish items from old HITL study branch #1671

Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion examples/siro_sandbox/app_states/app_state_free_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def _update_help_text(self):
self._episode_helper.num_iter_episodes
- self._episode_helper.num_episodes_done
)
progress_str = f"{num_episodes_remaining} episodes remaining"
progress_str = f"{num_episodes_remaining} episodes left"
self._sandbox_service.text_drawer.add_text(
progress_str,
TextOnScreenAlignment.TOP_RIGHT,
Expand Down
2 changes: 1 addition & 1 deletion examples/siro_sandbox/app_states/app_state_rearrange.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def _update_help_text(self):
self._episode_helper.num_iter_episodes
- self._episode_helper.num_episodes_done
)
progress_str = f"{num_episodes_remaining} episodes remaining"
progress_str = f"{num_episodes_remaining} episodes left"
self._sandbox_service.text_drawer.add_text(
progress_str,
TextOnScreenAlignment.TOP_RIGHT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def _update_help_text(self):
self._episode_helper.num_iter_episodes
- self._episode_helper.num_episodes_done
)
progress_str = f"{num_episodes_remaining} episodes remaining"
progress_str = f"{num_episodes_remaining} episodes left"
self._sandbox_service.text_drawer.add_text(
progress_str,
TextOnScreenAlignment.TOP_RIGHT,
Expand Down
4 changes: 4 additions & 0 deletions examples/siro_sandbox/app_states/app_state_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ def _sim_update_tutorial(self, dt: float):
if self._sandbox_service.gui_input.get_key_down(GuiInput.KeyNS.SPACE):
self._tutorial.skip_stage()

if self._sandbox_service.gui_input.get_key_down(GuiInput.KeyNS.Q):
while not self._tutorial.is_completed():
self._tutorial.skip_stage()

if self._tutorial.is_completed():
self._tutorial.stop_animations()
else:
Expand Down
4 changes: 2 additions & 2 deletions examples/siro_sandbox/hitl_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
TEXT_ROBOT_FOCUS: str = (
"This is your robot assistant.\nIt will help you accomplish your tasks.\n"
)
TEXT_AVATAR_FOCUS: str = "This is your avatar.\nYou will now gain control."
TEXT_HELP: str = "Spacebar: Skip"
TEXT_AVATAR_FOCUS: str = "You will now gain control of your avatar."
TEXT_HELP: str = "Q: Skip \nSpacebar: Skip to the next stage of the tutorial"


class ObjectAnimation:
Expand Down
24 changes: 21 additions & 3 deletions examples/siro_sandbox/sandbox_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ def local_end_episode(do_reset=False):
self.ctrl_helper.get_policy_driven_agent_controller(),
)
]
if args.show_tutorial:
self._app_states.insert(
0,
AppStateTutorial(
self._sandbox_service,
self.ctrl_helper.get_gui_agent_controller(),
),
)
elif args.app_state == "free_camera":
self._app_states = [AppStateFreeCamera(self._sandbox_service)]
else:
Expand Down Expand Up @@ -381,6 +389,13 @@ def _reset_environment(self):
self._app_state_index = (
0 # start from the first app state for each episode
)
# if show_tutorial enabled we show the tutorial once - before the first episode
if (
self._args.show_tutorial
and self._episode_helper.num_episodes_done > 0
):
self._app_state_index += 1

self._app_state = self._app_states[self._app_state_index]
self._app_state.on_enter(
prev_state=self._get_prev_app_state(),
Expand Down Expand Up @@ -728,7 +743,7 @@ def _parse_debug_third_person(args, framebuffer_size):
"--show-tutorial",
action="store_true",
default=False,
help="Shows an intro sequence that helps familiarize the user to the scene and task in a HITL context.",
help="Shows an intro sequence before the first episode that helps familiarize the user to task in a HITL context.",
)
parser.add_argument(
"--hide-humanoid-in-gui",
Expand Down Expand Up @@ -776,9 +791,12 @@ def _parse_debug_third_person(args, framebuffer_size):
"but --save-filepath-base argument is not set. Specify filepath base for the session episode data to be saved."
)

if args.show_tutorial and args.app_state != "rearrange":
if args.show_tutorial and args.app_state not in {
"rearrange",
"socialnav_study",
}:
raise ValueError(
"--show-tutorial is only supported for --app-state=rearrange"
"--show-tutorial is only supported for --app-state=rearrange and --app-state=socialnav_study"
)

if args.remote_gui_mode and args.app_state != "fetch":
Expand Down
9 changes: 6 additions & 3 deletions habitat-lab/habitat/tasks/rearrange/actions/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,12 @@ def update_base(self, fix_leg=False):
end_pos = self._sim.step_filter(
rigid_state.translation, target_rigid_state.translation
)
# Offset the base if the base height is different between end_pos
# and the current state
if end_pos[1] != rigid_state.translation[1]:

# try_step may fail, in which case it simply returns the start argument
did_try_step_fail = end_pos == rigid_state.translation
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this is fine. But going forward, let's keep our PRs into the HITL codebase separate from our PRs into Habitat-lab/baselines.

if not did_try_step_fail:
# If try_step succeeded, it snapped our start position to the navmesh
# We should apply the base offset
end_pos -= self.cur_articulated_agent.params.base_offset

target_trans = mn.Matrix4.from_(
Expand Down