|
|
|
@@ -21,8 +21,8 @@ import frc4388.utility.controller.IHandController;
|
|
|
|
|
|
|
|
|
|
public class Shooter extends SubsystemBase {
|
|
|
|
|
|
|
|
|
|
public WPI_TalonFX m_shooterFalcon = new WPI_TalonFX(ShooterConstants.SHOOTER_FALCON_ID);
|
|
|
|
|
|
|
|
|
|
public WPI_TalonFX m_shooterFalconLeft = new WPI_TalonFX(ShooterConstants.SHOOTER_FALCON_BALLER_ID);
|
|
|
|
|
public WPI_TalonFX m_shooterFalconRight = new WPI_TalonFX(ShooterConstants.SHOOTER_FALCON_BALLER_FOLLOWER_ID);
|
|
|
|
|
public static Gains m_drumShooterGains = ShooterConstants.DRUM_SHOOTER_GAINS;
|
|
|
|
|
public static Shooter m_shooter;
|
|
|
|
|
public static IHandController m_controller;
|
|
|
|
@@ -50,24 +50,42 @@ public class Shooter extends SubsystemBase {
|
|
|
|
|
//SmartDashboard.putNumber("Velocity Target", 10000);
|
|
|
|
|
//SmartDashboard.putNumber("Angle Target", 3);
|
|
|
|
|
|
|
|
|
|
m_shooterFalcon.configFactoryDefault();
|
|
|
|
|
m_shooterFalcon.setNeutralMode(NeutralMode.Coast);
|
|
|
|
|
m_shooterFalcon.setInverted(true);
|
|
|
|
|
m_shooterFalcon.configOpenloopRamp(1, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
m_shooterFalcon.configClosedloopRamp(0.75, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
//LEFT FALCON
|
|
|
|
|
m_shooterFalconLeft.configFactoryDefault();
|
|
|
|
|
m_shooterFalconLeft.setNeutralMode(NeutralMode.Coast);
|
|
|
|
|
m_shooterFalconLeft.setInverted(true);
|
|
|
|
|
m_shooterFalconLeft.configOpenloopRamp(1, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
m_shooterFalconLeft.configClosedloopRamp(0.75, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
//RIGHT FALCON
|
|
|
|
|
m_shooterFalconRight.configFactoryDefault();
|
|
|
|
|
m_shooterFalconRight.setNeutralMode(NeutralMode.Coast);
|
|
|
|
|
m_shooterFalconRight.setInverted(false);
|
|
|
|
|
m_shooterFalconRight.configOpenloopRamp(1, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
m_shooterFalconRight.configClosedloopRamp(0.75, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
setShooterGains();
|
|
|
|
|
|
|
|
|
|
m_shooterFalcon.configPeakOutputReverse(0, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
m_shooterFalcon.setSelectedSensorPosition(0, ShooterConstants.SHOOTER_PID_LOOP_IDX, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
int closedLoopTimeMs = 1;
|
|
|
|
|
m_shooterFalcon.configClosedLoopPeriod(0, closedLoopTimeMs, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
//LEFT FALCON
|
|
|
|
|
m_shooterFalconLeft.configPeakOutputReverse(0, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
m_shooterFalconLeft.setSelectedSensorPosition(0, ShooterConstants.SHOOTER_PID_LOOP_IDX, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
m_shooterFalconLeft.configClosedLoopPeriod(0, closedLoopTimeMs, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
m_shooterFalconLeft.configSupplyCurrentLimit(ShooterConstants.SUPPLY_CURRENT_LIMIT_CONFIG, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//RIGHT FALCON
|
|
|
|
|
//m_shooterFalconRight.configPeakOutputForward(0, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
m_shooterFalconRight.setSelectedSensorPosition(0, ShooterConstants.SHOOTER_PID_LOOP_IDX, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
m_shooterFalconRight.configClosedLoopPeriod(0, closedLoopTimeMs, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
m_shooterFalconRight.configSupplyCurrentLimit(ShooterConstants.SUPPLY_CURRENT_LIMIT_CONFIG, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
m_shooterTable = new ShooterTables();
|
|
|
|
|
|
|
|
|
|
m_shooterFalcon.configSupplyCurrentLimit(ShooterConstants.SUPPLY_CURRENT_LIMIT_CONFIG, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
|
|
|
|
|
//SmartDashboard.putNumber("CSV 10", m_shooterTable.getVelocity(10));
|
|
|
|
|
//SmartDashboard.putNumber("CSV 200", m_shooterTable.getVelocity(200));
|
|
|
|
|
//SmartDashboard.putNumber("CSV 250", m_shooterTable.getVelocity(250));
|
|
|
|
@@ -83,13 +101,13 @@ public class Shooter extends SubsystemBase {
|
|
|
|
|
public void periodic() {
|
|
|
|
|
// This method will be called once per scheduler run
|
|
|
|
|
try{
|
|
|
|
|
SmartDashboard.putNumber("Drum Velocity", m_shooterFalcon.getSelectedSensorVelocity());
|
|
|
|
|
SmartDashboard.putNumber("Drum Velocity", m_shooterFalconLeft.getSelectedSensorVelocity());
|
|
|
|
|
|
|
|
|
|
SmartDashboard.putNumber("Drum Velocity CSV", m_fireVel);
|
|
|
|
|
|
|
|
|
|
SmartDashboard.putNumber("Shooter Temp C", m_shooterFalcon.getTemperature());
|
|
|
|
|
SmartDashboard.putNumber("Shooter Temp C", m_shooterFalconLeft.getTemperature());
|
|
|
|
|
|
|
|
|
|
SmartDashboard.putNumber("Shooter Current", m_shooterFalcon.getSupplyCurrent());
|
|
|
|
|
SmartDashboard.putNumber("Shooter Current", m_shooterFalconLeft.getSupplyCurrent());
|
|
|
|
|
|
|
|
|
|
SmartDashboard.putBoolean("Drum Ready" , m_isDrumReady);
|
|
|
|
|
}
|
|
|
|
@@ -118,18 +136,20 @@ public class Shooter extends SubsystemBase {
|
|
|
|
|
* @param speed Speed to set the motor at
|
|
|
|
|
*/
|
|
|
|
|
public void runDrumShooter(double speed) {
|
|
|
|
|
m_shooterFalcon.set(speed);
|
|
|
|
|
m_shooterFalconLeft.set(TalonFXControlMode.PercentOutput, speed);
|
|
|
|
|
m_shooterFalconRight.follow(m_shooterFalconLeft);
|
|
|
|
|
//m_shooterFalconRight.set(TalonFXControlMode.PercentOutput, speed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Configures gains for shooter PID.
|
|
|
|
|
*/
|
|
|
|
|
public void setShooterGains() {
|
|
|
|
|
m_shooterFalcon.selectProfileSlot(ShooterConstants.SHOOTER_SLOT_IDX, ShooterConstants.SHOOTER_PID_LOOP_IDX);
|
|
|
|
|
m_shooterFalcon.config_kF(ShooterConstants.SHOOTER_SLOT_IDX, m_drumShooterGains.m_kF, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
m_shooterFalcon.config_kP(ShooterConstants.SHOOTER_SLOT_IDX, m_drumShooterGains.m_kP, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
m_shooterFalcon.config_kI(ShooterConstants.SHOOTER_SLOT_IDX, m_drumShooterGains.m_kI, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
m_shooterFalcon.config_kD(ShooterConstants.SHOOTER_SLOT_IDX, m_drumShooterGains.m_kD, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
m_shooterFalconLeft.selectProfileSlot(ShooterConstants.SHOOTER_SLOT_IDX, ShooterConstants.SHOOTER_PID_LOOP_IDX);
|
|
|
|
|
m_shooterFalconLeft.config_kF(ShooterConstants.SHOOTER_SLOT_IDX, m_drumShooterGains.m_kF, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
m_shooterFalconLeft.config_kP(ShooterConstants.SHOOTER_SLOT_IDX, m_drumShooterGains.m_kP, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
m_shooterFalconLeft.config_kI(ShooterConstants.SHOOTER_SLOT_IDX, m_drumShooterGains.m_kI, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
m_shooterFalconLeft.config_kD(ShooterConstants.SHOOTER_SLOT_IDX, m_drumShooterGains.m_kD, ShooterConstants.SHOOTER_TIMEOUT_MS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@@ -138,6 +158,7 @@ public class Shooter extends SubsystemBase {
|
|
|
|
|
*/
|
|
|
|
|
public void runDrumShooterVelocityPID(double targetVel) {
|
|
|
|
|
//System.out.println("Target Velocity" + targetVel);
|
|
|
|
|
m_shooterFalcon.set(TalonFXControlMode.Velocity, targetVel); //Init PID
|
|
|
|
|
m_shooterFalconLeft.set(TalonFXControlMode.Velocity, targetVel); //Init PID
|
|
|
|
|
m_shooterFalconRight.follow(m_shooterFalconLeft);
|
|
|
|
|
}
|
|
|
|
|
}
|