Skip to content
learnFRC.org
programmingreference

Motion Profiling & Motion Magic

Generating smooth kinematic trajectories with bounded velocity, acceleration, and jerk to protect robot mechanisms.

When an elevator is commanded to step from 0 inches to 40 inches instantaneously, an unprofiled PID controller responds to the large step error by commanding maximum output voltage (12V). This causes wheel slip, mechanical shock, and potential mechanism damage.

Motion Profiling replaces instantaneous setpoint jumps with a physically achievable continuous trajectory of position x(t)x(t), velocity v(t)v(t), and acceleration a(t)a(t).


A trapezoidal profile divides movement into three phases:

  1. Constant Acceleration Phase: Accelerates at maximum acceleration a_max until reaching cruise velocity v_cruise.
  2. Cruise Velocity Phase: Travels at steady speed v_cruise.
  3. Constant Deceleration Phase: Decelerates at -a_max to bring velocity to exactly 0 at the destination.
Velocity
^
| ___________________ (Cruise Velocity)
| / \
| / \
| / \
| / \
+---+---------------------------+---> Time
| Accel | Cruise | Decel |

CTRE Motion Magic vs. WPILib ProfiledPIDController

Section titled “CTRE Motion Magic vs. WPILib ProfiledPIDController”
FeatureCTRE Phoenix 6 Motion MagicWPILib ProfiledPIDController
Execution Rate1,000 Hz (1 kHz onboard Talon FX)50 Hz (roboRIO loop cycle)
LatencyZero CAN bus communication latency20 ms roboRIO cycle latency
Jerk LimitingBuilt-in S-Curve Jerk parameter (j_max)Standard Trapezoid only
Setup in CodeMotionMagicVoltage control requestJava ProfiledPIDController object
TalonFXConfiguration config = new TalonFXConfiguration();
// Motion Magic parameters
config.MotionMagic.MotionMagicCruiseVelocity = 80.0; // rotations/sec
config.MotionMagic.MotionMagicAcceleration = 160.0; // rotations/sec²
config.MotionMagic.MotionMagicJerk = 1600.0; // rotations/sec³ (smooth S-curve)
// Closed-loop Slot 0 gains
config.Slot0.kP = 4.8;
config.Slot0.kD = 0.15;
config.Slot0.kV = 0.12;
config.Slot0.kS = 0.20;
m_motor.getConfigurator().apply(config);
Why S-Curve Jerk Matters

Jerk is the derivative of acceleration (da/dt). Limiting jerk smooths the sharp transitions at the corners of trapezoidal velocity curves, preventing chain lash and gearbox shock.

Verified Sources & Standards

Evergreen Standard Verified: Sep 24, 2026