From 097f0c0603e8ed6af0b4b435ac2ce0f9acdcadaf Mon Sep 17 00:00:00 2001 From: maxwtan <100314265+MaxwellTTan20@users.noreply.github.com> Date: Tue, 24 Feb 2026 15:01:42 -0800 Subject: [PATCH] Update VisionConstants.java --- .../frc/robot/constants/VisionConstants.java | 269 +++++++++--------- 1 file changed, 142 insertions(+), 127 deletions(-) diff --git a/src/main/java/frc/robot/constants/VisionConstants.java b/src/main/java/frc/robot/constants/VisionConstants.java index 83a56d6..39cf88a 100644 --- a/src/main/java/frc/robot/constants/VisionConstants.java +++ b/src/main/java/frc/robot/constants/VisionConstants.java @@ -19,118 +19,118 @@ import edu.wpi.first.math.util.Units; * Container class for vision constants. */ public class VisionConstants { - /** - * If April tag vision is enabled on the robot - */ - public static final boolean ENABLED = true; - - /** - * If object detection should be enabled - */ - public static final boolean OBJECT_DETECTION_ENABLED = false; - - /** If odometry should be updated using vision during auto */ - public static final boolean ENABLED_AUTO = true; - - /** - * If odometry should be updated using vision while running the GoToPose, - * GoToPosePID, and DriveToPose commands in teleop - */ - public static final boolean ENABLED_GO_TO_POSE = true; - - /** If vision should be simulated */ - public static final boolean ENABLED_SIM = false; - - /** If vision should only return values if it can see 2 good targets */ - public static final boolean ONLY_USE_2_TAGS = false; - - /** PoseStrategy to use in pose estimation */ - public static final PoseStrategy POSE_STRATEGY = PoseStrategy.MULTI_TAG_PNP_ON_COPROCESSOR; - - /** Fallback PoseStrategy if MultiTag doesn't work */ - public static final PoseStrategy MULTITAG_FALLBACK_STRATEGY = PoseStrategy.LOWEST_AMBIGUITY; - - /** - * Any April tags we always want to ignore. To ignore a tag, put its id in this - * array. - */ - public static final int[] TAGS_TO_IGNORE = {}; - - /** - * If multiple cameras return different poses, they will be ignored if the - * difference between them is greater than this - */ - public static final double MAX_POSE_DIFFERENCE = 0.2; - - /** - * The maximum distance to the tag to use - */ - public static final double MAX_DISTANCE = 2; - - /** If vision should use manual calculations */ - public static final boolean USE_MANUAL_CALCULATIONS = true; - - //
    did not work - /** - * Which version of driver assist to use. This would be an enum, except there is - * no short and descriptive name for all of these. - *

    - * The options are: - *

    - * 0: Disable driver assist - *

    - * 1: Completely remove the component of the driver's input that is not toward - * the object - *

    - * 2: Interpolate between the next achievable driver speed and a speed - * calculated using trapezoid profiles - *

    - * 3-5: Add a speed perpendicular to the driver input; there are 3 similar but - * different calculations for this - */ - public static final int DRIVER_ASSIST_MODE = 5; - - /** - * The number to multiply the distance to the April tag by. - *

    - * Only affects manual calculations. - *

    - * To find this, set it to 1 and measure the actual distance and the calculated - * distance. - *

    - * This should not be needed, and it is only here because it improved the - * accuracy of vision in the 2023 fall semester - */ - public static final double DISTANCE_SCALE = 1; - - /** - * The standard deviations to use for vision - */ - public static final Matrix VISION_STD_DEVS = VecBuilder.fill( - 0.3, // x in meters (default=0.9) - 0.3, // y in meters (default=0.9) - 0.9 // heading in radians. The gyroscope is very accurate, so as long as it is reset - // correctly it is unnecessary to correct it with vision - ); - - /** - * The standard deviations to use for vision when the wheels slip - */ - public static final Matrix VISION_STD_DEVS_2 = VecBuilder.fill( - 0.01, // x in meters (default=0.9) - 0.01, // y in meters (default=0.9) - 0.9 // heading in radians. The gyroscope is very accurate, so as long as it is reset - // correctly it is unnecessary to correct it with vision - ); - - /** - * The highest ambiguity to use. Ambiguities higher than this will be ignored. - *

    - * Only affects calculations using PhotonVision, not manual calculations. - */ - public static final double HIGHEST_AMBIGUITY = 0.01; - - public static final int MAX_EMPTY_TICKS = 10; + /** + * If April tag vision is enabled on the robot + */ + public static final boolean ENABLED = true; + + /** + * If object detection should be enabled + */ + public static final boolean OBJECT_DETECTION_ENABLED = false; + + /** If odometry should be updated using vision during auto */ + public static final boolean ENABLED_AUTO = true; + + /** + * If odometry should be updated using vision while running the GoToPose, + * GoToPosePID, and DriveToPose commands in teleop + */ + public static final boolean ENABLED_GO_TO_POSE = true; + + /** If vision should be simulated */ + public static final boolean ENABLED_SIM = false; + + /** If vision should only return values if it can see 2 good targets */ + public static final boolean ONLY_USE_2_TAGS = false; + + /** PoseStrategy to use in pose estimation */ + public static final PoseStrategy POSE_STRATEGY = PoseStrategy.MULTI_TAG_PNP_ON_COPROCESSOR; + + /** Fallback PoseStrategy if MultiTag doesn't work */ + public static final PoseStrategy MULTITAG_FALLBACK_STRATEGY = PoseStrategy.LOWEST_AMBIGUITY; + + /** + * Any April tags we always want to ignore. To ignore a tag, put its id in this + * array. + */ + public static final int[] TAGS_TO_IGNORE = {}; + + /** + * If multiple cameras return different poses, they will be ignored if the + * difference between them is greater than this + */ + public static final double MAX_POSE_DIFFERENCE = 0.2; + + /** + * The maximum distance to the tag to use + */ + public static final double MAX_DISTANCE = 6; + + /** If vision should use manual calculations */ + public static final boolean USE_MANUAL_CALCULATIONS = true; + + //

      did not work + /** + * Which version of driver assist to use. This would be an enum, except there is + * no short and descriptive name for all of these. + *

      + * The options are: + *

      + * 0: Disable driver assist + *

      + * 1: Completely remove the component of the driver's input that is not toward + * the object + *

      + * 2: Interpolate between the next achievable driver speed and a speed + * calculated using trapezoid profiles + *

      + * 3-5: Add a speed perpendicular to the driver input; there are 3 similar but + * different calculations for this + */ + public static final int DRIVER_ASSIST_MODE = 5; + + /** + * The number to multiply the distance to the April tag by. + *

      + * Only affects manual calculations. + *

      + * To find this, set it to 1 and measure the actual distance and the calculated + * distance. + *

      + * This should not be needed, and it is only here because it improved the + * accuracy of vision in the 2023 fall semester + */ + public static final double DISTANCE_SCALE = 1; + + /** + * The standard deviations to use for vision + */ + public static final Matrix VISION_STD_DEVS = VecBuilder.fill( + 0.3, // x in meters (default=0.9) + 0.3, // y in meters (default=0.9) + 0.9 // heading in radians. The gyroscope is very accurate, so as long as it is reset + // correctly it is unnecessary to correct it with vision + ); + + /** + * The standard deviations to use for vision when the wheels slip + */ + public static final Matrix VISION_STD_DEVS_2 = VecBuilder.fill( + 0.01, // x in meters (default=0.9) + 0.01, // y in meters (default=0.9) + 0.9 // heading in radians. The gyroscope is very accurate, so as long as it is reset + // correctly it is unnecessary to correct it with vision + ); + + /** + * The highest ambiguity to use. Ambiguities higher than this will be ignored. + *

      + * Only affects calculations using PhotonVision, not manual calculations. + */ + public static final double HIGHEST_AMBIGUITY = 0.05; + + public static final int MAX_EMPTY_TICKS = 10; /** * The camera poses @@ -153,30 +153,45 @@ public class VisionConstants { public static final ArrayList> APRIL_TAG_CAMERAS = new ArrayList>( List.of( new Pair( - "CameraFront", + "CameraFrontLeft", new Transform3d( new Translation3d(Units.inchesToMeters(10.485), Units.inchesToMeters(10.217), Units.inchesToMeters(11.012)), new Rotation3d(0, Units.degreesToRadians(-11), Math.PI/2 + Units.degreesToRadians(20)))), new Pair( - "CameraBack", + "CameraFrontRight", + new Transform3d( + new Translation3d(Units.inchesToMeters(-9.538), Units.inchesToMeters(7.474), + Units.inchesToMeters(8.719)), + new Rotation3d(0, Units.degreesToRadians(-19.5), + Math.PI/2-Units.degreesToRadians(25)))), + new Pair( + "CameraBackLeft", new Transform3d( new Translation3d(Units.inchesToMeters(-9.538), Units.inchesToMeters(7.474), Units.inchesToMeters(8.719)), new Rotation3d(0, Units.degreesToRadians(-19.5), - Math.PI/2-Units.degreesToRadians(25)))))); + Math.PI/2-Units.degreesToRadians(25)))), + new Pair( + "CameraBackRight", + new Transform3d( + new Translation3d(Units.inchesToMeters(-9.538), Units.inchesToMeters(7.474), + Units.inchesToMeters(8.719)), + new Rotation3d(0, Units.degreesToRadians(-19.5), + Math.PI/2-Units.degreesToRadians(25)))) + )); - /** - * The transformations from the robot to object detection cameras - */ - public static final ArrayList OBJECT_DETECTION_CAMERAS = new ArrayList<>(List.of( - new Transform3d( - new Translation3d(Units.inchesToMeters(10), 0, Units.inchesToMeters(24)), - new Rotation3d(0, Units.degreesToRadians(20), 0)))); - - // used to cleanly shutdown the OrangePi - public static final String[] ORANGEPI_HOSTNAMES = {"photonfront.local", "photonback.local"}; - public static final String ORANGEPI_USERNAME = "pi"; - public static final String ORANGEPI_PASSWORD = "raspberry"; + /** + * The transformations from the robot to object detection cameras + */ + public static final ArrayList OBJECT_DETECTION_CAMERAS = new ArrayList<>(List.of( + new Transform3d( + new Translation3d(Units.inchesToMeters(10), 0, Units.inchesToMeters(24)), + new Rotation3d(0, Units.degreesToRadians(20), 0)))); + + // used to cleanly shutdown the OrangePi + public static final String[] ORANGEPI_HOSTNAMES = { "photonfront.local", "photonback.local" }; + public static final String ORANGEPI_USERNAME = "pi"; + public static final String ORANGEPI_PASSWORD = "raspberry"; } -- 2.39.5