From d3fcf6ba820e00c8298f09733fb51fea3e8ecd46 Mon Sep 17 00:00:00 2001 From: GriffinEC2 <127626522+GriffinEC2@users.noreply.github.com> Date: Sat, 21 Sep 2024 17:02:44 -0700 Subject: [PATCH] add GeneralUtil class --- .../frc/robot/subsystems/drive/Drive.java | 5 +++- src/main/java/frc/robot/util/GeneralUtil.java | 24 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/main/java/frc/robot/util/GeneralUtil.java diff --git a/src/main/java/frc/robot/subsystems/drive/Drive.java b/src/main/java/frc/robot/subsystems/drive/Drive.java index 8e9d130..1ab97a4 100644 --- a/src/main/java/frc/robot/subsystems/drive/Drive.java +++ b/src/main/java/frc/robot/subsystems/drive/Drive.java @@ -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; @@ -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() { diff --git a/src/main/java/frc/robot/util/GeneralUtil.java b/src/main/java/frc/robot/util/GeneralUtil.java new file mode 100644 index 0000000..8c71c36 --- /dev/null +++ b/src/main/java/frc/robot/util/GeneralUtil.java @@ -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"); + } +}