Skip to content

Commit

Permalink
Merge pull request #8 from frc6506/fixingQuickTestCode
Browse files Browse the repository at this point in the history
Custom triggers & set values
  • Loading branch information
Icycoolbeand authored Mar 21, 2022
2 parents 3cf1017 + 8c365d5 commit e4dbfea
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 14 deletions.
11 changes: 7 additions & 4 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 =
Expand All @@ -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();
Expand All @@ -98,6 +99,8 @@ public RobotContainer() {
*/
private void configureButtonBindings() {
shootButton.whileHeld(spinFeedWheel);
intakeButton.whileActiveContinuous(spinIntakeWheel);
flywheelButton.whileActiveContinuous(spinFlywheel);
}

/**
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/frc/robot/TriggerL2Button.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
15 changes: 15 additions & 0 deletions src/main/java/frc/robot/TriggerR2Button.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/commands/ExampleCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/frc/robot/commands/SpinFlywheel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/frc/robot/commands/SpinIntakeWheel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit e4dbfea

Please sign in to comment.