mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-27 02:01:40 +00:00
generate packing for python messages (#1535)
Generate packet serialization in Python, too.
This commit is contained in:
@@ -21,14 +21,32 @@
|
||||
###############################################################################
|
||||
|
||||
from ..targeting import *
|
||||
from ..packet import Packet
|
||||
|
||||
|
||||
class PnpResultSerde:
|
||||
|
||||
# Message definition md5sum. See photon_packet.adoc for details
|
||||
MESSAGE_VERSION = "ae4d655c0a3104d88df4f5db144c1e86"
|
||||
MESSAGE_FORMAT = "Transform3d best;Transform3d alt;float64 bestReprojErr;float64 altReprojErr;float64 ambiguity;"
|
||||
|
||||
@staticmethod
|
||||
def pack(value: "PnpResult") -> "Packet":
|
||||
ret = Packet()
|
||||
|
||||
ret.encodeTransform(value.best)
|
||||
|
||||
ret.encodeTransform(value.alt)
|
||||
|
||||
# bestReprojErr is of intrinsic type float64
|
||||
ret.encodeDouble(value.bestReprojErr)
|
||||
|
||||
# altReprojErr is of intrinsic type float64
|
||||
ret.encodeDouble(value.altReprojErr)
|
||||
|
||||
# ambiguity is of intrinsic type float64
|
||||
ret.encodeDouble(value.ambiguity)
|
||||
return ret
|
||||
|
||||
@staticmethod
|
||||
def unpack(packet: "Packet") -> "PnpResult":
|
||||
ret = PnpResult()
|
||||
|
||||
Reference in New Issue
Block a user