Files
2023WayOfTheRobot/src/main/java/frc4388/robot/commands/Placement/LimeAlign.java
T

49 lines
1.3 KiB
Java
Raw Normal View History

2023-03-14 11:07:46 -06:00
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
2023-03-16 19:14:08 -06:00
package frc4388.robot.commands.Placement;
2023-03-14 11:07:46 -06:00
2023-03-16 23:08:08 -06:00
import java.util.function.DoubleSupplier;
2023-03-15 15:25:06 -06:00
import edu.wpi.first.math.geometry.Translation2d;
import frc4388.robot.Constants.VisionConstants;
2023-03-16 19:14:08 -06:00
import frc4388.robot.commands.PelvicInflammatoryDisease;
2023-03-15 15:25:06 -06:00
import frc4388.robot.subsystems.Limelight;
2023-03-14 11:07:46 -06:00
import frc4388.robot.subsystems.SwerveDrive;
2023-03-15 15:25:06 -06:00
public class LimeAlign extends PelvicInflammatoryDisease {
2023-03-14 11:07:46 -06:00
2023-03-15 15:25:06 -06:00
SwerveDrive drive;
Limelight lime;
2023-03-16 23:08:08 -06:00
DoubleSupplier ds;
2023-03-17 15:14:53 -06:00
public LimeAlign(SwerveDrive drive, Limelight lime, DoubleSupplier ds, double tolerance) {
super(0.4, 0.4, 0.0, 0.0, tolerance);
2023-03-15 15:25:06 -06:00
this.drive = drive;
this.lime = lime;
2023-03-16 23:08:08 -06:00
this.ds = ds;
2023-03-14 11:07:46 -06:00
2023-03-15 15:25:06 -06:00
addRequirements(drive, lime);
2023-03-14 11:07:46 -06:00
}
@Override
2023-03-15 15:25:06 -06:00
public double getError() {
2023-03-16 16:25:26 -06:00
double err = 0.0;
2023-03-15 15:25:06 -06:00
try {
2023-03-17 15:14:53 -06:00
System.out.println(ds.getAsDouble());
err = ds.getAsDouble() / (VisionConstants.H_FOV / 2);
2023-03-16 16:25:26 -06:00
} catch (NullPointerException ex) {}
return err;
2023-03-15 15:25:06 -06:00
}
2023-03-14 11:07:46 -06:00
@Override
2023-03-15 15:25:06 -06:00
public void runWithOutput(double output) {
drive.driveWithInput(new Translation2d(output, 0.0), new Translation2d(0.0, 0.0), true);
2023-03-14 11:07:46 -06:00
}
}