From d11083e560b57160fc79106dfd57cffab6945ca3 Mon Sep 17 00:00:00 2001 From: ryan123rudder <42309874+ryan123rudder@users.noreply.github.com> Date: Sun, 1 Mar 2020 00:41:23 -0700 Subject: [PATCH] Conventions No functional change --- src/main/java/frc4388/robot/Constants.java | 15 +++++++++++++++ .../frc4388/robot/commands/CalibrateShooter.java | 9 ++++++--- .../java/frc4388/robot/commands/HoldTarget.java | 2 ++ .../frc4388/robot/commands/HoodPositionPID.java | 5 ++++- .../frc4388/robot/commands/ShootPrepGroup.java | 2 +- .../robot/commands/ShooterVelocityControlPID.java | 10 +++++----- .../frc4388/robot/commands/StorageIntake.java | 4 +++- .../frc4388/robot/commands/StorageOutake.java | 3 ++- .../robot/commands/StoragePositionPID.java | 3 ++- .../frc4388/robot/commands/StoragePrepAim.java | 7 +++++-- .../frc4388/robot/commands/StoragePrepIntake.java | 6 ++++-- .../java/frc4388/robot/commands/StorageRun.java | 1 - .../java/frc4388/robot/commands/TrackTarget.java | 2 ++ .../java/frc4388/robot/commands/TrimShooter.java | 3 ++- .../java/frc4388/robot/subsystems/Shooter.java | 8 ++++---- .../java/frc4388/robot/subsystems/ShooterAim.java | 8 ++++---- .../java/frc4388/robot/subsystems/Storage.java | 11 ----------- 17 files changed, 61 insertions(+), 38 deletions(-) diff --git a/src/main/java/frc4388/robot/Constants.java b/src/main/java/frc4388/robot/Constants.java index a567edb..3408679 100644 --- a/src/main/java/frc4388/robot/Constants.java +++ b/src/main/java/frc4388/robot/Constants.java @@ -127,6 +127,20 @@ public final class Constants { public static final double ENCODER_TICKS_PER_REV = 2048; public static final double NEO_UNITS_PER_REV = 42; public static final double DEGREES_PER_ROT = 360; + + public static final int TURRET_RIGHT_SOFT_LIMIT = -2; + public static final int TURRET_LEFT_SOFT_LIMIT = -55; + public static final double TURRET_SPEED_MULTIPLIER = 0.3; + public static final double TURRET_CALIBRATE_SPEED = 0.075; + + public static final int HOOD_UP_SOFT_LIMIT = 33; + public static final int HOOD_DOWN_SOFT_LIMIT = 3; + public static final double HOOD_CONVERT_SLOPE = 0.47; + public static final double HOOD_CONVERT_B = 40.5; + public static final double HOOD_CALIBRATE_SPEED = 0.1; + + public static final double DRUM_RAMP_LIMIT = 1000; + public static final double DRUM_VELOCITY_BOUND = 300; } public static final class ClimberConstants { @@ -142,6 +156,7 @@ public final class Constants { public static final double STORAGE_PARTIAL_BALL = 2; public static final double STORAGE_FULL_BALL = 7; public static final double STORAGE_SPEED = 0.5; + public static final double STORAGE_TIMEOUT = 2000; /* Ball Indexes */ public static final int BEAM_SENSOR_DIO_0 = 0; diff --git a/src/main/java/frc4388/robot/commands/CalibrateShooter.java b/src/main/java/frc4388/robot/commands/CalibrateShooter.java index 1349f1c..1b766d7 100644 --- a/src/main/java/frc4388/robot/commands/CalibrateShooter.java +++ b/src/main/java/frc4388/robot/commands/CalibrateShooter.java @@ -11,6 +11,7 @@ import com.revrobotics.CANSparkMax.SoftLimitDirection; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.CommandBase; +import frc4388.robot.Constants.ShooterConstants; import frc4388.robot.subsystems.Shooter; import frc4388.robot.subsystems.ShooterAim; @@ -18,7 +19,9 @@ public class CalibrateShooter extends CommandBase { Shooter m_shooter; ShooterAim m_shooterAim; /** - * Creates a new CalibrateShooter. + * Calibrates the turret by moving the hood all the way down and moving the turret all the way right, then reseting the encoders + * @param shootSub The Shooter subsystem + * @param aimSub The ShooterAim subsystem */ public CalibrateShooter(Shooter shootSub, ShooterAim aimSub) { m_shooter = shootSub; @@ -37,12 +40,12 @@ public class CalibrateShooter extends CommandBase { m_shooter.m_angleAdjustMotor.enableSoftLimit(SoftLimitDirection.kForward, false); m_shooter.m_angleAdjustMotor.enableSoftLimit(SoftLimitDirection.kReverse, false); m_shooter.m_angleEncoder.setPosition(0); - m_shooter.m_angleAdjustMotor.set(-0.1); + m_shooter.m_angleAdjustMotor.set(-ShooterConstants.HOOD_CALIBRATE_SPEED); m_shooterAim.m_shooterRotateMotor.enableSoftLimit(SoftLimitDirection.kForward, false); m_shooterAim.m_shooterRotateMotor.enableSoftLimit(SoftLimitDirection.kReverse, false); m_shooterAim.m_shooterRotateEncoder.setPosition(0); - m_shooterAim.m_shooterRotateMotor.set(0.075); + m_shooterAim.m_shooterRotateMotor.set(ShooterConstants.TURRET_CALIBRATE_SPEED); } // Called once the command ends or is interrupted. diff --git a/src/main/java/frc4388/robot/commands/HoldTarget.java b/src/main/java/frc4388/robot/commands/HoldTarget.java index cfed837..cbdee25 100644 --- a/src/main/java/frc4388/robot/commands/HoldTarget.java +++ b/src/main/java/frc4388/robot/commands/HoldTarget.java @@ -40,6 +40,8 @@ public class HoldTarget extends CommandBase { /** * Uses the Limelight to track the target + * @param shooterSubsystem The Shooter subsystem + * @param aimSubsystem The ShooterAim subsystem */ public HoldTarget(Shooter shooterSubsystem, ShooterAim aimSubsystem) { m_shooterAim = aimSubsystem; diff --git a/src/main/java/frc4388/robot/commands/HoodPositionPID.java b/src/main/java/frc4388/robot/commands/HoodPositionPID.java index d713f8b..efecb58 100644 --- a/src/main/java/frc4388/robot/commands/HoodPositionPID.java +++ b/src/main/java/frc4388/robot/commands/HoodPositionPID.java @@ -9,6 +9,7 @@ package frc4388.robot.commands; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.CommandBase; +import frc4388.robot.Constants.ShooterConstants; import frc4388.robot.subsystems.Shooter; public class HoodPositionPID extends CommandBase { @@ -30,7 +31,9 @@ public class HoodPositionPID extends CommandBase { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - firingAngle = (-0.47*m_shooter.addFireAngle())+40.5; + double slope = ShooterConstants.HOOD_CONVERT_SLOPE; + double b = ShooterConstants.HOOD_CONVERT_B; + firingAngle = (-slope*m_shooter.addFireAngle())+b; SmartDashboard.putNumber("Shoot Angle From Equation", m_shooter.addFireAngle()); SmartDashboard.putNumber("Fire Angle", firingAngle); m_shooter.runAngleAdjustPID(firingAngle); diff --git a/src/main/java/frc4388/robot/commands/ShootPrepGroup.java b/src/main/java/frc4388/robot/commands/ShootPrepGroup.java index 0615b7d..5c20683 100644 --- a/src/main/java/frc4388/robot/commands/ShootPrepGroup.java +++ b/src/main/java/frc4388/robot/commands/ShootPrepGroup.java @@ -18,7 +18,7 @@ import frc4388.robot.subsystems.Storage; // https://docs.wpilib.org/en/latest/docs/software/commandbased/convenience-features.html public class ShootPrepGroup extends ParallelCommandGroup { /** - * Preps the Shooter to be fired + * Prepares the Shooter to be fired * @param m_shooter The Shooter subsytem * @param m_shooterAim The ShooterAim subsystem * @param m_storage The Storage subsytem diff --git a/src/main/java/frc4388/robot/commands/ShooterVelocityControlPID.java b/src/main/java/frc4388/robot/commands/ShooterVelocityControlPID.java index a5e0b5a..52dea7f 100644 --- a/src/main/java/frc4388/robot/commands/ShooterVelocityControlPID.java +++ b/src/main/java/frc4388/robot/commands/ShooterVelocityControlPID.java @@ -9,6 +9,7 @@ package frc4388.robot.commands; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.CommandBase; +import frc4388.robot.Constants.ShooterConstants; import frc4388.robot.subsystems.Shooter; public class ShooterVelocityControlPID extends CommandBase { @@ -16,9 +17,8 @@ public class ShooterVelocityControlPID extends CommandBase { double m_targetVel; double m_actualVel; /** - * Creates a new ShooterVelocityControlPID. + * Runs the drum at a velocity * @param subsystem The Shooter subsytem - * @param targetVel The target velocity */ public ShooterVelocityControlPID(Shooter subsystem) { m_shooter = subsystem; @@ -48,9 +48,9 @@ public class ShooterVelocityControlPID extends CommandBase { // Returns true when the command should end. @Override public boolean isFinished() { - //Tells wether the target velocity has been reached - double upperBound = m_targetVel + 300; - double lowerBound = m_targetVel - 300; + //Tells whether the target velocity has been reached + double upperBound = m_targetVel + ShooterConstants.DRUM_VELOCITY_BOUND; + double lowerBound = m_targetVel - ShooterConstants.DRUM_VELOCITY_BOUND; if (m_actualVel < upperBound && m_actualVel > lowerBound){ SmartDashboard.putBoolean("ShooterVelocityPID Finished", true); return true; diff --git a/src/main/java/frc4388/robot/commands/StorageIntake.java b/src/main/java/frc4388/robot/commands/StorageIntake.java index 69de480..baf1630 100644 --- a/src/main/java/frc4388/robot/commands/StorageIntake.java +++ b/src/main/java/frc4388/robot/commands/StorageIntake.java @@ -18,7 +18,9 @@ public class StorageIntake extends CommandBase { public Storage m_storage; public boolean intook; /** - * Creates a new storageIntake. + * Runs the Storage in for intaking + * @param inSub The Intake subsystem + * @param storeSub The Storage subsytem */ public StorageIntake(Intake inSub, Storage storeSub) { m_intake = inSub; diff --git a/src/main/java/frc4388/robot/commands/StorageOutake.java b/src/main/java/frc4388/robot/commands/StorageOutake.java index c19ce5a..3231600 100644 --- a/src/main/java/frc4388/robot/commands/StorageOutake.java +++ b/src/main/java/frc4388/robot/commands/StorageOutake.java @@ -14,7 +14,8 @@ import frc4388.robot.subsystems.Storage; public class StorageOutake extends CommandBase { Storage m_storage; /** - * Creates a new storageOutake. + * Runs the Storage out for outaking + * @param storeSub The Storage subsystem */ public StorageOutake(Storage storeSub) { m_storage = storeSub; diff --git a/src/main/java/frc4388/robot/commands/StoragePositionPID.java b/src/main/java/frc4388/robot/commands/StoragePositionPID.java index ec6caad..bc607e5 100644 --- a/src/main/java/frc4388/robot/commands/StoragePositionPID.java +++ b/src/main/java/frc4388/robot/commands/StoragePositionPID.java @@ -15,7 +15,8 @@ public class StoragePositionPID extends CommandBase { public Storage m_storage; double startPos; /** - * Creates a new StoragePositionPID. + * Moves the storage a number of rotations + * @param subsystem The Storage subsystem */ public StoragePositionPID(Storage subsystem) { m_storage = subsystem; diff --git a/src/main/java/frc4388/robot/commands/StoragePrepAim.java b/src/main/java/frc4388/robot/commands/StoragePrepAim.java index 2782c7c..f0e52c1 100644 --- a/src/main/java/frc4388/robot/commands/StoragePrepAim.java +++ b/src/main/java/frc4388/robot/commands/StoragePrepAim.java @@ -14,8 +14,10 @@ import frc4388.robot.subsystems.Storage; public class StoragePrepAim extends CommandBase { Storage m_storage; + double startTime; /** - * Creates a new storagePrepAim. + * Prepares the Storage for aiming + * @param storeSub The Storage subsystem */ public StoragePrepAim(Storage storeSub) { m_storage = storeSub; @@ -25,6 +27,7 @@ public class StoragePrepAim extends CommandBase { // Called when the command is initially scheduled. @Override public void initialize() { + startTime = System.currentTimeMillis(); } // Called every time the scheduler runs while the command is scheduled. @@ -46,7 +49,7 @@ public class StoragePrepAim extends CommandBase { // Returns true when the command should end. @Override public boolean isFinished() { - if (!m_storage.getBeam(1)){ + if (!m_storage.getBeam(1) || startTime + StorageConstants.STORAGE_TIMEOUT <= System.currentTimeMillis()){ SmartDashboard.putBoolean("StoragePrepAim Finished", true); return true; } diff --git a/src/main/java/frc4388/robot/commands/StoragePrepIntake.java b/src/main/java/frc4388/robot/commands/StoragePrepIntake.java index 6a9f36e..44a2d2e 100644 --- a/src/main/java/frc4388/robot/commands/StoragePrepIntake.java +++ b/src/main/java/frc4388/robot/commands/StoragePrepIntake.java @@ -18,7 +18,9 @@ public class StoragePrepIntake extends CommandBase { public double startTime; /** - * Creates a new StoragePrepIntake. + * Prepares the Storage for intaking + * @param inSub The Intake subsystem + * @param storeSub the Storage subsystem */ public StoragePrepIntake(Intake inSub, Storage storeSub) { m_intake = inSub; @@ -52,7 +54,7 @@ public class StoragePrepIntake extends CommandBase { // Returns true when the command should end. @Override public boolean isFinished() { - if (!m_storage.getBeam(0) || startTime + 2000 <= System.currentTimeMillis()){ + if (!m_storage.getBeam(0) || startTime + StorageConstants.STORAGE_TIMEOUT <= System.currentTimeMillis()){ return true; } return false; diff --git a/src/main/java/frc4388/robot/commands/StorageRun.java b/src/main/java/frc4388/robot/commands/StorageRun.java index b97d226..91632f5 100644 --- a/src/main/java/frc4388/robot/commands/StorageRun.java +++ b/src/main/java/frc4388/robot/commands/StorageRun.java @@ -29,7 +29,6 @@ public class StorageRun extends CommandBase { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - System.err.println("oiudhgisbjkljasbhfkofhdnsekdfjbsjfvsdkcfbsdjhfgvsdkjfbsd"); m_storage.runStorage(StorageConstants.STORAGE_SPEED); } diff --git a/src/main/java/frc4388/robot/commands/TrackTarget.java b/src/main/java/frc4388/robot/commands/TrackTarget.java index 95689e8..44295d2 100644 --- a/src/main/java/frc4388/robot/commands/TrackTarget.java +++ b/src/main/java/frc4388/robot/commands/TrackTarget.java @@ -44,6 +44,8 @@ public class TrackTarget extends CommandBase { /** * Uses the Limelight to track the target + * @param shooterSubsystem The Shooter subsystem + * @param aimSubsystem The ShooterAim subsystem */ public TrackTarget(Shooter shooterSubsystem, ShooterAim aimSubsystem) { m_shooterAim = aimSubsystem; diff --git a/src/main/java/frc4388/robot/commands/TrimShooter.java b/src/main/java/frc4388/robot/commands/TrimShooter.java index e83d00a..b77a4ba 100644 --- a/src/main/java/frc4388/robot/commands/TrimShooter.java +++ b/src/main/java/frc4388/robot/commands/TrimShooter.java @@ -23,7 +23,8 @@ public class TrimShooter extends CommandBase { public Shooter m_shooter; /** - * Creates a new TrimShooter. + * Trims the shooter based on the D-Pad inputs + * @param shootSub The Shooter subsytems */ public TrimShooter(Shooter shootSub) { m_shooter = shootSub; diff --git a/src/main/java/frc4388/robot/subsystems/Shooter.java b/src/main/java/frc4388/robot/subsystems/Shooter.java index b46247a..cd0dda3 100644 --- a/src/main/java/frc4388/robot/subsystems/Shooter.java +++ b/src/main/java/frc4388/robot/subsystems/Shooter.java @@ -57,7 +57,7 @@ public class Shooter extends SubsystemBase { public Trims shooterTrims; /* - * Creates a new Shooter subsystem. + * Creates a new Shooter subsystem, with the drum shooter and the angle adjsuter. */ public Shooter() { //Testing purposes reseting gyros @@ -100,8 +100,8 @@ public class Shooter extends SubsystemBase { m_angleAdjustMotor.enableSoftLimit(SoftLimitDirection.kForward, true); m_angleAdjustMotor.enableSoftLimit(SoftLimitDirection.kReverse, true); - m_angleAdjustMotor.setSoftLimit(SoftLimitDirection.kForward, 33); - m_angleAdjustMotor.setSoftLimit(SoftLimitDirection.kReverse, 3); + m_angleAdjustMotor.setSoftLimit(SoftLimitDirection.kForward, ShooterConstants.HOOD_UP_SOFT_LIMIT); + m_angleAdjustMotor.setSoftLimit(SoftLimitDirection.kReverse, ShooterConstants.HOOD_DOWN_SOFT_LIMIT); } @@ -159,7 +159,7 @@ public class Shooter extends SubsystemBase { */ public void runDrumShooterVelocityPID(double targetVel, double actualVel) { SmartDashboard.putNumber("shoot", actualVel); - if (actualVel < targetVel - 1000){ + if (actualVel < targetVel - ShooterConstants.DRUM_RAMP_LIMIT){ m_shooterFalcon.set(TalonFXControlMode.PercentOutput, 1);//Ramp up } else{ //PID Based on targetVel diff --git a/src/main/java/frc4388/robot/subsystems/ShooterAim.java b/src/main/java/frc4388/robot/subsystems/ShooterAim.java index fde5350..1111749 100644 --- a/src/main/java/frc4388/robot/subsystems/ShooterAim.java +++ b/src/main/java/frc4388/robot/subsystems/ShooterAim.java @@ -34,7 +34,7 @@ public class ShooterAim extends SubsystemBase { /** - * Creates a new ShooterAim. + * Creates a subsytem for the turret aiming */ public ShooterAim() { //resetGyroShooterRotate(); @@ -47,12 +47,12 @@ public class ShooterAim extends SubsystemBase { m_shooterRotateMotor.enableSoftLimit(SoftLimitDirection.kForward, false); m_shooterRotateMotor.enableSoftLimit(SoftLimitDirection.kReverse, true); - m_shooterRotateMotor.setSoftLimit(SoftLimitDirection.kForward, -2); - m_shooterRotateMotor.setSoftLimit(SoftLimitDirection.kReverse, -56); + m_shooterRotateMotor.setSoftLimit(SoftLimitDirection.kForward, ShooterConstants.TURRET_RIGHT_SOFT_LIMIT); + m_shooterRotateMotor.setSoftLimit(SoftLimitDirection.kReverse, ShooterConstants.TURRET_LEFT_SOFT_LIMIT); } public void runShooterWithInput(double input) { - m_shooterRotateMotor.set(input/3); + m_shooterRotateMotor.set(input*ShooterConstants.TURRET_SPEED_MULTIPLIER); } diff --git a/src/main/java/frc4388/robot/subsystems/Storage.java b/src/main/java/frc4388/robot/subsystems/Storage.java index ec258c5..7bcc411 100644 --- a/src/main/java/frc4388/robot/subsystems/Storage.java +++ b/src/main/java/frc4388/robot/subsystems/Storage.java @@ -102,15 +102,4 @@ public class Storage extends SubsystemBase { public void setStoragePID(double position){ m_storagePIDController.setReference(position , ControlType.kPosition); } - - - /* - If pressing aim - run unti; hitting top beam - else - Run until hitting bottom beam - dont run intake if balls not at bottom - - 2 beamms total - */ }