Skip to content

Commit 27dd5b6

Browse files
authored
Merge pull request #70 from strykeforce/barge-buffer-zone
Opponent Steal and Auto Barge Improvements
2 parents 5400f94 + 6156b6d commit 27dd5b6

File tree

4 files changed

+45
-10
lines changed

4 files changed

+45
-10
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ public class BiscuitConstants {
55
// public static final double kZero = .37;
66
public static final int talonID = 25;
77
public static final double kCloseEnough = 1.3; // was 0.05
8-
public static final double kInFunnel = 0.94; // TODO Put real numbers in here
8+
public static final double kInFunnel = 0.94;
99
public static final double kTooLow = 0.217;
1010
public static final double kZeroVelThresh = 2;
1111
// public static final double kSafeToStowUpper = 40;

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ public RobotStateSubsystem(
119119
this.tagAlignSubsystem = tagAlignSubsystem;
120120
this.visionSubsystem = visionSubsystem;
121121
this.bargeAlignSubsystem = bargeAlignSubsystem;
122-
this.canBus = new CANBus();
122+
this.canBus = new CANBus("CAN FD 25-1");
123123

124124
ledSubsystem.setState(LEDStates.NORMAL);
125125
}
126126

127127
public boolean isCANivoreConnected() {
128-
CANBusStatus status = canBus.getStatus("CAN FD 25-1");
128+
CANBusStatus status = canBus.getStatus();
129129
return status.Status.isOK();
130130
}
131131

@@ -344,6 +344,14 @@ private boolean needSafeAlgaeTransfer(RobotStates nextState) {
344344

345345
return false;
346346
}
347+
// Function made so I don't cram everything into a function call in toReefAlign
348+
private boolean justAlgae() {
349+
boolean blueSide = driveSubsystem.getPoseMeters().getX() < DriveConstants.kFieldMaxX / 2;
350+
351+
return !hasCoral()
352+
|| (blueSide && allianceColor == Alliance.Red)
353+
|| (!blueSide && allianceColor == Alliance.Blue);
354+
}
347355

348356
public void toStow() {
349357
visionSubsystem.setYawUpdateCamera(-1);
@@ -501,7 +509,11 @@ private void toReefAlign(boolean getAlgae, boolean drive) {
501509
return;
502510
}
503511

512+
boolean ignoreCoralScoring = isAutoPlacing && getAlgaeOnCycle && scoreSide == ScoreSide.RIGHT;
513+
504514
if (drive) {
515+
// TODO Test without a coral in the robot and we don't want algae
516+
tagAlignSubsystem.setJustAlgae(justAlgae());
505517
tagAlignSubsystem.start(
506518
allianceColor,
507519
scoringLevel,
@@ -516,8 +528,6 @@ private void toReefAlign(boolean getAlgae, boolean drive) {
516528
tagAlignSubsystem.getCurRadius() > TagServoingConstants.kAlgaeStopXDriveRadius
517529
|| tagAlignSubsystem.getState() != TagAlignStates.DRIVE;
518530

519-
boolean ignoreCoralScoring = isAutoPlacing && getAlgaeOnCycle && scoreSide == ScoreSide.RIGHT;
520-
521531
if (wantAlgae && !algaeSafe) {
522532
algaeSubsystem.intakeAlgae();
523533
setBiscuitTransfer(RobotConstants.kPrestageAlgaeSetpoint, true);
@@ -693,6 +703,7 @@ public void toScoreAlgae() {
693703
if (needSafeAlgaeTransfer(RobotStates.BARGE_ALGAE)) {
694704
return;
695705
}
706+
696707
double poseX = driveSubsystem.getPoseMeters().getX();
697708
isBargeSafe =
698709
poseX > RobotStateConstants.kRedBargeSafeX

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,17 @@ public void periodic() {
145145
terminate();
146146
}
147147
}
148+
case REVERSE -> {
149+
if (isOnBlueSide) {
150+
driveSubsystem.move(
151+
-vX, getYStickReading(), BargeAlignConstants.kBlueRaiseElevatorX, true);
152+
if (shouldRaiseElevator()) {
153+
setState(BargeAlignStates.RAISE_ELEV);
154+
}
155+
} else {
156+
driveSubsystem.move(vX, getYStickReading(), BargeAlignConstants.kRedRaiseElevatorX, true);
157+
}
158+
}
148159
case FINISHED -> {}
149160
}
150161
}
@@ -158,6 +169,7 @@ public enum BargeAlignStates {
158169
// INIT,
159170
DRIVE,
160171
RAISE_ELEV,
172+
REVERSE,
161173
FINISHED
162174
}
163175
}

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

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public class TagAlignSubsystem extends MeasurableSubsystem {
5151
private double coralOffset = 0;
5252
private double noProgressCounts = 0;
5353
private double yAutoOffset = 0;
54+
private boolean justAlgae = false;
5455

5556
public TagAlignSubsystem(DriveSubsystem driveSubsystem, VisionSubsystem visionSubsystem) {
5657
this.driveSubsystem = driveSubsystem;
@@ -80,6 +81,10 @@ public void setProceedToAlign(boolean proceed) {
8081
this.proceedToAlign = proceed;
8182
}
8283

84+
public void setJustAlgae(boolean justAlgae) {
85+
this.justAlgae = justAlgae;
86+
}
87+
8388
public boolean yErrorSmall() {
8489
return curState == TagAlignStates.DONE
8590
|| finalDrive
@@ -285,6 +290,7 @@ public void startAuto(
285290
isAuto = true;
286291
this.yAutoOffset = yAutoOffset;
287292
setup(alliance, level, scoreLeft, algae);
293+
setJustAlgae(false);
288294
tagAlign();
289295
}
290296

@@ -406,10 +412,14 @@ public void periodic() {
406412
}
407413
}
408414
case TAG_ALIGN -> {
409-
if ((
410-
/*isAuto ? true :*/ FastMath.abs(alignX.getError()) < driveXCloseEnough)
411-
&& FastMath.abs(alignY.getError()) < driveYCloseEnough) {
415+
if (justAlgae && (FastMath.abs(alignY.getError()) < driveYCloseEnough)) {
412416
finalDrive = true;
417+
} else {
418+
if ((
419+
/*isAuto ? true :*/ FastMath.abs(alignX.getError()) < driveXCloseEnough)
420+
&& FastMath.abs(alignY.getError()) < driveYCloseEnough) {
421+
finalDrive = true;
422+
}
413423
}
414424
if (finalDrive
415425
&& driveSubsystem.getAvgDriveCurrent()
@@ -430,9 +440,11 @@ public void periodic() {
430440
}
431441
}
432442
}
433-
443+
// TODO Find Proper Number
434444
if (finalDrive) {
435-
if (isAuto) {
445+
if (justAlgae) {
446+
vX = (vX > 0.35) ? vX : 0.35;
447+
} else if (isAuto) {
436448
if (scoreLeft) {
437449
vX = 0.25;
438450
} else {

0 commit comments

Comments
 (0)