Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Commit

Permalink
Finished getters and setters for java
Browse files Browse the repository at this point in the history
  • Loading branch information
ewpratten committed Jan 26, 2020
1 parent 070178c commit 71af4e9
Showing 1 changed file with 75 additions and 1 deletion.
76 changes: 75 additions & 1 deletion src/main/java/ca/retrylife/frc/limelight/Limelight.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand Down Expand Up @@ -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();
});

}

/**
Expand All @@ -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
*
Expand Down Expand Up @@ -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
*
Expand Down

0 comments on commit 71af4e9

Please sign in to comment.