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  AprilTagFields(String resourceFile) {
028    m_resourceFile = kBaseResourceDir + resourceFile;
029  }
030
031  /**
032   * Get a {@link AprilTagFieldLayout} from the resource JSON.
033   *
034   * @return AprilTagFieldLayout of the field
035   * @throws UncheckedIOException If the layout does not exist
036   */
037  public AprilTagFieldLayout loadAprilTagLayoutField() {
038    return AprilTagFieldLayout.loadField(this);
039  }
040}