Skip to content

Commit 5b4b10c

Browse files
committed
elevator finish, climb pos
1 parent 5489c24 commit 5b4b10c

File tree

3 files changed

+58
-2
lines changed

3 files changed

+58
-2
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package frc.robot.commands.robotState;
2+
3+
import edu.wpi.first.wpilibj2.command.Command;
4+
import frc.robot.subsystems.algae.AlgaeSubsystem;
5+
import frc.robot.subsystems.biscuit.BiscuitSubsystem;
6+
import frc.robot.subsystems.elevator.ElevatorSubsystem;
7+
import frc.robot.subsystems.robotState.RobotStateSubsystem;
8+
import frc.robot.subsystems.robotState.RobotStateSubsystem.AlgaeHeight;
9+
import frc.robot.subsystems.robotState.RobotStateSubsystem.RobotStates;
10+
11+
public class ForceBargeCommand extends Command {
12+
RobotStateSubsystem robotStateSubsystem;
13+
ElevatorSubsystem elevatorSubsystem;
14+
boolean hasTriedToPickup = false;
15+
private RobotStates startState;
16+
private boolean startingElevatorFinished;
17+
18+
public ForceBargeCommand(
19+
RobotStateSubsystem robotStateSubsystem,
20+
ElevatorSubsystem elevatorSubsystem,
21+
BiscuitSubsystem biscuitSubsystem,
22+
AlgaeSubsystem algaeSubsystem) {
23+
this.robotStateSubsystem = robotStateSubsystem;
24+
this.elevatorSubsystem = elevatorSubsystem;
25+
addRequirements(elevatorSubsystem, biscuitSubsystem, algaeSubsystem);
26+
}
27+
28+
@Override
29+
public void initialize() {
30+
startState = robotStateSubsystem.getState();
31+
startingElevatorFinished = elevatorSubsystem.isFinished();
32+
robotStateSubsystem.setAlgaeHeight(AlgaeHeight.HIGH);
33+
if (startState == RobotStates.BARGE_ALGAE) robotStateSubsystem.releaseAlgae();
34+
else robotStateSubsystem.toScoreAlgae();
35+
}
36+
37+
@Override
38+
public boolean isFinished() {
39+
if (startState == RobotStates.PROCESSOR_ALGAE || startState == RobotStates.BARGE_ALGAE) {
40+
return robotStateSubsystem.getState() == RobotStates.FUNNEL_LOAD
41+
|| robotStateSubsystem.getState() == RobotStates.STOW
42+
|| !startingElevatorFinished;
43+
} else {
44+
return robotStateSubsystem.getState() == RobotStates.BARGE_ALGAE
45+
|| robotStateSubsystem.getState() == RobotStates.PROCESSOR_ALGAE
46+
|| !robotStateSubsystem.getIsBargeSafe();
47+
}
48+
}
49+
}

src/main/java/frc/robot/constants/ElevatorConstants.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
public class ElevatorConstants {
2222

2323
public static final double kCloseEnoughRotations = 0.1;
24+
public static final double kStowThresholdDone = 0.3676757 + 0.5;
2425
public static final double kMaxFwd = 53;
2526
public static final double kMaxRev = 2;
2627
public static final double kElevatorLiftHeight = 1; // for pit command
@@ -50,7 +51,7 @@ public class ElevatorConstants {
5051

5152
// Coral score
5253
public static final Angle kL1CoralSetpoint = Rotations.of(15.2); // 13.04053
53-
public static final Angle kL2CoralSetpoint = Rotations.of(21.0786); // 19.62793 -> 21.0786
54+
public static final Angle kL2CoralSetpoint = Rotations.of(19.62793); // 19.62793 -> 21.0786 ->
5455
public static final Angle kL3CoralSetpoint =
5556
Rotations.of(31.0901); // was 30.42969 -> 31.7505 -> 31.0901
5657
public static final Angle kL4CoralSetpoint = Rotations.of(48.28076);

src/main/java/frc/robot/subsystems/robotState/RobotStateSubsystem.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,9 @@ public void toPrepClimb() {
619619
public void toClimb() {
620620
if (curState == RobotStates.PREP_CLIMB || climbSubsystem.getState() == ClimbState.PREPPED) {
621621

622+
biscuitSubsystem.setPosition(RobotConstants.kHpAlgaeSetpoint, hasAlgae());
623+
elevatorSubsystem.setPosition(ElevatorConstants.kHpAlgaeSetpoint);
624+
622625
climbSubsystem.climb();
623626
driveSubsystem.prepClimb();
624627

@@ -657,7 +660,10 @@ public void periodic() {
657660
}
658661

659662
case TO_STOW -> {
660-
if (biscuitSubsystem.isFinished() && elevatorSubsystem.isFinished()) {
663+
if (biscuitSubsystem.isFinished()
664+
&& (elevatorSubsystem.isFinished()
665+
|| elevatorSubsystem.getPosition().in(Rotations)
666+
< ElevatorConstants.kStowThresholdDone)) {
661667
setState(RobotStates.STOW);
662668
}
663669
}

0 commit comments

Comments
 (0)