Skip to main content

April Tag

Explanation & History

The days of Retroreflection are over, AprilTags are here. AprilTags are small QR-Code-like visual tags used in robotics. They provide low overhead, high accuracy localization for lots of applications. They are used in FRC for robot localization to the field, or specific element. AprilTags have unique IDs that are used to identify where they are at on the field. The IDs are mapped to known positions on the field.

All this feature encompasses is to make a container specifying its ID and the known 3D pose of that AprilTag.

Code Example

package;

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

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

public class MyClass {

    int tagID = 1;
    // In meters.
    double positionX = PARTsUnit.InchesToMeters.apply(467.64);
    double positionY = PARTsUnit.InchesToMeters.apply(292.31);
    double positionZ = PARTsUnit.InchesToMeters.apply(35.00);
    
    // In radians.
    double rotationX = 0;
    double rotationY = 0;
    double rotationZ = 3.141593; // 180 in Degrees.

    // Create our AprilTag object.
    AprilTag tag = new AprilTag(
        tagID, 
        new Pose3d(
            positionX,
            positionY,
            positionZ,

            new Rotation3d(
                rotationX,
                rotationY,
                rotationZ
            )
        )
    );
}