Skip to content
learnFRC.org
programminglesson35 min

SysId System Characterization

Automated mechanism characterization using WPILib SysIdRoutine, data collection protocols, and regression curve analysis for kS, kV, kA, and kG.

What you will learn

  • Instrument robot subsystem classes with the WPILib SysIdRoutine API.
  • Run quasistatic (ramp) and dynamic (step) test routines in forward and reverse directions.
  • Record high-frequency voltage, velocity, and position logs using DataLogManager.
  • Analyze SysId data sets to calculate kS, kV, kA, and kG feedforward parameters with R² > 0.95.

Prerequisites:Physics Simulation & Mechanism Modeling

Tuning feedforward gains by trial and error is tedious and error-prone. If kVk_V is too low, the PID controller must accumulate integral error to overcome steady-state drag. If kAk_A is omitted, the mechanism lags behind fast trapezoidal motion profiles.

WPILib’s SysId (System Identification) tool automates parameter extraction. By applying controlled voltage waveforms and logging position and velocity, SysId fits ordinary least-squares regression lines to calculate the exact physical coefficients of your mechanism.


Before running SysId routines:

  1. Ensure physical mechanism travel limits, limit switches, and hard stops are mechanically secure.
  2. Enable binary flight logging via DataLogManager.start() in Robot.java as covered in Telemetry Logging.

2. Instrumenting Subsystems with SysIdRoutine

Section titled “2. Instrumenting Subsystems with SysIdRoutine”

In your mechanism subsystem (for example, ElevatorSubsystem), declare and configure a SysIdRoutine:

package frc.robot.subsystems;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine;
import edu.wpi.first.units.measure.Voltage;
import static edu.wpi.first.units.Units.*;
import com.ctre.phoenix6.hardware.TalonFX;
import com.ctre.phoenix6.controls.VoltageOut;
public class ElevatorSubsystemWithSysId extends SubsystemBase {
private final TalonFX m_motor = new TalonFX(11, "rio");
private final VoltageOut m_voltReq = new VoltageOut(0.0);
// Create the SysIdRoutine helper
private final SysIdRoutine m_sysIdRoutine = new SysIdRoutine(
new SysIdRoutine.Config(
VoltsPerSecond.of(1.0), // Voltage ramp rate: 1.0 V/s for quasistatic test
Volts.of(7.0), // Step voltage: 7.0 V for dynamic test
Seconds.of(4.0) // Test timeout: 4.0 seconds
),
new SysIdRoutine.Mechanism(
// Voltage consumer: sends commanded voltage to hardware
(Voltage volts) -> m_motor.setControl(m_voltReq.withOutput(volts.in(Volts))),
// Telemetry log callback: records position and velocity
log -> {
log.motor("elevator-motor")
.voltage(Volts.of(m_motor.getMotorVoltage().getValueAsDouble()))
.linearPosition(Meters.of(m_motor.getPosition().getValueAsDouble() * 0.05))
.linearVelocity(MetersPerSecond.of(m_motor.getVelocity().getValueAsDouble() * 0.05));
},
this
)
);
// Expose SysId command factories:
public Command sysIdQuasistatic(SysIdRoutine.Direction direction) {
return m_sysIdRoutine.quasistatic(direction);
}
public Command sysIdDynamic(SysIdRoutine.Direction direction) {
return m_sysIdRoutine.dynamic(direction);
}
}

3. Running the Four Characterization Tests

Section titled “3. Running the Four Characterization Tests”

SysId requires four distinct tests to isolate static friction, velocity drag, and mass acceleration:

  1. Quasistatic Forward:
    • Slowly ramps voltage (1.0 V/s) upward.
    • Measures static friction breakaway (kSk_S) and velocity feedforward (kVk_V).
  2. Quasistatic Reverse:
    • Slowly ramps voltage downward in the opposite direction.
    • Checks directional friction symmetry and isolates gravity bias (kGk_G).
  3. Dynamic Forward:
    • Applies an instantaneous voltage step (e.g., 7.0 V).
    • Measures acceleration feedforward (kAk_A) by capturing the slope of the initial velocity response.
  4. Dynamic Reverse:
    • Applies an instantaneous negative voltage step.
    • Measures reverse acceleration dynamics.
Respect Mechanism Hard Stops

On mechanisms with limited travel (arms and elevators), release the test button before the mechanism reaches its physical travel stop! Hitting hard stops at full voltage will corrupt regression data and risk stripping gearbox teeth.


4. Analyzing Data in the SysId Application

Section titled “4. Analyzing Data in the SysId Application”
  1. Connect laptop to the robot and open the SysId tool from VS Code (WPILib: Start Tool -> SysId).
  2. Click Open Data Log and select the .wpilog file downloaded from /u/logs/.
  3. In the analysis window:
    • Select your mechanism type (Elevator, Arm, or Simple).
    • Inspect the velocity vs. voltage scatter plot.
    • Verify that data points form a linear line. If the plot curves upward, mechanical binding or motor current saturation was reached.
  4. Read the calculated constants:
    • kSk_S: Static friction voltage (typically 0.15 to 0.30 V).
    • kVk_V: Velocity feedforward (typically 0.10 to 0.25 V/(rad/s)).
    • kAk_A: Acceleration feedforward (typically 0.01 to 0.05 V/(rad/s²)).
    • kGk_G: Constant holding voltage against gravity.

  1. Statistical Fit Quality (R2R^2):
    • The linear regression R2R^2 value in the SysId tool must be ≥0.95\ge 0.95. An R2<0.90R^2 < 0.90 indicates excessive mechanical slop, loose sensor couplings, or hitting travel stops during the run.
  2. Feedforward Verification:
    • Command the mechanism to move at a steady velocity using pure feedforward (V = kS * sgn(v) + kV * v + kG).
    • The mechanism must maintain steady velocity within 10%10\% of the target with zero closed-loop PID feedback active.

With measured physical constants in hand, proceed to the final lesson: State-Space Modeling, LQR & Kalman Filters to formulate optimal closed-loop controllers.

Verified Sources & Standards

Evergreen Standard Verified: Sep 25, 2026