Skip to main content
Play back a recorded trajectory, driving joint positions from recorded frames. Accepts output from useTrajectoryRecorder directly, or raw qpos arrays.

Signature

Usage

Record and Replay

Record a trajectory with useTrajectoryRecorder, then play it back directly — no format conversion needed:

Options

Return Value

State Machine

Playback Modes

Kinematic (default)

Pauses the simulation and writes qpos directly from the trajectory, calling mj_forward to update positions for rendering. No physics stepping occurs. The simulation resumes when playback completes or reset() is called.

Physics

Keeps the simulation running and applies ctrl values from the trajectory each physics step via useBeforePhysicsStep. Frame advancement is based on simulation time (data.time) rather than wall-clock time. Use this mode to replay recorded control inputs through the physics engine, which is useful for comparing recorded vs. simulated behavior. Requires trajectory frames with ctrl data (use useTrajectoryRecorder with fields: ["qpos", "ctrl"]).

Notes

  • In kinematic mode, the simulation’s previous pause state is restored on reset() or completion
  • The trajectory input accepts both TrajectoryFrame[] and number[][] — format is auto-detected
  • For a declarative component API, see <TrajectoryPlayer>