Skip to content

Commit 266c181

Browse files
committed
Remove unused methods and imports from PathFinder for improved clarity
1 parent 8e04ed1 commit 266c181

File tree

1 file changed

+0
-79
lines changed

1 file changed

+0
-79
lines changed

src/main/java/frc/robot/Utilitys/PathFinder.java

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -5,92 +5,13 @@
55
import com.pathplanner.lib.config.PIDConstants;
66
import com.pathplanner.lib.config.RobotConfig;
77
import com.pathplanner.lib.controllers.PPHolonomicDriveController;
8-
import edu.wpi.first.math.controller.ProfiledPIDController;
9-
import edu.wpi.first.math.geometry.Pose2d;
10-
import edu.wpi.first.math.geometry.Rotation2d;
11-
import edu.wpi.first.math.kinematics.ChassisSpeeds;
128
import edu.wpi.first.math.system.plant.DCMotor;
139
import edu.wpi.first.wpilibj.DriverStation;
14-
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
1510
import frc.robot.Subsystems.Drive.Drive;
16-
import frc.robot.Subsystems.Drive.DriveStates;
1711
import swervelib.SwerveDrive;
1812

1913
public class PathFinder {
2014

21-
public static Pose2d getNearestTargetPose(DriveStates state, Pose2d currentPose) {
22-
Pose2d nearestPose = null;
23-
double nearestDistance = Double.MAX_VALUE;
24-
25-
for (Pose2d pose : state.getTargetPoses()) {
26-
double distance = getDistance(currentPose, pose);
27-
if (distance < nearestDistance) {
28-
nearestPose = pose;
29-
nearestDistance = distance;
30-
}
31-
}
32-
return nearestPose;
33-
}
34-
35-
public static Pose2d MirrorPoseNear(DriveStates state, Pose2d currentPose) {
36-
Pose2d nearestPose = null;
37-
double nearestDistance = Double.MAX_VALUE;
38-
Pose2d workingPose;
39-
40-
for (Pose2d pose : state.getTargetPoses()) {
41-
workingPose = MirrorPose(pose);
42-
double distance = getDistance(currentPose, workingPose);
43-
if (distance < nearestDistance) {
44-
nearestPose = workingPose;
45-
nearestDistance = distance;
46-
}
47-
}
48-
return nearestPose;
49-
}
50-
51-
public static Pose2d MirrorPose(Pose2d input) {
52-
return new Pose2d(
53-
(8.77 * 2) - input.getX(),
54-
input.getY(),
55-
new Rotation2d(-input.getRotation().getRadians())
56-
);
57-
}
58-
59-
public static double getDistance(Pose2d a, Pose2d b) {
60-
return (a.getTranslation().getDistance(b.getTranslation()));
61-
}
62-
63-
public static ChassisSpeeds driveToPose(
64-
Pose2d targetPose,
65-
Pose2d currentPose,
66-
ProfiledPIDController x,
67-
ProfiledPIDController y,
68-
ProfiledPIDController omega
69-
) {
70-
double rotationOutput = omega.calculate(
71-
currentPose.getRotation().getRadians(),
72-
targetPose.getRotation().getRadians()
73-
);
74-
double xOutput = x.calculate(currentPose.getX(), targetPose.getX());
75-
double yOutput = y.calculate(currentPose.getY(), targetPose.getY());
76-
77-
return new ChassisSpeeds(xOutput, yOutput, rotationOutput);
78-
}
79-
80-
public static Pose2d getAssignedCagePose(
81-
SendableChooser<Pose2d[]> cageChooser,
82-
Pose2d curentPose
83-
) {
84-
if (
85-
getDistance(cageChooser.getSelected()[0], curentPose) >
86-
getDistance(cageChooser.getSelected()[1], curentPose)
87-
) {
88-
return cageChooser.getSelected()[1];
89-
} else {
90-
return cageChooser.getSelected()[0];
91-
}
92-
}
93-
9415
public static void BuildAutoBuilder(SwerveDrive swerveDrive, Drive drive) {
9516
// Auto Builder and Pathfinder setup:
9617
RobotConfig config = null;

0 commit comments

Comments
 (0)