Fix Shooter PID

This commit is contained in:
ryan123rudder
2020-01-31 21:39:51 -07:00
parent 8a95c8a8cc
commit 42db77fe6d
6 changed files with 16 additions and 151 deletions
@@ -25,6 +25,7 @@ public class Shooter extends SubsystemBase {
public static Gains m_shooterGains = ShooterConstants.SHOOTER_GAINS;
double velP;
/**
* Creates a new Shooter.
*/
@@ -76,7 +77,13 @@ public class Shooter extends SubsystemBase {
* @param falcon Motor to use
* @param targetVel Target velocity to run motor at
*/
public void runDrumShooterVelocityPID(double targetVel) {
m_shooterFalcon.set(TalonFXControlMode.Velocity, m_targetVel*ShooterConstants.ENCODER_TICKS_PER_REV/600);
public void runDrumShooterVelocityPID(double targetVel, double actualVel) {
velP = actualVel/targetVel;
if(velP < 0.1){
velP = 0.1;
}
double runSpeed = velP*(1-velP);
System.err.println(runSpeed);
m_shooterFalcon.set(TalonFXControlMode.PercentOutput, runSpeed/*ShooterConstants.ENCODER_TICKS_PER_REV/600*/);
}
}
}