(self, quat_params, root_pos, skel_joints=None, do_root_R=True)
| 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): |
| 127 | # quat_params (batch_size, joints_num, 4) |
| 128 | # joints (batch_size, joints_num, 3) |
| 129 | # root_pos (batch_size, 3) |
| 130 | if skel_joints is not None: |
| 131 | skel_joints = torch.from_numpy(skel_joints) |
| 132 | offsets = self.get_offsets_joints_batch(skel_joints) |
| 133 | if len(self._offset.shape) == 2: |
| 134 | offsets = self._offset.expand(quat_params.shape[0], -1, -1) |
| 135 | offsets = offsets.numpy() |
| 136 | joints = np.zeros(quat_params.shape[:-1] + (3,)) |
| 137 | joints[:, 0] = root_pos |
| 138 | for chain in self._kinematic_tree: |
| 139 | if do_root_R: |
| 140 | R = quat_params[:, 0] |
| 141 | else: |
| 142 | R = np.array([[1.0, 0.0, 0.0, 0.0]]).repeat(len(quat_params), axis=0) |
| 143 | for i in range(1, len(chain)): |
| 144 | R = qmul_np(R, quat_params[:, chain[i]]) |
| 145 | offset_vec = offsets[:, chain[i]] |
| 146 | joints[:, chain[i]] = qrot_np(R, offset_vec) + joints[:, chain[i - 1]] |
| 147 | return joints |
| 148 | |
| 149 | def forward_kinematics_cont6d_np(self, cont6d_params, root_pos, skel_joints=None, do_root_R=True): |
| 150 | # cont6d_params (batch_size, joints_num, 6) |
no test coverage detected