Programming MAXSwerve

MAXSwerve Code Templates

Below are two GitHub Repositories for template projects that will control an FRC swerve drivetrain built with REV MAXSwerve Modules.

Note that this is meant to be used with a drivetrain composed of four MAXSwerve Modules, each configured with two SPARK MAXs, a NEO as the driving motor, a NEO 550 as the steering motor, and a REV Through Bore Encoder as the absolute turning encoder.

Adjusting Slew Rate Parameters

Within the Constants file for both the Java and C++ MAXSwerve Templates, there are three variables that your team can tune for your robot's Slew Rate needs. To determine the default values we loaded a test MAXSwerve Drivetrain to approximately 140lbs (Including bumpers and battery) and tuned the parameters until we found values that made the MAXSwerve Wheels last the longest amount of time.


DirectionSlewRate is the most important parameter for reducing MAXSwerve Wheel failures. Lower values limit the rate of change of the direction of the robot. This avoids high-speed J turns that put destructive side loads on the wheels. Note that direction changes faster than the slew rate are allowed at lower speeds. The value here is the slew rate at 100% linear speed.


The MagnitudeSlewRate, or acceleration, in the linear direction. Generally, adjustments to the direction slew rate should be applied here as well (i.e. both should be increased or both should be reduced).


RotationalSlewRate is not a major contributor to wheel wear but may help smooth other motions out. If the robot has to do a lot of spinning due to defense or a particular style of mechanism, reducing this could help reduce tread wear.

// Driving Parameters - Note that these are not the maximum capable speeds of
// the robot, rather the allowed maximum speeds

public static final double kMaxSpeedMetersPerSecond = 4.8;
public static final double kMaxAngularSpeed = 2 * Math.PI; // radians per second

public static final double kDirectionSlewRate = 1.2; // radians per second
public static final double kMagnitudeSlewRate = 1.8; // percent per second (1 = 100%)
public static final double kRotationalSlewRate = 2.0; // percent per second (1 = 100%)

MAXSwerve Template Changelog:


  • Added a configurable rate limiting system to prevent excessive loads from causing premature wheel failure.

Last updated