Creating fast, repeatable autonomous routines requires striking a balance between speed and wheel traction. Traditional path generators rely on geometric splines with static velocity and acceleration caps. While simple to configure, static limits cannot account for motor torque dropoff at high speed or the fact that a robot cannot accelerate maximally while already cornering hard.
Kinodynamic trajectory optimization solves for the mathematically fastest trajectory that the physical robot can execute without exceeding motor torque limits or breaking carpet traction.
1. What to Learn First
Section titled “1. What to Learn First”Before diving into kinodynamic trajectory optimization:
- Ensure your swerve drivetrain is characterized with accurate wheel radius, gear ratios, and track dimensions as taught in Swerve Configuration.
- Understand WPILib coordinate conventions: +X points downfield away from the driver alliance wall, and +Y points to the left.
2. Geometric Splines vs Kinodynamic Optimization
Section titled “2. Geometric Splines vs Kinodynamic Optimization”Understanding the difference between the two approaches explains why kinodynamic trajectories run noticeably faster without wheel slip:
PathPlanner (Geometric Hermite Spline)
Section titled “PathPlanner (Geometric Hermite Spline)”- Uses cubic or quintic Hermite splines to define the shape of the path.
- Samples velocity and acceleration along the curve based on fixed scalar maximums:
- Max Linear Velocity (e.g., 4.5 m/s)
- Max Linear Acceleration (e.g., 3.5 m/s²)
- Max Angular Velocity (e.g., 6.28 rad/s)
- Limitation: The robot cannot accelerate at 3.5 m/s² while already traveling at 4.0 m/s because the drive motors are operating near their back-EMF limit where available torque approaches zero. A static acceleration limit either underutilizes low-speed torque or commands unreachable high-speed acceleration that causes wheel slip.
Choreo (Numerical Interior-Point Optimization)
Section titled “Choreo (Numerical Interior-Point Optimization)”- Solves a non-linear optimization problem using the interior-point optimizer IPOPT.
- Minimizes total transit time:
minimize T = integral(0 to T) 1 dt- Subject to dynamic equality constraints:
- Chassis Newton-Euler equations:
sum(F_x) = m * a_x,sum(F_y) = m * a_y,sum(tau) = J * alpha - Motor torque-speed curves: available torque
tau(omega) = tau_stall * (1 - omega / omega_free) - Wheel friction circle:
sqrt(F_x^2 + F_y^2) <= mu * F_N
- Chassis Newton-Euler equations:
- Result: The solver commands maximum motor torque when velocity is low, naturally rolls off acceleration as back-EMF rises, and coordinates chassis rotation with translation to prevent saturating wheel traction.
3. Configuring the Robot Model in Choreo
Section titled “3. Configuring the Robot Model in Choreo”To produce valid trajectories, enter exact physical dimensions into the Choreo robot configuration:
- Chassis Mass: Total weighed mass of the robot, including bumpers and battery (e.g., 52.0 kg).
- Moment of Inertia (J_z): Rotational inertia about the vertical axis. A typical 28 in × 28 in FRC robot has
J_z ≈ 4.0 to 6.5 kg·m². - Module Locations: Offsets of the four wheel contact points from the center of mass in meters (e.g.,
(±0.28 m, ±0.28 m)). - Drive Motor Model:
- Motor type:
Kraken X60,NEO, orFalcon 500. - Motor quantity: 1 per module (4 total drive motors).
- Gear ratio: Overall drive reduction (e.g., 6.75:1 for L2 MK4i).
- Wheel radius: Measured rolling radius (e.g., 0.0508 m for 4-inch wheels).
- Motor type:
- Coefficient of Friction (μ):
- Billet wheels with neoprene tread on standard FRC carpet typically exhibit
μ ≈ 1.1 to 1.3. - Setting μ too high (> 1.4) causes the solver to plan violent turns that break traction in practice.
- Billet wheels with neoprene tread on standard FRC carpet typically exhibit
4. Generating and Exporting Trajectories
Section titled “4. Generating and Exporting Trajectories”- In Choreo, place start, intermediate, and end waypoints across the field.
- Add rotational constraints: fix the robot’s heading at scoring positions, but let the solver freely rotate the chassis during transit to align drive wheels with the acceleration vector.
- Click Generate. Choreo runs the IPOPT solver locally, converging on a time-optimal state sequence in 1 to 3 seconds.
- Export the
.trajfile into your robot project’ssrc/main/deploy/choreo/directory.
5. Executing Choreo Trajectories in Java
Section titled “5. Executing Choreo Trajectories in Java”PathPlannerLib includes native support for loading and following Choreo trajectories using the same AutoBuilder pipeline:
package frc.robot.commands;
import com.pathplanner.lib.auto.AutoBuilder;import com.pathplanner.lib.path.PathPlannerPath;import edu.wpi.first.wpilibj2.command.Command;import edu.wpi.first.wpilibj2.command.Commands;import frc.robot.subsystems.SwerveSubsystem;
public class AutonomousRoutines { /** * Loads a pre-optimized Choreo trajectory and constructs a follow command. */ public static Command getChoreoAutoCommand(SwerveSubsystem swerve, String trajName) { try { // Load pre-computed kinodynamic trajectory from deploy/choreo/<trajName>.traj PathPlannerPath path = PathPlannerPath.fromChoreoTrajectory(trajName);
// AutoBuilder follows the trajectory using onboard pose estimation return AutoBuilder.followPath(path); } catch (Exception e) { // Fallback command in case trajectory file is missing return Commands.print("[ERROR] Failed to load Choreo trajectory: " + trajName); } }}Because swerve drivetrains are holonomic, Choreo can rotate the robot 180 degrees to face an intake while translating sideways toward a game piece. Always leave heading unconstrained at intermediate waypoints so the optimizer can find the fastest wheel vectors.
How Success is Checked
Section titled “How Success is Checked”- Solver Convergence:
- Verify that the Choreo generation indicator shows green (convergence achieved). If red, relax intermediate velocity constraints or increase maximum allowable time steps.
- AdvantageScope Trajectory Overlay:
- In simulation or log replay, compare
Swerve/ActualPoseagainstChoreo/DesiredPose. - Translation tracking error should remain under 0.08 meters across the entire routine.
- Heading tracking error should remain under 2.0 degrees.
- In simulation or log replay, compare
- No Wheel Slip:
- Inspect wheel speed graphs in AdvantageScope. Commanded module speeds must never saturate abruptly against the physical free speed limit.
Where to Go Next
Section titled “Where to Go Next”Now proceed to Dynamic Obstacle Avoidance & On-the-Fly Navigation to generate collision-free paths in real time when unexpected obstacles block pre-planned routes.
Verified Sources & Standards
- Choreo Trajectory Optimization Architecturechoreo.autosCommunity Reference
- PathPlannerLib Choreo Integrationpathplanner.devCommunity Reference