Check for foot floating in the motion data.
(full_info_path: str, device: str, **kwargs)
| 210 | } |
| 211 | |
| 212 | def compute_foot_floating(full_info_path: str, device: str, **kwargs): |
| 213 | """ |
| 214 | Check for foot floating in the motion data. |
| 215 | """ |
| 216 | prompt_dict_ls = load_dimension_info(full_info_path, dimension='Foot_Floating') |
| 217 | |
| 218 | floating_list = [] |
| 219 | per_motion_metrics = [] |
| 220 | |
| 221 | for prompt_dict in tqdm(prompt_dict_ls): |
| 222 | evaluation_file = prompt_dict["evaluation_file"] |
| 223 | pred_joints = load_joints(evaluation_file, device) |
| 224 | |
| 225 | |
| 226 | contact = get_contact(pred_joints, device=device) |
| 227 | frames = pred_joints.shape[0] |
| 228 | |
| 229 | delta_ts = 0.001 |
| 230 | rate_ts = 0.6 |
| 231 | rate_high_ts = 1.75 |
| 232 | |
| 233 | # Root position and velocity |
| 234 | root_pos = pred_joints[:, 0] |
| 235 | root_vel = root_pos[1:] - root_pos[:-1] |
| 236 | root_vel = torch.cat([root_vel, root_vel[-1:]], dim=0) |
| 237 | |
| 238 | # Foot positions and velocities |
| 239 | foot_pos = pred_joints[:, FOOT_IDX] # (frames, 2, 3) |
| 240 | foot_vel = foot_pos[1:] - foot_pos[:-1] |
| 241 | foot_vel = torch.cat([foot_vel, foot_vel[-1:]], dim=0) |
| 242 | |
| 243 | # Relative foot positions and velocities |
| 244 | rel_foot_pos = foot_pos - root_pos.unsqueeze(1) |
| 245 | rel_foot_vel = rel_foot_pos[1:] - rel_foot_pos[:-1] |
| 246 | rel_foot_vel = torch.cat([rel_foot_vel, rel_foot_vel[-1:]], dim=0) |
| 247 | |
| 248 | # Check frame floating |
| 249 | left_foot_fl_rate = torch.zeros((frames, 1)).to(device) |
| 250 | right_foot_fl_rate = torch.zeros((frames, 1)).to(device) |
| 251 | invalid_flag = torch.ones((frames, 2)).to(device) |
| 252 | |
| 253 | for f in range(frames): |
| 254 | root_dis = torch.norm(root_vel[f], p=2, dim=-1) |
| 255 | left_parent_dis = torch.norm(rel_foot_vel[f, 0], p=2, dim=-1) |
| 256 | right_parent_dis = torch.norm(rel_foot_vel[f, 1], p=2, dim=-1) |
| 257 | rate_left = left_parent_dis / (root_dis + 1e-6) |
| 258 | rate_right = right_parent_dis / (root_dis + 1e-6) |
| 259 | |
| 260 | left_foot_fl_rate[f] = rate_left |
| 261 | right_foot_fl_rate[f] = rate_right |
| 262 | |
| 263 | left_foot_dis = torch.norm(foot_vel[f, 0], p=2, dim=-1) |
| 264 | right_foot_dis = torch.norm(foot_vel[f, 1], p=2, dim=-1) |
| 265 | |
| 266 | if root_dis < delta_ts: |
| 267 | continue |
| 268 | |
| 269 | lf_l_invalid = rate_left < rate_ts and left_foot_dis > 1.2e-4 |
nothing calls this directly
no test coverage detected