// Docs

Motion trimming

Trim inactive frames from robotics episodes

motion_trim removes inactive frames before and after the motion window of an episode. It uses action and state deltas to infer activity.

pipeline = (
    mdr.read_lerobot("hf://datasets/acme/raw-aloha")
    .map(mdr.robotics.motion_trim(threshold=0.001, pad_frames=2))
    .write_lerobot("hf://buckets/acme-robotics/aloha-trimmed")
)

What it updates

DataBehavior
Frame tableKeeps only selected frame indices.
TimestampsShifts kept timestamps so the trimmed episode starts at zero.
VideosClips video views to the same time span.
Video statsDrops stale video stats so the writer recomputes them.
MetricsLogs frames in/out, removed frames, and trim fraction when launched.

Parameters

ParameterMeaning
thresholdMotion energy threshold for action/state deltas.
pad_framesExtra frames to keep before and after detected motion.
timestamp_keyFrame timestamp key when semantic timestamps are absent.
action_keyFrame action key when semantic actions are absent.
state_keyFrame state key when semantic states are absent.

Requirements

Input rows must implement RoboticsRow and contain non-empty frame data with timestamps, actions, and state values. read_lerobot(...) rows satisfy this when the dataset contains those fields. Generic rows should be converted with to_robot_rows.