MCPcopy Create free account
hub / github.com/MotrixLab/MotionDiffuse / recover_root_rot_pos

Function recover_root_rot_pos

text2motion/utils/motion_process.py:362–381  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

360# local_velocity (B, seq_len, joint_num*3)
361# foot contact (B, seq_len, 4)
362def recover_root_rot_pos(data):
363 rot_vel = data[..., 0]
364 r_rot_ang = torch.zeros_like(rot_vel).to(data.device)
365 '''Get Y-axis rotation from rotation velocity'''
366 r_rot_ang[..., 1:] = rot_vel[..., :-1]
367 r_rot_ang = torch.cumsum(r_rot_ang, dim=-1)
368
369 r_rot_quat = torch.zeros(data.shape[:-1] + (4,)).to(data.device)
370 r_rot_quat[..., 0] = torch.cos(r_rot_ang)
371 r_rot_quat[..., 2] = torch.sin(r_rot_ang)
372
373 r_pos = torch.zeros(data.shape[:-1] + (3,)).to(data.device)
374 r_pos[..., 1:, [0, 2]] = data[..., :-1, 1:3]
375 '''Add Y-axis rotation to root position'''
376 r_pos = qrot(qinv(r_rot_quat), r_pos)
377
378 r_pos = torch.cumsum(r_pos, dim=-2)
379
380 r_pos[..., 1] = data[..., 3]
381 return r_rot_quat, r_pos
382
383
384def recover_from_rot(data, joints_num, skeleton):

Callers 2

recover_from_rotFunction · 0.85
recover_from_ricFunction · 0.85

Calls 3

qrotFunction · 0.85
qinvFunction · 0.85
toMethod · 0.80

Tested by

no test coverage detected