Implement shooter readiness

Speed up shooter side detection for haptics
Change some variable names
This commit is contained in:
nathanrsxtn
2022-07-04 22:02:13 -06:00
parent 65cf0dd3a3
commit 74af4b2f2a
4 changed files with 98 additions and 76 deletions
+27 -27
View File
@@ -29,17 +29,17 @@ public class RobotContainer {
private final RobotMap m_robotMap = new RobotMap();
/* Subsystems */
private final Drive m_robotDrive = new Drive(m_robotMap.driveLeftLeaderMotor, m_robotMap.driveRightLeaderMotor, m_robotMap.driveBase);
private final Drive m_robotDrive = new Drive(m_robotMap.driveMotorLeftLeader, m_robotMap.driveMotorRightLeader, m_robotMap.driveBase);
private final Shooter m_robotShooterLowerLefterSolenoid = new Shooter(m_robotMap.shooterLowerLefterSolenoid);
private final Shooter m_robotShooterLowerLeftSolenoid = new Shooter(m_robotMap.shooterLowerLeftSolenoid);
private final Shooter m_robotShooterLowerRightSolenoid = new Shooter(m_robotMap.shooterLowerRightSolenoid);
private final Shooter m_robotShooterLowerRighterSolenoid = new Shooter(m_robotMap.shooterLowerRighterSolenoid);
private final Shooter m_robotShooterBottomLeftOuter = new Shooter(m_robotMap.shooterSolenoidBottomLeftOuter);
private final Shooter m_robotShooterBottomLeftInner = new Shooter(m_robotMap.shooterSolenoidBottomLeftInner);
private final Shooter m_robotShooterBottomRightInner = new Shooter(m_robotMap.shooterSolenoidBottomRightInner);
private final Shooter m_robotShooterBottomRightOuter = new Shooter(m_robotMap.shooterSolenoidBottomRightOuter);
private final Shooter m_robotShooterUpperLefterSolenoid = new Shooter(m_robotMap.shooterUpperLefterSolenoid);
private final Shooter m_robotShooterUpperLeftSolenoid = new Shooter(m_robotMap.shooterUpperLeftSolenoid);
private final Shooter m_robotShooterUpperRightSolenoid = new Shooter(m_robotMap.shooterUpperRightSolenoid);
private final Shooter m_robotShooterUpperRighterSolenoid = new Shooter(m_robotMap.shooterUpperRighterSolenoid);
private final Shooter m_robotShooterTopLeftOuter = new Shooter(m_robotMap.shooterSolenoidTopLeftOuter);
private final Shooter m_robotShooterTopLeftInner = new Shooter(m_robotMap.shooterSolenoidTopLeftInner);
private final Shooter m_robotShooterTopRightInner = new Shooter(m_robotMap.shooterSolenoidTopRightInner);
private final Shooter m_robotShooterTopRightOuter = new Shooter(m_robotMap.shooterSolenoidTopRightOuter);
private final Horn m_robotHorn = new Horn(m_robotMap.hornSolenoid);
@@ -64,23 +64,23 @@ public class RobotContainer {
* {@link edu.wpi.first.wpilibj2.command.button.JoystickButton}.
*/
private void configureButtonBindings() {
// Y Button: Fire Upper Lefter Shooter
new JoystickButton(getController(), XboxController.Button.kY.value).whenPressed(putToDashboard("Y", new InstantCommand(() -> fireShooterWithFeedback(m_robotShooterUpperLefterSolenoid)).withName("Fire Upper Lefter")));
// B Button: Fire Upper Right Shooter
new JoystickButton(getController(), XboxController.Button.kB.value).whenPressed(putToDashboard("B", new InstantCommand(() -> fireShooterWithFeedback(m_robotShooterUpperRightSolenoid)).withName("Fire Upper Right")));
// A Button: Fire Upper Righter Shooter
new JoystickButton(getController(), XboxController.Button.kA.value).whenPressed(putToDashboard("A", new InstantCommand(() -> fireShooterWithFeedback(m_robotShooterUpperRighterSolenoid)).withName("Fire Upper Righter")));
// X Button: Fire Upper Left Shooter
new JoystickButton(getController(), XboxController.Button.kX.value).whenPressed(putToDashboard("X", new InstantCommand(() -> fireShooterWithFeedback(m_robotShooterUpperLeftSolenoid)).withName("Fire Upper Left")));
// Y Button: Fire Top Lefter Shooter
new JoystickButton(getController(), XboxController.Button.kY.value).whenPressed(putToDashboard("Y", new InstantCommand(() -> fireShooterWithFeedback(m_robotShooterTopLeftOuter)).withName("Fire Top Lefter")));
// B Button: Fire Top Right Shooter
new JoystickButton(getController(), XboxController.Button.kB.value).whenPressed(putToDashboard("B", new InstantCommand(() -> fireShooterWithFeedback(m_robotShooterTopRightInner)).withName("Fire Top Right")));
// A Button: Fire Top Righter Shooter
new JoystickButton(getController(), XboxController.Button.kA.value).whenPressed(putToDashboard("A", new InstantCommand(() -> fireShooterWithFeedback(m_robotShooterTopRightOuter)).withName("Fire Top Righter")));
// X Button: Fire Top Left Shooter
new JoystickButton(getController(), XboxController.Button.kX.value).whenPressed(putToDashboard("X", new InstantCommand(() -> fireShooterWithFeedback(m_robotShooterTopLeftInner)).withName("Fire Top Left")));
// D-Pad Up: Fire Lower Lefter Shooter
new POVButton(getController(), 0).whenPressed(putToDashboard("Up", new InstantCommand(() -> fireShooterWithFeedback(m_robotShooterLowerLefterSolenoid)).withName("Fire Lower Lefter")));
// D-Pad Right: Fire Lower Right Shooter
new POVButton(getController(), 90).whenPressed(putToDashboard("Right", new InstantCommand(() -> fireShooterWithFeedback(m_robotShooterLowerRightSolenoid)).withName("Fire Lower Right")));
// D-Pad Left: Fire Lower Righter Shooter
new POVButton(getController(), 180).whenPressed(putToDashboard("Down", new InstantCommand(() -> fireShooterWithFeedback(m_robotShooterLowerRighterSolenoid)).withName("Fire Lower Righter")));
// D-Pad Up: Fire Lower Left Shooter
new POVButton(getController(), 270).whenPressed(putToDashboard("Left", new InstantCommand(() -> fireShooterWithFeedback(m_robotShooterLowerLeftSolenoid)).withName("Fire Lower Left")));
// D-Pad Up: Fire Bottom Lefter Shooter
new POVButton(getController(), 0).whenPressed(putToDashboard("Up", new InstantCommand(() -> fireShooterWithFeedback(m_robotShooterBottomLeftOuter)).withName("Fire Bottom Lefter")));
// D-Pad Right: Fire Bottom Right Shooter
new POVButton(getController(), 90).whenPressed(putToDashboard("Right", new InstantCommand(() -> fireShooterWithFeedback(m_robotShooterBottomRightInner)).withName("Fire Bottom Right")));
// D-Pad Left: Fire Bottom Righter Shooter
new POVButton(getController(), 180).whenPressed(putToDashboard("Down", new InstantCommand(() -> fireShooterWithFeedback(m_robotShooterBottomRightOuter)).withName("Fire Bottom Righter")));
// D-Pad Up: Fire Bottom Left Shooter
new POVButton(getController(), 270).whenPressed(putToDashboard("Left", new InstantCommand(() -> fireShooterWithFeedback(m_robotShooterBottomLeftInner)).withName("Fire Bottom Left")));
// Right Bumper: Sound Horn
new JoystickButton(getController(), XboxController.Button.kRightBumper.value).whenPressed(() -> m_robotHorn.set(true)).whenReleased(() -> m_robotHorn.set(false));
@@ -94,8 +94,8 @@ public class RobotContainer {
}
private void fireShooterWithFeedback(Shooter shooter) {
boolean fired = shooter.set(true);
RumbleType rumbleType = shooter.getName().contains("Left") ? RumbleType.kLeftRumble : RumbleType.kRightRumble;
boolean fired = shooter.fire();
RumbleType rumbleType = shooter.getName().indexOf('L', 13) >= 0 ? RumbleType.kLeftRumble : RumbleType.kRightRumble;
double value = fired ? 0.3 : 0.6;
double duration = fired ? 0.3 : 0.4;
CommandGroupBase.sequence(new InstantCommand(() -> getController().setRumble(rumbleType, value)), new WaitCommand(duration), new InstantCommand(() -> getController().setRumble(rumbleType, 0.0))).schedule();