Expose camera name in PhotonCamera (#523)

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
This commit is contained in:
Lavi Arzi
2022-12-25 07:01:57 +02:00
committed by GitHub
parent e1b39a1723
commit 8330bf9d92
3 changed files with 31 additions and 5 deletions

View File

@@ -80,6 +80,7 @@ public class PhotonCamera {
}
private final String path;
private final String name;
private static boolean VERSION_CHECK_ENABLED = true;
private static long VERSION_CHECK_INTERVAL = 5;
@@ -104,6 +105,7 @@ public class PhotonCamera {
* @param cameraName The name of the camera, as seen in the UI.
*/
public PhotonCamera(NetworkTableInstance instance, String cameraName) {
name = cameraName;
var mainTable = instance.getTable("photonvision");
this.rootTable = mainTable.getSubTable(cameraName);
path = rootTable.getPath();
@@ -252,6 +254,16 @@ public class PhotonCamera {
return getLatestResult().hasTargets();
}
/**
* Returns the name of the camera. This will return the same value that was given to the
* constructor as cameraName.
*
* @return The name of the camera.
*/
public String getName() {
return name;
}
/**
* Returns whether the camera is connected and actively returning new data. Connection status is
* debounced.