88
99import static edu .wpi .first .units .Units .Seconds ;
1010
11+ import org .frc6423 .lib .drivers .CommandRobot ;
12+ import org .frc6423 .lib .utilities .Tracer ;
13+ import org .frc6423 .robot .Constants .Flags ;
14+
15+ import edu .wpi .first .epilogue .Epilogue ;
16+ import edu .wpi .first .epilogue .Logged ;
17+ import edu .wpi .first .epilogue .logging .LazyBackend ;
18+ import edu .wpi .first .epilogue .logging .NTEpilogueBackend ;
19+ import edu .wpi .first .epilogue .logging .errors .ErrorHandler ;
20+ import edu .wpi .first .networktables .NetworkTableInstance ;
1121import edu .wpi .first .wpilibj .Alert ;
1222import edu .wpi .first .wpilibj .Alert .AlertType ;
23+ import edu .wpi .first .wpilibj .DataLogManager ;
1324import edu .wpi .first .wpilibj .DriverStation ;
1425import edu .wpi .first .wpilibj .RobotController ;
1526import edu .wpi .first .wpilibj .XboxController ;
1627import edu .wpi .first .wpilibj .smartdashboard .SmartDashboard ;
1728import edu .wpi .first .wpilibj2 .command .Command ;
1829import edu .wpi .first .wpilibj2 .command .Commands ;
19- import org .frc6423 .lib .drivers .CommandRobot ;
20- import org .frc6423 .lib .utilities .Tracer ;
21- import org .frc6423 .monologue .Logged ;
22- import org .frc6423 .monologue .Monologue ;
23- import org .frc6423 .monologue .Monologue .MonologueConfig ;
24- import org .frc6423 .robot .Constants .Flags ;
2530
2631/**
2732 * Declares the structure of the robot program (subsystems, commands, triggers, etc.).
2833 *
2934 * <p>Only scheduler calls are allowed in the {@link Robot} periodic method. Very little logic
3035 * should be defined in it.
3136 */
32- public class Robot extends CommandRobot implements Logged {
37+ @ Logged
38+ public class Robot extends CommandRobot {
3339 // * IO INIT
3440 private final XboxController driverController = new XboxController (0 );
3541 private final XboxController operatorController = new XboxController (1 );
@@ -52,31 +58,38 @@ public Robot() {
5258 // Prevent driverstation from clogging output
5359 DriverStation .silenceJoystickConnectionWarning (true );
5460
55- // Initialize Monologue
56- Monologue .setupMonologue (
57- this ,
58- "/Robot" ,
59- new MonologueConfig ()
60- .withAllowNonFinalLoggedFields (true )
61- .withDatalogPrefix ("Telemetry" )
62- .withLazyLogging (true )
63- .withOptimizeBandwidth (DriverStation ::isFMSAttached )
64- .withThrowOnWarning (false ));
65-
66- // Log build data to datalog
67- final String meta = "/BuildData/" ;
68- Monologue .log (meta + "RuntimeType" , getRuntimeType ().toString ());
69- Monologue .log (meta + "ProjectName" , BuildConstants .MAVEN_NAME );
70- Monologue .log (meta + "Version" , BuildConstants .VERSION );
71- Monologue .log (meta + "BuildDate" , BuildConstants .BUILD_DATE );
72- Monologue .log (meta + "GitDirty" , String .valueOf (BuildConstants .DIRTY ));
73- Monologue .log (meta + "GitSHA" , BuildConstants .GIT_SHA );
74- Monologue .log (meta + "GitDate" , BuildConstants .GIT_DATE );
75- Monologue .log (meta + "GitBranch" , BuildConstants .GIT_BRANCH );
76-
77- // Update and trace monologue periodically
78- addPeriodic (
79- () -> Tracer .traceFunc ("Monologue" , Monologue ::updateAll ), Flags .LOOPTIME .in (Seconds ));
61+ // Initialize Epilogue
62+ Epilogue .configure (
63+ config -> {
64+ // Set root data path
65+ config .root = "Telemetry" ;
66+
67+ // Mirror NT logged data to log file
68+ DataLogManager .start ();
69+ // Lazy log to NT
70+ config .backend =
71+ new LazyBackend (new NTEpilogueBackend (NetworkTableInstance .getDefault ()));
72+
73+ // Log build data to datalog
74+ final String meta = "/BuildData/" ;
75+ config .backend .log (meta + "RuntimeType" , getRuntimeType ().toString ());
76+ config .backend .log (meta + "ProjectName" , BuildConstants .MAVEN_NAME );
77+ config .backend .log (meta + "Version" , BuildConstants .VERSION );
78+ config .backend .log (meta + "BuildDate" , BuildConstants .BUILD_DATE );
79+ config .backend .log (meta + "GitDirty" , String .valueOf (BuildConstants .DIRTY ));
80+ config .backend .log (meta + "GitSHA" , BuildConstants .GIT_SHA );
81+ config .backend .log (meta + "GitDate" , BuildConstants .GIT_DATE );
82+ config .backend .log (meta + "GitBranch" , BuildConstants .GIT_BRANCH );
83+
84+ // crash sim on epilogue error
85+ if (isSimulation ()) {
86+ config .errorHandler = ErrorHandler .crashOnError ();
87+ }
88+
89+ // Log everything
90+ config .minimumImportance = Logged .Importance .DEBUG ;
91+ });
92+ Epilogue .bind (this );
8093
8194 // Update drive dashboard periodically
8295 addPeriodic (this ::updateDashboard , 0.02 );
0 commit comments