← Labs

Swerve kinematics lab

Predict module directions before changing the controls.

Try it

  1. Predict all four wheel directions for pure forward translation. Select the translation preset.
  2. Predict which modules point where during counterclockwise rotation. Select rotation.
  3. Challenge: choose mixed motion and lower the speed limit. Explain why every wheel is scaled by the same factor. Toggle optimization and explain the negative wheel speeds.

WPILib coordinates: +x is forward, +y is left, and positive rotation is counterclockwise. Angles are measured counterclockwise from +x. The diagram looks down on the robot: forward is up and left is left. This is ideal kinematics only: no slip, steering dynamics, torque limits, or odometry.

Controls

Current angle is shared by all modules for this experiment. Optimization uses the shortest turn within 90°; a negative speed reverses the wheel.

Module states

Module Speed (m/s) Angle (deg)

Arrows show actual velocity after desaturation, including reversed wheel speed. The center of rotation is marked ×.

Model

For module position (x, y) measured from the chosen center of rotation, vᵢ = (vx − ωy, vy + ωx). Field-relative translation is rotated by minus the robot heading into the robot frame. If the fastest module exceeds the speed limit, all speeds are multiplied by the same factor. At zero speed the displayed angle stays at the selected current angle.

WPILib: Chassis speeds and coordinates · WPILib: Swerve drive kinematics