Tested Shooter, Fine tuned it

This commit is contained in:
aarav18
2020-01-20 15:22:44 -07:00
parent a96cd7a3e2
commit db5c15a452
3 changed files with 15 additions and 8 deletions
@@ -101,16 +101,16 @@ public class RobotContainer {
.whenPressed(new DriveAtVelocityPID(m_robotDrive, 2000));
new JoystickButton(getOperatorJoystick(), XboxController.X_BUTTON)
.whileHeld(new ShooterVelocityControlPID(m_robotShooter, 2000));
.whileHeld(new RunCommand(() -> m_robotShooter.runDrumShooterVelocityPID(2300), m_robotShooter));
new JoystickButton(getOperatorJoystick(), XboxController.LEFT_BUMPER_BUTTON)
.whenPressed(new DistanceElevatorPID(m_robotElevator, 20000));
new JoystickButton(getDriverJoystick(), XboxController.LEFT_JOYSTICK_BUTTON)
.whenPressed(new InstantCommand(null, m_robotDrive));
/*new JoystickButton(getDriverJoystick(), XboxController.LEFT_JOYSTICK_BUTTON)
.whenPressed(new InstantCommand(null, m_robotDrive));*/
new JoystickButton(getOperatorJoystick(), XboxController.B_BUTTON)
.whileHeld(() -> m_robotShooter.runDrumShooter(1), m_robotShooter);
.whileHeld(new RunCommand(() -> m_robotShooter.runDrumShooter(0.2), m_robotShooter));
}
/**
@@ -31,7 +31,7 @@ public class ShooterVelocityControlPID extends CommandBase {
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
m_shooter.runDrumShooterVelocityPID(m_shooter.m_shooterFalcon, m_targetVel);
m_shooter.runDrumShooterVelocityPID(m_targetVel);
}
// Called once the command ends or is interrupted.
@@ -11,14 +11,18 @@ import com.ctre.phoenix.motorcontrol.NeutralMode;
import com.ctre.phoenix.motorcontrol.TalonFXControlMode;
import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc4388.robot.Gains;
import frc4388.robot.Constants.DriveConstants;
import frc4388.robot.Constants.ShooterConstants;
public class Shooter extends SubsystemBase {
public WPI_TalonFX m_shooterFalcon = new WPI_TalonFX(ShooterConstants.SHOOTER_FALCON_ID);
private double m_targetVel = 2300;
public static Gains m_shooterGains = ShooterConstants.SHOOTER_GAINS;
/**
@@ -29,7 +33,7 @@ public class Shooter extends SubsystemBase {
m_shooterFalcon.setNeutralMode(NeutralMode.Coast);
m_shooterFalcon.setInverted(false);
m_shooterFalcon.setInverted(true);
setShooterGains();
@@ -38,11 +42,14 @@ public class Shooter extends SubsystemBase {
int closedLoopTimeMs = 1;
m_shooterFalcon.configClosedLoopPeriod(0, closedLoopTimeMs, ShooterConstants.SHOOTER_TIMEOUT_MS);
m_shooterFalcon.configClosedLoopPeriod(1, closedLoopTimeMs, ShooterConstants.SHOOTER_TIMEOUT_MS);
SmartDashboard.putNumber("Shooter Velocity", m_targetVel);
}
@Override
public void periodic() {
// This method will be called once per scheduler run
m_targetVel = SmartDashboard.getNumber("Shooter Velocity", m_targetVel);
}
/**
@@ -68,7 +75,7 @@ public class Shooter extends SubsystemBase {
* @param falcon Motor to use
* @param targetVel Target velocity to run motor at
*/
public void runDrumShooterVelocityPID(WPI_TalonFX falcon, double targetVel) {
falcon.set(TalonFXControlMode.Velocity, targetVel);
public void runDrumShooterVelocityPID(double targetVel) {
m_shooterFalcon.set(TalonFXControlMode.Velocity, m_targetVel*ShooterConstants.ENCODER_TICKS_PER_REV/600);
}
}