Skip to content

Commit 2cbf266

Browse files
author
Roberts Kalnins
committed
Remove more timing
1 parent 5ec6eb0 commit 2cbf266

File tree

3 files changed

+3
-31
lines changed

3 files changed

+3
-31
lines changed

src/main/java/frc/team2767/deepspace/Robot.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@
66
import edu.wpi.first.wpilibj.command.CommandGroup;
77
import edu.wpi.first.wpilibj.command.Scheduler;
88
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
9-
import frc.team2767.deepspace.command.approach.sandstorm.SandstormCommandGroup;
109
import frc.team2767.deepspace.command.sequences.pickup.SandstormHatchPickupCommandGroup;
1110
import frc.team2767.deepspace.control.AutonChooser;
1211
import frc.team2767.deepspace.control.Controls;
1312
import frc.team2767.deepspace.subsystem.*;
1413
import frc.team2767.deepspace.subsystem.safety.SafetySubsystem;
15-
import org.slf4j.Logger;
16-
import org.slf4j.LoggerFactory;
1714
import org.strykeforce.thirdcoast.telemetry.TelemetryController;
1815
import org.strykeforce.thirdcoast.telemetry.TelemetryService;
1916
import org.strykeforce.thirdcoast.trapper.Session;

src/main/java/frc/team2767/deepspace/command/approach/VisionAutoAlignPickupCommand.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package frc.team2767.deepspace.command.approach;
22

33
import edu.wpi.first.wpilibj.DriverStation;
4-
import edu.wpi.first.wpilibj.Timer;
54
import edu.wpi.first.wpilibj.command.Command;
65
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
76
import frc.team2767.deepspace.Robot;
@@ -21,7 +20,6 @@ public class VisionAutoAlignPickupCommand extends Command {
2120
private static final double MAX_YAW = 0.3;
2221
private static final double goodEnoughYaw = 1.5;
2322
private static final double DRIVE_EXPO = 0.5;
24-
private static final double YAW_EXPO = 0.5;
2523
private static final double DEADBAND = 0.05;
2624
private static final double MIN_RANGE = 35.0;
2725
private static final double FWD_SCALE = 0.6;
@@ -31,23 +29,18 @@ public class VisionAutoAlignPickupCommand extends Command {
3129
private static final DriveSubsystem DRIVE = Robot.DRIVE;
3230
private static final VisionSubsystem VISION = Robot.VISION;
3331
private final ExpoScale driveExpo;
34-
private final ExpoScale yawExpo;
3532
private final Logger logger = LoggerFactory.getLogger(this.getClass());
3633
private double range;
37-
private double strafeError;
38-
private double yawError;
3934
private DriverControls controls;
4035
private double strafeCorrection;
4136
private boolean isAuton;
4237
private double targetYaw;
4338
private boolean isGood = false;
4439
private RateLimit strafeRateLimit;
45-
private double last;
4640

4741
public VisionAutoAlignPickupCommand() {
4842
requires(DRIVE);
4943
this.driveExpo = new ExpoScale(DEADBAND, DRIVE_EXPO);
50-
this.yawExpo = new ExpoScale(DEADBAND, YAW_EXPO);
5144
strafeRateLimit = new RateLimit(0.04); // 0.015
5245
}
5346

@@ -64,7 +57,6 @@ protected void initialize() {
6457
} else targetYaw = 90.0;
6558
DRIVE.setTargetYaw(targetYaw);
6659
logger.info("Target Yaw: {}", targetYaw);
67-
last = Timer.getFPGATimestamp();
6860
}
6961

7062
@SuppressWarnings("Duplicates")
@@ -76,7 +68,7 @@ protected void execute() {
7668
isGood = range >= 0; // check if range is good (we have a target), not -1
7769

7870
// Calculate Yaw Term based on gyro
79-
yawError = targetYaw - Math.IEEEremainder(DRIVE.getGyro().getAngle(), 360.0);
71+
double yawError = targetYaw - Math.IEEEremainder(DRIVE.getGyro().getAngle(), 360.0);
8072
DRIVE.setYawError(yawError);
8173
double yaw = kP_YAW * yawError;
8274
if (yaw > MAX_YAW) yaw = MAX_YAW;
@@ -96,7 +88,8 @@ protected void execute() {
9688
}
9789

9890
double strafe;
99-
strafeError = Math.sin(Math.toRadians(VISION.getCorrectedBearing())) * range - strafeCorrection;
91+
double strafeError =
92+
Math.sin(Math.toRadians(VISION.getCorrectedBearing())) * range - strafeCorrection;
10093

10194
VISION.setStrafeError(strafeError);
10295

src/main/java/frc/team2767/deepspace/subsystem/VisionSubsystem.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ public class VisionSubsystem extends Subsystem implements Item {
7272
private LightPattern currentPattern;
7373
private double lightState;
7474
private double strafeError = 0;
75-
private int counter;
7675

7776
public VisionSubsystem() {
7877

@@ -100,12 +99,6 @@ public VisionSubsystem() {
10099
TelemetryService telemetryService = Robot.TELEMETRY;
101100
telemetryService.stop();
102101
telemetryService.register(this);
103-
counter = 0;
104-
}
105-
106-
@Override
107-
public void periodic() {
108-
counter++;
109102
}
110103

111104
public double getCorrectedRange() {
@@ -147,7 +140,6 @@ public boolean isTargetAcquired() {
147140
public void queryPyeye() {
148141
rawBearing = (double) bearingEntry.getNumber(0.0);
149142
rawRange = (double) rangeEntry.getNumber(-1.0);
150-
counter++;
151143
}
152144

153145
public void setGamePiece(GamePiece gamePiece) {
@@ -274,20 +266,10 @@ public int compareTo(@NotNull Item item) {
274266
return 0;
275267
}
276268

277-
public void setCounter(int counter) {
278-
this.counter = counter;
279-
}
280-
281-
public int getCounter() {
282-
return counter % 20;
283-
}
284-
285269
@NotNull
286270
@Override
287271
public DoubleSupplier measurementFor(@NotNull Measure measure) {
288272
switch (measure) {
289-
case UNKNOWN:
290-
return this::getCounter;
291273
case POSITION:
292274
return this::getRawRange;
293275
case ANGLE:

0 commit comments

Comments
 (0)