SysId Tool Lesson

The SysId Tool: Engineering Over Guesswork

SysId (System Identification) is a powerful WPILib tool that automates the process of creating a precise mathematical model of our robot's mechanisms. It's the key to moving from basic control to championship-level predictive control.

The Problem: Why Guessing Gains Isn't Good Enough

To make a mechanism like a shooter or a drivetrain perform at its absolute limit, we need to use a Feedforward controller. This controller predicts the exact voltage needed to achieve a target speed. To do this, it needs a few "magic numbers" (gains) that describe the mechanism's physics: `kS` (static friction), `kV` (velocity), and `kA` (acceleration).

Manually tuning these values is extremely difficult. SysId finds them for us automatically and with scientific precision.

How SysId Works: The Characterization Process

System Identification, or "characterization," is the process of running a series of automated tests on a robot mechanism to gather data about its physical properties.

1. Running the Tests

We deploy a special, temporary SysId project to the robot. Then, using the SysId GUI on a laptop, we command the robot to run automated tests that measure how the mechanism responds to different voltages.

  • Quasistatic Test: Slowly ramps voltage up and down to measure the voltage needed to hold various speeds (finds `kS` and `kV`).
  • Dynamic Test: Applies sudden bursts of voltage to measure how the mechanism accelerates (finds `kA`).

2. Analyzing the Data

SysId logs all the test data (voltage, velocity, position) to a file. We then load this file into the SysId Analyzer tool. The analyzer runs a mathematical regression on the data to calculate the precise feedforward gains (`kS`, `kV`, `kA`) that best fit the real-world measurements.

3. Using the Gains in Our Code

The final step is to copy the calculated gains from the analyzer into our `Constants.java` file. These constants are then used to create `SimpleMotorFeedforward` and `PIDController` objects in our subsystems, giving us incredibly accurate and predictive control.

// In a subsystem, like a shooter:

// Gains are taken directly from the SysId Analyzer
public static final double kS = 0.1; // Volts
public static final double kV = 0.05; // Volts * seconds / meters
public static final double kA = 0.01; // Volts * seconds^2 / meters

private final SimpleMotorFeedforward m_feedforward = new SimpleMotorFeedforward(kS, kV, kA);

// When setting a target, we use the feedforward model to predict the required voltage.
double feedforwardVoltage = m_feedforward.calculate(targetVelocity);
m_motor.setVoltage(feedforwardVoltage);
    

Test Your Knowledge

Question: What is the primary purpose of the SysId tool?