From 7dc84b09a77d5fbeebd2335aeee335a22d49f3ce Mon Sep 17 00:00:00 2001 From: Cobblestone Date: Fri, 5 Jan 2024 20:54:37 -0500 Subject: [PATCH] Add intake subsystem to RobotContainer.java (#60) # Description This pull request adds the intake subsystem to the robot container, allowing the intake to be used. Scoring states have also been updated to be publicly accessible Fixes #53 ## Type of change Please delete options that are not relevant. - [X] New feature (non-breaking change which adds functionality) # Checklist: - [X] My code follows the style guidelines of this project - [X] I have performed a self-review of my code - [ ] I have commented my code, particularly in hard-to-understand areas - [X] I have made corresponding changes to the documentation, if any - [X] My changes generate no new warnings - [X] I have performed tests that prove my fix is effective or that my feature works, if necessary - [X] New and existing unit tests pass locally with my changes --------- Co-authored-by: github-actions <> --- src/main/java/frc/robot/RobotContainer.java | 18 ++++++++++++++++++ .../subsystems/intake/IntakeSubsystem.java | 1 - .../subsystems/intake/states/ScoringState.java | 3 --- .../intake/states/scoring/cone/HighCone.java | 2 +- .../states/scoring/cone/HighConeAuto.java | 2 +- .../intake/states/scoring/cone/MidCone.java | 2 +- .../states/scoring/cone/MidConeTipped.java | 2 +- .../intake/states/scoring/cube/HighCube.java | 2 +- .../states/scoring/cube/HighCubeAuto.java | 2 +- .../intake/states/scoring/cube/MidCube.java | 2 +- .../states/scoring/cube/MidCubeAuto.java | 2 +- .../intake/states/scoring/level/Low.java | 2 +- .../intake/states/scoring/level/LowAuto.java | 2 +- 13 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index d786c88..36551bc 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -7,10 +7,14 @@ import com.ctre.phoenix6.mechanisms.swerve.SwerveModule.DriveRequestType; import com.ctre.phoenix6.mechanisms.swerve.SwerveRequest; +import edu.wpi.first.wpilibj.PowerDistribution; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.InstantCommand; import frc.robot.subsystems.drive.DriveConstants; import frc.robot.subsystems.drive.DriveSubsystem; +import frc.robot.subsystems.intake.IntakeSubsystem; +import frc.robot.subsystems.intake.enums.IntakeGamepiece; +import frc.robot.subsystems.intake.states.scoring.cone.HighCone; import frc.robot.subsystems.led.LEDSubsystem; public class RobotContainer { @@ -20,6 +24,9 @@ private class Controller { } private final LEDSubsystem ledSubsystem; + private final IntakeSubsystem intakeSubsystem; + + private final PowerDistribution pdp = new PowerDistribution(); // Set up the base for the drive and drivetrain final DriveSubsystem drivetrain = DriveConstants.DriveTrain; @@ -57,11 +64,22 @@ private void configureBindings() { // (left) ) .ignoringDisable(true)); + + Controller.operator + .yellowButton() + .toggleOnTrue(intakeSubsystem.intakeHoldCommand(IntakeGamepiece.CONE)); + Controller.operator + .blueButton() + .toggleOnTrue(intakeSubsystem.intakeHoldCommand(IntakeGamepiece.CUBE)); + Controller.operator + .greenButton() + .toggleOnTrue(intakeSubsystem.intakeScoreCommand(new HighCone(), IntakeGamepiece.CONE)); } public RobotContainer() { configureBindings(); ledSubsystem = new LEDSubsystem(); + intakeSubsystem = new IntakeSubsystem(pdp); } public Command getAutonomousCommand() { diff --git a/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java b/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java index d4938b9..ad21f11 100644 --- a/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java +++ b/src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java @@ -57,7 +57,6 @@ public Command stopIntakeCommand() { * @param expectedPiece the type of gamepiece to expect when scoring * @return a command that scores a gamepiece */ - public Command intakeScoreCommand(ScoringState scoringState, IntakeGamepiece expectedGamepiece) { SmartDashboard.putString("INTAKE STATE", scoringState.getStateName()); diff --git a/src/main/java/frc/robot/subsystems/intake/states/ScoringState.java b/src/main/java/frc/robot/subsystems/intake/states/ScoringState.java index 34391fa..0326901 100644 --- a/src/main/java/frc/robot/subsystems/intake/states/ScoringState.java +++ b/src/main/java/frc/robot/subsystems/intake/states/ScoringState.java @@ -1,9 +1,7 @@ package frc.robot.subsystems.intake.states; - import frc.robot.subsystems.intake.enums.IntakeGamepiece; - public abstract class ScoringState { double outtakeSpeed; double cubeOuttakeSpeed; @@ -48,7 +46,6 @@ public String getStateName() { * Gets the outtake speed for the scoring state depending on the gamepiece that is expected to be * scored * - * @param expectedGamepiece The gamepiece that is expected to be scored * @return The outtake speed for the scoring state */ diff --git a/src/main/java/frc/robot/subsystems/intake/states/scoring/cone/HighCone.java b/src/main/java/frc/robot/subsystems/intake/states/scoring/cone/HighCone.java index 2bbe772..b8a2032 100644 --- a/src/main/java/frc/robot/subsystems/intake/states/scoring/cone/HighCone.java +++ b/src/main/java/frc/robot/subsystems/intake/states/scoring/cone/HighCone.java @@ -5,7 +5,7 @@ public class HighCone extends ScoringState { - HighCone() { + public HighCone() { super(IntakeConstants.OuttakeSpeeds.HIGH_CONE, "High Cone"); } } diff --git a/src/main/java/frc/robot/subsystems/intake/states/scoring/cone/HighConeAuto.java b/src/main/java/frc/robot/subsystems/intake/states/scoring/cone/HighConeAuto.java index f36850d..95c87c5 100644 --- a/src/main/java/frc/robot/subsystems/intake/states/scoring/cone/HighConeAuto.java +++ b/src/main/java/frc/robot/subsystems/intake/states/scoring/cone/HighConeAuto.java @@ -5,7 +5,7 @@ public class HighConeAuto extends ScoringState { - HighConeAuto() { + public HighConeAuto() { super(IntakeConstants.OuttakeSpeeds.HIGH_CONE_AUTO, "High Cone Auto"); } } diff --git a/src/main/java/frc/robot/subsystems/intake/states/scoring/cone/MidCone.java b/src/main/java/frc/robot/subsystems/intake/states/scoring/cone/MidCone.java index 2e582e2..4bc00f9 100644 --- a/src/main/java/frc/robot/subsystems/intake/states/scoring/cone/MidCone.java +++ b/src/main/java/frc/robot/subsystems/intake/states/scoring/cone/MidCone.java @@ -5,7 +5,7 @@ public class MidCone extends ScoringState { - MidCone() { + public MidCone() { super(IntakeConstants.OuttakeSpeeds.MID_CONE, "Mid Cone"); } } diff --git a/src/main/java/frc/robot/subsystems/intake/states/scoring/cone/MidConeTipped.java b/src/main/java/frc/robot/subsystems/intake/states/scoring/cone/MidConeTipped.java index f545e37..6be2495 100644 --- a/src/main/java/frc/robot/subsystems/intake/states/scoring/cone/MidConeTipped.java +++ b/src/main/java/frc/robot/subsystems/intake/states/scoring/cone/MidConeTipped.java @@ -5,7 +5,7 @@ public class MidConeTipped extends ScoringState { - MidConeTipped() { + public MidConeTipped() { super(IntakeConstants.OuttakeSpeeds.MID_CONE_TIPPED, "Mid Cone Tipped"); } } diff --git a/src/main/java/frc/robot/subsystems/intake/states/scoring/cube/HighCube.java b/src/main/java/frc/robot/subsystems/intake/states/scoring/cube/HighCube.java index 3f1ce58..b260fd8 100644 --- a/src/main/java/frc/robot/subsystems/intake/states/scoring/cube/HighCube.java +++ b/src/main/java/frc/robot/subsystems/intake/states/scoring/cube/HighCube.java @@ -5,7 +5,7 @@ public class HighCube extends ScoringState { - HighCube() { + public HighCube() { super(IntakeConstants.OuttakeSpeeds.HIGH_CUBE, "High Cube"); } } diff --git a/src/main/java/frc/robot/subsystems/intake/states/scoring/cube/HighCubeAuto.java b/src/main/java/frc/robot/subsystems/intake/states/scoring/cube/HighCubeAuto.java index 0592eed..65d5964 100644 --- a/src/main/java/frc/robot/subsystems/intake/states/scoring/cube/HighCubeAuto.java +++ b/src/main/java/frc/robot/subsystems/intake/states/scoring/cube/HighCubeAuto.java @@ -5,7 +5,7 @@ public class HighCubeAuto extends ScoringState { - HighCubeAuto() { + public HighCubeAuto() { super(IntakeConstants.OuttakeSpeeds.HIGH_CUBE, "High Cube Auto"); } } diff --git a/src/main/java/frc/robot/subsystems/intake/states/scoring/cube/MidCube.java b/src/main/java/frc/robot/subsystems/intake/states/scoring/cube/MidCube.java index 40758a9..dea9eac 100644 --- a/src/main/java/frc/robot/subsystems/intake/states/scoring/cube/MidCube.java +++ b/src/main/java/frc/robot/subsystems/intake/states/scoring/cube/MidCube.java @@ -5,7 +5,7 @@ public class MidCube extends ScoringState { - MidCube() { + public MidCube() { super(IntakeConstants.OuttakeSpeeds.MID_CUBE, "Mid Cube"); } } diff --git a/src/main/java/frc/robot/subsystems/intake/states/scoring/cube/MidCubeAuto.java b/src/main/java/frc/robot/subsystems/intake/states/scoring/cube/MidCubeAuto.java index 022b8e6..75cc262 100644 --- a/src/main/java/frc/robot/subsystems/intake/states/scoring/cube/MidCubeAuto.java +++ b/src/main/java/frc/robot/subsystems/intake/states/scoring/cube/MidCubeAuto.java @@ -5,7 +5,7 @@ public class MidCubeAuto extends ScoringState { - MidCubeAuto() { + public MidCubeAuto() { super(IntakeConstants.OuttakeSpeeds.MID_CUBE, "Mid Cube Auto"); } } diff --git a/src/main/java/frc/robot/subsystems/intake/states/scoring/level/Low.java b/src/main/java/frc/robot/subsystems/intake/states/scoring/level/Low.java index daad78d..de19cf1 100644 --- a/src/main/java/frc/robot/subsystems/intake/states/scoring/level/Low.java +++ b/src/main/java/frc/robot/subsystems/intake/states/scoring/level/Low.java @@ -5,7 +5,7 @@ public class Low extends ScoringState { - Low() { + public Low() { super(IntakeConstants.OuttakeSpeeds.LOW_CUBE, IntakeConstants.OuttakeSpeeds.LOW_CONE, "Low"); } } diff --git a/src/main/java/frc/robot/subsystems/intake/states/scoring/level/LowAuto.java b/src/main/java/frc/robot/subsystems/intake/states/scoring/level/LowAuto.java index 5135b0b..cf1cc1f 100644 --- a/src/main/java/frc/robot/subsystems/intake/states/scoring/level/LowAuto.java +++ b/src/main/java/frc/robot/subsystems/intake/states/scoring/level/LowAuto.java @@ -5,7 +5,7 @@ public class LowAuto extends ScoringState { - LowAuto() { + public LowAuto() { super( IntakeConstants.OuttakeSpeeds.LOW_CUBE_AUTO, IntakeConstants.OuttakeSpeeds.LOW_CONE_AUTO,