Logging
I am starting this documentation to track the though process of how we want logging to be done on the robot.
Resources: - FRC Team 6328 - Mechanical Advantage's presentation on logging at Champ's 2023 - AdvantageKit - Further examples of how to use that are listed in the README of this repo - AdvantageScope - Log viewer for both WPILib logs as well as AdvantageKit logs - WPILib Datalog documentation
Starting off, I think it is essential to get the basics of "Level 2" logging down before even attempting AdvantageKit. While it is a nice goal to have, it is definitely more of an offseason type of code-revamp. WPILib logging is much more attainable and most likely doable this season.
Importance of logging
Logging can provide so many benefits to the team: - Driver feedback during the match - Code crash investigation/debugging - Tuning PID loops - Re-creating a match timeline of events
WPILib Logging
The following summarizations come from here.
DataLogManageris a wrapper class around theDataLogWPILib class.- All Logging file I/O is handled is a thread separate to robot code.
- "Log files are initially named
FRC_TBD_{random}.wpiloguntil the DS connects. After the DS connects, the log file is renamed toFRC_yyyyMMdd_HHmmss.wpilog(where the date/time is UTC). If the FMS is connected and provides a match number, the log file is renamed toFRC_yyyyMMdd_HHmmss_{event}_{match}.wpilog." - USB flash drives need to be formatted as FAT32 to work with the roboRIO.
- Logging can be started very simply:
This can be put in RobotContainer's constructor or even better (because it happens sooner)
robotInit(). Future Mark here: This really doesn't provide any advantage, because RobotContainer gets defined first thing inrobotInit()anyway. So to keep theRobot.javaclass clean, just put it in RobotContainer. DataLogManager.log()can be used as a replacement toSystem.out.println(). It places the messages both in themessagesentry in the log as well as printing to DriverStation like normal.- By default, DataLogManager does not record joystick data. This can be started by performing the following: I'm unsure of what the difference in the statements above really mean as of right now.
Sendables
Sendable is a java interface which many WPILib classes implement. Because of this, instead of pushing specific values, a class that implements sendable can push the whole class and all values at once.
For example:
Unlike printing a value, Sendables only need to be sent to the dashboard once for their values to continually update