-
Notifications
You must be signed in to change notification settings - Fork 615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[epilogue] Allow configuring logging period and logging period offset #6893
[epilogue] Allow configuring logging period and logging period offset #6893
Conversation
/format |
dc9a788
to
b0e7ca1
Compare
@SamCarlberg Can you review? |
b0e7ca1
to
608bc7c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be wrong, but I think the original issue said that for the offset, null
should be the default value, which is interpreted as "half of whatever the logging period is" (since that isn't guaranteed to be 20ms). It'd probably also make sense to make the logging period have a default value of null
that is interpreted as "whatever the robot period is" (since that isn't guaranteed to be 20ms).
The reason I avoided making it null by default was that we would need to do an extra check on if the value is null before applying the default value. By doing this we make it a no cost operation for most cases and then have then leave it up to the user to configure it if they are running at a different speed (which if they are doing are probably already an advanced user). |
This is a premature optimization; null checks are already very fast
The issue only specified a configurable offset to keep logging at the same frequency as the main robot loop. Making the default value public Robot() {
super(0.01); // 100Hz update rate
Epilogue.configure(config -> {
// No configuration: logging at 50hz intervals and coincide with every second main loop iteration
});
Epilogue.configure(config -> {
// Both of these are required to be set in order to keep logging in sync and with the default behavior
config.loggingPeriod = Milliseconds.of(10);
config.loggingPeriodOffset = Milliseconds.of(5);
});
} versus: public Robot() {
super(0.01);
Epilogue.configure(config -> {
// No configuration: logs at 100Hz, offset by 5ms from the main loop
});
Epilogue.configure(config -> {
// Configure the offset: still log at 100Hz, but synchronized with the main robot loop
// This comes at the cost of higher CPU load
config.loggingPeriodOffset = Milliseconds.zero();
});
} If users really want custom logging periods, they can add a periodic callback themselves without using public Robot() {
super(0.01);
addPeriodic(
() -> {
Epilogue.robotLogger.tryUpdate(
Epilogue.getConfig().dataLogger.getSubLogger(Epilogue.getConfig().root),
this,
Epilogue.getConfig().errorHandler
)
},
loggingPeriod,
loggingPeriodOffset
);
} (As an aside, generating a |
608bc7c
to
ff7590f
Compare
I am aware but adding a loggingPeriod seemed like a good addition to me as well. |
ff7590f
to
f3596e7
Compare
epilogue-processor/src/main/java/edu/wpi/first/epilogue/processor/EpilogueGenerator.java
Outdated
Show resolved
Hide resolved
epilogue-processor/src/main/java/edu/wpi/first/epilogue/processor/EpilogueGenerator.java
Outdated
Show resolved
Hide resolved
f3596e7
to
0b20370
Compare
59ef766
to
4d7d9f1
Compare
4d7d9f1
to
f8895fe
Compare
972756b
to
26d2a0b
Compare
54c0a09
to
97b9794
Compare
epilogue-processor/src/main/java/edu/wpi/first/epilogue/processor/EpilogueGenerator.java
Show resolved
Hide resolved
epilogue-processor/src/main/java/edu/wpi/first/epilogue/processor/EpilogueGenerator.java
Outdated
Show resolved
Hide resolved
epilogue-runtime/src/main/java/edu/wpi/first/epilogue/EpilogueConfiguration.java
Outdated
Show resolved
Hide resolved
29561d9
to
e1004fe
Compare
Wow, spotbugs is dumber than I remembered it being. You actually do need to disable the spotbugs warnings on the two fields since it doesn't detect usages in examples |
Example number infinity of why spotbugs is stupid and this warning should be suppressed 🙂 |
We can suppress it locally via styleguide/spotbugs-exclude.xml. Suppressing it globally isn't ideal because it has caught valid issues before. |
eeb7d44
to
89c64a9
Compare
8483162
to
0234b17
Compare
0234b17
to
80bb082
Compare
Resolves #6883