Skip to content

Commit

Permalink
made stop shooter state🦟™️
Browse files Browse the repository at this point in the history
  • Loading branch information
FRCTeam3255-Shared-K1-10 committed Dec 7, 2024
1 parent 65cb03e commit 190ab76
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 8 deletions.
11 changes: 5 additions & 6 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,18 @@ private void configureBindings() {
() -> subStateMachine.tryState(RobotState.SHOOT)))
.onFalse(Commands.deferredProxy(
() -> subStateMachine.tryState(RobotState.NONE)));

// prepShooter -> hasGP

m_driverController.btn_B
.onTrue(Commands.deferredProxy(
() -> subStateMachine.tryState(RobotState.HAS_GP)));


// hasGP

hasGamePieceTrigger
.whileTrue(Commands.deferredProxy(
() -> subStateMachine.tryState(RobotState.HAS_GP)));

//StopShooter
m_driverController.btn_X
.onTrue(Commands.deferredProxy(
() -> subStateMachine.tryState(RobotState.STOP_SHOOTER) ));

}

Expand Down
46 changes: 46 additions & 0 deletions src/main/java/frc/robot/commands/states/StopShooter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// 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.commands.states;

import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.Shooter;
import frc.robot.subsystems.StateMachine;
import frc.robot.subsystems.StateMachine.RobotState;

public class StopShooter extends Command {
/** Creates a new StopShooter. */
Shooter globalShooter;
StateMachine globalStateMachine;
public StopShooter(StateMachine passedStateMachine, Shooter passedShooter) {
// Use addRequirements() here to declare subsystem dependencies.
globalStateMachine = passedStateMachine;
addRequirements(globalStateMachine);
globalShooter = passedShooter;


}

// Called when the command is initially scheduled.
@Override
public void initialize() {

globalStateMachine.setState(RobotState.STOP_SHOOTER);
globalShooter.setShooterNuetralOutput();
}

// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {}

// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {}

// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}
14 changes: 12 additions & 2 deletions src/main/java/frc/robot/subsystems/StateMachine.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.commands.*;
import frc.robot.commands.states.StopShooter;

public class StateMachine extends SubsystemBase {
/** Creates a new StateMachine. */
Expand Down Expand Up @@ -39,6 +40,7 @@ public enum RobotState {
NONE,
PREP_SHOOTER,
SHOOT,
STOP_SHOOTER,
}

public void setState(RobotState state) {
Expand Down Expand Up @@ -68,7 +70,7 @@ public Command tryState(RobotState desiredState) {
switch (currentState) {
case INTAKE_HOPPER:
case SHOOT:
case PREP_SHOOTER:
case STOP_SHOOTER:
case NONE:

return new HasGP(globalStager, globalShooter, globalStateMachine, globalLED);
Expand Down Expand Up @@ -99,7 +101,14 @@ public Command tryState(RobotState desiredState) {
return new Shoot(globalStateMachine, globalStager, globalShooter, globalLED);
}
break;
case NONE:
case STOP_SHOOTER:
switch (currentState) {
case PREP_SHOOTER:
return new StopShooter(globalStateMachine, globalShooter);

}
break;
case NONE:
switch (currentState) {
case EJECT_INTAKE:
case EJECT_SHOOTER:
Expand All @@ -109,6 +118,7 @@ public Command tryState(RobotState desiredState) {
return new none(globalStateMachine, globalHopper, globalIntake, globalShooter, globalStager, globalLED);
}
break;

// default:
// return new None(globalHopper, globalIntake, globalShooter, globalStager);
}
Expand Down

0 comments on commit 190ab76

Please sign in to comment.