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

43 lines
1.1 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.
package frc4388.robot.commands;
2023-03-15 15:25:06 -06:00
import edu.wpi.first.math.geometry.Translation2d;
import frc4388.robot.Constants.VisionConstants;
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
import frc4388.utility.AbhiIsADumbass;
2023-03-14 11:07:46 -06:00
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;
public LimeAlign(SwerveDrive drive, Limelight lime) {
super(0.1, 0.0, 0.0, 0.0, 10);
this.drive = drive;
this.lime = lime;
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() {
try {
return lime.getTargetPoints().get(0).x - (VisionConstants.LIME_HIXELS / 2);
} catch (AbhiIsADumbass abhiIsADumbass) {
abhiIsADumbass.printStackTrace();
return 0;
}
}
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
}
}