Unit 7: Advanced FRC Coding
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.
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.
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.
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.
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.
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);
Question: What is the primary purpose of the SysId tool?