Skip to content

Commit 0b2677d

Browse files
committed
optimize super cycles
1 parent d1a2b29 commit 0b2677d

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class AlgaeConstants {
3232
public static final double kIntakingSpeed = -1;
3333

3434
public static final double kHasAlgaeVelThreshold = 10;
35+
public static final double kSuperCycleHasAlgaeVelThres = 50;
3536
public static final double kHasAlgaeCounts = 2;
3637

3738
// Example Talon FX Config

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
public class ElevatorConstants {
2222

23-
public static final double kCloseEnoughRotations = 0.1;
23+
public static final double kCloseEnoughRotations = 0.4;
2424
public static final double kStowThresholdDone = 0.3676757 + 0.5;
2525
public static final double kMaxFwd = 53;
2626
public static final double kMaxRev = 0.1;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ public class RobotStateConstants {
1212

1313
public static final double kProcessorStowRadius = 0.5;
1414

15+
// Super Cycle Constants
16+
public static final double kBiscuitSuperCycleSafeThres = 6;
17+
1518
// Elevator good for climb, tolerates stuck coral
1619
public static final double kElevatorClimbMax = 11.4;
1720

src/main/java/frc/robot/subsystems/algae/AlgaeSubsystem.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ public boolean hasAlgae() {
5757
return curState == AlgaeStates.HAS_ALGAE;
5858
}
5959

60+
public boolean hasAlgaeSuperCycle() {
61+
return curState == AlgaeStates.HAS_ALGAE
62+
|| (FastMath.abs(inputs.velocity) < AlgaeConstants.kSuperCycleHasAlgaeVelThres
63+
&& inputs.isBeamBroken);
64+
}
65+
6066
public void setSpeed(double speed) {
6167
// io.setSpeed(speed);
6268
// desiredSpeed = speed;

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -720,15 +720,15 @@ public void periodic() {
720720
}
721721
}
722722
case REEF_ALIGN_ALGAE -> {
723-
if (algaeSubsystem.hasAlgae()) {
723+
if (algaeSubsystem.hasAlgaeSuperCycle()) {
724724
biscuitSubsystem.setIsRemovingAlgae(true);
725725
switch (getAlgaeLevel()) {
726726
case L2 -> {
727-
biscuitSubsystem.setPosition(RobotConstants.kL2AlgaeRemovalSetpoint, hasAlgae());
727+
biscuitSubsystem.setPosition(RobotConstants.kL2AlgaeRemovalSetpoint, true);
728728
elevatorSubsystem.setPosition(ElevatorConstants.kL2AlgaeRemovalSetpoint);
729729
}
730730
case L3 -> {
731-
biscuitSubsystem.setPosition(RobotConstants.kL3AlgaeRemovalSetpoint, hasAlgae());
731+
biscuitSubsystem.setPosition(RobotConstants.kL3AlgaeRemovalSetpoint, true);
732732
elevatorSubsystem.setPosition(ElevatorConstants.kL3AlgaeRemovalSetpoint);
733733
}
734734
default -> logger.error("Invalid algae level: {}", getAlgaeLevel());
@@ -750,7 +750,9 @@ public void periodic() {
750750
}
751751
}
752752
case REMOVE_ALGAE -> {
753-
if (biscuitSubsystem.isFinished() && elevatorSubsystem.isFinished()) {
753+
if (elevatorSubsystem.isFinished()
754+
&& biscuitSubsystem.getPosition().in(Rotations)
755+
<= RobotStateConstants.kBiscuitSuperCycleSafeThres) {
754756
biscuitSubsystem.setIsRemovingAlgae(false);
755757
if (coralSubsystem.hasCoral()
756758
&& !(isAutoPlacing && getAlgaeOnCycle && scoreSide == ScoreSide.RIGHT)) {

0 commit comments

Comments
 (0)