PID tuning

P and F
This commit is contained in:
ryan123rudder
2020-02-01 16:07:59 -07:00
parent c263ddc6f9
commit 0f5a6ef09f
3 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -42,7 +42,7 @@ public final class Constants {
public static final int SHOOTER_SLOT_IDX = 0;
public static final int SHOOTER_PID_LOOP_IDX = 1;
public static final int SHOOTER_TIMEOUT_MS = 30;
public static final Gains SHOOTER_GAINS = new Gains(0.0, 0.0, 0.0, 0.0542, 0, 1.0);
public static final Gains SHOOTER_GAINS = new Gains(0.13, 0.0, 0.0, 0.053, 0, 1.0);
public static final double ENCODER_TICKS_PER_REV = 2048;
}
@@ -79,7 +79,7 @@ public class RobotContainer {
.whenReleased(() -> m_robotLED.setPattern(LEDConstants.DEFAULT_PATTERN));
new JoystickButton(getOperatorJoystick(), XboxController.X_BUTTON)
.whileHeld(new ShooterVelocityControlPID(m_robotShooter, 13200));
.whileHeld(new ShooterVelocityControlPID(m_robotShooter, 8200));
/*new JoystickButton(getDriverJoystick(), XboxController.LEFT_JOYSTICK_BUTTON)
.whenPressed(new InstantCommand(null, m_robotDrive));*/
@@ -21,8 +21,6 @@ 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;
double velP;
@@ -43,14 +41,11 @@ 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 Target", m_targetVel);
}
@Override
public void periodic() {
// This method will be called once per scheduler run
m_targetVel = SmartDashboard.getNumber("Shooter Velocity Target", m_targetVel);
SmartDashboard.putNumber("Shooter Velocity", m_shooterFalcon.getSelectedSensorVelocity()*600/ShooterConstants.ENCODER_TICKS_PER_REV);
}
@@ -79,10 +74,15 @@ public class Shooter extends SubsystemBase {
*/
public void runDrumShooterVelocityPID(double targetVel, double actualVel) {
velP = actualVel/targetVel;
double runSpeed = actualVel + (20000*velP);
double runSpeed = actualVel + (12000*velP);
if (runSpeed > targetVel) {runSpeed = targetVel;}
System.err.println(velP + " " + runSpeed);
SmartDashboard.putNumber("shoot", actualVel);
m_shooterFalcon.set(TalonFXControlMode.Velocity, runSpeed);
if (actualVel < targetVel - 7000){
m_shooterFalcon.set(TalonFXControlMode.Velocity, runSpeed);
}
else{
m_shooterFalcon.set(TalonFXControlMode.Velocity, targetVel);
}
}
}