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. Tall or top-heavy robots benefit from values around 2.0–4.0; very low robots can run higher. 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 limit
motor.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 the standard 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
- 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.
Lesson quiz
RequiredAnswer all 3 questions correctly to complete this lesson.
01.What is the brownout threshold on a roboRIO 1, below which it disables all actuator outputs?
02.For a SlewRateLimiter constructed with a rate of 3.0, what does that value mean for the input it filters?
03.How does the project stop drive-motor current spikes from browning out the robot?
Answer every question to submit.
All 34 lessons in Drive Team
- Not started:Project 1: A Production-Ready Driver Control Scheme
- Not started:Project 2: A Drivetrain That Survives a Whole Match
- Not started:Project 3: Build a Paper + Spreadsheet Scouting System
- Not started:Project 4: Pull Live OPR & EPA Data with Python
- Not started:Project 5: The One-Page Pre-Match Strategy Brief