]> git.taranathan.com Git - FRC2026.git/commitdiff
I learned advantagekit + shooter IO logging
authorWesley28w <wesleycwong@gmail.com>
Sat, 24 Jan 2026 03:27:38 +0000 (19:27 -0800)
committerWesley28w <wesleycwong@gmail.com>
Sat, 24 Jan 2026 03:27:38 +0000 (19:27 -0800)
src/main/java/frc/robot/subsystems/shooter/Shooter.java
src/main/java/frc/robot/subsystems/shooter/ShooterIO.java [new file with mode: 0644]

index c6051c4190c508e9e1b1ac303e1ccf2f58bd1218..01fb039d0567b983d16751d884d954896ad3f476 100644 (file)
@@ -16,8 +16,9 @@ import edu.wpi.first.wpilibj2.command.InstantCommand;
 import edu.wpi.first.wpilibj2.command.SubsystemBase;
 import frc.robot.constants.Constants;
 import frc.robot.constants.IdConstants;
+import frc.robot.subsystems.shooter.ShooterIO.ShooterIOInputs;;
 
-public class Shooter extends SubsystemBase {
+public class Shooter extends SubsystemBase implements ShooterIO {
     
     private TalonFX shooterMotorLeft = new TalonFX(IdConstants.SHOOTER_LEFT_ID, Constants.RIO_CAN);
     private TalonFX shooterMotorRight = new TalonFX(IdConstants.SHOOTER_RIGHT_ID, Constants.RIO_CAN);
@@ -32,6 +33,8 @@ public class Shooter extends SubsystemBase {
     //Velocity in rotations per second
     VelocityVoltage voltageRequest = new VelocityVoltage(0);
 
+    private ShooterIOInputsAutoLogged inputs = new ShooterIOInputsAutoLogged();
+
     public Shooter(){
         TalonFXConfiguration config = new TalonFXConfiguration();
         config.Slot0.kP = 0.2; //tune p value
@@ -63,6 +66,8 @@ public class Shooter extends SubsystemBase {
     }
 
     public void periodic(){
+        updateInputs();
+
         shooterMotorLeft.setControl(voltageRequest.withVelocity(shooterTargetSpeed));
         shooterMotorRight.setControl(voltageRequest.withVelocity(shooterTargetSpeed));
         feederMotor.set(feederPower);
@@ -86,9 +91,19 @@ public class Shooter extends SubsystemBase {
     }
 
     public double getFeederVelocity() {
-        return feederMotor.getVelocity().getValueAsDouble();
+        return inputs.feederVelocity;
     }
+    
     public double getShooterVelcoity() {
-        return shooterMotorLeft.getVelocity().getValueAsDouble();
+        return inputs.leftShooterVelocity; // assuming they are the same rn
+    }
+
+    public void updateInputs() {
+        inputs.leftShooterVelocity = shooterMotorLeft.getVelocity().getValueAsDouble();
+        inputs.rightShooterVelocity = shooterMotorRight.getVelocity().getValueAsDouble();
+        inputs.feederVelocity = feederMotor.getVelocity().getValueAsDouble();
+        inputs.leftShooterCurrent = shooterMotorLeft.getStatorCurrent().getValueAsDouble();
+        inputs.rightShooterVelocity = shooterMotorRight.getStatorCurrent().getValueAsDouble();
+        inputs.feederVelocity = feederMotor.getStatorCurrent().getValueAsDouble();
     }
 }
diff --git a/src/main/java/frc/robot/subsystems/shooter/ShooterIO.java b/src/main/java/frc/robot/subsystems/shooter/ShooterIO.java
new file mode 100644 (file)
index 0000000..00585ff
--- /dev/null
@@ -0,0 +1,17 @@
+package frc.robot.subsystems.shooter;
+
+import org.littletonrobotics.junction.AutoLog;
+
+public interface ShooterIO {
+    @AutoLog
+    public static class ShooterIOInputs {
+        public double rightShooterVelocity = 0;
+        public double leftShooterVelocity = 0;
+        public double feederVelocity = 0;
+        public double rightShooterCurrent = 0;
+        public double leftShooterCurrent = 0;
+        public double feederCurrent = 0;
+    }
+
+    public void updateInputs();
+}