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

[BE] - cleanup ao humanoid controllers #1994

Merged
merged 4 commits into from
Jun 27, 2024

Conversation

aclegg3
Copy link
Contributor

@aclegg3 aclegg3 commented Jun 26, 2024

Motivation and Context

This PR addresses two BE topics:

  1. refactors isinstance(ManagedArticulatedObject) checks to use obj.is_articulated property introduced by --[BE] - Add utility function to specify whether object is ao or not habitat-sim#2416
  2. add typing and docstrings to articulated_agent_controller APIs

How Has This Been Tested

CI should test this

Note: until 2416 hits nightly this will fail.

Types of changes

  • [Refactoring] Large changes to the code that improve its functionality or performance

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 Jun 26, 2024
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 clean-up! Thank you @aclegg3!

"""Set the speed of the humanoid according to the simulator speed"""
def set_framerate_for_linspeed(
self, lin_speed: float, ang_speed: float, ctrl_freq: int
) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Unrelated to your changes:

The motion-driven approach to determine agent speed is problematic in some use cases as it caps the linear velocity defined in configs.

This had to be bypassed in HITL experiments to set humanoid speed. See this hack.

I would suggest that we tackle that in the following weeks so that we can have full functionality on main.

FYI @xavierpuigf

@@ -107,7 +107,7 @@ def get_link_index(self, object_id: int) -> int:
)
if (
obj is not None
and isinstance(obj, ManagedBulletArticulatedObject)
and obj.is_articulated
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks :)

I think that, eventually, habitat-lab should provide a top-level class similar to this one to wrap the world state.

# The last dimension contains the quaternion
return quat_tens / np.linalg.norm(quat_tens, axis=-1)[..., None]

def inter_data(x_i, y_i, z_i, dat, is_quat=False):
def inter_data(
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 _trilinear_interpolation(...).

@@ -601,10 +644,14 @@ def inter_data(x_i, y_i, z_i, dat, is_quat=False):
)
return joint_list, transform

def calculate_reach_pose(self, obj_pos: mn.Vector3, index_hand=0):
def calculate_reach_pose(
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 update_reach_pose(...) to convey that this is a stateful operation.

value_norm_t = (index - lower) / -lower
lower = -1

return lower, upper, value_norm_t

def comp_inter(x_i, y_i, z_i):
def comp_inter(x_i: int, y_i: int, z_i: int) -> int:
Copy link
Contributor

@0mdc 0mdc Jun 26, 2024

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 _compute_pose_index(...). To be honest, I'm not sure what this really does though.

num_bins: int,
value: float,
interp: bool = False,
) -> Tuple[int, int, float]:
Copy link
Contributor

Choose a reason for hiding this comment

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

It would also be great to explain what this one does in more details.

@aclegg3
Copy link
Contributor Author

aclegg3 commented Jun 27, 2024

@0mdc thanks for the review. Your comments on function names and design are valid. We're planning to refactor this code in upcoming BE, so I'll postpone those changes until we do so.

@aclegg3 aclegg3 merged commit 01f3332 into main Jun 27, 2024
4 checks passed
@aclegg3 aclegg3 deleted the alex-06_26-cleanup_ao_humanoid_controllers branch June 27, 2024 16:10
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