protomotions.agents.evaluators.smoothness_evaluator module

class protomotions.agents.evaluators.smoothness_evaluator.SmoothnessEvaluator(device, dt=0.03333333333333333, window_sec=0.4, high_jerk_threshold=6500.0)[source]

Bases: object

Evaluator 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=0.03333333333333333, window_sec=0.4, high_jerk_threshold=6500.0)[source]

Initialize the smoothness evaluator.

Parameters:
  • device (<Mock object at 0x701e6ba64ad0>[]) – Device to perform computations on

  • dt (float) – Time step duration in seconds

  • 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)[source]

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

compute_smoothness_metrics(metrics, num_bodies, window_sec=None)[source]

Compute smoothness metrics from collected motion data using sliding windows.

Parameters:
  • metrics (Dict[str, MotionMetrics]) – Dictionary of collected MotionMetrics

  • num_bodies (int) – Number of rigid bodies in the robot

  • window_sec (float | None) – Window size in seconds (uses default if None)

Returns:

Dictionary of smoothness metrics for logging

Return type:

Dict[str, float]