001/************************ PROJECT ZIXI ************************/ 002/* Copyright (c) 2026 StuyPulse Robotics. All rights reserved.*/ 003/* This work is licensed under the terms of the MIT license. */ 004/**************************************************************/ 005package com.stuypulse.robot.subsystems.vision; 006 007import static org.wpilib.units.Units.Seconds; 008 009import org.wpilib.math.geometry.Rotation3d; 010import org.wpilib.math.geometry.Transform3d; 011import org.wpilib.units.measure.Time; 012 013import com.limelightvision.IMUMode; 014import org.littletonrobotics.junction.networktables.LoggedNetworkBoolean; 015 016public interface VisionConstants { 017 public interface VisionSettings { 018 LoggedNetworkBoolean HDR_ENABLED = 019 new LoggedNetworkBoolean("/Tuning/Vision/HDR Enabled", false); 020 021 Time HDR_SWITCHING_INTERVAL = Seconds.of(0.5); 022 023 IMUMode RESET_IMU_MODE = IMUMode.EXTERNAL_SEED_INTERNAL; 024 025 // Basic filtering thresholds 026 double MAX_AMBIGUITY = 0.3; 027 double MAX_Z_ERROR = 0.75; 028 029 // Standard deviation baselines, for 1 meter distance and 1 tag 030 // (Adjusted automatically based on distance and # of tags) 031 double LINEAR_STD_DEV_BASELINE = 0.02; // Meters 032 double ANGULAR_STD_DEV_BASELINE = 0.06; // Radians 033 034 // Multipliers to apply for MegaTag 2 observations 035 double LINEAR_STD_DEV_MEGATAG_2_FACTOR = 0.5; // More stable than full 3D solve 036 double ANGULAR_STD_DEV_MEGATAG_2_FACTOR = 037 Double.POSITIVE_INFINITY; // No rotation data available 038 039 double BUZZ_DEBOUNCE = 0.25; 040 } 041 042 /** 043 * Represents a camera from its physical position and identified by name, which must be unique. 044 * 045 * <p>An constant of this enum looks like this <code> 046 * NAME("detailed name", {@link Transform3d#Transform3d(double, double, double, Rotation3d) new Transform3d(x, y, z, rotation)}, 1.0, CameraType.LIMELIGHT); 047 * </code> 048 */ 049 public enum Camera { 050 ; 051 private final String name; 052 private final Transform3d robotToCamera; 053 private final double stdDevFactor; 054 private final CameraType type; 055 056 /** 057 * Internal constructor to setup a camera. 058 * 059 * @param name name of the camera, can be more detailed than its simple enum constant's name 060 * @param robotToCamera transformation from the robot origin to the camera's position 061 * @param stdDevFactor scalar factor to multiply the camera's standard deviations by 062 * @param type the vision software backend used by the camera 063 */ 064 private Camera( 065 String name, Transform3d robotToCamera, double stdDevFactor, CameraType type) { 066 this.name = name; 067 this.robotToCamera = robotToCamera; 068 this.stdDevFactor = stdDevFactor; 069 this.type = type; 070 } 071 072 public String getName() { 073 return this.name; 074 } 075 076 public Transform3d getRobotToCamera() { 077 return this.robotToCamera; 078 } 079 080 public double getStdDevFactor() { 081 return this.stdDevFactor; 082 } 083 084 public CameraType getCameraType() { 085 return this.type; 086 } 087 } 088 089 public enum Pipeline { 090 HIGH_SUN(0), 091 LOW_SUN(1); 092 093 private final int index; 094 095 private Pipeline(int index) { 096 this.index = index; 097 } 098 099 public int getIndex() { 100 return index; 101 } 102 } 103 104 /** Represents the vision software backend used by a camera or observation. */ 105 public enum CameraType { 106 /** Limelight lib backend using {@link VisionIOLimelight} */ 107 LIMELIGHT, 108 /** Photon lib backend using {@link VisionIOPhoton} */ 109 PHOTONVISION 110 } 111}