Skip to content

Commit d8cc057

Browse files
Merge pull request #59 from Spectrum3847/54-update-vision-files
54 update vision files, merging vision in and we can fix from here
2 parents 1e3257d + e585d4a commit d8cc057

File tree

12 files changed

+555
-151
lines changed

12 files changed

+555
-151
lines changed

.vscode/launch.json

+16-3
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,31 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7-
7+
{
8+
"type": "java",
9+
"name": "Main",
10+
"request": "launch",
11+
"mainClass": "frc.robot.Main",
12+
"projectName": "2025-SpectrumBeta"
13+
},
14+
{
15+
"type": "java",
16+
"name": "Main",
17+
"request": "launch",
18+
"mainClass": "frc.robot.Main",
19+
"projectName": "2025-Spectrum"
20+
},
821
{
922
"type": "wpilib",
1023
"name": "WPILib Desktop Debug",
1124
"request": "launch",
12-
"desktop": true,
25+
"desktop": true
1326
},
1427
{
1528
"type": "wpilib",
1629
"name": "WPILib roboRIO Debug",
1730
"request": "launch",
18-
"desktop": false,
31+
"desktop": false
1932
}
2033
]
2134
}

.vscode/spellright.dict

+3
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,6 @@ eToSratio
142142
Ncoder
143143
Dpad
144144
Limelights
145+
Robotand
146+
vx
147+
vy

src/main/java/frc/reefscape/Field.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -66,40 +66,42 @@ public static class Reef {
6666
public static final double faceToZoneLine =
6767
Units.inchesToMeters(12); // Side of the reef to the inside of the reef zone line
6868

69+
@Getter
6970
public static final Pose2d[] centerFaces =
7071
new Pose2d[6]; // Starting facing the driver station in clockwise order
72+
7173
public static final List<Map<ReefHeight, Pose3d>> branchPositions =
7274
new ArrayList<>(); // Starting at the right branch facing the driver station in
7375
// clockwise
7476

7577
static {
7678
// Initialize faces
77-
centerFaces[0] =
79+
centerFaces[0] = // reef id 18
7880
new Pose2d(
7981
Units.inchesToMeters(144.003),
8082
Units.inchesToMeters(158.500),
8183
Rotation2d.fromDegrees(180));
82-
centerFaces[1] =
84+
centerFaces[1] = // reef id 19
8385
new Pose2d(
8486
Units.inchesToMeters(160.373),
8587
Units.inchesToMeters(186.857),
8688
Rotation2d.fromDegrees(120));
87-
centerFaces[2] =
89+
centerFaces[2] = // reef id 20
8890
new Pose2d(
8991
Units.inchesToMeters(193.116),
9092
Units.inchesToMeters(186.858),
9193
Rotation2d.fromDegrees(60));
92-
centerFaces[3] =
94+
centerFaces[3] = // reef id 21
9395
new Pose2d(
9496
Units.inchesToMeters(209.489),
9597
Units.inchesToMeters(158.502),
9698
Rotation2d.fromDegrees(0));
97-
centerFaces[4] =
99+
centerFaces[4] = // reef id 22
98100
new Pose2d(
99101
Units.inchesToMeters(193.118),
100102
Units.inchesToMeters(130.145),
101103
Rotation2d.fromDegrees(-60));
102-
centerFaces[5] =
104+
centerFaces[5] = // reef id 17
103105
new Pose2d(
104106
Units.inchesToMeters(160.375),
105107
Units.inchesToMeters(130.144),

src/main/java/frc/robot/pilot/Pilot.java

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public class Pilot extends Gamepad {
4040
public final Trigger actionReady = rightBumper.and(teleop);
4141
public final Trigger score = actionReady.not().and(teleop);
4242

43+
// vision Drive
44+
public final Trigger visionAim = Y.and(noFn, teleop);
4345
// Drive Triggers
4446
public final Trigger upReorient = upDpad.and(fn, teleop);
4547
public final Trigger leftReorient = leftDpad.and(fn, teleop);

src/main/java/frc/robot/swerve/Swerve.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ Command applyRequest(Supplier<SwerveRequest> requestSupplier) {
223223
return run(() -> this.setControl(requestSupplier.get())).ignoringDisable(true);
224224
}
225225

226-
private ChassisSpeeds getCurrentRobotChassisSpeeds() {
226+
public ChassisSpeeds getCurrentRobotChassisSpeeds() {
227227
return getKinematics().toChassisSpeeds(getState().ModuleStates);
228228
}
229229

src/main/java/frc/robot/swerve/SwerveStates.java

+11
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ protected static void setStates() {
5555
pilot.leftReorient.onTrue(log(reorientLeft()));
5656
pilot.downReorient.onTrue(log(reorientBack()));
5757
pilot.rightReorient.onTrue(log(reorientRight()));
58+
59+
// // vision aim
60+
pilot.visionAim.onTrue(log(visionReefDrive()));
5861
}
5962

6063
/** Pilot Commands ************************************************************************ */
@@ -88,6 +91,14 @@ protected static Command fpvDrive() {
8891
.withName("Swerve.PilotFPVDrive");
8992
}
9093

94+
protected static Command visionReefDrive() {
95+
return drive(
96+
pilot::getDriveFwdPositive,
97+
pilot::getDriveLeftPositive,
98+
() -> Robot.getVision().getAdjustedThetaToReefFace())
99+
.withName("Swerve.VisionDrive");
100+
}
101+
91102
protected static Command pilotAimDrive(DoubleSupplier targetDegrees) {
92103
return aimDrive(pilot::getDriveFwdPositive, pilot::getDriveLeftPositive, targetDegrees)
93104
.withName("Swerve.PilotAimDrive");

0 commit comments

Comments
 (0)