Skip to content

Commit a154cd0

Browse files
authored
Merge pull request #62 from strykeforce/west-mi-hotfix
West Michigan Hotfix
2 parents bfe781d + be30807 commit a154cd0

File tree

9 files changed

+61
-30
lines changed

9 files changed

+61
-30
lines changed

src/main/java/frc/robot/commands/auton/DriveAutonServoCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public void execute() {
175175
robotStateSubsystem.toAutonPrestage();
176176
}
177177
if (tagAlignSubsystem.getCurRadius(robotStateSubsystem.getAllianceColor())
178-
<= AutonConstants.kElevatorStageRadius
178+
<= AutonConstants.kElevatorStageRadiusPathOne
179179
&& !hasPreppedCoral) {
180180
hasPreppedCoral = true;
181181
robotStateSubsystem.toPrepCoral();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +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 = 45;
35+
public static final double kSuperCycleHasAlgaeVelThres = 40;
3636
public static final double kHasAlgaeCounts = 2;
3737

3838
// Example Talon FX Config

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class AutonConstants {
1111
public static final double kMaxOmegaErrorRadians = Units.degreesToRadians(kMaxOmegaErrorDegrees);
1212
public static final int kSwitchStableCounts = 3;
1313
public static final double kElevatorStageRadius = 2.2;
14+
public static final double kElevatorStageRadiusPathOne = 1.8;
1415
public static final double kInitPathPrestageTime = 0.6;
1516

1617
// Start Poses

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,25 @@ public class ElevatorConstants {
5555
Rotations.of(31.0901); // was 30.42969 -> 31.7505 -> 31.0901
5656
public static final Angle kL4CoralSetpoint = Rotations.of(48.28076);
5757

58-
public static final Angle kPrestageSetpoint = kL2CoralSetpoint;
5958
public static final Angle kAutoPrestageSetpoint = kL2CoralSetpoint;
6059

6160
// Algae obtaining
6261
public static final Angle kFloorAlgaeSetpoint = Rotations.of(5.82);
6362
public static final Angle kMicAlgaeSetpoint = Rotations.of(2.703);
6463
public static final Angle kHpAlgaeSetpoint = Rotations.of(14.9063);
6564

65+
// pre-stage tele
66+
public static final Angle kPrestageSetpoint = Rotations.of(10.0);
67+
6668
// Algae scoring
6769
public static final Angle kProcessorSetpoint =
6870
Rotations.of(1.49365); // was 4.297 -> 5.964 -> 3.348
6971
public static final Angle kBargeSetpoint = Rotations.of(44.785); // 41.936
7072
public static final Angle kBargeHigherThan = Rotations.of(31.0901);
7173

74+
// Min elevator height before biscuit movement
75+
public static final Angle kBiscuitSafeThreshold = Rotations.of(5);
76+
7277
public static TalonFXConfiguration getBothFXConfig() {
7378
TalonFXConfiguration fxConfig = new TalonFXConfiguration();
7479

@@ -114,7 +119,9 @@ public static TalonFXConfiguration getBothFXConfig() {
114119
fxConfig.Slot0 = slot0;
115120

116121
MotionMagicConfigs motionMagic =
117-
new MotionMagicConfigs().withMotionMagicCruiseVelocity(75).withMotionMagicAcceleration(300);
122+
new MotionMagicConfigs()
123+
.withMotionMagicCruiseVelocity(75)
124+
.withMotionMagicAcceleration(225); // was 300
118125
fxConfig.MotionMagic = motionMagic;
119126

120127
MotorOutputConfigs motorOut =

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,8 @@ public static class CompConstants {
350350
public static Angle kPrestageAlgaeSetpoint = kBiscuitStowSetpoint;
351351

352352
// Algae removal
353-
public static Angle kL2AlgaeSetpoint = Rotations.of(7.39);
354-
public static Angle kL3AlgaeSetpoint = Rotations.of(7.39);
353+
public static Angle kL2AlgaeSetpoint = Rotations.of(8.125); // was 7.39
354+
public static Angle kL3AlgaeSetpoint = Rotations.of(8.125); // was 7.39
355355

356356
public static Angle kL2AlgaeRemovalSetpoint = kPrestageSetpoint;
357357
public static Angle kL3AlgaeRemovalSetpoint = kPrestageSetpoint;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ public class RobotStateConstants {
2121
public static final double kElevatorClimbMax = 11.4;
2222

2323
// Climb LED Thresholds
24-
public static final double kClimbAngleSmall = -0.245;
25-
public static final double kClimbAngleBig = -0.215;
24+
public static final double kClimbAngleSmall = -0.235; // -0.245
25+
public static final double kClimbAngleBig = -0.213; // -0.215
2626
}

src/main/java/frc/robot/subsystems/biscuit/BiscuitSubsystem.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ public void setIsRemovingAlgae(boolean isRemoving) {
4949
}
5050

5151
public void setPosition(Angle position, boolean hasAlgae) {
52+
if (position.equals(setPoint)) {
53+
return;
54+
}
5255
io.setPosition(position, hasAlgae);
5356
setPoint = position;
5457
}

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

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static edu.wpi.first.units.Units.RotationsPerSecond;
55

66
import edu.wpi.first.math.geometry.Pose2d;
7+
import edu.wpi.first.units.measure.Angle;
78
import edu.wpi.first.wpilibj.DriverStation.Alliance;
89
import edu.wpi.first.wpilibj.Timer;
910
import frc.robot.constants.DriveConstants;
@@ -78,6 +79,7 @@ public class RobotStateSubsystem extends MeasurableSubsystem {
7879
private boolean hasElevatorAutoCoralPrestaged = false;
7980

8081
private Timer scoringTimer = new Timer();
82+
private Angle nextBiscuitSetpoint;
8183

8284
public RobotStateSubsystem(
8385
AlgaeSubsystem algaeSubsystem,
@@ -240,6 +242,14 @@ public void toggleGetAlgaeOnCycle() {
240242
ledSubsystem.setGetAlgeaLights(getAlgaeOnCycle);
241243
}
242244

245+
public void setBiscuitTransfer(Angle setpoint, boolean overrideThreshold) {
246+
if (overrideThreshold
247+
|| elevatorSubsystem.getPosition().gt(ElevatorConstants.kBiscuitSafeThreshold)) {
248+
biscuitSubsystem.setPosition(setpoint, hasAlgae());
249+
}
250+
nextBiscuitSetpoint = setpoint;
251+
}
252+
243253
public void setCurrentLimiting(boolean isCurrentLimiting) {
244254
this.isCurrentLimiting = isCurrentLimiting;
245255
ledSubsystem.setCurrentLimiting(isCurrentLimiting);
@@ -301,7 +311,7 @@ public void toStow() {
301311
driveSubsystem.setIgnoreSticks(false);
302312

303313
if (biscuitSubsystem.isSafeToStow()) {
304-
biscuitSubsystem.setPosition(RobotConstants.kStowSetpoint, hasAlgae());
314+
setBiscuitTransfer(RobotConstants.kStowSetpoint, true);
305315
elevatorSubsystem.setPosition(RobotConstants.kElevatorStowSetpoint);
306316
algaeSubsystem.hold();
307317

@@ -312,7 +322,7 @@ public void toStow() {
312322
}
313323

314324
public void toStowSafe() {
315-
biscuitSubsystem.setPosition(RobotConstants.kStowSetpoint, hasAlgae());
325+
setBiscuitTransfer(RobotConstants.kStowSetpoint, true);
316326
driveSubsystem.removeDriveMultiplier();
317327
driveSubsystem.setIgnoreSticks(false);
318328
algaeSubsystem.hold();
@@ -321,7 +331,7 @@ public void toStowSafe() {
321331
}
322332

323333
public void toStowSequential() {
324-
biscuitSubsystem.setPosition(RobotConstants.kStowSetpoint, hasAlgae());
334+
setBiscuitTransfer(RobotConstants.kStowSetpoint, true);
325335
driveSubsystem.removeDriveMultiplier();
326336
driveSubsystem.setIgnoreSticks(false);
327337
algaeSubsystem.hold();
@@ -331,23 +341,23 @@ public void toStowSequential() {
331341

332342
public void toAutonPrestage() {
333343
coralLoc = CoralLoc.CORAL;
334-
biscuitSubsystem.setPosition(RobotConstants.kPrestageSetpoint, hasAlgae());
344+
setBiscuitTransfer(RobotConstants.kPrestageSetpoint, false);
335345
elevatorSubsystem.setPosition(ElevatorConstants.kAutoPrestageSetpoint);
336346
funnelSubsystem.stopMotor();
337347

338348
setState(RobotStates.PRESTAGE, true);
339349
}
340350

341351
public void toFunnelLoad() {
342-
biscuitSubsystem.setPosition(RobotConstants.kFunnelSetpoint, hasAlgae());
352+
setBiscuitTransfer(RobotConstants.kFunnelSetpoint, true);
343353
coralSubsystem.intake();
344354
elevatorSubsystem.setPosition(RobotConstants.kElevatorFunnelSetpoint);
345355

346356
setState(RobotStates.FUNNEL_LOAD, true);
347357
}
348358

349359
private void toPrestage() {
350-
biscuitSubsystem.setPosition(RobotConstants.kPrestageSetpoint, hasAlgae());
360+
setBiscuitTransfer(RobotConstants.kPrestageSetpoint, false);
351361

352362
prestagingForAlgae = getAlgaeOnCycle;
353363

@@ -415,7 +425,7 @@ private void toReefAlign(boolean getAlgae, boolean drive) {
415425

416426
if (wantAlgae && !algaeSafe) {
417427
algaeSubsystem.intake();
418-
biscuitSubsystem.setPosition(RobotConstants.kPrestageAlgaeSetpoint, hasAlgae());
428+
setBiscuitTransfer(RobotConstants.kPrestageAlgaeSetpoint, true);
419429

420430
switch (getAlgaeLevel()) {
421431
case L2 -> {
@@ -442,11 +452,11 @@ private void toReefAlign(boolean getAlgae, boolean drive) {
442452

443453
switch (getAlgaeLevel()) {
444454
case L2 -> {
445-
biscuitSubsystem.setPosition(RobotConstants.kL2AlgaeSetpoint, hasAlgae());
455+
setBiscuitTransfer(RobotConstants.kL2AlgaeSetpoint, true);
446456
elevatorSubsystem.setPosition(ElevatorConstants.kL2AlgaeSetpoint);
447457
}
448458
case L3 -> {
449-
biscuitSubsystem.setPosition(RobotConstants.kL3AlgaeSetpoint, hasAlgae());
459+
setBiscuitTransfer(RobotConstants.kL3AlgaeSetpoint, true);
450460
elevatorSubsystem.setPosition(ElevatorConstants.kL3AlgaeSetpoint);
451461
}
452462
default -> logger.error("Invalid algae level: {}", getAlgaeLevel());
@@ -467,19 +477,19 @@ private void toReefAlign(boolean getAlgae, boolean drive) {
467477
currentLevel = scoringLevel;
468478
switch (scoringLevel) {
469479
case L1 -> {
470-
biscuitSubsystem.setPosition(RobotConstants.kL1CoralSetpoint, hasAlgae());
480+
setBiscuitTransfer(RobotConstants.kL1CoralSetpoint, true);
471481
elevatorSubsystem.setPosition(ElevatorConstants.kL1CoralSetpoint);
472482
}
473483
case L2 -> {
474-
biscuitSubsystem.setPosition(RobotConstants.kL2CoralSetpoint, hasAlgae());
484+
setBiscuitTransfer(RobotConstants.kL2CoralSetpoint, true);
475485
elevatorSubsystem.setPosition(ElevatorConstants.kL2CoralSetpoint);
476486
}
477487
case L3 -> {
478-
biscuitSubsystem.setPosition(RobotConstants.kL3CoralSetpoint, hasAlgae());
488+
setBiscuitTransfer(RobotConstants.kL3CoralSetpoint, true);
479489
elevatorSubsystem.setPosition(ElevatorConstants.kL3CoralSetpoint);
480490
}
481491
case L4 -> {
482-
biscuitSubsystem.setPosition(RobotConstants.kL4CoralSetpoint, hasAlgae());
492+
setBiscuitTransfer(RobotConstants.kL4CoralSetpoint, true);
483493
elevatorSubsystem.setPosition(ElevatorConstants.kL4CoralSetpoint);
484494
}
485495
}
@@ -526,7 +536,7 @@ public void toAlgaeFloorPickup() {
526536
return;
527537
}
528538

529-
biscuitSubsystem.setPosition(RobotConstants.kFloorAlgaeSetpoint, hasAlgae());
539+
setBiscuitTransfer(RobotConstants.kFloorAlgaeSetpoint, true);
530540
elevatorSubsystem.setPosition(ElevatorConstants.kFloorAlgaeSetpoint);
531541

532542
setState(RobotStates.FLOOR_ALGAE, true);
@@ -536,7 +546,7 @@ public void toAlgaeFloorPickup() {
536546
return;
537547
}
538548

539-
biscuitSubsystem.setPosition(RobotConstants.kMicAlgaeSetpoint, hasAlgae());
549+
setBiscuitTransfer(RobotConstants.kMicAlgaeSetpoint, true);
540550
elevatorSubsystem.setPosition(ElevatorConstants.kMicAlgaeSetpoint);
541551

542552
setState(RobotStates.MIC_ALGAE, true);
@@ -598,6 +608,7 @@ public void releaseAlgae() {
598608

599609
processorReleasePose = driveSubsystem.getPoseMeters();
600610
Logger.recordOutput("RobotState/Processor Release Pose", processorReleasePose);
611+
driveSubsystem.removeDriveMultiplier();
601612

602613
switch (algaeHeight) {
603614
case LOW -> {
@@ -623,7 +634,7 @@ public void toHpAlgae() {
623634

624635
algaeSubsystem.intake();
625636

626-
biscuitSubsystem.setPosition(RobotConstants.kHpAlgaeSetpoint, hasAlgae());
637+
setBiscuitTransfer(RobotConstants.kHpAlgaeSetpoint, false);
627638
elevatorSubsystem.setPosition(ElevatorConstants.kHpAlgaeSetpoint);
628639

629640
setState(RobotStates.HP_ALGAE, true);
@@ -640,7 +651,7 @@ private void toProcessor() {
640651
return;
641652
}
642653

643-
biscuitSubsystem.setPosition(RobotConstants.kProcessorSetpoint, hasAlgae());
654+
setBiscuitTransfer(RobotConstants.kProcessorSetpoint, true);
644655
elevatorSubsystem.setPosition(ElevatorConstants.kProcessorSetpoint);
645656

646657
setState(RobotStates.PROCESSOR_ALGAE, true);
@@ -672,7 +683,7 @@ public void toPrepClimb() {
672683
return;
673684
}
674685

675-
biscuitSubsystem.setPosition(RobotConstants.kStowSetpoint, hasAlgae());
686+
setBiscuitTransfer(RobotConstants.kStowSetpoint, true);
676687
elevatorSubsystem.setPosition(RobotConstants.kElevatorStowSetpoint);
677688

678689
climbSubsystem.prepClimb();
@@ -714,6 +725,9 @@ public void periodic() {
714725

715726
switch (curState) {
716727
case TRANSFER -> {
728+
if (elevatorSubsystem.getPosition().gt(ElevatorConstants.kBiscuitSafeThreshold)) {
729+
biscuitSubsystem.setPosition(nextBiscuitSetpoint, hasAlgae());
730+
}
717731
if (biscuitSubsystem.isFinished() && elevatorSubsystem.isFinished()
718732
|| ((nextState == RobotStates.PREP_CLIMB || nextState == RobotStates.CLIMB)
719733
&& elevatorSubsystem.getPosition().in(Rotations)
@@ -774,11 +788,15 @@ public void periodic() {
774788
biscuitSubsystem.setIsRemovingAlgae(true);
775789
switch (getAlgaeLevel()) {
776790
case L2 -> {
777-
biscuitSubsystem.setPosition(RobotConstants.kL2AlgaeRemovalSetpoint, true);
791+
biscuitSubsystem.setPosition(
792+
RobotConstants.kL2AlgaeRemovalSetpoint,
793+
true); // not using setBiscuitTransfer() to ensure hasAlgae is true
778794
elevatorSubsystem.setPosition(ElevatorConstants.kL2AlgaeRemovalSetpoint);
779795
}
780796
case L3 -> {
781-
biscuitSubsystem.setPosition(RobotConstants.kL3AlgaeRemovalSetpoint, true);
797+
biscuitSubsystem.setPosition(
798+
RobotConstants.kL3AlgaeRemovalSetpoint,
799+
true); // not using setBiscuitTransfer() to ensure hasAlgae is true
782800
elevatorSubsystem.setPosition(ElevatorConstants.kL3AlgaeRemovalSetpoint);
783801
}
784802
default -> logger.error("Invalid algae level: {}", getAlgaeLevel());
@@ -892,7 +910,9 @@ public void periodic() {
892910
}
893911
case TO_BARGE_ALGAE -> {
894912
if (elevatorSubsystem.isHigherThan(ElevatorConstants.kBargeHigherThan)) {
895-
biscuitSubsystem.setPosition(RobotConstants.kBargeSetpoint, hasAlgae());
913+
biscuitSubsystem.setPosition(
914+
RobotConstants.kBargeSetpoint,
915+
hasAlgae()); // not using setBiscuitTransfer(), moves biscuit at higher threshold
896916
curState = RobotStates.BARGE_ALGAE;
897917
}
898918
}

src/main/java/frc/robot/subsystems/tagAlign/TagAlignSubsystem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ public void periodic() {
434434
currentThresCount++;
435435
if (currentThresCount >= TagServoingConstants.kEndCountThreshold) {
436436
terminate();
437-
break;
437+
return;
438438
}
439439
} else {
440440
currentThresCount = 0;

0 commit comments

Comments
 (0)