Skip to content

Commit 38db091

Browse files
committed
barge auton vision bug, auton delays/offsets, l3 eject speed, earlier elevator raise in auto barge
1 parent d8ff74a commit 38db091

File tree

9 files changed

+356
-259
lines changed

9 files changed

+356
-259
lines changed

src/main/deploy/choreo/bargeToI.traj

Lines changed: 314 additions & 237 deletions
Large diffs are not rendered by default.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public void initialize() {
117117
robotStateSubsystem.clearCoral();
118118
}
119119

120-
visionSubsystem.setIsAuto(false);
120+
// visionSubsystem.setIsAuto(false);
121121
robotStateSubsystem.setAutoAlgaeLevel(algaeLevel);
122122

123123
isServoing = false;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ public class AutonConstants {
2929
new Pose2d(7.1, 7.257, Rotation2d.fromDegrees(180));
3030

3131
public static final Pose2d kMiddleBargeStart =
32-
new Pose2d(7.1, 7.257, Rotation2d.fromDegrees(180));
32+
new Pose2d(7.1, 3.7209, Rotation2d.fromDegrees(180));
3333
}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ public class BargeAlignConstants {
77

88
public static final double kBlueEjectAlgaeX = 7.67; // 7.72
99
public static final double kRedEjectAlgaeX = 9.86; // 9.81
10-
public static final double kBlueRaiseElevatorX = 7.02; // 7.22
11-
public static final double kRedRaiseElevatorX = 10.51; // 10.31
10+
public static final double kBlueRaiseElevatorX = 6.82; // 7.02
11+
public static final double kRedRaiseElevatorX = 10.71; // 10.51
12+
13+
public static final double kBlueUnsafeX = 7.02;
14+
public static final double kRedUnsafeX = 10.51;
1215

1316
public static final Rotation2d kBlueDesiredYaw = Rotation2d.fromDegrees(0.0);
1417
public static final Rotation2d kRedDesiredYaw = Rotation2d.fromDegrees(180.0);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class RobotStateConstants {
88
public static final double[] kNodeAngles = {0.0, 60.0, 120.0, 180.0, -120.0, -60.0};
99
public static final double kAlgaeRetreatDistance = 0;
1010

11-
public static final double kBlueBargeSafeX = 7; // 7.6
11+
public static final double kBlueBargeSafeX = 7.02; // 7.6
1212
public static final double kRedBargeSafeX = DriveConstants.kFieldMaxX - kBlueBargeSafeX;
1313

1414
public static final double kCoralEjectTimer = 0.25;

src/main/java/frc/robot/subsystems/auto/AutoSwitch.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ private AutoCommandInterface getAutoCommand(int switchPos) {
282282
PathHandlerConstants.kLoadLightDistance,
283283
PathHandlerConstants.kLoadLightDistance,
284284
PathHandlerConstants.kLoadLightDistance)),
285-
new ArrayList<>(Arrays.asList(-0.0175, 0.0, 0.0)),
285+
new ArrayList<>(Arrays.asList(-0.0075, -0.0075, -0.0075)),
286286
'j',
287287
false,
288288
AutonConstants.kNonProcessorMid);
@@ -366,12 +366,12 @@ private AutoCommandInterface getAutoCommand(int switchPos) {
366366
tagAlignSubsystem,
367367
visionSubsystem,
368368
new ArrayList<String>(Arrays.asList("startBargeToG", "bargeToE", "bargeToI")),
369-
new ArrayList<Double>(Arrays.asList(0.0, 0.0, 0.0)),
369+
new ArrayList<Double>(Arrays.asList(-0.00475, 0.0, 0.0)),
370370
new ArrayList<Double>(Arrays.asList(0.0, 0.0, 0.0)),
371371
new ArrayList<String>(Arrays.asList("GToBarge", "EToBarge", "IToNearBarge")),
372372
new ArrayList<>(Arrays.asList(ScoringLevel.L2, ScoringLevel.L3, ScoringLevel.L3)),
373373
AutonConstants.kMiddleBargeStart,
374-
0.5);
374+
0.0);
375375
}
376376

377377
case 0x12 -> {
@@ -550,7 +550,7 @@ private AutoCommandInterface getAutoCommand(int switchPos) {
550550
PathHandlerConstants.kLoadLightDistance,
551551
PathHandlerConstants.kLoadLightDistance,
552552
PathHandlerConstants.kLoadLightDistance)),
553-
new ArrayList<>(Arrays.asList(0.0, 0.0, 0.0)),
553+
new ArrayList<>(Arrays.asList(-0.0075, -0.0075, -0.0075)),
554554
'e',
555555
true,
556556
AutonConstants.kProcessorMid);

src/main/java/frc/robot/subsystems/coral/CoralSubsystem.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ public void eject(ScoringLevel level) {
105105
// setSpeed(CoralConstants.kEjectingSpeed);
106106

107107
switch (level) {
108-
case L1, L2, L3 -> setPct(0.8);
108+
case L1, L2 -> setPct(0.8);
109+
case L3 -> setPct(0.75);
109110
case L4 -> setPct(1);
110111
}
111112
setState(CoralState.EJECTING);

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

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,17 @@ private boolean isSafe() {
8383
private boolean shouldRaiseElevator() {
8484
double poseX = driveSubsystem.getPoseMeters().getX();
8585
return isOnBlueSide
86-
? poseX > BargeAlignConstants.kBlueRaiseElevatorX
87-
: poseX < BargeAlignConstants.kRedRaiseElevatorX;
86+
? (poseX > BargeAlignConstants.kBlueRaiseElevatorX
87+
&& poseX <= BargeAlignConstants.kBlueUnsafeX)
88+
: (poseX < BargeAlignConstants.kRedRaiseElevatorX
89+
&& poseX >= BargeAlignConstants.kRedUnsafeX);
90+
}
91+
92+
private boolean shouldDriveBackwards() {
93+
double poseX = driveSubsystem.getPoseMeters().getX();
94+
return isOnBlueSide
95+
? poseX > BargeAlignConstants.kBlueUnsafeX
96+
: poseX < BargeAlignConstants.kRedUnsafeX;
8897
}
8998

9099
private boolean shouldEjectAlgae() {
@@ -131,6 +140,8 @@ public void periodic() {
131140
Logger.recordOutput("BargeAlign/Vomega", vOmega);
132141
if (shouldRaiseElevator()) {
133142
setState(BargeAlignStates.RAISE_ELEV);
143+
} else if (shouldDriveBackwards()) {
144+
setState(BargeAlignStates.REVERSE);
134145
}
135146
}
136147
case RAISE_ELEV -> {
@@ -146,14 +157,18 @@ public void periodic() {
146157
}
147158
}
148159
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);
160+
double vOmega =
161+
driveOmega.calculate(
162+
driveSubsystem.getPoseMeters().getRotation().getRadians(), targetYaw.getRadians());
163+
164+
driveSubsystem.move(-vX, getYStickReading(), vOmega, true);
165+
166+
Logger.recordOutput("BargeAlign/Vx", vX);
167+
Logger.recordOutput("BargeAlign/OmegaErr", driveOmega.getError());
168+
Logger.recordOutput("BargeAlign/Vomega", vOmega);
169+
170+
if (shouldRaiseElevator()) {
171+
setState(BargeAlignStates.RAISE_ELEV);
157172
}
158173
}
159174
case FINISHED -> {}

src/main/java/frc/robot/subsystems/vision/VisionSubsystem.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public VisionSubsystem(DriveSubsystem driveSubsystem) {
136136
// Initialize our udpSubscribers
137137
udpSubscriber[0] = new UdpSubscriber(5802, cams[0]);
138138
udpSubscriber[1] = new UdpSubscriber(5803, cams[2]);
139-
udpSubscriber[2] = new UdpSubscriber(5804, cams[1], cams[3], cams[4]);
139+
udpSubscriber[2] = new UdpSubscriber(5804, cams[1], cams[3]);
140140
}
141141
// Setter Methods
142142
public void setVisionUpdating(boolean updating) {
@@ -443,7 +443,8 @@ public void periodic() {
443443
}
444444
}
445445

446-
if (acceptUpdates[i] || seeGoodTag) {
446+
if (((acceptUpdates[i] || seeGoodTag) && (i == 0 || i == 2))
447+
|| ((i == 1 || i == 3) && !ignoreRearCams && !isAuto)) {
447448
timeSinceLastUpdate = getSeconds();
448449
validResults.add(new Pair<WallEyeResult, Integer>(cams[i].getResults(), i));
449450
lastResult[i] = (WallEyeTagResult) cams[i].getResults();

0 commit comments

Comments
 (0)