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

Control humanoid velocity from config. #2060

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
DIST_TO_STOP: float = (
1e-9 # If the amount to move is this distance, just stop the character
)
DEFINE_VELOCITY_FROM_CONFIG: bool = True

from typing import List, Tuple

Expand Down Expand Up @@ -83,6 +84,7 @@ def __init__(

self.prev_orientation = None
self.walk_mocap_frame = 0
self.meters_per_step = 0.0

self.hand_processed_data = {}
self._hand_names = ["left_hand", "right_hand"]
Expand Down Expand Up @@ -125,8 +127,8 @@ def set_framerate_for_linspeed(
"""

seconds_per_step = 1.0 / ctrl_freq
meters_per_step = lin_speed * seconds_per_step
frames_per_step = meters_per_step / self.dist_per_step_size
self.meters_per_step = lin_speed * seconds_per_step
frames_per_step = self.meters_per_step / self.dist_per_step_size
self.motion_fps = self.walk_motion.fps / frames_per_step
rotate_amount = ang_speed * seconds_per_step
rotate_amount = rotate_amount * 180.0 / np.pi
Expand Down Expand Up @@ -270,7 +272,14 @@ def calculate_walk_pose(
# The base_transform here is independent of transforms caused by the current
# motion pose.
obj_transform_base = look_at_path_T
forward_V_dist = forward_V * dist_diff * distance_multiplier

# TODO: Switch between animation-driven speed and config-driven speed.
if DEFINE_VELOCITY_FROM_CONFIG:
forward_V_dist = (
forward_V * self.meters_per_step * distance_multiplier
)
else:
forward_V_dist = forward_V * dist_diff * distance_multiplier
obj_transform_base.translation += forward_V_dist

rot_offset = mn.Matrix4.rotation(
Expand Down Expand Up @@ -445,7 +454,14 @@ def calculate_walk_pose_directional(
# The base_transform here is independent of transforms caused by the current
# motion pose.
obj_transform_base = look_at_path_T
forward_V_dist = forward_V * dist_diff * distance_multiplier

# TODO: Switch between animation-driven speed and config-driven speed.
if DEFINE_VELOCITY_FROM_CONFIG:
forward_V_dist = (
forward_V * self.meters_per_step * distance_multiplier
)
else:
forward_V_dist = forward_V * dist_diff * distance_multiplier
obj_transform_base.translation += forward_V_dist

rot_offset = mn.Matrix4.rotation(
Expand Down