Skip to content

Commit adaa7be

Browse files
committed
made one more pass on commands
1 parent 53f8cbf commit adaa7be

File tree

2 files changed

+19
-31
lines changed

2 files changed

+19
-31
lines changed

src/main/java/frc/robot/CommandComposer.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ public static Command testRotation() {
4848
double duration = 2.0;
4949
return sequence(
5050
m_driveSubsystem.run(() -> m_driveSubsystem.setModuleAngles(0)).withTimeout(1),
51+
m_driveSubsystem.run(() -> m_driveSubsystem.drive(.5, 0, rotionalSpeed, true))
52+
.withTimeout(duration),
53+
m_driveSubsystem.run(() -> m_driveSubsystem.drive(-.5, 0, -rotionalSpeed, true))
54+
.withTimeout(duration),
5155
m_driveSubsystem.run(() -> m_driveSubsystem.drive(0, 0, rotionalSpeed, false))
5256
.withTimeout(duration),
5357
m_driveSubsystem.run(() -> m_driveSubsystem.setModuleAngles(0)).withTimeout(1),
@@ -106,17 +110,14 @@ public static Command moveForwardBackward3Controllers(double distanceInFeet, dou
106110
*
107111
* @param distanceTolerance the distance error in meters which is tolerable
108112
* @param angleTolerance the angle error in degrees which is tolerable
109-
* @param refinements the number of refinments applied to the path
110113
* @param robotToTag the {@code Tranform2d} representing the pose of the
111114
* {@code AprilTag} relative to the robot when the robot is aligned
112115
* @param tagIDs the IDs of the {@code AprilTag}s
113116
* @return a {@code Command} for visiting all the specified {@code AprilTag}s
114117
*/
115-
public static Command visitTags(double distanceTolerance, double angleTolerance, int refinements,
118+
public static Command visitTags(double distanceTolerance, double angleTolerance,
116119
Transform2d robotToTag, int... tagIDs) {
117120
Pose2d[] poses = PoseEstimationSubsystem.tagPoses(tagIDs);
118-
for (int i = 0; i < refinements; i++)
119-
poses = PoseEstimationSubsystem.refine(poses);
120121
var commands = Arrays.stream(poses).map(
121122
p -> AlignCommand
122123
.moveTo(
@@ -133,18 +134,15 @@ public static Command visitTags(double distanceTolerance, double angleTolerance,
133134
* @param angleTolerance the angle error in degrees which is tolerable
134135
* @param intermediateToleranceRatio the ratio of distance and angle tolerances
135136
* at intermediate {@code AprilTags} for faster movements
136-
* @param refinements the number of refinments applied to the path
137137
* @param robotToTag the {@code Tranform2d} representing the pose of the
138138
* {@code AprilTag} relative to the robot when the robot is aligned
139139
* @param tagIDs the IDs of the {@code AprilTag}s
140140
* @return a {@code Command} for visiting all the specified {@code AprilTag}s
141141
*/
142142
public static Command visitTagsOptimized(double distanceTolerance, double angleTolerance,
143-
double intermediateToleranceRatio, int refinements, Transform2d robotToTag,
143+
double intermediateToleranceRatio, Transform2d robotToTag,
144144
int... tagIDs) {
145145
var poses = PoseEstimationSubsystem.tagPoses(tagIDs);
146-
for (int i = 0; i < refinements; i++)
147-
poses = PoseEstimationSubsystem.refine(poses);
148146
poses = Arrays.stream(poses).map(p -> p.plus(robotToTag)).toList().toArray(new Pose2d[0]);
149147
return AlignCommand.follow(
150148
m_driveSubsystem, m_poseEstimationSubsystem, distanceTolerance, angleTolerance,

src/main/java/frc/robot/Robot.java

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -68,36 +68,27 @@ public Robot() {
6868
CommandComposer.moveForwardBackward3Controllers(6, 0.03, 3));
6969
m_autoSelector.addOption(
7070
"Move around the Red Reef",
71-
CommandComposer.visitTags(0.03, 3, 0, transform(1.5, 0, 180), 11, 6, 7, 8, 9, 10, 11));
71+
CommandComposer.visitTags(0.03, 3, transform(1.5, 0, 180), 11, 6, 7, 8, 9, 10, 11));
7272
m_autoSelector.addOption(
7373
"Move around the Blue Reef",
74-
CommandComposer.visitTags(0.03, 3, 0, transform(1.5, 0, 180), 22, 17, 18, 19, 20, 21, 22));
75-
m_autoSelector.addOption(
76-
"Move around the Red Reef (Refined)",
77-
CommandComposer.visitTags(0.03, 3, 2, transform(1.5, 0, 180), 11, 6, 7, 8, 9, 10, 11));
78-
m_autoSelector.addOption(
79-
"Move around the Blue Reef (Refined)",
80-
CommandComposer.visitTags(0.03, 3, 2, transform(1.5, 0, 180), 22, 17, 18, 19, 20, 21, 22));
81-
m_autoSelector.addOption(
82-
"Move around the Red Reef (Faster)",
83-
CommandComposer.visitTagsOptimized(0.03, 3, 5, 0, transform(1.5, 0, 180), 11, 6, 7, 8, 9, 10, 11));
84-
m_autoSelector.addOption(
85-
"Move around the Blue Reef (Faster)",
86-
CommandComposer.visitTagsOptimized(0.03, 3, 5, 0, transform(1.5, 0, 180), 22, 17, 18, 19, 20, 21, 22));
87-
m_autoSelector.addOption(
88-
"Move around the Red Reef (Faster, Refined)",
89-
CommandComposer.visitTagsOptimized(0.03, 3, 5, 2, transform(1.5, 0, 180), 11, 6, 7, 8, 9, 10, 11));
90-
m_autoSelector.addOption(
91-
"Move around the Blue Reef (Faster, Refined)",
92-
CommandComposer.visitTagsOptimized(0.03, 3, 5, 2, transform(1.5, 0, 180), 22, 17, 18, 19, 20, 21, 22));
74+
CommandComposer.visitTags(0.03, 3, transform(1.5, 0, 180), 22, 17, 18, 19, 20, 21, 22));
9375
m_autoSelector.addOption(
9476
"Move around the Red Reef (Complex)",
9577
CommandComposer.visitTags(
96-
0.03, 3, 20, transform(1.2, 0, 180), transform(0.5, 0, 180), 11, 6, 7, 8, 9, 10, 11));
78+
0.03, 3, 10, transform(1.2, 0, 180), transform(0.5, 0, 180), 11, 6, 7, 8, 9, 10, 11));
9779
m_autoSelector.addOption(
9880
"Move around the Blue Reef (Complex)",
9981
CommandComposer.visitTags(
100-
0.03, 3, 20, transform(1.2, 0, 180), transform(0.5, 0, 180), 22, 17, 18, 19, 20, 21, 22));
82+
0.03, 3, 10, transform(1.2, 0, 180), transform(0.5, 0, 180), 22, 17, 18, 19, 20, 21, 22));
83+
m_autoSelector.addOption(
84+
"Quickly Visit Red Team Tags",
85+
CommandComposer
86+
.visitTagsOptimized(0.03, 2, 5, transform(1.5, 0, 180), 11, 1, 6, 7, 8, 2, 8, 7, 6, 11));
87+
m_autoSelector.addOption(
88+
"Quickly Visit Blue Team Tags",
89+
CommandComposer
90+
.visitTagsOptimized(
91+
0.03, 2, 5, transform(1.5, 0, 180), 22, 12, 17, 18, 19, 13, 19, 18, 17, 22));
10192
SmartDashboard.putData(m_autoSelector);
10293

10394
SmartDashboard.putData(m_pdh);
@@ -187,7 +178,6 @@ public void disabledExit() {
187178
@Override
188179
public void autonomousInit() {
189180
m_autonomousCommand = m_autoSelector.getSelected();
190-
191181
if (m_autonomousCommand != null) {
192182
m_autonomousCommand.schedule();
193183
}

0 commit comments

Comments
 (0)