Unit 7: Advanced FRC Coding
AdvantageKit is an advanced logging framework that acts like a "black box" flight recorder for our robot. It records nearly every piece of data—motor outputs, sensor inputs, joystick commands, and more—allowing us to replay a match and diagnose complex issues with perfect clarity.
On our team, we don't guess—we use data. AdvantageKit is the tool that provides this data. It's the key to solving intermittent, match-specific bugs that are impossible to reproduce in the shop. It allows us to make data-driven decisions to improve robot performance and is a fundamental part of our engineering process.
This is the core of the framework. The `Logger` runs on the robot and automatically captures data every 20ms, saving it to a `.wpilog` file. It's incredibly efficient and can record thousands of data points without slowing the robot down.
To make logging effortless, we structure our subsystems using a "Logged I/O" pattern. We create a special inner class or interface (usually called `IO`) that contains all the raw inputs (from sensors) and outputs (to motors). AdvantageKit automatically logs every field in this interface.
public class IntakeSubsystem extends SubsystemBase {
// This special interface defines everything that will be logged.
public interface IO {
@Log
public default void setVoltage(double volts) {}
@Log
public default double getAppliedVoltage() { return 0; }
@Log
public default boolean getBeamBreakSensorTripped() { return false; }
}
private final IO m_io;
// ... in periodic() ...
// Now we use the methods from our IO interface
m_io.setVoltage(targetVoltage);
boolean hasNote = m_io.getBeamBreakSensorTripped();
}
With this structure, the voltage of our intake motor and the state of our sensor are automatically logged on every robot cycle without any extra code in the subsystem itself!
After a match, we download the `.wpilog` file and open it in AdvantageScope, a desktop application that brings the data to life. It allows us to scrub the timeline of a match, create graphs overlaying any variable, and visualize the robot's movement on the field based on its logged odometry.
Question: An autonomous routine mysteriously fails, but only during one specific match. What is the most effective way to diagnose this intermittent issue?