1919import java .util .function .Supplier ;
2020import org .littletonrobotics .junction .Logger ;
2121
22- /** Implements a Camera behavior for the This is up to date for Limelight OS 2024.10.2 (10/28/24 ) */
22+ /** Implements a Camera behavior for the This is up to date for Limelight OS 2026.0 (Feb 17, 2026 ) */
2323public class LimelightCamera extends AbstractChaosCamera {
2424 /** Limelight versions can help the implementation navigate features and calibration */
2525 public enum LimelightVersion {
@@ -28,43 +28,14 @@ public enum LimelightVersion {
2828 /** Limelight3 */
2929 LL3 ,
3030 /** Limelight3G (the global shutter / greyscale one) */
31- LL3G
31+ LL3G ,
32+ /** Limelight4 with optional starboard Hailo attachment */
33+ LL4
3234 }
3335
3436 /** Version of the limelight instance */
3537 protected LimelightVersion m_limeLightVersion ;
3638
37- /**
38- * Represents which mode the robot is in.
39- *
40- * <p>APRIL_TAGS - The pipeline
41- *
42- * <p>PIECE_TRACKING - The pipeline used for finding notes on the field. This is typically for
43- * intake cameras, which may not be the forward camera.
44- */
45- public enum Mode {
46- /** Focus on localization, and processing April Tags */
47- APRIL_TAGS (0 ),
48- /** Focus on tracking one or many game pieces */
49- PIECE_TRACKING (1 ),
50- /** Focus on a primary Blue side objective */
51- BLUE_PRIMARY (2 ),
52- /** Focus on a primary Red side objective */
53- RED_PRIMARY (3 ),
54- /** Focus on analyzing the environment */
55- MAPPING (4 );
56-
57- /** The pipeline ID for these features on the Limelight itself */
58- public final Integer pipelineId ;
59-
60- /**
61- * @param pipelineId ID for the mode
62- */
63- private Mode (Integer pipelineId ) {
64- this .pipelineId = pipelineId ;
65- }
66- }
67-
6839 /** NetworkTable name that corresponds with this Camera */
6940 protected NetworkTable m_visionTable ;
7041
@@ -74,7 +45,10 @@ private Mode(Integer pipelineId) {
7445 /** NetworkTable entry for MegaTag2 */
7546 protected NetworkTableEntry m_botposeMT2 ;
7647
77- /** A data structure used by AdvantageKit to record and replay Pose data */
48+ /**
49+ * A data structure used by AdvantageKit to record and replay Limelight specific MegaTag2 Pose
50+ * data. m_poseData already exists for standard megatag1 pose info.
51+ */
7852 protected NetworkPoseDataAutoLogged m_poseDataMT2 = new NetworkPoseDataAutoLogged ();
7953
8054 /** Distance in meters before swapping from MT1 to MT2 */
@@ -397,8 +371,9 @@ public VisionData processMeasuredData(int idx) {
397371 protected void LoadNTQueueToVisionData () {
398372 /** TODO: Serious race condition concern here! I can't simply fix this, Limelight needs to. */
399373 NetworkTableValue [] mt1_poses = m_botpose .readQueue ();
400- Logger .recordOutput (m_name + "/DataLength " , mt1_poses .length );
374+ Logger .recordOutput (m_name + "/MT1Length " , mt1_poses .length );
401375 NetworkTableValue [] mt2_poses = m_botposeMT2 .readQueue ();
376+ Logger .recordOutput (m_name + "/MT2Length" , mt2_poses .length );
402377 { // TODO: Analyze actual logs to see if this block is still necessary
403378 // TODO: Investigate TableEntry issues...
404379 if (mt1_poses .length == 1 && mt1_poses [0 ] == null ) {
@@ -458,6 +433,10 @@ protected void LoadNTQueueToVisionData() {
458433 m_poseData .tagCount [idx ] = (int ) data [idxTagCount ];
459434 m_poseData .timestamps [idx ] = timestampSeconds ;
460435 } // End MT1
436+ if (mt1_poses .length > 0 ) {
437+ Logger .recordOutput (m_name +"/Mt1TagDistance" , mt1_poses [mt1_poses .length -1 ].getDoubleArray ()[idxTagDistance ]);
438+ Logger .recordOutput (m_name +"/Mt1TagCount" , mt1_poses [mt1_poses .length -1 ].getDoubleArray ()[idxTagCount ]);
439+ }
461440
462441 // Parse MegaTag2 Info
463442 m_poseDataMT2 .resize (mt2_poses .length );
@@ -508,6 +487,11 @@ protected void LoadNTQueueToVisionData() {
508487 m_poseDataMT2 .tagCount [idx ] = (int ) data [idxTagCount ];
509488 m_poseDataMT2 .timestamps [idx ] = timestampSeconds ;
510489 } // End MT2
490+ if (mt2_poses .length > 0 ) {
491+ Logger .recordOutput (m_name +"/Mt2avgTagDistance" , mt2_poses [mt2_poses .length -1 ].getDoubleArray ()[idxTagDistance ]);
492+ Logger .recordOutput (m_name +"/Mt2TagCount" , mt2_poses [mt2_poses .length -1 ].getDoubleArray ()[idxTagCount ]);
493+ }
494+
511495 }
512496
513497 public static CameraSpecs LL3GSpecs () {
0 commit comments