Skip to content

Commit b396db6

Browse files
committed
scoring over coral works now
1 parent aaaabd8 commit b396db6

File tree

6 files changed

+35
-20
lines changed

6 files changed

+35
-20
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ public class TagServoingConstants {
9595
public static final double kEndVelThreshold = 5;
9696

9797
// Stuck coral
98-
public static final double kMinStuckCounts = 5;
99-
public static final double kCoralStuckDistance = 0.21;
98+
public static final double kMinStuckCounts = 3;
99+
public static final double kCoralStuckDistance = 0.19;
100100
public static final double kUnfixableCoralStuckDistance = 0.34;
101101

102102
// Reef
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
package frc.robot.subsystems.laser;
22

3+
import org.littletonrobotics.junction.AutoLog;
4+
35
public interface LaserIO {
46

7+
@AutoLog
8+
public static class LaserIOInputs {
9+
public double distance = 0.0;
10+
}
11+
12+
public void updateInputs(LaserIOInputs inputs);
13+
514
public double getDistanceMeters();
615
}

src/main/java/frc/robot/subsystems/laser/LaserIOCANRange.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ public LaserIOCANRange() {
1313
laser.getConfigurator().apply(LaserConstants.getLaserConfig());
1414
}
1515

16+
@Override
17+
public void updateInputs(LaserIOInputs inputs) {
18+
inputs.distance = getDistanceMeters();
19+
}
20+
1621
public double getDistanceMeters() {
1722
if (laser.getIsDetected().getValue()) {
1823
return laser.getDistance().getValue().in(Meters);

src/main/java/frc/robot/subsystems/laser/LaserSubsystem.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,21 @@
66

77
public class LaserSubsystem extends MeasurableSubsystem {
88

9-
private final LaserIO laserio;
9+
private final LaserIO io;
10+
private final LaserIOInputsAutoLogged inputs = new LaserIOInputsAutoLogged();
1011

1112
public LaserSubsystem(LaserIO laserio) {
12-
this.laserio = laserio;
13+
this.io = laserio;
1314
}
1415

1516
public double getDistance() {
16-
return laserio.getDistanceMeters();
17+
return io.getDistanceMeters();
18+
}
19+
20+
@Override
21+
public void periodic() {
22+
io.updateInputs(inputs);
23+
org.littletonrobotics.junction.Logger.processInputs("LaserInputs", inputs);
1724
}
1825

1926
@Override

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

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,34 +1046,26 @@ public void periodic() {
10461046

10471047
if (tagAlignSubsystem.fixableStuckCoral() == true) {
10481048
switch (scoringLevel) {
1049-
case L1 -> {
1050-
setBiscuitTransferSlow(RobotConstants.kL1CoralSetpoint, true);
1051-
elevatorSubsystem.setPosition(
1052-
ElevatorConstants.kL1CoralSetpoint.plus(
1053-
RobotStateConstants.kStuckCoralElevatorOffset));
1054-
}
1049+
case L1 -> {}
10551050
case L2 -> {
10561051
setBiscuitTransfer(RobotConstants.kL2CoralSetpoint, true);
10571052
elevatorSubsystem.setPosition(
10581053
ElevatorConstants.kL2CoralSetpoint.plus(
10591054
RobotStateConstants.kStuckCoralElevatorOffset));
1055+
setState(RobotStates.PLACE_CORAL, true);
1056+
reefCoralStuckFixable = tagAlignSubsystem.fixableStuckCoral();
10601057
}
10611058
case L3 -> {
10621059
setBiscuitTransfer(RobotConstants.kL3CoralSetpoint, true);
10631060
elevatorSubsystem.setPosition(
10641061
ElevatorConstants.kL3CoralSetpoint.plus(
10651062
RobotStateConstants.kStuckCoralElevatorOffset));
1063+
setState(RobotStates.PLACE_CORAL, true);
1064+
reefCoralStuckFixable = tagAlignSubsystem.fixableStuckCoral();
10661065
}
1067-
case L4 -> {
1068-
setBiscuitTransfer(RobotConstants.kL4CoralSetpoint, true);
1069-
elevatorSubsystem.setPosition(
1070-
ElevatorConstants.kL4CoralSetpoint.plus(
1071-
RobotStateConstants.kStuckCoralElevatorOffset));
1072-
}
1066+
case L4 -> {}
10731067
}
10741068
tagAlignSubsystem.terminate();
1075-
setState(RobotStates.PLACE_CORAL, true);
1076-
reefCoralStuckFixable = tagAlignSubsystem.fixableStuckCoral();
10771069
} else if ((isAutoPlacing
10781070
&& (tagAlignSubsystem.getState() == TagAlignSubsystem.TagAlignStates.DONE
10791071
/* || reefCoralStuckFixable

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,9 @@ public boolean stalled() {
232232

233233
public boolean fixableStuckCoral() {
234234
return laserSubsystem.getDistance() > TagServoingConstants.kCoralStuckDistance
235-
&& laserSubsystem.getDistance() < TagServoingConstants.kUnfixableCoralStuckDistance && stalled();
235+
&& laserSubsystem.getDistance() < TagServoingConstants.kUnfixableCoralStuckDistance
236+
&& FastMath.abs(driveOmega.getError()) < TagServoingConstants.kAngleCloseEnough
237+
&& stalled();
236238
}
237239

238240
public boolean isAligned() {

0 commit comments

Comments
 (0)