Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 195 additions & 0 deletions src/main/java/frc/robot/subsystems/StateMachine.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.commands.states.EjectingHopper;
import frc.robot.commands.states.Intaking;
import frc.robot.commands.states.None;
import frc.robot.commands.states.RetractIntake;
import frc.robot.commands.states.ReversingShooter;
import frc.robot.commands.states.*;
import frc.robot.commands.states.preps.*;

@Logged
public class StateMachine extends SubsystemBase {
Expand All @@ -22,6 +28,7 @@ public StateMachine() {

public void setRobotState(RobotState robotState) {
currentRobotState = robotState;

}

public RobotState getRobotState() {
Expand All @@ -33,9 +40,197 @@ public Command tryState(RobotState desiredState) {
case NONE:
switch (currentRobotState) {
case NONE:
case INTAKING:
case REVERSING_SHOOTER:
case SHOOTING:
case EJECTING_HOPPER:
Comment thread
Wu-Fan-529 marked this conversation as resolved.
return new None();
}
break;
case INTAKING:
switch (currentRobotState) {
case NONE:
case RETRACT_INTAKE:
case PREP_ANYWHERE:
case PREP_CORNER:
case PREP_HUB:
case PREP_NEUTRAL_TO_ALLIANCE:
case PREP_OPPONENT_TO_ALLIANCE:
case PREP_TOWER:
case PREP_TRENCH:
return new Intaking();
}
break;
case SHOOTING:
switch (currentRobotState) {
case RETRACT_INTAKE:
case PREP_ANYWHERE:
case PREP_CORNER:
case PREP_HUB:
case PREP_NEUTRAL_TO_ALLIANCE:
case PREP_OPPONENT_TO_ALLIANCE:
case PREP_TOWER:
case PREP_TRENCH:
return new Shooting();
}
case RETRACT_INTAKE:
switch (currentRobotState) {
case NONE:
case SHOOTING:
case EJECTING_HOPPER:
case REVERSING_SHOOTER:
case INTAKING:
case PREP_ANYWHERE:
case PREP_CORNER:
case PREP_HUB:
case PREP_NEUTRAL_TO_ALLIANCE:
case PREP_OPPONENT_TO_ALLIANCE:
case PREP_TRENCH:

return new RetractIntake();
}
break;
case REVERSING_SHOOTER:
switch (currentRobotState) {
case NONE:
Comment thread
Wu-Fan-529 marked this conversation as resolved.
case RETRACT_INTAKE:
case PREP_ANYWHERE:
case PREP_CORNER:
case PREP_HUB:
case PREP_NEUTRAL_TO_ALLIANCE:
case PREP_OPPONENT_TO_ALLIANCE:
case PREP_TOWER:
case PREP_TRENCH:
return new ReversingShooter();
}
break;
case PREP_ANYWHERE:
switch (currentRobotState) {
case NONE:
case RETRACT_INTAKE:
case PREP_ANYWHERE:
case PREP_CORNER:
case PREP_HUB:
case PREP_NEUTRAL_TO_ALLIANCE:
case PREP_OPPONENT_TO_ALLIANCE:
case PREP_TOWER:
case PREP_TRENCH:
case REVERSING_SHOOTER:
case INTAKING:
return new PrepAnywhere();
}
break;
case PREP_HUB:
switch (currentRobotState) {
case NONE:
case RETRACT_INTAKE:
case PREP_ANYWHERE:
case PREP_CORNER:
case PREP_HUB:
case PREP_NEUTRAL_TO_ALLIANCE:
case PREP_OPPONENT_TO_ALLIANCE:
case PREP_TOWER:
case PREP_TRENCH:
case REVERSING_SHOOTER:
Comment thread
Wu-Fan-529 marked this conversation as resolved.
case INTAKING:
return new PrepHub();
}
break;
case PREP_CORNER:
switch (currentRobotState) {
case NONE:
case RETRACT_INTAKE:
case PREP_ANYWHERE:
case PREP_CORNER:
case PREP_HUB:
case PREP_NEUTRAL_TO_ALLIANCE:
case PREP_OPPONENT_TO_ALLIANCE:
case PREP_TOWER:
case PREP_TRENCH:
case REVERSING_SHOOTER:
case INTAKING:
return new PrepCorner();
}
break;
case PREP_NEUTRAL_TO_ALLIANCE:
switch (currentRobotState) {
case NONE:
case RETRACT_INTAKE:
case PREP_ANYWHERE:
case PREP_CORNER:
case PREP_HUB:
case PREP_NEUTRAL_TO_ALLIANCE:
case PREP_OPPONENT_TO_ALLIANCE:
case PREP_TOWER:
case PREP_TRENCH:
case REVERSING_SHOOTER:
case INTAKING:
return new PrepNeutralToAlliance();
}
break;
case PREP_OPPONENT_TO_ALLIANCE:
switch (currentRobotState) {
case NONE:
case RETRACT_INTAKE:
case PREP_ANYWHERE:
case PREP_CORNER:
case PREP_HUB:
case PREP_NEUTRAL_TO_ALLIANCE:
case PREP_OPPONENT_TO_ALLIANCE:
case PREP_TOWER:
case PREP_TRENCH:
case REVERSING_SHOOTER:
case INTAKING:
return new PrepOpponentToAlliance();
}
break;
case PREP_TOWER:
switch (currentRobotState) {
case NONE:
case RETRACT_INTAKE:
case PREP_ANYWHERE:
case PREP_CORNER:
case PREP_HUB:
case PREP_NEUTRAL_TO_ALLIANCE:
case PREP_OPPONENT_TO_ALLIANCE:
case PREP_TOWER:
case PREP_TRENCH:
case REVERSING_SHOOTER:
case INTAKING:
return new PrepTower();
}
break;
case PREP_TRENCH:
switch (currentRobotState) {
Comment thread
Wu-Fan-529 marked this conversation as resolved.
case NONE:
case RETRACT_INTAKE:
case PREP_ANYWHERE:
case PREP_CORNER:
case PREP_HUB:
case PREP_NEUTRAL_TO_ALLIANCE:
case PREP_OPPONENT_TO_ALLIANCE:
case PREP_TOWER:
case PREP_TRENCH:
case REVERSING_SHOOTER:
case INTAKING:
return new PrepTrench();
}
break;
case EJECTING_HOPPER:
switch (currentRobotState) {
case NONE:
case RETRACT_INTAKE:
case PREP_ANYWHERE:
case PREP_CORNER:
case PREP_HUB:
case PREP_NEUTRAL_TO_ALLIANCE:
case PREP_OPPONENT_TO_ALLIANCE:
case PREP_TOWER:
case PREP_TRENCH:
case INTAKING:
return new EjectingHopper();
}

Comment thread
Wu-Fan-529 marked this conversation as resolved.
}
return Commands
.print("ITS SO OVER D: Invalid State Provided, Blame Eli. Attempted to go to: " + desiredState.toString()
Expand Down
Loading