protomotions.agents.evaluators.smoothness_calculator module#
- class protomotions.agents.evaluators.smoothness_calculator.SmoothnessCalculator(
- device,
- dt,
- window_sec=0.4,
- high_jerk_threshold=6500.0,
Bases:
objectCalculator for motion smoothness metrics like normalized jerk.
This class computes smoothness metrics from collected motion data, particularly using rigid body positions to derive velocity via finite differences and then computing normalized jerk.
- __init__(
- device,
- dt,
- window_sec=0.4,
- high_jerk_threshold=6500.0,
Initialize the smoothness evaluator.
- Parameters:
device (<Mock object at 0x7faa72920a10>[]) – Device to perform computations on
dt (float) – Time step duration in seconds (must be explicitly provided)
window_sec (float) – Default window size in seconds for rolling window computation
high_jerk_threshold (float) – Threshold for classifying windows as having high jerk
- compute_normalized_jerk_from_pos(
- rigid_body_pos_metric,
- num_bodies,
- window_sec=0.4,
- eps=0.1,
Compute normalized jerk from rigid body position data using sliding windows.
Similar to motion_visualizer_smoothness.py, computes normalized jerk over rolling windows rather than the entire motion sequence.
The normalized jerk is computed as: NJ = (T^5 * ∫|jerk|^2 dt) / (path_length^2)
Using T^5 makes the metric dimensionless and FPS-invariant, allowing fair comparison across motions sampled at different frame rates.
- Parameters:
rigid_body_pos_metric (MotionMetrics) – MotionMetrics containing rigid body positions Shape: [num_motions, max_frames, num_bodies*3]
num_bodies (int) – Number of rigid bodies
window_sec (float) – Window size in seconds for rolling window computation
eps (float) – Small epsilon for numerical stability
- Returns:
Mean normalized jerk per motion [num_motions] per_body_per_motion_nj: Mean normalized jerk per body per motion [num_motions, num_bodies] windowed_nj_per_motion: List of windowed NJ tensors per motion [num_windows, num_bodies]
- Return type:
per_motion_nj