Skip to content

Commit 031f7d9

Browse files
committed
remove elevatorAt & armAt
1 parent aa3d9d6 commit 031f7d9

File tree

2 files changed

+5
-27
lines changed

2 files changed

+5
-27
lines changed

src/main/java/frc/robot/subsystems/lift/LiftInstructions.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,8 @@ public record IDF (
783783
* @return The instruction set representing the transition from startingState to endingState. If there is no valid transition, return null
784784
*/
785785
public static IDF[] mapStatesToTransition(TargetLiftStates startingState, TargetLiftStates endingState) {
786+
// shortcut identical case
787+
if (startingState == endingState) return null;
786788
switch (startingState) {
787789
case STOW:
788790
switch (endingState) {

src/main/java/frc/robot/subsystems/lift/LiftSubsystem.java

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,7 @@ public SystemState nextState() {
192192
AT_STATE {
193193
@Override
194194
public SystemState nextState() {
195-
// would technically already return due to mapStatesToTransition returning null,
196-
// but this saves some time
197-
if (curState == nextState) {
198-
return this;
199-
}
200-
195+
// mapStatesToTransition returns null if identical
201196
IDF[] idf = LiftInstructions.mapStatesToTransition(curState, nextState);
202197
if (idf != null) {
203198
currentInstructionSet = idf;
@@ -217,7 +212,8 @@ public void initialize() {
217212

218213
@Override
219214
public void execute() {
220-
if (s_liftinstance.armAt(STOW_ANGLE) && s_liftinstance.elevatorAt(STOW_HEIGHT)) {
215+
if (s_liftinstance.getArmAngle().isNear(STOW_ANGLE, ARM_TOLERANCE)
216+
&& s_liftinstance.getElevatorHeight().isNear(STOW_HEIGHT, ELEVATOR_TOLERANCE)) {
221217
isLiftReady = true;
222218
} else {
223219
isLiftReady = false;
@@ -483,26 +479,6 @@ public boolean elevatorAtHome() {
483479
return elevatorHomingBeamBreak();
484480
}
485481

486-
/**
487-
* Return whether the elevator is at a target height or not
488-
*
489-
* @return Boolean of if elevator is at target height
490-
*/
491-
public boolean elevatorAt(Distance targetHeight) {
492-
Distance currentHeight = getElevatorHeight();
493-
return (currentHeight.isNear(targetHeight, ELEVATOR_TOLERANCE));
494-
}
495-
496-
/**
497-
* Return whether the arm is at a target angle or not
498-
*
499-
* @return Boolean of if arm is at target angle
500-
*/
501-
public boolean armAt(Angle targetAngle) {
502-
Angle currentAngle = getArmAngle();
503-
return (currentAngle.isNear(targetAngle, ARM_TOLERANCE));
504-
}
505-
506482
/**
507483
* Return whether the lift is ready to move or not
508484
* @return Boolean of if lift is at one of the 5 stages

0 commit comments

Comments
 (0)