Skip to content

Commit 7f55a48

Browse files
committed
Add elevator and dispenser. fix drive bugs.
commit 773704f Author: Sriman Achanta <[email protected]> Date: Fri Feb 28 12:44:29 2025 -0500 add reserialize command commit fd13f3f Author: Sriman Achanta <[email protected]> Date: Fri Feb 28 12:44:13 2025 -0500 update dispenser eject to be faster also goes back to stow automatically commit 5b7bf78 Author: Sriman Achanta <[email protected]> Date: Fri Feb 28 12:42:38 2025 -0500 Rename holdingCoral to better match lombok commit 3d7c324 Author: Sriman Achanta <[email protected]> Date: Fri Feb 28 12:41:47 2025 -0500 stop elevator from honing on gyro reset commit f17c272 Author: Sriman Achanta <[email protected]> Date: Fri Feb 28 12:41:19 2025 -0500 Make intake toggleable commit de0014c Author: Sriman Achanta <[email protected]> Date: Fri Feb 28 12:40:28 2025 -0500 Make slow mode toggleable and cleanup changes from Thursday commit e9c1694 Author: Sriman Achanta <[email protected]> Date: Fri Feb 28 10:51:20 2025 -0500 idk if this matters commit 24e9f2b Author: Sriman Achanta <[email protected]> Date: Fri Feb 28 10:50:57 2025 -0500 Auto hone elevator on start commit eda4d4b Author: Sriman Achanta <[email protected]> Date: Fri Feb 28 10:50:05 2025 -0500 Fix characterization DT bug commit a6ac1fe Author: Sriman Achanta <[email protected]> Date: Fri Feb 28 10:49:23 2025 -0500 fix merge commit 32aca1e Author: Talon540-root <[email protected]> Date: Thu Feb 27 01:05:11 2025 -0500 tuning stuff commit 1b9467e Merge: 07083ba 2e7b277 Author: Talon540-root <[email protected]> Date: Wed Feb 26 18:55:24 2025 -0500 Merge branch 'sriman-dev' of https://github.com/Talon540Programming/Reefscape2025 into sriman-dev commit 2e7b277 Author: Sriman Achanta <[email protected]> Date: Wed Feb 26 18:48:56 2025 -0500 Create ElevatorVisualizer.java commit b32b9fc Author: Sriman Achanta <[email protected]> Date: Wed Feb 26 18:48:48 2025 -0500 Update RobotContainer.java commit 6cfc8e3 Author: Sriman Achanta <[email protected]> Date: Wed Feb 26 14:57:45 2025 -0500 Update LoggedTunableNumber.java commit e7fadb7 Author: Sriman Achanta <[email protected]> Date: Wed Feb 26 11:20:15 2025 -0500 schedule home command if not homed on teleop init commit 1d3b191 Author: Sriman Achanta <[email protected]> Date: Wed Feb 26 10:24:53 2025 -0500 add proto auto intake commit d1f8beb Author: Sriman Achanta <[email protected]> Date: Wed Feb 26 10:24:33 2025 -0500 add sprint commit d267a5f Author: Sriman Achanta <[email protected]> Date: Wed Feb 26 01:54:57 2025 -0500 add elevator and end effector subsystems commit 07083ba Author: Talon540-root <[email protected]> Date: Wed Feb 26 01:36:12 2025 -0500 fixes commit ee57f87 Author: Sriman Achanta <[email protected]> Date: Tue Feb 25 22:03:17 2025 -0500 WIP commit 9f9de79 Author: Sriman Achanta <[email protected]> Date: Tue Feb 25 03:29:28 2025 -0500 Update IO commit ba09067 Author: Sriman Achanta <[email protected]> Date: Mon Feb 24 14:36:57 2025 -0500 Implement ElevatorIO commit 19e3976 Author: Sriman Achanta <[email protected]> Date: Mon Feb 24 14:36:49 2025 -0500 Implement DispenserIO commit bd348ee Author: Sriman Achanta <[email protected]> Date: Mon Feb 24 14:36:40 2025 -0500 Make sim models non static avoids building creating these objects when running as non-sim commit 1baa58d Author: Sriman Achanta <[email protected]> Date: Mon Feb 24 11:09:27 2025 -0500 Add updatable debouncer commit ba6e299 Author: Sriman Achanta <[email protected]> Date: Mon Feb 24 05:03:14 2025 -0500 Update EqualsUtil.java commit fb12507 Author: Sriman Achanta <[email protected]> Date: Sun Feb 23 13:58:29 2025 -0500 Update FieldConstants.java commit 96f6eae Author: Sriman Achanta <[email protected]> Date: Sat Feb 22 10:40:15 2025 -0500 dont make conversion factors variables commit 4343534 Author: Sriman Achanta <[email protected]> Date: Sat Feb 22 10:39:38 2025 -0500 explicitly set motor temp signals commit e8fbd80 Author: Sriman Achanta <[email protected]> Date: Sat Feb 22 01:28:04 2025 -0500 Update Intake commit 6adf211 Author: Sriman Achanta <[email protected]> Date: Sat Feb 22 01:05:32 2025 -0500 Fix DT bug commit ca2f600 Author: Sriman Achanta <[email protected]> Date: Sat Feb 22 00:53:08 2025 -0500 Update robot constants to match bot commit 68e75f9 Author: Sriman Achanta <[email protected]> Date: Wed Feb 19 23:34:57 2025 -0500 Add intake subsystem commit de577e5 Author: Sriman Achanta <[email protected]> Date: Wed Feb 19 21:47:57 2025 -0500 fix akit version mismatch commit 2a1068c Merge: 420fa3d 3be2661 Author: Sriman Achanta <[email protected]> Date: Sun Feb 16 15:45:12 2025 -0500 Merge branch 'main' into sriman-dev commit 420fa3d Author: Sriman Achanta <[email protected]> Date: Sun Feb 16 15:38:07 2025 -0500 Update WPILIB to 2025.3.1 commit 5b6968a Author: Sriman Achanta <[email protected]> Date: Thu Feb 13 01:44:37 2025 -0500 Fix red alliance drive commands bug commit 2952998 Author: Sriman Achanta <[email protected]> Date: Sat Feb 15 01:43:00 2025 -0500 Shorten name for drive temp commit b2626e8 Author: Sriman Achanta <[email protected]> Date: Thu Feb 13 00:06:04 2025 -0500 Refactor code structure to not over-expose subsystem specific stuff commit 2af259b Author: Sriman Achanta <[email protected]> Date: Wed Feb 12 23:47:30 2025 -0500 Update Phoenix6 to 2025.2.2 commit 2ae942f Author: Sriman Achanta <[email protected]> Date: Wed Feb 12 23:44:07 2025 -0500 Refactor abstract alerts into util class to later roll into LEDs commit 876046f Author: Sriman Achanta <[email protected]> Date: Wed Feb 12 23:42:36 2025 -0500 Rename RobotState to PoseEstimator Because only vision and drive will interact with pose (and purely position) and no other robot state is tracked, it makes more sense for this to be renammed to reflect that. commit e5c4843 Merge: f7606cf 9325f68 Author: Sriman Achanta <[email protected]> Date: Wed Feb 12 22:08:31 2025 -0500 Merge branch 'main' into sriman-dev commit f7606cf Author: Sriman Achanta <[email protected]> Date: Wed Feb 12 22:07:08 2025 -0500 Inline tuning mode alert commit addcdce Author: Sriman Achanta <[email protected]> Date: Wed Feb 12 22:04:53 2025 -0500 Formatting fixes commit 1b089c2 Merge: 37cd26f 93e655d Author: Sriman Achanta <[email protected]> Date: Wed Feb 12 22:03:18 2025 -0500 Merge branch 'main' into sriman-dev commit 37cd26f Author: Sriman Achanta <[email protected]> Date: Wed Feb 12 21:55:27 2025 -0500 Log drive motor temps commit 15e8caf Author: Sriman Achanta <[email protected]> Date: Wed Feb 12 21:43:07 2025 -0500 Update sim characterization constants to be more accurate, stops a massive overshooting for some reason commit 803498a Author: Sriman Achanta <[email protected]> Date: Wed Feb 12 21:42:46 2025 -0500 Cleanup dashboard setting stuff commit 1cc2430 Author: Sriman Achanta <[email protected]> Date: Wed Feb 12 21:42:25 2025 -0500 Cleanup typing, make errors more obvious commit 98c0715 Author: Sriman Achanta <[email protected]> Date: Wed Feb 5 13:21:38 2025 -0500 Fix Modules Falsely Reporting as Disconnected commit f9babf3 Author: Sriman Achanta <[email protected]> Date: Sat Feb 1 09:57:53 2025 -0500 clean commit 16c4eba Author: Sriman Achanta <[email protected]> Date: Wed Jan 29 12:44:39 2025 -0500 Increase voltage warning on battery and add CAN error alert commit 71368d1 Author: Sriman Achanta <[email protected]> Date: Sat Jan 18 04:02:47 2025 -0500 Implement Full Logging and Drivetrain Subsystem (#1) * Da Code * Add alerts on drive spark maxes * Add Config Changes from Meeting * Other lil bs * Add automatic brake disable on robot disable * add odometry * add SIM module * Add DriveCommands * Update RobotContainer.java * Formatting fixes * Misc Fixes * Add low voltage warning for DT * Add velocity scalars for DT * Update PID Coefficents and fix odometry issues * Update URCL.json --------- Fix CI Co-Authored-By: Talon540-root <[email protected]>
1 parent 3be2661 commit 7f55a48

36 files changed

+1661
-171
lines changed

src/main/java/frc/robot/Constants.java

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ public class Constants {
99
public static final boolean TUNING_MODE = true;
1010
// Disable the AdvantageKit logger from running
1111
public static final boolean ENABLE_LOGGING = true;
12+
// Disable LEDs, will reduce software and electrical overhead but disable hardware alerts
13+
public static final boolean ENABLE_LEDs = false;
1214

1315
public static final double kLoopPeriodSecs = 0.02;
1416

+87-108
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
11
package frc.robot;
22

3+
import edu.wpi.first.apriltag.AprilTagFieldLayout;
34
import edu.wpi.first.math.geometry.*;
45
import edu.wpi.first.math.util.Units;
5-
import java.util.ArrayList;
6-
import java.util.HashMap;
7-
import java.util.List;
8-
import java.util.Map;
6+
import java.io.IOException;
7+
import java.util.*;
8+
import lombok.Getter;
99

1010
/**
1111
* Contains various field dimensions and useful reference points. All units are in meters and poses
1212
* have a blue alliance origin.
1313
*/
1414
public class FieldConstants {
15-
public static final double fieldLength = Units.inchesToMeters(690.876);
16-
public static final double fieldWidth = Units.inchesToMeters(317);
15+
public static AprilTagFieldLayout fieldLayout = AprilTagLayoutType.OFFICIAL.getFieldLayout();
16+
17+
public static final double fieldLength =
18+
AprilTagLayoutType.OFFICIAL.getFieldLayout().getFieldLength();
19+
public static final double fieldWidth =
20+
AprilTagLayoutType.OFFICIAL.getFieldLayout().getFieldWidth();
1721
public static final double startingLineX =
1822
Units.inchesToMeters(299.438); // Measured from the inside of starting line
1923

2024
public static class Processor {
2125
public static final Pose2d centerFace =
22-
new Pose2d(Units.inchesToMeters(235.726), 0, Rotation2d.fromDegrees(90));
26+
new Pose2d(
27+
AprilTagLayoutType.OFFICIAL.getFieldLayout().getTagPose(16).get().getX(),
28+
0,
29+
Rotation2d.fromDegrees(90));
2330
}
2431

2532
public static class Barge {
@@ -36,73 +43,76 @@ public static class Barge {
3643
}
3744

3845
public static class CoralStation {
39-
public static final Pose2d leftCenterFace =
40-
new Pose2d(
41-
Units.inchesToMeters(33.526),
42-
Units.inchesToMeters(291.176),
43-
Rotation2d.fromDegrees(90 - 144.011));
46+
public static final double stationLength = Units.inchesToMeters(79.750);
4447
public static final Pose2d rightCenterFace =
4548
new Pose2d(
4649
Units.inchesToMeters(33.526),
4750
Units.inchesToMeters(25.824),
4851
Rotation2d.fromDegrees(144.011 - 90));
52+
public static final Pose2d leftCenterFace =
53+
new Pose2d(
54+
rightCenterFace.getX(),
55+
fieldWidth - rightCenterFace.getY(),
56+
Rotation2d.fromRadians(-rightCenterFace.getRotation().getRadians()));
57+
}
58+
59+
public enum ReefLevel {
60+
L1(Units.inchesToMeters(25.0), 0),
61+
L2(Units.inchesToMeters(31.875 - Math.cos(Math.toRadians(35.0)) * 0.625), -35),
62+
L3(Units.inchesToMeters(47.625 - Math.cos(Math.toRadians(35.0)) * 0.625), -35),
63+
L4(Units.inchesToMeters(72), -90);
64+
65+
public final double height;
66+
public final double pitch;
67+
68+
ReefLevel(double height, double pitch) {
69+
this.height = height;
70+
this.pitch = pitch; // Degrees
71+
}
72+
73+
public static ReefLevel fromLevel(int level) {
74+
return Arrays.stream(values())
75+
.filter(height -> height.ordinal() == level)
76+
.findFirst()
77+
.orElse(L4);
78+
}
4979
}
5080

5181
public static class Reef {
82+
public static final double faceLength = Units.inchesToMeters(36.792600);
5283
public static final Translation2d center =
53-
new Translation2d(Units.inchesToMeters(176.746), Units.inchesToMeters(158.501));
84+
new Translation2d(Units.inchesToMeters(176.746), fieldWidth / 2.0);
5485
public static final double faceToZoneLine =
5586
Units.inchesToMeters(12); // Side of the reef to the inside of the reef zone line
5687

5788
public static final Pose2d[] centerFaces =
5889
new Pose2d[6]; // Starting facing the driver station in clockwise order
59-
public static final List<Map<ReefHeight, Pose3d>> branchPositions =
90+
public static final List<Map<ReefLevel, Pose3d>> branchPositions =
6091
new ArrayList<>(); // Starting at the right branch facing the driver station in clockwise
92+
public static final List<Map<ReefLevel, Pose2d>> branchPositions2d = new ArrayList<>();
6193

6294
static {
6395
// Initialize faces
64-
centerFaces[0] =
65-
new Pose2d(
66-
Units.inchesToMeters(144.003),
67-
Units.inchesToMeters(158.500),
68-
Rotation2d.fromDegrees(180));
69-
centerFaces[1] =
70-
new Pose2d(
71-
Units.inchesToMeters(160.373),
72-
Units.inchesToMeters(186.857),
73-
Rotation2d.fromDegrees(120));
74-
centerFaces[2] =
75-
new Pose2d(
76-
Units.inchesToMeters(193.116),
77-
Units.inchesToMeters(186.858),
78-
Rotation2d.fromDegrees(60));
79-
centerFaces[3] =
80-
new Pose2d(
81-
Units.inchesToMeters(209.489),
82-
Units.inchesToMeters(158.502),
83-
Rotation2d.fromDegrees(0));
84-
centerFaces[4] =
85-
new Pose2d(
86-
Units.inchesToMeters(193.118),
87-
Units.inchesToMeters(130.145),
88-
Rotation2d.fromDegrees(-60));
89-
centerFaces[5] =
90-
new Pose2d(
91-
Units.inchesToMeters(160.375),
92-
Units.inchesToMeters(130.144),
93-
Rotation2d.fromDegrees(-120));
96+
var aprilTagLayout = AprilTagLayoutType.OFFICIAL.getFieldLayout();
97+
centerFaces[0] = aprilTagLayout.getTagPose(18).get().toPose2d();
98+
centerFaces[1] = aprilTagLayout.getTagPose(19).get().toPose2d();
99+
centerFaces[2] = aprilTagLayout.getTagPose(20).get().toPose2d();
100+
centerFaces[3] = aprilTagLayout.getTagPose(21).get().toPose2d();
101+
centerFaces[4] = aprilTagLayout.getTagPose(22).get().toPose2d();
102+
centerFaces[5] = aprilTagLayout.getTagPose(17).get().toPose2d();
94103

95104
// Initialize branch positions
96105
for (int face = 0; face < 6; face++) {
97-
Map<ReefHeight, Pose3d> fillRight = new HashMap<>();
98-
Map<ReefHeight, Pose3d> fillLeft = new HashMap<>();
99-
for (var level : ReefHeight.values()) {
106+
Map<ReefLevel, Pose3d> fillRight = new HashMap<>();
107+
Map<ReefLevel, Pose3d> fillLeft = new HashMap<>();
108+
Map<ReefLevel, Pose2d> fillRight2d = new HashMap<>();
109+
Map<ReefLevel, Pose2d> fillLeft2d = new HashMap<>();
110+
for (var level : ReefLevel.values()) {
100111
Pose2d poseDirection = new Pose2d(center, Rotation2d.fromDegrees(180 - (60 * face)));
101112
double adjustX = Units.inchesToMeters(30.738);
102113
double adjustY = Units.inchesToMeters(6.469);
103114

104-
fillRight.put(
105-
level,
115+
var rightBranchPose =
106116
new Pose3d(
107117
new Translation3d(
108118
poseDirection
@@ -115,9 +125,8 @@ public static class Reef {
115125
new Rotation3d(
116126
0,
117127
Units.degreesToRadians(level.pitch),
118-
poseDirection.getRotation().getRadians())));
119-
fillLeft.put(
120-
level,
128+
poseDirection.getRotation().getRadians()));
129+
var leftBranchPose =
121130
new Pose3d(
122131
new Translation3d(
123132
poseDirection
@@ -130,74 +139,44 @@ public static class Reef {
130139
new Rotation3d(
131140
0,
132141
Units.degreesToRadians(level.pitch),
133-
poseDirection.getRotation().getRadians())));
142+
poseDirection.getRotation().getRadians()));
143+
144+
fillRight.put(level, rightBranchPose);
145+
fillLeft.put(level, leftBranchPose);
146+
fillRight2d.put(level, rightBranchPose.toPose2d());
147+
fillLeft2d.put(level, leftBranchPose.toPose2d());
134148
}
135-
branchPositions.add((face * 2) + 1, fillRight);
136-
branchPositions.add((face * 2) + 2, fillLeft);
149+
branchPositions.add(fillRight);
150+
branchPositions.add(fillLeft);
151+
branchPositions2d.add(fillRight2d);
152+
branchPositions2d.add(fillLeft2d);
137153
}
138154
}
139155
}
140156

141157
public static class StagingPositions {
142158
// Measured from the center of the ice cream
143-
public static final Pose2d leftIceCream =
144-
new Pose2d(Units.inchesToMeters(48), Units.inchesToMeters(230.5), new Rotation2d());
159+
public static final double separation = Units.inchesToMeters(72.0);
145160
public static final Pose2d middleIceCream =
146-
new Pose2d(Units.inchesToMeters(48), Units.inchesToMeters(158.5), new Rotation2d());
161+
new Pose2d(Units.inchesToMeters(48), fieldWidth / 2.0, new Rotation2d());
162+
public static final Pose2d leftIceCream =
163+
new Pose2d(Units.inchesToMeters(48), middleIceCream.getY() + separation, new Rotation2d());
147164
public static final Pose2d rightIceCream =
148-
new Pose2d(Units.inchesToMeters(48), Units.inchesToMeters(86.5), new Rotation2d());
165+
new Pose2d(Units.inchesToMeters(48), middleIceCream.getY() - separation, new Rotation2d());
149166
}
150167

151-
public enum ReefHeight {
152-
L4(Units.inchesToMeters(72), -90),
153-
L3(Units.inchesToMeters(47.625), -35),
154-
L2(Units.inchesToMeters(31.875), -35),
155-
L1(Units.inchesToMeters(18), 0);
168+
@Getter
169+
public enum AprilTagLayoutType {
170+
OFFICIAL("2025-reefscape-welded.json");
156171

157-
ReefHeight(double height, double pitch) {
158-
this.height = height;
159-
this.pitch = pitch; // in degrees
160-
}
172+
private final AprilTagFieldLayout fieldLayout;
161173

162-
public final double height;
163-
public final double pitch;
174+
private AprilTagLayoutType(String file) {
175+
try {
176+
fieldLayout = AprilTagFieldLayout.loadFromResource(file);
177+
} catch (IOException exception) {
178+
throw new RuntimeException("Failed to load AprilTagLayoutType: " + file, exception);
179+
}
180+
}
164181
}
165-
166-
// TODO
167-
// public static final double aprilTagWidth = Units.inchesToMeters(6.50);
168-
// public static final AprilTagLayoutType defaultAprilTagType = AprilTagLayoutType.OFFICIAL;
169-
// public static final int aprilTagCount = 22;
170-
//
171-
// @Getter
172-
// public enum AprilTagLayoutType {
173-
// OFFICIAL("2025-official");
174-
//
175-
// AprilTagLayoutType(String name) {
176-
// if (Constants.disableHAL) {
177-
// layout = null;
178-
// } else {
179-
// try {
180-
// layout =
181-
// new AprilTagFieldLayout(
182-
// Path.of(Filesystem.getDeployDirectory().getPath(), "apriltags", name +
183-
// ".json"));
184-
// } catch (IOException e) {
185-
// throw new RuntimeException(e);
186-
// }
187-
// }
188-
// if (layout == null) {
189-
// layoutString = "";
190-
// } else {
191-
// try {
192-
// layoutString = new ObjectMapper().writeValueAsString(layout);
193-
// } catch (JsonProcessingException e) {
194-
// throw new RuntimeException(
195-
// "Failed to serialize AprilTag layout JSON " + toString() + "for Northstar");
196-
// }
197-
// }
198-
// }
199-
//
200-
// private final AprilTagFieldLayout layout;
201-
// private final String layoutString;
202-
// }
203182
}

0 commit comments

Comments
 (0)