protomotions.utils.motion_interpolation_utils module¶
Motion interpolation utilities.
Provides functions for smoothly interpolating between motion frames, including linear position interpolation and spherical quaternion interpolation (SLERP).
- protomotions.utils.motion_interpolation_utils.interpolate_pos(pos0, pos1, blend)[source]¶
Linear interpolation between two position tensors.
- Parameters:
pos0 – Starting positions [batch, …] or [batch, bodies, 3]
pos1 – Ending positions [batch, …] or [batch, bodies, 3]
blend – Blend factor [batch] where 0=pos0, 1=pos1
- Returns:
Interpolated positions with same shape as pos0/pos1
- protomotions.utils.motion_interpolation_utils.interpolate_quat(rot0, rot1, blend)[source]¶
Spherical linear interpolation (SLERP) between quaternions.
- Parameters:
rot0 – Starting quaternions [batch, 4] or [batch, bodies, 4]
rot1 – Ending quaternions [batch, 4] or [batch, bodies, 4]
blend – Blend factor [batch] where 0=rot0, 1=rot1
- Returns:
Interpolated quaternions with same shape as rot0/rot1
- protomotions.utils.motion_interpolation_utils.calc_frame_blend(time, length, num_frames, dt)[source]¶
Calculate frame indices and blend factor for interpolation.
- Parameters:
time (torch.Tensor) – Current time.
length (torch.Tensor) – Length of the motion sequence in seconds.
num_frames (torch.Tensor) – Number of frames in the motion sequence.
dt (torch.Tensor) – Time step between frames.
- Returns:
Frame index 0, frame index 1, and blend factor.
- Return type:
Tuple[torch.Tensor, torch.Tensor, torch.Tensor]