From 71af4e9bc6de04545c116a0a72284bfdb00c75bc Mon Sep 17 00:00:00 2001 From: Evan Pratten Date: Sat, 25 Jan 2020 21:34:35 -0500 Subject: [PATCH] Finished getters and setters for java --- .../ca/retrylife/frc/limelight/Limelight.java | 76 ++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/src/main/java/ca/retrylife/frc/limelight/Limelight.java b/src/main/java/ca/retrylife/frc/limelight/Limelight.java index f047810..0e97652 100644 --- a/src/main/java/ca/retrylife/frc/limelight/Limelight.java +++ b/src/main/java/ca/retrylife/frc/limelight/Limelight.java @@ -17,7 +17,7 @@ public class Limelight { /* Camera data */ private boolean tv; private double tx, ty, ta, ts, tl, tshort, tlong, thor, tvert; - private double[] camTran; + private double[] camTran, cornx, corny; public Limelight() { @@ -83,6 +83,16 @@ private void registerListeners() { this.camTran = v.getDoubleArray(); }); + // TCORNX + simpleListener(this.table, "tcornx", (v) -> { + this.cornx = v.getDoubleArray(); + }); + + // TCORNY + simpleListener(this.table, "tcorny", (v) -> { + this.corny = v.getDoubleArray(); + }); + } /** @@ -94,6 +104,16 @@ public boolean hasTarget() { return this.tv; } + /** + * Get the pipeline’s latency contribution (ms) Add at least 11ms for image + * capture latency. + * + * @return Pipeline latency + */ + public double getLatency() { + return this.tl; + } + /** * Get the detected vision target, or null if none found * @@ -133,6 +153,60 @@ public int getPipelineID() { return this.table.getEntry("getpipe").getNumber(0).intValue(); } + /** + * Get an array of corner X coordinates. "Send Contours" must be enabled on the + * Limelight + * + * @return Corner X coords + */ + public double[] getXCorners() { + return this.cornx; + } + + /** + * Get an array of corner Y coordinates. "Send Contours" must be enabled on the + * Limelight + * + * @return Corner Y coords + */ + public double[] getYCorners() { + return this.corny; + } + + /** + * Get raw contour data + * + * @return Array of raw contours + */ + public Contour[] getRawContours() { + Contour[] output = new Contour[3]; + + // Get each contour + output[0] = new Contour(this.table.getEntry("tx0").getDouble(0.0), this.table.getEntry("ty0").getDouble(0.0), + this.table.getEntry("ta0").getDouble(0.0), this.table.getEntry("ts0").getDouble(0.0)); + output[1] = new Contour(this.table.getEntry("tx1").getDouble(0.0), this.table.getEntry("ty1").getDouble(0.0), + this.table.getEntry("ta1").getDouble(0.0), this.table.getEntry("ts1").getDouble(0.0)); + output[2] = new Contour(this.table.getEntry("tx2").getDouble(0.0), this.table.getEntry("ty2").getDouble(0.0), + this.table.getEntry("ta2").getDouble(0.0), this.table.getEntry("ts2").getDouble(0.0)); + + return output; + } + + /** + * Get raw crosshair data + * + * @return Array of raw crosshairs + */ + public Crosshair[] getRawCrosshairs() { + Crosshair[] output = new Crosshair[2]; + + // Get each crosshair + output[0] = new Crosshair(this.table.getEntry("cx0").getDouble(0.0), this.table.getEntry("cy0").getDouble(0.0)); + output[1] = new Crosshair(this.table.getEntry("cx1").getDouble(0.0), this.table.getEntry("cy1").getDouble(0.0)); + + return output; + } + /** * Set the camera LED mode *