(self, quat_params, root_pos, skel_joints=None, do_root_R=True)
| 102 | |
| 103 | # Be sure root joint is at the beginning of kinematic chains |
| 104 | def forward_kinematics(self, quat_params, root_pos, skel_joints=None, do_root_R=True): |
| 105 | # quat_params (batch_size, joints_num, 4) |
| 106 | # joints (batch_size, joints_num, 3) |
| 107 | # root_pos (batch_size, 3) |
| 108 | if skel_joints is not None: |
| 109 | offsets = self.get_offsets_joints_batch(skel_joints) |
| 110 | if len(self._offset.shape) == 2: |
| 111 | offsets = self._offset.expand(quat_params.shape[0], -1, -1) |
| 112 | joints = torch.zeros(quat_params.shape[:-1] + (3,)).to(self.device) |
| 113 | joints[:, 0] = root_pos |
| 114 | for chain in self._kinematic_tree: |
| 115 | if do_root_R: |
| 116 | R = quat_params[:, 0] |
| 117 | else: |
| 118 | R = torch.tensor([[1.0, 0.0, 0.0, 0.0]]).expand(len(quat_params), -1).detach().to(self.device) |
| 119 | for i in range(1, len(chain)): |
| 120 | R = qmul(R, quat_params[:, chain[i]]) |
| 121 | offset_vec = offsets[:, chain[i]] |
| 122 | joints[:, chain[i]] = qrot(R, offset_vec) + joints[:, chain[i-1]] |
| 123 | return joints |
| 124 | |
| 125 | # Be sure root joint is at the beginning of kinematic chains |
| 126 | def forward_kinematics_np(self, quat_params, root_pos, skel_joints=None, do_root_R=True): |
nothing calls this directly
no test coverage detected