limelight s'anligne test
This commit is contained in:
@@ -10,6 +10,7 @@ import java.util.function.DoubleSupplier;
|
||||
import com.ctre.phoenix6.swerve.SwerveModule.DriveRequestType;
|
||||
import com.ctre.phoenix6.swerve.SwerveRequest;
|
||||
|
||||
import edu.wpi.first.math.MathUtil;
|
||||
import edu.wpi.first.wpilibj2.command.Command;
|
||||
import frc.robot.TunerConstants.TunerConstants;
|
||||
import frc.robot.subsystems.CommandSwerveDrivetrain;
|
||||
@@ -47,14 +48,37 @@ public class AprilTag3 extends Command {
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
double a = limelight3.getTx();
|
||||
double b = 1.46 / Math.sqrt((limelight3.getTA()/100) / (Math.cos(90-limelight3.getTx())));
|
||||
double[] targetPose = limelight3.getTargetPose();
|
||||
double[] BotPose = limelight3.getBotPose();
|
||||
double z = targetPose[2];
|
||||
double x = targetPose[0];
|
||||
double Botyaw = BotPose[5];
|
||||
double tx = limelight3.getTx();
|
||||
if(limelight3.getV() == true){
|
||||
if(Botyaw > 0 && Botyaw <=90){
|
||||
drivetrain.setControl(drive.
|
||||
withRotationalRate(tx/20).
|
||||
withVelocityX(MathUtil.clamp(x/4, -1, 1)).
|
||||
withVelocityY(MathUtil.clamp(z/4, -1, 1)));
|
||||
}
|
||||
else if(Botyaw >90 && Botyaw <=180){
|
||||
drivetrain.setControl(drive.
|
||||
withRotationalRate(a/20).
|
||||
withVelocityX(b/50).
|
||||
withVelocityY( 0));
|
||||
System.out.println(b/50);
|
||||
withRotationalRate(tx/20).
|
||||
withVelocityX(MathUtil.clamp(-x/4, -1, 1)).
|
||||
withVelocityY(MathUtil.clamp(z/4, -1, 1)));
|
||||
}
|
||||
else if(Botyaw >-90 && Botyaw <=0){
|
||||
drivetrain.setControl(drive.
|
||||
withRotationalRate(tx/20).
|
||||
withVelocityX(MathUtil.clamp(-x/4, -1, 1)).
|
||||
withVelocityY(MathUtil.clamp(-z/4, -1, 1)));
|
||||
}
|
||||
else if(Botyaw >-180 && Botyaw <=-90){
|
||||
drivetrain.setControl(drive.
|
||||
withRotationalRate(tx/20).
|
||||
withVelocityX(MathUtil.clamp(x/4, -1, 1)).
|
||||
withVelocityY(MathUtil.clamp(-z/4, -1, 1)));
|
||||
}
|
||||
}
|
||||
else{
|
||||
drivetrain.setControl(drive.
|
||||
|
||||
Reference in New Issue
Block a user