Skip to content

Commit

Permalink
Photonlibpy - Best Target Function #1223 (#1406)
Browse files Browse the repository at this point in the history
Supercedes #1223

---------

Co-authored-by: vladb <[email protected]>
  • Loading branch information
mcm001 and vladb committed Aug 31, 2024
1 parent 50ea32c commit 738e364
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions photon-lib/py/photonlibpy/photonPipelineResult.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,14 @@ def getTimestampSeconds(self) -> float:
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

0 comments on commit 738e364

Please sign in to comment.