mirror of
https://github.com/Team4388/RiseOfRidgebotics2020.git
synced 2026-06-09 08:48:01 -06:00
Merge branch 'add-storage' of https://github.com/Team4388/RiseOfRidgebotics2020 into add-storage
This commit is contained in:
@@ -48,6 +48,9 @@ public class Shooter extends SubsystemBase {
|
||||
|
||||
double velP;
|
||||
double input;
|
||||
public boolean velReached;
|
||||
public double m_fireVel;
|
||||
public double m_fireAngle;
|
||||
|
||||
/*
|
||||
* Creates a new Shooter subsystem.
|
||||
@@ -79,6 +82,13 @@ public class Shooter extends SubsystemBase {
|
||||
SmartDashboard.putNumber("Shooter Velocity", m_shooterFalcon.getSelectedSensorVelocity()*600/ShooterConstants.ENCODER_TICKS_PER_REV);
|
||||
}
|
||||
|
||||
public double addFireVel() {
|
||||
return m_fireVel;
|
||||
}
|
||||
public double addFireAngle() {
|
||||
return m_fireAngle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs drum shooter motor.
|
||||
* @param speed Speed to set the motor at
|
||||
@@ -105,15 +115,26 @@ public class Shooter extends SubsystemBase {
|
||||
public void runDrumShooterVelocityPID(double targetVel, double actualVel) {
|
||||
velP = actualVel/targetVel; //Percent of target
|
||||
double runSpeed = actualVel + (12000*velP); //Ramp up equation
|
||||
//if (runSpeed > targetVel) {runSpeed = targetVel;}
|
||||
SmartDashboard.putNumber("shoot", actualVel);
|
||||
runSpeed = runSpeed/targetVel; //Convert to percent
|
||||
|
||||
if (actualVel < targetVel - 1000){ //PID Based on ramp up amount
|
||||
m_shooterFalcon.set(TalonFXControlMode.PercentOutput, runSpeed);
|
||||
}
|
||||
else{ //PID Based on targetVel
|
||||
m_shooterFalcon.set(TalonFXControlMode.Velocity, targetVel); //Init PID
|
||||
}
|
||||
|
||||
//Tells wether the target velocity has been reached
|
||||
double upperBound = targetVel + 300;
|
||||
double lowerBound = targetVel - 300;
|
||||
if (actualVel < upperBound && actualVel > lowerBound)
|
||||
{
|
||||
velReached = true;
|
||||
}
|
||||
else{
|
||||
velReached = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ public class Storage extends SubsystemBase {
|
||||
|
||||
Intake m_intake;
|
||||
|
||||
public boolean botReached;
|
||||
|
||||
/**
|
||||
* Creates a new Storage.
|
||||
@@ -75,16 +74,17 @@ public class Storage extends SubsystemBase {
|
||||
/* Storage PID Control */
|
||||
public void runStoragePositionPID(double targetPos){
|
||||
// Set PID Coefficients
|
||||
m_storagePIDController.setP(storageGains.m_kP);
|
||||
m_storagePIDController.setI(storageGains.m_kI);
|
||||
m_storagePIDController.setD(storageGains.m_kD);
|
||||
m_storagePIDController.setIZone(storageGains.m_kIzone);
|
||||
m_storagePIDController.setFF(storageGains.m_kF);
|
||||
m_storagePIDController.setOutputRange(StorageConstants.STORAGE_MIN_OUTPUT, storageGains.m_kPeakOutput);
|
||||
m_storagePIDController.setP(m_storageGains.m_kP);
|
||||
m_storagePIDController.setI(m_storageGains.m_kI);
|
||||
m_storagePIDController.setD(m_storageGains.m_kD);
|
||||
m_storagePIDController.setIZone(m_storageGains.m_kIzone);
|
||||
m_storagePIDController.setFF(m_storageGains.m_kF);
|
||||
m_storagePIDController.setOutputRange(StorageConstants.storkminOutput, m_storageGains.m_kmaxOutput);
|
||||
|
||||
m_storagePIDController.setReference(targetPos, ControlType.kPosition);
|
||||
}
|
||||
|
||||
|
||||
public double getEncoderPos(){
|
||||
return m_encoder.getPosition();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user