| 1140 | |
| 1141 | |
| 1142 | class SkeletonMotion(SkeletonState): |
| 1143 | |
| 1144 | def __init__(self, tensor_backend, skeleton_tree, is_local, fps, *args, **kwargs): |
| 1145 | self._fps = fps |
| 1146 | super().__init__(tensor_backend, skeleton_tree, is_local, *args, **kwargs) |
| 1147 | |
| 1148 | def clone(self): |
| 1149 | return SkeletonMotion( |
| 1150 | self.tensor.clone(), self.skeleton_tree, self._is_local, self._fps |
| 1151 | ) |
| 1152 | |
| 1153 | @property |
| 1154 | def invariant_property(self): |
| 1155 | return { |
| 1156 | "skeleton_tree": self.skeleton_tree, |
| 1157 | "is_local": self.is_local, |
| 1158 | "fps": self.fps, |
| 1159 | } |
| 1160 | |
| 1161 | @property |
| 1162 | def global_velocity(self): |
| 1163 | """global velocity""" |
| 1164 | curr_index = self.num_joints * 4 + 3 |
| 1165 | return self.tensor[..., curr_index : curr_index + self.num_joints * 3].reshape( |
| 1166 | *(self.tensor.shape[:-1] + (self.num_joints, 3)) |
| 1167 | ) |
| 1168 | |
| 1169 | @property |
| 1170 | def global_angular_velocity(self): |
| 1171 | """global angular velocity""" |
| 1172 | curr_index = self.num_joints * 7 + 3 |
| 1173 | return self.tensor[..., curr_index : curr_index + self.num_joints * 3].reshape( |
| 1174 | *(self.tensor.shape[:-1] + (self.num_joints, 3)) |
| 1175 | ) |
| 1176 | |
| 1177 | @property |
| 1178 | def fps(self): |
| 1179 | """number of frames per second""" |
| 1180 | return self._fps |
| 1181 | |
| 1182 | @property |
| 1183 | def time_delta(self): |
| 1184 | """time between two adjacent frames""" |
| 1185 | return 1.0 / self.fps |
| 1186 | |
| 1187 | @property |
| 1188 | def global_root_velocity(self): |
| 1189 | """global root velocity""" |
| 1190 | return self.global_velocity[..., 0, :] |
| 1191 | |
| 1192 | @property |
| 1193 | def global_root_angular_velocity(self): |
| 1194 | """global root angular velocity""" |
| 1195 | return self.global_angular_velocity[..., 0, :] |
| 1196 | |
| 1197 | @classmethod |
| 1198 | def from_state_vector_and_velocity( |
| 1199 | cls, |