diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index a341959..5ffd297 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -44,6 +44,8 @@ public class RobotContainer { // https://first.wpi.edu/wpilib/allwpilib/docs/release/java/edu/wpi/first/wpilibj/XboxController.Button.html,and https://first.wpi.edu/wpilib/allwpilib/docs/release/java/src-html/edu/wpi/first/wpilibj/XboxController.Button.html#line.24 public static final JoystickButton shootButton = new JoystickButton(controller, Constants.JOYSTICK_BUTTON_SHOOT_ID); + public static final TriggerL2Button intakeButton = new TriggerL2Button(); + public static final TriggerR2Button flywheelButton = new TriggerR2Button(); // Subystems public static Drivetrain drivetrain = new Drivetrain(); // Drivetrain @@ -65,8 +67,9 @@ public class RobotContainer { // Shintake public static ExtendInAndOut extendInAndOut = new ExtendInAndOut(inAndOut2); // Extend linear actuator for Shintake Assybemly - public static SpinIntakeWheel spinIntakeWheel = new SpinIntakeWheel(intake); // Spin intake wheel - public static SpinFeedWheel spinFeedWheel = + public static final SpinIntakeWheel spinIntakeWheel = + new SpinIntakeWheel(intake); // Spin intake wheel + public static final SpinFeedWheel spinFeedWheel = new SpinFeedWheel(outtake); // Spin feed wheel for shooter public static SpinFlywheel spinFlywheel = new SpinFlywheel(outtake); // Spin flywheel public static BringInOutAndIn bringInOutAndIn = @@ -83,8 +86,6 @@ public class RobotContainer { public RobotContainer() { // setting default commands drivetrain.setDefaultCommand(arcadeDrive); - intake.setDefaultCommand(spinIntakeWheel); // TODO: Change to trigger - outtake.setDefaultCommand(spinFlywheel); // TODO: Change to trigger // Configure the button bindings configureButtonBindings(); @@ -98,6 +99,8 @@ public RobotContainer() { */ private void configureButtonBindings() { shootButton.whileHeld(spinFeedWheel); + intakeButton.whileActiveContinuous(spinIntakeWheel); + flywheelButton.whileActiveContinuous(spinFlywheel); } /** diff --git a/src/main/java/frc/robot/TriggerL2Button.java b/src/main/java/frc/robot/TriggerL2Button.java new file mode 100644 index 0000000..655bdf9 --- /dev/null +++ b/src/main/java/frc/robot/TriggerL2Button.java @@ -0,0 +1,15 @@ +// 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 frc.robot; + +import edu.wpi.first.wpilibj2.command.button.Trigger; + +/** Add your docs here. */ +public class TriggerL2Button extends Trigger { + @Override + public boolean get() { + return RobotContainer.controller.getRawAxis(3) > 0.5; + } +} diff --git a/src/main/java/frc/robot/TriggerR2Button.java b/src/main/java/frc/robot/TriggerR2Button.java new file mode 100644 index 0000000..238be50 --- /dev/null +++ b/src/main/java/frc/robot/TriggerR2Button.java @@ -0,0 +1,15 @@ +// 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 frc.robot; + +import edu.wpi.first.wpilibj2.command.button.Trigger; + +/** Add your docs here. */ +public class TriggerR2Button extends Trigger { + @Override + public boolean get() { + return RobotContainer.controller.getRawAxis(2) > 0.5; + } +} diff --git a/src/main/java/frc/robot/commands/ExampleCommand.java b/src/main/java/frc/robot/commands/ExampleCommand.java index 5150ec7..1f3b8da 100644 --- a/src/main/java/frc/robot/commands/ExampleCommand.java +++ b/src/main/java/frc/robot/commands/ExampleCommand.java @@ -9,7 +9,7 @@ /** An example command that uses an example subsystem. */ public class ExampleCommand extends CommandBase { - @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) + @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField", "unused"}) // :) Now its gone :) private final ExampleSubsystem m_subsystem; /** diff --git a/src/main/java/frc/robot/commands/SpinFlywheel.java b/src/main/java/frc/robot/commands/SpinFlywheel.java index 4f452fb..563c110 100644 --- a/src/main/java/frc/robot/commands/SpinFlywheel.java +++ b/src/main/java/frc/robot/commands/SpinFlywheel.java @@ -5,7 +5,6 @@ package frc.robot.commands; import edu.wpi.first.wpilibj2.command.CommandBase; -import frc.robot.RobotContainer; import frc.robot.subsystems.Outtake; public class SpinFlywheel extends CommandBase { @@ -25,14 +24,14 @@ public void initialize() {} // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - // outtake.spinFlywheel(.1); - outtake.spinFlywheel( - RobotContainer.controller.getRawAxis(2)); // TODO Chagne to trigger and set speed + outtake.spinFlywheel(.75); } // Called once the command ends or is interrupted. @Override - public void end(boolean interrupted) {} + public void end(boolean interrupted) { + outtake.spinFlywheel(0); + } // Returns true when the command should end. @Override diff --git a/src/main/java/frc/robot/commands/SpinIntakeWheel.java b/src/main/java/frc/robot/commands/SpinIntakeWheel.java index 2138e6d..9567c73 100644 --- a/src/main/java/frc/robot/commands/SpinIntakeWheel.java +++ b/src/main/java/frc/robot/commands/SpinIntakeWheel.java @@ -5,7 +5,6 @@ package frc.robot.commands; import edu.wpi.first.wpilibj2.command.CommandBase; -import frc.robot.RobotContainer; import frc.robot.subsystems.Intake; public class SpinIntakeWheel extends CommandBase { @@ -26,13 +25,14 @@ public void initialize() {} // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - intake.spinIntakeWheel( - RobotContainer.controller.getRawAxis(3)); // TODO Chagne to trigger and set speed + intake.spinIntakeWheel(0.5); } // Called once the command ends or is interrupted. @Override - public void end(boolean interrupted) {} + public void end(boolean interrupted) { + intake.spinIntakeWheel(0); + } // Returns true when the command should end. @Override