Skip to content

Commit

Permalink
moved auto path arrays to AutoHandlerFSM
Browse files Browse the repository at this point in the history
  • Loading branch information
AknA13 committed Dec 10, 2023
1 parent 47fae2c commit 89eb8a4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
14 changes: 2 additions & 12 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// Systems
import frc.robot.systems.FSMSystem;
import frc.robot.systems.AutoHandlerSystem;
import frc.robot.systems.AutoHandlerSystem.AutoFSMState;
import frc.robot.systems.AutoHandlerSystem.AutoPathIndex;

/**
* The VM is configured to automatically run this class, and to call the functions corresponding to
Expand All @@ -18,16 +18,6 @@
public class Robot extends TimedRobot {
private TeleopInput input;

//Predefined auto paths
private static final AutoFSMState[] PATH1 = new AutoFSMState[]{
AutoFSMState.STATE1, AutoFSMState.STATE2, AutoFSMState.STATE3};

private static final AutoFSMState[] PATH2 = new AutoFSMState[]{
AutoFSMState.STATE3, AutoFSMState.STATE2, AutoFSMState.STATE1};

private static final AutoFSMState[] PATH3 = new AutoFSMState[]{
AutoFSMState.STATE1, AutoFSMState.STATE3, AutoFSMState.STATE2};

// Systems
private FSMSystem fsmSystem;
private AutoHandlerSystem autoHandler;
Expand All @@ -49,7 +39,7 @@ public void robotInit() {
@Override
public void autonomousInit() {
System.out.println("-------- Autonomous Init --------");
autoHandler.reset(PATH1);
autoHandler.reset(AutoPathIndex.PATH1);
}

@Override
Expand Down
24 changes: 22 additions & 2 deletions src/main/java/frc/robot/systems/AutoHandlerSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ public enum AutoFSMState {
STATE2,
STATE3
}
public enum AutoPathIndex {
PATH1,
PATH2,
PATH3
}

/* ======================== Private variables ======================== */
//Contains the sequential list of states in the current auto path that must be executed
Expand All @@ -22,6 +27,15 @@ public enum AutoFSMState {
//FSM Systems that the autoHandlerFSM uses
private FSMSystem subsystem1;

//Predefined auto paths
private static final AutoFSMState[] PATH1 = new AutoFSMState[]{
AutoFSMState.STATE1, AutoFSMState.STATE2, AutoFSMState.STATE3};

private static final AutoFSMState[] PATH2 = new AutoFSMState[]{
AutoFSMState.STATE3, AutoFSMState.STATE2, AutoFSMState.STATE1};

private static final AutoFSMState[] PATH3 = new AutoFSMState[]{
AutoFSMState.STATE1, AutoFSMState.STATE3, AutoFSMState.STATE2};
/* ======================== Constructor ======================== */
/**
* Create FSMSystem and initialize to starting state.
Expand Down Expand Up @@ -50,10 +64,16 @@ public AutoFSMState getCurrentState() {
* Ex. if the robot is enabled, disabled, then reenabled.
* @param path the auto path to be executed
*/
public void reset(AutoFSMState[] path) {
public void reset(AutoPathIndex path) {
currentStateIndex = 0;
isCurrentStateFinished = false;
currentStateList = path;
if (path == AutoPathIndex.PATH1) {
currentStateList = PATH1;
} else if (path == AutoPathIndex.PATH2) {
currentStateList = PATH2;
} else if (path == AutoPathIndex.PATH3) {
currentStateList = PATH3;
}
}

/**
Expand Down

0 comments on commit 89eb8a4

Please sign in to comment.