Compute foot-floor penetration based on the foot joints.
(full_info_path: str, device: str, **kwargs)
| 170 | } |
| 171 | |
| 172 | def compute_ground_penetration(full_info_path: str, device: str, **kwargs): |
| 173 | """ |
| 174 | Compute foot-floor penetration based on the foot joints. |
| 175 | """ |
| 176 | prompt_dict_ls = load_dimension_info(full_info_path, dimension='Ground_Penetration') |
| 177 | |
| 178 | penetration_list = [] |
| 179 | per_motion_metrics = [] |
| 180 | |
| 181 | for prompt_dict in tqdm(prompt_dict_ls): |
| 182 | evaluation_file = prompt_dict["evaluation_file"] |
| 183 | pred_joints = load_joints(evaluation_file, device) |
| 184 | |
| 185 | delta_ts = 0.005 # 5mm tolerance |
| 186 | floor_height = 0.0 |
| 187 | |
| 188 | foot_pos = pred_joints[:, FOOT_IDX] # (frames, 2, 3) |
| 189 | foot_ground_height = foot_pos[:, :, 2] - floor_height |
| 190 | |
| 191 | # Compute penetration distance (below the ground) |
| 192 | penetration_dist = torch.abs(foot_ground_height[foot_ground_height < -delta_ts]) |
| 193 | penetration_score = penetration_dist.mean() if penetration_dist.numel() > 0 else torch.tensor(0.0) |
| 194 | penetration_value = penetration_score.item() |
| 195 | |
| 196 | penetration_list.append(penetration_value) |
| 197 | per_motion_metrics.append( |
| 198 | { |
| 199 | "id": prompt_dict.get("id"), |
| 200 | "prompt": prompt_dict.get("prompt"), |
| 201 | "value": penetration_value, |
| 202 | "evaluation_file": evaluation_file, |
| 203 | "motion_duration": prompt_dict.get("motion_duration"), |
| 204 | } |
| 205 | ) |
| 206 | |
| 207 | return { |
| 208 | "aggregate": summarize_scores(penetration_list), |
| 209 | "per_motion": per_motion_metrics, |
| 210 | } |
| 211 | |
| 212 | def compute_foot_floating(full_info_path: str, device: str, **kwargs): |
| 213 | """ |
nothing calls this directly
no test coverage detected