mirror of
https://github.com/PhotonVision/photonvision
synced 2026-07-04 03:11:40 +00:00
Add photonlibpy (#1040)
* Added a pure-python implementation of photonlib, named photonlibpy and hosted on pypi --------- Co-authored-by: Matt <matthew.morley.ca@gmail.com>
This commit is contained in:
38
photon-lib/py/photonlibpy/photonPipelineResult.py
Normal file
38
photon-lib/py/photonlibpy/photonPipelineResult.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
from photonlibpy.multiTargetPNPResult import MultiTargetPNPResult
|
||||
from photonlibpy.packet import Packet
|
||||
from photonlibpy.photonTrackedTarget import PhotonTrackedTarget
|
||||
|
||||
|
||||
@dataclass
|
||||
class PhotonPipelineResult:
|
||||
latencyMillis: float = -1.0
|
||||
timestampSec: float = -1.0
|
||||
targets: list[PhotonTrackedTarget] = field(default_factory=list)
|
||||
multiTagResult: MultiTargetPNPResult = field(default_factory=MultiTargetPNPResult)
|
||||
|
||||
def populateFromPacket(self, packet: Packet) -> Packet:
|
||||
self.targets = []
|
||||
self.latencyMillis = packet.decodeDouble()
|
||||
self.multiTagResult = MultiTargetPNPResult()
|
||||
self.multiTagResult.createFromPacket(packet)
|
||||
targetCount = packet.decode8()
|
||||
for _ in range(targetCount):
|
||||
target = PhotonTrackedTarget()
|
||||
target.createFromPacket(packet)
|
||||
self.targets.append(target)
|
||||
|
||||
return packet
|
||||
|
||||
def setTimestampSeconds(self, timestampSec: float) -> None:
|
||||
self.timestampSec = timestampSec
|
||||
|
||||
def getLatencyMillis(self) -> float:
|
||||
return self.latencyMillis
|
||||
|
||||
def getTimestamp(self) -> float:
|
||||
return self.timestampSec
|
||||
|
||||
def getTargets(self) -> list[PhotonTrackedTarget]:
|
||||
return self.targets
|
||||
Reference in New Issue
Block a user