Skip to main content

Field Base

Explanation & History

Since we've started working with full-field localization, we have had a need for a software defined field with the april tags and other field data. This base field is meant to be game-agnostic. It gets extended and that years AprilTags are created in that years field in the robot program. The base field contains the size of the field, along with helpers for field position calcualtions and AprilTag checks.

For AprilTags, refer to the April Tag page.

Code Example

package;

import org.parts3492.partslib.game.AprilTag;
import org.parts3492.partslib.game.FieldBase;

import edu.wpi.first.math.geometry.Pose3d;
import edu.wpi.first.math.geometry.Rotation3d;
import edu.wpi.first.math.util.Units;

public class MyField implements FieldBase {

    // My 2026 AprilTags.
    AprilTag[] APRILTAGS = {
        new AprilTag(1, new Pose3d(
                Units.inchesToMeters(467.64),
                Units.inchesToMeters(292.31),
                Units.inchesToMeters(35.00),
                new Rotation3d(
                    Units.degreesToRadians(0), 
                    Units.degreesToRadians(0), 
                    Units.degreesToRadians(180)
                )
            )
        ),

        new AprilTag(2, new Pose3d(
                Units.inchesToMeters(469.11), 
                Units.inchesToMeters(182.60),
                Units.inchesToMeters(44.25),
                new Rotation3d(
                    Units.degreesToRadians(0), 
                    Units.degreesToRadians(0), 
                    Units.degreesToRadians(90)
                )
            )
        ),

        new AprilTag(3, new Pose3d(
                    Units.inchesToMeters(445.35),
                    Units.inchesToMeters(172.84),
                    Units.inchesToMeters(44.25),
                new Rotation3d(
                    Units.degreesToRadians(0), 
                    Units.degreesToRadians(0), 
                    Units.degreesToRadians(180)
                )
            )
        )

        // More apriltags can be added here.
    };

    // ...
}