MCPcopy Create free account
hub / github.com/MotrixLab/ViMoGen / compute_foot_sliding

Function compute_foot_sliding

mbench/motion_quality.py:362–404  ·  view source on GitHub ↗

Check for foot sliding in the motion data.

(full_info_path: str, device: str, **kwargs)

Source from the content-addressed store, hash-verified

360 }
361
362def compute_foot_sliding(full_info_path: str, device: str, **kwargs):
363 """
364 Check for foot sliding in the motion data.
365 """
366 prompt_dict_ls = load_dimension_info(full_info_path, dimension='Foot_Sliding')
367
368 sliding_list = []
369 per_motion_metrics = []
370
371 for prompt_dict in tqdm(prompt_dict_ls):
372 evaluation_file = prompt_dict["evaluation_file"]
373 pred_joints = load_joints(evaluation_file, device)
374
375
376 contact = get_contact(pred_joints, device=device)
377
378 foot_pos = pred_joints[:, FOOT_IDX] # (frames, 2, 3)
379 # Compute foot velocity and delta joints
380 foot_vel = foot_pos[1:] - foot_pos[:-1]
381 foot_vel = torch.cat([foot_vel, foot_vel[-1:]], dim=0)
382 foot_delta = torch.norm(foot_vel[:, :, :2], dim=-1)
383
384 # Calculate sliding distance for left and right foot
385 left_sliding_dis = (foot_delta[:, 0] * contact[:, 0]).sum(dim=0) / ((contact[:, 0]).sum(dim=0) + 1e-6)
386 right_sliding_dis = (foot_delta[:, 1] * contact[:, 1]).sum(dim=0) / ((contact[:, 1]).sum(dim=0) + 1e-6)
387
388 sliding_score = (left_sliding_dis + right_sliding_dis) / 2
389 sliding_value = sliding_score.item()
390 sliding_list.append(sliding_value)
391 per_motion_metrics.append(
392 {
393 "id": prompt_dict.get("id"),
394 "prompt": prompt_dict.get("prompt"),
395 "value": sliding_value,
396 "evaluation_file": evaluation_file,
397 "motion_duration": prompt_dict.get("motion_duration"),
398 }
399 )
400
401 return {
402 "aggregate": summarize_scores(sliding_list),
403 "per_motion": per_motion_metrics,
404 }
405
406def compute_dynamic_degree(full_info_path: str, device: str, **kwargs):
407 """

Callers

nothing calls this directly

Calls 4

load_dimension_infoFunction · 0.90
load_jointsFunction · 0.85
get_contactFunction · 0.85
summarize_scoresFunction · 0.70

Tested by

no test coverage detected