mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-19 00:41:41 +00:00
* data updates to capture multiple rawBytes packets associated with serde updates from late this past month --------- Co-authored-by: Matt <matthew.morley.ca@gmail.com>
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
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()
|
|
targetCount = packet.decode8()
|
|
|
|
print(f"targetCount = {targetCount}")
|
|
for _ in range(targetCount):
|
|
target = PhotonTrackedTarget()
|
|
target.createFromPacket(packet)
|
|
self.targets.append(target)
|
|
|
|
self.multiTagResult = MultiTargetPNPResult()
|
|
self.multiTagResult.createFromPacket(packet)
|
|
|
|
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
|