-
Notifications
You must be signed in to change notification settings - Fork 0
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
Epliogue Loggers #34
Comments
also did you make this https://github.com/Greater-Rochester-Robotics/GRRBase/blob/main/src/main/java/org/team340/lib/util/Profiler.java off my https://github.com/wpilibsuite/allwpilib/blob/6ea95967906d237e8667e9695eb49914ea5ff0b4/wpilibj/src/main/java/edu/wpi/first/wpilibj/Tracer.java pr cuz ive been using that tracer in my code for over a year now. just kinda funny if we made the same thing independantly. Same thing for Tunable, Alliance, PhoenixUtil etc. Like the template overall. |
I was waiting to test on a real robot to see the performance implications, we only got our CANivores last week, good to know
Pretty sure the behavior you're talking about is essentially the current implementation, unless there's some dumb Java wizardry happening that I'm not aware of. The
I was unaware of your PR when I made that, I think I pulled the implementation from a stray file on my laptop from last season, leftover from when we were trying to debug some loop overruns, it's hard to track though since I've just been force pushing main for the past 4 months 🤪
Tunable was drafted last season with some students, as a replacement for setters in |
great minds think alike fr fr. On the note of the lambda, everything inside the brackets is executed every time the code is ran. You store the function itself but that has no state other than some captures. Due to the fact that ctre caches status signals its not a huge deal, just a few hash lookups to fetch them again but whatever. |
Still not following what you mean, the outer lambda only runs once per device when it is first logged. The cached consumer will not not re-evaluate the variables it captures. cache
.computeIfAbsent(canCoder, key -> {
// This is in the outer lambda, and is ran when the specified key of the
// cache is absent, which is only the case when a device is first logged.
var absolutePosition = canCoder.getAbsolutePosition(false);
var magnetHealth = canCoder.getMagnetHealth(false);
var position = canCoder.getPosition(false);
var velocity = canCoder.getVelocity(false);
BaseStatusSignal[] signals = { absolutePosition, magnetHealth, position, velocity };
// See console output below
System.out.println("Logging CANcoder " + canCoder.getDeviceID());
// This is the consumer saved in the cache, i.e. the code that will run periodically.
// Variables such as "absolutePosition" and "signals" are captured by this lambda,
// and will not be recomputed in future logging cycles.
return b -> {
BaseStatusSignal.refreshAll(signals);
b.log("absolutePosition", absolutePosition.getValueAsDouble());
b.log("magnetHealth", magnetHealth.getValue().name());
b.log("position", position.getValueAsDouble());
b.log("velocity", velocity.getValueAsDouble());
};
})
.accept(backend); produces:
|
I was looking to maybe yoink some stuff and just wanted to callout some things incase u care, feel free to close this if u dont ofc.
CANBus status fetching is a blocking call and will usually take multiple MS, i doubt you really want epilogue calling this.
for your ctre hardware stuff i would recommend doing anonymous implementations for the consumers instead of lambdas to not refetch all the status signals and remake array each time.
The text was updated successfully, but these errors were encountered: