Project 2: A Drivetrain That Survives a Whole Match
A fast robot that browns out mid-match is slower than a smooth one that never quits. This project hardens your drivetrain against the two most common failure modes: jerky acceleration that wears drivers out, and current spikes that drop system voltage and disable the robot.
Step 1 — Smooth the inputs with a slew rate limiter. A SlewRateLimiter caps how fast a value can change, in units per second. Construct one per axis (the filter has memory, so each input stream needs its own instance).
import edu.wpi.first.math.filter.SlewRateLimiter;
// 3.0 means "full stick (0->1) takes 1/3 second"private final SlewRateLimiter xLimiter = new SlewRateLimiter(3.0);private final SlewRateLimiter yLimiter = new SlewRateLimiter(3.0);private final SlewRateLimiter rotLimiter = new SlewRateLimiter(3.0);
public void driveFieldRelative(double x, double y, double rot) { x = xLimiter.calculate(x); y = yLimiter.calculate(y); rot = rotLimiter.calculate(rot); // ... feed to kinematics / drive ...}The WPILib docs show the same pattern (drivetrain.arcadeDrive(filter.calculate(forward), turn)). Higher numbers = snappier; lower = gentler. WPILib notes slew limiting is especially handy for robots that are very top-heavy or that have very powerful drives, but gives no fixed numeric range — tune the value empirically for your robot. Tune on the practice field by feel.
Step 2 — Cap current at the motor controllers. Brownouts happen when transient current spikes drop the battery below the roboRIO threshold (6.3 V on roboRIO 1; 6.75 V default Stage-2 on roboRIO 2, which is software-settable), which disables all actuators. The fix is a smart current limit on each drive motor. On a REV SPARK MAX driving a NEO:
import com.revrobotics.spark.config.SparkMaxConfig;
SparkMaxConfig cfg = new SparkMaxConfig();cfg.smartCurrentLimit(40); // 40 A is a common, safe drivetrain limitmotor.configure(cfg, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters);A 40–50 A limit is a common community sweet spot: responsive enough that drivers don’t notice it, but it keeps the robot out of brownout. (On CTRE TalonFX, the equivalent is a CurrentLimitsConfigs stator/supply limit.) Remember the battery is a single 12 V 18 Ah SLA (the MK ES17-12 is one common, legal example part); under hard driving four unlimited drive motors plus a mechanism can demand far more transient current than the battery can supply without sagging, which is exactly what triggers a brownout.
Step 3 — Verify. Open the Driver Station charts and watch battery voltage during a hard acceleration test. Before limits, you may see deep dips toward the brownout floor; after limits, voltage should stay comfortably higher under the same driving. Drive a full match’s worth (REBUILT is a 20-second auto plus a 2:20 teleop, about 2:40 total) of aggressive sprints and stops on one battery; if it never disables and the battery still reads healthy, you’re match-ready.
Key takeaways
Section titled “Key takeaways”- SlewRateLimiter(rate) caps change in units/sec; 3.0 means full stick takes ~1/3 second. Use one instance per axis.
- Set SPARK MAX smartCurrentLimit to ~40A on drive motors to prevent brownouts (roboRIO disables at 6.3V / 6.75V).
- Verify on the Driver Station voltage chart: under hard driving, voltage should stay well above the brownout floor.
This lesson was adapted from learnfrc.com.
