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);
//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
}
public void periodic(){
+ updateInputs();
+
shooterMotorLeft.setControl(voltageRequest.withVelocity(shooterTargetSpeed));
shooterMotorRight.setControl(voltageRequest.withVelocity(shooterTargetSpeed));
feederMotor.set(feederPower);
}
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();
}
}
--- /dev/null
+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();
+}