s'enligne vers le apriltag
This commit is contained in:
@@ -10,10 +10,11 @@ import java.util.function.DoubleSupplier;
|
||||
|
||||
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
|
||||
import com.ctre.phoenix6.swerve.SwerveRequest;
|
||||
|
||||
import edu.wpi.first.math.filter.SlewRateLimiter;
|
||||
import edu.wpi.first.math.MathUtil;
|
||||
import edu.wpi.first.wpilibj.DriverStation;
|
||||
import edu.wpi.first.wpilibj.DriverStation.Alliance;
|
||||
import edu.wpi.first.wpilibj.SynchronousInterrupt.WaitResult;
|
||||
import edu.wpi.first.wpilibj2.command.Command;
|
||||
import frc.robot.TunerConstants.TunerConstants;
|
||||
import frc.robot.subsystems.CommandSwerveDrivetrain;
|
||||
@@ -51,7 +52,7 @@ public class AprilTag3 extends Command {
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
double[] BotPose = new double[7];
|
||||
double[] BotPose = new double[6];
|
||||
Optional<DriverStation.Alliance> alliance = DriverStation.getAlliance();
|
||||
if(alliance.get() == DriverStation.Alliance.Red){
|
||||
BotPose = limelight3.getBotPoseRed();
|
||||
@@ -60,18 +61,24 @@ public class AprilTag3 extends Command {
|
||||
BotPose = limelight3.getBotPoseBlue();
|
||||
}
|
||||
double botx = BotPose[0];
|
||||
double botz = BotPose[2];
|
||||
double boty = BotPose[1];
|
||||
double tx = limelight3.getTx();
|
||||
double tagId = BotPose[7];
|
||||
double tagId = limelight3.getTId();
|
||||
if(limelight3.getV() == true){
|
||||
if(tagId ==8){
|
||||
if(tagId ==10){
|
||||
drivetrain.setControl(drive.
|
||||
withRotationalRate(tx/20).
|
||||
withVelocityX(2-botx).
|
||||
withVelocityY(2-botz));
|
||||
withVelocityX((botx-5.81)*2).
|
||||
withVelocityY((boty-4)*4));
|
||||
}
|
||||
else if(tagId ==7){
|
||||
drivetrain.setControl(drive.
|
||||
withRotationalRate(tx/20).
|
||||
withVelocityX(-(botx-2.21)*2).
|
||||
withVelocityY(-(boty-4)*4));
|
||||
}
|
||||
}
|
||||
else{
|
||||
else{
|
||||
drivetrain.setControl(drive.
|
||||
withRotationalRate(0).
|
||||
withVelocityX(0).
|
||||
|
||||
Reference in New Issue
Block a user