Skip to content

Commit 048a5b2

Browse files
authored
Merge pull request #64 from Manchester-Central/camera-logging-tweaks
more comments and cleanup than logs, really
2 parents b9533ff + f019ae0 commit 048a5b2

File tree

3 files changed

+25
-37
lines changed

3 files changed

+25
-37
lines changed

src/main/java/com/chaos131/vision/AbstractChaosCamera.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public enum CameraMode {
8686
* A high level operating mode for the camera system. Individual cameras may or may not implement
8787
* specific sub-states or sub-modes. For instance, multiple piece tracking modes.
8888
*/
89-
protected CameraMode m_mode;
89+
protected CameraMode m_mode = CameraMode.LOCALIZATION;
9090

9191
/*******************
9292
* Initializations *
@@ -102,7 +102,7 @@ public enum CameraMode {
102102
public AbstractChaosCamera(String name, CameraSpecs specs) {
103103
m_name = name;
104104
m_specs = specs;
105-
m_useForOdometry = true;
105+
setUseForOdometry(true);
106106
m_disconnectedTimer.start();
107107

108108
m_poseData.reset();
@@ -221,6 +221,7 @@ protected void processUpdateQueue() {
221221
VisionData data = processMeasuredData(idx);
222222
if (data != null) {
223223
m_poseUpdator.accept(data);
224+
224225
Logger.recordOutput(m_name + "/PoseTimestamp", data.getTimestampSeconds());
225226
Logger.recordOutput(m_name + "/RobotPose", data.getPose2d());
226227
Logger.recordOutput(m_name + "/RobotPose3d", data.getPose3d());
@@ -355,5 +356,6 @@ public abstract void updateCropFromRobotpose(
355356
*/
356357
public void setUseForOdometry(boolean val) {
357358
m_useForOdometry = val;
359+
Logger.recordOutput(m_name + "/useForOdometry", m_useForOdometry);
358360
}
359361
}

src/main/java/com/chaos131/vision/CameraSpecs.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ public class CameraSpecs {
2525
/** Deviation Coefficients */
2626
public LinearVelocity max_speed_acceptable;
2727

28+
/** Max speed that the robot can rotate before the data is discarded */
2829
public AngularVelocity max_rotation_acceptable;
2930

31+
/** Max average tag distance before the tag is discarded */
3032
public Distance max_distance_acceptable;
3133
}

src/main/java/com/chaos131/vision/LimelightCamera.java

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import java.util.function.Supplier;
2020
import 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) */
2323
public 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

Comments
 (0)