HumanML3D icon indicating copy to clipboard operation
HumanML3D copied to clipboard

Joint rotation output

Open XinandYu opened this issue 2 years ago • 2 comments

Hi, Eric! I'm trying to make a real time AI controlled motion agent. Because the skeleton of the agent is different, I have to convert the XYZ coordinate to the joint rotations first and then conduct FK to calculate the new joint positions. When I use the function from Skeleton.py, I meet the same problem as #26

May I ask why do you use xyz coordinate as the ouput but not joint rotation? Is there any real-time way to transfer the xyz coordinates to the joint rotation?

Thanks for your time. I'll appreciate a lot if you can help me.

XinandYu avatar Apr 17 '23 09:04 XinandYu

Hi, there is no specific reason of using xyz instead of rotations. Even if we use rotation, we may still use FK to obtain xyz positions from rotation. Because current rotation representation seems not compatible to other 3D softwares like blender. I kind of get the reason. In IK/FK in skeleton.py, for i_th bone, we are calculating the rotations for itself. While in bvh, actually we should get the rotations of it parent instead. Therefore, in line 91, you could try to use its parent bone, instead of the bone itself. I am not sure if it works. Here I attach the codes of our FK and bvh FK, you may see the difference: Our FK:

for i in range(1, len(chain)): 
      R = qmul(R, quat_params[:, chain[i]])
      offset_vec = offsets[:, chain[i]]
      joints[:, chain[i]] = qrot(R, offset_vec) + joints[:, chain[i-1]]

BVH FK:

for i in range(1, len(self.parents)): 
    global_quats[:, i] = qmul(global_quats[:, self.parents[i]], local_quats[:, i])
    global_pos[:, i] = qrot(global_quats[:, self.parents[i]], offsets[:, i]) + global_pos[:, self.parents[i]]

Hope this helps you. If it does not work, I know the recent work ReMoDiffuse managed to use the rotation representation in their demo. You may refer to them.

EricGuo5513 avatar Apr 17 '23 17:04 EricGuo5513

Thanks. I tried and the reason is what you mentioned. However, your FK seems more reasonable because if rotation is from the parents, there would be more than one children of some joints. For example, the parent of joints 1, 2 and 3 is 0. However, this rotation will calculate the offset of joints 1, 2 and 3. It seems not possible to do this with only one vector. If we replace the rotation of parents only, then there would be some errors when the joints have more than 1 child. Why did bvh do this? Could you please tell me where you got bvh FK code? Thanks. 屏幕截图 2023-04-20 105719

Ssstirm avatar Apr 20 '23 09:04 Ssstirm