Photonlibpy - Best Target Function #1223 (#1406)

Supercedes https://github.com/PhotonVision/photonvision/pull/1223

---------

Co-authored-by: vladb <vlad.bondar@frc5113.com>
This commit is contained in:
Matt
2024-08-31 12:30:09 -04:00
committed by GitHub
parent 50ea32c82d
commit 738e3646f7

View File

@@ -58,5 +58,14 @@ class PhotonPipelineResult:
def getTargets(self) -> list[PhotonTrackedTarget]:
return self.targets
def getBestTarget(self) -> PhotonTrackedTarget:
"""
Returns the best target in this pipeline result. If there are no targets, this method will
return null. The best target is determined by the target sort mode in the PhotonVision UI.
"""
if not self.hasTargets():
return None
return self.getTargets()[0]
def hasTargets(self) -> bool:
return len(self.targets) > 0