I suggest we add the following to Constants::FieldConstants and replace all the references to AprilTagFieldLayout to this one reference in constants. Likewise we replace all references to field LENGTH and WIDTH to these values.
UPDATE: I made sense of the RobotConfig class. The getAprilTagFieldLayout() method needs to get changed so that we only call loadAprilTagLayoutField() once in the constructor for RobotConfig and not everytime we call getAprilTagFieldLayout. I think that is actually loading a JSON file from the filesystem and could be very slow. We only one one instance of the AprilTagFieldLayout for the whole robot code.
This makes things less messy and eliminates issues where we don't update the LENGTH/WIDTH correctly everywhere.
public class FieldConstants {
// may need some refactoring to make sure we have RoboConfig before we do this? or move FieldConstants to be part of RobotConfig
public static AprilTagFieldLayout aprilTagFieldLayout = RobotConfig.getAprilTagFieldLayout();
// official Field dimensions
// https://github.com/wpilibsuite/allwpilib/blob/1e168f363e23c42bde8b39e75765bb2eb81f97b2/apriltag/src/main/native/resources/edu/wpi/first/apriltag/2024-crescendo.json#L292
public static double FIELD_LENGTH = aprilTagFieldLayout.getFieldLength();
public static double FIELD_WIDTH = aprilTagFieldLayout.getFieldWidth();
I suggest we add the following to Constants::FieldConstants and replace all the references to AprilTagFieldLayout to this one reference in constants. Likewise we replace all references to field LENGTH and WIDTH to these values.
UPDATE: I made sense of the RobotConfig class. The
getAprilTagFieldLayout()method needs to get changed so that we only callloadAprilTagLayoutField()once in the constructor for RobotConfig and not everytime we callgetAprilTagFieldLayout. I think that is actually loading a JSON file from the filesystem and could be very slow. We only one one instance of the AprilTagFieldLayout for the whole robot code.This makes things less messy and eliminates issues where we don't update the LENGTH/WIDTH correctly everywhere.