From e4d3bb9307e11e8c3e40b933fb4ac467dd86517a Mon Sep 17 00:00:00 2001 From: samarthkaashyap <107322449+samarthkaashyap@users.noreply.github.com> Date: Mon, 13 May 2024 17:58:12 -0700 Subject: [PATCH] maggie/samarth json offseason update 5/13 --- .../wpi/first/apriltag/AprilTagFields.java | 42 +++ .../first/apriltag/OffseasonAprilTags.json | 297 ++++++++++++++++++ 2 files changed, 339 insertions(+) create mode 100644 src/main/java/edu/wpi/first/apriltag/AprilTagFields.java create mode 100644 src/main/java/edu/wpi/first/apriltag/OffseasonAprilTags.json diff --git a/src/main/java/edu/wpi/first/apriltag/AprilTagFields.java b/src/main/java/edu/wpi/first/apriltag/AprilTagFields.java new file mode 100644 index 0000000..65554c5 --- /dev/null +++ b/src/main/java/edu/wpi/first/apriltag/AprilTagFields.java @@ -0,0 +1,42 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package edu.wpi.first.apriltag; + +import java.io.UncheckedIOException; + +/** Loadable AprilTag field layouts. */ +public enum AprilTagFields { + /** 2022 Rapid React. */ + // k2022RapidReact("2022-rapidreact.json"), + // /** 2023 Charged Up. */ + // k2023ChargedUp("2023-chargedup.json"), + // /** 2024 Crescendo. */ + // k2024Crescendo("2024-crescendo.json"), + /** 2024 Offseason Crescendo */ + k2024OffseasonCrescendo("OffseasonAprilTags.json"); + + /** Base resource directory. */ + public static final String kBaseResourceDir = "/edu/wpi/first/apriltag/"; + + /** Alias to the current game. */ + public static final AprilTagFields kDefaultField = k2024OffseasonCrescendo; + + /** Resource filename. */ + public final String m_resourceFile; + + AprilTagFields(String resourceFile) { + m_resourceFile = kBaseResourceDir + resourceFile; + } + + /** + * Get a {@link AprilTagFieldLayout} from the resource JSON. + * + * @return AprilTagFieldLayout of the field + * @throws UncheckedIOException If the layout does not exist + */ + public AprilTagFieldLayout loadAprilTagLayoutField() { + return AprilTagFieldLayout.loadField(this); + } +} diff --git a/src/main/java/edu/wpi/first/apriltag/OffseasonAprilTags.json b/src/main/java/edu/wpi/first/apriltag/OffseasonAprilTags.json new file mode 100644 index 0000000..0c578e1 --- /dev/null +++ b/src/main/java/edu/wpi/first/apriltag/OffseasonAprilTags.json @@ -0,0 +1,297 @@ +{ + "tags": [ + { + "ID": 1, + "pose": { + "translation": { + "x": 13.217334499999997, + "y": 0.24587199999999998, + "z": 1.355852 + }, + "rotation": { + "quaternion": { + "W": 0.5000000000000001, + "X": 0.0, + "Y": 0.0, + "Z": 0.8660254037844386 + } + } + } + }, + { + "ID": 2, + "pose": { + "translation": { + "x": 14.3229965, + "y": 0.883666, + "z": 1.355852 + }, + "rotation": { + "quaternion": { + "W": 0.5000000000000001, + "X": 0.0, + "Y": 0.0, + "Z": 0.8660254037844386 + } + } + } + }, + { + "ID": 3, + "pose": { + "translation": { + "x": 14.7172045, + "y": 4.982717999999999, + "z": 1.4511020000000001 + }, + "rotation": { + "quaternion": { + "W": 6.123233995736766e-17, + "X": 0.0, + "Y": 0.0, + "Z": 1.0 + } + } + } + }, + { + "ID": 4, + "pose": { + "translation": { + "x": 14.7172045, + "y": 5.547867999999999, + "z": 1.4511020000000001 + }, + "rotation": { + "quaternion": { + "W": 6.123233995736766e-17, + "X": 0.0, + "Y": 0.0, + "Z": 1.0 + } + } + } + }, + { + "ID": 5, + "pose": { + "translation": { + "x": 12.838620499999999, + "y": 8.2042, + "z": 1.355852 + }, + "rotation": { + "quaternion": { + "W": -0.7071067811865475, + "X": -0.0, + "Y": 0.0, + "Z": 0.7071067811865476 + } + } + } + }, + { + "ID": 6, + "pose": { + "translation": { + "x": 1.8415, + "y": 8.2042, + "z": 1.355852 + }, + "rotation": { + "quaternion": { + "W": -0.7071067811865475, + "X": -0.0, + "Y": 0.0, + "Z": 0.7071067811865476 + } + } + } + }, + { + "ID": 7, + "pose": { + "translation": { + "x": -0.038099999999999995, + "y": 5.547867999999999, + "z": 1.4511020000000001 + }, + "rotation": { + "quaternion": { + "W": 1.0, + "X": 0.0, + "Y": 0.0, + "Z": 0.0 + } + } + } + }, + { + "ID": 8, + "pose": { + "translation": { + "x": -0.038099999999999995, + "y": 4.982717999999999, + "z": 1.4511020000000001 + }, + "rotation": { + "quaternion": { + "W": 1.0, + "X": 0.0, + "Y": 0.0, + "Z": 0.0 + } + } + } + }, + { + "ID": 9, + "pose": { + "translation": { + "x": 0.356108, + "y": 0.883666, + "z": 1.355852 + }, + "rotation": { + "quaternion": { + "W": 0.8660254037844387, + "X": 0.0, + "Y": 0.0, + "Z": 0.49999999999999994 + } + } + } + }, + { + "ID": 10, + "pose": { + "translation": { + "x": 1.4615159999999998, + "y": 0.24587199999999998, + "z": 1.355852 + }, + "rotation": { + "quaternion": { + "W": 0.8660254037844387, + "X": 0.0, + "Y": 0.0, + "Z": 0.49999999999999994 + } + } + } + }, + { + "ID": 11, + "pose": { + "translation": { + "x": 10.0425885, + "y": 3.7132259999999997, + "z": 1.3208 + }, + "rotation": { + "quaternion": { + "W": -0.8660254037844387, + "X": -0.0, + "Y": 0.0, + "Z": 0.49999999999999994 + } + } + } + }, + { + "ID": 12, + "pose": { + "translation": { + "x": 10.0425885, + "y": 4.49834, + "z": 1.3208 + }, + "rotation": { + "quaternion": { + "W": 0.8660254037844387, + "X": 0.0, + "Y": 0.0, + "Z": 0.49999999999999994 + } + } + } + }, + { + "ID": 13, + "pose": { + "translation": { + "x": 9.3580585, + "y": 4.105148, + "z": 1.3208 + }, + "rotation": { + "quaternion": { + "W": 6.123233995736766e-17, + "X": 0.0, + "Y": 0.0, + "Z": 1.0 + } + } + } + }, + { + "ID": 14, + "pose": { + "translation": { + "x": 5.320792, + "y": 4.105148, + "z": 1.3208 + }, + "rotation": { + "quaternion": { + "W": 1.0, + "X": 0.0, + "Y": 0.0, + "Z": 0.0 + } + } + } + }, + { + "ID": 15, + "pose": { + "translation": { + "x": 4.641342, + "y": 4.49834, + "z": 1.3208 + }, + "rotation": { + "quaternion": { + "W": 0.5000000000000001, + "X": 0.0, + "Y": 0.0, + "Z": 0.8660254037844386 + } + } + } + }, + { + "ID": 16, + "pose": { + "translation": { + "x": 4.641342, + "y": 3.7132259999999997, + "z": 1.3208 + }, + "rotation": { + "quaternion": { + "W": -0.4999999999999998, + "X": -0.0, + "Y": 0.0, + "Z": 0.8660254037844387 + } + } + } + } + ], + "field": { + "length": 16.541, + "width": 8.211 + } + } + \ No newline at end of file