Skip to content

Commit 6fe746c

Browse files
committed
spotless
1 parent 73c2e4d commit 6fe746c

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package frc.robot.constants;
22

33
public class RobotStateConstants {
4-
public static final double[] kNodeAngles = {0.0, 60.0, 120.0, 180.0, -120.0, -60.0};
4+
public static final double[] kNodeAngles = {0.0, 60.0, 120.0, 180.0, -120.0, -60.0};
55
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package frc.robot.constants;
22

33
public class TagServoingConstants {
4-
public static final double kAngleCloseEnough = 3.0;
4+
public static final double kAngleCloseEnough = 3.0;
55
}

src/main/java/frc/robot/subsystems/pathHandler/PathHandler.java

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
package frc.robot.subsystems.pathHandler;
22

33
import choreo.Choreo;
4-
54
import choreo.trajectory.SwerveSample;
65
import choreo.trajectory.Trajectory;
76
import edu.wpi.first.wpilibj.Timer;
8-
import frc.robot.Robot;
97
import frc.robot.constants.RobotStateConstants;
108
import frc.robot.constants.TagServoingConstants;
119
import frc.robot.subsystems.drive.DriveSubsystem;
12-
import net.jafama.FastMath;
13-
1410
import java.util.List;
1511
import java.util.Optional;
1612
import java.util.Set;
13+
import net.jafama.FastMath;
1714
import org.strykeforce.telemetry.measurable.MeasurableSubsystem;
1815
import org.strykeforce.telemetry.measurable.Measure;
1916

@@ -133,13 +130,16 @@ private void drivePath() {
133130

134131
private void drivePathServo() {
135132
if (isHandling && runningPath && currPath != null && isServoing) {
136-
driveSubsystem.calculateControllerServo(currPath.sampleAt(timer.get(), mirrorTrajectory).get(), 0.0); // TODO: use tag servoing here when ready
133+
driveSubsystem.calculateControllerServo(
134+
currPath.sampleAt(timer.get(), mirrorTrajectory).get(),
135+
0.0); // TODO: use tag servoing here when ready
137136
if (timer.hasElapsed(currPath.getTotalTime())) {
138137
driveSubsystem.setAutoDebugMsg("End " + currPathString);
139138
runningPath = false;
140139
timer.stop();
141140
timer.reset();
142-
driveSubsystem.calculateControllerServo(currPath.getFinalSample(mirrorTrajectory).get(), 0.0);
141+
driveSubsystem.calculateControllerServo(
142+
currPath.getFinalSample(mirrorTrajectory).get(), 0.0);
143143
if (currState == PathStates.DRIVE_FETCH) {
144144
currState = PathStates.FETCH;
145145
} else if (currState == PathStates.DRIVE_PLACE_SERVO) {
@@ -186,17 +186,25 @@ public void killPathHandlerAfterPath() {
186186

187187
private boolean shouldTransitionToServoing() {
188188
boolean isCloseEnough = false;
189-
double preNormalizedAngle = FastMath.toRadians(RobotStateConstants.kNodeAngles[FastMath.floorToInt((NodeNames.get(0) - 'a') / 2)]);
190-
double goal = mirrorTrajectory ? FastMath.normalizeMinusPiPi(preNormalizedAngle + Math.PI) : preNormalizedAngle;
189+
double preNormalizedAngle =
190+
FastMath.toRadians(
191+
RobotStateConstants.kNodeAngles[FastMath.floorToInt((NodeNames.get(0) - 'a') / 2)]);
192+
double goal =
193+
mirrorTrajectory
194+
? FastMath.normalizeMinusPiPi(preNormalizedAngle + Math.PI)
195+
: preNormalizedAngle;
191196
double pos = driveSubsystem.getGyroRotation2d().getRadians();
192-
if (goal < -Math.PI/2 || goal > Math.PI/2) {
193-
isCloseEnough = FastMath.abs(FastMath.normalizeZeroTwoPi(pos) - FastMath.normalizeZeroTwoPi(goal)) < FastMath.toRadians(TagServoingConstants.kAngleCloseEnough);
197+
if (goal < -Math.PI / 2 || goal > Math.PI / 2) {
198+
isCloseEnough =
199+
FastMath.abs(FastMath.normalizeZeroTwoPi(pos) - FastMath.normalizeZeroTwoPi(goal))
200+
< FastMath.toRadians(TagServoingConstants.kAngleCloseEnough);
194201
} else {
195-
isCloseEnough = FastMath.abs(pos - goal) < FastMath.toRadians(TagServoingConstants.kAngleCloseEnough);
202+
isCloseEnough =
203+
FastMath.abs(pos - goal) < FastMath.toRadians(TagServoingConstants.kAngleCloseEnough);
196204
}
197205
return currState == PathStates.DRIVE_PLACE
198-
&& timer.hasElapsed(currPath.getTotalTime() - 1.0)
199-
&& isCloseEnough;
206+
&& timer.hasElapsed(currPath.getTotalTime() - 1.0)
207+
&& isCloseEnough;
200208
}
201209

202210
public void periodic() {
@@ -209,8 +217,8 @@ public void periodic() {
209217
break;
210218
case FETCH:
211219
// if (robotStateSubsystem.hasPiece) {
212-
advanceNodes();
213-
currState = PathStates.DRIVE_PLACE;
220+
advanceNodes();
221+
currState = PathStates.DRIVE_PLACE;
214222
// }
215223
break;
216224
case DRIVE_PLACE:
@@ -226,7 +234,7 @@ public void periodic() {
226234
break;
227235
case PLACE:
228236
// if (RobotStateSubsystem.State != RobotStateSubsystem.hasPiece) {
229-
currState = PathStates.DRIVE_FETCH;
237+
currState = PathStates.DRIVE_FETCH;
230238
// }
231239
break;
232240
case DONE:

0 commit comments

Comments
 (0)