Skip to content

Commit

Permalink
add GeneralUtil class
Browse files Browse the repository at this point in the history
  • Loading branch information
GriffinEC2 committed Sep 22, 2024
1 parent b2384ff commit d3fcf6b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/frc/robot/subsystems/drive/Drive.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.util.GeneralUtil;

import java.util.function.Supplier;

public class Drive extends SubsystemBase {
private final DriveIOReal io;
private final DriveIOInputsAutoLogged driveInputs = new DriveIOInputsAutoLogged();

public Drive(DriveIOReal io) {
this.io = io;
Expand All @@ -15,7 +18,7 @@ public void periodic() {
// TODO: Logs
// io.updateInputs(inputs);
// Logger.processInputs("Shooter/Feeder", inputs);
// GeneralUtil.logSubsystem(this, "Shooter/Feeder");
GeneralUtil.logSubsystem(this, "Shooter/Feeder");
}

private void fullStop() {
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/frc/robot/util/GeneralUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package frc.robot.util;

import edu.wpi.first.wpilibj2.command.SubsystemBase;
import org.littletonrobotics.junction.Logger;

public abstract class GeneralUtil {
public static void logSubsystem(SubsystemBase s, String sName) {
String key = sName + "/command";
Logger.recordOutput(
key, s.getCurrentCommand() != null ? s.getCurrentCommand().getName() : "none");
}

public static void logFullSubsystem(SubsystemBase s, String sName) {
sName += "/cmdInfo/";
Logger.recordOutput(sName + "hasDefault", s.getDefaultCommand() != null);
Logger.recordOutput(
sName + "default",
s.getDefaultCommand() != null ? s.getDefaultCommand().getName() : "none");
Logger.recordOutput(sName + "hasCommand", s.getCurrentCommand() != null);
Logger.recordOutput(
sName + "command",
s.getCurrentCommand() != null ? s.getCurrentCommand().getName() : "none");
}
}

0 comments on commit d3fcf6b

Please sign in to comment.