Skip to content

Commit 32b7401

Browse files
committed
removed unnecessary test cases.
1 parent 2fd5b06 commit 32b7401

File tree

2 files changed

+10
-103
lines changed

2 files changed

+10
-103
lines changed

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

Lines changed: 3 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@
33
import static edu.wpi.first.math.util.Units.*;
44
import static edu.wpi.first.wpilibj2.command.Commands.*;
55
import static frc.robot.Constants.*;
6-
import static frc.robot.Constants.DriveConstants.*;
76
import static frc.robot.subsystems.PoseEstimationSubsystem.*;
87

98
import java.util.LinkedList;
109
import java.util.List;
1110
import java.util.function.Supplier;
1211

1312
import edu.wpi.first.math.geometry.Pose2d;
14-
import edu.wpi.first.math.geometry.Rotation2d;
1513
import edu.wpi.first.math.geometry.Transform2d;
1614
import edu.wpi.first.wpilibj2.command.Command;
1715
import edu.wpi.first.wpilibj2.command.Commands;
16+
import edu.wpi.first.wpilibj2.command.WaitCommand;
1817
import frc.robot.commands.DriveCommand;
1918
import frc.robot.commands.PathDriveCommand;
2019
import frc.robot.subsystems.DriveSubsystem;
@@ -40,38 +39,6 @@ public static Command testAllSubsystems() {
4039
m_driveSubsystem.testCommand());
4140
}
4241

43-
/**
44-
* Returns a {@code Command} for testing the rotation capability of the robot.
45-
*
46-
* @return a {@code Command} for testing the rotation capability of the robot
47-
*/
48-
public static Command testRotation() {
49-
double rotionalSpeed = kTurnMaxAngularSpeed * 0.9;
50-
double duration = 2.0;
51-
return sequence(
52-
m_driveSubsystem.run(() -> m_driveSubsystem.setModuleAngles(0)).withTimeout(0.1),
53-
m_driveSubsystem.run(() -> m_driveSubsystem.drive(.5, 0, rotionalSpeed, true))
54-
.withTimeout(duration),
55-
m_driveSubsystem.run(() -> m_driveSubsystem.drive(-.5, 0, -rotionalSpeed, true))
56-
.withTimeout(duration),
57-
m_driveSubsystem.run(() -> m_driveSubsystem.drive(0.05, 0, 0, false))
58-
.withTimeout(duration),
59-
m_driveSubsystem.run(() -> m_driveSubsystem.drive(0, 0, rotionalSpeed, false))
60-
.withTimeout(duration),
61-
m_driveSubsystem.run(() -> m_driveSubsystem.drive(0.05, 0, 0, false))
62-
.withTimeout(duration),
63-
m_driveSubsystem.run(() -> m_driveSubsystem.drive(0, 0, -rotionalSpeed, false))
64-
.withTimeout(duration),
65-
m_driveSubsystem.run(() -> m_driveSubsystem.drive(0.05, 0, 0, false))
66-
.withTimeout(duration),
67-
m_driveSubsystem.run(() -> m_driveSubsystem.drive(0, 0, rotionalSpeed, false))
68-
.withTimeout(duration),
69-
m_driveSubsystem.run(() -> m_driveSubsystem.drive(0.05, 0, 0, false))
70-
.withTimeout(duration),
71-
m_driveSubsystem.run(() -> m_driveSubsystem.drive(0, 0, -rotionalSpeed, false))
72-
.withTimeout(duration));
73-
}
74-
7542
/**
7643
* Returns a {@code Command} for moving forward and then backward.
7744
*
@@ -81,7 +48,7 @@ public static Command testRotation() {
8148
*
8249
* @return a {@code Command} for moving forward and then backward.
8350
*/
84-
public static Command moveForwardBackward2Controllers(double distanceInFeet, double distanceTolerance,
51+
public static Command moveForwardBackward(double distanceInFeet, double distanceTolerance,
8552
double angleTolerance) {
8653
return sequence(
8754
new DriveCommand(m_driveSubsystem, distanceTolerance, angleTolerance, pose(0.0, 0, 0)),
@@ -119,58 +86,6 @@ distanceTolerance, angleTolerance, pose(0.0, 0, 0)).withTimeout(1),
11986
new DriveCommand(m_driveSubsystem, distanceTolerance, angleTolerance, pose(0.0, 0, 0)));
12087
}
12188

122-
/**
123-
* Returns a {@code Command} for moving the robot on a circle.
124-
*
125-
* @param radius the radius of the circle in meters
126-
* @param initialAngularIncrement the initial angular increment in degrees which
127-
* describes how quickly the robot to move on the circle
128-
* @param finalAngularIncrement the final angular increment in degrees which
129-
* describes how quickly the robot to move on the circle
130-
* @param distanceTolerance the distance error in meters which is tolerable
131-
* @param angleTolerance the angle error in degrees which is tolerable
132-
* @param intermediateDistanceTolerance the distance error in meters which is
133-
* tolerable for intermeidate target {@code Pose2d}s
134-
* @param intermediateAngleToleranceInDegrees the angle error in degrees which
135-
* is tolerable for intermeidate target {@code Pose2d}s
136-
* @param poseCount the number of {@code Pose2d}s on the circle
137-
*
138-
* @return a {@code Command} for moving the robot on a circle
139-
*/
140-
public static Command moveOnOval(double radius, double initialAngularIncrement, double finalAngularIncrement,
141-
double distanceTolerance, double angleTolerance, double intermediateDistanceTolerance,
142-
double intermediateAngleToleranceInDegrees, int poseCount) {
143-
Rotation2d angle = Rotation2d.kZero;
144-
var l = new LinkedList<Pose2d>();
145-
for (double i = 0; i < poseCount; i++) {
146-
var t = translation(radius, 0).rotateBy(angle);
147-
l.add(new Pose2d(translation(t.getX() + radius, t.getY() / 2), angle));
148-
double progress = i / poseCount;
149-
double angularVelocity = progress * finalAngularIncrement + (1 - progress) * initialAngularIncrement;
150-
angle = angle.plus(rotation(angularVelocity));
151-
}
152-
return new PathDriveCommand(m_driveSubsystem, distanceTolerance, angleTolerance, intermediateDistanceTolerance,
153-
intermediateAngleToleranceInDegrees, l.toArray(new Pose2d[0]));
154-
}
155-
156-
/**
157-
* Returns a {@code Command} for turning the robot toward the specified
158-
* {@code AprilTag}.
159-
*
160-
* @param tagID the ID of the {@code AprilTag}
161-
* @return a {@code Command} for turning the robot toward the specified
162-
* {@code AprilTag}
163-
*/
164-
public static Command turnTowardTag(int tagID) {
165-
return m_driveSubsystem.run(() -> {
166-
Rotation2d a = m_poseEstimationSubsystem.angularDisplacement(1);
167-
if (a != null)
168-
m_driveSubsystem.drive(
169-
0, 0, a.getRadians() * kTurnP,
170-
false);
171-
}).withTimeout(1);
172-
}
173-
17489
/**
17590
* Returns a {@code Command} for aligning the robot to the specified
17691
* {@code AprilTag}s.
@@ -209,7 +124,7 @@ public static Command alignToTags(double distanceTolerance, double angleToleranc
209124
intermediateDistanceTolerance, intermediateAngleToleranceInDegrees, l.stream()
210125
.map(p -> (Supplier<Pose2d>) (() -> m_poseEstimationSubsystem.odometryCentricPose(p)))
211126
.toList());
212-
commands.add(command);
127+
commands.add(command.andThen(new WaitCommand(.5)));
213128
}
214129
return sequence(commands.toArray(new Command[0]));
215130
}

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

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,8 @@ public Robot() {
7272
double intermediateDistanceTolerance = 0.16;
7373
double intermediateAngleToleranceInDegrees = 16.0;
7474

75-
m_testSelector
76-
.addOption(
77-
"Check kDriveGearRatio and kWheelDiameter (F/B 6 feet)",
78-
CommandComposer.moveForwardBackward2Controllers(6, distanceTolerance, angleToleranceInDegrees));
79-
m_testSelector
80-
.addOption(
81-
"Check PID Constants for Driving (Oval with Max Radius of 1m)",
82-
CommandComposer.moveOnOval(
83-
1, 8, 16, distanceTolerance, angleToleranceInDegrees, intermediateDistanceTolerance,
84-
intermediateAngleToleranceInDegrees, 360 / 12 * 3 / 2));
75+
m_testSelector.addOption("Check All Subsystems in Pitt", CommandComposer.testAllSubsystems());
76+
m_testSelector.addOption("Check All Subsystems on Field", CommandComposer.testAllSubsystems());
8577
m_testSelector
8678
.addOption(
8779
"Quickly Align to AprilTags 1, 2, 6, 7, and 8",
@@ -91,18 +83,18 @@ public Robot() {
9183
List.of(transform(1.5, 0, 180), transform(1.0, 0, 180), transform(.5, 0, 180)),
9284
transform(1.5, 0, 180), 7, 6, 1,
9385
6, 7, 8, 2, 8, 7));
94-
m_testSelector.addOption("Check All Subsystems in Pitt", CommandComposer.testAllSubsystems());
95-
m_testSelector.addOption("Check All Subsystems on Field", CommandComposer.testAllSubsystems());
9686
m_testSelector
9787
.addOption(
98-
"Check DriveSubsystem (F/B/L/R/LR/RR and F/B while rotating)", m_driveSubsystem.testCommand());
88+
"Check kDriveGearRatio and kWheelDiameter (F/B 6 feet)",
89+
CommandComposer.moveForwardBackward(6, distanceTolerance, angleToleranceInDegrees));
9990
m_testSelector
10091
.addOption(
10192
"Check PID Constants for Driving (5'x5' Square)",
10293
CommandComposer
10394
.moveOnSquare(Units.feetToMeters(5), distanceTolerance, angleToleranceInDegrees, 16));
104-
m_testSelector.addOption("Test Rotation", CommandComposer.testRotation());
105-
m_testSelector.addOption("Turn toward Tag 1", CommandComposer.turnTowardTag(1));
95+
m_testSelector
96+
.addOption(
97+
"Check DriveSubsystem (F/B/L/R/LR/RR and F/B while rotating)", m_driveSubsystem.testCommand());
10698

10799
SmartDashboard.putData("Test Selector", m_testSelector);
108100

0 commit comments

Comments
 (0)