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 PnpResult 042 */ 043public class PnpResultSerde implements PacketSerde<PnpResult> { 044 045 @Override 046 public final String getInterfaceUUID() { return "ae4d655c0a3104d88df4f5db144c1e86"; } 047 @Override 048 public final String getSchema() { return "Transform3d best;Transform3d alt;float64 bestReprojErr;float64 altReprojErr;float64 ambiguity;"; } 049 @Override 050 public final String getTypeName() { return "PnpResult"; } 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, PnpResult value) { 060 PacketUtils.packTransform3d(packet, value.best); 061 062 PacketUtils.packTransform3d(packet, value.alt); 063 064 // field bestReprojErr is of intrinsic type float64 065 packet.encode((double) value.bestReprojErr); 066 067 // field altReprojErr is of intrinsic type float64 068 packet.encode((double) value.altReprojErr); 069 070 // field ambiguity is of intrinsic type float64 071 packet.encode((double) value.ambiguity); 072 } 073 074 @Override 075 public PnpResult unpack(Packet packet) { 076 var ret = new PnpResult(); 077 078 ret.best = PacketUtils.unpackTransform3d(packet); 079 080 ret.alt = PacketUtils.unpackTransform3d(packet); 081 082 // bestReprojErr is of intrinsic type float64 083 ret.bestReprojErr = packet.decodeDouble(); 084 085 // altReprojErr is of intrinsic type float64 086 ret.altReprojErr = packet.decodeDouble(); 087 088 // ambiguity is of intrinsic type float64 089 ret.ambiguity = packet.decodeDouble(); 090 091 return ret; 092 } 093 094 @Override 095 public PacketSerde<?>[] getNestedPhotonMessages() { 096 return new PacketSerde<?>[] { 097 098 }; 099 } 100 101 @Override 102 public Struct<?>[] getNestedWpilibMessages() { 103 return new Struct<?>[] { 104 Transform3d.struct 105 }; 106 } 107}