001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.apriltag;
006
007import java.io.UncheckedIOException;
008
009/** Loadable AprilTag field layouts. */
010public enum AprilTagFields {
011  /** 2022 Rapid React. */
012  k2022RapidReact("2022-rapidreact.json"),
013  /** 2023 Charged Up. */
014  k2023ChargedUp("2023-chargedup.json"),
015  /** 2024 Crescendo. */
016  k2024Crescendo("2024-crescendo.json");
017
018  /** Base resource directory. */
019  public static final String kBaseResourceDir = "/edu/wpi/first/apriltag/";
020
021  /** Alias to the current game. */
022  public static final AprilTagFields kDefaultField = k2024Crescendo;
023
024  /** Resource filename. */
025  public final String m_resourceFile;
026
027  AprilTagFieldLayout m_fieldLayout;
028
029  AprilTagFields(String resourceFile) {
030    m_resourceFile = kBaseResourceDir + resourceFile;
031  }
032
033  /**
034   * Get a {@link AprilTagFieldLayout} from the resource JSON.
035   *
036   * @return AprilTagFieldLayout of the field
037   * @throws UncheckedIOException If the layout does not exist
038   * @deprecated Use {@link AprilTagFieldLayout#loadField(AprilTagFields)} instead.
039   */
040  @Deprecated(forRemoval = true, since = "2025")
041  public AprilTagFieldLayout loadAprilTagLayoutField() {
042    return AprilTagFieldLayout.loadField(this);
043  }
044}