-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71150ca
commit c97113a
Showing
2 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/main/java/frc/robot/statemachines/ClimbStateMachine.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package frc.robot.statemachines; | ||
|
||
import java.lang.invoke.MethodHandles.Lookup.ClassOption; | ||
|
||
import org.littletonrobotics.junction.Logger; | ||
|
||
import frc.robot.subsystems.elevator.Elevator; | ||
import frc.robot.subsystems.pivot.Pivot; | ||
import frc.robot.subsystems.shooter.Shooter; | ||
|
||
public class ClimbStateMachine { | ||
private final Elevator elevator; | ||
private final Pivot pivot; | ||
private final Shooter shooter; | ||
|
||
public ClimbStateMachine(Elevator elevator, Shooter shooter, Pivot pivot) { | ||
this.elevator = elevator; | ||
this.pivot = pivot; | ||
this.shooter = shooter; | ||
} | ||
public enum CLIMB_STATES { | ||
NONE, | ||
EXTEND_CLIMB, | ||
RETRACT_CLIMB, | ||
SCORE_TRAP, | ||
} | ||
|
||
private CLIMB_STATES targetState = CLIMB_STATES.NONE; | ||
int counter = 0; | ||
|
||
public CLIMB_STATES getTargetState() { | ||
return targetState; | ||
} | ||
|
||
public void advanceTargetState() { | ||
if (atTargetState()) counter = Math.min(counter+1, 3); | ||
|
||
switch (counter) { | ||
case 0: | ||
targetState = CLIMB_STATES.NONE; | ||
break; | ||
case 1: | ||
targetState = CLIMB_STATES.EXTEND_CLIMB; | ||
break; | ||
case 2: | ||
targetState = CLIMB_STATES.RETRACT_CLIMB; | ||
break; | ||
case 3: | ||
targetState = CLIMB_STATES.SCORE_TRAP; | ||
default: | ||
targetState = CLIMB_STATES.NONE; | ||
break; | ||
} | ||
Logger.recordOutput("Climb Target State", targetState); | ||
} | ||
|
||
public boolean atTargetState() { | ||
if (elevator.extenderAtSetpoint() && pivot.pivotAtSetpoint() && shooter.atFlywheelSetpoints()) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |