April Tag Auto Alignment Help

Hello! I’m getting started with Auto Aligning and I’m wondering if the following code would work. We use YAGSL and the official Limelight software. The goal is to be able to line up with the Amp (April Tags 5 and 6) rotationally with the code and then drive up to it manually. Will this work or is there a better way to do it? Thank you!

public void autoLineup() {

    CommandXboxController driverController = RobotContainer.getDriverController();
    double forward = driverController.getLeftY();
    double strafe = driverController.getLeftX();
    final Translation2d translation2dAutoLineup = new Translation2d(forward, strafe);
    double getX = LimelightHelpers.getTX("limelight");
    if (LimelightHelpers.getLatestResults("limelight") != null && (LimelightHelpers.getFiducialID("limelight") == 5
     || LimelightHelpers.getFiducialID("limelight") == 6)) {

        swerveDrive.drive(translation2dAutoLineup, getX, true, false);
        System.out.println("Auto Lineup Complete");
      }
}

You may wanna look at https://github.com/BroncBotz3481/YAGSL-Example/blob/dev/src%2Fmain%2Fjava%2Ffrc%2Frobot%2Fsubsystems%2Fswervedrive%2FSwerveSubsystem.java#L133-L151

and take inspiration. It should use a PID and yiu can use the one from controllerproperties.json

Thanks! Unfortunately, we couldn’t get PhotonVision working and Limelight OS is what we know how to use. Is there a similar function to call when the Limelight sees a target for Limelight OS? I used LimelightHelpers.getLatestResults("limelight") != null but I’m not sure if that will work.

I am not either, but thr point was more of extrapolate the angle and pass that into SwerveController

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.