mirror of
https://github.com/PhotonVision/photonvision
synced 2026-07-01 02:41:42 +00:00
Add message UUID and type names to hash and message defintion (#1409)
This commit is contained in:
@@ -25,8 +25,8 @@ from ..targeting import *
|
||||
|
||||
class MultiTargetPNPResultSerde:
|
||||
# Message definition md5sum. See photon_packet.adoc for details
|
||||
MESSAGE_VERSION = "ffc1cb847deb6e796a583a5b1885496b"
|
||||
MESSAGE_FORMAT = "PnpResult estimatedPose;int16[?] fiducialIDsUsed;"
|
||||
MESSAGE_VERSION = "541096947e9f3ca2d3f425ff7b04aa7b"
|
||||
MESSAGE_FORMAT = "PnpResult:ae4d655c0a3104d88df4f5db144c1e86 estimatedPose;int16 fiducialIDsUsed[?];"
|
||||
|
||||
@staticmethod
|
||||
def unpack(packet: "Packet") -> "MultiTargetPNPResult":
|
||||
|
||||
@@ -25,7 +25,7 @@ from ..targeting import *
|
||||
|
||||
class PhotonPipelineMetadataSerde:
|
||||
# Message definition md5sum. See photon_packet.adoc for details
|
||||
MESSAGE_VERSION = "2a7039527bda14d13028a1b9282d40a2"
|
||||
MESSAGE_VERSION = "626e70461cbdb274fb43ead09c255f4e"
|
||||
MESSAGE_FORMAT = (
|
||||
"int64 sequenceID;int64 captureTimestampMicros;int64 publishTimestampMicros;"
|
||||
)
|
||||
|
||||
@@ -25,8 +25,8 @@ from ..targeting import *
|
||||
|
||||
class PhotonPipelineResultSerde:
|
||||
# Message definition md5sum. See photon_packet.adoc for details
|
||||
MESSAGE_VERSION = "cb3e1605048ba49325888eb797399fe2"
|
||||
MESSAGE_FORMAT = "PhotonPipelineMetadata metadata;PhotonTrackedTarget[?] targets;MultiTargetPNPResult? multiTagResult;"
|
||||
MESSAGE_VERSION = "5eeaa293d0c69aea90eaddea786a2b3b"
|
||||
MESSAGE_FORMAT = "PhotonPipelineMetadata:626e70461cbdb274fb43ead09c255f4e metadata;PhotonTrackedTarget:cc6dbb5c5c1e0fa808108019b20863f1 targets[?];optional MultiTargetPNPResult:541096947e9f3ca2d3f425ff7b04aa7b multitagResult;"
|
||||
|
||||
@staticmethod
|
||||
def unpack(packet: "Packet") -> "PhotonPipelineResult":
|
||||
@@ -38,8 +38,8 @@ class PhotonPipelineResultSerde:
|
||||
# targets is a custom VLA!
|
||||
ret.targets = packet.decodeList(PhotonTrackedTarget.photonStruct)
|
||||
|
||||
# multiTagResult is optional! it better not be a VLA too
|
||||
ret.multiTagResult = packet.decodeOptional(MultiTargetPNPResult.photonStruct)
|
||||
# multitagResult is optional! it better not be a VLA too
|
||||
ret.multitagResult = packet.decodeOptional(MultiTargetPNPResult.photonStruct)
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ from ..targeting import *
|
||||
|
||||
class PhotonTrackedTargetSerde:
|
||||
# Message definition md5sum. See photon_packet.adoc for details
|
||||
MESSAGE_VERSION = "8fdada56b9162f2e32bd24f0055d7b60"
|
||||
MESSAGE_FORMAT = "float64 yaw;float64 pitch;float64 area;float64 skew;int32 fiducialId;int32 objDetectId;float32 objDetectConf;Transform3d bestCameraToTarget;Transform3d altCameraToTarget;float64 poseAmbiguity;TargetCorner[?] minAreaRectCorners;TargetCorner[?] detectedCorners;"
|
||||
MESSAGE_VERSION = "cc6dbb5c5c1e0fa808108019b20863f1"
|
||||
MESSAGE_FORMAT = "float64 yaw;float64 pitch;float64 area;float64 skew;int32 fiducialId;int32 objDetectId;float32 objDetectConf;Transform3d bestCameraToTarget;Transform3d altCameraToTarget;float64 poseAmbiguity;TargetCorner:16f6ac0dedc8eaccb951f4895d9e18b6 minAreaRectCorners[?];TargetCorner:16f6ac0dedc8eaccb951f4895d9e18b6 detectedCorners[?];"
|
||||
|
||||
@staticmethod
|
||||
def unpack(packet: "Packet") -> "PhotonTrackedTarget":
|
||||
@@ -53,10 +53,8 @@ class PhotonTrackedTargetSerde:
|
||||
# objDetectConf is of intrinsic type float32
|
||||
ret.objDetectConf = packet.decodeFloat()
|
||||
|
||||
# field is shimmed!
|
||||
ret.bestCameraToTarget = packet.decodeTransform()
|
||||
|
||||
# field is shimmed!
|
||||
ret.altCameraToTarget = packet.decodeTransform()
|
||||
|
||||
# poseAmbiguity is of intrinsic type float64
|
||||
|
||||
@@ -25,17 +25,15 @@ from ..targeting import *
|
||||
|
||||
class PnpResultSerde:
|
||||
# Message definition md5sum. See photon_packet.adoc for details
|
||||
MESSAGE_VERSION = "0d1f2546b00f24718e30f38d206d4491"
|
||||
MESSAGE_VERSION = "ae4d655c0a3104d88df4f5db144c1e86"
|
||||
MESSAGE_FORMAT = "Transform3d best;Transform3d alt;float64 bestReprojErr;float64 altReprojErr;float64 ambiguity;"
|
||||
|
||||
@staticmethod
|
||||
def unpack(packet: "Packet") -> "PnpResult":
|
||||
ret = PnpResult()
|
||||
|
||||
# field is shimmed!
|
||||
ret.best = packet.decodeTransform()
|
||||
|
||||
# field is shimmed!
|
||||
ret.alt = packet.decodeTransform()
|
||||
|
||||
# bestReprojErr is of intrinsic type float64
|
||||
|
||||
@@ -25,7 +25,7 @@ from ..targeting import *
|
||||
|
||||
class TargetCornerSerde:
|
||||
# Message definition md5sum. See photon_packet.adoc for details
|
||||
MESSAGE_VERSION = "22b1ff7551d10215af6fb3672fe4eda8"
|
||||
MESSAGE_VERSION = "16f6ac0dedc8eaccb951f4895d9e18b6"
|
||||
MESSAGE_FORMAT = "float64 x;float64 y;"
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -85,7 +85,9 @@ class Packet:
|
||||
for _ in range(numBytes):
|
||||
intList.append(self._getNextByteAsInt())
|
||||
|
||||
# Interpret the bytes as a floating point number
|
||||
# Interpret the bytes as the requested type.
|
||||
# Note due to NT's byte order assumptions,
|
||||
# we have to flip the order of intList
|
||||
value = struct.unpack(unpackFormat, bytes(intList))[0]
|
||||
|
||||
return value
|
||||
@@ -96,7 +98,7 @@ class Packet:
|
||||
*
|
||||
* @return A decoded byte from the packet.
|
||||
"""
|
||||
return self._decodeGeneric(">b", 1)
|
||||
return self._decodeGeneric("<b", 1)
|
||||
|
||||
def decode16(self) -> int:
|
||||
"""
|
||||
@@ -104,7 +106,7 @@ class Packet:
|
||||
*
|
||||
* @return A decoded short from the packet.
|
||||
"""
|
||||
return self._decodeGeneric(">h", 2)
|
||||
return self._decodeGeneric("<h", 2)
|
||||
|
||||
def decodeInt(self) -> int:
|
||||
"""
|
||||
@@ -112,7 +114,7 @@ class Packet:
|
||||
*
|
||||
* @return A decoded int from the packet.
|
||||
"""
|
||||
return self._decodeGeneric(">l", 4)
|
||||
return self._decodeGeneric("<l", 4)
|
||||
|
||||
def decodeFloat(self) -> float:
|
||||
"""
|
||||
@@ -120,7 +122,7 @@ class Packet:
|
||||
*
|
||||
* @return A decoded float from the packet.
|
||||
"""
|
||||
return self._decodeGeneric(">f", 4)
|
||||
return self._decodeGeneric("<f", 4)
|
||||
|
||||
def decodeLong(self) -> int:
|
||||
"""
|
||||
@@ -128,7 +130,7 @@ class Packet:
|
||||
*
|
||||
* @return A decoded int64 from the packet.
|
||||
"""
|
||||
return self._decodeGeneric(">q", 8)
|
||||
return self._decodeGeneric("<q", 8)
|
||||
|
||||
def decodeDouble(self) -> float:
|
||||
"""
|
||||
@@ -136,7 +138,7 @@ class Packet:
|
||||
*
|
||||
* @return A decoded double from the packet.
|
||||
"""
|
||||
return self._decodeGeneric(">d", 8)
|
||||
return self._decodeGeneric("<d", 8)
|
||||
|
||||
def decodeBoolean(self) -> bool:
|
||||
"""
|
||||
|
||||
@@ -225,7 +225,15 @@ class PhotonCamera:
|
||||
)
|
||||
|
||||
versionString = self.versionEntry.get(defaultValue="")
|
||||
if len(versionString) > 0 and versionString != PHOTONVISION_VERSION:
|
||||
localUUID = PhotonPipelineResult.photonStruct.MESSAGE_VERSION
|
||||
remoteUUID = self._rawBytesEntry.getTopic().getProperty("message_uuid")
|
||||
|
||||
if remoteUUID is None or len(remoteUUID) == 0:
|
||||
wpilib.reportWarning(
|
||||
f"PhotonVision coprocessor at path {self._path} has not reported a message interface UUID - is your coprocessor's camera started?",
|
||||
True,
|
||||
)
|
||||
elif localUUID != remoteUUID:
|
||||
# Verified version mismatch
|
||||
|
||||
bfw = """
|
||||
@@ -250,6 +258,6 @@ class PhotonCamera:
|
||||
|
||||
wpilib.reportWarning(bfw)
|
||||
|
||||
errText = f"Photon version {PHOTONLIB_VERSION} does not match coprocessor version {versionString}. Please install photonlibpy version {versionString}, or update your coprocessor to {PHOTONLIB_VERSION}."
|
||||
errText = f"Photonlibpy version {PHOTONLIB_VERSION} (With message UUID {localUUID}) does not match coprocessor version {versionString} (with message UUID {remoteUUID}). Please install photonlibpy version {versionString}, or update your coprocessor to {PHOTONLIB_VERSION}."
|
||||
wpilib.reportError(errText, True)
|
||||
raise Exception(errText)
|
||||
|
||||
Reference in New Issue
Block a user