001/* 002 * MIT License 003 * 004 * Copyright (c) PhotonVision 005 * 006 * Permission is hereby granted, free of charge, to any person obtaining a copy 007 * of this software and associated documentation files (the "Software"), to deal 008 * in the Software without restriction, including without limitation the rights 009 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 010 * copies of the Software, and to permit persons to whom the Software is 011 * furnished to do so, subject to the following conditions: 012 * 013 * The above copyright notice and this permission notice shall be included in all 014 * copies or substantial portions of the Software. 015 * 016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 017 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 018 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 019 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 020 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 021 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 022 * SOFTWARE. 023 */ 024 025// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY 026 027package org.photonvision.struct; 028 029import org.photonvision.common.dataflow.structures.Packet; 030import org.photonvision.common.dataflow.structures.PacketSerde; 031import org.photonvision.utils.PacketUtils; 032 033// Assume that the base class lives here and we can import it 034import org.photonvision.targeting.*; 035 036// WPILib imports (if any) 037import edu.wpi.first.util.struct.Struct; 038import edu.wpi.first.math.geometry.Transform3d; 039 040/** 041 * Auto-generated serialization/deserialization helper for PhotonTrackedTarget 042 */ 043public class PhotonTrackedTargetSerde implements PacketSerde<PhotonTrackedTarget> { 044 045 @Override 046 public final String getInterfaceUUID() { return "cc6dbb5c5c1e0fa808108019b20863f1"; } 047 @Override 048 public final String getSchema() { return "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[?];"; } 049 @Override 050 public final String getTypeName() { return "PhotonTrackedTarget"; } 051 052 @Override 053 public int getMaxByteSize() { 054 // TODO Auto-generated method stub 055 throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); 056 } 057 058 @Override 059 public void pack(Packet packet, PhotonTrackedTarget value) { 060 // field yaw is of intrinsic type float64 061 packet.encode((double) value.yaw); 062 063 // field pitch is of intrinsic type float64 064 packet.encode((double) value.pitch); 065 066 // field area is of intrinsic type float64 067 packet.encode((double) value.area); 068 069 // field skew is of intrinsic type float64 070 packet.encode((double) value.skew); 071 072 // field fiducialId is of intrinsic type int32 073 packet.encode((int) value.fiducialId); 074 075 // field objDetectId is of intrinsic type int32 076 packet.encode((int) value.objDetectId); 077 078 // field objDetectConf is of intrinsic type float32 079 packet.encode((float) value.objDetectConf); 080 081 PacketUtils.packTransform3d(packet, value.bestCameraToTarget); 082 083 PacketUtils.packTransform3d(packet, value.altCameraToTarget); 084 085 // field poseAmbiguity is of intrinsic type float64 086 packet.encode((double) value.poseAmbiguity); 087 088 // minAreaRectCorners is a custom VLA! 089 packet.encodeList(value.minAreaRectCorners); 090 091 // detectedCorners is a custom VLA! 092 packet.encodeList(value.detectedCorners); 093 } 094 095 @Override 096 public PhotonTrackedTarget unpack(Packet packet) { 097 var ret = new PhotonTrackedTarget(); 098 099 // yaw is of intrinsic type float64 100 ret.yaw = packet.decodeDouble(); 101 102 // pitch is of intrinsic type float64 103 ret.pitch = packet.decodeDouble(); 104 105 // area is of intrinsic type float64 106 ret.area = packet.decodeDouble(); 107 108 // skew is of intrinsic type float64 109 ret.skew = packet.decodeDouble(); 110 111 // fiducialId is of intrinsic type int32 112 ret.fiducialId = packet.decodeInt(); 113 114 // objDetectId is of intrinsic type int32 115 ret.objDetectId = packet.decodeInt(); 116 117 // objDetectConf is of intrinsic type float32 118 ret.objDetectConf = packet.decodeFloat(); 119 120 ret.bestCameraToTarget = PacketUtils.unpackTransform3d(packet); 121 122 ret.altCameraToTarget = PacketUtils.unpackTransform3d(packet); 123 124 // poseAmbiguity is of intrinsic type float64 125 ret.poseAmbiguity = packet.decodeDouble(); 126 127 // minAreaRectCorners is a custom VLA! 128 ret.minAreaRectCorners = packet.decodeList(TargetCorner.photonStruct); 129 130 // detectedCorners is a custom VLA! 131 ret.detectedCorners = packet.decodeList(TargetCorner.photonStruct); 132 133 return ret; 134 } 135 136 @Override 137 public PacketSerde<?>[] getNestedPhotonMessages() { 138 return new PacketSerde<?>[] { 139 TargetCorner.photonStruct 140 }; 141 } 142 143 @Override 144 public Struct<?>[] getNestedWpilibMessages() { 145 return new Struct<?>[] { 146 Transform3d.struct 147 }; 148 } 149}