Skip to content

SysId & Continuous Tuning

PID controllers are powerful, but they are reactive. To achieve truly championship-grade motion, you need Feedforward—the ability to predict the voltage required to achieve a target velocity. MARSLib provides a specialized SysId suite to calculate these constants automatically.

MARSLib uses the standard WPILib-style Feedforward model:

  • kS (Static): The voltage required to overcome static friction and just start the motor moving.
  • kV (Velocity): The voltage required to maintain a steady state velocity (proportional to speed).
  • kA (Acceleration): The voltage required to change velocity (proportional to acceleration).

For one-time characterization, use the SysIdRoutine command. This will execute the “Quasistatic” and “Dynamic” ramps required for the SysId analysis tool.

  • Quasistatic: The motor voltage slowly ramps up linearly. This isolates the kV and kS values.
  • Dynamic: The motor is blasted with full voltage. This isolates the kA (inertia) value.
// Command-based SysId implementation
public Command getSysIdCommand() {
return new SysIdRoutine(
new Config(),
new Mechanism(
(volts) -> m_drive.setVoltage(volts),
null, // No logging needed, handled by @AutoLog
this
)
).quasistatic(Direction.kForward);
}

Static System Identification (running specific “quasistatic” tests in the pits) is the industry standard. However, mechanism friction changes as the robot’s gears wear down or get dirty throughout a 3-day competition. MARSLib introduces Continuous SysId, which passively identifies your kV and kA constants during real matches.

Because every motor voltage and velocity is logged at high frequency through AdvantageKit, we don’t need dedicated tests. The MARSSysIdManager runs an Ordinary Least Squares (OLS) regression against the log data every time the robot is disabled.

To enable passive characterization, you must register your subsystem’s IO with the manager.

// Inside RobotContainer.java
SysIdManager.getInstance().registerMechanism(
"Shooter",
flywheel::getVoltage,
flywheel::getVelocityRadPerSec
);

The calculated kV (Volts per Unit/s) and kA (Volts per Unit/s²) are pushed to NetworkTables. If the passively identified kV differs from your hardcoded constant by more than 15%, a Fault Alert will trigger, notifying the pit crew that a mechanism is experiencing unexpected friction.