This commit is contained in:
‮Zach Wilke
2021-10-11 18:00:20 -06:00
parent 50b8a632af
commit f95b02ecb2
5 changed files with 93 additions and 13 deletions
@@ -44,4 +44,14 @@ public final class Constants {
public static final int HORN_SOLENOID_ID = 0; public static final int HORN_SOLENOID_ID = 0;
//Todo: Change ID with new id on the robot //Todo: Change ID with new id on the robot
} }
public static final class ShooterConstants {
public static final int SHOOTER_SOLENOID_0_ID = 1;
public static final int SHOOTER_SOLENOID_1_ID = 2;
public static final int SHOOTER_SOLENOID_2_ID = 3;
public static final int SHOOTER_SOLENOID_3_ID = 4;
public static final int SHOOTER_SOLENOID_4_ID = 5;
public static final int SHOOTER_SOLENOID_5_ID = 6;
public static final int SHOOTER_SOLENOID_6_ID = 7;
public static final int SHOOTER_SOLENOID_7_ID = 8;
}
} }
@@ -43,6 +43,16 @@ public class RobotContainer {
private final XboxController m_driverXbox = new XboxController(OIConstants.XBOX_DRIVER_ID); private final XboxController m_driverXbox = new XboxController(OIConstants.XBOX_DRIVER_ID);
private final XboxController m_operatorXbox = new XboxController(OIConstants.XBOX_OPERATOR_ID); private final XboxController m_operatorXbox = new XboxController(OIConstants.XBOX_OPERATOR_ID);
private final Solenoid[] tubes = {
m_robotMap.ShooterSolenoid0,
m_robotMap.ShooterSolenoid1,
m_robotMap.ShooterSolenoid2,
m_robotMap.ShooterSolenoid3,
m_robotMap.ShooterSolenoid4,
m_robotMap.ShooterSolenoid5,
m_robotMap.ShooterSolenoid6,
m_robotMap.ShooterSolenoid7};
/** /**
* The container for the robot. Contains subsystems, OI devices, and commands. * The container for the robot. Contains subsystems, OI devices, and commands.
*/ */
@@ -67,19 +77,27 @@ public class RobotContainer {
private void configureButtonBindings() { private void configureButtonBindings() {
/* Driver Buttons */ /* Driver Buttons */
// test command to spin the robot while pressing A on the driver controller // test command to spin the robot while pressing A on the driver controller
new JoystickButton(getDriverJoystick(), XboxController.A_BUTTON) /*new JoystickButton(getDriverJoystick(), XboxController.A_BUTTON)
.whileHeld(() -> m_robotDrive.driveWithInput(0, 1)); .whileHeld(() -> m_robotDrive.driveWithInput(0, 1));
*/
/* Operator Buttons */ /* Operator Buttons */
// activates "Lit Mode" // activates ""🔥👌💯" Mode"™⁋
/*
new JoystickButton(getOperatorJoystick(), XboxController.A_BUTTON) new JoystickButton(getOperatorJoystick(), XboxController.A_BUTTON)
.whenPressed(() -> m_robotLED.setPattern(LEDPatterns.LAVA_RAINBOW)) .whenPressed(() -> m_robotLED.setPattern(LEDPatterns.LAVA_RAINBOW))
.whenReleased(() -> m_robotLED.setPattern(LEDConstants.DEFAULT_PATTERN)); .whenReleased(() -> m_robotLED.setPattern(LEDConstants.DEFAULT_PATTERN));
*/
// BWAHHHHHHHHHHHH // Fire horn
new JoystickButton(getOperatorJoystick(), XboxController.RIGHT_TRIGGER_AXIS) new JoystickButton(getOperatorJoystick(), XboxController.LEFT_TRIGGER_AXIS)
.whenPressed(() -> m_robotHorn.hornSet(true)) .whenPressed(() -> m_robotHorn.hornSet(true))
.whenReleased(() -> m_robotHorn.hornSet(false)); .whenReleased(() -> m_robotHorn.hornSet(false));
new JoystickButton(getOperatorJoystick(), XboxController.RIGHT_TRIGGER_AXIS)
.whenPressed(() -> new ShootYourShot(true)) /*Fire one per once triger*/
.whenReleased(() -> new ShootYourShot(false));
} }
/** /**
+11 -1
View File
@@ -70,6 +70,16 @@ public class RobotMap {
leftBackMotor.setInverted(InvertType.FollowMaster); leftBackMotor.setInverted(InvertType.FollowMaster);
rightBackMotor.setInverted(InvertType.FollowMaster); rightBackMotor.setInverted(InvertType.FollowMaster);
} }
/* Horn subsystem */
public final Solenoid HornSolenoid = new Solenoid(HornConstants.HORN_SOLENOID_ID); public final Solenoid HornSolenoid = new Solenoid(HornConstants.HORN_SOLENOID_ID);
/* Shooter subsystem */
public final Solenoid ShooterSolenoid0 = new Solenoid(ShooterConstants.SHOOTER_SOLENOID_0_ID);
public final Solenoid ShooterSolenoid1 = new Solenoid(ShooterConstants.SHOOTER_SOLENOID_1_ID);
public final Solenoid ShooterSolenoid2 = new Solenoid(ShooterConstants.SHOOTER_SOLENOID_2_ID);
public final Solenoid ShooterSolenoid3 = new Solenoid(ShooterConstants.SHOOTER_SOLENOID_3_ID);
public final Solenoid ShooterSolenoid4 = new Solenoid(ShooterConstants.SHOOTER_SOLENOID_4_ID);
public final Solenoid ShooterSolenoid5 = new Solenoid(ShooterConstants.SHOOTER_SOLENOID_5_ID);
public final Solenoid ShooterSolenoid6 = new Solenoid(ShooterConstants.SHOOTER_SOLENOID_6_ID);
public final Solenoid ShooterSolenoid7 = new Solenoid(ShooterConstants.SHOOTER_SOLENOID_7_ID);
} }
@@ -0,0 +1,41 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package frc4388.robot.commands;
import edu.wpi.first.wpilibj2.command.CommandBase;
public class ShootYourShot extends CommandBase {
private Solenoid[] m_solenoids = {};
private int counter;
/** Creates a new ShootYourShot
*. */
public ShootYourShot(Solenoid[] solenoids) {
m_solenoids = solenoids;
counter = 0;
}
// Called when the command is initially scheduled.
@Override
public void initialize() {}
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
ShootTube.ShootTubeSet(m_solenoids[counter]);
}
// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {
counter += 1;
}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}
@@ -10,12 +10,13 @@ import edu.wpi.first.wbilib.Solnoid;
public class ShootTube extends SubsystemBase { public class ShootTube extends SubsystemBase {
/** Creates a new ShootTube. */ /** Creates a new ShootTube. */
public ShootTube() { Solenoid m_solenoids;
m_solenoid = new solenoid(0); public ShootTube(Solenoid[] solenoids) {
m_solenoids = solenoids;
} }
public void ShootTubeset(boolean arg) { public void ShootTubeSet(boolean arg, Solenoid tube) {
m_solenoid.set(arg); tube.set(arg);
} }
@Override @Override