From 896bbc011cef371a987a2f473702d290beba7650 Mon Sep 17 00:00:00 2001 From: aarav18 Date: Sun, 20 Mar 2022 15:24:48 -0600 Subject: [PATCH] can now drive while Shoot.java was running --- src/main/java/frc4388/robot/Constants.java | 2 +- .../java/frc4388/robot/RobotContainer.java | 39 +++++++++---------- .../robot/commands/ShooterCommands/Shoot.java | 4 +- .../frc4388/robot/subsystems/BoomBoom.java | 3 +- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/main/java/frc4388/robot/Constants.java b/src/main/java/frc4388/robot/Constants.java index 39814d8..e1dcc07 100644 --- a/src/main/java/frc4388/robot/Constants.java +++ b/src/main/java/frc4388/robot/Constants.java @@ -279,7 +279,7 @@ public final class Constants { // Shoot Command Constants public static final Gains TURRET_SHOOT_GAINS = new Gains(3.0, 0.0, 0.0, 0.0, 0, 1.0); - public static final Gains SWERVE_SHOOT_GAINS = new Gains(4.0, 0.0, 0.0, 0.0, 0, 1.0); + public static final Gains SWERVE_SHOOT_GAINS = new Gains(6.0, 0.0, 0.0, 0.0, 0, 1.0); /* Turret Constants */ // ID diff --git a/src/main/java/frc4388/robot/RobotContainer.java b/src/main/java/frc4388/robot/RobotContainer.java index 8c8add1..94da529 100644 --- a/src/main/java/frc4388/robot/RobotContainer.java +++ b/src/main/java/frc4388/robot/RobotContainer.java @@ -131,8 +131,8 @@ public class RobotContainer { // public final Climber m_robotClimber = new Climber(testShoulderMotor, testElbowMotor); // Controllers - private final XboxController m_driverXbox = new DeadbandedXboxController(OIConstants.XBOX_DRIVER_ID); - private final XboxController m_operatorXbox = new DeadbandedXboxController(OIConstants.XBOX_OPERATOR_ID); + private final static XboxController m_driverXbox = new DeadbandedXboxController(OIConstants.XBOX_DRIVER_ID); + private final static XboxController m_operatorXbox = new DeadbandedXboxController(OIConstants.XBOX_OPERATOR_ID); private final ButtonBox m_buttonBox = new ButtonBox(OIConstants.BUTTON_BOX_ID); // Autonomous @@ -270,31 +270,29 @@ public class RobotContainer { new JoystickButton(getDriverController(), XboxController.Button.kRightBumper.value) .whenPressed(() -> m_robotSwerveDrive.highSpeed(true)); - new JoystickButton(getDriverController(), XboxController.Button.kA.value) - .whileHeld(() -> m_robotSwerveDrive.driveWithInput(0.0, 0.0, 0.2, true)) - .whenReleased(() -> m_robotSwerveDrive.stopModules()); + // new JoystickButton(getDriverController(), XboxController.Button.kA.value) + // .whileHeld(() -> m_robotSwerveDrive.driveWithInput(0.0, 0.0, 0.2, true)) + // .whenReleased(() -> m_robotSwerveDrive.stopModules()); - new JoystickButton(getDriverController(), XboxController.Button.kB.value) - .whileHeld(new AimToCenter(m_robotTurret, m_robotVisionOdometry, m_robotSwerveDrive::getOdometry)) - .whenReleased(new InstantCommand(() -> m_robotTurret.runTurretWithInput(0.0), m_robotTurret)); + // new JoystickButton(getDriverController(), XboxController.Button.kB.value) + // .whileHeld(new AimToCenter(m_robotTurret, m_robotVisionOdometry, m_robotSwerveDrive::getOdometry)) + // .whenReleased(new InstantCommand(() -> m_robotTurret.runTurretWithInput(0.0), m_robotTurret)); // new JoystickButton(getDriverController(), XboxController.Button.kY.value) // .whenPressed(new Shoot(m_robotSwerveDrive, m_robotBoomBoom, m_robotTurret, m_robotHood, false)); // .whenReleased(new InstantCommand(() -> m_robotTurret.runTurretWithInput(0.0), m_robotTurret)) // .whenReleased(() -> m_robotSwerveDrive.stopModules()); - new JoystickButton(getDriverController(), XboxController.Button.kX.value) - .whileHeld(new TrackTarget(m_robotTurret, m_robotBoomBoom, m_robotHood, m_robotVisionOdometry)) - .whenReleased(new InstantCommand(() -> m_robotTurret.runTurretWithInput(0.0), m_robotTurret)) - .whenReleased(new InstantCommand(() -> m_robotHood.runHood(0.0), m_robotHood)) - .whenReleased(new InstantCommand(() -> m_robotBoomBoom.runDrumShooter(0.0), m_robotBoomBoom)); + // new JoystickButton(getDriverController(), XboxController.Button.kX.value) + // .whileHeld(new TrackTarget(m_robotTurret, m_robotBoomBoom, m_robotHood, m_robotVisionOdometry)) + // .whenReleased(new InstantCommand(() -> m_robotTurret.runTurretWithInput(0.0), m_robotTurret)) + // .whenReleased(new InstantCommand(() -> m_robotHood.runHood(0.0), m_robotHood)) + // .whenReleased(new InstantCommand(() -> m_robotBoomBoom.runDrumShooter(0.0), m_robotBoomBoom)); /* Operator Buttons */ new JoystickButton(getOperatorController(), XboxController.Button.kY.value) .whenPressed(new Shoot(m_robotSwerveDrive, m_robotBoomBoom, m_robotTurret, m_robotHood, false)); - //!.whenReleased(new InstantCommand(() -> m_robotTurret.runTurretWithInput(0.0), m_robotTurret)) - //!.whenReleased(() -> m_robotSwerveDrive.stopModules()); // new JoystickButton(getOperatorController(), XboxController.Button.kY.value) // .whileHeld(new RunCommand(() -> m_robotClaws.setOpen(true))); @@ -340,9 +338,10 @@ public class RobotContainer { //B > Shoot with Lime new JoystickButton(getOperatorController(), XboxController.Button.kA.value) - .whileHeld(new TrackTarget(m_robotTurret, m_robotBoomBoom, m_robotHood, m_robotVisionOdometry)) - .whenReleased(new InstantCommand(() -> m_robotVisionOdometry.setLEDs(false))) - .whenReleased(new RunCommand(() -> m_robotBoomBoom.runDrumShooterVelocityPID(0))); + // .whileHeld(new TrackTarget(m_robotTurret, m_robotBoomBoom, m_robotHood, m_robotVisionOdometry)) + // .whenReleased(new InstantCommand(() -> m_robotVisionOdometry.setLEDs(false))) + .whenPressed(new RunCommand(() -> m_robotBoomBoom.runDrumShooter(0.25))) + .whenReleased(new RunCommand(() -> m_robotBoomBoom.runDrumShooter(0.0))); // .whileHeld% /* Button Box Buttons */ @@ -414,11 +413,11 @@ public class RobotContainer { return null; } - public XboxController getDriverController() { + public static XboxController getDriverController() { return m_driverXbox; } - public XboxController getOperatorController() { + public static XboxController getOperatorController() { return m_operatorXbox; } diff --git a/src/main/java/frc4388/robot/commands/ShooterCommands/Shoot.java b/src/main/java/frc4388/robot/commands/ShooterCommands/Shoot.java index ffc761a..ecd88ab 100644 --- a/src/main/java/frc4388/robot/commands/ShooterCommands/Shoot.java +++ b/src/main/java/frc4388/robot/commands/ShooterCommands/Shoot.java @@ -9,6 +9,8 @@ import edu.wpi.first.math.geometry.Translation2d; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.CommandBase; import frc4388.robot.Constants; +import frc4388.robot.Robot; +import frc4388.robot.RobotContainer; import frc4388.robot.Constants.ShooterConstants; import frc4388.robot.Constants.SwerveDriveConstants; import frc4388.robot.subsystems.BoomBoom; @@ -160,7 +162,7 @@ public class Shoot extends CommandBase { this.turret.runTurretWithCustomPID(normOutput); // this.turret.m_boomBoomRotateMotor.set(normOutput); - this.swerve.driveWithInput(0, 0, normOutput * (this.swerveGains.kP/this.turretGains.kP), false); // ? should the output be field relative + this.swerve.driveWithInput(RobotContainer.getDriverController().getLeftX(), RobotContainer.getDriverController().getLeftY(), normOutput * (this.swerveGains.kP/this.turretGains.kP), true); // ? should the output be field relative if (this.toShoot) { this.hood.runAngleAdjustPID(this.targetHood); diff --git a/src/main/java/frc4388/robot/subsystems/BoomBoom.java b/src/main/java/frc4388/robot/subsystems/BoomBoom.java index c81fd38..8e8c334 100644 --- a/src/main/java/frc4388/robot/subsystems/BoomBoom.java +++ b/src/main/java/frc4388/robot/subsystems/BoomBoom.java @@ -189,7 +189,8 @@ public class BoomBoom extends SubsystemBase { * @param speed percent output form -1.0 to 1.0 */ public void runDrumShooter(double speed) { - m_shooterFalconLeft.set(TalonFXControlMode.PercentOutput, speed + speed2); + // m_shooterFalconLeft.set(TalonFXControlMode.PercentOutput, speed + speed2); + m_shooterFalconLeft.set(speed); SmartDashboard.putNumber("BoomBoom percent speed", speed + speed2); SmartDashboard.putNumber("BoomBoom current stator", m_shooterFalconLeft.getStatorCurrent()); SmartDashboard.putNumber("BoomBoom current supply", m_shooterFalconLeft.getSupplyCurrent());