wpilibsuite / allwpilib

Official Repository of WPILibJ and WPILibC
https://wpilib.org/
Other
1.05k stars 612 forks source link

[epilogue] Allow logging period to be configurable #6883

Closed SamCarlberg closed 3 weeks ago

SamCarlberg commented 1 month ago

Is your feature request related to a problem? Please describe.

Epilogue's generated bind method will always log data offset by a half phase from the main robot loop (ie for a 20ms loop, logging is run at 20ms at a 10ms offset). This helps spread load out instead of spiking all at once, but can lead to imprecise logs since slightly different data may be logged than what is used by control loops.

Describe the solution you'd like

Add a time offset option to the EpilogueConfiguration class that can be configured at startup. To keep the default behavior of half a loop cycle, a default value of null for this option would make sense, since robot loop times can be configured and aren't guaranteed to be the 20ms default.

For example:

public Robot() {
  Epilogue.configure(config -> {
    config.loggingPeriodOffset = Milliseconds.zero(); // Logs at the same time as each main loop run
    config.loggingPeriodOffset = Milliseconds.of(5); // Logs 5ms after each main loop run
  });
  Epilogue.bind(this);
}
spacey-sooty commented 1 month ago

Would we also want to the option to log at faster than the main loop? For example


public Robot() {
    Epilogue.configure(config -> {
        config.loggingPeriod = Milliseconds.of(10); // Logs at 10ms
    }
    Epilogue.bind(this);
}