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.IOException;
008import java.io.UncheckedIOException;
009
010public enum AprilTagFields {
011  k2022RapidReact("2022-rapidreact.json"),
012  k2023ChargedUp("2023-chargedup.json");
013
014  public static final String kBaseResourceDir = "/edu/wpi/first/apriltag/";
015
016  /** Alias to the current game. */
017  public static final AprilTagFields kDefaultField = k2023ChargedUp;
018
019  public final String m_resourceFile;
020
021  AprilTagFields(String resourceFile) {
022    m_resourceFile = kBaseResourceDir + resourceFile;
023  }
024
025  /**
026   * Get a {@link AprilTagFieldLayout} from the resource JSON.
027   *
028   * @return AprilTagFieldLayout of the field
029   * @throws UncheckedIOException If the layout does not exist
030   */
031  public AprilTagFieldLayout loadAprilTagLayoutField() {
032    try {
033      return AprilTagFieldLayout.loadFromResource(m_resourceFile);
034    } catch (IOException e) {
035      throw new UncheckedIOException(
036          "Could not load AprilTagFieldLayout from " + m_resourceFile, e);
037    }
038  }
039}