Last year, 6328 introduced our AdvantageKit logging framework as part of our #OpenAlliance efforts. Whether you’ve never heard of AdvantageKit or are already using it yourself (thank you ), we have some exciting updates to share. Feel free to skip to “What’s New For 2023?” if you’re already familiar with AdvantageKit and log replay.
What is AdvantageKit?
Most logging frameworks in FRC (like WPILib’s built-in data logging) are designed to record a limited number of fields that are explicitly logged by the robot code. AdvantageKit goes beyond this traditional approach by recording all of the data flowing into the robot code, not just its outputs. By isolating hardware interaction in subsystems, log data can be replayed in simulation. Forgot to log a field? Run a replay and inspect the code more closely. Want to retune an odometry pipeline? Run a replay and see how it would have affected your last match. Input capture and log replay completely redefine the types of problems logging can solve.
Does this feel a little abstract? Let’s look at an example. Below is some log data from 6328’s 2022 robot, showing the flywheel setpoint during a match. It’s set automatically based on the distance to the target, but it seems we forgot to log the measured distance . So how can we check that the calculation is working?
Let’s just log the new data with this call…
Logger.getInstance().recordOutput("TargetDistanceMeters", latestPose.getTranslation().getDistance(FieldConstants.hubCenter));
…run the code in replay…
…and enjoy our newly logged data:
We can confirm that the flywheel setpoint is increasing along with distance, so the calculation is working correctly. Using replay, we’re able to make that conclusion with complete certainty even though we’re using data that was never logged by the robot on the field.
Below are just a few more examples of how we’ve used log replay in the 2022 season. Solving any one of these issues would likely have taken multiple hours of testing on the real robot, but log replay took care of them with almost no time required for testing.
-
While working between shop meetings, we were able to debug a subtle issue with the code’s vision pipeline by recording extra outputs from a log saved from a previous testing session. More details here.
-
During an event, we retuned our odometry pipeline to more aggressively adjust based on vision data (tuning that requires a normal match environment with other robots). We tested the change using replay and deployed it in the next match, and saw much more reliable odometry data for the remainder of the event. More details here.
-
After an event, we determined that our hood was not zeroing currently during match conditions. This involved replaying the matches with a manually adjusted hood position and comparing the quality of the vision data processed with different angles (the robot’s Limelight was mounted to the hood). More details here.
For more detailed examples of AdvantageKit in action, check out the “What is AdvantageKit?” page in the documentation.
What’s New For 2023?
We’ve introduced a variety of new features for AdvantageKit’s 2023 update. Here are some of the most important changes:
- WPILOG and NT4 have replaced our old RLOG format for logging and live data streaming, allowing AdvantageKit to interface with WPILib tools like Glass and Sapphire. AdvantageScope’s 2023 update adds support for WPILOG and NT4 (link at the end of this post).
- Console output (STDOUT and STDERR) is now captured automatically by AdvantageKit, and can be displayed in AdvantageScope’s new console view.
- The
@AutoLog
annotation automatically defines thetoLog
andfromLog
methods for subsystem inputs, reducing the amount of boilerplate code. - New methods allow for convenient output logging of WPILib classes like
Pose2d
,Pose3d
, andSwerveModuleState
. - More fields and customizability has been added to the built-in system stats and power distribution logging.
- Example projects are now provided with each AdvantageKit release: a skeleton project with just the basics, and a command-based example project with multiple subsystems.
The first 2023 beta of AdvantageKit has now been released. For information on getting started, check out the AdvantageKit documentation. We would welcome community feedback, questions, and suggestions as we continue our development effort.
We also just released the 2023 beta of AdvantageScope, our data visualization tool! More details here.
-Jonah