lime stuff works

This commit is contained in:
aarav18
2023-03-16 16:25:26 -06:00
parent ff2c34a26e
commit 6b2ca9e433
4 changed files with 62 additions and 29 deletions
@@ -4,20 +4,20 @@
package frc4388.robot.commands;
import org.photonvision.targeting.PhotonTrackedTarget;
import edu.wpi.first.math.geometry.Translation2d;
import frc4388.robot.Constants.VisionConstants;
import frc4388.robot.subsystems.Limelight;
import frc4388.robot.subsystems.SwerveDrive;
import frc4388.utility.AbhiIsADumbass;
public class LimeAlign extends PelvicInflammatoryDisease {
SwerveDrive drive;
Limelight lime;
public LimeAlign(SwerveDrive drive, Limelight lime) {
super(0.1, 0.0, 0.0, 0.0, 10);
super(0.7, 0.1, 0.0, 0.0, 0);
this.drive = drive;
this.lime = lime;
@@ -27,16 +27,24 @@ public class LimeAlign extends PelvicInflammatoryDisease {
@Override
public double getError() {
double err = 0.0;
try {
return lime.getTargetPoints().get(0).x - (VisionConstants.LIME_HIXELS / 2);
} catch (AbhiIsADumbass abhiIsADumbass) {
abhiIsADumbass.printStackTrace();
return 0;
}
err = lime.getFirstTargetPoint().getYaw() / (VisionConstants.H_FOV / 2);
} catch (NullPointerException ex) {}
return err;
}
@Override
public void runWithOutput(double output) {
if (output > 0) {
output += 0.6;
} else if (output < 0) {
output -= 0.6;
}
drive.driveWithInput(new Translation2d(output, 0.0), new Translation2d(0.0, 0.0), true);
}
}