From abaefc52deef7a69678a7b8f7727b5a2dcdaef5b Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Wed, 13 May 2026 15:30:38 -0400 Subject: [PATCH 01/42] Squashed commit of the following: commit 0a27b16bac228645349e53c9af4dce9588c6da71 Author: Jesse Kane Date: Wed May 13 15:04:11 2026 -0400 linting commit 78d1c5e2376871415d7429749b3a8e9eb85e50b1 Author: Jesse Kane Date: Mon May 11 18:54:51 2026 -0400 fixed ambiguous cases commit f4e64eff7a88199dec234bb266d58bdae39b696c Author: Jesse Kane Date: Sat May 9 16:50:51 2026 -0400 stuff --- photon-serde/templates/Message.java.jinja | 23 ++- photon-serde/templates/ThingSerde.py.jinja | 11 +- .../struct/MultiTargetPNPResultSerde.java | 4 + .../struct/PhotonPipelineMetadataSerde.java | 4 + .../struct/PhotonPipelineResultSerde.java | 4 + .../struct/PhotonTrackedTargetSerde.java | 4 + .../photonvision/struct/PnpResultSerde.java | 4 + .../struct/TargetCornerSerde.java | 4 + .../photon/dataflow/structures/Packet.h | 138 +++++++++++++++++- 9 files changed, 188 insertions(+), 8 deletions(-) diff --git a/photon-serde/templates/Message.java.jinja b/photon-serde/templates/Message.java.jinja index 75983e6a51..3204045257 100644 --- a/photon-serde/templates/Message.java.jinja +++ b/photon-serde/templates/Message.java.jinja @@ -33,6 +33,10 @@ import org.photonvision.utils.PacketUtils; // Assume that the base class lives here and we can import it import org.photonvision.targeting.*; +// Needed for optional shims +import java.util.function.BiConsumer; +import java.util.function.Function; + // WPILib imports (if any) import org.wpilib.util.struct.Struct; {% for type in nested_wpilib_types -%} @@ -57,12 +61,22 @@ public class {{ name }}Serde implements PacketSerde<{{name}}> { // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); } - +{% for field in fields -%} +{%- if field.type | is_shimmed and field.optional == True %} + private static BiConsumer {{ field.name }}_PSINTERNALencode_shim_callable = (packet, value) -> {{ get_message_by_name(field.type).java_encode_shim }}(packet, value); + private static Function {{ field.name }}_PSINTERNALdecode_shim_callable = (packet) -> {{ get_message_by_name(field.type).java_decode_shim }}(packet); +{% endif -%} +{% endfor%} @Override public void pack(Packet packet, {{ name }} value) { {%- for field in fields -%} {%- if field.type | is_shimmed %} + {%- if field.optional == True %} + // {{ field.name }} is optional and shimmed! + PacketUtils.packOptional(packet, value.{{ field.name }}, {{ field.name }}_PSINTERNALencode_shim_callable); + {%- else %} {{ get_message_by_name(field.type).java_encode_shim }}(packet, value.{{ field.name }}); + {%- endif %} {%- elif field.optional == True %} // {{ field.name }} is optional! it better not be a VLA too packet.encodeOptional(value.{{ field.name }}); @@ -89,7 +103,12 @@ public class {{ name }}Serde implements PacketSerde<{{name}}> { var ret = new {{ name }}(); {% for field in fields -%} {%- if field.type | is_shimmed %} + {%- if field.optional == True %} + // {{ field.name }} is optional and shimmed! + ret.{{ field.name }} = PacketUtils.unpackOptional(packet, {{ field.name }}_PSINTERNALdecode_shim_callable); + {%- else %} ret.{{ field.name }} = {{ get_message_by_name(field.type).java_decode_shim }}(packet); + {%- endif %} {%- elif field.optional == True %} // {{ field.name }} is optional! it better not be a VLA too ret.{{ field.name }} = packet.decodeOptional({{ field.type }}.photonStruct); @@ -132,4 +151,4 @@ public class {{ name }}Serde implements PacketSerde<{{name}}> { {%- endfor%} }; } -}{{'\n'}} +}{{'\n'}} \ No newline at end of file diff --git a/photon-serde/templates/ThingSerde.py.jinja b/photon-serde/templates/ThingSerde.py.jinja index 324757a520..19e912de05 100644 --- a/photon-serde/templates/ThingSerde.py.jinja +++ b/photon-serde/templates/ThingSerde.py.jinja @@ -55,7 +55,11 @@ class {{ name }}Serde: ret = Packet() {% for field in fields -%} {%- if field.type | is_shimmed %} + {%- if field.optional == True %} + ret.encodeOptionalShimmed(value.{{ field.name }}, ret.{{ get_message_by_name(field.type).python_encode_shim }}) + {%- else %} ret.{{ get_message_by_name(field.type).python_encode_shim}}(value.{{ field.name }}) + {%- endif %} {%- elif field.optional == True %} # {{ field.name }} is optional! it better not be a VLA too ret.encodeOptional(value.{{ field.name }}, {{ field.type }}.photonStruct) @@ -82,7 +86,12 @@ class {{ name }}Serde: ret = {{ name }}() {% for field in fields -%} {%- if field.type | is_shimmed %} +{%- if field.optional == True %} + # {{ field.name }} is optional and shimmed! + ret.{{ field.name }} = packet.decodeOptionalShimmed(packet.{{ get_message_by_name(field.type).python_decode_shim }}) +{%- else %} ret.{{ field.name }} = packet.{{ get_message_by_name(field.type).python_decode_shim }}() +{%- endif %} {%- elif field.optional == True %} # {{ field.name }} is optional! it better not be a VLA too ret.{{ field.name }} = packet.decodeOptional({{ field.type }}.photonStruct) @@ -107,4 +116,4 @@ class {{ name }}Serde: # Hack ourselves into the base class -{{ name }}.photonStruct = {{ name }}Serde(){{'\n'}} +{{ name }}.photonStruct = {{ name }}Serde(){{'\n'}} \ No newline at end of file diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/MultiTargetPNPResultSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/MultiTargetPNPResultSerde.java index bf1c0696fe..4fc09a1539 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/MultiTargetPNPResultSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/MultiTargetPNPResultSerde.java @@ -32,6 +32,10 @@ // Assume that the base class lives here and we can import it import org.photonvision.targeting.*; +// Needed for optional shims +import java.util.function.BiConsumer; +import java.util.function.Function; + // WPILib imports (if any) import org.wpilib.util.struct.Struct; diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineMetadataSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineMetadataSerde.java index fb8e811dd9..8be1c3fab5 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineMetadataSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineMetadataSerde.java @@ -32,6 +32,10 @@ // Assume that the base class lives here and we can import it import org.photonvision.targeting.*; +// Needed for optional shims +import java.util.function.BiConsumer; +import java.util.function.Function; + // WPILib imports (if any) import org.wpilib.util.struct.Struct; diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java index ec0371fe2f..c3233c1416 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java @@ -32,6 +32,10 @@ // Assume that the base class lives here and we can import it import org.photonvision.targeting.*; +// Needed for optional shims +import java.util.function.BiConsumer; +import java.util.function.Function; + // WPILib imports (if any) import org.wpilib.util.struct.Struct; diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonTrackedTargetSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonTrackedTargetSerde.java index 5d1c3a84bf..d941a3b1e3 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonTrackedTargetSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonTrackedTargetSerde.java @@ -33,6 +33,10 @@ // Assume that the base class lives here and we can import it import org.photonvision.targeting.*; +// Needed for optional shims +import java.util.function.BiConsumer; +import java.util.function.Function; + // WPILib imports (if any) import org.wpilib.util.struct.Struct; import org.wpilib.math.geometry.Transform3d; diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/PnpResultSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/PnpResultSerde.java index 90f4b7a6f0..4a4b929e80 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/PnpResultSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/PnpResultSerde.java @@ -33,6 +33,10 @@ // Assume that the base class lives here and we can import it import org.photonvision.targeting.*; +// Needed for optional shims +import java.util.function.BiConsumer; +import java.util.function.Function; + // WPILib imports (if any) import org.wpilib.util.struct.Struct; import org.wpilib.math.geometry.Transform3d; diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/TargetCornerSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/TargetCornerSerde.java index df42d7f46f..b4e4d668ba 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/TargetCornerSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/TargetCornerSerde.java @@ -32,6 +32,10 @@ // Assume that the base class lives here and we can import it import org.photonvision.targeting.*; +// Needed for optional shims +import java.util.function.BiConsumer; +import java.util.function.Function; + // WPILib imports (if any) import org.wpilib.util.struct.Struct; diff --git a/photon-targeting/src/main/native/include/photon/dataflow/structures/Packet.h b/photon-targeting/src/main/native/include/photon/dataflow/structures/Packet.h index 840ee8300c..61b00470f2 100644 --- a/photon-targeting/src/main/native/include/photon/dataflow/structures/Packet.h +++ b/photon-targeting/src/main/native/include/photon/dataflow/structures/Packet.h @@ -17,19 +17,71 @@ #pragma once -#include -#include +#include +#include +#include +#include #include #include -#include +#include #include +#include +#include #include namespace photon { class Packet; +template +struct optional_inner; + +template +struct optional_inner> { + using type = T; +}; + +template +using optional_inner_t = typename optional_inner>::type; + +template +struct is_optional : std::false_type {}; + +template +struct is_optional> : std::true_type {}; + +template +concept Optional = is_optional>::value; + +template +concept OptionalWPIStructSerializable = + Optional && wpi::StructSerializable, I...>; + +template +struct vector_inner; + +template +struct vector_inner> { + using type = T; +}; + +template +using vector_inner_t = typename vector_inner>::type; + +template +struct is_vector : std::false_type {}; + +template +struct is_vector> : std::true_type {}; + +template +concept Vector = is_vector>::value; + +template +concept VectorWPIStructSerializable = + Vector && wpi::StructSerializable, I...>; + // Struct is where all our actual ser/de methods are implemented template struct SerdeType {}; @@ -104,6 +156,30 @@ class Packet { writePos = newWritePos; } + // Support encoding optional wpi structs + template + requires OptionalWPIStructSerializable + inline void Pack(const std::optional>& value) { + using T = optional_inner_t; + if (value) { + Pack(1u); + Pack(*value); + } else { + Pack(0u); + } + } + + // Support encoding wpi struct vectors + template + requires VectorWPIStructSerializable + inline void Pack(const std::vector>& value) { + using T = vector_inner_t; + Pack(value.size()); + for (const auto& thing : value) { + Pack(thing); + } + } + template requires(PhotonStructSerializable) inline void Pack(const T& value) { @@ -120,6 +196,58 @@ class Packet { return ret; } + // Support decoding optional wpi structs + template + requires OptionalWPIStructSerializable + inline std::optional> Unpack() { + using T = optional_inner_t; + if (Unpack() == 0u) { + return std::nullopt; + } else { + return std::make_optional(Unpack()); + } + } + + // Support decoding wpi struct vectors + template + requires VectorWPIStructSerializable + inline std::vector> Unpack() { + using T = vector_inner_t; + uint8_t len = Unpack(); + std::vector ret; + ret.reserve(len); + for (size_t i = 0; i < len; i++) { + ret.push_back(Unpack()); + } + return ret; + } + + // Support decoding optional wpi structs + template + requires OptionalWPIStructSerializable + inline std::optional> Unpack() { + using T = optional_inner_t; + if (Unpack() == 0u) { + return std::nullopt; + } else { + return std::make_optional(Unpack()); + } + } + + // Support decoding wpi struct vectors + template + requires VectorWPIStructSerializable + inline std::vector> Unpack() { + using T = vector_inner_t; + uint8_t len = Unpack(); + std::vector ret; + ret.reserve(len); + for (size_t i = 0; i < len; i++) { + ret.push_back(Unpack()); + } + return ret; + } + template requires(PhotonStructSerializable) inline T Unpack() { @@ -142,7 +270,7 @@ concept arithmetic = std::integral || std::floating_point; // support encoding vectors template - requires(PhotonStructSerializable || arithmetic) + requires(PhotonStructSerializable) struct SerdeType> { static std::vector Unpack(Packet& packet) { uint8_t len = packet.Unpack(); @@ -173,7 +301,7 @@ struct SerdeType> { // support encoding optional types template - requires(PhotonStructSerializable || arithmetic) + requires(PhotonStructSerializable) struct SerdeType> { static std::optional Unpack(Packet& packet) { if (packet.Unpack() == 1u) { From 0fd012fa04671e90711a2c2395c694424e008742 Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Wed, 13 May 2026 19:14:41 -0400 Subject: [PATCH 02/42] regenerated messages --- photon-serde/messages.yaml | 2 +- .../struct/MultiTargetPNPResultSerde.java | 1 + .../struct/PhotonPipelineMetadataSerde.java | 1 + .../struct/PhotonPipelineResultSerde.java | 3 +- .../struct/TargetCornerSerde.java | 1 + .../photon/dataflow/structures/Packet.h | 39 +++---------------- 6 files changed, 11 insertions(+), 36 deletions(-) diff --git a/photon-serde/messages.yaml b/photon-serde/messages.yaml index 40cbc1436b..88eebc5b98 100644 --- a/photon-serde/messages.yaml +++ b/photon-serde/messages.yaml @@ -15,7 +15,7 @@ java_decode_shim: PacketUtils.unpackTransform3d java_encode_shim: PacketUtils.packTransform3d cpp_type: wpi::math::Transform3d - cpp_include: "" + cpp_include: "" python_decode_shim: decodeTransform python_encode_shim: encodeTransform java_import: org.wpilib.math.geometry.Transform3d diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/MultiTargetPNPResultSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/MultiTargetPNPResultSerde.java index 4fc09a1539..c30411cc73 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/MultiTargetPNPResultSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/MultiTargetPNPResultSerde.java @@ -28,6 +28,7 @@ import org.photonvision.common.dataflow.structures.Packet; import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.utils.PacketUtils; // Assume that the base class lives here and we can import it import org.photonvision.targeting.*; diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineMetadataSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineMetadataSerde.java index 8be1c3fab5..7b1723f57a 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineMetadataSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineMetadataSerde.java @@ -28,6 +28,7 @@ import org.photonvision.common.dataflow.structures.Packet; import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.utils.PacketUtils; // Assume that the base class lives here and we can import it import org.photonvision.targeting.*; diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java index c3233c1416..e67c0de3f9 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java @@ -28,6 +28,7 @@ import org.photonvision.common.dataflow.structures.Packet; import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.utils.PacketUtils; // Assume that the base class lives here and we can import it import org.photonvision.targeting.*; @@ -89,7 +90,7 @@ public PhotonPipelineResult unpack(Packet packet) { @Override public PacketSerde[] getNestedPhotonMessages() { return new PacketSerde[] { - PhotonTrackedTarget.photonStruct,MultiTargetPNPResult.photonStruct,PhotonPipelineMetadata.photonStruct + PhotonPipelineMetadata.photonStruct,PhotonTrackedTarget.photonStruct,MultiTargetPNPResult.photonStruct }; } diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/TargetCornerSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/TargetCornerSerde.java index b4e4d668ba..b0f5865174 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/TargetCornerSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/TargetCornerSerde.java @@ -28,6 +28,7 @@ import org.photonvision.common.dataflow.structures.Packet; import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.utils.PacketUtils; // Assume that the base class lives here and we can import it import org.photonvision.targeting.*; diff --git a/photon-targeting/src/main/native/include/photon/dataflow/structures/Packet.h b/photon-targeting/src/main/native/include/photon/dataflow/structures/Packet.h index 61b00470f2..9a82001685 100644 --- a/photon-targeting/src/main/native/include/photon/dataflow/structures/Packet.h +++ b/photon-targeting/src/main/native/include/photon/dataflow/structures/Packet.h @@ -26,8 +26,8 @@ #include #include -#include -#include +#include +#include #include namespace photon { @@ -56,7 +56,7 @@ concept Optional = is_optional>::value; template concept OptionalWPIStructSerializable = - Optional && wpi::StructSerializable, I...>; + Optional && wpi::util::StructSerializable, I...>; template struct vector_inner; @@ -80,7 +80,7 @@ concept Vector = is_vector>::value; template concept VectorWPIStructSerializable = - Vector && wpi::StructSerializable, I...>; + Vector && wpi::util::StructSerializable, I...>; // Struct is where all our actual ser/de methods are implemented template @@ -217,33 +217,7 @@ class Packet { std::vector ret; ret.reserve(len); for (size_t i = 0; i < len; i++) { - ret.push_back(Unpack()); - } - return ret; - } - - // Support decoding optional wpi structs - template - requires OptionalWPIStructSerializable - inline std::optional> Unpack() { - using T = optional_inner_t; - if (Unpack() == 0u) { - return std::nullopt; - } else { - return std::make_optional(Unpack()); - } - } - - // Support decoding wpi struct vectors - template - requires VectorWPIStructSerializable - inline std::vector> Unpack() { - using T = vector_inner_t; - uint8_t len = Unpack(); - std::vector ret; - ret.reserve(len); - for (size_t i = 0; i < len; i++) { - ret.push_back(Unpack()); + ret.push_back(Unpack()); } return ret; } @@ -265,9 +239,6 @@ class Packet { size_t writePos = 0; }; -template -concept arithmetic = std::integral || std::floating_point; - // support encoding vectors template requires(PhotonStructSerializable) From 93c9855d20f7d6470e037afdd9c84ad33c72a03a Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Fri, 15 May 2026 14:01:53 -0400 Subject: [PATCH 03/42] wip --- .../generated/MultiTargetPNPResultSerde.py | 4 +- .../generated/PhotonTrackedTargetSerde.py | 2 + .../photonlibpy/generated/PnpResultSerde.py | 2 + photon-lib/py/photonlibpy/packet.py | 33 +- photon-serde/templates/Message.java.jinja | 8 +- photon-serde/templates/ThingSerde.py.jinja | 66 ++- .../struct/PhotonPipelineResultSerde.java | 2 +- .../common/dataflow/structures/Packet.java | 540 +++++++++++++++--- .../org/photonvision/utils/PacketUtils.java | 83 ++- 9 files changed, 630 insertions(+), 110 deletions(-) diff --git a/photon-lib/py/photonlibpy/generated/MultiTargetPNPResultSerde.py b/photon-lib/py/photonlibpy/generated/MultiTargetPNPResultSerde.py index 1c668e56b1..8a3e5ab415 100644 --- a/photon-lib/py/photonlibpy/generated/MultiTargetPNPResultSerde.py +++ b/photon-lib/py/photonlibpy/generated/MultiTargetPNPResultSerde.py @@ -50,7 +50,7 @@ def pack(value: "MultiTargetPNPResult") -> "Packet": ret.encodeBytes(PnpResult.photonStruct.pack(value.estimatedPose).getData()) # fiducialIDsUsed is a custom VLA! - ret.encodeShortList(value.fiducialIDsUsed) + ret.encodeListShimmed(value.fiducialIDsUsed, ret.encodeShort) return ret @staticmethod @@ -61,7 +61,7 @@ def unpack(packet: "Packet") -> "MultiTargetPNPResult": ret.estimatedPose = PnpResult.photonStruct.unpack(packet) # fiducialIDsUsed is a custom VLA! - ret.fiducialIDsUsed = packet.decodeShortList() + ret.fiducialIDsUsed = packet.decodeListShimmed(packet.decodeShort) return ret diff --git a/photon-lib/py/photonlibpy/generated/PhotonTrackedTargetSerde.py b/photon-lib/py/photonlibpy/generated/PhotonTrackedTargetSerde.py index c224bbf993..ebe96fc34b 100644 --- a/photon-lib/py/photonlibpy/generated/PhotonTrackedTargetSerde.py +++ b/photon-lib/py/photonlibpy/generated/PhotonTrackedTargetSerde.py @@ -67,8 +67,10 @@ def pack(value: "PhotonTrackedTarget") -> "Packet": # objDetectConf is of intrinsic type float32 ret.encodeFloat(value.objDetectConf) + # bestCameraToTarget is of shimmed type Transform3d ret.encodeTransform(value.bestCameraToTarget) + # altCameraToTarget is of shimmed type Transform3d ret.encodeTransform(value.altCameraToTarget) # poseAmbiguity is of intrinsic type float64 diff --git a/photon-lib/py/photonlibpy/generated/PnpResultSerde.py b/photon-lib/py/photonlibpy/generated/PnpResultSerde.py index 34abc0a74a..0447c69076 100644 --- a/photon-lib/py/photonlibpy/generated/PnpResultSerde.py +++ b/photon-lib/py/photonlibpy/generated/PnpResultSerde.py @@ -45,8 +45,10 @@ class PnpResultSerde: def pack(value: "PnpResult") -> "Packet": ret = Packet() + # best is of shimmed type Transform3d ret.encodeTransform(value.best) + # alt is of shimmed type Transform3d ret.encodeTransform(value.alt) # bestReprojErr is of intrinsic type float64 diff --git a/photon-lib/py/photonlibpy/packet.py b/photon-lib/py/photonlibpy/packet.py index 8aae95062e..e7f39fc887 100644 --- a/photon-lib/py/photonlibpy/packet.py +++ b/photon-lib/py/photonlibpy/packet.py @@ -16,7 +16,7 @@ ############################################################################### import struct -from typing import Generic, Optional, Protocol, TypeVar +from typing import Callable, Generic, Optional, Protocol, TypeVar import wpilib from wpimath.geometry import Quaternion, Rotation3d, Transform3d, Translation3d @@ -200,12 +200,25 @@ def decodeList(self, serde: Serde[T]) -> list[T]: for _ in range(arr_len): retList.append(serde.unpack(self)) return retList + + def decodeListShimmed(self, shim: Callable[[], T]) -> list[T]: + retList = [] + arr_len = self.decode8() + for _ in range(arr_len): + retList.append(shim()) + return retList def decodeOptional(self, serde: Serde[T]) -> Optional[T]: if self.decodeBoolean(): return serde.unpack(self) else: return None + + def decodeOptionalShimmed(self, shim: Callable[[], T]) -> Optional[T]: + if self.decodeBoolean(): + return shim() + else: + return None def _encodeGeneric(self, packFormat, value): """ @@ -297,6 +310,14 @@ def encodeList(self, values: list[T], serde: Serde[T]): packed = serde.pack(item) self.packetData = self.packetData + packed.getData() self.size = len(self.packetData) + + def encodeListShimmed(self, values: list[T], shim: Callable[[T], None]): + """ + Encodes a list of items using a specific serializer and appends it to the packet. + """ + self.encode8(len(values)) + for item in values: + shim(item) def encodeOptional(self, value: Optional[T], serde: Serde[T]): """ @@ -309,6 +330,16 @@ def encodeOptional(self, value: Optional[T], serde: Serde[T]): packed = serde.pack(value) self.packetData = self.packetData + packed.getData() self.size = len(self.packetData) + + def encodeOptionalShimmed(self, value: Optional[T], shim: Callable[[T], None]): + """ + Encodes an optional value using a specific shimmed serializer. + """ + if value is None: + self.encodeBoolean(False) + else: + self.encodeBoolean(True) + shim(value) def encodeBytes(self, value: bytes): self.packetData = self.packetData + value diff --git a/photon-serde/templates/Message.java.jinja b/photon-serde/templates/Message.java.jinja index 3204045257..b250c3fb3b 100644 --- a/photon-serde/templates/Message.java.jinja +++ b/photon-serde/templates/Message.java.jinja @@ -63,8 +63,8 @@ public class {{ name }}Serde implements PacketSerde<{{name}}> { } {% for field in fields -%} {%- if field.type | is_shimmed and field.optional == True %} - private static BiConsumer {{ field.name }}_PSINTERNALencode_shim_callable = (packet, value) -> {{ get_message_by_name(field.type).java_encode_shim }}(packet, value); - private static Function {{ field.name }}_PSINTERNALdecode_shim_callable = (packet) -> {{ get_message_by_name(field.type).java_decode_shim }}(packet); + private static BiConsumer {{ field.name }}_PSINTERNALopt_encode_shim_callable = (packet, value) -> {{ get_message_by_name(field.type).java_encode_shim }}(packet, value); + private static Function {{ field.name }}_PSINTERNALopt_decode_shim_callable = (packet) -> {{ get_message_by_name(field.type).java_decode_shim }}(packet); {% endif -%} {% endfor%} @Override @@ -104,8 +104,8 @@ public class {{ name }}Serde implements PacketSerde<{{name}}> { {% for field in fields -%} {%- if field.type | is_shimmed %} {%- if field.optional == True %} - // {{ field.name }} is optional and shimmed! - ret.{{ field.name }} = PacketUtils.unpackOptional(packet, {{ field.name }}_PSINTERNALdecode_shim_callable); + // {{ field.name }} is optional! it better not be a VLA too + ret.{{ field.name }} = PacketUtils.unpackOptional(packet, {{ field.name }}_PSINTERNALopt_decode_shim_callable); {%- else %} ret.{{ field.name }} = {{ get_message_by_name(field.type).java_decode_shim }}(packet); {%- endif %} diff --git a/photon-serde/templates/ThingSerde.py.jinja b/photon-serde/templates/ThingSerde.py.jinja index 19e912de05..5f562ca642 100644 --- a/photon-serde/templates/ThingSerde.py.jinja +++ b/photon-serde/templates/ThingSerde.py.jinja @@ -56,25 +56,37 @@ class {{ name }}Serde: {% for field in fields -%} {%- if field.type | is_shimmed %} {%- if field.optional == True %} + # {{ field.name }} is optional! it better not be a VLA too ret.encodeOptionalShimmed(value.{{ field.name }}, ret.{{ get_message_by_name(field.type).python_encode_shim }}) + {%- elif field.vla == True %} + # {{ field.name }} is a custom VLA! + ret.encodeListShimmed(value.{{ field.name }}, ret.{{ get_message_by_name(field.type).python_encode_shim }}) {%- else %} + # {{ field.name }} is of shimmed type {{ field.type }} ret.{{ get_message_by_name(field.type).python_encode_shim}}(value.{{ field.name }}) {%- endif %} -{%- elif field.optional == True %} +{%- elif field.type | is_intrinsic %} + {%- if field.optional == True %} # {{ field.name }} is optional! it better not be a VLA too - ret.encodeOptional(value.{{ field.name }}, {{ field.type }}.photonStruct) -{%- elif field.vla == True and not field.type | is_intrinsic %} + ret.encodeOptionalShimmed(value.{{ field.name }}, ret.{{ type_map[field.type].python_encode_shim }}) + {%- elif field.vla == True %} # {{ field.name }} is a custom VLA! - ret.encodeList(value.{{ field.name }}, {{ field.type }}.photonStruct) -{%- elif field.vla == True and field.type | is_intrinsic %} - # {{ field.name }} is a custom VLA! - ret.encode{{ type_map[field.type].java_type.title() }}List(value.{{ field.name }}) -{%- elif field.type | is_intrinsic %} + ret.encodeListShimmed(value.{{ field.name }}, ret.{{ type_map[field.type].python_encode_shim }}) + {%- else %} # {{ field.name }} is of intrinsic type {{ field.type }} - ret.{{ type_map[field.type].python_encode_shim }}(value.{{field.name}}) + ret.{{ type_map[field.type].python_encode_shim}}(value.{{ field.name }}) + {%- endif %} {%- else %} + {%- if field.optional == True %} + # {{ field.name }} is optional! it better not be a VLA too + ret.encodeOptional(value.{{ field.name }}, {{ field.type }}.photonStruct) + {%- elif field.vla == True %} + # {{ field.name }} is a custom VLA! + ret.encodeList(value.{{ field.name }}, {{ field.type }}.photonStruct) + {%- else %} # {{ field.name }} is of non-intrinsic type {{ field.type }} ret.encodeBytes({{ field.type }}.photonStruct.pack(value.{{field.name}}).getData()) + {%- endif %} {%- endif %} {%- if not loop.last %} {% endif -%} @@ -86,27 +98,37 @@ class {{ name }}Serde: ret = {{ name }}() {% for field in fields -%} {%- if field.type | is_shimmed %} -{%- if field.optional == True %} - # {{ field.name }} is optional and shimmed! + {%- if field.optional == True %} + # {{ field.name }} is optional! it better not be a VLA too ret.{{ field.name }} = packet.decodeOptionalShimmed(packet.{{ get_message_by_name(field.type).python_decode_shim }}) -{%- else %} + {%- elif field.vla == True %} + # {{ field.name }} is a custom VLA! + ret.{{ field.name }} = packet.decodeListShimmed(packet.{{ get_message_by_name(field.type).python_decode_shim }}) + {%- else %} ret.{{ field.name }} = packet.{{ get_message_by_name(field.type).python_decode_shim }}() -{%- endif %} -{%- elif field.optional == True %} + {%- endif %} +{%- elif field.type | is_intrinsic %} + {%- if field.optional == True %} # {{ field.name }} is optional! it better not be a VLA too - ret.{{ field.name }} = packet.decodeOptional({{ field.type }}.photonStruct) -{%- elif field.vla == True and not field.type | is_intrinsic %} + ret.{{ field.name }} = packet.decodeOptionalShimmed(packet.{{ type_map[field.type].python_decode_shim }}) + {%- elif field.vla == True %} # {{ field.name }} is a custom VLA! - ret.{{ field.name }} = packet.decodeList({{ field.type }}.photonStruct) -{%- elif field.vla == True and field.type | is_intrinsic %} - # {{ field.name }} is a custom VLA! - ret.{{ field.name }} = packet.decode{{ type_map[field.type].java_type.title() }}List() -{%- elif field.type | is_intrinsic %} + ret.{{ field.name }} = packet.decodeListShimmed(packet.{{ type_map[field.type].python_decode_shim }}) + {%- else %} # {{ field.name }} is of intrinsic type {{ field.type }} - ret.{{field.name}} = packet.{{ type_map[field.type].python_decode_shim }}() + ret.{{ field.name }} = packet.{{ type_map[field.type].python_decode_shim }}() + {%- endif %} {%- else %} + {%- if field.optional == True %} + # {{ field.name }} is optional! it better not be a VLA too + ret.{{ field.name }} = packet.decodeOptional({{ field.type }}.photonStruct) + {%- elif field.vla == True %} + # {{ field.name }} is a custom VLA! + ret.{{ field.name }} = packet.decodeList({{ field.type }}.photonStruct) + {%- else %} # {{ field.name }} is of non-intrinsic type {{ field.type }} ret.{{field.name}} = {{ field.type }}.photonStruct.unpack(packet) + {%- endif %} {%- endif %} {%- if not loop.last %} {% endif -%} diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java index e67c0de3f9..9f585a1696 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java @@ -90,7 +90,7 @@ public PhotonPipelineResult unpack(Packet packet) { @Override public PacketSerde[] getNestedPhotonMessages() { return new PacketSerde[] { - PhotonPipelineMetadata.photonStruct,PhotonTrackedTarget.photonStruct,MultiTargetPNPResult.photonStruct + PhotonTrackedTarget.photonStruct,PhotonPipelineMetadata.photonStruct,MultiTargetPNPResult.photonStruct }; } diff --git a/photon-targeting/src/main/java/org/photonvision/common/dataflow/structures/Packet.java b/photon-targeting/src/main/java/org/photonvision/common/dataflow/structures/Packet.java index 590fd04b24..1efb79a858 100644 --- a/photon-targeting/src/main/java/org/photonvision/common/dataflow/structures/Packet.java +++ b/photon-targeting/src/main/java/org/photonvision/common/dataflow/structures/Packet.java @@ -21,6 +21,8 @@ import java.util.Arrays; import java.util.List; import java.util.Optional; +import java.util.function.BiConsumer; +import java.util.function.Function; import org.photonvision.targeting.serde.PhotonStructSerializable; /** A packet that holds byte-packed data to be sent over NetworkTables. */ @@ -151,28 +153,88 @@ private void ensureCapacity(int bytesToAdd) { * * @param src The byte to encode. */ - public void encode(byte src) { + public void encodeByte(byte src) { ensureCapacity(1); packetData[writePos++] = src; } + /** + * Encodes a VLA of bytes into the packet + * + * @param src The VLA of bytes to encode + */ + public void encodeByteList(List src) { + byte size = (byte) src.size(); + if (src.size() > Byte.MAX_VALUE) { + throw new RuntimeException("Array too long! Got " + size); + } + + encodeByte(size); + + for (var f : src) { + encodeByte(f); + } + } + + /** + * Encodes an optional byte into the packet + * + * @param src the optional byte to encode + */ + public void encodeByteOptional(Optional src) { + encodeBoolean(src.isPresent()); + if (src.isPresent()) { + encodeByte(src.get()); + } + } + /** * Encodes the short into the packet. * * @param src The short to encode. */ - public void encode(short src) { + public void encodeShort(short src) { ensureCapacity(2); packetData[writePos++] = (byte) src; packetData[writePos++] = (byte) (src >>> 8); } + /** + * Encodes a VLA of shorts into the packet + * + * @param src The VLA of shorts to encode + */ + public void encodeShortList(List src) { + byte size = (byte) src.size(); + if (src.size() > Byte.MAX_VALUE) { + throw new RuntimeException("Array too long! Got " + size); + } + + encodeByte(size); + + for (var f : src) { + encodeShort(f); + } + } + + /** + * Encodes an optional short into the packet + * + * @param src the optional short to encode + */ + public void encodeShortOptional(Optional src) { + encodeBoolean(src.isPresent()); + if (src.isPresent()) { + encodeShort(src.get()); + } + } + /** * Encodes the integer into the packet. * * @param src The integer to encode. */ - public void encode(int src) { + public void encodeInt(int src) { ensureCapacity(4); packetData[writePos++] = (byte) src; packetData[writePos++] = (byte) (src >>> 8); @@ -180,12 +242,89 @@ public void encode(int src) { packetData[writePos++] = (byte) (src >>> 24); } + /** + * Encodes a VLA of ints into the packet + * + * @param src The VLA of intsto encode + */ + public void encodeIntList(List src) { + byte size = (byte) src.size(); + if (src.size() > Byte.MAX_VALUE) { + throw new RuntimeException("Array too long! Got " + size); + } + + encodeByte(size); + + for (var f : src) { + encodeInt(f); + } + } + + /** + * Encodes an optional int into the packet + * + * @param src the optional int to encode + */ + public void encodeIntOptional(Optional src) { + encodeBoolean(src.isPresent()); + if (src.isPresent()) { + encodeInt(src.get()); + } + } + + /** + * Encodes the double into the packet. + * + * @param src The double to encode. + */ + public void encodeLong(long src) { + ensureCapacity(8); + packetData[writePos++] = (byte) src; + packetData[writePos++] = (byte) ((src >> 8) & 0xff); + packetData[writePos++] = (byte) ((src >> 16) & 0xff); + packetData[writePos++] = (byte) ((src >> 24) & 0xff); + packetData[writePos++] = (byte) ((src >> 32) & 0xff); + packetData[writePos++] = (byte) ((src >> 40) & 0xff); + packetData[writePos++] = (byte) ((src >> 48) & 0xff); + packetData[writePos++] = (byte) ((src >> 56) & 0xff); + } + + /** + * Encodes a VLA of longs into the packet + * + * @param src The VLA of longs to encode + */ + public void encodeLongList(List src) { + byte size = (byte) src.size(); + if (src.size() > Byte.MAX_VALUE) { + throw new RuntimeException("Array too long! Got " + size); + } + + encodeByte(size); + + for (var f : src) { + encodeLong(f); + } + } + + /** + * Encodes an optional long into the packet + * + * @param src the optional long to encode + */ + public void encodeLongOptional(Optional src) { + encodeBoolean(src.isPresent()); + if (src.isPresent()) { + encodeLong(src.get()); + } + } + /** * Encodes the float into the packet. * * @param src The float to encode. */ - public void encode(float src) { + public void encodeFloat(float src) { ensureCapacity(4); int data = Float.floatToIntBits(src); packetData[writePos++] = (byte) (data & 0xff); @@ -195,20 +334,33 @@ public void encode(float src) { } /** - * Encodes the double into the packet. - * - * @param data The double to encode. + * Encodes a VLA of floats into the packet + * + * @param src The VLA of floats to encode */ - public void encode(long data) { - ensureCapacity(8); - packetData[writePos++] = (byte) (data & 0xff); - packetData[writePos++] = (byte) ((data >> 8) & 0xff); - packetData[writePos++] = (byte) ((data >> 16) & 0xff); - packetData[writePos++] = (byte) ((data >> 24) & 0xff); - packetData[writePos++] = (byte) ((data >> 32) & 0xff); - packetData[writePos++] = (byte) ((data >> 40) & 0xff); - packetData[writePos++] = (byte) ((data >> 48) & 0xff); - packetData[writePos++] = (byte) ((data >> 56) & 0xff); + public void encodeFloatList(List src) { + byte size = (byte) src.size(); + if (src.size() > Byte.MAX_VALUE) { + throw new RuntimeException("Array too long! Got " + size); + } + + encodeByte(size); + + for (var f : src) { + encodeFloat(f); + } + } + + /** + * Encodes an optional float into the packet + * + * @param src the optional float to encode + */ + public void encodeFloatOptional(Optional src) { + encodeBoolean(src.isPresent()); + if (src.isPresent()) { + encodeFloat(src.get()); + } } /** @@ -216,7 +368,7 @@ public void encode(long data) { * * @param src The double to encode. */ - public void encode(double src) { + public void encodeDouble(double src) { ensureCapacity(8); long data = Double.doubleToRawLongBits(src); packetData[writePos++] = (byte) (data & 0xff); @@ -229,27 +381,73 @@ public void encode(double src) { packetData[writePos++] = (byte) ((data >> 56) & 0xff); } + /** + * Encodes a VLA of doubles into the packet + * + * @param src The VLA of doubles to encode + */ + public void encodeDoubleList(List src) { + byte size = (byte) src.size(); + if (src.size() > Byte.MAX_VALUE) { + throw new RuntimeException("Array too long! Got " + size); + } + + encodeByte(size); + + for (var f : src) { + encodeDouble(f); + } + } + + /** + * Encodes an optional double into the packet + * + * @param src the optional double to encode + */ + public void encodeDoubleOptional(Optional src) { + encodeBoolean(src.isPresent()); + if (src.isPresent()) { + encodeDouble(src.get()); + } + } + /** * Encodes the boolean into the packet. * * @param src The boolean to encode. */ - public void encode(boolean src) { + public void encodeBoolean(boolean src) { ensureCapacity(1); packetData[writePos++] = src ? (byte) 1 : (byte) 0; } - public void encode(List data) { - byte size = (byte) data.size(); - if (data.size() > Byte.MAX_VALUE) { + /** + * Encodes a VLA of booleans into the packet + * + * @param src The VLA of booleans to encode + */ + public void encodeBooleanList(List src) { + byte size = (byte) src.size(); + if (src.size() > Byte.MAX_VALUE) { throw new RuntimeException("Array too long! Got " + size); } - // length byte - encode(size); + encodeByte(size); - for (var f : data) { - encode(f); + for (var f : src) { + encodeShort(f); + } + } + + /** + * Encodes an optional boolean into the packet + * + * @param src the optional boolean to encode + */ + public void encodeBooleanOptional(Optional src) { + encodeBoolean(src.isPresent()); + if (src.isPresent()) { + encodeBoolean(src.get()); } } @@ -271,15 +469,22 @@ public > void encodeList(List data) { } // length byte - encode(size); + encodeByte(size); for (var f : data) { f.getSerde().pack(this, f); } } + /** + * Encode an optional serializable struct. Lists are stored as [uint8 length, [length many] data + * structs] + * + * @param the class this optional will be packing + * @param data + */ public > void encodeOptional(Optional data) { - encode(data.isPresent()); + encodeBoolean(data.isPresent()); if (data.isPresent()) { data.get().getSerde().pack(this, data.get()); } @@ -297,6 +502,80 @@ public byte decodeByte() { return packetData[readPos++]; } + /** + * Returns a list of decoded byte from the packet + * + * @return A decoded list of byte from the packet + */ + public List decodeByteList() { + byte length = decodeByte(); + + var ret = new ArrayList(); + ret.ensureCapacity(length); + + for (int i = 0; i < length; i++) { + ret.add(decodeByte()); + } + + return ret; + } + + /** + * Returns an optional decoded byte from the packet + * + * @return A decoded optional byte from the packet + */ + public Optional decodeByteOptional() { + var present = decodeBoolean(); + if (present) { + return Optional.of(decodeByte()); + } + return Optional.empty(); + } + + /** + * Returns a decoded short from the packet + * + * @return A decoded short from the packet + */ + public short decodeShort() { + if (packetData.length < readPos + 1) { + return 0; + } + return (short) ((0xff & packetData[readPos++]) | (0xff & packetData[readPos++]) << 8); + } + + /** + * Returns a list of decoded shorts from the packet + * + * @return A decoded list of shorts from the packet + */ + public List decodeShortList() { + byte length = decodeByte(); + + var ret = new ArrayList(); + ret.ensureCapacity(length); + + for (int i = 0; i < length; i++) { + ret.add(decodeShort()); + } + + return ret; + } + + /** + * Returns an optional decoded short from the packet + * + * @return A decoded optional short from the packet + */ + public Optional decodeShortOptional() { + var present = decodeBoolean(); + if (present) { + return Optional.of(decodeShort()); + } + return Optional.empty(); + } + /** * Returns a decoded int from the packet. * @@ -312,6 +591,37 @@ public int decodeInt() { | (0xff & packetData[readPos++]) << 24; } + /** + * Returns a list of decoded ints from the packet + * + * @return A decoded list of ints from the packet + */ + public List decodeIntList() { + byte length = decodeByte(); + + var ret = new ArrayList(); + ret.ensureCapacity(length); + + for (int i = 0; i < length; i++) { + ret.add(decodeShort()); + } + + return ret; + } + + /** + * Returns an optional decoded int from the packet + * + * @return A decoded optional int from the packet + */ + public Optional decodeIntOptional() { + var present = decodeBoolean(); + if (present) { + return Optional.of(decodeInt()); + } + return Optional.empty(); + } + public long decodeLong() { if (packetData.length < (readPos + 7)) { return 0; @@ -329,6 +639,86 @@ public long decodeLong() { return data; } + /** + * Returns a list of decoded longs from the packet + * + * @return A decoded list of longs from the packet + */ + public List decodeLongList() { + byte length = decodeByte(); + + var ret = new ArrayList(); + ret.ensureCapacity(length); + + for (int i = 0; i < length; i++) { + ret.add(decodeLong()); + } + + return ret; + } + + /** + * Returns an optional decoded long from the packet + * + * @return A decoded optional long from the packet + */ + public Optional decodeLongOptional() { + var present = decodeBoolean(); + if (present) { + return Optional.of(decodeLong()); + } + return Optional.empty(); + } + + /** + * Returns a decoded float from the packet. + * + * @return A decoded float from the packet. + */ + public float decodeFloat() { + if (packetData.length < (readPos + 3)) { + return 0; + } + + int data = + ((0xff & packetData[readPos++] + | (0xff & packetData[readPos++]) << 8 + | (0xff & packetData[readPos++]) << 16 + | (0xff & packetData[readPos++]) << 24)); + return Float.intBitsToFloat(data); + } + + /** + * Returns a list of decoded floats from the packet + * + * @return A decoded list of floats from the packet + */ + public List decodeFloatList() { + byte length = decodeByte(); + + var ret = new ArrayList(); + ret.ensureCapacity(length); + + for (int i = 0; i < length; i++) { + ret.add(decodeFloat()); + } + + return ret; + } + + /** + * Returns an optional decoded float from the packet + * + * @return A decoded optional float from the packet + */ + public Optional decodeFloatOptional() { + var present = decodeBoolean(); + if (present) { + return Optional.of(decodeFloat()); + } + return Optional.empty(); + } + /** * Returns a decoded double from the packet. * @@ -352,21 +742,34 @@ public double decodeDouble() { } /** - * Returns a decoded float from the packet. - * - * @return A decoded float from the packet. + * Returns a list of decoded doubles from the packet + * + * @return A decoded list of doubles from the packet */ - public float decodeFloat() { - if (packetData.length < (readPos + 3)) { - return 0; + public List decodeDoubleList() { + byte length = decodeByte(); + + var ret = new ArrayList(); + ret.ensureCapacity(length); + + for (int i = 0; i < length; i++) { + ret.add(decodeDouble()); } - int data = - ((0xff & packetData[readPos++] - | (0xff & packetData[readPos++]) << 8 - | (0xff & packetData[readPos++]) << 16 - | (0xff & packetData[readPos++]) << 24)); - return Float.intBitsToFloat(data); + return ret; + } + + /** + * Returns an optional decoded double from the packet + * + * @return A decoded optional double from the packet + */ + public Optional decodeDoubleOptional() { + var present = decodeBoolean(); + if (present) { + return Optional.of(decodeDouble()); + } + return Optional.empty(); } /** @@ -381,25 +784,39 @@ public boolean decodeBoolean() { return packetData[readPos++] == 1; } - public void encode(double[] data) { - for (double d : data) { - encode(d); - } - } + /** + * Returns a list of decoded booleans from the packet + * + * @return A decoded list of booleans from the packet + */ + public List decodeBooleanList() { + byte length = decodeByte(); - public double[] decodeDoubleArray(int len) { - double[] ret = new double[len]; - for (int i = 0; i < len; i++) { - ret[i] = decodeDouble(); + var ret = new ArrayList(); + ret.ensureCapacity(length); + + for (int i = 0; i < length; i++) { + ret.add(decodeBoolean()); } + return ret; } - public short decodeShort() { - if (packetData.length < readPos + 1) { - return 0; + /** + * Returns an optional decoded boolean from the packet + * + * @return A decoded optional boolean from the packet + */ + public Optional decodeBooleanOptional() { + var present = decodeBoolean(); + if (present) { + return Optional.of(decodeBoolean()); } - return (short) ((0xff & packetData[readPos++]) | (0xff & packetData[readPos++]) << 8); + return Optional.empty(); + } + + public > T decode(PhotonStructSerializable t) { + return t.getSerde().unpack(this); } /** @@ -429,21 +846,4 @@ public > Optional decodeOptional(Packet } return Optional.empty(); } - - public List decodeShortList() { - byte length = decodeByte(); - - var ret = new ArrayList(); - ret.ensureCapacity(length); - - for (int i = 0; i < length; i++) { - ret.add(decodeShort()); - } - - return ret; - } - - public > T decode(PhotonStructSerializable t) { - return t.getSerde().unpack(this); - } } diff --git a/photon-targeting/src/main/java/org/photonvision/utils/PacketUtils.java b/photon-targeting/src/main/java/org/photonvision/utils/PacketUtils.java index 501d753a24..ebd06880ea 100644 --- a/photon-targeting/src/main/java/org/photonvision/utils/PacketUtils.java +++ b/photon-targeting/src/main/java/org/photonvision/utils/PacketUtils.java @@ -18,8 +18,24 @@ package org.photonvision.utils; import org.photonvision.common.dataflow.structures.Packet; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.function.BiConsumer; +import java.util.function.Function; import org.wpilib.math.geometry.*; +import edu.wpi.first.math.geometry.Pose2d; +import edu.wpi.first.math.geometry.Pose3d; +import edu.wpi.first.math.geometry.Quaternion; +import edu.wpi.first.math.geometry.Rotation2d; +import edu.wpi.first.math.geometry.Rotation3d; +import edu.wpi.first.math.geometry.Transform2d; +import edu.wpi.first.math.geometry.Transform3d; +import edu.wpi.first.math.geometry.Translation2d; +import edu.wpi.first.math.geometry.Translation3d; + @SuppressWarnings("doclint") public class PacketUtils { public static final int ROTATION2D_BYTE_SIZE = Double.BYTES; @@ -33,7 +49,7 @@ public class PacketUtils { public static final int POSE3D_BYTE_SIZE = TRANSLATION3D_BYTE_SIZE + ROTATION3D_BYTE_SIZE; public static void packRotation2d(Packet packet, Rotation2d rotation) { - packet.encode(rotation.getRadians()); + packet.encodeDouble(rotation.getRadians()); } public static Rotation2d unpackRotation2d(Packet packet) { @@ -41,10 +57,10 @@ public static Rotation2d unpackRotation2d(Packet packet) { } public static void packQuaternion(Packet packet, Quaternion quaternion) { - packet.encode(quaternion.getW()); - packet.encode(quaternion.getX()); - packet.encode(quaternion.getY()); - packet.encode(quaternion.getZ()); + packet.encodeDouble(quaternion.getW()); + packet.encodeDouble(quaternion.getX()); + packet.encodeDouble(quaternion.getY()); + packet.encodeDouble(quaternion.getZ()); } public static Quaternion unpackQuaternion(Packet packet) { @@ -61,8 +77,8 @@ public static Rotation3d unpackRotation3d(Packet packet) { } public static void packTranslation2d(Packet packet, Translation2d translation) { - packet.encode(translation.getX()); - packet.encode(translation.getY()); + packet.encodeDouble(translation.getX()); + packet.encodeDouble(translation.getY()); } public static Translation2d unpackTranslation2d(Packet packet) { @@ -70,9 +86,9 @@ public static Translation2d unpackTranslation2d(Packet packet) { } public static void packTranslation3d(Packet packet, Translation3d translation) { - packet.encode(translation.getX()); - packet.encode(translation.getY()); - packet.encode(translation.getZ()); + packet.encodeDouble(translation.getX()); + packet.encodeDouble(translation.getY()); + packet.encodeDouble(translation.getZ()); } public static Translation3d unpackTranslation3d(Packet packet) { @@ -114,4 +130,51 @@ public static void packPose3d(Packet packet, Pose3d pose) { public static Pose3d unpackPose3d(Packet packet) { return new Pose3d(unpackTranslation3d(packet), unpackRotation3d(packet)); } + + public static void packList( + Packet packet, List data, BiConsumer packer) { + byte size = (byte) data.size(); + if (data.size() > Byte.MAX_VALUE) { + throw new RuntimeException("Array too long! Got " + size); + } + + // length byte + packet.encodeByte(size); + + for (var f : data) { + packer.accept(packet,f); + } + } + + public static List unpackList(Packet packet, Function unpacker) { + byte length = packet.decodeByte(); + + var ret = new ArrayList(); + ret.ensureCapacity(length); + + for (int i = 0; i < length; i++) { + ret.add(unpacker.apply(packet)); + } + + return ret; + } + + public static void packOptional( + Packet packet, Optional optional, BiConsumer packer) { + if (optional.isPresent()) { + packet.encodeBoolean(true); + packer.accept(packet, optional.get()); + } else { + packet.encodeBoolean(false); + } + } + + public static Optional unpackOptional(Packet packet, Function unpacker) { + boolean isPresent = packet.decodeBoolean(); + if (isPresent) { + return Optional.of(unpacker.apply(packet)); + } else { + return Optional.empty(); + } + } } From db591c127b64fe6d7066da6cba8c63b077074675 Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Fri, 15 May 2026 15:24:08 -0400 Subject: [PATCH 04/42] regenerated messages --- photon-serde/message_data_types.yaml | 35 +++++++-- photon-serde/templates/Message.java.jinja | 66 +++++++++++------ .../struct/MultiTargetPNPResultSerde.java | 4 +- .../struct/PhotonPipelineMetadataSerde.java | 8 +- .../struct/PhotonPipelineResultSerde.java | 2 +- .../struct/PhotonTrackedTargetSerde.java | 26 +++++-- .../photonvision/struct/PnpResultSerde.java | 16 +++- .../struct/TargetCornerSerde.java | 4 +- .../common/dataflow/structures/Packet.java | 74 +++++++++---------- .../org/photonvision/utils/PacketUtils.java | 18 +---- 10 files changed, 152 insertions(+), 101 deletions(-) diff --git a/photon-serde/message_data_types.yaml b/photon-serde/message_data_types.yaml index 834822e7f5..d8ed574873 100644 --- a/photon-serde/message_data_types.yaml +++ b/photon-serde/message_data_types.yaml @@ -5,7 +5,11 @@ bool: java_type: bool cpp_type: bool java_decode_method: decodeBoolean - java_encode_shim: encodeBoolean + java_optional_decode_method: decodeBooleanOptional + java_list_decode_method: decodeBooleanList + java_encode_method: encodeBoolean + java_optional_encode_method: encodeBooleanOptional + java_list_encode_method: encodeBooleanList python_decode_shim: decodeBoolean python_encode_shim: encodeBoolean int16: @@ -13,8 +17,11 @@ int16: java_type: short cpp_type: int16_t java_decode_method: decodeShort + java_optional_decode_method: decodeShortOptional java_list_decode_method: decodeShortList - java_encode_shim: encodeShort + java_encode_method: encodeShort + java_optional_encode_method: encodeShortOptional + java_list_encode_method: encodeShortList python_decode_shim: decodeShort python_encode_shim: encodeShort int32: @@ -22,7 +29,11 @@ int32: java_type: int cpp_type: int32_t java_decode_method: decodeInt - java_encode_shim: encodeInt + java_optional_decode_method: decodeIntOptional + java_list_decode_method: decodeIntList + java_encode_method: encodeInt + java_optional_encode_method: encodeIntOptional + java_list_encode_method: encodeIntList python_decode_shim: decodeInt python_encode_shim: encodeInt int64: @@ -30,7 +41,11 @@ int64: java_type: long cpp_type: int64_t java_decode_method: decodeLong - java_encode_shim: encodeLong + java_optional_decode_method: decodeLongOptional + java_list_decode_method: decodeLongList + java_encode_method: encodeLong + java_optional_encode_method: encodeLongOptional + java_list_encode_method: encodeLongList python_decode_shim: decodeLong python_encode_shim: encodeLong float32: @@ -38,7 +53,11 @@ float32: java_type: float cpp_type: float java_decode_method: decodeFloat - java_encode_shim: encodeFloat + java_optional_decode_method: decodeFloatOptional + java_list_decode_method: decodeFloatList + java_encode_method: encodeFloat + java_optional_encode_method: encodeFloatOptional + java_list_encode_method: encodeFloatList python_decode_shim: decodeFloat python_encode_shim: encodeFloat float64: @@ -46,6 +65,10 @@ float64: java_type: double cpp_type: double java_decode_method: decodeDouble - java_encode_shim: encodeDouble + java_optional_decode_method: decodeDoubleOptional + java_list_decode_method: decodeDoubleList + java_encode_method: encodeDouble + java_optional_encode_method: encodeDoubleOptional + java_list_encode_method: encodeDoubleList python_decode_shim: decodeDouble python_encode_shim: encodeDouble diff --git a/photon-serde/templates/Message.java.jinja b/photon-serde/templates/Message.java.jinja index b250c3fb3b..8ac978128c 100644 --- a/photon-serde/templates/Message.java.jinja +++ b/photon-serde/templates/Message.java.jinja @@ -62,9 +62,9 @@ public class {{ name }}Serde implements PacketSerde<{{name}}> { throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); } {% for field in fields -%} -{%- if field.type | is_shimmed and field.optional == True %} - private static BiConsumer {{ field.name }}_PSINTERNALopt_encode_shim_callable = (packet, value) -> {{ get_message_by_name(field.type).java_encode_shim }}(packet, value); - private static Function {{ field.name }}_PSINTERNALopt_decode_shim_callable = (packet) -> {{ get_message_by_name(field.type).java_decode_shim }}(packet); +{%- if field.type | is_shimmed %} + private static BiConsumer {{ field.name }}_PSINTERNALencode_shim_callable = (packet, value) -> {{ get_message_by_name(field.type).java_encode_shim }}(packet, value); + private static Function {{ field.name }}_PSINTERNALdecode_shim_callable = (packet) -> {{ get_message_by_name(field.type).java_decode_shim }}(packet); {% endif -%} {% endfor%} @Override @@ -72,26 +72,37 @@ public class {{ name }}Serde implements PacketSerde<{{name}}> { {%- for field in fields -%} {%- if field.type | is_shimmed %} {%- if field.optional == True %} - // {{ field.name }} is optional and shimmed! + // {{ field.name }} is optional! it better not be a VLA too PacketUtils.packOptional(packet, value.{{ field.name }}, {{ field.name }}_PSINTERNALencode_shim_callable); + {%- elif field.vla == True %} + // {{ field.name }} is a custom VLA! + PacketUtils.packList(packet, value.{{ field.name }}, {{ field.name }}_PSINTERNALencode_shim_callable); {%- else %} + // {{ field.name }} is of shimmed type {{ field.type }} {{ get_message_by_name(field.type).java_encode_shim }}(packet, value.{{ field.name }}); {%- endif %} -{%- elif field.optional == True %} +{%- elif field.type | is_intrinsic %} + {%- if field.optional == True %} // {{ field.name }} is optional! it better not be a VLA too - packet.encodeOptional(value.{{ field.name }}); -{%- elif field.vla == True and field.type | is_intrinsic %} - // {{ field.name }} is a intrinsic VLA! - packet.encode(value.{{ field.name }}); -{%- elif field.vla == True %} + packet.{{ type_map[field.type].java_optipnal_encode_method }}(value.{{ field.name }}); + {%- elif field.vla == True %} // {{ field.name }} is a custom VLA! - packet.encodeList(value.{{ field.name }}); -{%- elif field.type | is_intrinsic %} + packet.{{ type_map[field.type].java_list_encode_method }}(value.{{ field.name }}); + {%- else %} // field {{ field.name }} is of intrinsic type {{ field.type }} - packet.encode(({{ type_map[field.type].java_type }}) value.{{ field.name }}); + packet.{{ type_map[field.type].java_encode_method }}(value.{{ field.name }}); + {%- endif %} {%- else %} + {%- if field.optional == True %} + // {{ field.name }} is optional! it better not be a VLA too + packet.encodeOptional(value.{{ field.name }}); + {%- elif field.vla == True %} + // {{ field.name }} is a custom VLA! + packet.encodeList(value.{{ field.name }}); + {%- else %} // field {{ field.name }} is of non-intrinsic type {{ field.type }} {{ field.type }}.photonStruct.pack(packet, value.{{ field.name }}); + {%- endif %} {%- endif %} {%- if not loop.last %} {% endif -%} @@ -105,25 +116,36 @@ public class {{ name }}Serde implements PacketSerde<{{name}}> { {%- if field.type | is_shimmed %} {%- if field.optional == True %} // {{ field.name }} is optional! it better not be a VLA too - ret.{{ field.name }} = PacketUtils.unpackOptional(packet, {{ field.name }}_PSINTERNALopt_decode_shim_callable); + ret.{{ field.name }} = PacketUtils.unpackOptional(packet, {{ field.name }}_PSINTERNALdecode_shim_callable); + {%- elif field.vla == True %} + // {{ field.name }} is a custom VLA! + ret.{{ field.name }} = PacketUtils.unpackList(packet, {{ field.name }}_PSINTERNALdecode_shim_callable); {%- else %} + // {{ field.name }} is of shimmed type {{ field.type }} ret.{{ field.name }} = {{ get_message_by_name(field.type).java_decode_shim }}(packet); {%- endif %} -{%- elif field.optional == True %} +{%- elif field.type | is_intrinsic %} + {%- if field.optional == True %} // {{ field.name }} is optional! it better not be a VLA too - ret.{{ field.name }} = packet.decodeOptional({{ field.type }}.photonStruct); -{%- elif field.vla == True and not field.type | is_intrinsic %} + ret.{{ field.name }} = packet.{{ type_map[field.type].java_optional_decode_method }}(); + {%- elif field.vla == True %} // {{ field.name }} is a custom VLA! - ret.{{ field.name }} = packet.decodeList({{ field.type }}.photonStruct); -{%- elif field.vla == True and field.type | is_intrinsic %} - // {{ field.name }} is a custom VLA! - ret.{{ field.name }} = packet.decode{{ type_map[field.type].java_type.title() }}List(); -{%- elif field.type | is_intrinsic %} + ret.{{ field.name }} = packet.{{ type_map[field.type].java_list_decode_method }}(); + {%- else %} // {{ field.name }} is of intrinsic type {{ field.type }} ret.{{field.name}} = packet.{{ type_map[field.type].java_decode_method }}(); + {%- endif %} {%- else %} + {%- if field.optional == True %} + // {{ field.name }} is optional! it better not be a VLA too + ret.{{ field.name }} = packet.decodeOptional({{ field.type }}.photonStruct); + {%- elif field.vla == True %} + // {{ field.name }} is a custom VLA! + ret.{{ field.name }} = packet.decodeList({{ field.type }}.photonStruct); + {%- else %} // {{ field.name }} is of non-intrinsic type {{ field.type }} ret.{{field.name}} = {{ field.type }}.photonStruct.unpack(packet); + {%- endif %} {%- endif %} {%- if not loop.last %} {% endif -%} diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/MultiTargetPNPResultSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/MultiTargetPNPResultSerde.java index c30411cc73..7b7cef7de2 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/MultiTargetPNPResultSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/MultiTargetPNPResultSerde.java @@ -64,8 +64,8 @@ public void pack(Packet packet, MultiTargetPNPResult value) { // field estimatedPose is of non-intrinsic type PnpResult PnpResult.photonStruct.pack(packet, value.estimatedPose); - // fiducialIDsUsed is a intrinsic VLA! - packet.encode(value.fiducialIDsUsed); + // fiducialIDsUsed is a custom VLA! + packet.encodeShortList(value.fiducialIDsUsed); } @Override diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineMetadataSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineMetadataSerde.java index 7b1723f57a..100d545270 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineMetadataSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineMetadataSerde.java @@ -62,16 +62,16 @@ public int getMaxByteSize() { @Override public void pack(Packet packet, PhotonPipelineMetadata value) { // field sequenceID is of intrinsic type int64 - packet.encode((long) value.sequenceID); + packet.encodeLong(value.sequenceID); // field captureTimestampMicros is of intrinsic type int64 - packet.encode((long) value.captureTimestampMicros); + packet.encodeLong(value.captureTimestampMicros); // field publishTimestampMicros is of intrinsic type int64 - packet.encode((long) value.publishTimestampMicros); + packet.encodeLong(value.publishTimestampMicros); // field timeSinceLastPong is of intrinsic type int64 - packet.encode((long) value.timeSinceLastPong); + packet.encodeLong(value.timeSinceLastPong); } @Override diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java index 9f585a1696..fad9d7084c 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java @@ -90,7 +90,7 @@ public PhotonPipelineResult unpack(Packet packet) { @Override public PacketSerde[] getNestedPhotonMessages() { return new PacketSerde[] { - PhotonTrackedTarget.photonStruct,PhotonPipelineMetadata.photonStruct,MultiTargetPNPResult.photonStruct + PhotonTrackedTarget.photonStruct,MultiTargetPNPResult.photonStruct,PhotonPipelineMetadata.photonStruct }; } diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonTrackedTargetSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonTrackedTargetSerde.java index d941a3b1e3..8d96ee26c7 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonTrackedTargetSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonTrackedTargetSerde.java @@ -59,35 +59,43 @@ public int getMaxByteSize() { throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); } + private static BiConsumer bestCameraToTarget_PSINTERNALencode_shim_callable = (packet, value) -> PacketUtils.packTransform3d(packet, value); + private static Function bestCameraToTarget_PSINTERNALdecode_shim_callable = (packet) -> PacketUtils.unpackTransform3d(packet); + + private static BiConsumer altCameraToTarget_PSINTERNALencode_shim_callable = (packet, value) -> PacketUtils.packTransform3d(packet, value); + private static Function altCameraToTarget_PSINTERNALdecode_shim_callable = (packet) -> PacketUtils.unpackTransform3d(packet); + @Override public void pack(Packet packet, PhotonTrackedTarget value) { // field yaw is of intrinsic type float64 - packet.encode((double) value.yaw); + packet.encodeDouble(value.yaw); // field pitch is of intrinsic type float64 - packet.encode((double) value.pitch); + packet.encodeDouble(value.pitch); // field area is of intrinsic type float64 - packet.encode((double) value.area); + packet.encodeDouble(value.area); // field skew is of intrinsic type float64 - packet.encode((double) value.skew); + packet.encodeDouble(value.skew); // field fiducialId is of intrinsic type int32 - packet.encode((int) value.fiducialId); + packet.encodeInt(value.fiducialId); // field objDetectId is of intrinsic type int32 - packet.encode((int) value.objDetectId); + packet.encodeInt(value.objDetectId); // field objDetectConf is of intrinsic type float32 - packet.encode((float) value.objDetectConf); + packet.encodeFloat(value.objDetectConf); + // bestCameraToTarget is of shimmed type Transform3d PacketUtils.packTransform3d(packet, value.bestCameraToTarget); + // altCameraToTarget is of shimmed type Transform3d PacketUtils.packTransform3d(packet, value.altCameraToTarget); // field poseAmbiguity is of intrinsic type float64 - packet.encode((double) value.poseAmbiguity); + packet.encodeDouble(value.poseAmbiguity); // minAreaRectCorners is a custom VLA! packet.encodeList(value.minAreaRectCorners); @@ -121,8 +129,10 @@ public PhotonTrackedTarget unpack(Packet packet) { // objDetectConf is of intrinsic type float32 ret.objDetectConf = packet.decodeFloat(); + // bestCameraToTarget is of shimmed type Transform3d ret.bestCameraToTarget = PacketUtils.unpackTransform3d(packet); + // altCameraToTarget is of shimmed type Transform3d ret.altCameraToTarget = PacketUtils.unpackTransform3d(packet); // poseAmbiguity is of intrinsic type float64 diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/PnpResultSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/PnpResultSerde.java index 4a4b929e80..c8e6ae6897 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/PnpResultSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/PnpResultSerde.java @@ -59,28 +59,38 @@ public int getMaxByteSize() { throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); } + private static BiConsumer best_PSINTERNALencode_shim_callable = (packet, value) -> PacketUtils.packTransform3d(packet, value); + private static Function best_PSINTERNALdecode_shim_callable = (packet) -> PacketUtils.unpackTransform3d(packet); + + private static BiConsumer alt_PSINTERNALencode_shim_callable = (packet, value) -> PacketUtils.packTransform3d(packet, value); + private static Function alt_PSINTERNALdecode_shim_callable = (packet) -> PacketUtils.unpackTransform3d(packet); + @Override public void pack(Packet packet, PnpResult value) { + // best is of shimmed type Transform3d PacketUtils.packTransform3d(packet, value.best); + // alt is of shimmed type Transform3d PacketUtils.packTransform3d(packet, value.alt); // field bestReprojErr is of intrinsic type float64 - packet.encode((double) value.bestReprojErr); + packet.encodeDouble(value.bestReprojErr); // field altReprojErr is of intrinsic type float64 - packet.encode((double) value.altReprojErr); + packet.encodeDouble(value.altReprojErr); // field ambiguity is of intrinsic type float64 - packet.encode((double) value.ambiguity); + packet.encodeDouble(value.ambiguity); } @Override public PnpResult unpack(Packet packet) { var ret = new PnpResult(); + // best is of shimmed type Transform3d ret.best = PacketUtils.unpackTransform3d(packet); + // alt is of shimmed type Transform3d ret.alt = PacketUtils.unpackTransform3d(packet); // bestReprojErr is of intrinsic type float64 diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/TargetCornerSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/TargetCornerSerde.java index b0f5865174..ee867ee1f0 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/TargetCornerSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/TargetCornerSerde.java @@ -62,10 +62,10 @@ public int getMaxByteSize() { @Override public void pack(Packet packet, TargetCorner value) { // field x is of intrinsic type float64 - packet.encode((double) value.x); + packet.encodeDouble(value.x); // field y is of intrinsic type float64 - packet.encode((double) value.y); + packet.encodeDouble(value.y); } @Override diff --git a/photon-targeting/src/main/java/org/photonvision/common/dataflow/structures/Packet.java b/photon-targeting/src/main/java/org/photonvision/common/dataflow/structures/Packet.java index 1efb79a858..89077b71fd 100644 --- a/photon-targeting/src/main/java/org/photonvision/common/dataflow/structures/Packet.java +++ b/photon-targeting/src/main/java/org/photonvision/common/dataflow/structures/Packet.java @@ -21,8 +21,6 @@ import java.util.Arrays; import java.util.List; import java.util.Optional; -import java.util.function.BiConsumer; -import java.util.function.Function; import org.photonvision.targeting.serde.PhotonStructSerializable; /** A packet that holds byte-packed data to be sent over NetworkTables. */ @@ -160,7 +158,7 @@ public void encodeByte(byte src) { /** * Encodes a VLA of bytes into the packet - * + * * @param src The VLA of bytes to encode */ public void encodeByteList(List src) { @@ -178,7 +176,7 @@ public void encodeByteList(List src) { /** * Encodes an optional byte into the packet - * + * * @param src the optional byte to encode */ public void encodeByteOptional(Optional src) { @@ -201,7 +199,7 @@ public void encodeShort(short src) { /** * Encodes a VLA of shorts into the packet - * + * * @param src The VLA of shorts to encode */ public void encodeShortList(List src) { @@ -219,7 +217,7 @@ public void encodeShortList(List src) { /** * Encodes an optional short into the packet - * + * * @param src the optional short to encode */ public void encodeShortOptional(Optional src) { @@ -244,7 +242,7 @@ public void encodeInt(int src) { /** * Encodes a VLA of ints into the packet - * + * * @param src The VLA of intsto encode */ public void encodeIntList(List src) { @@ -262,7 +260,7 @@ public void encodeIntList(List src) { /** * Encodes an optional int into the packet - * + * * @param src the optional int to encode */ public void encodeIntOptional(Optional src) { @@ -291,7 +289,7 @@ public void encodeLong(long src) { /** * Encodes a VLA of longs into the packet - * + * * @param src The VLA of longs to encode */ public void encodeLongList(List src) { @@ -309,7 +307,7 @@ public void encodeLongList(List src) { /** * Encodes an optional long into the packet - * + * * @param src the optional long to encode */ public void encodeLongOptional(Optional src) { @@ -335,7 +333,7 @@ public void encodeFloat(float src) { /** * Encodes a VLA of floats into the packet - * + * * @param src The VLA of floats to encode */ public void encodeFloatList(List src) { @@ -353,7 +351,7 @@ public void encodeFloatList(List src) { /** * Encodes an optional float into the packet - * + * * @param src the optional float to encode */ public void encodeFloatOptional(Optional src) { @@ -383,7 +381,7 @@ public void encodeDouble(double src) { /** * Encodes a VLA of doubles into the packet - * + * * @param src The VLA of doubles to encode */ public void encodeDoubleList(List src) { @@ -401,7 +399,7 @@ public void encodeDoubleList(List src) { /** * Encodes an optional double into the packet - * + * * @param src the optional double to encode */ public void encodeDoubleOptional(Optional src) { @@ -423,7 +421,7 @@ public void encodeBoolean(boolean src) { /** * Encodes a VLA of booleans into the packet - * + * * @param src The VLA of booleans to encode */ public void encodeBooleanList(List src) { @@ -441,7 +439,7 @@ public void encodeBooleanList(List src) { /** * Encodes an optional boolean into the packet - * + * * @param src the optional boolean to encode */ public void encodeBooleanOptional(Optional src) { @@ -504,7 +502,7 @@ public byte decodeByte() { /** * Returns a list of decoded byte from the packet - * + * * @return A decoded list of byte from the packet */ public List decodeByteList() { @@ -522,7 +520,7 @@ public List decodeByteList() { /** * Returns an optional decoded byte from the packet - * + * * @return A decoded optional byte from the packet */ public Optional decodeByteOptional() { @@ -530,12 +528,12 @@ public Optional decodeByteOptional() { if (present) { return Optional.of(decodeByte()); } - return Optional.empty(); + return Optional.empty(); } /** * Returns a decoded short from the packet - * + * * @return A decoded short from the packet */ public short decodeShort() { @@ -547,7 +545,7 @@ public short decodeShort() { /** * Returns a list of decoded shorts from the packet - * + * * @return A decoded list of shorts from the packet */ public List decodeShortList() { @@ -565,7 +563,7 @@ public List decodeShortList() { /** * Returns an optional decoded short from the packet - * + * * @return A decoded optional short from the packet */ public Optional decodeShortOptional() { @@ -573,7 +571,7 @@ public Optional decodeShortOptional() { if (present) { return Optional.of(decodeShort()); } - return Optional.empty(); + return Optional.empty(); } /** @@ -593,7 +591,7 @@ public int decodeInt() { /** * Returns a list of decoded ints from the packet - * + * * @return A decoded list of ints from the packet */ public List decodeIntList() { @@ -611,7 +609,7 @@ public List decodeIntList() { /** * Returns an optional decoded int from the packet - * + * * @return A decoded optional int from the packet */ public Optional decodeIntOptional() { @@ -619,7 +617,7 @@ public Optional decodeIntOptional() { if (present) { return Optional.of(decodeInt()); } - return Optional.empty(); + return Optional.empty(); } public long decodeLong() { @@ -641,7 +639,7 @@ public long decodeLong() { /** * Returns a list of decoded longs from the packet - * + * * @return A decoded list of longs from the packet */ public List decodeLongList() { @@ -659,7 +657,7 @@ public List decodeLongList() { /** * Returns an optional decoded long from the packet - * + * * @return A decoded optional long from the packet */ public Optional decodeLongOptional() { @@ -667,7 +665,7 @@ public Optional decodeLongOptional() { if (present) { return Optional.of(decodeLong()); } - return Optional.empty(); + return Optional.empty(); } /** @@ -690,7 +688,7 @@ public float decodeFloat() { /** * Returns a list of decoded floats from the packet - * + * * @return A decoded list of floats from the packet */ public List decodeFloatList() { @@ -708,7 +706,7 @@ public List decodeFloatList() { /** * Returns an optional decoded float from the packet - * + * * @return A decoded optional float from the packet */ public Optional decodeFloatOptional() { @@ -716,7 +714,7 @@ public Optional decodeFloatOptional() { if (present) { return Optional.of(decodeFloat()); } - return Optional.empty(); + return Optional.empty(); } /** @@ -743,7 +741,7 @@ public double decodeDouble() { /** * Returns a list of decoded doubles from the packet - * + * * @return A decoded list of doubles from the packet */ public List decodeDoubleList() { @@ -761,7 +759,7 @@ public List decodeDoubleList() { /** * Returns an optional decoded double from the packet - * + * * @return A decoded optional double from the packet */ public Optional decodeDoubleOptional() { @@ -769,7 +767,7 @@ public Optional decodeDoubleOptional() { if (present) { return Optional.of(decodeDouble()); } - return Optional.empty(); + return Optional.empty(); } /** @@ -786,7 +784,7 @@ public boolean decodeBoolean() { /** * Returns a list of decoded booleans from the packet - * + * * @return A decoded list of booleans from the packet */ public List decodeBooleanList() { @@ -804,7 +802,7 @@ public List decodeBooleanList() { /** * Returns an optional decoded boolean from the packet - * + * * @return A decoded optional boolean from the packet */ public Optional decodeBooleanOptional() { @@ -812,7 +810,7 @@ public Optional decodeBooleanOptional() { if (present) { return Optional.of(decodeBoolean()); } - return Optional.empty(); + return Optional.empty(); } public > T decode(PhotonStructSerializable t) { diff --git a/photon-targeting/src/main/java/org/photonvision/utils/PacketUtils.java b/photon-targeting/src/main/java/org/photonvision/utils/PacketUtils.java index ebd06880ea..f8ff8f7581 100644 --- a/photon-targeting/src/main/java/org/photonvision/utils/PacketUtils.java +++ b/photon-targeting/src/main/java/org/photonvision/utils/PacketUtils.java @@ -17,25 +17,14 @@ package org.photonvision.utils; -import org.photonvision.common.dataflow.structures.Packet; - import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.function.BiConsumer; import java.util.function.Function; +import org.photonvision.common.dataflow.structures.Packet; import org.wpilib.math.geometry.*; -import edu.wpi.first.math.geometry.Pose2d; -import edu.wpi.first.math.geometry.Pose3d; -import edu.wpi.first.math.geometry.Quaternion; -import edu.wpi.first.math.geometry.Rotation2d; -import edu.wpi.first.math.geometry.Rotation3d; -import edu.wpi.first.math.geometry.Transform2d; -import edu.wpi.first.math.geometry.Transform3d; -import edu.wpi.first.math.geometry.Translation2d; -import edu.wpi.first.math.geometry.Translation3d; - @SuppressWarnings("doclint") public class PacketUtils { public static final int ROTATION2D_BYTE_SIZE = Double.BYTES; @@ -131,8 +120,7 @@ public static Pose3d unpackPose3d(Packet packet) { return new Pose3d(unpackTranslation3d(packet), unpackRotation3d(packet)); } - public static void packList( - Packet packet, List data, BiConsumer packer) { + public static void packList(Packet packet, List data, BiConsumer packer) { byte size = (byte) data.size(); if (data.size() > Byte.MAX_VALUE) { throw new RuntimeException("Array too long! Got " + size); @@ -142,7 +130,7 @@ public static void packList( packet.encodeByte(size); for (var f : data) { - packer.accept(packet,f); + packer.accept(packet, f); } } From 1dc7746f7ac326b92d2cf76c7582b270c189488d Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Fri, 15 May 2026 18:14:13 -0400 Subject: [PATCH 05/42] autogenerated test classes --- .../generated/BoolTestMessageSerde.py | 75 ++++++++++++ .../generated/Float32TestMessageSerde.py | 75 ++++++++++++ .../generated/Float64TestMessageSerde.py | 75 ++++++++++++ .../generated/Int16TestMessageSerde.py | 75 ++++++++++++ .../generated/Int32TestMessageSerde.py | 75 ++++++++++++ .../generated/Int64TestMessageSerde.py | 75 ++++++++++++ .../generated/Int8TestMessageSerde.py | 75 ++++++++++++ .../generated/MultiTargetPNPResultSerde.py | 4 +- .../generated/Transform3dTestMessageSerde.py | 74 ++++++++++++ photon-lib/py/photonlibpy/packet.py | 16 --- .../py/photonlibpy/targeting/testMessages.py | 55 +++++++++ photon-serde/generate_messages.py | 60 ++++++++++ photon-serde/message_data_types.yaml | 25 +++- photon-serde/messages.yaml | 98 +++++++++++++++ photon-serde/templates/Message.java.jinja | 2 +- .../templates/ThingTestClass.java.jinja | 74 ++++++++++++ .../templates/ThingTestStruct.h.jinja | 51 ++++++++ .../struct/BoolTestMessageSerde.java | 103 ++++++++++++++++ .../struct/Float32TestMessageSerde.java | 103 ++++++++++++++++ .../struct/Float64TestMessageSerde.java | 103 ++++++++++++++++ .../struct/Int16TestMessageSerde.java | 103 ++++++++++++++++ .../struct/Int32TestMessageSerde.java | 103 ++++++++++++++++ .../struct/Int64TestMessageSerde.java | 103 ++++++++++++++++ .../struct/Int8TestMessageSerde.java | 103 ++++++++++++++++ .../struct/Transform3dTestMessageSerde.java | 112 ++++++++++++++++++ .../targeting/BoolTestMessage.java | 59 +++++++++ .../targeting/Float32TestMessage.java | 59 +++++++++ .../targeting/Float64TestMessage.java | 59 +++++++++ .../targeting/Int16TestMessage.java | 59 +++++++++ .../targeting/Int32TestMessage.java | 59 +++++++++ .../targeting/Int64TestMessage.java | 59 +++++++++ .../targeting/Int8TestMessage.java | 59 +++++++++ .../targeting/Transform3dTestMessage.java | 59 +++++++++ .../cpp/photon/serde/BoolTestMessageSerde.cpp | 47 ++++++++ .../photon/serde/Float32TestMessageSerde.cpp | 47 ++++++++ .../photon/serde/Float64TestMessageSerde.cpp | 47 ++++++++ .../photon/serde/Int16TestMessageSerde.cpp | 47 ++++++++ .../photon/serde/Int32TestMessageSerde.cpp | 47 ++++++++ .../photon/serde/Int64TestMessageSerde.cpp | 47 ++++++++ .../cpp/photon/serde/Int8TestMessageSerde.cpp | 47 ++++++++ .../serde/Transform3dTestMessageSerde.cpp | 47 ++++++++ .../photon/serde/BoolTestMessageSerde.h | 59 +++++++++ .../photon/serde/Float32TestMessageSerde.h | 59 +++++++++ .../photon/serde/Float64TestMessageSerde.h | 59 +++++++++ .../photon/serde/Int16TestMessageSerde.h | 59 +++++++++ .../photon/serde/Int32TestMessageSerde.h | 59 +++++++++ .../photon/serde/Int64TestMessageSerde.h | 59 +++++++++ .../photon/serde/Int8TestMessageSerde.h | 59 +++++++++ .../serde/Transform3dTestMessageSerde.h | 60 ++++++++++ .../photon/struct/BoolTestMessageStruct.h | 45 +++++++ .../photon/struct/Float32TestMessageStruct.h | 45 +++++++ .../photon/struct/Float64TestMessageStruct.h | 45 +++++++ .../photon/struct/Int16TestMessageStruct.h | 45 +++++++ .../photon/struct/Int32TestMessageStruct.h | 45 +++++++ .../photon/struct/Int64TestMessageStruct.h | 45 +++++++ .../photon/struct/Int8TestMessageStruct.h | 45 +++++++ .../struct/Transform3dTestMessageStruct.h | 46 +++++++ .../photon/targeting/BoolTestMessage.h | 51 ++++++++ .../photon/targeting/Float32TestMessage.h | 51 ++++++++ .../photon/targeting/Float64TestMessage.h | 51 ++++++++ .../photon/targeting/Int16TestMessage.h | 51 ++++++++ .../photon/targeting/Int32TestMessage.h | 51 ++++++++ .../photon/targeting/Int64TestMessage.h | 51 ++++++++ .../photon/targeting/Int8TestMessage.h | 51 ++++++++ .../photon/targeting/Transform3dTestMessage.h | 51 ++++++++ .../common/dataflow/structures/Packet.java | 10 +- 66 files changed, 3890 insertions(+), 27 deletions(-) create mode 100644 photon-lib/py/photonlibpy/generated/BoolTestMessageSerde.py create mode 100644 photon-lib/py/photonlibpy/generated/Float32TestMessageSerde.py create mode 100644 photon-lib/py/photonlibpy/generated/Float64TestMessageSerde.py create mode 100644 photon-lib/py/photonlibpy/generated/Int16TestMessageSerde.py create mode 100644 photon-lib/py/photonlibpy/generated/Int32TestMessageSerde.py create mode 100644 photon-lib/py/photonlibpy/generated/Int64TestMessageSerde.py create mode 100644 photon-lib/py/photonlibpy/generated/Int8TestMessageSerde.py create mode 100644 photon-lib/py/photonlibpy/generated/Transform3dTestMessageSerde.py create mode 100644 photon-lib/py/photonlibpy/targeting/testMessages.py create mode 100644 photon-serde/templates/ThingTestClass.java.jinja create mode 100644 photon-serde/templates/ThingTestStruct.h.jinja create mode 100644 photon-targeting/src/generated/main/java/org/photonvision/struct/BoolTestMessageSerde.java create mode 100644 photon-targeting/src/generated/main/java/org/photonvision/struct/Float32TestMessageSerde.java create mode 100644 photon-targeting/src/generated/main/java/org/photonvision/struct/Float64TestMessageSerde.java create mode 100644 photon-targeting/src/generated/main/java/org/photonvision/struct/Int16TestMessageSerde.java create mode 100644 photon-targeting/src/generated/main/java/org/photonvision/struct/Int32TestMessageSerde.java create mode 100644 photon-targeting/src/generated/main/java/org/photonvision/struct/Int64TestMessageSerde.java create mode 100644 photon-targeting/src/generated/main/java/org/photonvision/struct/Int8TestMessageSerde.java create mode 100644 photon-targeting/src/generated/main/java/org/photonvision/struct/Transform3dTestMessageSerde.java create mode 100644 photon-targeting/src/generated/main/java/org/photonvision/targeting/BoolTestMessage.java create mode 100644 photon-targeting/src/generated/main/java/org/photonvision/targeting/Float32TestMessage.java create mode 100644 photon-targeting/src/generated/main/java/org/photonvision/targeting/Float64TestMessage.java create mode 100644 photon-targeting/src/generated/main/java/org/photonvision/targeting/Int16TestMessage.java create mode 100644 photon-targeting/src/generated/main/java/org/photonvision/targeting/Int32TestMessage.java create mode 100644 photon-targeting/src/generated/main/java/org/photonvision/targeting/Int64TestMessage.java create mode 100644 photon-targeting/src/generated/main/java/org/photonvision/targeting/Int8TestMessage.java create mode 100644 photon-targeting/src/generated/main/java/org/photonvision/targeting/Transform3dTestMessage.java create mode 100644 photon-targeting/src/generated/main/native/cpp/photon/serde/BoolTestMessageSerde.cpp create mode 100644 photon-targeting/src/generated/main/native/cpp/photon/serde/Float32TestMessageSerde.cpp create mode 100644 photon-targeting/src/generated/main/native/cpp/photon/serde/Float64TestMessageSerde.cpp create mode 100644 photon-targeting/src/generated/main/native/cpp/photon/serde/Int16TestMessageSerde.cpp create mode 100644 photon-targeting/src/generated/main/native/cpp/photon/serde/Int32TestMessageSerde.cpp create mode 100644 photon-targeting/src/generated/main/native/cpp/photon/serde/Int64TestMessageSerde.cpp create mode 100644 photon-targeting/src/generated/main/native/cpp/photon/serde/Int8TestMessageSerde.cpp create mode 100644 photon-targeting/src/generated/main/native/cpp/photon/serde/Transform3dTestMessageSerde.cpp create mode 100644 photon-targeting/src/generated/main/native/include/photon/serde/BoolTestMessageSerde.h create mode 100644 photon-targeting/src/generated/main/native/include/photon/serde/Float32TestMessageSerde.h create mode 100644 photon-targeting/src/generated/main/native/include/photon/serde/Float64TestMessageSerde.h create mode 100644 photon-targeting/src/generated/main/native/include/photon/serde/Int16TestMessageSerde.h create mode 100644 photon-targeting/src/generated/main/native/include/photon/serde/Int32TestMessageSerde.h create mode 100644 photon-targeting/src/generated/main/native/include/photon/serde/Int64TestMessageSerde.h create mode 100644 photon-targeting/src/generated/main/native/include/photon/serde/Int8TestMessageSerde.h create mode 100644 photon-targeting/src/generated/main/native/include/photon/serde/Transform3dTestMessageSerde.h create mode 100644 photon-targeting/src/generated/main/native/include/photon/struct/BoolTestMessageStruct.h create mode 100644 photon-targeting/src/generated/main/native/include/photon/struct/Float32TestMessageStruct.h create mode 100644 photon-targeting/src/generated/main/native/include/photon/struct/Float64TestMessageStruct.h create mode 100644 photon-targeting/src/generated/main/native/include/photon/struct/Int16TestMessageStruct.h create mode 100644 photon-targeting/src/generated/main/native/include/photon/struct/Int32TestMessageStruct.h create mode 100644 photon-targeting/src/generated/main/native/include/photon/struct/Int64TestMessageStruct.h create mode 100644 photon-targeting/src/generated/main/native/include/photon/struct/Int8TestMessageStruct.h create mode 100644 photon-targeting/src/generated/main/native/include/photon/struct/Transform3dTestMessageStruct.h create mode 100644 photon-targeting/src/generated/main/native/include/photon/targeting/BoolTestMessage.h create mode 100644 photon-targeting/src/generated/main/native/include/photon/targeting/Float32TestMessage.h create mode 100644 photon-targeting/src/generated/main/native/include/photon/targeting/Float64TestMessage.h create mode 100644 photon-targeting/src/generated/main/native/include/photon/targeting/Int16TestMessage.h create mode 100644 photon-targeting/src/generated/main/native/include/photon/targeting/Int32TestMessage.h create mode 100644 photon-targeting/src/generated/main/native/include/photon/targeting/Int64TestMessage.h create mode 100644 photon-targeting/src/generated/main/native/include/photon/targeting/Int8TestMessage.h create mode 100644 photon-targeting/src/generated/main/native/include/photon/targeting/Transform3dTestMessage.h diff --git a/photon-lib/py/photonlibpy/generated/BoolTestMessageSerde.py b/photon-lib/py/photonlibpy/generated/BoolTestMessageSerde.py new file mode 100644 index 0000000000..60da7741c9 --- /dev/null +++ b/photon-lib/py/photonlibpy/generated/BoolTestMessageSerde.py @@ -0,0 +1,75 @@ +# +# MIT License +# +# Copyright (c) PhotonVision +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +############################################################################### +## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. +## --> DO NOT MODIFY <-- +############################################################################### + +from typing import TYPE_CHECKING + +from ..packet import Packet +from ..targeting import * # noqa + +if TYPE_CHECKING: + from ..targeting import BoolTestMessage # noqa + + +class BoolTestMessageSerde: + # Message definition md5sum. See photon_packet.adoc for details + MESSAGE_VERSION = "c8efe94a9c0d815658c74de6f672939c" + MESSAGE_FORMAT = "bool test;bool vlaTest[?];optional bool optTest;" + + @staticmethod + def pack(value: "BoolTestMessage") -> "Packet": + ret = Packet() + + # test is of intrinsic type bool + ret.encodeBoolean(value.test) + + # vlaTest is a custom VLA! + ret.encodeListShimmed(value.vlaTest, ret.encodeBoolean) + + # optTest is optional! it better not be a VLA too + ret.encodeOptionalShimmed(value.optTest, ret.encodeBoolean) + return ret + + @staticmethod + def unpack(packet: "Packet") -> "BoolTestMessage": + ret = BoolTestMessage() + + # test is of intrinsic type bool + ret.test = packet.decodeBoolean() + + # vlaTest is a custom VLA! + ret.vlaTest = packet.decodeListShimmed(packet.decodeBoolean) + + # optTest is optional! it better not be a VLA too + ret.optTest = packet.decodeOptionalShimmed(packet.decodeBoolean) + + return ret + + +# Hack ourselves into the base class +BoolTestMessage.photonStruct = BoolTestMessageSerde() diff --git a/photon-lib/py/photonlibpy/generated/Float32TestMessageSerde.py b/photon-lib/py/photonlibpy/generated/Float32TestMessageSerde.py new file mode 100644 index 0000000000..7736826024 --- /dev/null +++ b/photon-lib/py/photonlibpy/generated/Float32TestMessageSerde.py @@ -0,0 +1,75 @@ +# +# MIT License +# +# Copyright (c) PhotonVision +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +############################################################################### +## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. +## --> DO NOT MODIFY <-- +############################################################################### + +from typing import TYPE_CHECKING + +from ..packet import Packet +from ..targeting import * # noqa + +if TYPE_CHECKING: + from ..targeting import Float32TestMessage # noqa + + +class Float32TestMessageSerde: + # Message definition md5sum. See photon_packet.adoc for details + MESSAGE_VERSION = "9fd9ed51ec69d6738ee24af43b2b9c7e" + MESSAGE_FORMAT = "float32 test;float32 vlaTest[?];optional float32 optTest;" + + @staticmethod + def pack(value: "Float32TestMessage") -> "Packet": + ret = Packet() + + # test is of intrinsic type float32 + ret.encodeFloat(value.test) + + # vlaTest is a custom VLA! + ret.encodeListShimmed(value.vlaTest, ret.encodeFloat) + + # optTest is optional! it better not be a VLA too + ret.encodeOptionalShimmed(value.optTest, ret.encodeFloat) + return ret + + @staticmethod + def unpack(packet: "Packet") -> "Float32TestMessage": + ret = Float32TestMessage() + + # test is of intrinsic type float32 + ret.test = packet.decodeFloat() + + # vlaTest is a custom VLA! + ret.vlaTest = packet.decodeListShimmed(packet.decodeFloat) + + # optTest is optional! it better not be a VLA too + ret.optTest = packet.decodeOptionalShimmed(packet.decodeFloat) + + return ret + + +# Hack ourselves into the base class +Float32TestMessage.photonStruct = Float32TestMessageSerde() diff --git a/photon-lib/py/photonlibpy/generated/Float64TestMessageSerde.py b/photon-lib/py/photonlibpy/generated/Float64TestMessageSerde.py new file mode 100644 index 0000000000..945db5f1a6 --- /dev/null +++ b/photon-lib/py/photonlibpy/generated/Float64TestMessageSerde.py @@ -0,0 +1,75 @@ +# +# MIT License +# +# Copyright (c) PhotonVision +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +############################################################################### +## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. +## --> DO NOT MODIFY <-- +############################################################################### + +from typing import TYPE_CHECKING + +from ..packet import Packet +from ..targeting import * # noqa + +if TYPE_CHECKING: + from ..targeting import Float64TestMessage # noqa + + +class Float64TestMessageSerde: + # Message definition md5sum. See photon_packet.adoc for details + MESSAGE_VERSION = "bc96c1f7d9db9371269d0e4f4d4b4cb2" + MESSAGE_FORMAT = "float64 test;float64 vlaTest[?];optional float64 optTest;" + + @staticmethod + def pack(value: "Float64TestMessage") -> "Packet": + ret = Packet() + + # test is of intrinsic type float64 + ret.encodeDouble(value.test) + + # vlaTest is a custom VLA! + ret.encodeListShimmed(value.vlaTest, ret.encodeDouble) + + # optTest is optional! it better not be a VLA too + ret.encodeOptionalShimmed(value.optTest, ret.encodeDouble) + return ret + + @staticmethod + def unpack(packet: "Packet") -> "Float64TestMessage": + ret = Float64TestMessage() + + # test is of intrinsic type float64 + ret.test = packet.decodeDouble() + + # vlaTest is a custom VLA! + ret.vlaTest = packet.decodeListShimmed(packet.decodeDouble) + + # optTest is optional! it better not be a VLA too + ret.optTest = packet.decodeOptionalShimmed(packet.decodeDouble) + + return ret + + +# Hack ourselves into the base class +Float64TestMessage.photonStruct = Float64TestMessageSerde() diff --git a/photon-lib/py/photonlibpy/generated/Int16TestMessageSerde.py b/photon-lib/py/photonlibpy/generated/Int16TestMessageSerde.py new file mode 100644 index 0000000000..751bd4cdfb --- /dev/null +++ b/photon-lib/py/photonlibpy/generated/Int16TestMessageSerde.py @@ -0,0 +1,75 @@ +# +# MIT License +# +# Copyright (c) PhotonVision +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +############################################################################### +## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. +## --> DO NOT MODIFY <-- +############################################################################### + +from typing import TYPE_CHECKING + +from ..packet import Packet +from ..targeting import * # noqa + +if TYPE_CHECKING: + from ..targeting import Int16TestMessage # noqa + + +class Int16TestMessageSerde: + # Message definition md5sum. See photon_packet.adoc for details + MESSAGE_VERSION = "23e6ccab160b942600aae8e94a72778a" + MESSAGE_FORMAT = "int16 test;int16 vlaTest[?];optional int16 optTest;" + + @staticmethod + def pack(value: "Int16TestMessage") -> "Packet": + ret = Packet() + + # test is of intrinsic type int16 + ret.encode16(value.test) + + # vlaTest is a custom VLA! + ret.encodeListShimmed(value.vlaTest, ret.encode16) + + # optTest is optional! it better not be a VLA too + ret.encodeOptionalShimmed(value.optTest, ret.encode16) + return ret + + @staticmethod + def unpack(packet: "Packet") -> "Int16TestMessage": + ret = Int16TestMessage() + + # test is of intrinsic type int16 + ret.test = packet.decode16() + + # vlaTest is a custom VLA! + ret.vlaTest = packet.decodeListShimmed(packet.decode16) + + # optTest is optional! it better not be a VLA too + ret.optTest = packet.decodeOptionalShimmed(packet.decode16) + + return ret + + +# Hack ourselves into the base class +Int16TestMessage.photonStruct = Int16TestMessageSerde() diff --git a/photon-lib/py/photonlibpy/generated/Int32TestMessageSerde.py b/photon-lib/py/photonlibpy/generated/Int32TestMessageSerde.py new file mode 100644 index 0000000000..ad7b8de3b2 --- /dev/null +++ b/photon-lib/py/photonlibpy/generated/Int32TestMessageSerde.py @@ -0,0 +1,75 @@ +# +# MIT License +# +# Copyright (c) PhotonVision +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +############################################################################### +## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. +## --> DO NOT MODIFY <-- +############################################################################### + +from typing import TYPE_CHECKING + +from ..packet import Packet +from ..targeting import * # noqa + +if TYPE_CHECKING: + from ..targeting import Int32TestMessage # noqa + + +class Int32TestMessageSerde: + # Message definition md5sum. See photon_packet.adoc for details + MESSAGE_VERSION = "d8596149c4701e7b8912df238cd4ec66" + MESSAGE_FORMAT = "int32 test;int32 vlaTest[?];optional int32 optTest;" + + @staticmethod + def pack(value: "Int32TestMessage") -> "Packet": + ret = Packet() + + # test is of intrinsic type int32 + ret.encodeInt(value.test) + + # vlaTest is a custom VLA! + ret.encodeListShimmed(value.vlaTest, ret.encodeInt) + + # optTest is optional! it better not be a VLA too + ret.encodeOptionalShimmed(value.optTest, ret.encodeInt) + return ret + + @staticmethod + def unpack(packet: "Packet") -> "Int32TestMessage": + ret = Int32TestMessage() + + # test is of intrinsic type int32 + ret.test = packet.decodeInt() + + # vlaTest is a custom VLA! + ret.vlaTest = packet.decodeListShimmed(packet.decodeInt) + + # optTest is optional! it better not be a VLA too + ret.optTest = packet.decodeOptionalShimmed(packet.decodeInt) + + return ret + + +# Hack ourselves into the base class +Int32TestMessage.photonStruct = Int32TestMessageSerde() diff --git a/photon-lib/py/photonlibpy/generated/Int64TestMessageSerde.py b/photon-lib/py/photonlibpy/generated/Int64TestMessageSerde.py new file mode 100644 index 0000000000..c536f23474 --- /dev/null +++ b/photon-lib/py/photonlibpy/generated/Int64TestMessageSerde.py @@ -0,0 +1,75 @@ +# +# MIT License +# +# Copyright (c) PhotonVision +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +############################################################################### +## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. +## --> DO NOT MODIFY <-- +############################################################################### + +from typing import TYPE_CHECKING + +from ..packet import Packet +from ..targeting import * # noqa + +if TYPE_CHECKING: + from ..targeting import Int64TestMessage # noqa + + +class Int64TestMessageSerde: + # Message definition md5sum. See photon_packet.adoc for details + MESSAGE_VERSION = "dd2e470b4d07bbcd208906c26a2ae37a" + MESSAGE_FORMAT = "int64 test;int64 vlaTest[?];optional int64 optTest;" + + @staticmethod + def pack(value: "Int64TestMessage") -> "Packet": + ret = Packet() + + # test is of intrinsic type int64 + ret.encodeLong(value.test) + + # vlaTest is a custom VLA! + ret.encodeListShimmed(value.vlaTest, ret.encodeLong) + + # optTest is optional! it better not be a VLA too + ret.encodeOptionalShimmed(value.optTest, ret.encodeLong) + return ret + + @staticmethod + def unpack(packet: "Packet") -> "Int64TestMessage": + ret = Int64TestMessage() + + # test is of intrinsic type int64 + ret.test = packet.decodeLong() + + # vlaTest is a custom VLA! + ret.vlaTest = packet.decodeListShimmed(packet.decodeLong) + + # optTest is optional! it better not be a VLA too + ret.optTest = packet.decodeOptionalShimmed(packet.decodeLong) + + return ret + + +# Hack ourselves into the base class +Int64TestMessage.photonStruct = Int64TestMessageSerde() diff --git a/photon-lib/py/photonlibpy/generated/Int8TestMessageSerde.py b/photon-lib/py/photonlibpy/generated/Int8TestMessageSerde.py new file mode 100644 index 0000000000..e4e7842364 --- /dev/null +++ b/photon-lib/py/photonlibpy/generated/Int8TestMessageSerde.py @@ -0,0 +1,75 @@ +# +# MIT License +# +# Copyright (c) PhotonVision +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +############################################################################### +## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. +## --> DO NOT MODIFY <-- +############################################################################### + +from typing import TYPE_CHECKING + +from ..packet import Packet +from ..targeting import * # noqa + +if TYPE_CHECKING: + from ..targeting import Int8TestMessage # noqa + + +class Int8TestMessageSerde: + # Message definition md5sum. See photon_packet.adoc for details + MESSAGE_VERSION = "76297a79f30e4d995b8f95c5fa6297fa" + MESSAGE_FORMAT = "int8 test;int8 vlaTest[?];optional int8 optTest;" + + @staticmethod + def pack(value: "Int8TestMessage") -> "Packet": + ret = Packet() + + # test is of intrinsic type int8 + ret.encode8(value.test) + + # vlaTest is a custom VLA! + ret.encodeListShimmed(value.vlaTest, ret.encode8) + + # optTest is optional! it better not be a VLA too + ret.encodeOptionalShimmed(value.optTest, ret.encode8) + return ret + + @staticmethod + def unpack(packet: "Packet") -> "Int8TestMessage": + ret = Int8TestMessage() + + # test is of intrinsic type int8 + ret.test = packet.decode8() + + # vlaTest is a custom VLA! + ret.vlaTest = packet.decodeListShimmed(packet.decode8) + + # optTest is optional! it better not be a VLA too + ret.optTest = packet.decodeOptionalShimmed(packet.decode8) + + return ret + + +# Hack ourselves into the base class +Int8TestMessage.photonStruct = Int8TestMessageSerde() diff --git a/photon-lib/py/photonlibpy/generated/MultiTargetPNPResultSerde.py b/photon-lib/py/photonlibpy/generated/MultiTargetPNPResultSerde.py index 8a3e5ab415..70ee5de786 100644 --- a/photon-lib/py/photonlibpy/generated/MultiTargetPNPResultSerde.py +++ b/photon-lib/py/photonlibpy/generated/MultiTargetPNPResultSerde.py @@ -50,7 +50,7 @@ def pack(value: "MultiTargetPNPResult") -> "Packet": ret.encodeBytes(PnpResult.photonStruct.pack(value.estimatedPose).getData()) # fiducialIDsUsed is a custom VLA! - ret.encodeListShimmed(value.fiducialIDsUsed, ret.encodeShort) + ret.encodeListShimmed(value.fiducialIDsUsed, ret.encode16) return ret @staticmethod @@ -61,7 +61,7 @@ def unpack(packet: "Packet") -> "MultiTargetPNPResult": ret.estimatedPose = PnpResult.photonStruct.unpack(packet) # fiducialIDsUsed is a custom VLA! - ret.fiducialIDsUsed = packet.decodeListShimmed(packet.decodeShort) + ret.fiducialIDsUsed = packet.decodeListShimmed(packet.decode16) return ret diff --git a/photon-lib/py/photonlibpy/generated/Transform3dTestMessageSerde.py b/photon-lib/py/photonlibpy/generated/Transform3dTestMessageSerde.py new file mode 100644 index 0000000000..0aeaa5fc39 --- /dev/null +++ b/photon-lib/py/photonlibpy/generated/Transform3dTestMessageSerde.py @@ -0,0 +1,74 @@ +# +# MIT License +# +# Copyright (c) PhotonVision +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +############################################################################### +## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. +## --> DO NOT MODIFY <-- +############################################################################### + +from typing import TYPE_CHECKING + +from ..packet import Packet +from ..targeting import * # noqa + +if TYPE_CHECKING: + from ..targeting import Transform3dTestMessage # noqa + + +class Transform3dTestMessageSerde: + # Message definition md5sum. See photon_packet.adoc for details + MESSAGE_VERSION = "37188f532d61c3b549080489012b4d07" + MESSAGE_FORMAT = "Transform3d test;Transform3d vlaTest[?];optional Transform3d optTest;" + + @staticmethod + def pack(value: "Transform3dTestMessage") -> "Packet": + ret = Packet() + + # test is of shimmed type Transform3d + ret.encodeTransform(value.test) + + # vlaTest is a custom VLA! + ret.encodeListShimmed(value.vlaTest, ret.encodeTransform) + + # optTest is optional! it better not be a VLA too + ret.encodeOptionalShimmed(value.optTest, ret.encodeTransform) + return ret + + @staticmethod + def unpack(packet: "Packet") -> "Transform3dTestMessage": + ret = Transform3dTestMessage() + + ret.test = packet.decodeTransform() + + # vlaTest is a custom VLA! + ret.vlaTest = packet.decodeListShimmed(packet.decodeTransform) + + # optTest is optional! it better not be a VLA too + ret.optTest = packet.decodeOptionalShimmed(packet.decodeTransform) + + return ret + + +# Hack ourselves into the base class +Transform3dTestMessage.photonStruct = Transform3dTestMessageSerde() diff --git a/photon-lib/py/photonlibpy/packet.py b/photon-lib/py/photonlibpy/packet.py index e7f39fc887..edfe1d6b73 100644 --- a/photon-lib/py/photonlibpy/packet.py +++ b/photon-lib/py/photonlibpy/packet.py @@ -269,22 +269,6 @@ def encodeBoolean(self, value: bool): """ self.encode8(1 if value else 0) - def encodeDoubleArray(self, values: list[float]): - """ - Encodes an array of doubles and appends it to the packet. - """ - self.encode8(len(values)) - for value in values: - self.encodeDouble(value) - - def encodeShortList(self, values: list[int]): - """ - Encodes a list of shorts, with length prefixed as a single byte. - """ - self.encode8(len(values)) - for value in values: - self.encode16(value) - def encodeTransform(self, transform: Transform3d): """ Encodes a Transform3d (translation and rotation) and appends it to the packet. diff --git a/photon-lib/py/photonlibpy/targeting/testMessages.py b/photon-lib/py/photonlibpy/targeting/testMessages.py new file mode 100644 index 0000000000..e8c77e739c --- /dev/null +++ b/photon-lib/py/photonlibpy/targeting/testMessages.py @@ -0,0 +1,55 @@ +from dataclasses import dataclass, field + +from typing import Optional + +from wpimath.geometry import Transform3d + +# TODO: Autogenerate python test classes? + +@dataclass +class Int8TestMessage: + test: int + vlaTest: list[int] + optTest: Optional[int] + +@dataclass +class Int16TestMessage: + test: int + vlaTest: list[int] + optTest: Optional[int] + +@dataclass +class Int32TestMessage: + test: int + vlaTest: list[int] + optTest: Optional[int] + +@dataclass +class Int64TestMessage: + test: int + vlaTest: list[int] + optTest: Optional[int] + +@dataclass +class Float32TestMessage: + test: float + vlaTest: list[float] + optTest: Optional[float] + +@dataclass +class Float64TestMessage: + test: float + vlaTest: list[float] + optTest: Optional[float] + +@dataclass +class BoolTestMessage: + test: bool + vlaTest: list[bool] + optTest: Optional[bool] + +@dataclass +class Transform3dTestMessage: + test: Transform3d + vlaTest: list[Transform3d] + optTest: Optional[Transform3d] \ No newline at end of file diff --git a/photon-serde/generate_messages.py b/photon-serde/generate_messages.py index 8013b0f120..ff1ef3e8a9 100644 --- a/photon-serde/generate_messages.py +++ b/photon-serde/generate_messages.py @@ -39,6 +39,8 @@ class SerdeField(TypedDict): class MessageType(TypedDict): name: str fields: List[SerdeField] + # whether or not this is a test message type. If yes, test classes will be autogenerated alongside the ser/de code + test: bool # will be 'shim' if shimmed, and the shims will be set shimmed: bool java_decode_shim: str @@ -268,6 +270,9 @@ def generate_photon_messages(cpp_java_root, py_root, template_root): java_output_dir = Path(cpp_java_root) / "main/java/org/photonvision/struct" java_output_dir.mkdir(parents=True, exist_ok=True) + java_test_class_output_dir = Path(cpp_java_root) / "main/java/org/photonvision/targeting" + java_test_class_output_dir.mkdir(parents=True, exist_ok=True) + cpp_serde_header_dir = Path(cpp_java_root) / "main/native/include/photon/serde/" cpp_serde_header_dir.mkdir(parents=True, exist_ok=True) cpp_serde_source_dir = Path(cpp_java_root) / "main/native/cpp/photon/serde/" @@ -276,6 +281,9 @@ def generate_photon_messages(cpp_java_root, py_root, template_root): cpp_struct_header_dir = Path(cpp_java_root) / "main/native/include/photon/struct/" cpp_struct_header_dir.mkdir(parents=True, exist_ok=True) + cpp_test_struct_output_dir = Path(cpp_java_root) / "main/native/include/photon/targeting/" + cpp_test_struct_output_dir.mkdir(parents=True, exist_ok=True) + py_serde_source_dir = Path(py_root) py_serde_source_dir.mkdir(parents=True, exist_ok=True) @@ -352,6 +360,58 @@ def generate_photon_messages(cpp_java_root, py_root, template_root): ), encoding="utf-8", ) + + if 'test' in message.keys() and message['test']: + java_test_class_name = f"{message['name']}.java" + java_test_class_template = env.get_template("ThingTestClass.java.jinja") + + cpp_test_struct_name = f"{message['name']}.h" + cpp_test_struct_template = env.get_template("ThingTestStruct.h.jinja") + for output_name, template, output_folder in [ + [java_test_class_name, java_test_class_template, java_test_class_output_dir], + [cpp_test_struct_name, cpp_test_struct_template, cpp_test_struct_output_dir] + ]: + # Hack in our message getter + template.globals["get_message_by_name"] = lambda name: get_message_by_name( + messages, name + ) + + # TODO: Are the nested types really necessary for ts? + nested_photon_types = set( + [ + field["type"] + for field in message["fields"] + if ( + not is_intrinsic_type(field["type"]) + and not get_shimmed_filter(messages)(field["type"]) + ) + ] + ) + nested_wpilib_types = set( + [ + field["type"] + for field in message["fields"] + if ( + not is_intrinsic_type(field["type"]) + and get_shimmed_filter(messages)(field["type"]) + ) + ] + ) + + output_file = output_folder / output_name + output_file.write_text( + template.render( + message, + type_map=extended_data_types, + message_fmt=get_struct_schema_str(message, messages), + message_hash=message_hash, + cpp_includes=get_includes(messages, message), + nested_photon_types=nested_photon_types, + nested_wpilib_types=nested_wpilib_types, + ), + encoding="utf-8", + ) + def main(argv): diff --git a/photon-serde/message_data_types.yaml b/photon-serde/message_data_types.yaml index d8ed574873..b0ea42327b 100644 --- a/photon-serde/message_data_types.yaml +++ b/photon-serde/message_data_types.yaml @@ -2,7 +2,8 @@ bool: # length in bytes len: 1 - java_type: bool + java_type: boolean + java_boxed_type: Boolean cpp_type: bool java_decode_method: decodeBoolean java_optional_decode_method: decodeBooleanOptional @@ -12,9 +13,23 @@ bool: java_list_encode_method: encodeBooleanList python_decode_shim: decodeBoolean python_encode_shim: encodeBoolean +int8: + len: 1 + java_type: byte + java_boxed_type: Byte + cpp_type: int8_t + java_decode_method: decodeByte + java_optional_decode_method: decodeByteOptional + java_list_decode_method: decodeByteList + java_encode_method: encodeByte + java_optional_encode_method: encodeByteOptional + java_list_encode_method: encodeByteList + python_decode_shim: decode8 + python_encode_shim: encode8 int16: len: 2 java_type: short + java_boxed_type: Short cpp_type: int16_t java_decode_method: decodeShort java_optional_decode_method: decodeShortOptional @@ -22,11 +37,12 @@ int16: java_encode_method: encodeShort java_optional_encode_method: encodeShortOptional java_list_encode_method: encodeShortList - python_decode_shim: decodeShort - python_encode_shim: encodeShort + python_decode_shim: decode16 + python_encode_shim: encode16 int32: len: 4 java_type: int + java_boxed_type: Integer cpp_type: int32_t java_decode_method: decodeInt java_optional_decode_method: decodeIntOptional @@ -39,6 +55,7 @@ int32: int64: len: 8 java_type: long + java_boxed_type: Long cpp_type: int64_t java_decode_method: decodeLong java_optional_decode_method: decodeLongOptional @@ -51,6 +68,7 @@ int64: float32: len: 4 java_type: float + java_boxed_type: Float cpp_type: float java_decode_method: decodeFloat java_optional_decode_method: decodeFloatOptional @@ -63,6 +81,7 @@ float32: float64: len: 8 java_type: double + java_boxed_type: Double cpp_type: double java_decode_method: decodeDouble java_optional_decode_method: decodeDoubleOptional diff --git a/photon-serde/messages.yaml b/photon-serde/messages.yaml index 88eebc5b98..7fd1f47116 100644 --- a/photon-serde/messages.yaml +++ b/photon-serde/messages.yaml @@ -92,3 +92,101 @@ - name: multitagResult type: MultiTargetPNPResult optional: True + +# Messages for ser/de unit tests, not actually used in dataflow +- name: Int8TestMessage + test: True + fields: + - name: test + type: int8 + - name: vlaTest + type: int8 + vla: True + - name: optTest + type: int8 + optional: True + +- name: Int16TestMessage + test: True + fields: + - name: test + type: int16 + - name: vlaTest + type: int16 + vla: True + - name: optTest + type: int16 + optional: True + +- name: Int32TestMessage + test: True + fields: + - name: test + type: int32 + - name: vlaTest + type: int32 + vla: True + - name: optTest + type: int32 + optional: True + +- name: Int64TestMessage + test: True + fields: + - name: test + type: int64 + - name: vlaTest + type: int64 + vla: True + - name: optTest + type: int64 + optional: True + +- name: Float32TestMessage + test: True + fields: + - name: test + type: float32 + - name: vlaTest + type: float32 + vla: True + - name: optTest + type: float32 + optional: True + +- name: Float64TestMessage + test: True + fields: + - name: test + type: float64 + - name: vlaTest + type: float64 + vla: True + - name: optTest + type: float64 + optional: True + +- name: BoolTestMessage + test: True + fields: + - name: test + type: bool + - name: vlaTest + type: bool + vla: True + - name: optTest + type: bool + optional: True + +# Test for shimmed ser/de +- name: Transform3dTestMessage + test: True + fields: + - name: test + type: Transform3d + - name: vlaTest + type: Transform3d + vla: True + - name: optTest + type: Transform3d + optional: True \ No newline at end of file diff --git a/photon-serde/templates/Message.java.jinja b/photon-serde/templates/Message.java.jinja index 8ac978128c..6bd3aae1d8 100644 --- a/photon-serde/templates/Message.java.jinja +++ b/photon-serde/templates/Message.java.jinja @@ -84,7 +84,7 @@ public class {{ name }}Serde implements PacketSerde<{{name}}> { {%- elif field.type | is_intrinsic %} {%- if field.optional == True %} // {{ field.name }} is optional! it better not be a VLA too - packet.{{ type_map[field.type].java_optipnal_encode_method }}(value.{{ field.name }}); + packet.{{ type_map[field.type].java_optional_encode_method }}(value.{{ field.name }}); {%- elif field.vla == True %} // {{ field.name }} is a custom VLA! packet.{{ type_map[field.type].java_list_encode_method }}(value.{{ field.name }}); diff --git a/photon-serde/templates/ThingTestClass.java.jinja b/photon-serde/templates/ThingTestClass.java.jinja new file mode 100644 index 0000000000..ab89df597a --- /dev/null +++ b/photon-serde/templates/ThingTestClass.java.jinja @@ -0,0 +1,74 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.targeting; + +import java.util.List; +import java.util.Optional; + +import org.photonvision.struct.{{ name }}Serde; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.targeting.serde.PhotonStructSerializable; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; +{% for type in nested_wpilib_types -%} +import {{ get_message_by_name(type).java_import }}; +{%- if not loop.last %},{% endif -%} +{%- endfor%} + +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +public class {{ name }} implements PhotonStructSerializable<{{ name }}> { +{% for field in fields -%} +{%- if field.type | is_intrinsic %} + {%- if field.optional == True %} + public Optional<{{ type_map[field.type].java_boxed_type }}> {{ field.name }}; + {%- elif field.vla == True %} + public List<{{ type_map[field.type].java_boxed_type }}> {{ field.name }}; + {%- else %} + public {{ type_map[field.type].java_type }} {{ field.name }}; + {%- endif %} +{%- else %} + {%- if field.optional == True %} + public Optional<{{ field.type }}> {{ field.name }}; + {%- elif field.vla == True %} + public List<{{ field.type }}> {{ field.name }}; + {%- else %} + public {{ field.type }} {{ field.name }}; + {%- endif %} +{%- endif %} +{% endfor%} + + /** {{ name }} PhotonStruct for serialization. */ + public static final {{ name }}Serde photonStruct = new {{ name }}Serde(); + + @Override + public PacketSerde<{{ name }}> getSerde() { + return photonStruct; + } +} \ No newline at end of file diff --git a/photon-serde/templates/ThingTestStruct.h.jinja b/photon-serde/templates/ThingTestStruct.h.jinja new file mode 100644 index 0000000000..8c200c9d9f --- /dev/null +++ b/photon-serde/templates/ThingTestStruct.h.jinja @@ -0,0 +1,51 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/struct/{{ name }}Struct.h" + +namespace photon { +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +class {{ name }} : public {{ name }}_PhotonStruct { + using Base = {{ name }}_PhotonStruct; + +public: + {{ name }}() = default; + + explicit {{ name }}(Base&& data) : Base(data) {} + + template + explicit {{ name }}(Args&&... args) + : Base{std::forward(args)...} {} + + friend bool operator==({{ name }} const&, {{ name }} const&) = default; +}; +} // namespace photon + +#include "photon/serde/{{ name }}Serde.h" \ No newline at end of file diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/BoolTestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/BoolTestMessageSerde.java new file mode 100644 index 0000000000..fa788b7724 --- /dev/null +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/BoolTestMessageSerde.java @@ -0,0 +1,103 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.struct; + +import org.photonvision.common.dataflow.structures.Packet; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.utils.PacketUtils; + +// Assume that the base class lives here and we can import it +import org.photonvision.targeting.*; + +// Needed for optional shims +import java.util.function.BiConsumer; +import java.util.function.Function; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated serialization/deserialization helper for BoolTestMessage + */ +public class BoolTestMessageSerde implements PacketSerde { + + @Override + public final String getInterfaceUUID() { return "c8efe94a9c0d815658c74de6f672939c"; } + @Override + public final String getSchema() { return "bool test;bool vlaTest[?];optional bool optTest;"; } + @Override + public final String getTypeName() { return "BoolTestMessage"; } + + @Override + public int getMaxByteSize() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); + } + + @Override + public void pack(Packet packet, BoolTestMessage value) { + // field test is of intrinsic type bool + packet.encodeBoolean(value.test); + + // vlaTest is a custom VLA! + packet.encodeBooleanList(value.vlaTest); + + // optTest is optional! it better not be a VLA too + packet.encodeBooleanOptional(value.optTest); + } + + @Override + public BoolTestMessage unpack(Packet packet) { + var ret = new BoolTestMessage(); + + // test is of intrinsic type bool + ret.test = packet.decodeBoolean(); + + // vlaTest is a custom VLA! + ret.vlaTest = packet.decodeBooleanList(); + + // optTest is optional! it better not be a VLA too + ret.optTest = packet.decodeBooleanOptional(); + + return ret; + } + + @Override + public PacketSerde[] getNestedPhotonMessages() { + return new PacketSerde[] { + + }; + } + + @Override + public Struct[] getNestedWpilibMessages() { + return new Struct[] { + + }; + } +} diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/Float32TestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/Float32TestMessageSerde.java new file mode 100644 index 0000000000..f1ca1d9900 --- /dev/null +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/Float32TestMessageSerde.java @@ -0,0 +1,103 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.struct; + +import org.photonvision.common.dataflow.structures.Packet; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.utils.PacketUtils; + +// Assume that the base class lives here and we can import it +import org.photonvision.targeting.*; + +// Needed for optional shims +import java.util.function.BiConsumer; +import java.util.function.Function; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated serialization/deserialization helper for Float32TestMessage + */ +public class Float32TestMessageSerde implements PacketSerde { + + @Override + public final String getInterfaceUUID() { return "9fd9ed51ec69d6738ee24af43b2b9c7e"; } + @Override + public final String getSchema() { return "float32 test;float32 vlaTest[?];optional float32 optTest;"; } + @Override + public final String getTypeName() { return "Float32TestMessage"; } + + @Override + public int getMaxByteSize() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); + } + + @Override + public void pack(Packet packet, Float32TestMessage value) { + // field test is of intrinsic type float32 + packet.encodeFloat(value.test); + + // vlaTest is a custom VLA! + packet.encodeFloatList(value.vlaTest); + + // optTest is optional! it better not be a VLA too + packet.encodeFloatOptional(value.optTest); + } + + @Override + public Float32TestMessage unpack(Packet packet) { + var ret = new Float32TestMessage(); + + // test is of intrinsic type float32 + ret.test = packet.decodeFloat(); + + // vlaTest is a custom VLA! + ret.vlaTest = packet.decodeFloatList(); + + // optTest is optional! it better not be a VLA too + ret.optTest = packet.decodeFloatOptional(); + + return ret; + } + + @Override + public PacketSerde[] getNestedPhotonMessages() { + return new PacketSerde[] { + + }; + } + + @Override + public Struct[] getNestedWpilibMessages() { + return new Struct[] { + + }; + } +} diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/Float64TestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/Float64TestMessageSerde.java new file mode 100644 index 0000000000..f1795625cd --- /dev/null +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/Float64TestMessageSerde.java @@ -0,0 +1,103 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.struct; + +import org.photonvision.common.dataflow.structures.Packet; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.utils.PacketUtils; + +// Assume that the base class lives here and we can import it +import org.photonvision.targeting.*; + +// Needed for optional shims +import java.util.function.BiConsumer; +import java.util.function.Function; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated serialization/deserialization helper for Float64TestMessage + */ +public class Float64TestMessageSerde implements PacketSerde { + + @Override + public final String getInterfaceUUID() { return "bc96c1f7d9db9371269d0e4f4d4b4cb2"; } + @Override + public final String getSchema() { return "float64 test;float64 vlaTest[?];optional float64 optTest;"; } + @Override + public final String getTypeName() { return "Float64TestMessage"; } + + @Override + public int getMaxByteSize() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); + } + + @Override + public void pack(Packet packet, Float64TestMessage value) { + // field test is of intrinsic type float64 + packet.encodeDouble(value.test); + + // vlaTest is a custom VLA! + packet.encodeDoubleList(value.vlaTest); + + // optTest is optional! it better not be a VLA too + packet.encodeDoubleOptional(value.optTest); + } + + @Override + public Float64TestMessage unpack(Packet packet) { + var ret = new Float64TestMessage(); + + // test is of intrinsic type float64 + ret.test = packet.decodeDouble(); + + // vlaTest is a custom VLA! + ret.vlaTest = packet.decodeDoubleList(); + + // optTest is optional! it better not be a VLA too + ret.optTest = packet.decodeDoubleOptional(); + + return ret; + } + + @Override + public PacketSerde[] getNestedPhotonMessages() { + return new PacketSerde[] { + + }; + } + + @Override + public Struct[] getNestedWpilibMessages() { + return new Struct[] { + + }; + } +} diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/Int16TestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/Int16TestMessageSerde.java new file mode 100644 index 0000000000..5ca7d921af --- /dev/null +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/Int16TestMessageSerde.java @@ -0,0 +1,103 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.struct; + +import org.photonvision.common.dataflow.structures.Packet; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.utils.PacketUtils; + +// Assume that the base class lives here and we can import it +import org.photonvision.targeting.*; + +// Needed for optional shims +import java.util.function.BiConsumer; +import java.util.function.Function; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated serialization/deserialization helper for Int16TestMessage + */ +public class Int16TestMessageSerde implements PacketSerde { + + @Override + public final String getInterfaceUUID() { return "23e6ccab160b942600aae8e94a72778a"; } + @Override + public final String getSchema() { return "int16 test;int16 vlaTest[?];optional int16 optTest;"; } + @Override + public final String getTypeName() { return "Int16TestMessage"; } + + @Override + public int getMaxByteSize() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); + } + + @Override + public void pack(Packet packet, Int16TestMessage value) { + // field test is of intrinsic type int16 + packet.encodeShort(value.test); + + // vlaTest is a custom VLA! + packet.encodeShortList(value.vlaTest); + + // optTest is optional! it better not be a VLA too + packet.encodeShortOptional(value.optTest); + } + + @Override + public Int16TestMessage unpack(Packet packet) { + var ret = new Int16TestMessage(); + + // test is of intrinsic type int16 + ret.test = packet.decodeShort(); + + // vlaTest is a custom VLA! + ret.vlaTest = packet.decodeShortList(); + + // optTest is optional! it better not be a VLA too + ret.optTest = packet.decodeShortOptional(); + + return ret; + } + + @Override + public PacketSerde[] getNestedPhotonMessages() { + return new PacketSerde[] { + + }; + } + + @Override + public Struct[] getNestedWpilibMessages() { + return new Struct[] { + + }; + } +} diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/Int32TestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/Int32TestMessageSerde.java new file mode 100644 index 0000000000..1fca3ff773 --- /dev/null +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/Int32TestMessageSerde.java @@ -0,0 +1,103 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.struct; + +import org.photonvision.common.dataflow.structures.Packet; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.utils.PacketUtils; + +// Assume that the base class lives here and we can import it +import org.photonvision.targeting.*; + +// Needed for optional shims +import java.util.function.BiConsumer; +import java.util.function.Function; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated serialization/deserialization helper for Int32TestMessage + */ +public class Int32TestMessageSerde implements PacketSerde { + + @Override + public final String getInterfaceUUID() { return "d8596149c4701e7b8912df238cd4ec66"; } + @Override + public final String getSchema() { return "int32 test;int32 vlaTest[?];optional int32 optTest;"; } + @Override + public final String getTypeName() { return "Int32TestMessage"; } + + @Override + public int getMaxByteSize() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); + } + + @Override + public void pack(Packet packet, Int32TestMessage value) { + // field test is of intrinsic type int32 + packet.encodeInt(value.test); + + // vlaTest is a custom VLA! + packet.encodeIntList(value.vlaTest); + + // optTest is optional! it better not be a VLA too + packet.encodeIntOptional(value.optTest); + } + + @Override + public Int32TestMessage unpack(Packet packet) { + var ret = new Int32TestMessage(); + + // test is of intrinsic type int32 + ret.test = packet.decodeInt(); + + // vlaTest is a custom VLA! + ret.vlaTest = packet.decodeIntList(); + + // optTest is optional! it better not be a VLA too + ret.optTest = packet.decodeIntOptional(); + + return ret; + } + + @Override + public PacketSerde[] getNestedPhotonMessages() { + return new PacketSerde[] { + + }; + } + + @Override + public Struct[] getNestedWpilibMessages() { + return new Struct[] { + + }; + } +} diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/Int64TestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/Int64TestMessageSerde.java new file mode 100644 index 0000000000..d98fcb8683 --- /dev/null +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/Int64TestMessageSerde.java @@ -0,0 +1,103 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.struct; + +import org.photonvision.common.dataflow.structures.Packet; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.utils.PacketUtils; + +// Assume that the base class lives here and we can import it +import org.photonvision.targeting.*; + +// Needed for optional shims +import java.util.function.BiConsumer; +import java.util.function.Function; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated serialization/deserialization helper for Int64TestMessage + */ +public class Int64TestMessageSerde implements PacketSerde { + + @Override + public final String getInterfaceUUID() { return "dd2e470b4d07bbcd208906c26a2ae37a"; } + @Override + public final String getSchema() { return "int64 test;int64 vlaTest[?];optional int64 optTest;"; } + @Override + public final String getTypeName() { return "Int64TestMessage"; } + + @Override + public int getMaxByteSize() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); + } + + @Override + public void pack(Packet packet, Int64TestMessage value) { + // field test is of intrinsic type int64 + packet.encodeLong(value.test); + + // vlaTest is a custom VLA! + packet.encodeLongList(value.vlaTest); + + // optTest is optional! it better not be a VLA too + packet.encodeLongOptional(value.optTest); + } + + @Override + public Int64TestMessage unpack(Packet packet) { + var ret = new Int64TestMessage(); + + // test is of intrinsic type int64 + ret.test = packet.decodeLong(); + + // vlaTest is a custom VLA! + ret.vlaTest = packet.decodeLongList(); + + // optTest is optional! it better not be a VLA too + ret.optTest = packet.decodeLongOptional(); + + return ret; + } + + @Override + public PacketSerde[] getNestedPhotonMessages() { + return new PacketSerde[] { + + }; + } + + @Override + public Struct[] getNestedWpilibMessages() { + return new Struct[] { + + }; + } +} diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/Int8TestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/Int8TestMessageSerde.java new file mode 100644 index 0000000000..eadf7560e6 --- /dev/null +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/Int8TestMessageSerde.java @@ -0,0 +1,103 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.struct; + +import org.photonvision.common.dataflow.structures.Packet; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.utils.PacketUtils; + +// Assume that the base class lives here and we can import it +import org.photonvision.targeting.*; + +// Needed for optional shims +import java.util.function.BiConsumer; +import java.util.function.Function; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated serialization/deserialization helper for Int8TestMessage + */ +public class Int8TestMessageSerde implements PacketSerde { + + @Override + public final String getInterfaceUUID() { return "76297a79f30e4d995b8f95c5fa6297fa"; } + @Override + public final String getSchema() { return "int8 test;int8 vlaTest[?];optional int8 optTest;"; } + @Override + public final String getTypeName() { return "Int8TestMessage"; } + + @Override + public int getMaxByteSize() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); + } + + @Override + public void pack(Packet packet, Int8TestMessage value) { + // field test is of intrinsic type int8 + packet.encodeByte(value.test); + + // vlaTest is a custom VLA! + packet.encodeByteList(value.vlaTest); + + // optTest is optional! it better not be a VLA too + packet.encodeByteOptional(value.optTest); + } + + @Override + public Int8TestMessage unpack(Packet packet) { + var ret = new Int8TestMessage(); + + // test is of intrinsic type int8 + ret.test = packet.decodeByte(); + + // vlaTest is a custom VLA! + ret.vlaTest = packet.decodeByteList(); + + // optTest is optional! it better not be a VLA too + ret.optTest = packet.decodeByteOptional(); + + return ret; + } + + @Override + public PacketSerde[] getNestedPhotonMessages() { + return new PacketSerde[] { + + }; + } + + @Override + public Struct[] getNestedWpilibMessages() { + return new Struct[] { + + }; + } +} diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/Transform3dTestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/Transform3dTestMessageSerde.java new file mode 100644 index 0000000000..5d1d7696d5 --- /dev/null +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/Transform3dTestMessageSerde.java @@ -0,0 +1,112 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.struct; + +import org.photonvision.common.dataflow.structures.Packet; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.utils.PacketUtils; + +// Assume that the base class lives here and we can import it +import org.photonvision.targeting.*; + +// Needed for optional shims +import java.util.function.BiConsumer; +import java.util.function.Function; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; +import org.wpilib.math.geometry.Transform3d; + +/** + * Auto-generated serialization/deserialization helper for Transform3dTestMessage + */ +public class Transform3dTestMessageSerde implements PacketSerde { + + @Override + public final String getInterfaceUUID() { return "37188f532d61c3b549080489012b4d07"; } + @Override + public final String getSchema() { return "Transform3d test;Transform3d vlaTest[?];optional Transform3d optTest;"; } + @Override + public final String getTypeName() { return "Transform3dTestMessage"; } + + @Override + public int getMaxByteSize() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); + } + + private static BiConsumer test_PSINTERNALencode_shim_callable = (packet, value) -> PacketUtils.packTransform3d(packet, value); + private static Function test_PSINTERNALdecode_shim_callable = (packet) -> PacketUtils.unpackTransform3d(packet); + + private static BiConsumer vlaTest_PSINTERNALencode_shim_callable = (packet, value) -> PacketUtils.packTransform3d(packet, value); + private static Function vlaTest_PSINTERNALdecode_shim_callable = (packet) -> PacketUtils.unpackTransform3d(packet); + + private static BiConsumer optTest_PSINTERNALencode_shim_callable = (packet, value) -> PacketUtils.packTransform3d(packet, value); + private static Function optTest_PSINTERNALdecode_shim_callable = (packet) -> PacketUtils.unpackTransform3d(packet); + + @Override + public void pack(Packet packet, Transform3dTestMessage value) { + // test is of shimmed type Transform3d + PacketUtils.packTransform3d(packet, value.test); + + // vlaTest is a custom VLA! + PacketUtils.packList(packet, value.vlaTest, vlaTest_PSINTERNALencode_shim_callable); + + // optTest is optional! it better not be a VLA too + PacketUtils.packOptional(packet, value.optTest, optTest_PSINTERNALencode_shim_callable); + } + + @Override + public Transform3dTestMessage unpack(Packet packet) { + var ret = new Transform3dTestMessage(); + + // test is of shimmed type Transform3d + ret.test = PacketUtils.unpackTransform3d(packet); + + // vlaTest is a custom VLA! + ret.vlaTest = PacketUtils.unpackList(packet, vlaTest_PSINTERNALdecode_shim_callable); + + // optTest is optional! it better not be a VLA too + ret.optTest = PacketUtils.unpackOptional(packet, optTest_PSINTERNALdecode_shim_callable); + + return ret; + } + + @Override + public PacketSerde[] getNestedPhotonMessages() { + return new PacketSerde[] { + + }; + } + + @Override + public Struct[] getNestedWpilibMessages() { + return new Struct[] { + Transform3d.struct + }; + } +} diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/BoolTestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/BoolTestMessage.java new file mode 100644 index 0000000000..58bd1814ad --- /dev/null +++ b/photon-targeting/src/generated/main/java/org/photonvision/targeting/BoolTestMessage.java @@ -0,0 +1,59 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.targeting; + +import java.util.List; +import java.util.Optional; + +import org.photonvision.struct.BoolTestMessageSerde; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.targeting.serde.PhotonStructSerializable; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +public class BoolTestMessage implements PhotonStructSerializable { + + public boolean test; + + public List vlaTest; + + public Optional optTest; + + + /** BoolTestMessage PhotonStruct for serialization. */ + public static final BoolTestMessageSerde photonStruct = new BoolTestMessageSerde(); + + @Override + public PacketSerde getSerde() { + return photonStruct; + } +} \ No newline at end of file diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float32TestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float32TestMessage.java new file mode 100644 index 0000000000..9cb263afa4 --- /dev/null +++ b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float32TestMessage.java @@ -0,0 +1,59 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.targeting; + +import java.util.List; +import java.util.Optional; + +import org.photonvision.struct.Float32TestMessageSerde; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.targeting.serde.PhotonStructSerializable; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +public class Float32TestMessage implements PhotonStructSerializable { + + public float test; + + public List vlaTest; + + public Optional optTest; + + + /** Float32TestMessage PhotonStruct for serialization. */ + public static final Float32TestMessageSerde photonStruct = new Float32TestMessageSerde(); + + @Override + public PacketSerde getSerde() { + return photonStruct; + } +} \ No newline at end of file diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float64TestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float64TestMessage.java new file mode 100644 index 0000000000..af4975c191 --- /dev/null +++ b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float64TestMessage.java @@ -0,0 +1,59 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.targeting; + +import java.util.List; +import java.util.Optional; + +import org.photonvision.struct.Float64TestMessageSerde; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.targeting.serde.PhotonStructSerializable; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +public class Float64TestMessage implements PhotonStructSerializable { + + public double test; + + public List vlaTest; + + public Optional optTest; + + + /** Float64TestMessage PhotonStruct for serialization. */ + public static final Float64TestMessageSerde photonStruct = new Float64TestMessageSerde(); + + @Override + public PacketSerde getSerde() { + return photonStruct; + } +} \ No newline at end of file diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int16TestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int16TestMessage.java new file mode 100644 index 0000000000..72c6e00df1 --- /dev/null +++ b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int16TestMessage.java @@ -0,0 +1,59 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.targeting; + +import java.util.List; +import java.util.Optional; + +import org.photonvision.struct.Int16TestMessageSerde; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.targeting.serde.PhotonStructSerializable; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +public class Int16TestMessage implements PhotonStructSerializable { + + public short test; + + public List vlaTest; + + public Optional optTest; + + + /** Int16TestMessage PhotonStruct for serialization. */ + public static final Int16TestMessageSerde photonStruct = new Int16TestMessageSerde(); + + @Override + public PacketSerde getSerde() { + return photonStruct; + } +} \ No newline at end of file diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int32TestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int32TestMessage.java new file mode 100644 index 0000000000..3caf4a7255 --- /dev/null +++ b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int32TestMessage.java @@ -0,0 +1,59 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.targeting; + +import java.util.List; +import java.util.Optional; + +import org.photonvision.struct.Int32TestMessageSerde; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.targeting.serde.PhotonStructSerializable; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +public class Int32TestMessage implements PhotonStructSerializable { + + public int test; + + public List vlaTest; + + public Optional optTest; + + + /** Int32TestMessage PhotonStruct for serialization. */ + public static final Int32TestMessageSerde photonStruct = new Int32TestMessageSerde(); + + @Override + public PacketSerde getSerde() { + return photonStruct; + } +} \ No newline at end of file diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int64TestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int64TestMessage.java new file mode 100644 index 0000000000..8ecd2808d7 --- /dev/null +++ b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int64TestMessage.java @@ -0,0 +1,59 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.targeting; + +import java.util.List; +import java.util.Optional; + +import org.photonvision.struct.Int64TestMessageSerde; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.targeting.serde.PhotonStructSerializable; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +public class Int64TestMessage implements PhotonStructSerializable { + + public long test; + + public List vlaTest; + + public Optional optTest; + + + /** Int64TestMessage PhotonStruct for serialization. */ + public static final Int64TestMessageSerde photonStruct = new Int64TestMessageSerde(); + + @Override + public PacketSerde getSerde() { + return photonStruct; + } +} \ No newline at end of file diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int8TestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int8TestMessage.java new file mode 100644 index 0000000000..4c723075ba --- /dev/null +++ b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int8TestMessage.java @@ -0,0 +1,59 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.targeting; + +import java.util.List; +import java.util.Optional; + +import org.photonvision.struct.Int8TestMessageSerde; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.targeting.serde.PhotonStructSerializable; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +public class Int8TestMessage implements PhotonStructSerializable { + + public byte test; + + public List vlaTest; + + public Optional optTest; + + + /** Int8TestMessage PhotonStruct for serialization. */ + public static final Int8TestMessageSerde photonStruct = new Int8TestMessageSerde(); + + @Override + public PacketSerde getSerde() { + return photonStruct; + } +} \ No newline at end of file diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Transform3dTestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Transform3dTestMessage.java new file mode 100644 index 0000000000..7356cb28a4 --- /dev/null +++ b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Transform3dTestMessage.java @@ -0,0 +1,59 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.targeting; + +import java.util.List; +import java.util.Optional; + +import org.photonvision.struct.Transform3dTestMessageSerde; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.targeting.serde.PhotonStructSerializable; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; +import org.wpilib.math.geometry.Transform3d; + +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +public class Transform3dTestMessage implements PhotonStructSerializable { + + public Transform3d test; + + public List vlaTest; + + public Optional optTest; + + + /** Transform3dTestMessage PhotonStruct for serialization. */ + public static final Transform3dTestMessageSerde photonStruct = new Transform3dTestMessageSerde(); + + @Override + public PacketSerde getSerde() { + return photonStruct; + } +} \ No newline at end of file diff --git a/photon-targeting/src/generated/main/native/cpp/photon/serde/BoolTestMessageSerde.cpp b/photon-targeting/src/generated/main/native/cpp/photon/serde/BoolTestMessageSerde.cpp new file mode 100644 index 0000000000..da87d5ae5d --- /dev/null +++ b/photon-targeting/src/generated/main/native/cpp/photon/serde/BoolTestMessageSerde.cpp @@ -0,0 +1,47 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/serde/BoolTestMessageSerde.h" + +namespace photon { + +using StructType = SerdeType; + +void StructType::Pack(Packet& packet, const BoolTestMessage& value) { + packet.Pack(value.test); + packet.Pack>(value.vlaTest); + packet.Pack>(value.optTest); +} + +BoolTestMessage StructType::Unpack(Packet& packet) { + return BoolTestMessage{ BoolTestMessage_PhotonStruct{ + .test = packet.Unpack(), + .vlaTest = packet.Unpack>(), + .optTest = packet.Unpack>(), + }}; +} + +} // namespace photon diff --git a/photon-targeting/src/generated/main/native/cpp/photon/serde/Float32TestMessageSerde.cpp b/photon-targeting/src/generated/main/native/cpp/photon/serde/Float32TestMessageSerde.cpp new file mode 100644 index 0000000000..ece04ef963 --- /dev/null +++ b/photon-targeting/src/generated/main/native/cpp/photon/serde/Float32TestMessageSerde.cpp @@ -0,0 +1,47 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/serde/Float32TestMessageSerde.h" + +namespace photon { + +using StructType = SerdeType; + +void StructType::Pack(Packet& packet, const Float32TestMessage& value) { + packet.Pack(value.test); + packet.Pack>(value.vlaTest); + packet.Pack>(value.optTest); +} + +Float32TestMessage StructType::Unpack(Packet& packet) { + return Float32TestMessage{ Float32TestMessage_PhotonStruct{ + .test = packet.Unpack(), + .vlaTest = packet.Unpack>(), + .optTest = packet.Unpack>(), + }}; +} + +} // namespace photon diff --git a/photon-targeting/src/generated/main/native/cpp/photon/serde/Float64TestMessageSerde.cpp b/photon-targeting/src/generated/main/native/cpp/photon/serde/Float64TestMessageSerde.cpp new file mode 100644 index 0000000000..cd82f36ca5 --- /dev/null +++ b/photon-targeting/src/generated/main/native/cpp/photon/serde/Float64TestMessageSerde.cpp @@ -0,0 +1,47 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/serde/Float64TestMessageSerde.h" + +namespace photon { + +using StructType = SerdeType; + +void StructType::Pack(Packet& packet, const Float64TestMessage& value) { + packet.Pack(value.test); + packet.Pack>(value.vlaTest); + packet.Pack>(value.optTest); +} + +Float64TestMessage StructType::Unpack(Packet& packet) { + return Float64TestMessage{ Float64TestMessage_PhotonStruct{ + .test = packet.Unpack(), + .vlaTest = packet.Unpack>(), + .optTest = packet.Unpack>(), + }}; +} + +} // namespace photon diff --git a/photon-targeting/src/generated/main/native/cpp/photon/serde/Int16TestMessageSerde.cpp b/photon-targeting/src/generated/main/native/cpp/photon/serde/Int16TestMessageSerde.cpp new file mode 100644 index 0000000000..afb02107f1 --- /dev/null +++ b/photon-targeting/src/generated/main/native/cpp/photon/serde/Int16TestMessageSerde.cpp @@ -0,0 +1,47 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/serde/Int16TestMessageSerde.h" + +namespace photon { + +using StructType = SerdeType; + +void StructType::Pack(Packet& packet, const Int16TestMessage& value) { + packet.Pack(value.test); + packet.Pack>(value.vlaTest); + packet.Pack>(value.optTest); +} + +Int16TestMessage StructType::Unpack(Packet& packet) { + return Int16TestMessage{ Int16TestMessage_PhotonStruct{ + .test = packet.Unpack(), + .vlaTest = packet.Unpack>(), + .optTest = packet.Unpack>(), + }}; +} + +} // namespace photon diff --git a/photon-targeting/src/generated/main/native/cpp/photon/serde/Int32TestMessageSerde.cpp b/photon-targeting/src/generated/main/native/cpp/photon/serde/Int32TestMessageSerde.cpp new file mode 100644 index 0000000000..3f6a57d53d --- /dev/null +++ b/photon-targeting/src/generated/main/native/cpp/photon/serde/Int32TestMessageSerde.cpp @@ -0,0 +1,47 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/serde/Int32TestMessageSerde.h" + +namespace photon { + +using StructType = SerdeType; + +void StructType::Pack(Packet& packet, const Int32TestMessage& value) { + packet.Pack(value.test); + packet.Pack>(value.vlaTest); + packet.Pack>(value.optTest); +} + +Int32TestMessage StructType::Unpack(Packet& packet) { + return Int32TestMessage{ Int32TestMessage_PhotonStruct{ + .test = packet.Unpack(), + .vlaTest = packet.Unpack>(), + .optTest = packet.Unpack>(), + }}; +} + +} // namespace photon diff --git a/photon-targeting/src/generated/main/native/cpp/photon/serde/Int64TestMessageSerde.cpp b/photon-targeting/src/generated/main/native/cpp/photon/serde/Int64TestMessageSerde.cpp new file mode 100644 index 0000000000..b8b5c5711e --- /dev/null +++ b/photon-targeting/src/generated/main/native/cpp/photon/serde/Int64TestMessageSerde.cpp @@ -0,0 +1,47 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/serde/Int64TestMessageSerde.h" + +namespace photon { + +using StructType = SerdeType; + +void StructType::Pack(Packet& packet, const Int64TestMessage& value) { + packet.Pack(value.test); + packet.Pack>(value.vlaTest); + packet.Pack>(value.optTest); +} + +Int64TestMessage StructType::Unpack(Packet& packet) { + return Int64TestMessage{ Int64TestMessage_PhotonStruct{ + .test = packet.Unpack(), + .vlaTest = packet.Unpack>(), + .optTest = packet.Unpack>(), + }}; +} + +} // namespace photon diff --git a/photon-targeting/src/generated/main/native/cpp/photon/serde/Int8TestMessageSerde.cpp b/photon-targeting/src/generated/main/native/cpp/photon/serde/Int8TestMessageSerde.cpp new file mode 100644 index 0000000000..5209a43077 --- /dev/null +++ b/photon-targeting/src/generated/main/native/cpp/photon/serde/Int8TestMessageSerde.cpp @@ -0,0 +1,47 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/serde/Int8TestMessageSerde.h" + +namespace photon { + +using StructType = SerdeType; + +void StructType::Pack(Packet& packet, const Int8TestMessage& value) { + packet.Pack(value.test); + packet.Pack>(value.vlaTest); + packet.Pack>(value.optTest); +} + +Int8TestMessage StructType::Unpack(Packet& packet) { + return Int8TestMessage{ Int8TestMessage_PhotonStruct{ + .test = packet.Unpack(), + .vlaTest = packet.Unpack>(), + .optTest = packet.Unpack>(), + }}; +} + +} // namespace photon diff --git a/photon-targeting/src/generated/main/native/cpp/photon/serde/Transform3dTestMessageSerde.cpp b/photon-targeting/src/generated/main/native/cpp/photon/serde/Transform3dTestMessageSerde.cpp new file mode 100644 index 0000000000..aa5eb5418a --- /dev/null +++ b/photon-targeting/src/generated/main/native/cpp/photon/serde/Transform3dTestMessageSerde.cpp @@ -0,0 +1,47 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/serde/Transform3dTestMessageSerde.h" + +namespace photon { + +using StructType = SerdeType; + +void StructType::Pack(Packet& packet, const Transform3dTestMessage& value) { + packet.Pack(value.test); + packet.Pack>(value.vlaTest); + packet.Pack>(value.optTest); +} + +Transform3dTestMessage StructType::Unpack(Packet& packet) { + return Transform3dTestMessage{ Transform3dTestMessage_PhotonStruct{ + .test = packet.Unpack(), + .vlaTest = packet.Unpack>(), + .optTest = packet.Unpack>(), + }}; +} + +} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/serde/BoolTestMessageSerde.h b/photon-targeting/src/generated/main/native/include/photon/serde/BoolTestMessageSerde.h new file mode 100644 index 0000000000..a671323f45 --- /dev/null +++ b/photon-targeting/src/generated/main/native/include/photon/serde/BoolTestMessageSerde.h @@ -0,0 +1,59 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include + +// Include myself +#include "photon/dataflow/structures/Packet.h" +#include "photon/targeting/BoolTestMessage.h" + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +template <> +struct WPILIB_DLLEXPORT SerdeType { + static constexpr std::string_view GetSchemaHash() { + return "c8efe94a9c0d815658c74de6f672939c"; + } + + static constexpr std::string_view GetSchema() { + return "bool test;bool vlaTest[?];optional bool optTest;"; + } + + static photon::BoolTestMessage Unpack(photon::Packet& packet); + static void Pack(photon::Packet& packet, const photon::BoolTestMessage& value); +}; + +static_assert(photon::PhotonStructSerializable); + +} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/serde/Float32TestMessageSerde.h b/photon-targeting/src/generated/main/native/include/photon/serde/Float32TestMessageSerde.h new file mode 100644 index 0000000000..34d82a2ca3 --- /dev/null +++ b/photon-targeting/src/generated/main/native/include/photon/serde/Float32TestMessageSerde.h @@ -0,0 +1,59 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include + +// Include myself +#include "photon/dataflow/structures/Packet.h" +#include "photon/targeting/Float32TestMessage.h" + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +template <> +struct WPILIB_DLLEXPORT SerdeType { + static constexpr std::string_view GetSchemaHash() { + return "9fd9ed51ec69d6738ee24af43b2b9c7e"; + } + + static constexpr std::string_view GetSchema() { + return "float32 test;float32 vlaTest[?];optional float32 optTest;"; + } + + static photon::Float32TestMessage Unpack(photon::Packet& packet); + static void Pack(photon::Packet& packet, const photon::Float32TestMessage& value); +}; + +static_assert(photon::PhotonStructSerializable); + +} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/serde/Float64TestMessageSerde.h b/photon-targeting/src/generated/main/native/include/photon/serde/Float64TestMessageSerde.h new file mode 100644 index 0000000000..a2d6b0f1da --- /dev/null +++ b/photon-targeting/src/generated/main/native/include/photon/serde/Float64TestMessageSerde.h @@ -0,0 +1,59 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include + +// Include myself +#include "photon/dataflow/structures/Packet.h" +#include "photon/targeting/Float64TestMessage.h" + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +template <> +struct WPILIB_DLLEXPORT SerdeType { + static constexpr std::string_view GetSchemaHash() { + return "bc96c1f7d9db9371269d0e4f4d4b4cb2"; + } + + static constexpr std::string_view GetSchema() { + return "float64 test;float64 vlaTest[?];optional float64 optTest;"; + } + + static photon::Float64TestMessage Unpack(photon::Packet& packet); + static void Pack(photon::Packet& packet, const photon::Float64TestMessage& value); +}; + +static_assert(photon::PhotonStructSerializable); + +} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/serde/Int16TestMessageSerde.h b/photon-targeting/src/generated/main/native/include/photon/serde/Int16TestMessageSerde.h new file mode 100644 index 0000000000..b71917804a --- /dev/null +++ b/photon-targeting/src/generated/main/native/include/photon/serde/Int16TestMessageSerde.h @@ -0,0 +1,59 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include + +// Include myself +#include "photon/dataflow/structures/Packet.h" +#include "photon/targeting/Int16TestMessage.h" + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +template <> +struct WPILIB_DLLEXPORT SerdeType { + static constexpr std::string_view GetSchemaHash() { + return "23e6ccab160b942600aae8e94a72778a"; + } + + static constexpr std::string_view GetSchema() { + return "int16 test;int16 vlaTest[?];optional int16 optTest;"; + } + + static photon::Int16TestMessage Unpack(photon::Packet& packet); + static void Pack(photon::Packet& packet, const photon::Int16TestMessage& value); +}; + +static_assert(photon::PhotonStructSerializable); + +} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/serde/Int32TestMessageSerde.h b/photon-targeting/src/generated/main/native/include/photon/serde/Int32TestMessageSerde.h new file mode 100644 index 0000000000..5eb44c6381 --- /dev/null +++ b/photon-targeting/src/generated/main/native/include/photon/serde/Int32TestMessageSerde.h @@ -0,0 +1,59 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include + +// Include myself +#include "photon/dataflow/structures/Packet.h" +#include "photon/targeting/Int32TestMessage.h" + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +template <> +struct WPILIB_DLLEXPORT SerdeType { + static constexpr std::string_view GetSchemaHash() { + return "d8596149c4701e7b8912df238cd4ec66"; + } + + static constexpr std::string_view GetSchema() { + return "int32 test;int32 vlaTest[?];optional int32 optTest;"; + } + + static photon::Int32TestMessage Unpack(photon::Packet& packet); + static void Pack(photon::Packet& packet, const photon::Int32TestMessage& value); +}; + +static_assert(photon::PhotonStructSerializable); + +} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/serde/Int64TestMessageSerde.h b/photon-targeting/src/generated/main/native/include/photon/serde/Int64TestMessageSerde.h new file mode 100644 index 0000000000..a2beb754f4 --- /dev/null +++ b/photon-targeting/src/generated/main/native/include/photon/serde/Int64TestMessageSerde.h @@ -0,0 +1,59 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include + +// Include myself +#include "photon/dataflow/structures/Packet.h" +#include "photon/targeting/Int64TestMessage.h" + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +template <> +struct WPILIB_DLLEXPORT SerdeType { + static constexpr std::string_view GetSchemaHash() { + return "dd2e470b4d07bbcd208906c26a2ae37a"; + } + + static constexpr std::string_view GetSchema() { + return "int64 test;int64 vlaTest[?];optional int64 optTest;"; + } + + static photon::Int64TestMessage Unpack(photon::Packet& packet); + static void Pack(photon::Packet& packet, const photon::Int64TestMessage& value); +}; + +static_assert(photon::PhotonStructSerializable); + +} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/serde/Int8TestMessageSerde.h b/photon-targeting/src/generated/main/native/include/photon/serde/Int8TestMessageSerde.h new file mode 100644 index 0000000000..d1c526b338 --- /dev/null +++ b/photon-targeting/src/generated/main/native/include/photon/serde/Int8TestMessageSerde.h @@ -0,0 +1,59 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include + +// Include myself +#include "photon/dataflow/structures/Packet.h" +#include "photon/targeting/Int8TestMessage.h" + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +template <> +struct WPILIB_DLLEXPORT SerdeType { + static constexpr std::string_view GetSchemaHash() { + return "76297a79f30e4d995b8f95c5fa6297fa"; + } + + static constexpr std::string_view GetSchema() { + return "int8 test;int8 vlaTest[?];optional int8 optTest;"; + } + + static photon::Int8TestMessage Unpack(photon::Packet& packet); + static void Pack(photon::Packet& packet, const photon::Int8TestMessage& value); +}; + +static_assert(photon::PhotonStructSerializable); + +} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/serde/Transform3dTestMessageSerde.h b/photon-targeting/src/generated/main/native/include/photon/serde/Transform3dTestMessageSerde.h new file mode 100644 index 0000000000..69bcc31f3f --- /dev/null +++ b/photon-targeting/src/generated/main/native/include/photon/serde/Transform3dTestMessageSerde.h @@ -0,0 +1,60 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include + +// Include myself +#include "photon/dataflow/structures/Packet.h" +#include "photon/targeting/Transform3dTestMessage.h" + +// Includes for dependant types +#include +#include +#include +#include + + +namespace photon { + +template <> +struct WPILIB_DLLEXPORT SerdeType { + static constexpr std::string_view GetSchemaHash() { + return "37188f532d61c3b549080489012b4d07"; + } + + static constexpr std::string_view GetSchema() { + return "Transform3d test;Transform3d vlaTest[?];optional Transform3d optTest;"; + } + + static photon::Transform3dTestMessage Unpack(photon::Packet& packet); + static void Pack(photon::Packet& packet, const photon::Transform3dTestMessage& value); +}; + +static_assert(photon::PhotonStructSerializable); + +} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/struct/BoolTestMessageStruct.h b/photon-targeting/src/generated/main/native/include/photon/struct/BoolTestMessageStruct.h new file mode 100644 index 0000000000..a3fca76c9d --- /dev/null +++ b/photon-targeting/src/generated/main/native/include/photon/struct/BoolTestMessageStruct.h @@ -0,0 +1,45 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +struct BoolTestMessage_PhotonStruct { + bool test; + std::vector vlaTest; + std::optional optTest; + + friend bool operator==(BoolTestMessage_PhotonStruct const&, BoolTestMessage_PhotonStruct const&) = default; +}; + +} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/struct/Float32TestMessageStruct.h b/photon-targeting/src/generated/main/native/include/photon/struct/Float32TestMessageStruct.h new file mode 100644 index 0000000000..652daa87dd --- /dev/null +++ b/photon-targeting/src/generated/main/native/include/photon/struct/Float32TestMessageStruct.h @@ -0,0 +1,45 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +struct Float32TestMessage_PhotonStruct { + float test; + std::vector vlaTest; + std::optional optTest; + + friend bool operator==(Float32TestMessage_PhotonStruct const&, Float32TestMessage_PhotonStruct const&) = default; +}; + +} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/struct/Float64TestMessageStruct.h b/photon-targeting/src/generated/main/native/include/photon/struct/Float64TestMessageStruct.h new file mode 100644 index 0000000000..5ee739d063 --- /dev/null +++ b/photon-targeting/src/generated/main/native/include/photon/struct/Float64TestMessageStruct.h @@ -0,0 +1,45 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +struct Float64TestMessage_PhotonStruct { + double test; + std::vector vlaTest; + std::optional optTest; + + friend bool operator==(Float64TestMessage_PhotonStruct const&, Float64TestMessage_PhotonStruct const&) = default; +}; + +} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/struct/Int16TestMessageStruct.h b/photon-targeting/src/generated/main/native/include/photon/struct/Int16TestMessageStruct.h new file mode 100644 index 0000000000..356b0ae1d5 --- /dev/null +++ b/photon-targeting/src/generated/main/native/include/photon/struct/Int16TestMessageStruct.h @@ -0,0 +1,45 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +struct Int16TestMessage_PhotonStruct { + int16_t test; + std::vector vlaTest; + std::optional optTest; + + friend bool operator==(Int16TestMessage_PhotonStruct const&, Int16TestMessage_PhotonStruct const&) = default; +}; + +} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/struct/Int32TestMessageStruct.h b/photon-targeting/src/generated/main/native/include/photon/struct/Int32TestMessageStruct.h new file mode 100644 index 0000000000..519a6aed06 --- /dev/null +++ b/photon-targeting/src/generated/main/native/include/photon/struct/Int32TestMessageStruct.h @@ -0,0 +1,45 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +struct Int32TestMessage_PhotonStruct { + int32_t test; + std::vector vlaTest; + std::optional optTest; + + friend bool operator==(Int32TestMessage_PhotonStruct const&, Int32TestMessage_PhotonStruct const&) = default; +}; + +} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/struct/Int64TestMessageStruct.h b/photon-targeting/src/generated/main/native/include/photon/struct/Int64TestMessageStruct.h new file mode 100644 index 0000000000..f4ce39755e --- /dev/null +++ b/photon-targeting/src/generated/main/native/include/photon/struct/Int64TestMessageStruct.h @@ -0,0 +1,45 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +struct Int64TestMessage_PhotonStruct { + int64_t test; + std::vector vlaTest; + std::optional optTest; + + friend bool operator==(Int64TestMessage_PhotonStruct const&, Int64TestMessage_PhotonStruct const&) = default; +}; + +} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/struct/Int8TestMessageStruct.h b/photon-targeting/src/generated/main/native/include/photon/struct/Int8TestMessageStruct.h new file mode 100644 index 0000000000..5b37d13a64 --- /dev/null +++ b/photon-targeting/src/generated/main/native/include/photon/struct/Int8TestMessageStruct.h @@ -0,0 +1,45 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +struct Int8TestMessage_PhotonStruct { + int8_t test; + std::vector vlaTest; + std::optional optTest; + + friend bool operator==(Int8TestMessage_PhotonStruct const&, Int8TestMessage_PhotonStruct const&) = default; +}; + +} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/struct/Transform3dTestMessageStruct.h b/photon-targeting/src/generated/main/native/include/photon/struct/Transform3dTestMessageStruct.h new file mode 100644 index 0000000000..2cb9dd7481 --- /dev/null +++ b/photon-targeting/src/generated/main/native/include/photon/struct/Transform3dTestMessageStruct.h @@ -0,0 +1,46 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +// Includes for dependant types +#include +#include +#include +#include + + +namespace photon { + +struct Transform3dTestMessage_PhotonStruct { + wpi::math::Transform3d test; + std::vector vlaTest; + std::optional optTest; + + friend bool operator==(Transform3dTestMessage_PhotonStruct const&, Transform3dTestMessage_PhotonStruct const&) = default; +}; + +} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/targeting/BoolTestMessage.h b/photon-targeting/src/generated/main/native/include/photon/targeting/BoolTestMessage.h new file mode 100644 index 0000000000..ae7b782c59 --- /dev/null +++ b/photon-targeting/src/generated/main/native/include/photon/targeting/BoolTestMessage.h @@ -0,0 +1,51 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/struct/BoolTestMessageStruct.h" + +namespace photon { +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +class BoolTestMessage : public BoolTestMessage_PhotonStruct { + using Base = BoolTestMessage_PhotonStruct; + +public: + BoolTestMessage() = default; + + explicit BoolTestMessage(Base&& data) : Base(data) {} + + template + explicit BoolTestMessage(Args&&... args) + : Base{std::forward(args)...} {} + + friend bool operator==(BoolTestMessage const&, BoolTestMessage const&) = default; +}; +} // namespace photon + +#include "photon/serde/BoolTestMessageSerde.h" \ No newline at end of file diff --git a/photon-targeting/src/generated/main/native/include/photon/targeting/Float32TestMessage.h b/photon-targeting/src/generated/main/native/include/photon/targeting/Float32TestMessage.h new file mode 100644 index 0000000000..f020bb63ee --- /dev/null +++ b/photon-targeting/src/generated/main/native/include/photon/targeting/Float32TestMessage.h @@ -0,0 +1,51 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/struct/Float32TestMessageStruct.h" + +namespace photon { +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +class Float32TestMessage : public Float32TestMessage_PhotonStruct { + using Base = Float32TestMessage_PhotonStruct; + +public: + Float32TestMessage() = default; + + explicit Float32TestMessage(Base&& data) : Base(data) {} + + template + explicit Float32TestMessage(Args&&... args) + : Base{std::forward(args)...} {} + + friend bool operator==(Float32TestMessage const&, Float32TestMessage const&) = default; +}; +} // namespace photon + +#include "photon/serde/Float32TestMessageSerde.h" \ No newline at end of file diff --git a/photon-targeting/src/generated/main/native/include/photon/targeting/Float64TestMessage.h b/photon-targeting/src/generated/main/native/include/photon/targeting/Float64TestMessage.h new file mode 100644 index 0000000000..79d80fd45b --- /dev/null +++ b/photon-targeting/src/generated/main/native/include/photon/targeting/Float64TestMessage.h @@ -0,0 +1,51 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/struct/Float64TestMessageStruct.h" + +namespace photon { +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +class Float64TestMessage : public Float64TestMessage_PhotonStruct { + using Base = Float64TestMessage_PhotonStruct; + +public: + Float64TestMessage() = default; + + explicit Float64TestMessage(Base&& data) : Base(data) {} + + template + explicit Float64TestMessage(Args&&... args) + : Base{std::forward(args)...} {} + + friend bool operator==(Float64TestMessage const&, Float64TestMessage const&) = default; +}; +} // namespace photon + +#include "photon/serde/Float64TestMessageSerde.h" \ No newline at end of file diff --git a/photon-targeting/src/generated/main/native/include/photon/targeting/Int16TestMessage.h b/photon-targeting/src/generated/main/native/include/photon/targeting/Int16TestMessage.h new file mode 100644 index 0000000000..a05168af30 --- /dev/null +++ b/photon-targeting/src/generated/main/native/include/photon/targeting/Int16TestMessage.h @@ -0,0 +1,51 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/struct/Int16TestMessageStruct.h" + +namespace photon { +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +class Int16TestMessage : public Int16TestMessage_PhotonStruct { + using Base = Int16TestMessage_PhotonStruct; + +public: + Int16TestMessage() = default; + + explicit Int16TestMessage(Base&& data) : Base(data) {} + + template + explicit Int16TestMessage(Args&&... args) + : Base{std::forward(args)...} {} + + friend bool operator==(Int16TestMessage const&, Int16TestMessage const&) = default; +}; +} // namespace photon + +#include "photon/serde/Int16TestMessageSerde.h" \ No newline at end of file diff --git a/photon-targeting/src/generated/main/native/include/photon/targeting/Int32TestMessage.h b/photon-targeting/src/generated/main/native/include/photon/targeting/Int32TestMessage.h new file mode 100644 index 0000000000..d5df8c6063 --- /dev/null +++ b/photon-targeting/src/generated/main/native/include/photon/targeting/Int32TestMessage.h @@ -0,0 +1,51 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/struct/Int32TestMessageStruct.h" + +namespace photon { +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +class Int32TestMessage : public Int32TestMessage_PhotonStruct { + using Base = Int32TestMessage_PhotonStruct; + +public: + Int32TestMessage() = default; + + explicit Int32TestMessage(Base&& data) : Base(data) {} + + template + explicit Int32TestMessage(Args&&... args) + : Base{std::forward(args)...} {} + + friend bool operator==(Int32TestMessage const&, Int32TestMessage const&) = default; +}; +} // namespace photon + +#include "photon/serde/Int32TestMessageSerde.h" \ No newline at end of file diff --git a/photon-targeting/src/generated/main/native/include/photon/targeting/Int64TestMessage.h b/photon-targeting/src/generated/main/native/include/photon/targeting/Int64TestMessage.h new file mode 100644 index 0000000000..9df6fa7fee --- /dev/null +++ b/photon-targeting/src/generated/main/native/include/photon/targeting/Int64TestMessage.h @@ -0,0 +1,51 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/struct/Int64TestMessageStruct.h" + +namespace photon { +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +class Int64TestMessage : public Int64TestMessage_PhotonStruct { + using Base = Int64TestMessage_PhotonStruct; + +public: + Int64TestMessage() = default; + + explicit Int64TestMessage(Base&& data) : Base(data) {} + + template + explicit Int64TestMessage(Args&&... args) + : Base{std::forward(args)...} {} + + friend bool operator==(Int64TestMessage const&, Int64TestMessage const&) = default; +}; +} // namespace photon + +#include "photon/serde/Int64TestMessageSerde.h" \ No newline at end of file diff --git a/photon-targeting/src/generated/main/native/include/photon/targeting/Int8TestMessage.h b/photon-targeting/src/generated/main/native/include/photon/targeting/Int8TestMessage.h new file mode 100644 index 0000000000..d7e9e3c3ea --- /dev/null +++ b/photon-targeting/src/generated/main/native/include/photon/targeting/Int8TestMessage.h @@ -0,0 +1,51 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/struct/Int8TestMessageStruct.h" + +namespace photon { +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +class Int8TestMessage : public Int8TestMessage_PhotonStruct { + using Base = Int8TestMessage_PhotonStruct; + +public: + Int8TestMessage() = default; + + explicit Int8TestMessage(Base&& data) : Base(data) {} + + template + explicit Int8TestMessage(Args&&... args) + : Base{std::forward(args)...} {} + + friend bool operator==(Int8TestMessage const&, Int8TestMessage const&) = default; +}; +} // namespace photon + +#include "photon/serde/Int8TestMessageSerde.h" \ No newline at end of file diff --git a/photon-targeting/src/generated/main/native/include/photon/targeting/Transform3dTestMessage.h b/photon-targeting/src/generated/main/native/include/photon/targeting/Transform3dTestMessage.h new file mode 100644 index 0000000000..1b12f52678 --- /dev/null +++ b/photon-targeting/src/generated/main/native/include/photon/targeting/Transform3dTestMessage.h @@ -0,0 +1,51 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/struct/Transform3dTestMessageStruct.h" + +namespace photon { +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +class Transform3dTestMessage : public Transform3dTestMessage_PhotonStruct { + using Base = Transform3dTestMessage_PhotonStruct; + +public: + Transform3dTestMessage() = default; + + explicit Transform3dTestMessage(Base&& data) : Base(data) {} + + template + explicit Transform3dTestMessage(Args&&... args) + : Base{std::forward(args)...} {} + + friend bool operator==(Transform3dTestMessage const&, Transform3dTestMessage const&) = default; +}; +} // namespace photon + +#include "photon/serde/Transform3dTestMessageSerde.h" \ No newline at end of file diff --git a/photon-targeting/src/main/java/org/photonvision/common/dataflow/structures/Packet.java b/photon-targeting/src/main/java/org/photonvision/common/dataflow/structures/Packet.java index 89077b71fd..0e05a9f537 100644 --- a/photon-targeting/src/main/java/org/photonvision/common/dataflow/structures/Packet.java +++ b/photon-targeting/src/main/java/org/photonvision/common/dataflow/structures/Packet.java @@ -424,7 +424,7 @@ public void encodeBoolean(boolean src) { * * @param src The VLA of booleans to encode */ - public void encodeBooleanList(List src) { + public void encodeBooleanList(List src) { byte size = (byte) src.size(); if (src.size() > Byte.MAX_VALUE) { throw new RuntimeException("Array too long! Got " + size); @@ -433,7 +433,7 @@ public void encodeBooleanList(List src) { encodeByte(size); for (var f : src) { - encodeShort(f); + encodeBoolean(f); } } @@ -594,14 +594,14 @@ public int decodeInt() { * * @return A decoded list of ints from the packet */ - public List decodeIntList() { + public List decodeIntList() { byte length = decodeByte(); - var ret = new ArrayList(); + var ret = new ArrayList(); ret.ensureCapacity(length); for (int i = 0; i < length; i++) { - ret.add(decodeShort()); + ret.add(decodeInt()); } return ret; From b93d8ab74ee61000174d47feb5bca0cd09f6150d Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Fri, 15 May 2026 18:15:28 -0400 Subject: [PATCH 06/42] linting --- photon-lib/py/photonlibpy/packet.py | 8 ++--- .../py/photonlibpy/targeting/testMessages.py | 13 ++++++-- photon-serde/generate_messages.py | 31 +++++++++++++------ photon-serde/messages.yaml | 2 +- 4 files changed, 36 insertions(+), 18 deletions(-) diff --git a/photon-lib/py/photonlibpy/packet.py b/photon-lib/py/photonlibpy/packet.py index edfe1d6b73..41f1287eae 100644 --- a/photon-lib/py/photonlibpy/packet.py +++ b/photon-lib/py/photonlibpy/packet.py @@ -200,7 +200,7 @@ def decodeList(self, serde: Serde[T]) -> list[T]: for _ in range(arr_len): retList.append(serde.unpack(self)) return retList - + def decodeListShimmed(self, shim: Callable[[], T]) -> list[T]: retList = [] arr_len = self.decode8() @@ -213,7 +213,7 @@ def decodeOptional(self, serde: Serde[T]) -> Optional[T]: return serde.unpack(self) else: return None - + def decodeOptionalShimmed(self, shim: Callable[[], T]) -> Optional[T]: if self.decodeBoolean(): return shim() @@ -294,7 +294,7 @@ def encodeList(self, values: list[T], serde: Serde[T]): packed = serde.pack(item) self.packetData = self.packetData + packed.getData() self.size = len(self.packetData) - + def encodeListShimmed(self, values: list[T], shim: Callable[[T], None]): """ Encodes a list of items using a specific serializer and appends it to the packet. @@ -314,7 +314,7 @@ def encodeOptional(self, value: Optional[T], serde: Serde[T]): packed = serde.pack(value) self.packetData = self.packetData + packed.getData() self.size = len(self.packetData) - + def encodeOptionalShimmed(self, value: Optional[T], shim: Callable[[T], None]): """ Encodes an optional value using a specific shimmed serializer. diff --git a/photon-lib/py/photonlibpy/targeting/testMessages.py b/photon-lib/py/photonlibpy/targeting/testMessages.py index e8c77e739c..a8bffeb7de 100644 --- a/photon-lib/py/photonlibpy/targeting/testMessages.py +++ b/photon-lib/py/photonlibpy/targeting/testMessages.py @@ -1,55 +1,62 @@ -from dataclasses import dataclass, field - +from dataclasses import dataclass from typing import Optional from wpimath.geometry import Transform3d # TODO: Autogenerate python test classes? + @dataclass class Int8TestMessage: test: int vlaTest: list[int] optTest: Optional[int] + @dataclass class Int16TestMessage: test: int vlaTest: list[int] optTest: Optional[int] + @dataclass class Int32TestMessage: test: int vlaTest: list[int] optTest: Optional[int] + @dataclass class Int64TestMessage: test: int vlaTest: list[int] optTest: Optional[int] + @dataclass class Float32TestMessage: test: float vlaTest: list[float] optTest: Optional[float] + @dataclass class Float64TestMessage: test: float vlaTest: list[float] optTest: Optional[float] + @dataclass class BoolTestMessage: test: bool vlaTest: list[bool] optTest: Optional[bool] + @dataclass class Transform3dTestMessage: test: Transform3d vlaTest: list[Transform3d] - optTest: Optional[Transform3d] \ No newline at end of file + optTest: Optional[Transform3d] diff --git a/photon-serde/generate_messages.py b/photon-serde/generate_messages.py index ff1ef3e8a9..3d7dfa7a28 100644 --- a/photon-serde/generate_messages.py +++ b/photon-serde/generate_messages.py @@ -270,7 +270,9 @@ def generate_photon_messages(cpp_java_root, py_root, template_root): java_output_dir = Path(cpp_java_root) / "main/java/org/photonvision/struct" java_output_dir.mkdir(parents=True, exist_ok=True) - java_test_class_output_dir = Path(cpp_java_root) / "main/java/org/photonvision/targeting" + java_test_class_output_dir = ( + Path(cpp_java_root) / "main/java/org/photonvision/targeting" + ) java_test_class_output_dir.mkdir(parents=True, exist_ok=True) cpp_serde_header_dir = Path(cpp_java_root) / "main/native/include/photon/serde/" @@ -281,7 +283,9 @@ def generate_photon_messages(cpp_java_root, py_root, template_root): cpp_struct_header_dir = Path(cpp_java_root) / "main/native/include/photon/struct/" cpp_struct_header_dir.mkdir(parents=True, exist_ok=True) - cpp_test_struct_output_dir = Path(cpp_java_root) / "main/native/include/photon/targeting/" + cpp_test_struct_output_dir = ( + Path(cpp_java_root) / "main/native/include/photon/targeting/" + ) cpp_test_struct_output_dir.mkdir(parents=True, exist_ok=True) py_serde_source_dir = Path(py_root) @@ -360,20 +364,28 @@ def generate_photon_messages(cpp_java_root, py_root, template_root): ), encoding="utf-8", ) - - if 'test' in message.keys() and message['test']: + + if "test" in message.keys() and message["test"]: java_test_class_name = f"{message['name']}.java" java_test_class_template = env.get_template("ThingTestClass.java.jinja") - + cpp_test_struct_name = f"{message['name']}.h" cpp_test_struct_template = env.get_template("ThingTestStruct.h.jinja") for output_name, template, output_folder in [ - [java_test_class_name, java_test_class_template, java_test_class_output_dir], - [cpp_test_struct_name, cpp_test_struct_template, cpp_test_struct_output_dir] + [ + java_test_class_name, + java_test_class_template, + java_test_class_output_dir, + ], + [ + cpp_test_struct_name, + cpp_test_struct_template, + cpp_test_struct_output_dir, + ], ]: # Hack in our message getter - template.globals["get_message_by_name"] = lambda name: get_message_by_name( - messages, name + template.globals["get_message_by_name"] = ( + lambda name: get_message_by_name(messages, name) ) # TODO: Are the nested types really necessary for ts? @@ -413,7 +425,6 @@ def generate_photon_messages(cpp_java_root, py_root, template_root): ) - def main(argv): script_path = Path(__file__).resolve() dirname = script_path.parent diff --git a/photon-serde/messages.yaml b/photon-serde/messages.yaml index 7fd1f47116..b05cc85830 100644 --- a/photon-serde/messages.yaml +++ b/photon-serde/messages.yaml @@ -189,4 +189,4 @@ vla: True - name: optTest type: Transform3d - optional: True \ No newline at end of file + optional: True From 44ac51e358cef33d60be99abbe7ec25775472273 Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Fri, 15 May 2026 20:23:59 -0400 Subject: [PATCH 07/42] added java tests --- photon-serde/templates/Message.java.jinja | 1 + .../templates/ThingTestClass.java.jinja | 32 ++- .../struct/PhotonPipelineResultSerde.java | 2 +- .../struct/PhotonTrackedTargetSerde.java | 2 + .../photonvision/struct/PnpResultSerde.java | 2 + .../struct/Transform3dTestMessageSerde.java | 3 + .../targeting/BoolTestMessage.java | 20 +- .../targeting/Float32TestMessage.java | 20 +- .../targeting/Float64TestMessage.java | 20 +- .../targeting/Int16TestMessage.java | 20 +- .../targeting/Int32TestMessage.java | 20 +- .../targeting/Int64TestMessage.java | 20 +- .../targeting/Int8TestMessage.java | 20 +- .../targeting/Transform3dTestMessage.java | 22 +- .../java/org/photonvision/PacketTest.java | 2 +- .../test/java/org/photonvision/SerdeTest.java | 215 ++++++++++++++++++ 16 files changed, 397 insertions(+), 24 deletions(-) create mode 100644 photon-targeting/src/test/java/org/photonvision/SerdeTest.java diff --git a/photon-serde/templates/Message.java.jinja b/photon-serde/templates/Message.java.jinja index 6bd3aae1d8..3789b6750b 100644 --- a/photon-serde/templates/Message.java.jinja +++ b/photon-serde/templates/Message.java.jinja @@ -63,6 +63,7 @@ public class {{ name }}Serde implements PacketSerde<{{name}}> { } {% for field in fields -%} {%- if field.type | is_shimmed %} + // Hack because the shim is PacketUtil.[shim] not PacketUtil::[shim] private static BiConsumer {{ field.name }}_PSINTERNALencode_shim_callable = (packet, value) -> {{ get_message_by_name(field.type).java_encode_shim }}(packet, value); private static Function {{ field.name }}_PSINTERNALdecode_shim_callable = (packet) -> {{ get_message_by_name(field.type).java_decode_shim }}(packet); {% endif -%} diff --git a/photon-serde/templates/ThingTestClass.java.jinja b/photon-serde/templates/ThingTestClass.java.jinja index ab89df597a..760df7d4a1 100644 --- a/photon-serde/templates/ThingTestClass.java.jinja +++ b/photon-serde/templates/ThingTestClass.java.jinja @@ -47,23 +47,45 @@ public class {{ name }} implements PhotonStructSerializable<{{ name }}> { {% for field in fields -%} {%- if field.type | is_intrinsic %} {%- if field.optional == True %} - public Optional<{{ type_map[field.type].java_boxed_type }}> {{ field.name }}; + public Optional<{{ type_map[field.type].java_boxed_type }}> {{ field.name }} = Optional.empty(); {%- elif field.vla == True %} - public List<{{ type_map[field.type].java_boxed_type }}> {{ field.name }}; + public List<{{ type_map[field.type].java_boxed_type }}> {{ field.name }} = List.of(); {%- else %} public {{ type_map[field.type].java_type }} {{ field.name }}; {%- endif %} {%- else %} {%- if field.optional == True %} - public Optional<{{ field.type }}> {{ field.name }}; + public Optional<{{ field.type }}> {{ field.name }} = Optional.empty(); {%- elif field.vla == True %} - public List<{{ field.type }}> {{ field.name }}; + public List<{{ field.type }}> {{ field.name }} = List.of(); {%- else %} - public {{ field.type }} {{ field.name }}; + public {{ field.type }} {{ field.name }} = new {{ field.type }}(); {%- endif %} {%- endif %} {% endfor%} + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + + {{ name }} other = ({{ name }}) obj; +{% for field in fields -%} +{%- if field.type | is_intrinsic %} + {%- if field.optional == True %} + if (!this.{{ field.name }}.equals(other.{{ field.name }})) return false; + {%- elif field.vla == True %} + if (!this.{{ field.name }}.equals(other.{{ field.name }})) return false; + {%- else %} + if (this.{{ field.name }} != other.{{ field.name }}) return false; + {%- endif %} +{%- else %} + if (!this.{{ field.name }}.equals(other.{{ field.name }})) return false; +{%- endif %} +{% endfor%} + return true; + } + /** {{ name }} PhotonStruct for serialization. */ public static final {{ name }}Serde photonStruct = new {{ name }}Serde(); diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java index fad9d7084c..e67c0de3f9 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java @@ -90,7 +90,7 @@ public PhotonPipelineResult unpack(Packet packet) { @Override public PacketSerde[] getNestedPhotonMessages() { return new PacketSerde[] { - PhotonTrackedTarget.photonStruct,MultiTargetPNPResult.photonStruct,PhotonPipelineMetadata.photonStruct + PhotonPipelineMetadata.photonStruct,PhotonTrackedTarget.photonStruct,MultiTargetPNPResult.photonStruct }; } diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonTrackedTargetSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonTrackedTargetSerde.java index 8d96ee26c7..cfacc83369 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonTrackedTargetSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonTrackedTargetSerde.java @@ -59,9 +59,11 @@ public int getMaxByteSize() { throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); } + // Hack because the shim is PacketUtil.[shim] not PacketUtil::[shim] private static BiConsumer bestCameraToTarget_PSINTERNALencode_shim_callable = (packet, value) -> PacketUtils.packTransform3d(packet, value); private static Function bestCameraToTarget_PSINTERNALdecode_shim_callable = (packet) -> PacketUtils.unpackTransform3d(packet); + // Hack because the shim is PacketUtil.[shim] not PacketUtil::[shim] private static BiConsumer altCameraToTarget_PSINTERNALencode_shim_callable = (packet, value) -> PacketUtils.packTransform3d(packet, value); private static Function altCameraToTarget_PSINTERNALdecode_shim_callable = (packet) -> PacketUtils.unpackTransform3d(packet); diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/PnpResultSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/PnpResultSerde.java index c8e6ae6897..fe518e586e 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/PnpResultSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/PnpResultSerde.java @@ -59,9 +59,11 @@ public int getMaxByteSize() { throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); } + // Hack because the shim is PacketUtil.[shim] not PacketUtil::[shim] private static BiConsumer best_PSINTERNALencode_shim_callable = (packet, value) -> PacketUtils.packTransform3d(packet, value); private static Function best_PSINTERNALdecode_shim_callable = (packet) -> PacketUtils.unpackTransform3d(packet); + // Hack because the shim is PacketUtil.[shim] not PacketUtil::[shim] private static BiConsumer alt_PSINTERNALencode_shim_callable = (packet, value) -> PacketUtils.packTransform3d(packet, value); private static Function alt_PSINTERNALdecode_shim_callable = (packet) -> PacketUtils.unpackTransform3d(packet); diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/Transform3dTestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/Transform3dTestMessageSerde.java index 5d1d7696d5..065fbf5985 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/Transform3dTestMessageSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/Transform3dTestMessageSerde.java @@ -59,12 +59,15 @@ public int getMaxByteSize() { throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); } + // Hack because the shim is PacketUtil.[shim] not PacketUtil::[shim] private static BiConsumer test_PSINTERNALencode_shim_callable = (packet, value) -> PacketUtils.packTransform3d(packet, value); private static Function test_PSINTERNALdecode_shim_callable = (packet) -> PacketUtils.unpackTransform3d(packet); + // Hack because the shim is PacketUtil.[shim] not PacketUtil::[shim] private static BiConsumer vlaTest_PSINTERNALencode_shim_callable = (packet, value) -> PacketUtils.packTransform3d(packet, value); private static Function vlaTest_PSINTERNALdecode_shim_callable = (packet) -> PacketUtils.unpackTransform3d(packet); + // Hack because the shim is PacketUtil.[shim] not PacketUtil::[shim] private static BiConsumer optTest_PSINTERNALencode_shim_callable = (packet, value) -> PacketUtils.packTransform3d(packet, value); private static Function optTest_PSINTERNALdecode_shim_callable = (packet) -> PacketUtils.unpackTransform3d(packet); diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/BoolTestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/BoolTestMessage.java index 58bd1814ad..cefdab332a 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/targeting/BoolTestMessage.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/targeting/BoolTestMessage.java @@ -44,11 +44,27 @@ public class BoolTestMessage implements PhotonStructSerializable vlaTest; + public List vlaTest = List.of(); - public Optional optTest; + public Optional optTest = Optional.empty(); + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + + BoolTestMessage other = (BoolTestMessage) obj; + + if (this.test != other.test) return false; + + if (!this.vlaTest.equals(other.vlaTest)) return false; + + if (!this.optTest.equals(other.optTest)) return false; + + return true; + } + /** BoolTestMessage PhotonStruct for serialization. */ public static final BoolTestMessageSerde photonStruct = new BoolTestMessageSerde(); diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float32TestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float32TestMessage.java index 9cb263afa4..db57992556 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float32TestMessage.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float32TestMessage.java @@ -44,11 +44,27 @@ public class Float32TestMessage implements PhotonStructSerializable vlaTest; + public List vlaTest = List.of(); - public Optional optTest; + public Optional optTest = Optional.empty(); + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + + Float32TestMessage other = (Float32TestMessage) obj; + + if (this.test != other.test) return false; + + if (!this.vlaTest.equals(other.vlaTest)) return false; + + if (!this.optTest.equals(other.optTest)) return false; + + return true; + } + /** Float32TestMessage PhotonStruct for serialization. */ public static final Float32TestMessageSerde photonStruct = new Float32TestMessageSerde(); diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float64TestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float64TestMessage.java index af4975c191..305ef70044 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float64TestMessage.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float64TestMessage.java @@ -44,11 +44,27 @@ public class Float64TestMessage implements PhotonStructSerializable vlaTest; + public List vlaTest = List.of(); - public Optional optTest; + public Optional optTest = Optional.empty(); + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + + Float64TestMessage other = (Float64TestMessage) obj; + + if (this.test != other.test) return false; + + if (!this.vlaTest.equals(other.vlaTest)) return false; + + if (!this.optTest.equals(other.optTest)) return false; + + return true; + } + /** Float64TestMessage PhotonStruct for serialization. */ public static final Float64TestMessageSerde photonStruct = new Float64TestMessageSerde(); diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int16TestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int16TestMessage.java index 72c6e00df1..5f40f7b783 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int16TestMessage.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int16TestMessage.java @@ -44,11 +44,27 @@ public class Int16TestMessage implements PhotonStructSerializable vlaTest; + public List vlaTest = List.of(); - public Optional optTest; + public Optional optTest = Optional.empty(); + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + + Int16TestMessage other = (Int16TestMessage) obj; + + if (this.test != other.test) return false; + + if (!this.vlaTest.equals(other.vlaTest)) return false; + + if (!this.optTest.equals(other.optTest)) return false; + + return true; + } + /** Int16TestMessage PhotonStruct for serialization. */ public static final Int16TestMessageSerde photonStruct = new Int16TestMessageSerde(); diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int32TestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int32TestMessage.java index 3caf4a7255..39e4820ce5 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int32TestMessage.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int32TestMessage.java @@ -44,11 +44,27 @@ public class Int32TestMessage implements PhotonStructSerializable vlaTest; + public List vlaTest = List.of(); - public Optional optTest; + public Optional optTest = Optional.empty(); + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + + Int32TestMessage other = (Int32TestMessage) obj; + + if (this.test != other.test) return false; + + if (!this.vlaTest.equals(other.vlaTest)) return false; + + if (!this.optTest.equals(other.optTest)) return false; + + return true; + } + /** Int32TestMessage PhotonStruct for serialization. */ public static final Int32TestMessageSerde photonStruct = new Int32TestMessageSerde(); diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int64TestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int64TestMessage.java index 8ecd2808d7..a706e4d520 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int64TestMessage.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int64TestMessage.java @@ -44,11 +44,27 @@ public class Int64TestMessage implements PhotonStructSerializable vlaTest; + public List vlaTest = List.of(); - public Optional optTest; + public Optional optTest = Optional.empty(); + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + + Int64TestMessage other = (Int64TestMessage) obj; + + if (this.test != other.test) return false; + + if (!this.vlaTest.equals(other.vlaTest)) return false; + + if (!this.optTest.equals(other.optTest)) return false; + + return true; + } + /** Int64TestMessage PhotonStruct for serialization. */ public static final Int64TestMessageSerde photonStruct = new Int64TestMessageSerde(); diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int8TestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int8TestMessage.java index 4c723075ba..deba66761a 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int8TestMessage.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int8TestMessage.java @@ -44,11 +44,27 @@ public class Int8TestMessage implements PhotonStructSerializable vlaTest; + public List vlaTest = List.of(); - public Optional optTest; + public Optional optTest = Optional.empty(); + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + + Int8TestMessage other = (Int8TestMessage) obj; + + if (this.test != other.test) return false; + + if (!this.vlaTest.equals(other.vlaTest)) return false; + + if (!this.optTest.equals(other.optTest)) return false; + + return true; + } + /** Int8TestMessage PhotonStruct for serialization. */ public static final Int8TestMessageSerde photonStruct = new Int8TestMessageSerde(); diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Transform3dTestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Transform3dTestMessage.java index 7356cb28a4..d034c06464 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Transform3dTestMessage.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Transform3dTestMessage.java @@ -42,13 +42,29 @@ */ public class Transform3dTestMessage implements PhotonStructSerializable { - public Transform3d test; + public Transform3d test = new Transform3d(); - public List vlaTest; + public List vlaTest = List.of(); - public Optional optTest; + public Optional optTest = Optional.empty(); + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + + Transform3dTestMessage other = (Transform3dTestMessage) obj; + + if (!this.test.equals(other.test)) return false; + + if (!this.vlaTest.equals(other.vlaTest)) return false; + + if (!this.optTest.equals(other.optTest)) return false; + + return true; + } + /** Transform3dTestMessage PhotonStruct for serialization. */ public static final Transform3dTestMessageSerde photonStruct = new Transform3dTestMessageSerde(); diff --git a/photon-targeting/src/test/java/org/photonvision/PacketTest.java b/photon-targeting/src/test/java/org/photonvision/PacketTest.java index b531f54816..725cdef4c2 100644 --- a/photon-targeting/src/test/java/org/photonvision/PacketTest.java +++ b/photon-targeting/src/test/java/org/photonvision/PacketTest.java @@ -41,7 +41,7 @@ public void testTargetCorner() { } @Test - void pipelineResultSerde() { + public void pipelineResultSerde() { var ret1 = new PhotonPipelineResult(1, 2, 3, 1024, List.of()); var p1 = new Packet(10); PhotonPipelineResult.photonStruct.pack(p1, ret1); diff --git a/photon-targeting/src/test/java/org/photonvision/SerdeTest.java b/photon-targeting/src/test/java/org/photonvision/SerdeTest.java new file mode 100644 index 0000000000..0f40bcd061 --- /dev/null +++ b/photon-targeting/src/test/java/org/photonvision/SerdeTest.java @@ -0,0 +1,215 @@ +/* + * Copyright (C) Photon Vision. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.photonvision; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.List; +import java.util.Optional; +import org.junit.jupiter.api.Test; +import org.photonvision.common.dataflow.structures.Packet; +import org.photonvision.targeting.*; +import org.photonvision.targeting.serde.PhotonStructSerializable; +import org.wpilib.math.geometry.Rotation3d; +import org.wpilib.math.geometry.Transform3d; + +public class SerdeTest { + + private > boolean testSerde(T data) { + var p = new Packet(10); + p.encode(data); + var unpackedData = p.decode(data); // kinda scuffed lowkey + return data.equals(unpackedData); + } + + @Test + public void int8Test() { + // Default test + var test1 = new Int8TestMessage(); + assertTrue(testSerde(test1)); + // Optional test + var test2 = new Int8TestMessage(); + test2.optTest = Optional.of((byte) 3); + assertTrue(testSerde(test2)); + // VLA test + var test3 = new Int8TestMessage(); + test3.vlaTest = List.of((byte) 1, (byte) 2, (byte) 3); + assertTrue(testSerde(test3)); + // General test + var test4 = new Int8TestMessage(); + test4.test = (byte) 1; + test4.vlaTest = List.of((byte) 1, (byte) 2, (byte) 3); + test4.optTest = Optional.of((byte) 3); + assertTrue(testSerde(test4)); + } + + @Test + public void int16Test() { + // Default test + var test1 = new Int16TestMessage(); + assertTrue(testSerde(test1)); + // Optional test + var test2 = new Int16TestMessage(); + test2.optTest = Optional.of((short) 3); + assertTrue(testSerde(test2)); + // VLA test + var test3 = new Int16TestMessage(); + test3.vlaTest = List.of((short) 1, (short) 2, (short) 3); + assertTrue(testSerde(test3)); + // General test + var test4 = new Int16TestMessage(); + test4.test = (short) 1; + test4.vlaTest = List.of((short) 1, (short) 2, (short) 3); + test4.optTest = Optional.of((short) 3); + assertTrue(testSerde(test4)); + } + + @Test + public void int32Test() { + // Default test + var test1 = new Int32TestMessage(); + assertTrue(testSerde(test1)); + // Optional test + var test2 = new Int32TestMessage(); + test2.optTest = Optional.of((int) 3); + assertTrue(testSerde(test2)); + // VLA test + var test3 = new Int32TestMessage(); + test3.vlaTest = List.of((int) 1, (int) 2, (int) 3); + assertTrue(testSerde(test3)); + // General test + var test4 = new Int32TestMessage(); + test4.test = (int) 1; + test4.vlaTest = List.of((int) 1, (int) 2, (int) 3); + test4.optTest = Optional.of((int) 3); + assertTrue(testSerde(test4)); + } + + @Test + public void int64Test() { + // Default test + var test1 = new Int64TestMessage(); + assertTrue(testSerde(test1)); + // Optional test + var test2 = new Int64TestMessage(); + test2.optTest = Optional.of((long) 3); + assertTrue(testSerde(test2)); + // VLA test + var test3 = new Int64TestMessage(); + test3.vlaTest = List.of((long) 1, (long) 2, (long) 3); + assertTrue(testSerde(test3)); + // General test + var test4 = new Int64TestMessage(); + test4.test = (long) 1; + test4.vlaTest = List.of((long) 1, (long) 2, (long) 3); + test4.optTest = Optional.of((long) 3); + assertTrue(testSerde(test4)); + } + + @Test + public void float32Test() { + // Default test + var test1 = new Float32TestMessage(); + assertTrue(testSerde(test1)); + // Optional test + var test2 = new Float32TestMessage(); + test2.optTest = Optional.of((float) 3.0); + assertTrue(testSerde(test2)); + // VLA test + var test3 = new Float32TestMessage(); + test3.vlaTest = List.of((float) 1.0, (float) 2.0, (float) 3.0); + assertTrue(testSerde(test3)); + // General test + var test4 = new Float32TestMessage(); + test4.test = (float) 1.0; + test4.vlaTest = List.of((float) 1.0, (float) 2.0, (float) 3.0); + test4.optTest = Optional.of((float) 3.0); + assertTrue(testSerde(test4)); + } + + @Test + public void float64Test() { + // Default test + var test1 = new Float64TestMessage(); + assertTrue(testSerde(test1)); + // Optional test + var test2 = new Float64TestMessage(); + test2.optTest = Optional.of((double) 3.0); + assertTrue(testSerde(test2)); + // VLA test + var test3 = new Float64TestMessage(); + test3.vlaTest = List.of((double) 1.0, (double) 2.0, (double) 3.0); + assertTrue(testSerde(test3)); + // General test + var test4 = new Float64TestMessage(); + test4.test = (float) 1.0; + test4.vlaTest = List.of((double) 1.0, (double) 2.0, (double) 3.0); + test4.optTest = Optional.of((double) 3.0); + assertTrue(testSerde(test4)); + } + + @Test + public void boolTest() { + // Default test + var test1 = new BoolTestMessage(); + assertTrue(testSerde(test1)); + // Optional test + var test2 = new BoolTestMessage(); + test2.optTest = Optional.of(true); + assertTrue(testSerde(test2)); + // VLA test + var test3 = new BoolTestMessage(); + test3.vlaTest = List.of(true, false, true); + assertTrue(testSerde(test3)); + // General test + var test4 = new BoolTestMessage(); + test4.test = true; + test4.vlaTest = List.of(true, false, true); + test4.optTest = Optional.of(true); + assertTrue(testSerde(test4)); + } + + @Test + public void Transform3dTest() { + // Default test + var test1 = new Transform3dTestMessage(); + assertTrue(testSerde(test1)); + // Optional test + var test2 = new Transform3dTestMessage(); + test2.optTest = Optional.of(new Transform3d(1.0, 2.0, 3.0, new Rotation3d(1.0, 2.0, 3.0))); + assertTrue(testSerde(test2)); + // VLA test + var test3 = new Transform3dTestMessage(); + test3.vlaTest = + List.of( + new Transform3d(1.0, 2.0, 3.0, new Rotation3d(1.0, 2.0, 3.0)), + new Transform3d(2.0, 1.0, 5.0, new Rotation3d(4.0, 3.0, 2.0)), + new Transform3d(1.0, 0.0, 0.0, new Rotation3d(1.0, 5.0, 3.0))); + assertTrue(testSerde(test3)); + // General test + var test4 = new Transform3dTestMessage(); + test4.test = new Transform3d(0.0, 1.0, 0.0, new Rotation3d(0.0, 2.0, 0.0)); + test4.vlaTest = + List.of( + new Transform3d(1.0, 2.0, 3.0, new Rotation3d(1.0, 2.0, 3.0)), + new Transform3d(2.0, 1.0, 5.0, new Rotation3d(4.0, 3.0, 2.0)), + new Transform3d(1.0, 0.0, 0.0, new Rotation3d(1.0, 5.0, 3.0))); + test4.optTest = Optional.of(new Transform3d(1.0, 2.0, 3.0, new Rotation3d(1.0, 2.0, 3.0))); + assertTrue(testSerde(test4)); + } +} From 1cd8a97b725dde2d639ab9a19482f78dc850c927 Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Fri, 15 May 2026 20:24:56 -0400 Subject: [PATCH 08/42] wpiformat --- photon-targeting/src/test/java/org/photonvision/SerdeTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/photon-targeting/src/test/java/org/photonvision/SerdeTest.java b/photon-targeting/src/test/java/org/photonvision/SerdeTest.java index 0f40bcd061..aa1968b29a 100644 --- a/photon-targeting/src/test/java/org/photonvision/SerdeTest.java +++ b/photon-targeting/src/test/java/org/photonvision/SerdeTest.java @@ -29,7 +29,6 @@ import org.wpilib.math.geometry.Transform3d; public class SerdeTest { - private > boolean testSerde(T data) { var p = new Packet(10); p.encode(data); From f7cadf013e310e1f78fa05c321330183fd70e0d6 Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Fri, 15 May 2026 20:44:59 -0400 Subject: [PATCH 09/42] added print messages to serde tests --- .../src/test/java/org/photonvision/SerdeTest.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/photon-targeting/src/test/java/org/photonvision/SerdeTest.java b/photon-targeting/src/test/java/org/photonvision/SerdeTest.java index aa1968b29a..2c9cdf32ac 100644 --- a/photon-targeting/src/test/java/org/photonvision/SerdeTest.java +++ b/photon-targeting/src/test/java/org/photonvision/SerdeTest.java @@ -38,6 +38,7 @@ private > boolean testSerde(T data) { @Test public void int8Test() { + System.out.println("Running int8 Test"); // Default test var test1 = new Int8TestMessage(); assertTrue(testSerde(test1)); @@ -59,6 +60,7 @@ public void int8Test() { @Test public void int16Test() { + System.out.println("Running int16 Test"); // Default test var test1 = new Int16TestMessage(); assertTrue(testSerde(test1)); @@ -80,6 +82,7 @@ public void int16Test() { @Test public void int32Test() { + System.out.println("Running int32 Test"); // Default test var test1 = new Int32TestMessage(); assertTrue(testSerde(test1)); @@ -101,6 +104,7 @@ public void int32Test() { @Test public void int64Test() { + System.out.println("Running int64 Test"); // Default test var test1 = new Int64TestMessage(); assertTrue(testSerde(test1)); @@ -122,6 +126,7 @@ public void int64Test() { @Test public void float32Test() { + System.out.println("Running float32 Test"); // Default test var test1 = new Float32TestMessage(); assertTrue(testSerde(test1)); @@ -143,6 +148,7 @@ public void float32Test() { @Test public void float64Test() { + System.out.println("Running float64 Test"); // Default test var test1 = new Float64TestMessage(); assertTrue(testSerde(test1)); @@ -164,6 +170,7 @@ public void float64Test() { @Test public void boolTest() { + System.out.println("Running bool Test"); // Default test var test1 = new BoolTestMessage(); assertTrue(testSerde(test1)); @@ -185,6 +192,7 @@ public void boolTest() { @Test public void Transform3dTest() { + System.out.println("Running Transform3d Test"); // Default test var test1 = new Transform3dTestMessage(); assertTrue(testSerde(test1)); From d2b7e2c9c23c8896b13d23e87f1305b18642226f Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Tue, 19 May 2026 09:54:31 -0400 Subject: [PATCH 10/42] started work on cpp tests --- .../src/test/native/cpp/SerdeTest.cpp | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 photon-targeting/src/test/native/cpp/SerdeTest.cpp diff --git a/photon-targeting/src/test/native/cpp/SerdeTest.cpp b/photon-targeting/src/test/native/cpp/SerdeTest.cpp new file mode 100644 index 0000000000..ec4c945231 --- /dev/null +++ b/photon-targeting/src/test/native/cpp/SerdeTest.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) Photon Vision. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include + +#include "photon/dataflow/structures/Packet.h" + +#include "photon/targeting/BoolTestMessage.h" +#include "photon/targeting/Int8TestMessage.h" +#include "photon/targeting/Int16TestMessage.h" +#include "photon/targeting/Int32TestMessage.h" +#include "photon/targeting/Int64TestMessage.h" +#include "photon/targeting/Float32TestMessage.h" +#include "photon/targeting/Float64TestMessage.h" +#include "photon/targeting/Transform3dTestMessage.h" + +#include "gtest/gtest.h" + +#include + +using namespace photon; + +template + requires(PhotonStructSerializable) +inline bool test_serde(const T& data) { + Packet p; + p.Pack(data); + T unpackedData = p.Unpack(); + return data == unpackedData; +} + +TEST(SerdeTest, Int8Test) { + std::cout << "Running int8 Test\n"; + // Default Test + Int8TestMessage test1{}; + ASSERT_TRUE(test_serde(test1)); + std::cout << "Running int8 Test\n"; + // Optional Test + Int8TestMessage test2{}; + test2.optTest = {3}; + ASSERT_TRUE(test_serde(test2)); +} \ No newline at end of file From 89bbb8eaa31fc6c634866caaf5ada74a35a22a94 Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Tue, 19 May 2026 11:04:54 -0400 Subject: [PATCH 11/42] hopefully fixed tests. also wpiformat --- .../src/test/native/cpp/SerdeTest.cpp | 213 +++++++++++++++--- 1 file changed, 187 insertions(+), 26 deletions(-) diff --git a/photon-targeting/src/test/native/cpp/SerdeTest.cpp b/photon-targeting/src/test/native/cpp/SerdeTest.cpp index ec4c945231..879eca3161 100644 --- a/photon-targeting/src/test/native/cpp/SerdeTest.cpp +++ b/photon-targeting/src/test/native/cpp/SerdeTest.cpp @@ -16,41 +16,202 @@ */ #include +#include -#include "photon/dataflow/structures/Packet.h" +#include +#include "gtest/gtest.h" +#include "photon/dataflow/structures/Packet.h" #include "photon/targeting/BoolTestMessage.h" -#include "photon/targeting/Int8TestMessage.h" +#include "photon/targeting/Float32TestMessage.h" +#include "photon/targeting/Float64TestMessage.h" #include "photon/targeting/Int16TestMessage.h" #include "photon/targeting/Int32TestMessage.h" #include "photon/targeting/Int64TestMessage.h" -#include "photon/targeting/Float32TestMessage.h" -#include "photon/targeting/Float64TestMessage.h" +#include "photon/targeting/Int8TestMessage.h" #include "photon/targeting/Transform3dTestMessage.h" -#include "gtest/gtest.h" - -#include - using namespace photon; template - requires(PhotonStructSerializable) + requires(PhotonStructSerializable) inline bool test_serde(const T& data) { - Packet p; - p.Pack(data); - T unpackedData = p.Unpack(); - return data == unpackedData; -} - -TEST(SerdeTest, Int8Test) { - std::cout << "Running int8 Test\n"; - // Default Test - Int8TestMessage test1{}; - ASSERT_TRUE(test_serde(test1)); - std::cout << "Running int8 Test\n"; - // Optional Test - Int8TestMessage test2{}; - test2.optTest = {3}; - ASSERT_TRUE(test_serde(test2)); -} \ No newline at end of file + Packet p; + p.Pack(data); + T unpackedData = p.Unpack(); + return data == unpackedData; +} + +TEST(SerdeTest, Int8) { + std::cout << "Running int8 Test\n"; + // Default Test + Int8TestMessage test1{}; + ASSERT_TRUE(test_serde(test1)); + // Optional Test + Int8TestMessage test2{}; + test2.optTest = {3}; + ASSERT_TRUE(test_serde(test2)); + // VLA Test + Int8TestMessage test3{}; + test3.vlaTest = {1, 2, 3}; + ASSERT_TRUE(test_serde(test3)); + // General Test + Int8TestMessage test4{}; + test4.test = 1; + test4.vlaTest = {1, 2, 3}; + test4.optTest = {3}; + ASSERT_TRUE(test_serde(test4)); +} + +TEST(SerdeTest, Int16) { + std::cout << "Running int16 Test\n"; + // Default Test + Int16TestMessage test1{}; + ASSERT_TRUE(test_serde(test1)); + // Optional Test + Int16TestMessage test2{}; + test2.optTest = {3}; + ASSERT_TRUE(test_serde(test2)); + // VLA Test + Int16TestMessage test3{}; + test3.vlaTest = {1, 2, 3}; + ASSERT_TRUE(test_serde(test3)); + // General Test + Int16TestMessage test4{}; + test4.test = 1; + test4.vlaTest = {1, 2, 3}; + test4.optTest = {3}; + ASSERT_TRUE(test_serde(test4)); +} + +TEST(SerdeTest, Int32) { + std::cout << "Running int32 Test\n"; + // Default Test + Int32TestMessage test1{}; + ASSERT_TRUE(test_serde(test1)); + // Optional Test + Int32TestMessage test2{}; + test2.optTest = {3}; + ASSERT_TRUE(test_serde(test2)); + // VLA Test + Int32TestMessage test3{}; + test3.vlaTest = {1, 2, 3}; + ASSERT_TRUE(test_serde(test3)); + // General Test + Int32TestMessage test4{}; + test4.test = 1; + test4.vlaTest = {1, 2, 3}; + test4.optTest = {3}; + ASSERT_TRUE(test_serde(test4)); +} + +TEST(SerdeTest, Int64) { + std::cout << "Running int64 Test\n"; + // Default Test + Int64TestMessage test1{}; + ASSERT_TRUE(test_serde(test1)); + // Optional Test + Int64TestMessage test2{}; + test2.optTest = {3}; + ASSERT_TRUE(test_serde(test2)); + // VLA Test + Int64TestMessage test3{}; + test3.vlaTest = {1, 2, 3}; + ASSERT_TRUE(test_serde(test3)); + // General Test + Int64TestMessage test4{}; + test4.test = 1; + test4.vlaTest = {1, 2, 3}; + test4.optTest = {3}; + ASSERT_TRUE(test_serde(test4)); +} + +TEST(SerdeTest, Float32) { + std::cout << "Running float32 Test\n"; + // Default Test + Float32TestMessage test1{}; + ASSERT_TRUE(test_serde(test1)); + // Optional Test + Float32TestMessage test2{}; + test2.optTest = {3.0}; + ASSERT_TRUE(test_serde(test2)); + // VLA Test + Float32TestMessage test3{}; + test3.vlaTest = {1.0, 2.0, 3.0}; + ASSERT_TRUE(test_serde(test3)); + // General Test + Float32TestMessage test4{}; + test4.test = 1.0; + test4.vlaTest = {1.0, 2.0, 3.0}; + test4.optTest = {3.0}; + ASSERT_TRUE(test_serde(test4)); +} + +TEST(SerdeTest, Float64) { + std::cout << "Running float64 Test\n"; + // Default Test + Float64TestMessage test1{}; + ASSERT_TRUE(test_serde(test1)); + // Optional Test + Float64TestMessage test2{}; + test2.optTest = {3.0}; + ASSERT_TRUE(test_serde(test2)); + // VLA Test + Float64TestMessage test3{}; + test3.vlaTest = {1.0, 2.0, 3.0}; + ASSERT_TRUE(test_serde(test3)); + // General Test + Float64TestMessage test4{}; + test4.test = 1.0; + test4.vlaTest = {1.0, 2.0, 3.0}; + test4.optTest = {3.0}; + ASSERT_TRUE(test_serde(test4)); +} + +TEST(SerdeTest, Bool) { + std::cout << "Running bool Test\n"; + // Default Test + BoolTestMessage test1{}; + ASSERT_TRUE(test_serde(test1)); + // Optional Test + BoolTestMessage test2{}; + test2.optTest = {true}; + ASSERT_TRUE(test_serde(test2)); + // VLA Test + BoolTestMessage test3{}; + test3.vlaTest = {true, false, true}; + ASSERT_TRUE(test_serde(test3)); + // General Test + BoolTestMessage test4{}; + test4.test = true; + test4.vlaTest = {false, true, false}; + test4.optTest = {true}; + ASSERT_TRUE(test_serde(test4)); +} + +TEST(SerdeTest, Transform3d) { + std::cout << "Running Transform3d Test\n"; + // Default Test + Transform3dTestMessage test1{}; + ASSERT_TRUE(test_serde(test1)); + // Optional Test + Transform3dTestMessage test2{}; + test2.optTest = {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}; + ASSERT_TRUE(test_serde(test2)); + // VLA Test + Transform3dTestMessage test3{}; + test3.vlaTest = { + {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}, + {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}, + {8_m, 2_m, 1_m, wpi::math::Rotation3d{0_deg, 1_deg, 88_deg}}}; + ASSERT_TRUE(test_serde(test3)); + // General Test + Transform3dTestMessage test4{}; + test4.test = {8_m, 2_m, 1_m, wpi::math::Rotation3d{0_deg, 1_deg, 88_deg}}; + test4.vlaTest = { + {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}, + {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}, + {8_m, 2_m, 1_m, wpi::math::Rotation3d{0_deg, 1_deg, 88_deg}}}; + test4.optTest = {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}; + ASSERT_TRUE(test_serde(test4)); +} From 646713dd22402661be2468d58b2ce47633a14178 Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Tue, 19 May 2026 12:34:45 -0400 Subject: [PATCH 12/42] refactor + regenerate messages --- .../generated/BoolTestMessageSerde.py | 2 +- .../generated/Float32TestMessageSerde.py | 2 +- .../generated/Float64TestMessageSerde.py | 2 +- .../generated/Int16TestMessageSerde.py | 2 +- .../generated/Int32TestMessageSerde.py | 2 +- .../generated/Int64TestMessageSerde.py | 2 +- .../generated/Int8TestMessageSerde.py | 2 +- .../generated/MultiTargetPNPResultSerde.py | 2 +- .../generated/Transform3dTestMessageSerde.py | 2 +- photon-serde/message_data_types.yaml | 49 +- photon-serde/messages.yaml | 2 + photon-serde/templates/Message.java.jinja | 41 +- photon-serde/templates/ThingSerde.py.jinja | 4 +- .../struct/BoolTestMessageSerde.java | 15 +- .../struct/Float32TestMessageSerde.java | 15 +- .../struct/Float64TestMessageSerde.java | 15 +- .../struct/Int16TestMessageSerde.java | 15 +- .../struct/Int32TestMessageSerde.java | 15 +- .../struct/Int64TestMessageSerde.java | 15 +- .../struct/Int8TestMessageSerde.java | 15 +- .../struct/MultiTargetPNPResultSerde.java | 9 +- .../struct/PhotonPipelineMetadataSerde.java | 9 +- .../struct/PhotonPipelineResultSerde.java | 9 +- .../struct/PhotonTrackedTargetSerde.java | 33 +- .../photonvision/struct/PnpResultSerde.java | 15 +- .../struct/TargetCornerSerde.java | 5 +- .../struct/Transform3dTestMessageSerde.java | 25 +- .../common/dataflow/structures/Packet.java | 501 ++---------------- .../org/photonvision/utils/PacketUtils.java | 128 ++--- 29 files changed, 252 insertions(+), 701 deletions(-) diff --git a/photon-lib/py/photonlibpy/generated/BoolTestMessageSerde.py b/photon-lib/py/photonlibpy/generated/BoolTestMessageSerde.py index 60da7741c9..3fed217391 100644 --- a/photon-lib/py/photonlibpy/generated/BoolTestMessageSerde.py +++ b/photon-lib/py/photonlibpy/generated/BoolTestMessageSerde.py @@ -62,7 +62,7 @@ def unpack(packet: "Packet") -> "BoolTestMessage": # test is of intrinsic type bool ret.test = packet.decodeBoolean() - # vlaTest is a custom VLA! + # vlaTest is an intrinsic VLA! ret.vlaTest = packet.decodeListShimmed(packet.decodeBoolean) # optTest is optional! it better not be a VLA too diff --git a/photon-lib/py/photonlibpy/generated/Float32TestMessageSerde.py b/photon-lib/py/photonlibpy/generated/Float32TestMessageSerde.py index 7736826024..b7fe2c4d73 100644 --- a/photon-lib/py/photonlibpy/generated/Float32TestMessageSerde.py +++ b/photon-lib/py/photonlibpy/generated/Float32TestMessageSerde.py @@ -62,7 +62,7 @@ def unpack(packet: "Packet") -> "Float32TestMessage": # test is of intrinsic type float32 ret.test = packet.decodeFloat() - # vlaTest is a custom VLA! + # vlaTest is an intrinsic VLA! ret.vlaTest = packet.decodeListShimmed(packet.decodeFloat) # optTest is optional! it better not be a VLA too diff --git a/photon-lib/py/photonlibpy/generated/Float64TestMessageSerde.py b/photon-lib/py/photonlibpy/generated/Float64TestMessageSerde.py index 945db5f1a6..1ae7d6e678 100644 --- a/photon-lib/py/photonlibpy/generated/Float64TestMessageSerde.py +++ b/photon-lib/py/photonlibpy/generated/Float64TestMessageSerde.py @@ -62,7 +62,7 @@ def unpack(packet: "Packet") -> "Float64TestMessage": # test is of intrinsic type float64 ret.test = packet.decodeDouble() - # vlaTest is a custom VLA! + # vlaTest is an intrinsic VLA! ret.vlaTest = packet.decodeListShimmed(packet.decodeDouble) # optTest is optional! it better not be a VLA too diff --git a/photon-lib/py/photonlibpy/generated/Int16TestMessageSerde.py b/photon-lib/py/photonlibpy/generated/Int16TestMessageSerde.py index 751bd4cdfb..a1b6bc8758 100644 --- a/photon-lib/py/photonlibpy/generated/Int16TestMessageSerde.py +++ b/photon-lib/py/photonlibpy/generated/Int16TestMessageSerde.py @@ -62,7 +62,7 @@ def unpack(packet: "Packet") -> "Int16TestMessage": # test is of intrinsic type int16 ret.test = packet.decode16() - # vlaTest is a custom VLA! + # vlaTest is an intrinsic VLA! ret.vlaTest = packet.decodeListShimmed(packet.decode16) # optTest is optional! it better not be a VLA too diff --git a/photon-lib/py/photonlibpy/generated/Int32TestMessageSerde.py b/photon-lib/py/photonlibpy/generated/Int32TestMessageSerde.py index ad7b8de3b2..a86fbd1ee4 100644 --- a/photon-lib/py/photonlibpy/generated/Int32TestMessageSerde.py +++ b/photon-lib/py/photonlibpy/generated/Int32TestMessageSerde.py @@ -62,7 +62,7 @@ def unpack(packet: "Packet") -> "Int32TestMessage": # test is of intrinsic type int32 ret.test = packet.decodeInt() - # vlaTest is a custom VLA! + # vlaTest is an intrinsic VLA! ret.vlaTest = packet.decodeListShimmed(packet.decodeInt) # optTest is optional! it better not be a VLA too diff --git a/photon-lib/py/photonlibpy/generated/Int64TestMessageSerde.py b/photon-lib/py/photonlibpy/generated/Int64TestMessageSerde.py index c536f23474..7c1739c0b2 100644 --- a/photon-lib/py/photonlibpy/generated/Int64TestMessageSerde.py +++ b/photon-lib/py/photonlibpy/generated/Int64TestMessageSerde.py @@ -62,7 +62,7 @@ def unpack(packet: "Packet") -> "Int64TestMessage": # test is of intrinsic type int64 ret.test = packet.decodeLong() - # vlaTest is a custom VLA! + # vlaTest is an intrinsic VLA! ret.vlaTest = packet.decodeListShimmed(packet.decodeLong) # optTest is optional! it better not be a VLA too diff --git a/photon-lib/py/photonlibpy/generated/Int8TestMessageSerde.py b/photon-lib/py/photonlibpy/generated/Int8TestMessageSerde.py index e4e7842364..5361f47e93 100644 --- a/photon-lib/py/photonlibpy/generated/Int8TestMessageSerde.py +++ b/photon-lib/py/photonlibpy/generated/Int8TestMessageSerde.py @@ -62,7 +62,7 @@ def unpack(packet: "Packet") -> "Int8TestMessage": # test is of intrinsic type int8 ret.test = packet.decode8() - # vlaTest is a custom VLA! + # vlaTest is an intrinsic VLA! ret.vlaTest = packet.decodeListShimmed(packet.decode8) # optTest is optional! it better not be a VLA too diff --git a/photon-lib/py/photonlibpy/generated/MultiTargetPNPResultSerde.py b/photon-lib/py/photonlibpy/generated/MultiTargetPNPResultSerde.py index 70ee5de786..c7192ad1f9 100644 --- a/photon-lib/py/photonlibpy/generated/MultiTargetPNPResultSerde.py +++ b/photon-lib/py/photonlibpy/generated/MultiTargetPNPResultSerde.py @@ -60,7 +60,7 @@ def unpack(packet: "Packet") -> "MultiTargetPNPResult": # estimatedPose is of non-intrinsic type PnpResult ret.estimatedPose = PnpResult.photonStruct.unpack(packet) - # fiducialIDsUsed is a custom VLA! + # fiducialIDsUsed is an intrinsic VLA! ret.fiducialIDsUsed = packet.decodeListShimmed(packet.decode16) return ret diff --git a/photon-lib/py/photonlibpy/generated/Transform3dTestMessageSerde.py b/photon-lib/py/photonlibpy/generated/Transform3dTestMessageSerde.py index 0aeaa5fc39..93b88082ed 100644 --- a/photon-lib/py/photonlibpy/generated/Transform3dTestMessageSerde.py +++ b/photon-lib/py/photonlibpy/generated/Transform3dTestMessageSerde.py @@ -61,7 +61,7 @@ def unpack(packet: "Packet") -> "Transform3dTestMessage": ret.test = packet.decodeTransform() - # vlaTest is a custom VLA! + # vlaTest is a shimmed VLA! ret.vlaTest = packet.decodeListShimmed(packet.decodeTransform) # optTest is optional! it better not be a VLA too diff --git a/photon-serde/message_data_types.yaml b/photon-serde/message_data_types.yaml index b0ea42327b..3233c74857 100644 --- a/photon-serde/message_data_types.yaml +++ b/photon-serde/message_data_types.yaml @@ -6,11 +6,8 @@ bool: java_boxed_type: Boolean cpp_type: bool java_decode_method: decodeBoolean - java_optional_decode_method: decodeBooleanOptional - java_list_decode_method: decodeBooleanList - java_encode_method: encodeBoolean - java_optional_encode_method: encodeBooleanOptional - java_list_encode_method: encodeBooleanList + java_decode_shim_ref: PacketUtils::unpackBoolean + java_encode_shim_ref: PacketUtils::packBoolean python_decode_shim: decodeBoolean python_encode_shim: encodeBoolean int8: @@ -19,11 +16,8 @@ int8: java_boxed_type: Byte cpp_type: int8_t java_decode_method: decodeByte - java_optional_decode_method: decodeByteOptional - java_list_decode_method: decodeByteList - java_encode_method: encodeByte - java_optional_encode_method: encodeByteOptional - java_list_encode_method: encodeByteList + java_decode_shim_ref: PacketUtils::unpackByte + java_encode_shim_ref: PacketUtils::packByte python_decode_shim: decode8 python_encode_shim: encode8 int16: @@ -32,11 +26,8 @@ int16: java_boxed_type: Short cpp_type: int16_t java_decode_method: decodeShort - java_optional_decode_method: decodeShortOptional - java_list_decode_method: decodeShortList - java_encode_method: encodeShort - java_optional_encode_method: encodeShortOptional - java_list_encode_method: encodeShortList + java_decode_shim_ref: PacketUtils::unpackShort + java_encode_shim_ref: PacketUtils::packShort python_decode_shim: decode16 python_encode_shim: encode16 int32: @@ -45,11 +36,8 @@ int32: java_boxed_type: Integer cpp_type: int32_t java_decode_method: decodeInt - java_optional_decode_method: decodeIntOptional - java_list_decode_method: decodeIntList - java_encode_method: encodeInt - java_optional_encode_method: encodeIntOptional - java_list_encode_method: encodeIntList + java_decode_shim_ref: PacketUtils::unpackInt + java_encode_shim_ref: PacketUtils::packInt python_decode_shim: decodeInt python_encode_shim: encodeInt int64: @@ -58,11 +46,8 @@ int64: java_boxed_type: Long cpp_type: int64_t java_decode_method: decodeLong - java_optional_decode_method: decodeLongOptional - java_list_decode_method: decodeLongList - java_encode_method: encodeLong - java_optional_encode_method: encodeLongOptional - java_list_encode_method: encodeLongList + java_decode_shim_ref: PacketUtils::unpackLong + java_encode_shim_ref: PacketUtils::packLong python_decode_shim: decodeLong python_encode_shim: encodeLong float32: @@ -71,11 +56,8 @@ float32: java_boxed_type: Float cpp_type: float java_decode_method: decodeFloat - java_optional_decode_method: decodeFloatOptional - java_list_decode_method: decodeFloatList - java_encode_method: encodeFloat - java_optional_encode_method: encodeFloatOptional - java_list_encode_method: encodeFloatList + java_decode_shim_ref: PacketUtils::unpackFloat + java_encode_shim_ref: PacketUtils::packFloat python_decode_shim: decodeFloat python_encode_shim: encodeFloat float64: @@ -84,10 +66,7 @@ float64: java_boxed_type: Double cpp_type: double java_decode_method: decodeDouble - java_optional_decode_method: decodeDoubleOptional - java_list_decode_method: decodeDoubleList - java_encode_method: encodeDouble - java_optional_encode_method: encodeDoubleOptional - java_list_encode_method: encodeDoubleList + java_decode_shim_ref: PacketUtils::unpackDouble + java_encode_shim_ref: PacketUtils::packDouble python_decode_shim: decodeDouble python_encode_shim: encodeDouble diff --git a/photon-serde/messages.yaml b/photon-serde/messages.yaml index b05cc85830..e29b39b7cc 100644 --- a/photon-serde/messages.yaml +++ b/photon-serde/messages.yaml @@ -13,7 +13,9 @@ - name: Transform3d shimmed: True java_decode_shim: PacketUtils.unpackTransform3d + java_decode_shim_ref: PacketUtils::unpackTransform3d java_encode_shim: PacketUtils.packTransform3d + java_encode_shim_ref: PacketUtils::packTransform3d cpp_type: wpi::math::Transform3d cpp_include: "" python_decode_shim: decodeTransform diff --git a/photon-serde/templates/Message.java.jinja b/photon-serde/templates/Message.java.jinja index 3789b6750b..6f5d121da2 100644 --- a/photon-serde/templates/Message.java.jinja +++ b/photon-serde/templates/Message.java.jinja @@ -61,23 +61,16 @@ public class {{ name }}Serde implements PacketSerde<{{name}}> { // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); } -{% for field in fields -%} -{%- if field.type | is_shimmed %} - // Hack because the shim is PacketUtil.[shim] not PacketUtil::[shim] - private static BiConsumer {{ field.name }}_PSINTERNALencode_shim_callable = (packet, value) -> {{ get_message_by_name(field.type).java_encode_shim }}(packet, value); - private static Function {{ field.name }}_PSINTERNALdecode_shim_callable = (packet) -> {{ get_message_by_name(field.type).java_decode_shim }}(packet); -{% endif -%} -{% endfor%} @Override public void pack(Packet packet, {{ name }} value) { {%- for field in fields -%} {%- if field.type | is_shimmed %} {%- if field.optional == True %} // {{ field.name }} is optional! it better not be a VLA too - PacketUtils.packOptional(packet, value.{{ field.name }}, {{ field.name }}_PSINTERNALencode_shim_callable); + packet.encodeOptionalImpl(value.{{ field.name }}, {{ get_message_by_name(field.type).java_encode_shim_ref }}); {%- elif field.vla == True %} - // {{ field.name }} is a custom VLA! - PacketUtils.packList(packet, value.{{ field.name }}, {{ field.name }}_PSINTERNALencode_shim_callable); + // {{ field.name }} is a shimmed VLA! + packet.encodeListImpl(value.{{ field.name }}, {{ get_message_by_name(field.type).java_encode_shim_ref }}); {%- else %} // {{ field.name }} is of shimmed type {{ field.type }} {{ get_message_by_name(field.type).java_encode_shim }}(packet, value.{{ field.name }}); @@ -85,21 +78,21 @@ public class {{ name }}Serde implements PacketSerde<{{name}}> { {%- elif field.type | is_intrinsic %} {%- if field.optional == True %} // {{ field.name }} is optional! it better not be a VLA too - packet.{{ type_map[field.type].java_optional_encode_method }}(value.{{ field.name }}); + packet.encodeOptionalImpl(value.{{ field.name }},{{ type_map[field.type].java_encode_shim_ref }}); {%- elif field.vla == True %} - // {{ field.name }} is a custom VLA! - packet.{{ type_map[field.type].java_list_encode_method }}(value.{{ field.name }}); + // {{ field.name }} is an intrinsic VLA! + packet.encodeListImpl(value.{{ field.name }},{{ type_map[field.type].java_encode_shim_ref }}); {%- else %} // field {{ field.name }} is of intrinsic type {{ field.type }} - packet.{{ type_map[field.type].java_encode_method }}(value.{{ field.name }}); + packet.encode(value.{{ field.name }}); {%- endif %} {%- else %} {%- if field.optional == True %} // {{ field.name }} is optional! it better not be a VLA too - packet.encodeOptional(value.{{ field.name }}); + packet.encodeOptionalImpl(value.{{ field.name }},{{ field.type }}.photonStruct::pack); {%- elif field.vla == True %} // {{ field.name }} is a custom VLA! - packet.encodeList(value.{{ field.name }}); + packet.encodeListImpl(value.{{ field.name }},{{ field.type }}.photonStruct::pack); {%- else %} // field {{ field.name }} is of non-intrinsic type {{ field.type }} {{ field.type }}.photonStruct.pack(packet, value.{{ field.name }}); @@ -117,10 +110,10 @@ public class {{ name }}Serde implements PacketSerde<{{name}}> { {%- if field.type | is_shimmed %} {%- if field.optional == True %} // {{ field.name }} is optional! it better not be a VLA too - ret.{{ field.name }} = PacketUtils.unpackOptional(packet, {{ field.name }}_PSINTERNALdecode_shim_callable); + ret.{{ field.name }} = packet.decodeOptionalImpl({{ get_message_by_name(field.type).java_decode_shim_ref }}); {%- elif field.vla == True %} - // {{ field.name }} is a custom VLA! - ret.{{ field.name }} = PacketUtils.unpackList(packet, {{ field.name }}_PSINTERNALdecode_shim_callable); + // {{ field.name }} is a shimmed VLA! + ret.{{ field.name }} = packet.decodeListImpl({{ get_message_by_name(field.type).java_decode_shim_ref }}); {%- else %} // {{ field.name }} is of shimmed type {{ field.type }} ret.{{ field.name }} = {{ get_message_by_name(field.type).java_decode_shim }}(packet); @@ -128,10 +121,10 @@ public class {{ name }}Serde implements PacketSerde<{{name}}> { {%- elif field.type | is_intrinsic %} {%- if field.optional == True %} // {{ field.name }} is optional! it better not be a VLA too - ret.{{ field.name }} = packet.{{ type_map[field.type].java_optional_decode_method }}(); + ret.{{ field.name }} = packet.decodeOptionalImpl({{ type_map[field.type].java_decode_shim_ref }}); {%- elif field.vla == True %} - // {{ field.name }} is a custom VLA! - ret.{{ field.name }} = packet.{{ type_map[field.type].java_list_decode_method }}(); + // {{ field.name }} is an intrinsic VLA! + ret.{{ field.name }} = packet.decodeListImpl({{ type_map[field.type].java_decode_shim_ref }}); {%- else %} // {{ field.name }} is of intrinsic type {{ field.type }} ret.{{field.name}} = packet.{{ type_map[field.type].java_decode_method }}(); @@ -139,10 +132,10 @@ public class {{ name }}Serde implements PacketSerde<{{name}}> { {%- else %} {%- if field.optional == True %} // {{ field.name }} is optional! it better not be a VLA too - ret.{{ field.name }} = packet.decodeOptional({{ field.type }}.photonStruct); + ret.{{ field.name }} = packet.decodeOptionalImpl({{ field.type }}.photonStruct::unpack); {%- elif field.vla == True %} // {{ field.name }} is a custom VLA! - ret.{{ field.name }} = packet.decodeList({{ field.type }}.photonStruct); + ret.{{ field.name }} = packet.decodeListImpl({{ field.type }}.photonStruct::unpack); {%- else %} // {{ field.name }} is of non-intrinsic type {{ field.type }} ret.{{field.name}} = {{ field.type }}.photonStruct.unpack(packet); diff --git a/photon-serde/templates/ThingSerde.py.jinja b/photon-serde/templates/ThingSerde.py.jinja index 5f562ca642..452f1bb79a 100644 --- a/photon-serde/templates/ThingSerde.py.jinja +++ b/photon-serde/templates/ThingSerde.py.jinja @@ -102,7 +102,7 @@ class {{ name }}Serde: # {{ field.name }} is optional! it better not be a VLA too ret.{{ field.name }} = packet.decodeOptionalShimmed(packet.{{ get_message_by_name(field.type).python_decode_shim }}) {%- elif field.vla == True %} - # {{ field.name }} is a custom VLA! + # {{ field.name }} is a shimmed VLA! ret.{{ field.name }} = packet.decodeListShimmed(packet.{{ get_message_by_name(field.type).python_decode_shim }}) {%- else %} ret.{{ field.name }} = packet.{{ get_message_by_name(field.type).python_decode_shim }}() @@ -112,7 +112,7 @@ class {{ name }}Serde: # {{ field.name }} is optional! it better not be a VLA too ret.{{ field.name }} = packet.decodeOptionalShimmed(packet.{{ type_map[field.type].python_decode_shim }}) {%- elif field.vla == True %} - # {{ field.name }} is a custom VLA! + # {{ field.name }} is an intrinsic VLA! ret.{{ field.name }} = packet.decodeListShimmed(packet.{{ type_map[field.type].python_decode_shim }}) {%- else %} # {{ field.name }} is of intrinsic type {{ field.type }} diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/BoolTestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/BoolTestMessageSerde.java index fa788b7724..d016b41c39 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/BoolTestMessageSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/BoolTestMessageSerde.java @@ -58,17 +58,16 @@ public int getMaxByteSize() { // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); } - @Override public void pack(Packet packet, BoolTestMessage value) { // field test is of intrinsic type bool - packet.encodeBoolean(value.test); + packet.encode(value.test); - // vlaTest is a custom VLA! - packet.encodeBooleanList(value.vlaTest); + // vlaTest is an intrinsic VLA! + packet.encodeListImpl(value.vlaTest,PacketUtils::packBoolean); // optTest is optional! it better not be a VLA too - packet.encodeBooleanOptional(value.optTest); + packet.encodeOptionalImpl(value.optTest,PacketUtils::packBoolean); } @Override @@ -78,11 +77,11 @@ public BoolTestMessage unpack(Packet packet) { // test is of intrinsic type bool ret.test = packet.decodeBoolean(); - // vlaTest is a custom VLA! - ret.vlaTest = packet.decodeBooleanList(); + // vlaTest is an intrinsic VLA! + ret.vlaTest = packet.decodeListImpl(PacketUtils::unpackBoolean); // optTest is optional! it better not be a VLA too - ret.optTest = packet.decodeBooleanOptional(); + ret.optTest = packet.decodeOptionalImpl(PacketUtils::unpackBoolean); return ret; } diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/Float32TestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/Float32TestMessageSerde.java index f1ca1d9900..e61302dd02 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/Float32TestMessageSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/Float32TestMessageSerde.java @@ -58,17 +58,16 @@ public int getMaxByteSize() { // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); } - @Override public void pack(Packet packet, Float32TestMessage value) { // field test is of intrinsic type float32 - packet.encodeFloat(value.test); + packet.encode(value.test); - // vlaTest is a custom VLA! - packet.encodeFloatList(value.vlaTest); + // vlaTest is an intrinsic VLA! + packet.encodeListImpl(value.vlaTest,PacketUtils::packFloat); // optTest is optional! it better not be a VLA too - packet.encodeFloatOptional(value.optTest); + packet.encodeOptionalImpl(value.optTest,PacketUtils::packFloat); } @Override @@ -78,11 +77,11 @@ public Float32TestMessage unpack(Packet packet) { // test is of intrinsic type float32 ret.test = packet.decodeFloat(); - // vlaTest is a custom VLA! - ret.vlaTest = packet.decodeFloatList(); + // vlaTest is an intrinsic VLA! + ret.vlaTest = packet.decodeListImpl(PacketUtils::unpackFloat); // optTest is optional! it better not be a VLA too - ret.optTest = packet.decodeFloatOptional(); + ret.optTest = packet.decodeOptionalImpl(PacketUtils::unpackFloat); return ret; } diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/Float64TestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/Float64TestMessageSerde.java index f1795625cd..e475a5ff41 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/Float64TestMessageSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/Float64TestMessageSerde.java @@ -58,17 +58,16 @@ public int getMaxByteSize() { // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); } - @Override public void pack(Packet packet, Float64TestMessage value) { // field test is of intrinsic type float64 - packet.encodeDouble(value.test); + packet.encode(value.test); - // vlaTest is a custom VLA! - packet.encodeDoubleList(value.vlaTest); + // vlaTest is an intrinsic VLA! + packet.encodeListImpl(value.vlaTest,PacketUtils::packDouble); // optTest is optional! it better not be a VLA too - packet.encodeDoubleOptional(value.optTest); + packet.encodeOptionalImpl(value.optTest,PacketUtils::packDouble); } @Override @@ -78,11 +77,11 @@ public Float64TestMessage unpack(Packet packet) { // test is of intrinsic type float64 ret.test = packet.decodeDouble(); - // vlaTest is a custom VLA! - ret.vlaTest = packet.decodeDoubleList(); + // vlaTest is an intrinsic VLA! + ret.vlaTest = packet.decodeListImpl(PacketUtils::unpackDouble); // optTest is optional! it better not be a VLA too - ret.optTest = packet.decodeDoubleOptional(); + ret.optTest = packet.decodeOptionalImpl(PacketUtils::unpackDouble); return ret; } diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/Int16TestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/Int16TestMessageSerde.java index 5ca7d921af..908134519b 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/Int16TestMessageSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/Int16TestMessageSerde.java @@ -58,17 +58,16 @@ public int getMaxByteSize() { // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); } - @Override public void pack(Packet packet, Int16TestMessage value) { // field test is of intrinsic type int16 - packet.encodeShort(value.test); + packet.encode(value.test); - // vlaTest is a custom VLA! - packet.encodeShortList(value.vlaTest); + // vlaTest is an intrinsic VLA! + packet.encodeListImpl(value.vlaTest,PacketUtils::packShort); // optTest is optional! it better not be a VLA too - packet.encodeShortOptional(value.optTest); + packet.encodeOptionalImpl(value.optTest,PacketUtils::packShort); } @Override @@ -78,11 +77,11 @@ public Int16TestMessage unpack(Packet packet) { // test is of intrinsic type int16 ret.test = packet.decodeShort(); - // vlaTest is a custom VLA! - ret.vlaTest = packet.decodeShortList(); + // vlaTest is an intrinsic VLA! + ret.vlaTest = packet.decodeListImpl(PacketUtils::unpackShort); // optTest is optional! it better not be a VLA too - ret.optTest = packet.decodeShortOptional(); + ret.optTest = packet.decodeOptionalImpl(PacketUtils::unpackShort); return ret; } diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/Int32TestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/Int32TestMessageSerde.java index 1fca3ff773..ed8ef13400 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/Int32TestMessageSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/Int32TestMessageSerde.java @@ -58,17 +58,16 @@ public int getMaxByteSize() { // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); } - @Override public void pack(Packet packet, Int32TestMessage value) { // field test is of intrinsic type int32 - packet.encodeInt(value.test); + packet.encode(value.test); - // vlaTest is a custom VLA! - packet.encodeIntList(value.vlaTest); + // vlaTest is an intrinsic VLA! + packet.encodeListImpl(value.vlaTest,PacketUtils::packInt); // optTest is optional! it better not be a VLA too - packet.encodeIntOptional(value.optTest); + packet.encodeOptionalImpl(value.optTest,PacketUtils::packInt); } @Override @@ -78,11 +77,11 @@ public Int32TestMessage unpack(Packet packet) { // test is of intrinsic type int32 ret.test = packet.decodeInt(); - // vlaTest is a custom VLA! - ret.vlaTest = packet.decodeIntList(); + // vlaTest is an intrinsic VLA! + ret.vlaTest = packet.decodeListImpl(PacketUtils::unpackInt); // optTest is optional! it better not be a VLA too - ret.optTest = packet.decodeIntOptional(); + ret.optTest = packet.decodeOptionalImpl(PacketUtils::unpackInt); return ret; } diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/Int64TestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/Int64TestMessageSerde.java index d98fcb8683..94bbef6df8 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/Int64TestMessageSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/Int64TestMessageSerde.java @@ -58,17 +58,16 @@ public int getMaxByteSize() { // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); } - @Override public void pack(Packet packet, Int64TestMessage value) { // field test is of intrinsic type int64 - packet.encodeLong(value.test); + packet.encode(value.test); - // vlaTest is a custom VLA! - packet.encodeLongList(value.vlaTest); + // vlaTest is an intrinsic VLA! + packet.encodeListImpl(value.vlaTest,PacketUtils::packLong); // optTest is optional! it better not be a VLA too - packet.encodeLongOptional(value.optTest); + packet.encodeOptionalImpl(value.optTest,PacketUtils::packLong); } @Override @@ -78,11 +77,11 @@ public Int64TestMessage unpack(Packet packet) { // test is of intrinsic type int64 ret.test = packet.decodeLong(); - // vlaTest is a custom VLA! - ret.vlaTest = packet.decodeLongList(); + // vlaTest is an intrinsic VLA! + ret.vlaTest = packet.decodeListImpl(PacketUtils::unpackLong); // optTest is optional! it better not be a VLA too - ret.optTest = packet.decodeLongOptional(); + ret.optTest = packet.decodeOptionalImpl(PacketUtils::unpackLong); return ret; } diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/Int8TestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/Int8TestMessageSerde.java index eadf7560e6..2d84615186 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/Int8TestMessageSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/Int8TestMessageSerde.java @@ -58,17 +58,16 @@ public int getMaxByteSize() { // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); } - @Override public void pack(Packet packet, Int8TestMessage value) { // field test is of intrinsic type int8 - packet.encodeByte(value.test); + packet.encode(value.test); - // vlaTest is a custom VLA! - packet.encodeByteList(value.vlaTest); + // vlaTest is an intrinsic VLA! + packet.encodeListImpl(value.vlaTest,PacketUtils::packByte); // optTest is optional! it better not be a VLA too - packet.encodeByteOptional(value.optTest); + packet.encodeOptionalImpl(value.optTest,PacketUtils::packByte); } @Override @@ -78,11 +77,11 @@ public Int8TestMessage unpack(Packet packet) { // test is of intrinsic type int8 ret.test = packet.decodeByte(); - // vlaTest is a custom VLA! - ret.vlaTest = packet.decodeByteList(); + // vlaTest is an intrinsic VLA! + ret.vlaTest = packet.decodeListImpl(PacketUtils::unpackByte); // optTest is optional! it better not be a VLA too - ret.optTest = packet.decodeByteOptional(); + ret.optTest = packet.decodeOptionalImpl(PacketUtils::unpackByte); return ret; } diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/MultiTargetPNPResultSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/MultiTargetPNPResultSerde.java index 7b7cef7de2..b2fb5f6483 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/MultiTargetPNPResultSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/MultiTargetPNPResultSerde.java @@ -58,14 +58,13 @@ public int getMaxByteSize() { // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); } - @Override public void pack(Packet packet, MultiTargetPNPResult value) { // field estimatedPose is of non-intrinsic type PnpResult PnpResult.photonStruct.pack(packet, value.estimatedPose); - // fiducialIDsUsed is a custom VLA! - packet.encodeShortList(value.fiducialIDsUsed); + // fiducialIDsUsed is an intrinsic VLA! + packet.encodeListImpl(value.fiducialIDsUsed,PacketUtils::packShort); } @Override @@ -75,8 +74,8 @@ public MultiTargetPNPResult unpack(Packet packet) { // estimatedPose is of non-intrinsic type PnpResult ret.estimatedPose = PnpResult.photonStruct.unpack(packet); - // fiducialIDsUsed is a custom VLA! - ret.fiducialIDsUsed = packet.decodeShortList(); + // fiducialIDsUsed is an intrinsic VLA! + ret.fiducialIDsUsed = packet.decodeListImpl(PacketUtils::unpackShort); return ret; } diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineMetadataSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineMetadataSerde.java index 100d545270..d60c773ced 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineMetadataSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineMetadataSerde.java @@ -58,20 +58,19 @@ public int getMaxByteSize() { // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); } - @Override public void pack(Packet packet, PhotonPipelineMetadata value) { // field sequenceID is of intrinsic type int64 - packet.encodeLong(value.sequenceID); + packet.encode(value.sequenceID); // field captureTimestampMicros is of intrinsic type int64 - packet.encodeLong(value.captureTimestampMicros); + packet.encode(value.captureTimestampMicros); // field publishTimestampMicros is of intrinsic type int64 - packet.encodeLong(value.publishTimestampMicros); + packet.encode(value.publishTimestampMicros); // field timeSinceLastPong is of intrinsic type int64 - packet.encodeLong(value.timeSinceLastPong); + packet.encode(value.timeSinceLastPong); } @Override diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java index e67c0de3f9..188feb1ff4 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java @@ -58,17 +58,16 @@ public int getMaxByteSize() { // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); } - @Override public void pack(Packet packet, PhotonPipelineResult value) { // field metadata is of non-intrinsic type PhotonPipelineMetadata PhotonPipelineMetadata.photonStruct.pack(packet, value.metadata); // targets is a custom VLA! - packet.encodeList(value.targets); + packet.encodeListImpl(value.targets,PhotonTrackedTarget.photonStruct::pack); // multitagResult is optional! it better not be a VLA too - packet.encodeOptional(value.multitagResult); + packet.encodeOptionalImpl(value.multitagResult,MultiTargetPNPResult.photonStruct::pack); } @Override @@ -79,10 +78,10 @@ public PhotonPipelineResult unpack(Packet packet) { ret.metadata = PhotonPipelineMetadata.photonStruct.unpack(packet); // targets is a custom VLA! - ret.targets = packet.decodeList(PhotonTrackedTarget.photonStruct); + ret.targets = packet.decodeListImpl(PhotonTrackedTarget.photonStruct::unpack); // multitagResult is optional! it better not be a VLA too - ret.multitagResult = packet.decodeOptional(MultiTargetPNPResult.photonStruct); + ret.multitagResult = packet.decodeOptionalImpl(MultiTargetPNPResult.photonStruct::unpack); return ret; } diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonTrackedTargetSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonTrackedTargetSerde.java index cfacc83369..aa246348c9 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonTrackedTargetSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonTrackedTargetSerde.java @@ -58,37 +58,28 @@ public int getMaxByteSize() { // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); } - - // Hack because the shim is PacketUtil.[shim] not PacketUtil::[shim] - private static BiConsumer bestCameraToTarget_PSINTERNALencode_shim_callable = (packet, value) -> PacketUtils.packTransform3d(packet, value); - private static Function bestCameraToTarget_PSINTERNALdecode_shim_callable = (packet) -> PacketUtils.unpackTransform3d(packet); - - // Hack because the shim is PacketUtil.[shim] not PacketUtil::[shim] - private static BiConsumer altCameraToTarget_PSINTERNALencode_shim_callable = (packet, value) -> PacketUtils.packTransform3d(packet, value); - private static Function altCameraToTarget_PSINTERNALdecode_shim_callable = (packet) -> PacketUtils.unpackTransform3d(packet); - @Override public void pack(Packet packet, PhotonTrackedTarget value) { // field yaw is of intrinsic type float64 - packet.encodeDouble(value.yaw); + packet.encode(value.yaw); // field pitch is of intrinsic type float64 - packet.encodeDouble(value.pitch); + packet.encode(value.pitch); // field area is of intrinsic type float64 - packet.encodeDouble(value.area); + packet.encode(value.area); // field skew is of intrinsic type float64 - packet.encodeDouble(value.skew); + packet.encode(value.skew); // field fiducialId is of intrinsic type int32 - packet.encodeInt(value.fiducialId); + packet.encode(value.fiducialId); // field objDetectId is of intrinsic type int32 - packet.encodeInt(value.objDetectId); + packet.encode(value.objDetectId); // field objDetectConf is of intrinsic type float32 - packet.encodeFloat(value.objDetectConf); + packet.encode(value.objDetectConf); // bestCameraToTarget is of shimmed type Transform3d PacketUtils.packTransform3d(packet, value.bestCameraToTarget); @@ -97,13 +88,13 @@ public void pack(Packet packet, PhotonTrackedTarget value) { PacketUtils.packTransform3d(packet, value.altCameraToTarget); // field poseAmbiguity is of intrinsic type float64 - packet.encodeDouble(value.poseAmbiguity); + packet.encode(value.poseAmbiguity); // minAreaRectCorners is a custom VLA! - packet.encodeList(value.minAreaRectCorners); + packet.encodeListImpl(value.minAreaRectCorners,TargetCorner.photonStruct::pack); // detectedCorners is a custom VLA! - packet.encodeList(value.detectedCorners); + packet.encodeListImpl(value.detectedCorners,TargetCorner.photonStruct::pack); } @Override @@ -141,10 +132,10 @@ public PhotonTrackedTarget unpack(Packet packet) { ret.poseAmbiguity = packet.decodeDouble(); // minAreaRectCorners is a custom VLA! - ret.minAreaRectCorners = packet.decodeList(TargetCorner.photonStruct); + ret.minAreaRectCorners = packet.decodeListImpl(TargetCorner.photonStruct::unpack); // detectedCorners is a custom VLA! - ret.detectedCorners = packet.decodeList(TargetCorner.photonStruct); + ret.detectedCorners = packet.decodeListImpl(TargetCorner.photonStruct::unpack); return ret; } diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/PnpResultSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/PnpResultSerde.java index fe518e586e..7917b6876e 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/PnpResultSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/PnpResultSerde.java @@ -58,15 +58,6 @@ public int getMaxByteSize() { // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); } - - // Hack because the shim is PacketUtil.[shim] not PacketUtil::[shim] - private static BiConsumer best_PSINTERNALencode_shim_callable = (packet, value) -> PacketUtils.packTransform3d(packet, value); - private static Function best_PSINTERNALdecode_shim_callable = (packet) -> PacketUtils.unpackTransform3d(packet); - - // Hack because the shim is PacketUtil.[shim] not PacketUtil::[shim] - private static BiConsumer alt_PSINTERNALencode_shim_callable = (packet, value) -> PacketUtils.packTransform3d(packet, value); - private static Function alt_PSINTERNALdecode_shim_callable = (packet) -> PacketUtils.unpackTransform3d(packet); - @Override public void pack(Packet packet, PnpResult value) { // best is of shimmed type Transform3d @@ -76,13 +67,13 @@ public void pack(Packet packet, PnpResult value) { PacketUtils.packTransform3d(packet, value.alt); // field bestReprojErr is of intrinsic type float64 - packet.encodeDouble(value.bestReprojErr); + packet.encode(value.bestReprojErr); // field altReprojErr is of intrinsic type float64 - packet.encodeDouble(value.altReprojErr); + packet.encode(value.altReprojErr); // field ambiguity is of intrinsic type float64 - packet.encodeDouble(value.ambiguity); + packet.encode(value.ambiguity); } @Override diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/TargetCornerSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/TargetCornerSerde.java index ee867ee1f0..875fdccaa4 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/TargetCornerSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/TargetCornerSerde.java @@ -58,14 +58,13 @@ public int getMaxByteSize() { // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); } - @Override public void pack(Packet packet, TargetCorner value) { // field x is of intrinsic type float64 - packet.encodeDouble(value.x); + packet.encode(value.x); // field y is of intrinsic type float64 - packet.encodeDouble(value.y); + packet.encode(value.y); } @Override diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/Transform3dTestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/Transform3dTestMessageSerde.java index 065fbf5985..24b0b6c1cc 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/Transform3dTestMessageSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/Transform3dTestMessageSerde.java @@ -58,29 +58,16 @@ public int getMaxByteSize() { // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); } - - // Hack because the shim is PacketUtil.[shim] not PacketUtil::[shim] - private static BiConsumer test_PSINTERNALencode_shim_callable = (packet, value) -> PacketUtils.packTransform3d(packet, value); - private static Function test_PSINTERNALdecode_shim_callable = (packet) -> PacketUtils.unpackTransform3d(packet); - - // Hack because the shim is PacketUtil.[shim] not PacketUtil::[shim] - private static BiConsumer vlaTest_PSINTERNALencode_shim_callable = (packet, value) -> PacketUtils.packTransform3d(packet, value); - private static Function vlaTest_PSINTERNALdecode_shim_callable = (packet) -> PacketUtils.unpackTransform3d(packet); - - // Hack because the shim is PacketUtil.[shim] not PacketUtil::[shim] - private static BiConsumer optTest_PSINTERNALencode_shim_callable = (packet, value) -> PacketUtils.packTransform3d(packet, value); - private static Function optTest_PSINTERNALdecode_shim_callable = (packet) -> PacketUtils.unpackTransform3d(packet); - @Override public void pack(Packet packet, Transform3dTestMessage value) { // test is of shimmed type Transform3d PacketUtils.packTransform3d(packet, value.test); - // vlaTest is a custom VLA! - PacketUtils.packList(packet, value.vlaTest, vlaTest_PSINTERNALencode_shim_callable); + // vlaTest is a shimmed VLA! + packet.encodeListImpl(value.vlaTest, PacketUtils::packTransform3d); // optTest is optional! it better not be a VLA too - PacketUtils.packOptional(packet, value.optTest, optTest_PSINTERNALencode_shim_callable); + packet.encodeOptionalImpl(value.optTest, PacketUtils::packTransform3d); } @Override @@ -90,11 +77,11 @@ public Transform3dTestMessage unpack(Packet packet) { // test is of shimmed type Transform3d ret.test = PacketUtils.unpackTransform3d(packet); - // vlaTest is a custom VLA! - ret.vlaTest = PacketUtils.unpackList(packet, vlaTest_PSINTERNALdecode_shim_callable); + // vlaTest is a shimmed VLA! + ret.vlaTest = packet.decodeListImpl(PacketUtils::unpackTransform3d); // optTest is optional! it better not be a VLA too - ret.optTest = PacketUtils.unpackOptional(packet, optTest_PSINTERNALdecode_shim_callable); + ret.optTest = packet.decodeOptionalImpl(PacketUtils::unpackTransform3d); return ret; } diff --git a/photon-targeting/src/main/java/org/photonvision/common/dataflow/structures/Packet.java b/photon-targeting/src/main/java/org/photonvision/common/dataflow/structures/Packet.java index 0e05a9f537..ef94632c12 100644 --- a/photon-targeting/src/main/java/org/photonvision/common/dataflow/structures/Packet.java +++ b/photon-targeting/src/main/java/org/photonvision/common/dataflow/structures/Packet.java @@ -21,6 +21,8 @@ import java.util.Arrays; import java.util.List; import java.util.Optional; +import java.util.function.BiConsumer; +import java.util.function.Function; import org.photonvision.targeting.serde.PhotonStructSerializable; /** A packet that holds byte-packed data to be sent over NetworkTables. */ @@ -151,88 +153,28 @@ private void ensureCapacity(int bytesToAdd) { * * @param src The byte to encode. */ - public void encodeByte(byte src) { + public void encode(byte src) { ensureCapacity(1); packetData[writePos++] = src; } - /** - * Encodes a VLA of bytes into the packet - * - * @param src The VLA of bytes to encode - */ - public void encodeByteList(List src) { - byte size = (byte) src.size(); - if (src.size() > Byte.MAX_VALUE) { - throw new RuntimeException("Array too long! Got " + size); - } - - encodeByte(size); - - for (var f : src) { - encodeByte(f); - } - } - - /** - * Encodes an optional byte into the packet - * - * @param src the optional byte to encode - */ - public void encodeByteOptional(Optional src) { - encodeBoolean(src.isPresent()); - if (src.isPresent()) { - encodeByte(src.get()); - } - } - /** * Encodes the short into the packet. * * @param src The short to encode. */ - public void encodeShort(short src) { + public void encode(short src) { ensureCapacity(2); packetData[writePos++] = (byte) src; packetData[writePos++] = (byte) (src >>> 8); } - /** - * Encodes a VLA of shorts into the packet - * - * @param src The VLA of shorts to encode - */ - public void encodeShortList(List src) { - byte size = (byte) src.size(); - if (src.size() > Byte.MAX_VALUE) { - throw new RuntimeException("Array too long! Got " + size); - } - - encodeByte(size); - - for (var f : src) { - encodeShort(f); - } - } - - /** - * Encodes an optional short into the packet - * - * @param src the optional short to encode - */ - public void encodeShortOptional(Optional src) { - encodeBoolean(src.isPresent()); - if (src.isPresent()) { - encodeShort(src.get()); - } - } - /** * Encodes the integer into the packet. * * @param src The integer to encode. */ - public void encodeInt(int src) { + public void encode(int src) { ensureCapacity(4); packetData[writePos++] = (byte) src; packetData[writePos++] = (byte) (src >>> 8); @@ -241,41 +183,11 @@ public void encodeInt(int src) { } /** - * Encodes a VLA of ints into the packet - * - * @param src The VLA of intsto encode - */ - public void encodeIntList(List src) { - byte size = (byte) src.size(); - if (src.size() > Byte.MAX_VALUE) { - throw new RuntimeException("Array too long! Got " + size); - } - - encodeByte(size); - - for (var f : src) { - encodeInt(f); - } - } - - /** - * Encodes an optional int into the packet - * - * @param src the optional int to encode - */ - public void encodeIntOptional(Optional src) { - encodeBoolean(src.isPresent()); - if (src.isPresent()) { - encodeInt(src.get()); - } - } - - /** - * Encodes the double into the packet. + * Encodes the long into the packet. * - * @param src The double to encode. + * @param src The long to encode. */ - public void encodeLong(long src) { + public void encode(long src) { ensureCapacity(8); packetData[writePos++] = (byte) src; packetData[writePos++] = (byte) ((src >> 8) & 0xff); @@ -287,42 +199,12 @@ public void encodeLong(long src) { packetData[writePos++] = (byte) ((src >> 56) & 0xff); } - /** - * Encodes a VLA of longs into the packet - * - * @param src The VLA of longs to encode - */ - public void encodeLongList(List src) { - byte size = (byte) src.size(); - if (src.size() > Byte.MAX_VALUE) { - throw new RuntimeException("Array too long! Got " + size); - } - - encodeByte(size); - - for (var f : src) { - encodeLong(f); - } - } - - /** - * Encodes an optional long into the packet - * - * @param src the optional long to encode - */ - public void encodeLongOptional(Optional src) { - encodeBoolean(src.isPresent()); - if (src.isPresent()) { - encodeLong(src.get()); - } - } - /** * Encodes the float into the packet. * * @param src The float to encode. */ - public void encodeFloat(float src) { + public void encode(float src) { ensureCapacity(4); int data = Float.floatToIntBits(src); packetData[writePos++] = (byte) (data & 0xff); @@ -331,42 +213,12 @@ public void encodeFloat(float src) { packetData[writePos++] = (byte) ((data >> 24) & 0xff); } - /** - * Encodes a VLA of floats into the packet - * - * @param src The VLA of floats to encode - */ - public void encodeFloatList(List src) { - byte size = (byte) src.size(); - if (src.size() > Byte.MAX_VALUE) { - throw new RuntimeException("Array too long! Got " + size); - } - - encodeByte(size); - - for (var f : src) { - encodeFloat(f); - } - } - - /** - * Encodes an optional float into the packet - * - * @param src the optional float to encode - */ - public void encodeFloatOptional(Optional src) { - encodeBoolean(src.isPresent()); - if (src.isPresent()) { - encodeFloat(src.get()); - } - } - /** * Encodes the double into the packet. * * @param src The double to encode. */ - public void encodeDouble(double src) { + public void encode(double src) { ensureCapacity(8); long data = Double.doubleToRawLongBits(src); packetData[writePos++] = (byte) (data & 0xff); @@ -379,80 +231,41 @@ public void encodeDouble(double src) { packetData[writePos++] = (byte) ((data >> 56) & 0xff); } - /** - * Encodes a VLA of doubles into the packet - * - * @param src The VLA of doubles to encode - */ - public void encodeDoubleList(List src) { - byte size = (byte) src.size(); - if (src.size() > Byte.MAX_VALUE) { - throw new RuntimeException("Array too long! Got " + size); - } - - encodeByte(size); - - for (var f : src) { - encodeDouble(f); - } - } - - /** - * Encodes an optional double into the packet - * - * @param src the optional double to encode - */ - public void encodeDoubleOptional(Optional src) { - encodeBoolean(src.isPresent()); - if (src.isPresent()) { - encodeDouble(src.get()); - } - } - /** * Encodes the boolean into the packet. * * @param src The boolean to encode. */ - public void encodeBoolean(boolean src) { + public void encode(boolean src) { ensureCapacity(1); packetData[writePos++] = src ? (byte) 1 : (byte) 0; } - /** - * Encodes a VLA of booleans into the packet - * - * @param src The VLA of booleans to encode - */ - public void encodeBooleanList(List src) { - byte size = (byte) src.size(); - if (src.size() > Byte.MAX_VALUE) { + public > void encode(T data) { + data.getSerde().pack(this, data); + } + + public void encodeListImpl(List data, BiConsumer encoder) { + byte size = (byte) data.size(); + if (data.size() > Byte.MAX_VALUE) { throw new RuntimeException("Array too long! Got " + size); } - encodeByte(size); + // length byte + encode(size); - for (var f : src) { - encodeBoolean(f); + for (var f : data) { + encoder.accept(this, f); } } - /** - * Encodes an optional boolean into the packet - * - * @param src the optional boolean to encode - */ - public void encodeBooleanOptional(Optional src) { - encodeBoolean(src.isPresent()); - if (src.isPresent()) { - encodeBoolean(src.get()); + public void encodeOptionalImpl(Optional data, BiConsumer encoder) { + encode(data.isPresent()); + if (data.isPresent()) { + encoder.accept(this, data.get()); } } - public > void encode(T data) { - data.getSerde().pack(this, data); - } - /** * Encode a list of serializable structs. Lists are stored as [uint8 length, [length many] data * structs] @@ -461,17 +274,18 @@ public > void encode(T data) { * @param data */ public > void encodeList(List data) { - byte size = (byte) data.size(); - if (data.size() > Byte.MAX_VALUE) { - throw new RuntimeException("Array too long! Got " + size); + // Hack + BiConsumer encoder; + if (data.size() > 0) { + encoder = + (packet, value) -> { + ; + }; + } else { + encoder = data.get(0).getSerde()::pack; } - // length byte - encodeByte(size); - - for (var f : data) { - f.getSerde().pack(this, f); - } + encodeListImpl(data, encoder); } /** @@ -482,10 +296,18 @@ public > void encodeList(List data) { * @param data */ public > void encodeOptional(Optional data) { - encodeBoolean(data.isPresent()); + // Hack + BiConsumer encoder; if (data.isPresent()) { - data.get().getSerde().pack(this, data.get()); + encoder = + (packet, value) -> { + ; + }; + } else { + encoder = data.get().getSerde()::pack; } + + encodeOptionalImpl(data, encoder); } /** @@ -500,37 +322,6 @@ public byte decodeByte() { return packetData[readPos++]; } - /** - * Returns a list of decoded byte from the packet - * - * @return A decoded list of byte from the packet - */ - public List decodeByteList() { - byte length = decodeByte(); - - var ret = new ArrayList(); - ret.ensureCapacity(length); - - for (int i = 0; i < length; i++) { - ret.add(decodeByte()); - } - - return ret; - } - - /** - * Returns an optional decoded byte from the packet - * - * @return A decoded optional byte from the packet - */ - public Optional decodeByteOptional() { - var present = decodeBoolean(); - if (present) { - return Optional.of(decodeByte()); - } - return Optional.empty(); - } - /** * Returns a decoded short from the packet * @@ -543,37 +334,6 @@ public short decodeShort() { return (short) ((0xff & packetData[readPos++]) | (0xff & packetData[readPos++]) << 8); } - /** - * Returns a list of decoded shorts from the packet - * - * @return A decoded list of shorts from the packet - */ - public List decodeShortList() { - byte length = decodeByte(); - - var ret = new ArrayList(); - ret.ensureCapacity(length); - - for (int i = 0; i < length; i++) { - ret.add(decodeShort()); - } - - return ret; - } - - /** - * Returns an optional decoded short from the packet - * - * @return A decoded optional short from the packet - */ - public Optional decodeShortOptional() { - var present = decodeBoolean(); - if (present) { - return Optional.of(decodeShort()); - } - return Optional.empty(); - } - /** * Returns a decoded int from the packet. * @@ -589,37 +349,6 @@ public int decodeInt() { | (0xff & packetData[readPos++]) << 24; } - /** - * Returns a list of decoded ints from the packet - * - * @return A decoded list of ints from the packet - */ - public List decodeIntList() { - byte length = decodeByte(); - - var ret = new ArrayList(); - ret.ensureCapacity(length); - - for (int i = 0; i < length; i++) { - ret.add(decodeInt()); - } - - return ret; - } - - /** - * Returns an optional decoded int from the packet - * - * @return A decoded optional int from the packet - */ - public Optional decodeIntOptional() { - var present = decodeBoolean(); - if (present) { - return Optional.of(decodeInt()); - } - return Optional.empty(); - } - public long decodeLong() { if (packetData.length < (readPos + 7)) { return 0; @@ -637,37 +366,6 @@ public long decodeLong() { return data; } - /** - * Returns a list of decoded longs from the packet - * - * @return A decoded list of longs from the packet - */ - public List decodeLongList() { - byte length = decodeByte(); - - var ret = new ArrayList(); - ret.ensureCapacity(length); - - for (int i = 0; i < length; i++) { - ret.add(decodeLong()); - } - - return ret; - } - - /** - * Returns an optional decoded long from the packet - * - * @return A decoded optional long from the packet - */ - public Optional decodeLongOptional() { - var present = decodeBoolean(); - if (present) { - return Optional.of(decodeLong()); - } - return Optional.empty(); - } - /** * Returns a decoded float from the packet. * @@ -686,37 +384,6 @@ public float decodeFloat() { return Float.intBitsToFloat(data); } - /** - * Returns a list of decoded floats from the packet - * - * @return A decoded list of floats from the packet - */ - public List decodeFloatList() { - byte length = decodeByte(); - - var ret = new ArrayList(); - ret.ensureCapacity(length); - - for (int i = 0; i < length; i++) { - ret.add(decodeFloat()); - } - - return ret; - } - - /** - * Returns an optional decoded float from the packet - * - * @return A decoded optional float from the packet - */ - public Optional decodeFloatOptional() { - var present = decodeBoolean(); - if (present) { - return Optional.of(decodeFloat()); - } - return Optional.empty(); - } - /** * Returns a decoded double from the packet. * @@ -739,37 +406,6 @@ public double decodeDouble() { return Double.longBitsToDouble(data); } - /** - * Returns a list of decoded doubles from the packet - * - * @return A decoded list of doubles from the packet - */ - public List decodeDoubleList() { - byte length = decodeByte(); - - var ret = new ArrayList(); - ret.ensureCapacity(length); - - for (int i = 0; i < length; i++) { - ret.add(decodeDouble()); - } - - return ret; - } - - /** - * Returns an optional decoded double from the packet - * - * @return A decoded optional double from the packet - */ - public Optional decodeDoubleOptional() { - var present = decodeBoolean(); - if (present) { - return Optional.of(decodeDouble()); - } - return Optional.empty(); - } - /** * Returns a decoded boolean from the packet. * @@ -782,41 +418,31 @@ public boolean decodeBoolean() { return packetData[readPos++] == 1; } - /** - * Returns a list of decoded booleans from the packet - * - * @return A decoded list of booleans from the packet - */ - public List decodeBooleanList() { + public > T decode(PhotonStructSerializable t) { + return t.getSerde().unpack(this); + } + + public List decodeListImpl(Function decoder) { byte length = decodeByte(); - var ret = new ArrayList(); + var ret = new ArrayList(); ret.ensureCapacity(length); for (int i = 0; i < length; i++) { - ret.add(decodeBoolean()); + ret.add(decoder.apply(this)); } return ret; } - /** - * Returns an optional decoded boolean from the packet - * - * @return A decoded optional boolean from the packet - */ - public Optional decodeBooleanOptional() { + public Optional decodeOptionalImpl(Function decoder) { var present = decodeBoolean(); if (present) { - return Optional.of(decodeBoolean()); + return Optional.of(decoder.apply(this)); } return Optional.empty(); } - public > T decode(PhotonStructSerializable t) { - return t.getSerde().unpack(this); - } - /** * Decode a list of serializable structs. Lists are stored as [uint8 length, [length many] data * structs]. Because java sucks, we need to take the serde ref directly @@ -825,23 +451,10 @@ public > T decode(PhotonStructSerializable * @param serde */ public > List decodeList(PacketSerde serde) { - byte length = decodeByte(); - - var ret = new ArrayList(); - ret.ensureCapacity(length); - - for (int i = 0; i < length; i++) { - ret.add(serde.unpack(this)); - } - - return ret; + return decodeListImpl(serde::unpack); } public > Optional decodeOptional(PacketSerde serde) { - var present = decodeBoolean(); - if (present) { - return Optional.of(serde.unpack(this)); - } - return Optional.empty(); + return decodeOptionalImpl(serde::unpack); } } diff --git a/photon-targeting/src/main/java/org/photonvision/utils/PacketUtils.java b/photon-targeting/src/main/java/org/photonvision/utils/PacketUtils.java index f8ff8f7581..5c29371d8b 100644 --- a/photon-targeting/src/main/java/org/photonvision/utils/PacketUtils.java +++ b/photon-targeting/src/main/java/org/photonvision/utils/PacketUtils.java @@ -17,11 +17,6 @@ package org.photonvision.utils; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.function.BiConsumer; -import java.util.function.Function; import org.photonvision.common.dataflow.structures.Packet; import org.wpilib.math.geometry.*; @@ -37,8 +32,65 @@ public class PacketUtils { public static final int POSE2D_BYTE_SIZE = TRANSLATION2D_BYTE_SIZE + ROTATION2D_BYTE_SIZE; public static final int POSE3D_BYTE_SIZE = TRANSLATION3D_BYTE_SIZE + ROTATION3D_BYTE_SIZE; + // Kinda scuffed, this is so that datatype functions have the same signature as other shims + public static void packByte(Packet packet, byte data) { + packet.encode(data); + } + + public static byte unpackByte(Packet packet) { + return packet.decodeByte(); + } + + public static void packShort(Packet packet, short data) { + packet.encode(data); + } + + public static short unpackShort(Packet packet) { + return packet.decodeShort(); + } + + public static void packInt(Packet packet, int data) { + packet.encode(data); + } + + public static int unpackInt(Packet packet) { + return packet.decodeInt(); + } + + public static void packLong(Packet packet, long data) { + packet.encode(data); + } + + public static long unpackLong(Packet packet) { + return packet.decodeLong(); + } + + public static void packFloat(Packet packet, float data) { + packet.encode(data); + } + + public static float unpackFloat(Packet packet) { + return packet.decodeFloat(); + } + + public static void packDouble(Packet packet, double data) { + packet.encode(data); + } + + public static double unpackDouble(Packet packet) { + return packet.decodeDouble(); + } + + public static void packBoolean(Packet packet, boolean data) { + packet.encode(data); + } + + public static boolean unpackBoolean(Packet packet) { + return packet.decodeBoolean(); + } + public static void packRotation2d(Packet packet, Rotation2d rotation) { - packet.encodeDouble(rotation.getRadians()); + packet.encode(rotation.getRadians()); } public static Rotation2d unpackRotation2d(Packet packet) { @@ -46,10 +98,10 @@ public static Rotation2d unpackRotation2d(Packet packet) { } public static void packQuaternion(Packet packet, Quaternion quaternion) { - packet.encodeDouble(quaternion.getW()); - packet.encodeDouble(quaternion.getX()); - packet.encodeDouble(quaternion.getY()); - packet.encodeDouble(quaternion.getZ()); + packet.encode(quaternion.getW()); + packet.encode(quaternion.getX()); + packet.encode(quaternion.getY()); + packet.encode(quaternion.getZ()); } public static Quaternion unpackQuaternion(Packet packet) { @@ -66,8 +118,8 @@ public static Rotation3d unpackRotation3d(Packet packet) { } public static void packTranslation2d(Packet packet, Translation2d translation) { - packet.encodeDouble(translation.getX()); - packet.encodeDouble(translation.getY()); + packet.encode(translation.getX()); + packet.encode(translation.getY()); } public static Translation2d unpackTranslation2d(Packet packet) { @@ -75,9 +127,9 @@ public static Translation2d unpackTranslation2d(Packet packet) { } public static void packTranslation3d(Packet packet, Translation3d translation) { - packet.encodeDouble(translation.getX()); - packet.encodeDouble(translation.getY()); - packet.encodeDouble(translation.getZ()); + packet.encode(translation.getX()); + packet.encode(translation.getY()); + packet.encode(translation.getZ()); } public static Translation3d unpackTranslation3d(Packet packet) { @@ -119,50 +171,4 @@ public static void packPose3d(Packet packet, Pose3d pose) { public static Pose3d unpackPose3d(Packet packet) { return new Pose3d(unpackTranslation3d(packet), unpackRotation3d(packet)); } - - public static void packList(Packet packet, List data, BiConsumer packer) { - byte size = (byte) data.size(); - if (data.size() > Byte.MAX_VALUE) { - throw new RuntimeException("Array too long! Got " + size); - } - - // length byte - packet.encodeByte(size); - - for (var f : data) { - packer.accept(packet, f); - } - } - - public static List unpackList(Packet packet, Function unpacker) { - byte length = packet.decodeByte(); - - var ret = new ArrayList(); - ret.ensureCapacity(length); - - for (int i = 0; i < length; i++) { - ret.add(unpacker.apply(packet)); - } - - return ret; - } - - public static void packOptional( - Packet packet, Optional optional, BiConsumer packer) { - if (optional.isPresent()) { - packet.encodeBoolean(true); - packer.accept(packet, optional.get()); - } else { - packet.encodeBoolean(false); - } - } - - public static Optional unpackOptional(Packet packet, Function unpacker) { - boolean isPresent = packet.decodeBoolean(); - if (isPresent) { - return Optional.of(unpacker.apply(packet)); - } else { - return Optional.empty(); - } - } } From 3f2739533f1669d794dac22bef064ccd327ebfb0 Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Tue, 19 May 2026 12:57:08 -0400 Subject: [PATCH 13/42] added prints to java test classes --- .../templates/ThingTestClass.java.jinja | 24 ++++++++++++++++--- .../struct/PhotonPipelineResultSerde.java | 2 +- .../targeting/BoolTestMessage.java | 19 +++++++++------ .../targeting/Float32TestMessage.java | 19 +++++++++------ .../targeting/Float64TestMessage.java | 19 +++++++++------ .../targeting/Int16TestMessage.java | 19 +++++++++------ .../targeting/Int32TestMessage.java | 19 +++++++++------ .../targeting/Int64TestMessage.java | 19 +++++++++------ .../targeting/Int8TestMessage.java | 19 +++++++++------ .../targeting/Transform3dTestMessage.java | 19 +++++++++------ .../test/java/org/photonvision/SerdeTest.java | 1 + 11 files changed, 119 insertions(+), 60 deletions(-) diff --git a/photon-serde/templates/ThingTestClass.java.jinja b/photon-serde/templates/ThingTestClass.java.jinja index 760df7d4a1..42133cdbc7 100644 --- a/photon-serde/templates/ThingTestClass.java.jinja +++ b/photon-serde/templates/ThingTestClass.java.jinja @@ -62,7 +62,7 @@ public class {{ name }} implements PhotonStructSerializable<{{ name }}> { public {{ field.type }} {{ field.name }} = new {{ field.type }}(); {%- endif %} {%- endif %} -{% endfor%} +{%- endfor%} @Override public boolean equals(Object obj) { @@ -70,7 +70,7 @@ public class {{ name }} implements PhotonStructSerializable<{{ name }}> { if (obj == null || getClass() != obj.getClass()) return false; {{ name }} other = ({{ name }}) obj; -{% for field in fields -%} +{%- for field in fields -%} {%- if field.type | is_intrinsic %} {%- if field.optional == True %} if (!this.{{ field.name }}.equals(other.{{ field.name }})) return false; @@ -82,7 +82,7 @@ public class {{ name }} implements PhotonStructSerializable<{{ name }}> { {%- else %} if (!this.{{ field.name }}.equals(other.{{ field.name }})) return false; {%- endif %} -{% endfor%} +{%- endfor %} return true; } @@ -93,4 +93,22 @@ public class {{ name }} implements PhotonStructSerializable<{{ name }}> { public PacketSerde<{{ name }}> getSerde() { return photonStruct; } + + @Override + public String toString() { + return "{{ name }} [" + {%- for field in fields -%} + {%- if loop.first %} + + "{{ field.name }}=" + {%- else %} + + ", {{ field.name }}=" + {%- endif -%} + {%- if field.type | is_intrinsic %} + + {{ field.name }} + {%- else %} + + {{ field.name }}.toString() + {%- endif -%} + {%- endfor %} + + "]"; + } } \ No newline at end of file diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java index 188feb1ff4..48da60b3ad 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java @@ -89,7 +89,7 @@ public PhotonPipelineResult unpack(Packet packet) { @Override public PacketSerde[] getNestedPhotonMessages() { return new PacketSerde[] { - PhotonPipelineMetadata.photonStruct,PhotonTrackedTarget.photonStruct,MultiTargetPNPResult.photonStruct + PhotonPipelineMetadata.photonStruct,MultiTargetPNPResult.photonStruct,PhotonTrackedTarget.photonStruct }; } diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/BoolTestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/BoolTestMessage.java index cefdab332a..d11f269a96 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/targeting/BoolTestMessage.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/targeting/BoolTestMessage.java @@ -43,25 +43,18 @@ public class BoolTestMessage implements PhotonStructSerializable { public boolean test; - public List vlaTest = List.of(); - public Optional optTest = Optional.empty(); - @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || getClass() != obj.getClass()) return false; BoolTestMessage other = (BoolTestMessage) obj; - if (this.test != other.test) return false; - if (!this.vlaTest.equals(other.vlaTest)) return false; - if (!this.optTest.equals(other.optTest)) return false; - return true; } @@ -72,4 +65,16 @@ public boolean equals(Object obj) { public PacketSerde getSerde() { return photonStruct; } + + @Override + public String toString() { + return "BoolTestMessage [" + + "test=" + + test + + ", vlaTest=" + + vlaTest + + ", optTest=" + + optTest + + "]"; + } } \ No newline at end of file diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float32TestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float32TestMessage.java index db57992556..66da4713b8 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float32TestMessage.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float32TestMessage.java @@ -43,25 +43,18 @@ public class Float32TestMessage implements PhotonStructSerializable { public float test; - public List vlaTest = List.of(); - public Optional optTest = Optional.empty(); - @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || getClass() != obj.getClass()) return false; Float32TestMessage other = (Float32TestMessage) obj; - if (this.test != other.test) return false; - if (!this.vlaTest.equals(other.vlaTest)) return false; - if (!this.optTest.equals(other.optTest)) return false; - return true; } @@ -72,4 +65,16 @@ public boolean equals(Object obj) { public PacketSerde getSerde() { return photonStruct; } + + @Override + public String toString() { + return "Float32TestMessage [" + + "test=" + + test + + ", vlaTest=" + + vlaTest + + ", optTest=" + + optTest + + "]"; + } } \ No newline at end of file diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float64TestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float64TestMessage.java index 305ef70044..04c8422d5b 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float64TestMessage.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float64TestMessage.java @@ -43,25 +43,18 @@ public class Float64TestMessage implements PhotonStructSerializable { public double test; - public List vlaTest = List.of(); - public Optional optTest = Optional.empty(); - @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || getClass() != obj.getClass()) return false; Float64TestMessage other = (Float64TestMessage) obj; - if (this.test != other.test) return false; - if (!this.vlaTest.equals(other.vlaTest)) return false; - if (!this.optTest.equals(other.optTest)) return false; - return true; } @@ -72,4 +65,16 @@ public boolean equals(Object obj) { public PacketSerde getSerde() { return photonStruct; } + + @Override + public String toString() { + return "Float64TestMessage [" + + "test=" + + test + + ", vlaTest=" + + vlaTest + + ", optTest=" + + optTest + + "]"; + } } \ No newline at end of file diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int16TestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int16TestMessage.java index 5f40f7b783..38f46f8a4b 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int16TestMessage.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int16TestMessage.java @@ -43,25 +43,18 @@ public class Int16TestMessage implements PhotonStructSerializable { public short test; - public List vlaTest = List.of(); - public Optional optTest = Optional.empty(); - @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || getClass() != obj.getClass()) return false; Int16TestMessage other = (Int16TestMessage) obj; - if (this.test != other.test) return false; - if (!this.vlaTest.equals(other.vlaTest)) return false; - if (!this.optTest.equals(other.optTest)) return false; - return true; } @@ -72,4 +65,16 @@ public boolean equals(Object obj) { public PacketSerde getSerde() { return photonStruct; } + + @Override + public String toString() { + return "Int16TestMessage [" + + "test=" + + test + + ", vlaTest=" + + vlaTest + + ", optTest=" + + optTest + + "]"; + } } \ No newline at end of file diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int32TestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int32TestMessage.java index 39e4820ce5..d3d1723099 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int32TestMessage.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int32TestMessage.java @@ -43,25 +43,18 @@ public class Int32TestMessage implements PhotonStructSerializable { public int test; - public List vlaTest = List.of(); - public Optional optTest = Optional.empty(); - @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || getClass() != obj.getClass()) return false; Int32TestMessage other = (Int32TestMessage) obj; - if (this.test != other.test) return false; - if (!this.vlaTest.equals(other.vlaTest)) return false; - if (!this.optTest.equals(other.optTest)) return false; - return true; } @@ -72,4 +65,16 @@ public boolean equals(Object obj) { public PacketSerde getSerde() { return photonStruct; } + + @Override + public String toString() { + return "Int32TestMessage [" + + "test=" + + test + + ", vlaTest=" + + vlaTest + + ", optTest=" + + optTest + + "]"; + } } \ No newline at end of file diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int64TestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int64TestMessage.java index a706e4d520..6b6859bfa1 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int64TestMessage.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int64TestMessage.java @@ -43,25 +43,18 @@ public class Int64TestMessage implements PhotonStructSerializable { public long test; - public List vlaTest = List.of(); - public Optional optTest = Optional.empty(); - @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || getClass() != obj.getClass()) return false; Int64TestMessage other = (Int64TestMessage) obj; - if (this.test != other.test) return false; - if (!this.vlaTest.equals(other.vlaTest)) return false; - if (!this.optTest.equals(other.optTest)) return false; - return true; } @@ -72,4 +65,16 @@ public boolean equals(Object obj) { public PacketSerde getSerde() { return photonStruct; } + + @Override + public String toString() { + return "Int64TestMessage [" + + "test=" + + test + + ", vlaTest=" + + vlaTest + + ", optTest=" + + optTest + + "]"; + } } \ No newline at end of file diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int8TestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int8TestMessage.java index deba66761a..b8af7c5422 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int8TestMessage.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int8TestMessage.java @@ -43,25 +43,18 @@ public class Int8TestMessage implements PhotonStructSerializable { public byte test; - public List vlaTest = List.of(); - public Optional optTest = Optional.empty(); - @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || getClass() != obj.getClass()) return false; Int8TestMessage other = (Int8TestMessage) obj; - if (this.test != other.test) return false; - if (!this.vlaTest.equals(other.vlaTest)) return false; - if (!this.optTest.equals(other.optTest)) return false; - return true; } @@ -72,4 +65,16 @@ public boolean equals(Object obj) { public PacketSerde getSerde() { return photonStruct; } + + @Override + public String toString() { + return "Int8TestMessage [" + + "test=" + + test + + ", vlaTest=" + + vlaTest + + ", optTest=" + + optTest + + "]"; + } } \ No newline at end of file diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Transform3dTestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Transform3dTestMessage.java index d034c06464..7362877940 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Transform3dTestMessage.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Transform3dTestMessage.java @@ -43,25 +43,18 @@ public class Transform3dTestMessage implements PhotonStructSerializable { public Transform3d test = new Transform3d(); - public List vlaTest = List.of(); - public Optional optTest = Optional.empty(); - @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || getClass() != obj.getClass()) return false; Transform3dTestMessage other = (Transform3dTestMessage) obj; - if (!this.test.equals(other.test)) return false; - if (!this.vlaTest.equals(other.vlaTest)) return false; - if (!this.optTest.equals(other.optTest)) return false; - return true; } @@ -72,4 +65,16 @@ public boolean equals(Object obj) { public PacketSerde getSerde() { return photonStruct; } + + @Override + public String toString() { + return "Transform3dTestMessage [" + + "test=" + + test.toString() + + ", vlaTest=" + + vlaTest.toString() + + ", optTest=" + + optTest.toString() + + "]"; + } } \ No newline at end of file diff --git a/photon-targeting/src/test/java/org/photonvision/SerdeTest.java b/photon-targeting/src/test/java/org/photonvision/SerdeTest.java index 2c9cdf32ac..5393b29314 100644 --- a/photon-targeting/src/test/java/org/photonvision/SerdeTest.java +++ b/photon-targeting/src/test/java/org/photonvision/SerdeTest.java @@ -33,6 +33,7 @@ private > boolean testSerde(T data) { var p = new Packet(10); p.encode(data); var unpackedData = p.decode(data); // kinda scuffed lowkey + System.out.println("IN: " + data.toString() + "\nOUT: " + unpackedData.toString()); return data.equals(unpackedData); } From b98076298f82bc87ced47eab2aed2726e3364f1b Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Tue, 19 May 2026 13:54:05 -0400 Subject: [PATCH 14/42] fixed potential C++ bug --- .../src/main/native/include/photon/dataflow/structures/Packet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/photon-targeting/src/main/native/include/photon/dataflow/structures/Packet.h b/photon-targeting/src/main/native/include/photon/dataflow/structures/Packet.h index 9a82001685..cceff711a4 100644 --- a/photon-targeting/src/main/native/include/photon/dataflow/structures/Packet.h +++ b/photon-targeting/src/main/native/include/photon/dataflow/structures/Packet.h @@ -176,7 +176,7 @@ class Packet { using T = vector_inner_t; Pack(value.size()); for (const auto& thing : value) { - Pack(thing); + Pack(thing); } } From 1c98b20421fc88d58c015ec7d842df027e118389 Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Tue, 19 May 2026 14:26:13 -0400 Subject: [PATCH 15/42] quick bugfix in packet.java, also started protocol documentation --- photon-serde/README.md | 8 ++++++++ .../photonvision/common/dataflow/structures/Packet.java | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/photon-serde/README.md b/photon-serde/README.md index 50777ebffb..5296fe1dd1 100644 --- a/photon-serde/README.md +++ b/photon-serde/README.md @@ -80,3 +80,11 @@ float64 poseAmbiguity; TargetCorner:16f6ac0dedc8eaccb951f4895d9e18b6[?] minAreaRectCorners; TargetCorner:16f6ac0dedc8eaccb951f4895d9e18b6[?] detectedCorners; ``` + +## Binary Protocol + +photon-serde works by decomposing every message into a few base types: these are `int8` `int16` `int32` `int64` `float32` `float64` `boolean`. These base-types are essentially copied directly into the packet. + +Shimmed messages are a special case where we need to encode/decode a type that is not part of Photonvision (e.g. WPILib types like Transform3d, Rotation2d, etc.), so we send them to a custom shim that isn't automatically generated by photon-serde + +Custom messages are essentially structs that pack \ No newline at end of file diff --git a/photon-targeting/src/main/java/org/photonvision/common/dataflow/structures/Packet.java b/photon-targeting/src/main/java/org/photonvision/common/dataflow/structures/Packet.java index ef94632c12..eadfa34f93 100644 --- a/photon-targeting/src/main/java/org/photonvision/common/dataflow/structures/Packet.java +++ b/photon-targeting/src/main/java/org/photonvision/common/dataflow/structures/Packet.java @@ -276,7 +276,7 @@ public void encodeOptionalImpl(Optional data, BiConsumer encod public > void encodeList(List data) { // Hack BiConsumer encoder; - if (data.size() > 0) { + if (data.size() < 1) { encoder = (packet, value) -> { ; From d90ada4c654a7e0ce53f1898b84ab7496f55424e Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Tue, 19 May 2026 14:28:43 -0400 Subject: [PATCH 16/42] forgot to run wpiformat award --- photon-serde/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/photon-serde/README.md b/photon-serde/README.md index 5296fe1dd1..17228f48c2 100644 --- a/photon-serde/README.md +++ b/photon-serde/README.md @@ -87,4 +87,4 @@ photon-serde works by decomposing every message into a few base types: these are Shimmed messages are a special case where we need to encode/decode a type that is not part of Photonvision (e.g. WPILib types like Transform3d, Rotation2d, etc.), so we send them to a custom shim that isn't automatically generated by photon-serde -Custom messages are essentially structs that pack \ No newline at end of file +Custom messages are essentially structs that pack From da169d8d11f7f73487845ad13c4512959cae09fa Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Tue, 19 May 2026 19:00:31 -0400 Subject: [PATCH 17/42] new java packet tests --- .../java/org/photonvision/PacketTest.java | 278 ++++++++++++++++++ 1 file changed, 278 insertions(+) diff --git a/photon-targeting/src/test/java/org/photonvision/PacketTest.java b/photon-targeting/src/test/java/org/photonvision/PacketTest.java index 725cdef4c2..6c49e8ed1e 100644 --- a/photon-targeting/src/test/java/org/photonvision/PacketTest.java +++ b/photon-targeting/src/test/java/org/photonvision/PacketTest.java @@ -161,4 +161,282 @@ public void pipelineResultSerde() { var unpackedRet3 = PhotonPipelineResult.photonStruct.unpack(p3); assertEquals(ret3, unpackedRet3); } + + public void VLASerde() { + var ret1 = + List.of( + new PhotonPipelineResult( + 1, + 2, + 3, + 1024, + List.of( + new PhotonTrackedTarget( + 3.0, + -4.0, + 9.0, + 4.0, + 2, + -1, + -1f, + new Transform3d(new Translation3d(1, 2, 3), new Rotation3d(1, 2, 3)), + new Transform3d(new Translation3d(1, 2, 3), new Rotation3d(1, 2, 3)), + 0.25, + List.of( + new TargetCorner(1, 2), + new TargetCorner(3, 4), + new TargetCorner(5, 6), + new TargetCorner(7, 8)), + List.of( + new TargetCorner(1, 2), + new TargetCorner(3, 4), + new TargetCorner(5, 6), + new TargetCorner(7, 8))), + new PhotonTrackedTarget( + 3.0, + -4.0, + 9.1, + 6.7, + 3, + -1, + -1f, + new Transform3d(new Translation3d(4, 2, 3), new Rotation3d(1, 5, 3)), + new Transform3d(new Translation3d(4, 2, 3), new Rotation3d(1, 5, 3)), + 0.25, + List.of( + new TargetCorner(1, 2), + new TargetCorner(3, 4), + new TargetCorner(5, 6), + new TargetCorner(7, 8)), + List.of( + new TargetCorner(1, 2), + new TargetCorner(3, 4), + new TargetCorner(5, 6), + new TargetCorner(7, 8))))), + new PhotonPipelineResult( + 1, + 2, + 3, + 1024, + List.of( + new PhotonTrackedTarget( + 3.0, + -4.0, + 9.0, + 4.0, + 2, + -1, + -1f, + new Transform3d(new Translation3d(1, 2, 3), new Rotation3d(1, 2, 3)), + new Transform3d(new Translation3d(1, 2, 3), new Rotation3d(1, 2, 3)), + 0.25, + List.of( + new TargetCorner(1, 2), + new TargetCorner(3, 4), + new TargetCorner(5, 6), + new TargetCorner(7, 8)), + List.of( + new TargetCorner(1, 2), + new TargetCorner(3, 4), + new TargetCorner(5, 6), + new TargetCorner(7, 8))), + new PhotonTrackedTarget( + 3.0, + -4.0, + 9.1, + 6.7, + 3, + -1, + -1f, + new Transform3d(new Translation3d(4, 2, 3), new Rotation3d(1, 5, 3)), + new Transform3d(new Translation3d(4, 2, 3), new Rotation3d(1, 5, 3)), + 0.25, + List.of( + new TargetCorner(1, 2), + new TargetCorner(3, 4), + new TargetCorner(5, 6), + new TargetCorner(7, 8)), + List.of( + new TargetCorner(1, 2), + new TargetCorner(3, 4), + new TargetCorner(5, 6), + new TargetCorner(7, 8))))), + new PhotonPipelineResult( + 1, + 2, + 3, + 1024, + List.of( + new PhotonTrackedTarget( + 3.0, + -4.0, + 9.0, + 4.0, + 2, + -1, + -1f, + new Transform3d(new Translation3d(1, 2, 3), new Rotation3d(1, 2, 3)), + new Transform3d(new Translation3d(1, 2, 3), new Rotation3d(1, 2, 3)), + 0.25, + List.of( + new TargetCorner(1, 2), + new TargetCorner(3, 4), + new TargetCorner(5, 6), + new TargetCorner(7, 8)), + List.of( + new TargetCorner(1, 2), + new TargetCorner(3, 4), + new TargetCorner(5, 6), + new TargetCorner(7, 8))), + new PhotonTrackedTarget( + 3.0, + -4.0, + 9.1, + 6.7, + 3, + -1, + -1f, + new Transform3d(new Translation3d(4, 2, 3), new Rotation3d(1, 5, 3)), + new Transform3d(new Translation3d(4, 2, 3), new Rotation3d(1, 5, 3)), + 0.25, + List.of( + new TargetCorner(1, 2), + new TargetCorner(3, 4), + new TargetCorner(5, 6), + new TargetCorner(7, 8)), + List.of( + new TargetCorner(1, 2), + new TargetCorner(3, 4), + new TargetCorner(5, 6), + new TargetCorner(7, 8)))))); + var p1 = new Packet(10); + p1.encodeList(ret1); + var unpackedRet1 = p1.decodeList(PhotonPipelineResult.photonStruct); + assertEquals(ret1, unpackedRet1); + + List ret2 = List.of(); + var p2 = new Packet(10); + p2.encodeList(ret2); + var unpackedRet2 = p2.decodeList(PhotonPipelineResult.photonStruct); + assertEquals(ret2, unpackedRet2); + } + + public void optionalSerde() { + var ret1 = + Optional.of( + new PhotonPipelineResult( + 1, + 2, + 3, + 1024, + List.of( + new PhotonTrackedTarget( + 3.0, + -4.0, + 9.0, + 4.0, + 2, + -1, + -1f, + new Transform3d(new Translation3d(1, 2, 3), new Rotation3d(1, 2, 3)), + new Transform3d(new Translation3d(1, 2, 3), new Rotation3d(1, 2, 3)), + 0.25, + List.of( + new TargetCorner(1, 2), + new TargetCorner(3, 4), + new TargetCorner(5, 6), + new TargetCorner(7, 8)), + List.of( + new TargetCorner(1, 2), + new TargetCorner(3, 4), + new TargetCorner(5, 6), + new TargetCorner(7, 8))), + new PhotonTrackedTarget( + 3.0, + -4.0, + 9.1, + 6.7, + 3, + -1, + -1f, + new Transform3d(new Translation3d(4, 2, 3), new Rotation3d(1, 5, 3)), + new Transform3d(new Translation3d(4, 2, 3), new Rotation3d(1, 5, 3)), + 0.25, + List.of( + new TargetCorner(1, 2), + new TargetCorner(3, 4), + new TargetCorner(5, 6), + new TargetCorner(7, 8)), + List.of( + new TargetCorner(1, 2), + new TargetCorner(3, 4), + new TargetCorner(5, 6), + new TargetCorner(7, 8)))))); + var p1 = new Packet(10); + p1.encodeOptional(ret1); + var unpackedRet1 = p1.decodeOptional(PhotonPipelineResult.photonStruct); + assertEquals(p1, unpackedRet1); + + Optional ret2 = Optional.empty(); + var p2 = new Packet(10); + p2.encodeOptional(ret2); + var unpackedRet2 = p2.decodeOptional(PhotonPipelineResult.photonStruct); + assertEquals(ret2, unpackedRet2); + } + + public void encodePhotonStruct() { + var ret1 = + new PhotonPipelineResult( + 1, + 2, + 3, + 1024, + List.of( + new PhotonTrackedTarget( + 3.0, + -4.0, + 9.0, + 4.0, + 2, + -1, + -1f, + new Transform3d(new Translation3d(1, 2, 3), new Rotation3d(1, 2, 3)), + new Transform3d(new Translation3d(1, 2, 3), new Rotation3d(1, 2, 3)), + 0.25, + List.of( + new TargetCorner(1, 2), + new TargetCorner(3, 4), + new TargetCorner(5, 6), + new TargetCorner(7, 8)), + List.of( + new TargetCorner(1, 2), + new TargetCorner(3, 4), + new TargetCorner(5, 6), + new TargetCorner(7, 8))), + new PhotonTrackedTarget( + 3.0, + -4.0, + 9.1, + 6.7, + 3, + -1, + -1f, + new Transform3d(new Translation3d(4, 2, 3), new Rotation3d(1, 5, 3)), + new Transform3d(new Translation3d(4, 2, 3), new Rotation3d(1, 5, 3)), + 0.25, + List.of( + new TargetCorner(1, 2), + new TargetCorner(3, 4), + new TargetCorner(5, 6), + new TargetCorner(7, 8)), + List.of( + new TargetCorner(1, 2), + new TargetCorner(3, 4), + new TargetCorner(5, 6), + new TargetCorner(7, 8))))); + var p1 = new Packet(10); + p1.encode(ret1); + var unpackedRet1 = p1.decode(ret1); + assertEquals(ret1, unpackedRet1); + } } From 35945b011546e1bd100b80f245a0500938effb8c Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Tue, 19 May 2026 21:41:41 -0400 Subject: [PATCH 18/42] protocol docs + example --- photon-serde/README.md | 135 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 132 insertions(+), 3 deletions(-) diff --git a/photon-serde/README.md b/photon-serde/README.md index 17228f48c2..93f48a76a0 100644 --- a/photon-serde/README.md +++ b/photon-serde/README.md @@ -81,10 +81,139 @@ TargetCorner:16f6ac0dedc8eaccb951f4895d9e18b6[?] minAreaRectCorners; TargetCorner:16f6ac0dedc8eaccb951f4895d9e18b6[?] detectedCorners; ``` -## Binary Protocol +## Serialization Protocol -photon-serde works by decomposing every message into a few base types: these are `int8` `int16` `int32` `int64` `float32` `float64` `boolean`. These base-types are essentially copied directly into the packet. +photon-serde works by decomposing every message into a few intrinsic types: these are `int8` `int16` `int32` `int64` `float32` `float64` `boolean`. These intrinsic types are essentially copied directly, with no special logic for ser/de. Shimmed messages are a special case where we need to encode/decode a type that is not part of Photonvision (e.g. WPILib types like Transform3d, Rotation2d, etc.), so we send them to a custom shim that isn't automatically generated by photon-serde -Custom messages are essentially structs that pack +Custom messages essentially serialize their fields next to each other in memory. Fields can either be an intrinsic type, in which it'll be copied directly, a shimmed type, in which case it'll be encoded with the corresponding shim, or a nested custom message, in which case the corresponding ser/de will be called, which will invoke the same rules on the custom type field. Any field can also be a Variable-length array, in which case the values will be stored contiguously in binary, and prepended with a length byte telling the ser/de the length of the array (and then normal ser/de rules apply to the array elements), or an Optional, in which case the value will be prepended with a boolean flag that signal whether or not the value is present. If the flag is set, the normal ser/de rules apply. Otherwise, the flag will be followed immediately by the next field or the end of the message, without any sort of sentinal or placeholder value. However, a field cannot be BOTH a vla and optional at the same time + +Custom messages are defined in the `messages.yaml` file + +### A Worked Example + +As an example of how the serde protocol works, let's consider the following messages +```yaml +--- +- name: foo +# Every message type has a unique name + fields: + - name: foo_foo + type: int32 + - name: foo_bar + type: int16 + vla: true +- name: bar +# A single yaml file can define multiple message types + fields: + - name: bar_foo + type: int32 + - name: bar_bar + type: foo + - name: bar_baz + type: foo + vla: true + - name: bar_qux + type: foo + optional: true + - name: bar_quux + type: Transform3d + # This is an example of a shimmed type, corresponding to WPILib's Transform3d. The message definition is omitted here for brevity +``` + +`foo` would be encoded as +``` +foo_foo (int32) | foo_bar size (int8) | foo_bar data (int16[]) +``` + +and `bar` would be encoded as +``` +bar_foo (int32) | bar_bar (foo) | bar_baz size (int8) | bar_baz data (foo[]) | bar_qux present (bool) | bar_qux data (foo?) | bar_quux (Transform3d) +``` +> `bar_qux data` is skipped entirely if `bar_qux present` is `false` + +Below is C-style pseudocode for a hypothetical ser/de generated from these messages (The actual implementations of photon-serde doesn't look exactly like this, but the base logic is the same) + +```c +struct foo { + int32_t foo_foo + int16_t[size] foo_bar +} + +void serialize_foo(packet& p, foo val){ + p.packInt32(val.foo_foo) + + p.packInt8(val.foo_bar size) + for (ele in val.foo_bar) { + p.packInt16(ele) + } +} + +// fields are serialized and deserialized in the same order +foo deserialize_foo(packet& p){ + foo out + + out.foo_foo p.unpackInt32() + + int8_t size = p.unpackInt8() + out.foo_bar = int16_t[size] + for (int i; i < size; i++) { + out.foo_bar[i] = p.unpackInt16() + } + + return foo +} +``` + +```c +struct bar { + int32_t bar_foo + foo bar_bar + foo[size] bar_baz + foo? bar_quz + foo bar_quuz +} + +void serialize_bar(packet& p, foo val){ + p.packInt32(val.bar_foo) + serialize_foo(p,val.bar_bar) + + p.packInt8(val.bar_baz size) + for (ele in val.bar_baz) { + serialize_foo(p,ele) + } + + p.packBool(val.bar_quz present) + if (val.bar_quz present) { + serialize_foo(p,val.bar_quz value) + } + + Transform3d_encode_shim(p,val.bar_quuz) +} + +foo deserialize_bar(packet& p){ + bar out + + out.bar_foo = p.unpackInt32() + + out.bar_bar = deserialize_foo(p) + + int8_t bar_baz size = p.unpackInt8() + out.bar_baz = int16_t[bar_baz size] + for (int i; i < bar_baz size; i++) { + out.bar_baz[i] = deserialize_foo(p) + } + + bool bar_quz present = p.unpackBool() + if (bar_quz present) { + out.bar_quz = deserialize_foo(p) + } else { + out.bar_quz = empty + } + + out.bar_quuz = Transform3d_decode_shim(p) + + return foo +} +``` From 2ea25e3d9a38166cdc10e1e8d442c185ce24409f Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Wed, 20 May 2026 01:57:15 -0400 Subject: [PATCH 19/42] updated gitignore --- .gitignore | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.gitignore b/.gitignore index 032a1d7e11..2a44d92d96 100644 --- a/.gitignore +++ b/.gitignore @@ -163,3 +163,18 @@ flake.nix flake.lock /workspace + +# photon-serde tests (Java & Cpp) +photon-targeting/src/generated/main/java/org/photonvision/targeting/ +photon-targeting/src/generated/main/java/org/photonvision/struct/test/ +photon-targeting/src/test/java/generated/ + +photon-targeting/src/generated/main/cpp/photon/serde/test/ +photon-targeting/src/generated/main/native/include/photon/targeting/ +photon-targeting/src/generated/main/native/include/photon/serde/test/ +photon-targeting/src/generated/main/native/include/photon/struct/test/ +photon-targeting/src/test/native/cpp/generated/ + +# photon-serde tests (Python) +photon-lib/py/photonlibpy/generated/test +photon-lib/py/test/generated From e931bc386b9645a18c0e3ae848a50825a36828d1 Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Mon, 25 May 2026 12:15:05 -0400 Subject: [PATCH 20/42] updated gitignore and WIP on removing test classes from repository --- .gitignore | 20 +- photon-serde/generate_messages.py | 276 +++++++++++++----- photon-serde/message_data_types.yaml | 7 + photon-serde/messages.yaml | 101 +------ photon-serde/requirements.txt | 2 + photon-serde/templates/Message.java.jinja | 4 + photon-serde/templates/ThingSerde.cpp.jinja | 9 +- photon-serde/templates/ThingSerde.py.jinja | 4 + photon-serde/templates/ThingStruct.h.jinja | 2 +- .../templates/ThingTestClass.java.jinja | 2 +- .../templates/ThingTestDataclass.py.jinja | 49 ++++ .../templates/ThingTestStruct.h.jinja | 2 +- photon-serde/test_messages.yaml | 98 +++++++ photon-serde/tests.yaml | 11 + .../targeting/BoolTestMessage.java | 80 ----- .../targeting/Float32TestMessage.java | 80 ----- .../targeting/Float64TestMessage.java | 80 ----- .../targeting/Int16TestMessage.java | 80 ----- .../targeting/Int32TestMessage.java | 80 ----- .../targeting/Int64TestMessage.java | 80 ----- .../targeting/Int8TestMessage.java | 80 ----- .../targeting/Transform3dTestMessage.java | 80 ----- .../photon/targeting/BoolTestMessage.h | 51 ---- .../photon/targeting/Float32TestMessage.h | 51 ---- .../photon/targeting/Float64TestMessage.h | 51 ---- .../photon/targeting/Int16TestMessage.h | 51 ---- .../photon/targeting/Int32TestMessage.h | 51 ---- .../photon/targeting/Int64TestMessage.h | 51 ---- .../photon/targeting/Int8TestMessage.h | 51 ---- .../photon/targeting/Transform3dTestMessage.h | 51 ---- 30 files changed, 396 insertions(+), 1239 deletions(-) create mode 100644 photon-serde/requirements.txt create mode 100644 photon-serde/templates/ThingTestDataclass.py.jinja create mode 100644 photon-serde/test_messages.yaml create mode 100644 photon-serde/tests.yaml delete mode 100644 photon-targeting/src/generated/main/java/org/photonvision/targeting/BoolTestMessage.java delete mode 100644 photon-targeting/src/generated/main/java/org/photonvision/targeting/Float32TestMessage.java delete mode 100644 photon-targeting/src/generated/main/java/org/photonvision/targeting/Float64TestMessage.java delete mode 100644 photon-targeting/src/generated/main/java/org/photonvision/targeting/Int16TestMessage.java delete mode 100644 photon-targeting/src/generated/main/java/org/photonvision/targeting/Int32TestMessage.java delete mode 100644 photon-targeting/src/generated/main/java/org/photonvision/targeting/Int64TestMessage.java delete mode 100644 photon-targeting/src/generated/main/java/org/photonvision/targeting/Int8TestMessage.java delete mode 100644 photon-targeting/src/generated/main/java/org/photonvision/targeting/Transform3dTestMessage.java delete mode 100644 photon-targeting/src/generated/main/native/include/photon/targeting/BoolTestMessage.h delete mode 100644 photon-targeting/src/generated/main/native/include/photon/targeting/Float32TestMessage.h delete mode 100644 photon-targeting/src/generated/main/native/include/photon/targeting/Float64TestMessage.h delete mode 100644 photon-targeting/src/generated/main/native/include/photon/targeting/Int16TestMessage.h delete mode 100644 photon-targeting/src/generated/main/native/include/photon/targeting/Int32TestMessage.h delete mode 100644 photon-targeting/src/generated/main/native/include/photon/targeting/Int64TestMessage.h delete mode 100644 photon-targeting/src/generated/main/native/include/photon/targeting/Int8TestMessage.h delete mode 100644 photon-targeting/src/generated/main/native/include/photon/targeting/Transform3dTestMessage.h diff --git a/.gitignore b/.gitignore index 2a44d92d96..ad0d63af7b 100644 --- a/.gitignore +++ b/.gitignore @@ -165,15 +165,17 @@ flake.lock /workspace # photon-serde tests (Java & Cpp) -photon-targeting/src/generated/main/java/org/photonvision/targeting/ -photon-targeting/src/generated/main/java/org/photonvision/struct/test/ -photon-targeting/src/test/java/generated/ - -photon-targeting/src/generated/main/cpp/photon/serde/test/ -photon-targeting/src/generated/main/native/include/photon/targeting/ -photon-targeting/src/generated/main/native/include/photon/serde/test/ -photon-targeting/src/generated/main/native/include/photon/struct/test/ -photon-targeting/src/test/native/cpp/generated/ +photon-targeting/src/generated/main/java/org/photonvision/targeting +photon-targeting/src/generated/main/java/org/photonvision/struct/test +photon-targeting/src/test/java/generated + +photon-targeting/src/generated/main/cpp/photon/serde/test +photon-targeting/src/generated/main/native/include/photon/targeting +photon-targeting/src/generated/main/native/include/photon/serde/test +photon-targeting/src/generated/main/native/cpp/photon/serde/test +photon-targeting/src/generated/main/native/include/photon/struct/test +photon-targeting/src/generated/main/native/include/photon/targeting +photon-targeting/src/test/native/cpp/generated # photon-serde tests (Python) photon-lib/py/photonlibpy/generated/test diff --git a/photon-serde/generate_messages.py b/photon-serde/generate_messages.py index 3d7dfa7a28..e725f3b739 100644 --- a/photon-serde/generate_messages.py +++ b/photon-serde/generate_messages.py @@ -23,10 +23,10 @@ import sys from pathlib import Path from typing import List, TypedDict, cast +from dataclasses import dataclass import yaml -from jinja2 import Environment, FileSystemLoader - +from jinja2 import Environment, FileSystemLoader, Template class SerdeField(TypedDict): name: str @@ -89,7 +89,7 @@ def is_shimmed(message_name: str): return is_shimmed -def get_qualified_cpp_name( +def get_cpp_qualified_name( message_db: List[MessageType], data_types, field: SerdeField ): """ @@ -113,6 +113,27 @@ def get_qualified_cpp_name( return typestr + +def get_python_qualified_name( + message_db: List[MessageType], data_types, field: SerdeField +): + """ + Get the full name of the type encoded. Eg: + list[Transform3d] + """ + + base_type = data_types[field["type"]]["python_type"] + + if "optional" in field and field["optional"] == True: + typestr = f"Optional[{base_type}]" + elif "vla" in field and field["vla"] == True: + typestr = f"List[{base_type}]" + else: + typestr = base_type + + return typestr + + def get_message_by_name(message_db: List[MessageType], message_name: str): try: return next( @@ -179,8 +200,8 @@ def get_includes(db, message: MessageType) -> str: return sorted(set(includes)) -def parse_yaml() -> List[MessageType]: - config = yaml_to_dict("messages.yaml") +def parse_yaml(message_file: str) -> List[MessageType]: + config = yaml_to_dict(message_file) return config @@ -241,9 +262,8 @@ def get_struct_schema_str(message: MessageType, message_db: List[MessageType]): return ret - def generate_photon_messages(cpp_java_root, py_root, template_root): - messages = parse_yaml() + messages = parse_yaml("messages.yaml") for message in messages: message["message_hash"] = get_message_hash(messages, message) @@ -265,16 +285,12 @@ def generate_photon_messages(cpp_java_root, py_root, template_root): "len": -1, "java_type": name, "cpp_type": "photon::" + name, + "python_type": name } java_output_dir = Path(cpp_java_root) / "main/java/org/photonvision/struct" java_output_dir.mkdir(parents=True, exist_ok=True) - java_test_class_output_dir = ( - Path(cpp_java_root) / "main/java/org/photonvision/targeting" - ) - java_test_class_output_dir.mkdir(parents=True, exist_ok=True) - cpp_serde_header_dir = Path(cpp_java_root) / "main/native/include/photon/serde/" cpp_serde_header_dir.mkdir(parents=True, exist_ok=True) cpp_serde_source_dir = Path(cpp_java_root) / "main/native/cpp/photon/serde/" @@ -283,20 +299,19 @@ def generate_photon_messages(cpp_java_root, py_root, template_root): cpp_struct_header_dir = Path(cpp_java_root) / "main/native/include/photon/struct/" cpp_struct_header_dir.mkdir(parents=True, exist_ok=True) - cpp_test_struct_output_dir = ( - Path(cpp_java_root) / "main/native/include/photon/targeting/" - ) - cpp_test_struct_output_dir.mkdir(parents=True, exist_ok=True) - py_serde_source_dir = Path(py_root) py_serde_source_dir.mkdir(parents=True, exist_ok=True) - env.filters["get_qualified_name"] = lambda field: get_qualified_cpp_name( + env.filters["get_cpp_qualified_name"] = lambda field: get_cpp_qualified_name( + messages, extended_data_types, field + ) + + env.filters["get_python_qualified_name"] = lambda field: get_python_qualified_name( messages, extended_data_types, field ) for message in messages: - # don't generate shimmed types + # don't generate shimmed types. Probably not necessa if get_shimmed_filter(messages)(message["name"]): continue @@ -323,7 +338,7 @@ def generate_photon_messages(cpp_java_root, py_root, template_root): [cpp_serde_header_name, cpp_serde_header_template, cpp_serde_header_dir], [cpp_serde_source_name, cpp_serde_source_template, cpp_serde_source_dir], [cpp_struct_header_name, cpp_struct_header_template, cpp_struct_header_dir], - [py_name, py_template, py_serde_source_dir], + [py_name, py_template, py_serde_source_dir] ]: # Hack in our message getter template.globals["get_message_by_name"] = lambda name: get_message_by_name( @@ -361,69 +376,166 @@ def generate_photon_messages(cpp_java_root, py_root, template_root): cpp_includes=get_includes(messages, message), nested_photon_types=nested_photon_types, nested_wpilib_types=nested_wpilib_types, + test=False ), encoding="utf-8", ) - if "test" in message.keys() and message["test"]: - java_test_class_name = f"{message['name']}.java" - java_test_class_template = env.get_template("ThingTestClass.java.jinja") +# TODO: code duplication +def generate_tests(cpp_java_root, py_root, template_root): + + # Generate test messages + test_messages = parse_yaml("test_messages.yaml") + real_messages = parse_yaml("messages.yaml") + message_db = test_messages + real_messages + + for message in real_messages: + message["message_hash"] = get_message_hash(real_messages, message) - cpp_test_struct_name = f"{message['name']}.h" - cpp_test_struct_template = env.get_template("ThingTestStruct.h.jinja") - for output_name, template, output_folder in [ + for test_message in test_messages: + test_message["message_hash"] = get_message_hash(message_db, message) + + env = Environment( + loader=FileSystemLoader(str(template_root)), + # autoescape=False, + # keep_trailing_newline=False, + ) + + env.filters["is_intrinsic"] = is_intrinsic_type + env.filters["is_shimmed"] = get_shimmed_filter(message_db) + + # add our custom types + extended_data_types = data_types.copy() + for message in message_db: + name = message["name"] + extended_data_types[name] = { + "len": -1, + "java_type": name, + "cpp_type": "photon::" + name, + "python_type": name + } + + java_output_dir = Path(cpp_java_root) / "main/java/org/photonvision/struct/test" + java_output_dir.mkdir(parents=True, exist_ok=True) + + java_test_class_output_dir = ( + Path(cpp_java_root) / "main/java/org/photonvision/targeting" + ) + java_test_class_output_dir.mkdir(parents=True, exist_ok=True) + + cpp_serde_header_dir = Path(cpp_java_root) / "main/native/include/photon/serde/test/" + cpp_serde_header_dir.mkdir(parents=True, exist_ok=True) + cpp_serde_source_dir = Path(cpp_java_root) / "main/native/cpp/photon/serde/test/" + cpp_serde_source_dir.mkdir(parents=True, exist_ok=True) + + cpp_struct_header_dir = Path(cpp_java_root) / "main/native/include/photon/struct/test/" + cpp_struct_header_dir.mkdir(parents=True, exist_ok=True) + + cpp_test_struct_output_dir = ( + Path(cpp_java_root) / "main/native/include/photon/targeting/" + ) + cpp_test_struct_output_dir.mkdir(parents=True, exist_ok=True) + + py_serde_source_dir = Path(py_root) / "test" + py_serde_source_dir.mkdir(parents=True, exist_ok=True) + + python_test_dataclass_output_dir = ( + Path(py_root) / "test" + ) + + env.filters["get_cpp_qualified_name"] = lambda field: get_cpp_qualified_name( + message_db, extended_data_types, field + ) + + env.filters["get_python_qualified_name"] = lambda field: get_python_qualified_name( + message_db, extended_data_types, field + ) + + for test_message in test_messages: + + # don't generate shimmed types. TODO: Probably unnecessary for test messages + if get_shimmed_filter(message_db)(test_message["name"]): + continue + + test_message = cast(MessageType, test_message) + + java_name = f"{test_message['name']}Serde.java" + cpp_serde_header_name = f"{test_message['name']}Serde.h" + cpp_serde_source_name = f"{test_message['name']}Serde.cpp" + cpp_struct_header_name = f"{test_message['name']}Struct.h" + py_name = f"{test_message['name']}Serde.py" + + java_template = env.get_template("Message.java.jinja") + + cpp_serde_header_template = env.get_template("ThingSerde.h.jinja") + cpp_serde_source_template = env.get_template("ThingSerde.cpp.jinja") + cpp_struct_header_template = env.get_template("ThingStruct.h.jinja") + + py_template = env.get_template("ThingSerde.py.jinja") + + message_hash = get_message_hash(message_db, test_message) + + java_test_class_name = f"{test_message['name']}.java" + java_test_class_template = env.get_template("ThingTestClass.java.jinja") + + cpp_test_struct_name = f"{test_message['name']}.h" + cpp_test_struct_template = env.get_template("ThingTestStruct.h.jinja") + + python_test_dataclass_name = f"{test_message['name']}.py" + python_test_dataclass_template = env.get_template("ThingTestDataclass.py.jinja") + + for output_name, template, output_folder in [ + [java_name, java_template, java_output_dir], + [cpp_serde_header_name, cpp_serde_header_template, cpp_serde_header_dir], + [cpp_serde_source_name, cpp_serde_source_template, cpp_serde_source_dir], + [cpp_struct_header_name, cpp_struct_header_template, cpp_struct_header_dir], + [py_name, py_template, py_serde_source_dir], + [java_test_class_name,java_test_class_template,java_test_class_output_dir], + [cpp_test_struct_name,cpp_test_struct_template,cpp_test_struct_output_dir], + [python_test_dataclass_name,python_test_dataclass_template,python_test_dataclass_output_dir] + ]: + # Hack in our message getter + template.globals["get_message_by_name"] = lambda name: get_message_by_name( + message_db, name + ) + + nested_photon_types = set( [ - java_test_class_name, - java_test_class_template, - java_test_class_output_dir, - ], + field["type"] + for field in test_message["fields"] + if ( + not is_intrinsic_type(field["type"]) + and not get_shimmed_filter(message_db)(field["type"]) + ) + ] + ) + nested_wpilib_types = set( [ - cpp_test_struct_name, - cpp_test_struct_template, - cpp_test_struct_output_dir, - ], - ]: - # Hack in our message getter - template.globals["get_message_by_name"] = ( - lambda name: get_message_by_name(messages, name) - ) - - # TODO: Are the nested types really necessary for ts? - nested_photon_types = set( - [ - field["type"] - for field in message["fields"] - if ( - not is_intrinsic_type(field["type"]) - and not get_shimmed_filter(messages)(field["type"]) - ) - ] - ) - nested_wpilib_types = set( - [ - field["type"] - for field in message["fields"] - if ( - not is_intrinsic_type(field["type"]) - and get_shimmed_filter(messages)(field["type"]) - ) - ] - ) - - output_file = output_folder / output_name - output_file.write_text( - template.render( - message, - type_map=extended_data_types, - message_fmt=get_struct_schema_str(message, messages), - message_hash=message_hash, - cpp_includes=get_includes(messages, message), - nested_photon_types=nested_photon_types, - nested_wpilib_types=nested_wpilib_types, - ), - encoding="utf-8", - ) + field["type"] + for field in test_message["fields"] + if ( + not is_intrinsic_type(field["type"]) + and get_shimmed_filter(message_db)(field["type"]) + ) + ] + ) + output_file = output_folder / output_name + output_file.write_text( + template.render( + test_message, + type_map=extended_data_types, + message_fmt=get_struct_schema_str(test_message, message_db), + message_hash=message_hash, + cpp_includes=get_includes(message_db, test_message), + nested_photon_types=nested_photon_types, + nested_wpilib_types=nested_wpilib_types, + test=True + ), + encoding="utf-8", + ) + + # Generate test fixtures (WIP) def main(argv): script_path = Path(__file__).resolve() @@ -448,11 +560,19 @@ def main(argv): default=dirname / "templates", type=Path, ) + parser.add_argument( + "--tests", + help="Generates tests and test messages instead of regular serde", + action="store_true" + ) args = parser.parse_args(argv) - generate_photon_messages( - args.cpp_java_output_dir, args.py_output_dir, args.template_root - ) + if (args.tests): + generate_tests(args.cpp_java_output_dir, args.py_output_dir, args.template_root) + else: + generate_photon_messages( + args.cpp_java_output_dir, args.py_output_dir, args.template_root + ) if __name__ == "__main__": diff --git a/photon-serde/message_data_types.yaml b/photon-serde/message_data_types.yaml index 3233c74857..029ea678f0 100644 --- a/photon-serde/message_data_types.yaml +++ b/photon-serde/message_data_types.yaml @@ -5,6 +5,7 @@ bool: java_type: boolean java_boxed_type: Boolean cpp_type: bool + python_type: bool java_decode_method: decodeBoolean java_decode_shim_ref: PacketUtils::unpackBoolean java_encode_shim_ref: PacketUtils::packBoolean @@ -15,6 +16,7 @@ int8: java_type: byte java_boxed_type: Byte cpp_type: int8_t + python_type: int java_decode_method: decodeByte java_decode_shim_ref: PacketUtils::unpackByte java_encode_shim_ref: PacketUtils::packByte @@ -30,11 +32,13 @@ int16: java_encode_shim_ref: PacketUtils::packShort python_decode_shim: decode16 python_encode_shim: encode16 + python_type: int int32: len: 4 java_type: int java_boxed_type: Integer cpp_type: int32_t + python_type: int java_decode_method: decodeInt java_decode_shim_ref: PacketUtils::unpackInt java_encode_shim_ref: PacketUtils::packInt @@ -45,6 +49,7 @@ int64: java_type: long java_boxed_type: Long cpp_type: int64_t + python_type: int java_decode_method: decodeLong java_decode_shim_ref: PacketUtils::unpackLong java_encode_shim_ref: PacketUtils::packLong @@ -55,6 +60,7 @@ float32: java_type: float java_boxed_type: Float cpp_type: float + python_type: float java_decode_method: decodeFloat java_decode_shim_ref: PacketUtils::unpackFloat java_encode_shim_ref: PacketUtils::packFloat @@ -65,6 +71,7 @@ float64: java_type: double java_boxed_type: Double cpp_type: double + python_type: float java_decode_method: decodeDouble java_decode_shim_ref: PacketUtils::unpackDouble java_encode_shim_ref: PacketUtils::packDouble diff --git a/photon-serde/messages.yaml b/photon-serde/messages.yaml index e29b39b7cc..7f64f65d21 100644 --- a/photon-serde/messages.yaml +++ b/photon-serde/messages.yaml @@ -18,6 +18,7 @@ java_encode_shim_ref: PacketUtils::packTransform3d cpp_type: wpi::math::Transform3d cpp_include: "" + python_import: "from wpimath.geometry import Transform3d" python_decode_shim: decodeTransform python_encode_shim: encodeTransform java_import: org.wpilib.math.geometry.Transform3d @@ -93,102 +94,4 @@ vla: True - name: multitagResult type: MultiTargetPNPResult - optional: True - -# Messages for ser/de unit tests, not actually used in dataflow -- name: Int8TestMessage - test: True - fields: - - name: test - type: int8 - - name: vlaTest - type: int8 - vla: True - - name: optTest - type: int8 - optional: True - -- name: Int16TestMessage - test: True - fields: - - name: test - type: int16 - - name: vlaTest - type: int16 - vla: True - - name: optTest - type: int16 - optional: True - -- name: Int32TestMessage - test: True - fields: - - name: test - type: int32 - - name: vlaTest - type: int32 - vla: True - - name: optTest - type: int32 - optional: True - -- name: Int64TestMessage - test: True - fields: - - name: test - type: int64 - - name: vlaTest - type: int64 - vla: True - - name: optTest - type: int64 - optional: True - -- name: Float32TestMessage - test: True - fields: - - name: test - type: float32 - - name: vlaTest - type: float32 - vla: True - - name: optTest - type: float32 - optional: True - -- name: Float64TestMessage - test: True - fields: - - name: test - type: float64 - - name: vlaTest - type: float64 - vla: True - - name: optTest - type: float64 - optional: True - -- name: BoolTestMessage - test: True - fields: - - name: test - type: bool - - name: vlaTest - type: bool - vla: True - - name: optTest - type: bool - optional: True - -# Test for shimmed ser/de -- name: Transform3dTestMessage - test: True - fields: - - name: test - type: Transform3d - - name: vlaTest - type: Transform3d - vla: True - - name: optTest - type: Transform3d - optional: True + optional: True \ No newline at end of file diff --git a/photon-serde/requirements.txt b/photon-serde/requirements.txt new file mode 100644 index 0000000000..297c616082 --- /dev/null +++ b/photon-serde/requirements.txt @@ -0,0 +1,2 @@ +yaml +jinja2 \ No newline at end of file diff --git a/photon-serde/templates/Message.java.jinja b/photon-serde/templates/Message.java.jinja index 6f5d121da2..0536c99cad 100644 --- a/photon-serde/templates/Message.java.jinja +++ b/photon-serde/templates/Message.java.jinja @@ -24,7 +24,11 @@ // THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY +{% if test %} +package org.photonvision.struct.test; +{% else %} package org.photonvision.struct; +{% endif %} import org.photonvision.common.dataflow.structures.Packet; import org.photonvision.common.dataflow.structures.PacketSerde; diff --git a/photon-serde/templates/ThingSerde.cpp.jinja b/photon-serde/templates/ThingSerde.cpp.jinja index e25214c373..068267925c 100644 --- a/photon-serde/templates/ThingSerde.cpp.jinja +++ b/photon-serde/templates/ThingSerde.cpp.jinja @@ -24,7 +24,12 @@ // THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY +{% if test %} +#include "photon/serde/test/{{ name }}Serde.h" +{% else %} #include "photon/serde/{{ name }}Serde.h" +{% endif %} + namespace photon { @@ -32,7 +37,7 @@ using StructType = SerdeType<{{ name }}>; void StructType::Pack(Packet& packet, const {{ name }}& value) { {% for field in fields -%} - packet.Pack<{{ field | get_qualified_name }}>(value.{{ field.name }}); + packet.Pack<{{ field | get_cpp_qualified_name }}>(value.{{ field.name }}); {%- if not loop.last %} {% endif -%} {% endfor %} @@ -41,7 +46,7 @@ void StructType::Pack(Packet& packet, const {{ name }}& value) { {{ name }} StructType::Unpack(Packet& packet) { return {{ name }}{ {{ name }}_PhotonStruct{ {% for field in fields -%} - .{{ field.name}} = packet.Unpack<{{ field | get_qualified_name }}>(), + .{{ field.name}} = packet.Unpack<{{ field | get_cpp_qualified_name }}>(), {%- if not loop.last %} {% endif -%} {% endfor %} diff --git a/photon-serde/templates/ThingSerde.py.jinja b/photon-serde/templates/ThingSerde.py.jinja index 452f1bb79a..667e184888 100644 --- a/photon-serde/templates/ThingSerde.py.jinja +++ b/photon-serde/templates/ThingSerde.py.jinja @@ -31,6 +31,10 @@ from typing import TYPE_CHECKING from ..packet import Packet from ..targeting import * # noqa +{% if test %} +from ..targeting.test import * +{% endif %} + if TYPE_CHECKING: {%- set ns = namespace(types=[]) -%} diff --git a/photon-serde/templates/ThingStruct.h.jinja b/photon-serde/templates/ThingStruct.h.jinja index 2ceea5e759..f79452cc0d 100644 --- a/photon-serde/templates/ThingStruct.h.jinja +++ b/photon-serde/templates/ThingStruct.h.jinja @@ -35,7 +35,7 @@ namespace photon { struct {{ name }}_PhotonStruct { {% for field in fields -%} - {{ field | get_qualified_name }} {{ field.name }}; + {{ field | get_cpp_qualified_name }} {{ field.name }}; {%- if not loop.last %} {% endif -%} {% endfor %} diff --git a/photon-serde/templates/ThingTestClass.java.jinja b/photon-serde/templates/ThingTestClass.java.jinja index 42133cdbc7..e58a1d421b 100644 --- a/photon-serde/templates/ThingTestClass.java.jinja +++ b/photon-serde/templates/ThingTestClass.java.jinja @@ -29,7 +29,7 @@ package org.photonvision.targeting; import java.util.List; import java.util.Optional; -import org.photonvision.struct.{{ name }}Serde; +import org.photonvision.struct.test.{{ name }}Serde; import org.photonvision.common.dataflow.structures.PacketSerde; import org.photonvision.targeting.serde.PhotonStructSerializable; diff --git a/photon-serde/templates/ThingTestDataclass.py.jinja b/photon-serde/templates/ThingTestDataclass.py.jinja new file mode 100644 index 0000000000..84643f1f82 --- /dev/null +++ b/photon-serde/templates/ThingTestDataclass.py.jinja @@ -0,0 +1,49 @@ +# +# MIT License +# +# Copyright (c) PhotonVision +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +############################################################################### +## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. +## --> DO NOT MODIFY <-- +############################################################################### + +from typing import TYPE_CHECKING, Optional + +from ..packet import Packet +from ..targeting import * # noqa +{% if test %} +from ..targeting.test import * +{% endif %} + +{% for type in nested_wpilib_types -%} +from {{ get_message_by_name(type).python_module }} import {{ type }} +{%- if not loop.last %},{% endif -%} +{%- endfor%} + +@dataclass +class {{ name }}: + {% for field in fields -%} + {{ field.name }}: {{ field | get_cpp_qualified_name }} + {%- if not loop.last %} + {% endif -%} +{% endfor %} diff --git a/photon-serde/templates/ThingTestStruct.h.jinja b/photon-serde/templates/ThingTestStruct.h.jinja index 8c200c9d9f..b2e6c77a91 100644 --- a/photon-serde/templates/ThingTestStruct.h.jinja +++ b/photon-serde/templates/ThingTestStruct.h.jinja @@ -26,7 +26,7 @@ // THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY -#include "photon/struct/{{ name }}Struct.h" +#include "photon/struct/test/{{ name }}Struct.h" namespace photon { /** diff --git a/photon-serde/test_messages.yaml b/photon-serde/test_messages.yaml new file mode 100644 index 0000000000..5372482868 --- /dev/null +++ b/photon-serde/test_messages.yaml @@ -0,0 +1,98 @@ +--- +# Messages for ser/de unit tests, not actually used in dataflow +- name: Int8TestMessage + test: True + fields: + - name: test + type: int8 + - name: vlaTest + type: int8 + vla: True + - name: optTest + type: int8 + optional: True + +- name: Int16TestMessage + test: True + fields: + - name: test + type: int16 + - name: vlaTest + type: int16 + vla: True + - name: optTest + type: int16 + optional: True + +- name: Int32TestMessage + test: True + fields: + - name: test + type: int32 + - name: vlaTest + type: int32 + vla: True + - name: optTest + type: int32 + optional: True + +- name: Int64TestMessage + test: True + fields: + - name: test + type: int64 + - name: vlaTest + type: int64 + vla: True + - name: optTest + type: int64 + optional: True + +- name: Float32TestMessage + test: True + fields: + - name: test + type: float32 + - name: vlaTest + type: float32 + vla: True + - name: optTest + type: float32 + optional: True + +- name: Float64TestMessage + test: True + fields: + - name: test + type: float64 + - name: vlaTest + type: float64 + vla: True + - name: optTest + type: float64 + optional: True + +- name: BoolTestMessage + test: True + fields: + - name: test + type: bool + - name: vlaTest + type: bool + vla: True + - name: optTest + type: bool + optional: True + +# Test for shimmed ser/de +- name: Transform3dTestMessage + test: True + fields: + - name: test + type: Transform3d + - name: vlaTest + type: Transform3d + vla: True + - name: optTest + type: Transform3d + optional: True diff --git a/photon-serde/tests.yaml b/photon-serde/tests.yaml new file mode 100644 index 0000000000..4d0a52446a --- /dev/null +++ b/photon-serde/tests.yaml @@ -0,0 +1,11 @@ +--- +- name: Int8Test + type: Int8TestMessage + cases: + - name: ret1 + py: Int8TestMessage() + java: new Int8TestMessage() + # We just need the brace initializer list. Ts is kinda cooked but whatever + cpp: "{}" + - name: ret2 + py: Int8TestMessage() diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/BoolTestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/BoolTestMessage.java deleted file mode 100644 index d11f269a96..0000000000 --- a/photon-targeting/src/generated/main/java/org/photonvision/targeting/BoolTestMessage.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -package org.photonvision.targeting; - -import java.util.List; -import java.util.Optional; - -import org.photonvision.struct.BoolTestMessageSerde; -import org.photonvision.common.dataflow.structures.PacketSerde; -import org.photonvision.targeting.serde.PhotonStructSerializable; - -// WPILib imports (if any) -import org.wpilib.util.struct.Struct; - - -/** - * Auto-generated ser/de test class, not intended for use in actual dataflow - */ -public class BoolTestMessage implements PhotonStructSerializable { - - public boolean test; - public List vlaTest = List.of(); - public Optional optTest = Optional.empty(); - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - - BoolTestMessage other = (BoolTestMessage) obj; - if (this.test != other.test) return false; - if (!this.vlaTest.equals(other.vlaTest)) return false; - if (!this.optTest.equals(other.optTest)) return false; - return true; - } - - /** BoolTestMessage PhotonStruct for serialization. */ - public static final BoolTestMessageSerde photonStruct = new BoolTestMessageSerde(); - - @Override - public PacketSerde getSerde() { - return photonStruct; - } - - @Override - public String toString() { - return "BoolTestMessage [" - + "test=" - + test - + ", vlaTest=" - + vlaTest - + ", optTest=" - + optTest - + "]"; - } -} \ No newline at end of file diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float32TestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float32TestMessage.java deleted file mode 100644 index 66da4713b8..0000000000 --- a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float32TestMessage.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -package org.photonvision.targeting; - -import java.util.List; -import java.util.Optional; - -import org.photonvision.struct.Float32TestMessageSerde; -import org.photonvision.common.dataflow.structures.PacketSerde; -import org.photonvision.targeting.serde.PhotonStructSerializable; - -// WPILib imports (if any) -import org.wpilib.util.struct.Struct; - - -/** - * Auto-generated ser/de test class, not intended for use in actual dataflow - */ -public class Float32TestMessage implements PhotonStructSerializable { - - public float test; - public List vlaTest = List.of(); - public Optional optTest = Optional.empty(); - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - - Float32TestMessage other = (Float32TestMessage) obj; - if (this.test != other.test) return false; - if (!this.vlaTest.equals(other.vlaTest)) return false; - if (!this.optTest.equals(other.optTest)) return false; - return true; - } - - /** Float32TestMessage PhotonStruct for serialization. */ - public static final Float32TestMessageSerde photonStruct = new Float32TestMessageSerde(); - - @Override - public PacketSerde getSerde() { - return photonStruct; - } - - @Override - public String toString() { - return "Float32TestMessage [" - + "test=" - + test - + ", vlaTest=" - + vlaTest - + ", optTest=" - + optTest - + "]"; - } -} \ No newline at end of file diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float64TestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float64TestMessage.java deleted file mode 100644 index 04c8422d5b..0000000000 --- a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Float64TestMessage.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -package org.photonvision.targeting; - -import java.util.List; -import java.util.Optional; - -import org.photonvision.struct.Float64TestMessageSerde; -import org.photonvision.common.dataflow.structures.PacketSerde; -import org.photonvision.targeting.serde.PhotonStructSerializable; - -// WPILib imports (if any) -import org.wpilib.util.struct.Struct; - - -/** - * Auto-generated ser/de test class, not intended for use in actual dataflow - */ -public class Float64TestMessage implements PhotonStructSerializable { - - public double test; - public List vlaTest = List.of(); - public Optional optTest = Optional.empty(); - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - - Float64TestMessage other = (Float64TestMessage) obj; - if (this.test != other.test) return false; - if (!this.vlaTest.equals(other.vlaTest)) return false; - if (!this.optTest.equals(other.optTest)) return false; - return true; - } - - /** Float64TestMessage PhotonStruct for serialization. */ - public static final Float64TestMessageSerde photonStruct = new Float64TestMessageSerde(); - - @Override - public PacketSerde getSerde() { - return photonStruct; - } - - @Override - public String toString() { - return "Float64TestMessage [" - + "test=" - + test - + ", vlaTest=" - + vlaTest - + ", optTest=" - + optTest - + "]"; - } -} \ No newline at end of file diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int16TestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int16TestMessage.java deleted file mode 100644 index 38f46f8a4b..0000000000 --- a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int16TestMessage.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -package org.photonvision.targeting; - -import java.util.List; -import java.util.Optional; - -import org.photonvision.struct.Int16TestMessageSerde; -import org.photonvision.common.dataflow.structures.PacketSerde; -import org.photonvision.targeting.serde.PhotonStructSerializable; - -// WPILib imports (if any) -import org.wpilib.util.struct.Struct; - - -/** - * Auto-generated ser/de test class, not intended for use in actual dataflow - */ -public class Int16TestMessage implements PhotonStructSerializable { - - public short test; - public List vlaTest = List.of(); - public Optional optTest = Optional.empty(); - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - - Int16TestMessage other = (Int16TestMessage) obj; - if (this.test != other.test) return false; - if (!this.vlaTest.equals(other.vlaTest)) return false; - if (!this.optTest.equals(other.optTest)) return false; - return true; - } - - /** Int16TestMessage PhotonStruct for serialization. */ - public static final Int16TestMessageSerde photonStruct = new Int16TestMessageSerde(); - - @Override - public PacketSerde getSerde() { - return photonStruct; - } - - @Override - public String toString() { - return "Int16TestMessage [" - + "test=" - + test - + ", vlaTest=" - + vlaTest - + ", optTest=" - + optTest - + "]"; - } -} \ No newline at end of file diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int32TestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int32TestMessage.java deleted file mode 100644 index d3d1723099..0000000000 --- a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int32TestMessage.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -package org.photonvision.targeting; - -import java.util.List; -import java.util.Optional; - -import org.photonvision.struct.Int32TestMessageSerde; -import org.photonvision.common.dataflow.structures.PacketSerde; -import org.photonvision.targeting.serde.PhotonStructSerializable; - -// WPILib imports (if any) -import org.wpilib.util.struct.Struct; - - -/** - * Auto-generated ser/de test class, not intended for use in actual dataflow - */ -public class Int32TestMessage implements PhotonStructSerializable { - - public int test; - public List vlaTest = List.of(); - public Optional optTest = Optional.empty(); - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - - Int32TestMessage other = (Int32TestMessage) obj; - if (this.test != other.test) return false; - if (!this.vlaTest.equals(other.vlaTest)) return false; - if (!this.optTest.equals(other.optTest)) return false; - return true; - } - - /** Int32TestMessage PhotonStruct for serialization. */ - public static final Int32TestMessageSerde photonStruct = new Int32TestMessageSerde(); - - @Override - public PacketSerde getSerde() { - return photonStruct; - } - - @Override - public String toString() { - return "Int32TestMessage [" - + "test=" - + test - + ", vlaTest=" - + vlaTest - + ", optTest=" - + optTest - + "]"; - } -} \ No newline at end of file diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int64TestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int64TestMessage.java deleted file mode 100644 index 6b6859bfa1..0000000000 --- a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int64TestMessage.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -package org.photonvision.targeting; - -import java.util.List; -import java.util.Optional; - -import org.photonvision.struct.Int64TestMessageSerde; -import org.photonvision.common.dataflow.structures.PacketSerde; -import org.photonvision.targeting.serde.PhotonStructSerializable; - -// WPILib imports (if any) -import org.wpilib.util.struct.Struct; - - -/** - * Auto-generated ser/de test class, not intended for use in actual dataflow - */ -public class Int64TestMessage implements PhotonStructSerializable { - - public long test; - public List vlaTest = List.of(); - public Optional optTest = Optional.empty(); - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - - Int64TestMessage other = (Int64TestMessage) obj; - if (this.test != other.test) return false; - if (!this.vlaTest.equals(other.vlaTest)) return false; - if (!this.optTest.equals(other.optTest)) return false; - return true; - } - - /** Int64TestMessage PhotonStruct for serialization. */ - public static final Int64TestMessageSerde photonStruct = new Int64TestMessageSerde(); - - @Override - public PacketSerde getSerde() { - return photonStruct; - } - - @Override - public String toString() { - return "Int64TestMessage [" - + "test=" - + test - + ", vlaTest=" - + vlaTest - + ", optTest=" - + optTest - + "]"; - } -} \ No newline at end of file diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int8TestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int8TestMessage.java deleted file mode 100644 index b8af7c5422..0000000000 --- a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Int8TestMessage.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -package org.photonvision.targeting; - -import java.util.List; -import java.util.Optional; - -import org.photonvision.struct.Int8TestMessageSerde; -import org.photonvision.common.dataflow.structures.PacketSerde; -import org.photonvision.targeting.serde.PhotonStructSerializable; - -// WPILib imports (if any) -import org.wpilib.util.struct.Struct; - - -/** - * Auto-generated ser/de test class, not intended for use in actual dataflow - */ -public class Int8TestMessage implements PhotonStructSerializable { - - public byte test; - public List vlaTest = List.of(); - public Optional optTest = Optional.empty(); - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - - Int8TestMessage other = (Int8TestMessage) obj; - if (this.test != other.test) return false; - if (!this.vlaTest.equals(other.vlaTest)) return false; - if (!this.optTest.equals(other.optTest)) return false; - return true; - } - - /** Int8TestMessage PhotonStruct for serialization. */ - public static final Int8TestMessageSerde photonStruct = new Int8TestMessageSerde(); - - @Override - public PacketSerde getSerde() { - return photonStruct; - } - - @Override - public String toString() { - return "Int8TestMessage [" - + "test=" - + test - + ", vlaTest=" - + vlaTest - + ", optTest=" - + optTest - + "]"; - } -} \ No newline at end of file diff --git a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Transform3dTestMessage.java b/photon-targeting/src/generated/main/java/org/photonvision/targeting/Transform3dTestMessage.java deleted file mode 100644 index 7362877940..0000000000 --- a/photon-targeting/src/generated/main/java/org/photonvision/targeting/Transform3dTestMessage.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -package org.photonvision.targeting; - -import java.util.List; -import java.util.Optional; - -import org.photonvision.struct.Transform3dTestMessageSerde; -import org.photonvision.common.dataflow.structures.PacketSerde; -import org.photonvision.targeting.serde.PhotonStructSerializable; - -// WPILib imports (if any) -import org.wpilib.util.struct.Struct; -import org.wpilib.math.geometry.Transform3d; - -/** - * Auto-generated ser/de test class, not intended for use in actual dataflow - */ -public class Transform3dTestMessage implements PhotonStructSerializable { - - public Transform3d test = new Transform3d(); - public List vlaTest = List.of(); - public Optional optTest = Optional.empty(); - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - - Transform3dTestMessage other = (Transform3dTestMessage) obj; - if (!this.test.equals(other.test)) return false; - if (!this.vlaTest.equals(other.vlaTest)) return false; - if (!this.optTest.equals(other.optTest)) return false; - return true; - } - - /** Transform3dTestMessage PhotonStruct for serialization. */ - public static final Transform3dTestMessageSerde photonStruct = new Transform3dTestMessageSerde(); - - @Override - public PacketSerde getSerde() { - return photonStruct; - } - - @Override - public String toString() { - return "Transform3dTestMessage [" - + "test=" - + test.toString() - + ", vlaTest=" - + vlaTest.toString() - + ", optTest=" - + optTest.toString() - + "]"; - } -} \ No newline at end of file diff --git a/photon-targeting/src/generated/main/native/include/photon/targeting/BoolTestMessage.h b/photon-targeting/src/generated/main/native/include/photon/targeting/BoolTestMessage.h deleted file mode 100644 index ae7b782c59..0000000000 --- a/photon-targeting/src/generated/main/native/include/photon/targeting/BoolTestMessage.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -#include "photon/struct/BoolTestMessageStruct.h" - -namespace photon { -/** - * Auto-generated ser/de test class, not intended for use in actual dataflow - */ -class BoolTestMessage : public BoolTestMessage_PhotonStruct { - using Base = BoolTestMessage_PhotonStruct; - -public: - BoolTestMessage() = default; - - explicit BoolTestMessage(Base&& data) : Base(data) {} - - template - explicit BoolTestMessage(Args&&... args) - : Base{std::forward(args)...} {} - - friend bool operator==(BoolTestMessage const&, BoolTestMessage const&) = default; -}; -} // namespace photon - -#include "photon/serde/BoolTestMessageSerde.h" \ No newline at end of file diff --git a/photon-targeting/src/generated/main/native/include/photon/targeting/Float32TestMessage.h b/photon-targeting/src/generated/main/native/include/photon/targeting/Float32TestMessage.h deleted file mode 100644 index f020bb63ee..0000000000 --- a/photon-targeting/src/generated/main/native/include/photon/targeting/Float32TestMessage.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -#include "photon/struct/Float32TestMessageStruct.h" - -namespace photon { -/** - * Auto-generated ser/de test class, not intended for use in actual dataflow - */ -class Float32TestMessage : public Float32TestMessage_PhotonStruct { - using Base = Float32TestMessage_PhotonStruct; - -public: - Float32TestMessage() = default; - - explicit Float32TestMessage(Base&& data) : Base(data) {} - - template - explicit Float32TestMessage(Args&&... args) - : Base{std::forward(args)...} {} - - friend bool operator==(Float32TestMessage const&, Float32TestMessage const&) = default; -}; -} // namespace photon - -#include "photon/serde/Float32TestMessageSerde.h" \ No newline at end of file diff --git a/photon-targeting/src/generated/main/native/include/photon/targeting/Float64TestMessage.h b/photon-targeting/src/generated/main/native/include/photon/targeting/Float64TestMessage.h deleted file mode 100644 index 79d80fd45b..0000000000 --- a/photon-targeting/src/generated/main/native/include/photon/targeting/Float64TestMessage.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -#include "photon/struct/Float64TestMessageStruct.h" - -namespace photon { -/** - * Auto-generated ser/de test class, not intended for use in actual dataflow - */ -class Float64TestMessage : public Float64TestMessage_PhotonStruct { - using Base = Float64TestMessage_PhotonStruct; - -public: - Float64TestMessage() = default; - - explicit Float64TestMessage(Base&& data) : Base(data) {} - - template - explicit Float64TestMessage(Args&&... args) - : Base{std::forward(args)...} {} - - friend bool operator==(Float64TestMessage const&, Float64TestMessage const&) = default; -}; -} // namespace photon - -#include "photon/serde/Float64TestMessageSerde.h" \ No newline at end of file diff --git a/photon-targeting/src/generated/main/native/include/photon/targeting/Int16TestMessage.h b/photon-targeting/src/generated/main/native/include/photon/targeting/Int16TestMessage.h deleted file mode 100644 index a05168af30..0000000000 --- a/photon-targeting/src/generated/main/native/include/photon/targeting/Int16TestMessage.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -#include "photon/struct/Int16TestMessageStruct.h" - -namespace photon { -/** - * Auto-generated ser/de test class, not intended for use in actual dataflow - */ -class Int16TestMessage : public Int16TestMessage_PhotonStruct { - using Base = Int16TestMessage_PhotonStruct; - -public: - Int16TestMessage() = default; - - explicit Int16TestMessage(Base&& data) : Base(data) {} - - template - explicit Int16TestMessage(Args&&... args) - : Base{std::forward(args)...} {} - - friend bool operator==(Int16TestMessage const&, Int16TestMessage const&) = default; -}; -} // namespace photon - -#include "photon/serde/Int16TestMessageSerde.h" \ No newline at end of file diff --git a/photon-targeting/src/generated/main/native/include/photon/targeting/Int32TestMessage.h b/photon-targeting/src/generated/main/native/include/photon/targeting/Int32TestMessage.h deleted file mode 100644 index d5df8c6063..0000000000 --- a/photon-targeting/src/generated/main/native/include/photon/targeting/Int32TestMessage.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -#include "photon/struct/Int32TestMessageStruct.h" - -namespace photon { -/** - * Auto-generated ser/de test class, not intended for use in actual dataflow - */ -class Int32TestMessage : public Int32TestMessage_PhotonStruct { - using Base = Int32TestMessage_PhotonStruct; - -public: - Int32TestMessage() = default; - - explicit Int32TestMessage(Base&& data) : Base(data) {} - - template - explicit Int32TestMessage(Args&&... args) - : Base{std::forward(args)...} {} - - friend bool operator==(Int32TestMessage const&, Int32TestMessage const&) = default; -}; -} // namespace photon - -#include "photon/serde/Int32TestMessageSerde.h" \ No newline at end of file diff --git a/photon-targeting/src/generated/main/native/include/photon/targeting/Int64TestMessage.h b/photon-targeting/src/generated/main/native/include/photon/targeting/Int64TestMessage.h deleted file mode 100644 index 9df6fa7fee..0000000000 --- a/photon-targeting/src/generated/main/native/include/photon/targeting/Int64TestMessage.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -#include "photon/struct/Int64TestMessageStruct.h" - -namespace photon { -/** - * Auto-generated ser/de test class, not intended for use in actual dataflow - */ -class Int64TestMessage : public Int64TestMessage_PhotonStruct { - using Base = Int64TestMessage_PhotonStruct; - -public: - Int64TestMessage() = default; - - explicit Int64TestMessage(Base&& data) : Base(data) {} - - template - explicit Int64TestMessage(Args&&... args) - : Base{std::forward(args)...} {} - - friend bool operator==(Int64TestMessage const&, Int64TestMessage const&) = default; -}; -} // namespace photon - -#include "photon/serde/Int64TestMessageSerde.h" \ No newline at end of file diff --git a/photon-targeting/src/generated/main/native/include/photon/targeting/Int8TestMessage.h b/photon-targeting/src/generated/main/native/include/photon/targeting/Int8TestMessage.h deleted file mode 100644 index d7e9e3c3ea..0000000000 --- a/photon-targeting/src/generated/main/native/include/photon/targeting/Int8TestMessage.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -#include "photon/struct/Int8TestMessageStruct.h" - -namespace photon { -/** - * Auto-generated ser/de test class, not intended for use in actual dataflow - */ -class Int8TestMessage : public Int8TestMessage_PhotonStruct { - using Base = Int8TestMessage_PhotonStruct; - -public: - Int8TestMessage() = default; - - explicit Int8TestMessage(Base&& data) : Base(data) {} - - template - explicit Int8TestMessage(Args&&... args) - : Base{std::forward(args)...} {} - - friend bool operator==(Int8TestMessage const&, Int8TestMessage const&) = default; -}; -} // namespace photon - -#include "photon/serde/Int8TestMessageSerde.h" \ No newline at end of file diff --git a/photon-targeting/src/generated/main/native/include/photon/targeting/Transform3dTestMessage.h b/photon-targeting/src/generated/main/native/include/photon/targeting/Transform3dTestMessage.h deleted file mode 100644 index 1b12f52678..0000000000 --- a/photon-targeting/src/generated/main/native/include/photon/targeting/Transform3dTestMessage.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -#include "photon/struct/Transform3dTestMessageStruct.h" - -namespace photon { -/** - * Auto-generated ser/de test class, not intended for use in actual dataflow - */ -class Transform3dTestMessage : public Transform3dTestMessage_PhotonStruct { - using Base = Transform3dTestMessage_PhotonStruct; - -public: - Transform3dTestMessage() = default; - - explicit Transform3dTestMessage(Base&& data) : Base(data) {} - - template - explicit Transform3dTestMessage(Args&&... args) - : Base{std::forward(args)...} {} - - friend bool operator==(Transform3dTestMessage const&, Transform3dTestMessage const&) = default; -}; -} // namespace photon - -#include "photon/serde/Transform3dTestMessageSerde.h" \ No newline at end of file From b1e47eca8dd00ff8706a99c169ca827c745973b6 Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Mon, 25 May 2026 12:23:34 -0400 Subject: [PATCH 21/42] Deleted old test classes, CI will break because the fixture is still present --- .../struct/BoolTestMessageSerde.java | 102 ------------------ .../struct/Float32TestMessageSerde.java | 102 ------------------ .../struct/Float64TestMessageSerde.java | 102 ------------------ .../struct/Int16TestMessageSerde.java | 102 ------------------ .../struct/Int32TestMessageSerde.java | 102 ------------------ .../struct/Int64TestMessageSerde.java | 102 ------------------ .../struct/Int8TestMessageSerde.java | 102 ------------------ .../struct/Transform3dTestMessageSerde.java | 102 ------------------ .../cpp/photon/serde/BoolTestMessageSerde.cpp | 47 -------- .../photon/serde/Float32TestMessageSerde.cpp | 47 -------- .../photon/serde/Float64TestMessageSerde.cpp | 47 -------- .../photon/serde/Int16TestMessageSerde.cpp | 47 -------- .../photon/serde/Int32TestMessageSerde.cpp | 47 -------- .../photon/serde/Int64TestMessageSerde.cpp | 47 -------- .../cpp/photon/serde/Int8TestMessageSerde.cpp | 47 -------- .../serde/Transform3dTestMessageSerde.cpp | 47 -------- .../photon/serde/BoolTestMessageSerde.h | 59 ---------- .../photon/serde/Float32TestMessageSerde.h | 59 ---------- .../photon/serde/Float64TestMessageSerde.h | 59 ---------- .../photon/serde/Int16TestMessageSerde.h | 59 ---------- .../photon/serde/Int32TestMessageSerde.h | 59 ---------- .../photon/serde/Int64TestMessageSerde.h | 59 ---------- .../photon/serde/Int8TestMessageSerde.h | 59 ---------- .../serde/Transform3dTestMessageSerde.h | 60 ----------- .../photon/struct/BoolTestMessageStruct.h | 45 -------- .../photon/struct/Float32TestMessageStruct.h | 45 -------- .../photon/struct/Float64TestMessageStruct.h | 45 -------- .../photon/struct/Int16TestMessageStruct.h | 45 -------- .../photon/struct/Int32TestMessageStruct.h | 45 -------- .../photon/struct/Int64TestMessageStruct.h | 45 -------- .../photon/struct/Int8TestMessageStruct.h | 45 -------- .../struct/Transform3dTestMessageStruct.h | 46 -------- 32 files changed, 2026 deletions(-) delete mode 100644 photon-targeting/src/generated/main/java/org/photonvision/struct/BoolTestMessageSerde.java delete mode 100644 photon-targeting/src/generated/main/java/org/photonvision/struct/Float32TestMessageSerde.java delete mode 100644 photon-targeting/src/generated/main/java/org/photonvision/struct/Float64TestMessageSerde.java delete mode 100644 photon-targeting/src/generated/main/java/org/photonvision/struct/Int16TestMessageSerde.java delete mode 100644 photon-targeting/src/generated/main/java/org/photonvision/struct/Int32TestMessageSerde.java delete mode 100644 photon-targeting/src/generated/main/java/org/photonvision/struct/Int64TestMessageSerde.java delete mode 100644 photon-targeting/src/generated/main/java/org/photonvision/struct/Int8TestMessageSerde.java delete mode 100644 photon-targeting/src/generated/main/java/org/photonvision/struct/Transform3dTestMessageSerde.java delete mode 100644 photon-targeting/src/generated/main/native/cpp/photon/serde/BoolTestMessageSerde.cpp delete mode 100644 photon-targeting/src/generated/main/native/cpp/photon/serde/Float32TestMessageSerde.cpp delete mode 100644 photon-targeting/src/generated/main/native/cpp/photon/serde/Float64TestMessageSerde.cpp delete mode 100644 photon-targeting/src/generated/main/native/cpp/photon/serde/Int16TestMessageSerde.cpp delete mode 100644 photon-targeting/src/generated/main/native/cpp/photon/serde/Int32TestMessageSerde.cpp delete mode 100644 photon-targeting/src/generated/main/native/cpp/photon/serde/Int64TestMessageSerde.cpp delete mode 100644 photon-targeting/src/generated/main/native/cpp/photon/serde/Int8TestMessageSerde.cpp delete mode 100644 photon-targeting/src/generated/main/native/cpp/photon/serde/Transform3dTestMessageSerde.cpp delete mode 100644 photon-targeting/src/generated/main/native/include/photon/serde/BoolTestMessageSerde.h delete mode 100644 photon-targeting/src/generated/main/native/include/photon/serde/Float32TestMessageSerde.h delete mode 100644 photon-targeting/src/generated/main/native/include/photon/serde/Float64TestMessageSerde.h delete mode 100644 photon-targeting/src/generated/main/native/include/photon/serde/Int16TestMessageSerde.h delete mode 100644 photon-targeting/src/generated/main/native/include/photon/serde/Int32TestMessageSerde.h delete mode 100644 photon-targeting/src/generated/main/native/include/photon/serde/Int64TestMessageSerde.h delete mode 100644 photon-targeting/src/generated/main/native/include/photon/serde/Int8TestMessageSerde.h delete mode 100644 photon-targeting/src/generated/main/native/include/photon/serde/Transform3dTestMessageSerde.h delete mode 100644 photon-targeting/src/generated/main/native/include/photon/struct/BoolTestMessageStruct.h delete mode 100644 photon-targeting/src/generated/main/native/include/photon/struct/Float32TestMessageStruct.h delete mode 100644 photon-targeting/src/generated/main/native/include/photon/struct/Float64TestMessageStruct.h delete mode 100644 photon-targeting/src/generated/main/native/include/photon/struct/Int16TestMessageStruct.h delete mode 100644 photon-targeting/src/generated/main/native/include/photon/struct/Int32TestMessageStruct.h delete mode 100644 photon-targeting/src/generated/main/native/include/photon/struct/Int64TestMessageStruct.h delete mode 100644 photon-targeting/src/generated/main/native/include/photon/struct/Int8TestMessageStruct.h delete mode 100644 photon-targeting/src/generated/main/native/include/photon/struct/Transform3dTestMessageStruct.h diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/BoolTestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/BoolTestMessageSerde.java deleted file mode 100644 index d016b41c39..0000000000 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/BoolTestMessageSerde.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -package org.photonvision.struct; - -import org.photonvision.common.dataflow.structures.Packet; -import org.photonvision.common.dataflow.structures.PacketSerde; -import org.photonvision.utils.PacketUtils; - -// Assume that the base class lives here and we can import it -import org.photonvision.targeting.*; - -// Needed for optional shims -import java.util.function.BiConsumer; -import java.util.function.Function; - -// WPILib imports (if any) -import org.wpilib.util.struct.Struct; - - -/** - * Auto-generated serialization/deserialization helper for BoolTestMessage - */ -public class BoolTestMessageSerde implements PacketSerde { - - @Override - public final String getInterfaceUUID() { return "c8efe94a9c0d815658c74de6f672939c"; } - @Override - public final String getSchema() { return "bool test;bool vlaTest[?];optional bool optTest;"; } - @Override - public final String getTypeName() { return "BoolTestMessage"; } - - @Override - public int getMaxByteSize() { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); - } - @Override - public void pack(Packet packet, BoolTestMessage value) { - // field test is of intrinsic type bool - packet.encode(value.test); - - // vlaTest is an intrinsic VLA! - packet.encodeListImpl(value.vlaTest,PacketUtils::packBoolean); - - // optTest is optional! it better not be a VLA too - packet.encodeOptionalImpl(value.optTest,PacketUtils::packBoolean); - } - - @Override - public BoolTestMessage unpack(Packet packet) { - var ret = new BoolTestMessage(); - - // test is of intrinsic type bool - ret.test = packet.decodeBoolean(); - - // vlaTest is an intrinsic VLA! - ret.vlaTest = packet.decodeListImpl(PacketUtils::unpackBoolean); - - // optTest is optional! it better not be a VLA too - ret.optTest = packet.decodeOptionalImpl(PacketUtils::unpackBoolean); - - return ret; - } - - @Override - public PacketSerde[] getNestedPhotonMessages() { - return new PacketSerde[] { - - }; - } - - @Override - public Struct[] getNestedWpilibMessages() { - return new Struct[] { - - }; - } -} diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/Float32TestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/Float32TestMessageSerde.java deleted file mode 100644 index e61302dd02..0000000000 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/Float32TestMessageSerde.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -package org.photonvision.struct; - -import org.photonvision.common.dataflow.structures.Packet; -import org.photonvision.common.dataflow.structures.PacketSerde; -import org.photonvision.utils.PacketUtils; - -// Assume that the base class lives here and we can import it -import org.photonvision.targeting.*; - -// Needed for optional shims -import java.util.function.BiConsumer; -import java.util.function.Function; - -// WPILib imports (if any) -import org.wpilib.util.struct.Struct; - - -/** - * Auto-generated serialization/deserialization helper for Float32TestMessage - */ -public class Float32TestMessageSerde implements PacketSerde { - - @Override - public final String getInterfaceUUID() { return "9fd9ed51ec69d6738ee24af43b2b9c7e"; } - @Override - public final String getSchema() { return "float32 test;float32 vlaTest[?];optional float32 optTest;"; } - @Override - public final String getTypeName() { return "Float32TestMessage"; } - - @Override - public int getMaxByteSize() { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); - } - @Override - public void pack(Packet packet, Float32TestMessage value) { - // field test is of intrinsic type float32 - packet.encode(value.test); - - // vlaTest is an intrinsic VLA! - packet.encodeListImpl(value.vlaTest,PacketUtils::packFloat); - - // optTest is optional! it better not be a VLA too - packet.encodeOptionalImpl(value.optTest,PacketUtils::packFloat); - } - - @Override - public Float32TestMessage unpack(Packet packet) { - var ret = new Float32TestMessage(); - - // test is of intrinsic type float32 - ret.test = packet.decodeFloat(); - - // vlaTest is an intrinsic VLA! - ret.vlaTest = packet.decodeListImpl(PacketUtils::unpackFloat); - - // optTest is optional! it better not be a VLA too - ret.optTest = packet.decodeOptionalImpl(PacketUtils::unpackFloat); - - return ret; - } - - @Override - public PacketSerde[] getNestedPhotonMessages() { - return new PacketSerde[] { - - }; - } - - @Override - public Struct[] getNestedWpilibMessages() { - return new Struct[] { - - }; - } -} diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/Float64TestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/Float64TestMessageSerde.java deleted file mode 100644 index e475a5ff41..0000000000 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/Float64TestMessageSerde.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -package org.photonvision.struct; - -import org.photonvision.common.dataflow.structures.Packet; -import org.photonvision.common.dataflow.structures.PacketSerde; -import org.photonvision.utils.PacketUtils; - -// Assume that the base class lives here and we can import it -import org.photonvision.targeting.*; - -// Needed for optional shims -import java.util.function.BiConsumer; -import java.util.function.Function; - -// WPILib imports (if any) -import org.wpilib.util.struct.Struct; - - -/** - * Auto-generated serialization/deserialization helper for Float64TestMessage - */ -public class Float64TestMessageSerde implements PacketSerde { - - @Override - public final String getInterfaceUUID() { return "bc96c1f7d9db9371269d0e4f4d4b4cb2"; } - @Override - public final String getSchema() { return "float64 test;float64 vlaTest[?];optional float64 optTest;"; } - @Override - public final String getTypeName() { return "Float64TestMessage"; } - - @Override - public int getMaxByteSize() { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); - } - @Override - public void pack(Packet packet, Float64TestMessage value) { - // field test is of intrinsic type float64 - packet.encode(value.test); - - // vlaTest is an intrinsic VLA! - packet.encodeListImpl(value.vlaTest,PacketUtils::packDouble); - - // optTest is optional! it better not be a VLA too - packet.encodeOptionalImpl(value.optTest,PacketUtils::packDouble); - } - - @Override - public Float64TestMessage unpack(Packet packet) { - var ret = new Float64TestMessage(); - - // test is of intrinsic type float64 - ret.test = packet.decodeDouble(); - - // vlaTest is an intrinsic VLA! - ret.vlaTest = packet.decodeListImpl(PacketUtils::unpackDouble); - - // optTest is optional! it better not be a VLA too - ret.optTest = packet.decodeOptionalImpl(PacketUtils::unpackDouble); - - return ret; - } - - @Override - public PacketSerde[] getNestedPhotonMessages() { - return new PacketSerde[] { - - }; - } - - @Override - public Struct[] getNestedWpilibMessages() { - return new Struct[] { - - }; - } -} diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/Int16TestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/Int16TestMessageSerde.java deleted file mode 100644 index 908134519b..0000000000 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/Int16TestMessageSerde.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -package org.photonvision.struct; - -import org.photonvision.common.dataflow.structures.Packet; -import org.photonvision.common.dataflow.structures.PacketSerde; -import org.photonvision.utils.PacketUtils; - -// Assume that the base class lives here and we can import it -import org.photonvision.targeting.*; - -// Needed for optional shims -import java.util.function.BiConsumer; -import java.util.function.Function; - -// WPILib imports (if any) -import org.wpilib.util.struct.Struct; - - -/** - * Auto-generated serialization/deserialization helper for Int16TestMessage - */ -public class Int16TestMessageSerde implements PacketSerde { - - @Override - public final String getInterfaceUUID() { return "23e6ccab160b942600aae8e94a72778a"; } - @Override - public final String getSchema() { return "int16 test;int16 vlaTest[?];optional int16 optTest;"; } - @Override - public final String getTypeName() { return "Int16TestMessage"; } - - @Override - public int getMaxByteSize() { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); - } - @Override - public void pack(Packet packet, Int16TestMessage value) { - // field test is of intrinsic type int16 - packet.encode(value.test); - - // vlaTest is an intrinsic VLA! - packet.encodeListImpl(value.vlaTest,PacketUtils::packShort); - - // optTest is optional! it better not be a VLA too - packet.encodeOptionalImpl(value.optTest,PacketUtils::packShort); - } - - @Override - public Int16TestMessage unpack(Packet packet) { - var ret = new Int16TestMessage(); - - // test is of intrinsic type int16 - ret.test = packet.decodeShort(); - - // vlaTest is an intrinsic VLA! - ret.vlaTest = packet.decodeListImpl(PacketUtils::unpackShort); - - // optTest is optional! it better not be a VLA too - ret.optTest = packet.decodeOptionalImpl(PacketUtils::unpackShort); - - return ret; - } - - @Override - public PacketSerde[] getNestedPhotonMessages() { - return new PacketSerde[] { - - }; - } - - @Override - public Struct[] getNestedWpilibMessages() { - return new Struct[] { - - }; - } -} diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/Int32TestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/Int32TestMessageSerde.java deleted file mode 100644 index ed8ef13400..0000000000 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/Int32TestMessageSerde.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -package org.photonvision.struct; - -import org.photonvision.common.dataflow.structures.Packet; -import org.photonvision.common.dataflow.structures.PacketSerde; -import org.photonvision.utils.PacketUtils; - -// Assume that the base class lives here and we can import it -import org.photonvision.targeting.*; - -// Needed for optional shims -import java.util.function.BiConsumer; -import java.util.function.Function; - -// WPILib imports (if any) -import org.wpilib.util.struct.Struct; - - -/** - * Auto-generated serialization/deserialization helper for Int32TestMessage - */ -public class Int32TestMessageSerde implements PacketSerde { - - @Override - public final String getInterfaceUUID() { return "d8596149c4701e7b8912df238cd4ec66"; } - @Override - public final String getSchema() { return "int32 test;int32 vlaTest[?];optional int32 optTest;"; } - @Override - public final String getTypeName() { return "Int32TestMessage"; } - - @Override - public int getMaxByteSize() { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); - } - @Override - public void pack(Packet packet, Int32TestMessage value) { - // field test is of intrinsic type int32 - packet.encode(value.test); - - // vlaTest is an intrinsic VLA! - packet.encodeListImpl(value.vlaTest,PacketUtils::packInt); - - // optTest is optional! it better not be a VLA too - packet.encodeOptionalImpl(value.optTest,PacketUtils::packInt); - } - - @Override - public Int32TestMessage unpack(Packet packet) { - var ret = new Int32TestMessage(); - - // test is of intrinsic type int32 - ret.test = packet.decodeInt(); - - // vlaTest is an intrinsic VLA! - ret.vlaTest = packet.decodeListImpl(PacketUtils::unpackInt); - - // optTest is optional! it better not be a VLA too - ret.optTest = packet.decodeOptionalImpl(PacketUtils::unpackInt); - - return ret; - } - - @Override - public PacketSerde[] getNestedPhotonMessages() { - return new PacketSerde[] { - - }; - } - - @Override - public Struct[] getNestedWpilibMessages() { - return new Struct[] { - - }; - } -} diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/Int64TestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/Int64TestMessageSerde.java deleted file mode 100644 index 94bbef6df8..0000000000 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/Int64TestMessageSerde.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -package org.photonvision.struct; - -import org.photonvision.common.dataflow.structures.Packet; -import org.photonvision.common.dataflow.structures.PacketSerde; -import org.photonvision.utils.PacketUtils; - -// Assume that the base class lives here and we can import it -import org.photonvision.targeting.*; - -// Needed for optional shims -import java.util.function.BiConsumer; -import java.util.function.Function; - -// WPILib imports (if any) -import org.wpilib.util.struct.Struct; - - -/** - * Auto-generated serialization/deserialization helper for Int64TestMessage - */ -public class Int64TestMessageSerde implements PacketSerde { - - @Override - public final String getInterfaceUUID() { return "dd2e470b4d07bbcd208906c26a2ae37a"; } - @Override - public final String getSchema() { return "int64 test;int64 vlaTest[?];optional int64 optTest;"; } - @Override - public final String getTypeName() { return "Int64TestMessage"; } - - @Override - public int getMaxByteSize() { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); - } - @Override - public void pack(Packet packet, Int64TestMessage value) { - // field test is of intrinsic type int64 - packet.encode(value.test); - - // vlaTest is an intrinsic VLA! - packet.encodeListImpl(value.vlaTest,PacketUtils::packLong); - - // optTest is optional! it better not be a VLA too - packet.encodeOptionalImpl(value.optTest,PacketUtils::packLong); - } - - @Override - public Int64TestMessage unpack(Packet packet) { - var ret = new Int64TestMessage(); - - // test is of intrinsic type int64 - ret.test = packet.decodeLong(); - - // vlaTest is an intrinsic VLA! - ret.vlaTest = packet.decodeListImpl(PacketUtils::unpackLong); - - // optTest is optional! it better not be a VLA too - ret.optTest = packet.decodeOptionalImpl(PacketUtils::unpackLong); - - return ret; - } - - @Override - public PacketSerde[] getNestedPhotonMessages() { - return new PacketSerde[] { - - }; - } - - @Override - public Struct[] getNestedWpilibMessages() { - return new Struct[] { - - }; - } -} diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/Int8TestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/Int8TestMessageSerde.java deleted file mode 100644 index 2d84615186..0000000000 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/Int8TestMessageSerde.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -package org.photonvision.struct; - -import org.photonvision.common.dataflow.structures.Packet; -import org.photonvision.common.dataflow.structures.PacketSerde; -import org.photonvision.utils.PacketUtils; - -// Assume that the base class lives here and we can import it -import org.photonvision.targeting.*; - -// Needed for optional shims -import java.util.function.BiConsumer; -import java.util.function.Function; - -// WPILib imports (if any) -import org.wpilib.util.struct.Struct; - - -/** - * Auto-generated serialization/deserialization helper for Int8TestMessage - */ -public class Int8TestMessageSerde implements PacketSerde { - - @Override - public final String getInterfaceUUID() { return "76297a79f30e4d995b8f95c5fa6297fa"; } - @Override - public final String getSchema() { return "int8 test;int8 vlaTest[?];optional int8 optTest;"; } - @Override - public final String getTypeName() { return "Int8TestMessage"; } - - @Override - public int getMaxByteSize() { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); - } - @Override - public void pack(Packet packet, Int8TestMessage value) { - // field test is of intrinsic type int8 - packet.encode(value.test); - - // vlaTest is an intrinsic VLA! - packet.encodeListImpl(value.vlaTest,PacketUtils::packByte); - - // optTest is optional! it better not be a VLA too - packet.encodeOptionalImpl(value.optTest,PacketUtils::packByte); - } - - @Override - public Int8TestMessage unpack(Packet packet) { - var ret = new Int8TestMessage(); - - // test is of intrinsic type int8 - ret.test = packet.decodeByte(); - - // vlaTest is an intrinsic VLA! - ret.vlaTest = packet.decodeListImpl(PacketUtils::unpackByte); - - // optTest is optional! it better not be a VLA too - ret.optTest = packet.decodeOptionalImpl(PacketUtils::unpackByte); - - return ret; - } - - @Override - public PacketSerde[] getNestedPhotonMessages() { - return new PacketSerde[] { - - }; - } - - @Override - public Struct[] getNestedWpilibMessages() { - return new Struct[] { - - }; - } -} diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/Transform3dTestMessageSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/Transform3dTestMessageSerde.java deleted file mode 100644 index 24b0b6c1cc..0000000000 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/Transform3dTestMessageSerde.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -package org.photonvision.struct; - -import org.photonvision.common.dataflow.structures.Packet; -import org.photonvision.common.dataflow.structures.PacketSerde; -import org.photonvision.utils.PacketUtils; - -// Assume that the base class lives here and we can import it -import org.photonvision.targeting.*; - -// Needed for optional shims -import java.util.function.BiConsumer; -import java.util.function.Function; - -// WPILib imports (if any) -import org.wpilib.util.struct.Struct; -import org.wpilib.math.geometry.Transform3d; - -/** - * Auto-generated serialization/deserialization helper for Transform3dTestMessage - */ -public class Transform3dTestMessageSerde implements PacketSerde { - - @Override - public final String getInterfaceUUID() { return "37188f532d61c3b549080489012b4d07"; } - @Override - public final String getSchema() { return "Transform3d test;Transform3d vlaTest[?];optional Transform3d optTest;"; } - @Override - public final String getTypeName() { return "Transform3dTestMessage"; } - - @Override - public int getMaxByteSize() { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); - } - @Override - public void pack(Packet packet, Transform3dTestMessage value) { - // test is of shimmed type Transform3d - PacketUtils.packTransform3d(packet, value.test); - - // vlaTest is a shimmed VLA! - packet.encodeListImpl(value.vlaTest, PacketUtils::packTransform3d); - - // optTest is optional! it better not be a VLA too - packet.encodeOptionalImpl(value.optTest, PacketUtils::packTransform3d); - } - - @Override - public Transform3dTestMessage unpack(Packet packet) { - var ret = new Transform3dTestMessage(); - - // test is of shimmed type Transform3d - ret.test = PacketUtils.unpackTransform3d(packet); - - // vlaTest is a shimmed VLA! - ret.vlaTest = packet.decodeListImpl(PacketUtils::unpackTransform3d); - - // optTest is optional! it better not be a VLA too - ret.optTest = packet.decodeOptionalImpl(PacketUtils::unpackTransform3d); - - return ret; - } - - @Override - public PacketSerde[] getNestedPhotonMessages() { - return new PacketSerde[] { - - }; - } - - @Override - public Struct[] getNestedWpilibMessages() { - return new Struct[] { - Transform3d.struct - }; - } -} diff --git a/photon-targeting/src/generated/main/native/cpp/photon/serde/BoolTestMessageSerde.cpp b/photon-targeting/src/generated/main/native/cpp/photon/serde/BoolTestMessageSerde.cpp deleted file mode 100644 index da87d5ae5d..0000000000 --- a/photon-targeting/src/generated/main/native/cpp/photon/serde/BoolTestMessageSerde.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -#include "photon/serde/BoolTestMessageSerde.h" - -namespace photon { - -using StructType = SerdeType; - -void StructType::Pack(Packet& packet, const BoolTestMessage& value) { - packet.Pack(value.test); - packet.Pack>(value.vlaTest); - packet.Pack>(value.optTest); -} - -BoolTestMessage StructType::Unpack(Packet& packet) { - return BoolTestMessage{ BoolTestMessage_PhotonStruct{ - .test = packet.Unpack(), - .vlaTest = packet.Unpack>(), - .optTest = packet.Unpack>(), - }}; -} - -} // namespace photon diff --git a/photon-targeting/src/generated/main/native/cpp/photon/serde/Float32TestMessageSerde.cpp b/photon-targeting/src/generated/main/native/cpp/photon/serde/Float32TestMessageSerde.cpp deleted file mode 100644 index ece04ef963..0000000000 --- a/photon-targeting/src/generated/main/native/cpp/photon/serde/Float32TestMessageSerde.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -#include "photon/serde/Float32TestMessageSerde.h" - -namespace photon { - -using StructType = SerdeType; - -void StructType::Pack(Packet& packet, const Float32TestMessage& value) { - packet.Pack(value.test); - packet.Pack>(value.vlaTest); - packet.Pack>(value.optTest); -} - -Float32TestMessage StructType::Unpack(Packet& packet) { - return Float32TestMessage{ Float32TestMessage_PhotonStruct{ - .test = packet.Unpack(), - .vlaTest = packet.Unpack>(), - .optTest = packet.Unpack>(), - }}; -} - -} // namespace photon diff --git a/photon-targeting/src/generated/main/native/cpp/photon/serde/Float64TestMessageSerde.cpp b/photon-targeting/src/generated/main/native/cpp/photon/serde/Float64TestMessageSerde.cpp deleted file mode 100644 index cd82f36ca5..0000000000 --- a/photon-targeting/src/generated/main/native/cpp/photon/serde/Float64TestMessageSerde.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -#include "photon/serde/Float64TestMessageSerde.h" - -namespace photon { - -using StructType = SerdeType; - -void StructType::Pack(Packet& packet, const Float64TestMessage& value) { - packet.Pack(value.test); - packet.Pack>(value.vlaTest); - packet.Pack>(value.optTest); -} - -Float64TestMessage StructType::Unpack(Packet& packet) { - return Float64TestMessage{ Float64TestMessage_PhotonStruct{ - .test = packet.Unpack(), - .vlaTest = packet.Unpack>(), - .optTest = packet.Unpack>(), - }}; -} - -} // namespace photon diff --git a/photon-targeting/src/generated/main/native/cpp/photon/serde/Int16TestMessageSerde.cpp b/photon-targeting/src/generated/main/native/cpp/photon/serde/Int16TestMessageSerde.cpp deleted file mode 100644 index afb02107f1..0000000000 --- a/photon-targeting/src/generated/main/native/cpp/photon/serde/Int16TestMessageSerde.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -#include "photon/serde/Int16TestMessageSerde.h" - -namespace photon { - -using StructType = SerdeType; - -void StructType::Pack(Packet& packet, const Int16TestMessage& value) { - packet.Pack(value.test); - packet.Pack>(value.vlaTest); - packet.Pack>(value.optTest); -} - -Int16TestMessage StructType::Unpack(Packet& packet) { - return Int16TestMessage{ Int16TestMessage_PhotonStruct{ - .test = packet.Unpack(), - .vlaTest = packet.Unpack>(), - .optTest = packet.Unpack>(), - }}; -} - -} // namespace photon diff --git a/photon-targeting/src/generated/main/native/cpp/photon/serde/Int32TestMessageSerde.cpp b/photon-targeting/src/generated/main/native/cpp/photon/serde/Int32TestMessageSerde.cpp deleted file mode 100644 index 3f6a57d53d..0000000000 --- a/photon-targeting/src/generated/main/native/cpp/photon/serde/Int32TestMessageSerde.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -#include "photon/serde/Int32TestMessageSerde.h" - -namespace photon { - -using StructType = SerdeType; - -void StructType::Pack(Packet& packet, const Int32TestMessage& value) { - packet.Pack(value.test); - packet.Pack>(value.vlaTest); - packet.Pack>(value.optTest); -} - -Int32TestMessage StructType::Unpack(Packet& packet) { - return Int32TestMessage{ Int32TestMessage_PhotonStruct{ - .test = packet.Unpack(), - .vlaTest = packet.Unpack>(), - .optTest = packet.Unpack>(), - }}; -} - -} // namespace photon diff --git a/photon-targeting/src/generated/main/native/cpp/photon/serde/Int64TestMessageSerde.cpp b/photon-targeting/src/generated/main/native/cpp/photon/serde/Int64TestMessageSerde.cpp deleted file mode 100644 index b8b5c5711e..0000000000 --- a/photon-targeting/src/generated/main/native/cpp/photon/serde/Int64TestMessageSerde.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -#include "photon/serde/Int64TestMessageSerde.h" - -namespace photon { - -using StructType = SerdeType; - -void StructType::Pack(Packet& packet, const Int64TestMessage& value) { - packet.Pack(value.test); - packet.Pack>(value.vlaTest); - packet.Pack>(value.optTest); -} - -Int64TestMessage StructType::Unpack(Packet& packet) { - return Int64TestMessage{ Int64TestMessage_PhotonStruct{ - .test = packet.Unpack(), - .vlaTest = packet.Unpack>(), - .optTest = packet.Unpack>(), - }}; -} - -} // namespace photon diff --git a/photon-targeting/src/generated/main/native/cpp/photon/serde/Int8TestMessageSerde.cpp b/photon-targeting/src/generated/main/native/cpp/photon/serde/Int8TestMessageSerde.cpp deleted file mode 100644 index 5209a43077..0000000000 --- a/photon-targeting/src/generated/main/native/cpp/photon/serde/Int8TestMessageSerde.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -#include "photon/serde/Int8TestMessageSerde.h" - -namespace photon { - -using StructType = SerdeType; - -void StructType::Pack(Packet& packet, const Int8TestMessage& value) { - packet.Pack(value.test); - packet.Pack>(value.vlaTest); - packet.Pack>(value.optTest); -} - -Int8TestMessage StructType::Unpack(Packet& packet) { - return Int8TestMessage{ Int8TestMessage_PhotonStruct{ - .test = packet.Unpack(), - .vlaTest = packet.Unpack>(), - .optTest = packet.Unpack>(), - }}; -} - -} // namespace photon diff --git a/photon-targeting/src/generated/main/native/cpp/photon/serde/Transform3dTestMessageSerde.cpp b/photon-targeting/src/generated/main/native/cpp/photon/serde/Transform3dTestMessageSerde.cpp deleted file mode 100644 index aa5eb5418a..0000000000 --- a/photon-targeting/src/generated/main/native/cpp/photon/serde/Transform3dTestMessageSerde.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -#include "photon/serde/Transform3dTestMessageSerde.h" - -namespace photon { - -using StructType = SerdeType; - -void StructType::Pack(Packet& packet, const Transform3dTestMessage& value) { - packet.Pack(value.test); - packet.Pack>(value.vlaTest); - packet.Pack>(value.optTest); -} - -Transform3dTestMessage StructType::Unpack(Packet& packet) { - return Transform3dTestMessage{ Transform3dTestMessage_PhotonStruct{ - .test = packet.Unpack(), - .vlaTest = packet.Unpack>(), - .optTest = packet.Unpack>(), - }}; -} - -} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/serde/BoolTestMessageSerde.h b/photon-targeting/src/generated/main/native/include/photon/serde/BoolTestMessageSerde.h deleted file mode 100644 index a671323f45..0000000000 --- a/photon-targeting/src/generated/main/native/include/photon/serde/BoolTestMessageSerde.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -#include - -// Include myself -#include "photon/dataflow/structures/Packet.h" -#include "photon/targeting/BoolTestMessage.h" - -// Includes for dependant types -#include -#include -#include - - -namespace photon { - -template <> -struct WPILIB_DLLEXPORT SerdeType { - static constexpr std::string_view GetSchemaHash() { - return "c8efe94a9c0d815658c74de6f672939c"; - } - - static constexpr std::string_view GetSchema() { - return "bool test;bool vlaTest[?];optional bool optTest;"; - } - - static photon::BoolTestMessage Unpack(photon::Packet& packet); - static void Pack(photon::Packet& packet, const photon::BoolTestMessage& value); -}; - -static_assert(photon::PhotonStructSerializable); - -} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/serde/Float32TestMessageSerde.h b/photon-targeting/src/generated/main/native/include/photon/serde/Float32TestMessageSerde.h deleted file mode 100644 index 34d82a2ca3..0000000000 --- a/photon-targeting/src/generated/main/native/include/photon/serde/Float32TestMessageSerde.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -#include - -// Include myself -#include "photon/dataflow/structures/Packet.h" -#include "photon/targeting/Float32TestMessage.h" - -// Includes for dependant types -#include -#include -#include - - -namespace photon { - -template <> -struct WPILIB_DLLEXPORT SerdeType { - static constexpr std::string_view GetSchemaHash() { - return "9fd9ed51ec69d6738ee24af43b2b9c7e"; - } - - static constexpr std::string_view GetSchema() { - return "float32 test;float32 vlaTest[?];optional float32 optTest;"; - } - - static photon::Float32TestMessage Unpack(photon::Packet& packet); - static void Pack(photon::Packet& packet, const photon::Float32TestMessage& value); -}; - -static_assert(photon::PhotonStructSerializable); - -} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/serde/Float64TestMessageSerde.h b/photon-targeting/src/generated/main/native/include/photon/serde/Float64TestMessageSerde.h deleted file mode 100644 index a2d6b0f1da..0000000000 --- a/photon-targeting/src/generated/main/native/include/photon/serde/Float64TestMessageSerde.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -#include - -// Include myself -#include "photon/dataflow/structures/Packet.h" -#include "photon/targeting/Float64TestMessage.h" - -// Includes for dependant types -#include -#include -#include - - -namespace photon { - -template <> -struct WPILIB_DLLEXPORT SerdeType { - static constexpr std::string_view GetSchemaHash() { - return "bc96c1f7d9db9371269d0e4f4d4b4cb2"; - } - - static constexpr std::string_view GetSchema() { - return "float64 test;float64 vlaTest[?];optional float64 optTest;"; - } - - static photon::Float64TestMessage Unpack(photon::Packet& packet); - static void Pack(photon::Packet& packet, const photon::Float64TestMessage& value); -}; - -static_assert(photon::PhotonStructSerializable); - -} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/serde/Int16TestMessageSerde.h b/photon-targeting/src/generated/main/native/include/photon/serde/Int16TestMessageSerde.h deleted file mode 100644 index b71917804a..0000000000 --- a/photon-targeting/src/generated/main/native/include/photon/serde/Int16TestMessageSerde.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -#include - -// Include myself -#include "photon/dataflow/structures/Packet.h" -#include "photon/targeting/Int16TestMessage.h" - -// Includes for dependant types -#include -#include -#include - - -namespace photon { - -template <> -struct WPILIB_DLLEXPORT SerdeType { - static constexpr std::string_view GetSchemaHash() { - return "23e6ccab160b942600aae8e94a72778a"; - } - - static constexpr std::string_view GetSchema() { - return "int16 test;int16 vlaTest[?];optional int16 optTest;"; - } - - static photon::Int16TestMessage Unpack(photon::Packet& packet); - static void Pack(photon::Packet& packet, const photon::Int16TestMessage& value); -}; - -static_assert(photon::PhotonStructSerializable); - -} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/serde/Int32TestMessageSerde.h b/photon-targeting/src/generated/main/native/include/photon/serde/Int32TestMessageSerde.h deleted file mode 100644 index 5eb44c6381..0000000000 --- a/photon-targeting/src/generated/main/native/include/photon/serde/Int32TestMessageSerde.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -#include - -// Include myself -#include "photon/dataflow/structures/Packet.h" -#include "photon/targeting/Int32TestMessage.h" - -// Includes for dependant types -#include -#include -#include - - -namespace photon { - -template <> -struct WPILIB_DLLEXPORT SerdeType { - static constexpr std::string_view GetSchemaHash() { - return "d8596149c4701e7b8912df238cd4ec66"; - } - - static constexpr std::string_view GetSchema() { - return "int32 test;int32 vlaTest[?];optional int32 optTest;"; - } - - static photon::Int32TestMessage Unpack(photon::Packet& packet); - static void Pack(photon::Packet& packet, const photon::Int32TestMessage& value); -}; - -static_assert(photon::PhotonStructSerializable); - -} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/serde/Int64TestMessageSerde.h b/photon-targeting/src/generated/main/native/include/photon/serde/Int64TestMessageSerde.h deleted file mode 100644 index a2beb754f4..0000000000 --- a/photon-targeting/src/generated/main/native/include/photon/serde/Int64TestMessageSerde.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -#include - -// Include myself -#include "photon/dataflow/structures/Packet.h" -#include "photon/targeting/Int64TestMessage.h" - -// Includes for dependant types -#include -#include -#include - - -namespace photon { - -template <> -struct WPILIB_DLLEXPORT SerdeType { - static constexpr std::string_view GetSchemaHash() { - return "dd2e470b4d07bbcd208906c26a2ae37a"; - } - - static constexpr std::string_view GetSchema() { - return "int64 test;int64 vlaTest[?];optional int64 optTest;"; - } - - static photon::Int64TestMessage Unpack(photon::Packet& packet); - static void Pack(photon::Packet& packet, const photon::Int64TestMessage& value); -}; - -static_assert(photon::PhotonStructSerializable); - -} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/serde/Int8TestMessageSerde.h b/photon-targeting/src/generated/main/native/include/photon/serde/Int8TestMessageSerde.h deleted file mode 100644 index d1c526b338..0000000000 --- a/photon-targeting/src/generated/main/native/include/photon/serde/Int8TestMessageSerde.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -#include - -// Include myself -#include "photon/dataflow/structures/Packet.h" -#include "photon/targeting/Int8TestMessage.h" - -// Includes for dependant types -#include -#include -#include - - -namespace photon { - -template <> -struct WPILIB_DLLEXPORT SerdeType { - static constexpr std::string_view GetSchemaHash() { - return "76297a79f30e4d995b8f95c5fa6297fa"; - } - - static constexpr std::string_view GetSchema() { - return "int8 test;int8 vlaTest[?];optional int8 optTest;"; - } - - static photon::Int8TestMessage Unpack(photon::Packet& packet); - static void Pack(photon::Packet& packet, const photon::Int8TestMessage& value); -}; - -static_assert(photon::PhotonStructSerializable); - -} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/serde/Transform3dTestMessageSerde.h b/photon-targeting/src/generated/main/native/include/photon/serde/Transform3dTestMessageSerde.h deleted file mode 100644 index 69bcc31f3f..0000000000 --- a/photon-targeting/src/generated/main/native/include/photon/serde/Transform3dTestMessageSerde.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -#include - -// Include myself -#include "photon/dataflow/structures/Packet.h" -#include "photon/targeting/Transform3dTestMessage.h" - -// Includes for dependant types -#include -#include -#include -#include - - -namespace photon { - -template <> -struct WPILIB_DLLEXPORT SerdeType { - static constexpr std::string_view GetSchemaHash() { - return "37188f532d61c3b549080489012b4d07"; - } - - static constexpr std::string_view GetSchema() { - return "Transform3d test;Transform3d vlaTest[?];optional Transform3d optTest;"; - } - - static photon::Transform3dTestMessage Unpack(photon::Packet& packet); - static void Pack(photon::Packet& packet, const photon::Transform3dTestMessage& value); -}; - -static_assert(photon::PhotonStructSerializable); - -} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/struct/BoolTestMessageStruct.h b/photon-targeting/src/generated/main/native/include/photon/struct/BoolTestMessageStruct.h deleted file mode 100644 index a3fca76c9d..0000000000 --- a/photon-targeting/src/generated/main/native/include/photon/struct/BoolTestMessageStruct.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -// Includes for dependant types -#include -#include -#include - - -namespace photon { - -struct BoolTestMessage_PhotonStruct { - bool test; - std::vector vlaTest; - std::optional optTest; - - friend bool operator==(BoolTestMessage_PhotonStruct const&, BoolTestMessage_PhotonStruct const&) = default; -}; - -} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/struct/Float32TestMessageStruct.h b/photon-targeting/src/generated/main/native/include/photon/struct/Float32TestMessageStruct.h deleted file mode 100644 index 652daa87dd..0000000000 --- a/photon-targeting/src/generated/main/native/include/photon/struct/Float32TestMessageStruct.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -// Includes for dependant types -#include -#include -#include - - -namespace photon { - -struct Float32TestMessage_PhotonStruct { - float test; - std::vector vlaTest; - std::optional optTest; - - friend bool operator==(Float32TestMessage_PhotonStruct const&, Float32TestMessage_PhotonStruct const&) = default; -}; - -} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/struct/Float64TestMessageStruct.h b/photon-targeting/src/generated/main/native/include/photon/struct/Float64TestMessageStruct.h deleted file mode 100644 index 5ee739d063..0000000000 --- a/photon-targeting/src/generated/main/native/include/photon/struct/Float64TestMessageStruct.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -// Includes for dependant types -#include -#include -#include - - -namespace photon { - -struct Float64TestMessage_PhotonStruct { - double test; - std::vector vlaTest; - std::optional optTest; - - friend bool operator==(Float64TestMessage_PhotonStruct const&, Float64TestMessage_PhotonStruct const&) = default; -}; - -} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/struct/Int16TestMessageStruct.h b/photon-targeting/src/generated/main/native/include/photon/struct/Int16TestMessageStruct.h deleted file mode 100644 index 356b0ae1d5..0000000000 --- a/photon-targeting/src/generated/main/native/include/photon/struct/Int16TestMessageStruct.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -// Includes for dependant types -#include -#include -#include - - -namespace photon { - -struct Int16TestMessage_PhotonStruct { - int16_t test; - std::vector vlaTest; - std::optional optTest; - - friend bool operator==(Int16TestMessage_PhotonStruct const&, Int16TestMessage_PhotonStruct const&) = default; -}; - -} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/struct/Int32TestMessageStruct.h b/photon-targeting/src/generated/main/native/include/photon/struct/Int32TestMessageStruct.h deleted file mode 100644 index 519a6aed06..0000000000 --- a/photon-targeting/src/generated/main/native/include/photon/struct/Int32TestMessageStruct.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -// Includes for dependant types -#include -#include -#include - - -namespace photon { - -struct Int32TestMessage_PhotonStruct { - int32_t test; - std::vector vlaTest; - std::optional optTest; - - friend bool operator==(Int32TestMessage_PhotonStruct const&, Int32TestMessage_PhotonStruct const&) = default; -}; - -} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/struct/Int64TestMessageStruct.h b/photon-targeting/src/generated/main/native/include/photon/struct/Int64TestMessageStruct.h deleted file mode 100644 index f4ce39755e..0000000000 --- a/photon-targeting/src/generated/main/native/include/photon/struct/Int64TestMessageStruct.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -// Includes for dependant types -#include -#include -#include - - -namespace photon { - -struct Int64TestMessage_PhotonStruct { - int64_t test; - std::vector vlaTest; - std::optional optTest; - - friend bool operator==(Int64TestMessage_PhotonStruct const&, Int64TestMessage_PhotonStruct const&) = default; -}; - -} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/struct/Int8TestMessageStruct.h b/photon-targeting/src/generated/main/native/include/photon/struct/Int8TestMessageStruct.h deleted file mode 100644 index 5b37d13a64..0000000000 --- a/photon-targeting/src/generated/main/native/include/photon/struct/Int8TestMessageStruct.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -// Includes for dependant types -#include -#include -#include - - -namespace photon { - -struct Int8TestMessage_PhotonStruct { - int8_t test; - std::vector vlaTest; - std::optional optTest; - - friend bool operator==(Int8TestMessage_PhotonStruct const&, Int8TestMessage_PhotonStruct const&) = default; -}; - -} // namespace photon diff --git a/photon-targeting/src/generated/main/native/include/photon/struct/Transform3dTestMessageStruct.h b/photon-targeting/src/generated/main/native/include/photon/struct/Transform3dTestMessageStruct.h deleted file mode 100644 index 2cb9dd7481..0000000000 --- a/photon-targeting/src/generated/main/native/include/photon/struct/Transform3dTestMessageStruct.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY - -// Includes for dependant types -#include -#include -#include -#include - - -namespace photon { - -struct Transform3dTestMessage_PhotonStruct { - wpi::math::Transform3d test; - std::vector vlaTest; - std::optional optTest; - - friend bool operator==(Transform3dTestMessage_PhotonStruct const&, Transform3dTestMessage_PhotonStruct const&) = default; -}; - -} // namespace photon From 1584dcf61a79b6e7fe265cc5efd3bd8fd183d3c7 Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Mon, 25 May 2026 16:53:59 -0400 Subject: [PATCH 22/42] began work on autogenerating test fixtures --- .gitignore | 4 +- photon-serde/templates/ThingTests.java.jinja | 57 ++++ photon-serde/tests.yaml | 265 ++++++++++++++++++- 3 files changed, 317 insertions(+), 9 deletions(-) create mode 100644 photon-serde/templates/ThingTests.java.jinja diff --git a/.gitignore b/.gitignore index ad0d63af7b..9a5be04d4f 100644 --- a/.gitignore +++ b/.gitignore @@ -167,7 +167,7 @@ flake.lock # photon-serde tests (Java & Cpp) photon-targeting/src/generated/main/java/org/photonvision/targeting photon-targeting/src/generated/main/java/org/photonvision/struct/test -photon-targeting/src/test/java/generated +photon-targeting/src/test/java/org/photonvision/AutoSerdeTest.java photon-targeting/src/generated/main/cpp/photon/serde/test photon-targeting/src/generated/main/native/include/photon/targeting @@ -175,7 +175,7 @@ photon-targeting/src/generated/main/native/include/photon/serde/test photon-targeting/src/generated/main/native/cpp/photon/serde/test photon-targeting/src/generated/main/native/include/photon/struct/test photon-targeting/src/generated/main/native/include/photon/targeting -photon-targeting/src/test/native/cpp/generated +photon-targeting/src/test/native/cpp/AutoSerdeTest.cpp # photon-serde tests (Python) photon-lib/py/photonlibpy/generated/test diff --git a/photon-serde/templates/ThingTests.java.jinja b/photon-serde/templates/ThingTests.java.jinja new file mode 100644 index 0000000000..4d1cf8bbbf --- /dev/null +++ b/photon-serde/templates/ThingTests.java.jinja @@ -0,0 +1,57 @@ +/* + * Copyright (C) Photon Vision. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +// We're injecting this file into the normal test directory so it gets run in CI. Don't change the file's name or the gitignore will break. +package org.photonvision; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.List; +import java.util.Optional; +import org.junit.jupiter.api.Test; +import org.photonvision.common.dataflow.structures.Packet; +import org.photonvision.targeting.*; +import org.photonvision.targeting.serde.PhotonStructSerializable; + +{% for dep in java_imports -%} +import {{ dep }}; +{% endfor %} + +public class AutoSerdeTest { + private > boolean testSerde(T data) { + var p = new Packet(10); + p.encode(data); + var unpackedData = p.decode(data); // kinda scuffed lowkey + System.out.println("IN: " + data.toString() + "\nOUT: " + unpackedData.toString()); + return data.equals(unpackedData); + } + {% for test in tests %} + @Test + public void {{ test.name }}() { + System.out.println("Running {{ test.name }} Test"); + {% for test_case in test.cases %} + var {{ test_case.name }} = new {{ test.type }}(); + {% for field in test_case.fields %} + {{ test_case.name }}.{{ field.name }} = {{ field.java_value }}; + {% endfor %} + assertTrue(testSerde({{ test_case.name }})); + {% endfor %} + } + {% endfor %} +} diff --git a/photon-serde/tests.yaml b/photon-serde/tests.yaml index 4d0a52446a..6f64207b98 100644 --- a/photon-serde/tests.yaml +++ b/photon-serde/tests.yaml @@ -1,11 +1,262 @@ --- +java_imports: +- 'org.wpilib.math.geometry.Rotation3d' +- 'org.wpilib.math.geometry.Translation3d' +- 'org.wpilib.math.geometry.Transform3d' +cpp_includes: +- '' +- '' +- '' +python_imports: +- 'from wpimath.geometry import Rotation3d' +- 'from wpimath.geometry import Translation3d' +- 'from wpimath.geometry import Transform3d' +tests: - name: Int8Test type: Int8TestMessage cases: - - name: ret1 - py: Int8TestMessage() - java: new Int8TestMessage() - # We just need the brace initializer list. Ts is kinda cooked but whatever - cpp: "{}" - - name: ret2 - py: Int8TestMessage() + - name: default_test + - name: optional_test + fields: + - name: optTest + java_value: 'Optional.of((byte) 3)' + cpp_value: '{3}' + python_value: '3' + - name: vla_test + fields: + - name: vlaTest + java_value: 'List.of((byte) 1, (byte) 2, (byte) 3)' + cpp_value: '{1, 2, 3}' + python_value: '[1, 2, 3]' + - name: general_test + fields: + - name: test + java_value: '(byte) 42' + cpp_value: '42' + python_value: '42' + fields: + - name: optTest + java_value: 'Optional.of((byte) 7)' + cpp_value: '{7}' + python_value: '7' + fields: + - name: vlaTest + java_value: 'List.of((byte) 4, (byte) 5, (byte) 6)' + cpp_value: '{4, 5, 6}' + python_value: '[4, 5, 6]' +- name: Int16Test + type: Int16TestMessage + cases: + - name: default_test + - name: optional_test + fields: + - name: optTest + java_value: 'Optional.of((short) 3)' + cpp_value: '{3}' + python_value: '3' + - name: vla_test + fields: + - name: vlaTest + java_value: 'List.of((short) 1, (short) 2, (short) 3)' + cpp_value: '{1, 2, 3}' + python_value: '[1, 2, 3]' + - name: general_test + fields: + - name: test + java_value: '(short) 42' + cpp_value: '42' + python_value: '42' + fields: + - name: optTest + java_value: 'Optional.of((short) 7)' + cpp_value: '{7}' + python_value: '7' + fields: + - name: vlaTest + java_value: 'List.of((short) 4, (short) 5, (short) 6)' + cpp_value: '{4, 5, 6}' + python_value: '[4, 5, 6]' +- name: Int32Test + type: Int32TestMessage + cases: + - name: default_test + - name: optional_test + fields: + - name: optTest + java_value: 'Optional.of((int) 3)' + cpp_value: '{3}' + python_value: '3' + - name: vla_test + fields: + - name: vlaTest + java_value: 'List.of((int) 1, (int) 2, (int) 3)' + cpp_value: '{1, 2, 3}' + python_value: '[1, 2, 3]' + - name: general_test + fields: + - name: test + java_value: '(int) 42' + cpp_value: '42' + python_value: '42' + fields: + - name: optTest + java_value: 'Optional.of((int) 7)' + cpp_value: '{7}' + python_value: '7' + fields: + - name: vlaTest + java_value: 'List.of((int) 4, (int) 5, (int) 6)' + cpp_value: '{4, 5, 6}' + python_value: '[4, 5, 6]' +- name: Int64Test + type: Int64TestMessage + cases: + - name: default_test + - name: optional_test + fields: + - name: optTest + java_value: 'Optional.of((long) 3)' + cpp_value: '{3}' + python_value: '3' + - name: vla_test + fields: + - name: vlaTest + java_value: 'List.of((long) 1, (long) 2, (long) 3)' + cpp_value: '{1, 2, 3}' + python_value: '[1, 2, 3]' + - name: general_test + fields: + - name: test + java_value: '(long) 42' + cpp_value: '42' + python_value: '42' + fields: + - name: optTest + java_value: 'Optional.of((long) 7)' + cpp_value: '{7}' + python_value: '7' + fields: + - name: vlaTest + java_value: 'List.of((long) 4, (long) 5, (long) 6)' + cpp_value: '{4, 5, 6}' + python_value: '[4, 5, 6]' +- name: Float32Test + type: Float32TestMessage + cases: + - name: default_test + - name: optional_test + fields: + - name: optTest + java_value: 'Optional.of((float) 3.0)' + cpp_value: '{3.0}' + python_value: '3.0' + - name: vla_test + fields: + - name: vlaTest + java_value: 'List.of((float) 1.0, (float) 2.0, (float) 3.0)' + cpp_value: '{1.0, 2.0, 3.0}' + python_value: '[1.0, 2.0, 3.0]' + - name: general_test + fields: + - name: test + java_value: '(float) 42.0' + cpp_value: '42.0' + python_value: '42.0' + - name: optTest + java_value: 'Optional.of((float) 7.0)' + cpp_value: '{7.0}' + python_value: '7.0' + - name: vlaTest + java_value: 'List.of((float) 4.0, (float) 5.0, (float) 6.0)' + cpp_value: '{4.0, 5.0, 6.0}' + python_value: '[4.0, 5.0, 6.0]' +- name: Float64Test + type: Float64TestMessage + cases: + - name: default_test + - name: optional_test + fields: + - name: optTest + java_value: 'Optional.of((double) 3.0)' + cpp_value: '{3.0}' + python_value: '3.0' + - name: vla_test + fields: + - name: vlaTest + java_value: 'List.of((double) 1.0, (double) 2.0, (double) 3.0)' + cpp_value: '{1.0, 2.0, 3.0}' + python_value: '[1.0, 2.0, 3.0]' + - name: general_test + fields: + - name: test + java_value: '(double) 42.0' + cpp_value: '42.0' + python_value: '42.0' + - name: optTest + java_value: 'Optional.of((double) 7.0)' + cpp_value: '{7.0}' + python_value: '7.0' + - name: vlaTest + java_value: 'List.of((double) 4.0, (double) 5.0, (double) 6.0)' + cpp_value: '{4.0, 5.0, 6.0}' + python_value: '[4.0, 5.0, 6.0]' +- name: BoolTest + type: BoolTestMessage + cases: + - name: default_test + - name: optional_test + fields: + - name: optTest + java_value: 'Optional.of(true)' + cpp_value: '{true}' + python_value: 'True' + - name: vla_test + fields: + - name: vlaTest + java_value: 'List.of(true, false, true)' + cpp_value: '{true, false, true}' + python_value: '[True, False, True]' + - name: general_test + fields: + - name: test + java_value: 'false' + cpp_value: 'false' + python_value: 'False' + - name: optTest + java_value: 'Optional.of(true)' + cpp_value: '{true}' + python_value: 'True' + - name: vlaTest + java_value: 'List.of(true, false, true)' + cpp_value: '{true, false, true}' + python_value: '[True, False, True]' +- name: Transform3dTest + type: Transform3dTestMessage + cases: + - name: default_test + - name: optional_test + fields: + - name: optTest + java_value: 'Optional.of(new Transform3d(new Translation3d(1.0, 2.0, 3.0), new Rotation3d(0.1, 0.2, 0.3)))' + cpp_value: '{1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}' + python_value: 'Transform3d(Translation3d(1.0, 2.0, 3.0), Rotation3d(0.1, 0.2, 0.3))' + - name: vla_test + fields: + - name: vlaTest + java_value: 'List.of(new Transform3d(new Translation3d(1.0, 2.0, 3.0), new Rotation3d(0.1, 0.2, 0.3)), new Transform3d(new Translation3d(4.0, 5.0, 6.0), new Rotation3d(0.4, 0.5, 0.6)))' + cpp_value: '{{1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}},{1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}},{8_m, 2_m, 1_m, wpi::math::Rotation3d{0_deg, 1_deg, 88_deg}}}' + python_value: '[Transform3d(Translation3d(1.0, 2.0, 3.0), Rotation3d(0.1, 0.2, 0.3)), Transform3d(Translation3d(4.0, 5.0, 6.0), Rotation3d(0.4, 0.5, 0.6))]' + - name: general_test + fields: + - name: test + java_value: 'new Transform3d(new Translation3d(7.0, 8.0, 9.0), new Rotation3d(0.7, 0.8, 0.9))' + cpp_value: '{8_m, 2_m, 1_m, wpi::math::Rotation3d{0_deg, 1_deg, 88_deg}}' + python_value: 'Transform3d(Translation3d(7.0, 8.0, 9.0), Rotation3d(0.7, 0.8, 0.9))' + - name: optTest + java_value: 'Optional.of(new Transform3d(new Translation3d(1.0, 2.0, 3.0), new Rotation3d(0.1, 0.2, 0.3)))' + cpp_value: '{1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}' + python_value: 'Transform3d(Translation3d(1.0, 2.0, 3.0), Rotation3d(0.1, 0.2, 0.3))' + - name: vlaTest + java_value: 'List.of(new Transform3d(new Translation3d(1.0, 2.0, 3.0), new Rotation3d(0.1, 0.2, 0.3)), new Transform3d(new Translation3d(4.0, 5.0, 6.0), new Rotation3d(0.4, 0.5, 0.6)))' + cpp_value: '{{1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}},{1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}},{8_m, 2_m, 1_m, wpi::math::Rotation3d{0_deg, 1_deg, 88_deg}}}' + python_value: '[Transform3d(Translation3d(1.0, 2.0, 3.0), Rotation3d(0.1, 0.2, 0.3)), Transform3d(Translation3d(4.0, 5.0, 6.0), Rotation3d(0.4, 0.5, 0.6))]' \ No newline at end of file From f3b83ff67f2725f364c4777c5e270de6fcfb0df6 Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Mon, 25 May 2026 17:23:03 -0400 Subject: [PATCH 23/42] updated python test codegen --- photon-serde/generate_messages.py | 2 +- photon-serde/messages.yaml | 2 +- photon-serde/templates/ThingSerde.py.jinja | 6 +- .../templates/ThingTestDataclass.py.jinja | 10 +- photon-serde/templates/ThingTests.cpp.jinja | 235 ++++++++++++++++++ photon-serde/templates/ThingTests.java.jinja | 2 +- photon-serde/tests.yaml | 1 + 7 files changed, 247 insertions(+), 11 deletions(-) create mode 100644 photon-serde/templates/ThingTests.cpp.jinja diff --git a/photon-serde/generate_messages.py b/photon-serde/generate_messages.py index e725f3b739..05e853418c 100644 --- a/photon-serde/generate_messages.py +++ b/photon-serde/generate_messages.py @@ -127,7 +127,7 @@ def get_python_qualified_name( if "optional" in field and field["optional"] == True: typestr = f"Optional[{base_type}]" elif "vla" in field and field["vla"] == True: - typestr = f"List[{base_type}]" + typestr = f"list[{base_type}]" else: typestr = base_type diff --git a/photon-serde/messages.yaml b/photon-serde/messages.yaml index 7f64f65d21..78c39ddc09 100644 --- a/photon-serde/messages.yaml +++ b/photon-serde/messages.yaml @@ -18,7 +18,7 @@ java_encode_shim_ref: PacketUtils::packTransform3d cpp_type: wpi::math::Transform3d cpp_include: "" - python_import: "from wpimath.geometry import Transform3d" + python_module: "wpimath.geometry" python_decode_shim: decodeTransform python_encode_shim: encodeTransform java_import: org.wpilib.math.geometry.Transform3d diff --git a/photon-serde/templates/ThingSerde.py.jinja b/photon-serde/templates/ThingSerde.py.jinja index 667e184888..705909ae6d 100644 --- a/photon-serde/templates/ThingSerde.py.jinja +++ b/photon-serde/templates/ThingSerde.py.jinja @@ -29,10 +29,12 @@ from typing import TYPE_CHECKING +{% if test %} +from ...packet import Packet +from ...targeting import * # noqa +{% else %} from ..packet import Packet from ..targeting import * # noqa -{% if test %} -from ..targeting.test import * {% endif %} diff --git a/photon-serde/templates/ThingTestDataclass.py.jinja b/photon-serde/templates/ThingTestDataclass.py.jinja index 84643f1f82..16bd7be011 100644 --- a/photon-serde/templates/ThingTestDataclass.py.jinja +++ b/photon-serde/templates/ThingTestDataclass.py.jinja @@ -28,12 +28,10 @@ ############################################################################### from typing import TYPE_CHECKING, Optional +from dataclasses import dataclass -from ..packet import Packet -from ..targeting import * # noqa -{% if test %} -from ..targeting.test import * -{% endif %} +from ...packet import Packet +from ...targeting import * # noqa {% for type in nested_wpilib_types -%} from {{ get_message_by_name(type).python_module }} import {{ type }} @@ -43,7 +41,7 @@ from {{ get_message_by_name(type).python_module }} import {{ type }} @dataclass class {{ name }}: {% for field in fields -%} - {{ field.name }}: {{ field | get_cpp_qualified_name }} + {{ field.name }}: {{ field | get_python_qualified_name }} {%- if not loop.last %} {% endif -%} {% endfor %} diff --git a/photon-serde/templates/ThingTests.cpp.jinja b/photon-serde/templates/ThingTests.cpp.jinja new file mode 100644 index 0000000000..6f2fd1ff63 --- /dev/null +++ b/photon-serde/templates/ThingTests.cpp.jinja @@ -0,0 +1,235 @@ +/* + * Copyright (C) Photon Vision. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +// We're injecting this file into the normal test directory so it gets run in CI. Don't change the file's name or the gitignore will break. +// The file should be named "AutoTestSerde.cpp" + +#include +#include +#include + +#include + +#include "gtest/gtest.h" + +{% for include in cpp_includes -%} +#include {{ include }} +{% endfor %} + +{% for test in tests %} +#include "photon/targeting/{{ test.type }}.h" +{% endfor %} + +using namespace photon; + +template + requires(PhotonStructSerializable) +inline bool test_serde(const T& data) { + Packet p; + p.Pack(data); + T unpackedData = p.Unpack(); + return data == unpackedData; +} + +{% for test in tests %} +TEST(AutoSerdeTest, {{ test.name }}) { + std::cout << "Running {{ test.name }}\n"; + {% for test_case in test.cases %} + {{ test.type }} {{ test_case.name }}{}; + {% for field in test_case.fields %} + {{ test_case.name }}.{{ field.name }} = {{ field.cpp_value }}; + {% endfor %} + ASSERT_TRUE(test_serde({{ test_case.name }})); + {% endfor %} +} +{% endfor %} + +TEST(SerdeTest, Int8) { + std::cout << "Running int8 Test\n"; + // Default Test + Int8TestMessage test1{}; + ASSERT_TRUE(test_serde(test1)); + // Optional Test + Int8TestMessage test2{}; + test2.optTest = {3}; + ASSERT_TRUE(test_serde(test2)); + // VLA Test + Int8TestMessage test3{}; + test3.vlaTest = {1, 2, 3}; + ASSERT_TRUE(test_serde(test3)); + // General Test + Int8TestMessage test4{}; + test4.test = 1; + test4.vlaTest = {1, 2, 3}; + test4.optTest = {3}; + ASSERT_TRUE(test_serde(test4)); +} + +TEST(SerdeTest, Int16) { + std::cout << "Running int16 Test\n"; + // Default Test + Int16TestMessage test1{}; + ASSERT_TRUE(test_serde(test1)); + // Optional Test + Int16TestMessage test2{}; + test2.optTest = {3}; + ASSERT_TRUE(test_serde(test2)); + // VLA Test + Int16TestMessage test3{}; + test3.vlaTest = {1, 2, 3}; + ASSERT_TRUE(test_serde(test3)); + // General Test + Int16TestMessage test4{}; + test4.test = 1; + test4.vlaTest = {1, 2, 3}; + test4.optTest = {3}; + ASSERT_TRUE(test_serde(test4)); +} + +TEST(SerdeTest, Int32) { + std::cout << "Running int32 Test\n"; + // Default Test + Int32TestMessage test1{}; + ASSERT_TRUE(test_serde(test1)); + // Optional Test + Int32TestMessage test2{}; + test2.optTest = {3}; + ASSERT_TRUE(test_serde(test2)); + // VLA Test + Int32TestMessage test3{}; + test3.vlaTest = {1, 2, 3}; + ASSERT_TRUE(test_serde(test3)); + // General Test + Int32TestMessage test4{}; + test4.test = 1; + test4.vlaTest = {1, 2, 3}; + test4.optTest = {3}; + ASSERT_TRUE(test_serde(test4)); +} + +TEST(SerdeTest, Int64) { + std::cout << "Running int64 Test\n"; + // Default Test + Int64TestMessage test1{}; + ASSERT_TRUE(test_serde(test1)); + // Optional Test + Int64TestMessage test2{}; + test2.optTest = {3}; + ASSERT_TRUE(test_serde(test2)); + // VLA Test + Int64TestMessage test3{}; + test3.vlaTest = {1, 2, 3}; + ASSERT_TRUE(test_serde(test3)); + // General Test + Int64TestMessage test4{}; + test4.test = 1; + test4.vlaTest = {1, 2, 3}; + test4.optTest = {3}; + ASSERT_TRUE(test_serde(test4)); +} + +TEST(SerdeTest, Float32) { + std::cout << "Running float32 Test\n"; + // Default Test + Float32TestMessage test1{}; + ASSERT_TRUE(test_serde(test1)); + // Optional Test + Float32TestMessage test2{}; + test2.optTest = {3.0}; + ASSERT_TRUE(test_serde(test2)); + // VLA Test + Float32TestMessage test3{}; + test3.vlaTest = {1.0, 2.0, 3.0}; + ASSERT_TRUE(test_serde(test3)); + // General Test + Float32TestMessage test4{}; + test4.test = 1.0; + test4.vlaTest = {1.0, 2.0, 3.0}; + test4.optTest = {3.0}; + ASSERT_TRUE(test_serde(test4)); +} + +TEST(SerdeTest, Float64) { + std::cout << "Running float64 Test\n"; + // Default Test + Float64TestMessage test1{}; + ASSERT_TRUE(test_serde(test1)); + // Optional Test + Float64TestMessage test2{}; + test2.optTest = {3.0}; + ASSERT_TRUE(test_serde(test2)); + // VLA Test + Float64TestMessage test3{}; + test3.vlaTest = {1.0, 2.0, 3.0}; + ASSERT_TRUE(test_serde(test3)); + // General Test + Float64TestMessage test4{}; + test4.test = 1.0; + test4.vlaTest = {1.0, 2.0, 3.0}; + test4.optTest = {3.0}; + ASSERT_TRUE(test_serde(test4)); +} + +TEST(SerdeTest, Bool) { + std::cout << "Running bool Test\n"; + // Default Test + BoolTestMessage test1{}; + ASSERT_TRUE(test_serde(test1)); + // Optional Test + BoolTestMessage test2{}; + test2.optTest = {true}; + ASSERT_TRUE(test_serde(test2)); + // VLA Test + BoolTestMessage test3{}; + test3.vlaTest = {true, false, true}; + ASSERT_TRUE(test_serde(test3)); + // General Test + BoolTestMessage test4{}; + test4.test = true; + test4.vlaTest = {false, true, false}; + test4.optTest = {true}; + ASSERT_TRUE(test_serde(test4)); +} + +TEST(SerdeTest, Transform3d) { + std::cout << "Running Transform3d Test\n"; + // Default Test + Transform3dTestMessage test1{}; + ASSERT_TRUE(test_serde(test1)); + // Optional Test + Transform3dTestMessage test2{}; + test2.optTest = {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}; + ASSERT_TRUE(test_serde(test2)); + // VLA Test + Transform3dTestMessage test3{}; + test3.vlaTest = { + {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}, + {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}, + {8_m, 2_m, 1_m, wpi::math::Rotation3d{0_deg, 1_deg, 88_deg}}}; + ASSERT_TRUE(test_serde(test3)); + // General Test + Transform3dTestMessage test4{}; + test4.test = {8_m, 2_m, 1_m, wpi::math::Rotation3d{0_deg, 1_deg, 88_deg}}; + test4.vlaTest = { + {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}, + {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}, + {8_m, 2_m, 1_m, wpi::math::Rotation3d{0_deg, 1_deg, 88_deg}}}; + test4.optTest = {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}; + ASSERT_TRUE(test_serde(test4)); +} diff --git a/photon-serde/templates/ThingTests.java.jinja b/photon-serde/templates/ThingTests.java.jinja index 4d1cf8bbbf..d979356d69 100644 --- a/photon-serde/templates/ThingTests.java.jinja +++ b/photon-serde/templates/ThingTests.java.jinja @@ -44,7 +44,7 @@ public class AutoSerdeTest { {% for test in tests %} @Test public void {{ test.name }}() { - System.out.println("Running {{ test.name }} Test"); + System.out.println("Running {{ test.name }}"); {% for test_case in test.cases %} var {{ test_case.name }} = new {{ test.type }}(); {% for field in test_case.fields %} diff --git a/photon-serde/tests.yaml b/photon-serde/tests.yaml index 6f64207b98..d069cc3aa5 100644 --- a/photon-serde/tests.yaml +++ b/photon-serde/tests.yaml @@ -7,6 +7,7 @@ cpp_includes: - '' - '' - '' +- '' python_imports: - 'from wpimath.geometry import Rotation3d' - 'from wpimath.geometry import Translation3d' From 76d05332892b1fbfb8c64b871ada65491d148d79 Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Mon, 25 May 2026 17:24:56 -0400 Subject: [PATCH 24/42] deleted extra code --- photon-serde/templates/ThingTests.cpp.jinja | 176 +------------------- 1 file changed, 1 insertion(+), 175 deletions(-) diff --git a/photon-serde/templates/ThingTests.cpp.jinja b/photon-serde/templates/ThingTests.cpp.jinja index 6f2fd1ff63..b83787b549 100644 --- a/photon-serde/templates/ThingTests.cpp.jinja +++ b/photon-serde/templates/ThingTests.cpp.jinja @@ -58,178 +58,4 @@ TEST(AutoSerdeTest, {{ test.name }}) { ASSERT_TRUE(test_serde({{ test_case.name }})); {% endfor %} } -{% endfor %} - -TEST(SerdeTest, Int8) { - std::cout << "Running int8 Test\n"; - // Default Test - Int8TestMessage test1{}; - ASSERT_TRUE(test_serde(test1)); - // Optional Test - Int8TestMessage test2{}; - test2.optTest = {3}; - ASSERT_TRUE(test_serde(test2)); - // VLA Test - Int8TestMessage test3{}; - test3.vlaTest = {1, 2, 3}; - ASSERT_TRUE(test_serde(test3)); - // General Test - Int8TestMessage test4{}; - test4.test = 1; - test4.vlaTest = {1, 2, 3}; - test4.optTest = {3}; - ASSERT_TRUE(test_serde(test4)); -} - -TEST(SerdeTest, Int16) { - std::cout << "Running int16 Test\n"; - // Default Test - Int16TestMessage test1{}; - ASSERT_TRUE(test_serde(test1)); - // Optional Test - Int16TestMessage test2{}; - test2.optTest = {3}; - ASSERT_TRUE(test_serde(test2)); - // VLA Test - Int16TestMessage test3{}; - test3.vlaTest = {1, 2, 3}; - ASSERT_TRUE(test_serde(test3)); - // General Test - Int16TestMessage test4{}; - test4.test = 1; - test4.vlaTest = {1, 2, 3}; - test4.optTest = {3}; - ASSERT_TRUE(test_serde(test4)); -} - -TEST(SerdeTest, Int32) { - std::cout << "Running int32 Test\n"; - // Default Test - Int32TestMessage test1{}; - ASSERT_TRUE(test_serde(test1)); - // Optional Test - Int32TestMessage test2{}; - test2.optTest = {3}; - ASSERT_TRUE(test_serde(test2)); - // VLA Test - Int32TestMessage test3{}; - test3.vlaTest = {1, 2, 3}; - ASSERT_TRUE(test_serde(test3)); - // General Test - Int32TestMessage test4{}; - test4.test = 1; - test4.vlaTest = {1, 2, 3}; - test4.optTest = {3}; - ASSERT_TRUE(test_serde(test4)); -} - -TEST(SerdeTest, Int64) { - std::cout << "Running int64 Test\n"; - // Default Test - Int64TestMessage test1{}; - ASSERT_TRUE(test_serde(test1)); - // Optional Test - Int64TestMessage test2{}; - test2.optTest = {3}; - ASSERT_TRUE(test_serde(test2)); - // VLA Test - Int64TestMessage test3{}; - test3.vlaTest = {1, 2, 3}; - ASSERT_TRUE(test_serde(test3)); - // General Test - Int64TestMessage test4{}; - test4.test = 1; - test4.vlaTest = {1, 2, 3}; - test4.optTest = {3}; - ASSERT_TRUE(test_serde(test4)); -} - -TEST(SerdeTest, Float32) { - std::cout << "Running float32 Test\n"; - // Default Test - Float32TestMessage test1{}; - ASSERT_TRUE(test_serde(test1)); - // Optional Test - Float32TestMessage test2{}; - test2.optTest = {3.0}; - ASSERT_TRUE(test_serde(test2)); - // VLA Test - Float32TestMessage test3{}; - test3.vlaTest = {1.0, 2.0, 3.0}; - ASSERT_TRUE(test_serde(test3)); - // General Test - Float32TestMessage test4{}; - test4.test = 1.0; - test4.vlaTest = {1.0, 2.0, 3.0}; - test4.optTest = {3.0}; - ASSERT_TRUE(test_serde(test4)); -} - -TEST(SerdeTest, Float64) { - std::cout << "Running float64 Test\n"; - // Default Test - Float64TestMessage test1{}; - ASSERT_TRUE(test_serde(test1)); - // Optional Test - Float64TestMessage test2{}; - test2.optTest = {3.0}; - ASSERT_TRUE(test_serde(test2)); - // VLA Test - Float64TestMessage test3{}; - test3.vlaTest = {1.0, 2.0, 3.0}; - ASSERT_TRUE(test_serde(test3)); - // General Test - Float64TestMessage test4{}; - test4.test = 1.0; - test4.vlaTest = {1.0, 2.0, 3.0}; - test4.optTest = {3.0}; - ASSERT_TRUE(test_serde(test4)); -} - -TEST(SerdeTest, Bool) { - std::cout << "Running bool Test\n"; - // Default Test - BoolTestMessage test1{}; - ASSERT_TRUE(test_serde(test1)); - // Optional Test - BoolTestMessage test2{}; - test2.optTest = {true}; - ASSERT_TRUE(test_serde(test2)); - // VLA Test - BoolTestMessage test3{}; - test3.vlaTest = {true, false, true}; - ASSERT_TRUE(test_serde(test3)); - // General Test - BoolTestMessage test4{}; - test4.test = true; - test4.vlaTest = {false, true, false}; - test4.optTest = {true}; - ASSERT_TRUE(test_serde(test4)); -} - -TEST(SerdeTest, Transform3d) { - std::cout << "Running Transform3d Test\n"; - // Default Test - Transform3dTestMessage test1{}; - ASSERT_TRUE(test_serde(test1)); - // Optional Test - Transform3dTestMessage test2{}; - test2.optTest = {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}; - ASSERT_TRUE(test_serde(test2)); - // VLA Test - Transform3dTestMessage test3{}; - test3.vlaTest = { - {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}, - {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}, - {8_m, 2_m, 1_m, wpi::math::Rotation3d{0_deg, 1_deg, 88_deg}}}; - ASSERT_TRUE(test_serde(test3)); - // General Test - Transform3dTestMessage test4{}; - test4.test = {8_m, 2_m, 1_m, wpi::math::Rotation3d{0_deg, 1_deg, 88_deg}}; - test4.vlaTest = { - {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}, - {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}, - {8_m, 2_m, 1_m, wpi::math::Rotation3d{0_deg, 1_deg, 88_deg}}}; - test4.optTest = {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}; - ASSERT_TRUE(test_serde(test4)); -} +{% endfor %} \ No newline at end of file From 115a8c1ba1339be8c08270c62d1fa018686db4d9 Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Mon, 25 May 2026 21:58:35 -0400 Subject: [PATCH 25/42] got cpp and java test fixtures to generate, still gotta fiddle around with gradle then set up the workflow --- .gitignore | 5 ++- photon-serde/generate_messages.py | 32 +++++++++++++++++-- photon-serde/templates/ThingSerde.py.jinja | 4 +++ .../templates/ThingTestDataclass.py.jinja | 2 +- photon-serde/templates/ThingTests.cpp.jinja | 6 ++-- photon-serde/templates/ThingTests.java.jinja | 4 +-- photon-serde/tests.yaml | 8 ----- 7 files changed, 42 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 9a5be04d4f..4dceacfe17 100644 --- a/.gitignore +++ b/.gitignore @@ -167,7 +167,6 @@ flake.lock # photon-serde tests (Java & Cpp) photon-targeting/src/generated/main/java/org/photonvision/targeting photon-targeting/src/generated/main/java/org/photonvision/struct/test -photon-targeting/src/test/java/org/photonvision/AutoSerdeTest.java photon-targeting/src/generated/main/cpp/photon/serde/test photon-targeting/src/generated/main/native/include/photon/targeting @@ -175,8 +174,8 @@ photon-targeting/src/generated/main/native/include/photon/serde/test photon-targeting/src/generated/main/native/cpp/photon/serde/test photon-targeting/src/generated/main/native/include/photon/struct/test photon-targeting/src/generated/main/native/include/photon/targeting -photon-targeting/src/test/native/cpp/AutoSerdeTest.cpp +photon-targeting/src/generated-test # photon-serde tests (Python) photon-lib/py/photonlibpy/generated/test -photon-lib/py/test/generated +photon-lib/py/generated-test diff --git a/photon-serde/generate_messages.py b/photon-serde/generate_messages.py index 05e853418c..93fa0c8e66 100644 --- a/photon-serde/generate_messages.py +++ b/photon-serde/generate_messages.py @@ -382,7 +382,7 @@ def generate_photon_messages(cpp_java_root, py_root, template_root): ) # TODO: code duplication -def generate_tests(cpp_java_root, py_root, template_root): +def generate_tests(cpp_java_root, cpp_java_test_root, py_root, py_test_root, template_root): # Generate test messages test_messages = parse_yaml("test_messages.yaml") @@ -536,6 +536,22 @@ def generate_tests(cpp_java_root, py_root, template_root): ) # Generate test fixtures (WIP) + tests = parse_yaml("tests.yaml") + java_test_target = Path(cpp_java_test_root) / "java/org/photonvision/AutoSerdeTest.java" + java_test_target.parent.mkdir(parents=True, exist_ok=True) + cpp_test_target = Path(cpp_java_test_root) / "native/cpp/AutoSerdeTest.cpp" + cpp_test_target.parent.mkdir(parents=True, exist_ok=True) + py_test_target = Path(py_test_root) / "AutoSerdeTest.py" + + java_test_template = env.get_template("ThingTests.java.jinja") + cpp_test_template = env.get_template("ThingTests.cpp.jinja") + + java_test_target.write_text( + java_test_template.render(tests) + ) + cpp_test_target.write_text( + cpp_test_template.render(tests) + ) def main(argv): script_path = Path(__file__).resolve() @@ -554,6 +570,18 @@ def main(argv): default=dirname.parent / "photon-lib/py/photonlibpy/generated", type=Path, ) + parser.add_argument( + "--cpp_java_test_dir", + help="Optional. If set, will output the generated test fixtures to this directory, otherwise it will use a path relative to the script", + default=dirname.parent / "photon-targeting/src/generated-test", + type=Path, + ) + parser.add_argument( + "--py_test_dir", + help="Optional. If set, will spit Python test fixtures here", + default=dirname.parent / "photon-lib/py/generated-test", + type=Path, + ) parser.add_argument( "--template_root", help="Optional. If set, will use this directory as the root for the jinja templates", @@ -568,7 +596,7 @@ def main(argv): args = parser.parse_args(argv) if (args.tests): - generate_tests(args.cpp_java_output_dir, args.py_output_dir, args.template_root) + generate_tests(args.cpp_java_output_dir, args.cpp_java_test_dir, args.py_output_dir, args.py_test_dir, args.template_root) else: generate_photon_messages( args.cpp_java_output_dir, args.py_output_dir, args.template_root diff --git a/photon-serde/templates/ThingSerde.py.jinja b/photon-serde/templates/ThingSerde.py.jinja index 705909ae6d..6d7c0d1f70 100644 --- a/photon-serde/templates/ThingSerde.py.jinja +++ b/photon-serde/templates/ThingSerde.py.jinja @@ -46,7 +46,11 @@ if TYPE_CHECKING: {% set _ = ns.types.append(name) -%} {%- for type in ns.types|sort%} {%- if not type | is_shimmed and not type | is_intrinsic %} +{%- if test %} + from ...targeting import {{ type }} # noqa +{%- else %} from ..targeting import {{ type }} # noqa +{% endif -%} {%- endif %} {%- endfor%} diff --git a/photon-serde/templates/ThingTestDataclass.py.jinja b/photon-serde/templates/ThingTestDataclass.py.jinja index 16bd7be011..7dd0749cec 100644 --- a/photon-serde/templates/ThingTestDataclass.py.jinja +++ b/photon-serde/templates/ThingTestDataclass.py.jinja @@ -40,7 +40,7 @@ from {{ get_message_by_name(type).python_module }} import {{ type }} @dataclass class {{ name }}: - {% for field in fields -%} +{% for field in fields -%} {{ field.name }}: {{ field | get_python_qualified_name }} {%- if not loop.last %} {% endif -%} diff --git a/photon-serde/templates/ThingTests.cpp.jinja b/photon-serde/templates/ThingTests.cpp.jinja index b83787b549..bc62b83f14 100644 --- a/photon-serde/templates/ThingTests.cpp.jinja +++ b/photon-serde/templates/ThingTests.cpp.jinja @@ -32,7 +32,7 @@ #include {{ include }} {% endfor %} -{% for test in tests %} +{% for test in tests -%} #include "photon/targeting/{{ test.type }}.h" {% endfor %} @@ -52,9 +52,9 @@ TEST(AutoSerdeTest, {{ test.name }}) { std::cout << "Running {{ test.name }}\n"; {% for test_case in test.cases %} {{ test.type }} {{ test_case.name }}{}; - {% for field in test_case.fields %} + {% for field in test_case.fields -%} {{ test_case.name }}.{{ field.name }} = {{ field.cpp_value }}; - {% endfor %} + {% endfor -%} ASSERT_TRUE(test_serde({{ test_case.name }})); {% endfor %} } diff --git a/photon-serde/templates/ThingTests.java.jinja b/photon-serde/templates/ThingTests.java.jinja index d979356d69..27c152f675 100644 --- a/photon-serde/templates/ThingTests.java.jinja +++ b/photon-serde/templates/ThingTests.java.jinja @@ -47,9 +47,9 @@ public class AutoSerdeTest { System.out.println("Running {{ test.name }}"); {% for test_case in test.cases %} var {{ test_case.name }} = new {{ test.type }}(); - {% for field in test_case.fields %} + {% for field in test_case.fields -%} {{ test_case.name }}.{{ field.name }} = {{ field.java_value }}; - {% endfor %} + {% endfor -%} assertTrue(testSerde({{ test_case.name }})); {% endfor %} } diff --git a/photon-serde/tests.yaml b/photon-serde/tests.yaml index d069cc3aa5..794e9f55fa 100644 --- a/photon-serde/tests.yaml +++ b/photon-serde/tests.yaml @@ -35,12 +35,10 @@ tests: java_value: '(byte) 42' cpp_value: '42' python_value: '42' - fields: - name: optTest java_value: 'Optional.of((byte) 7)' cpp_value: '{7}' python_value: '7' - fields: - name: vlaTest java_value: 'List.of((byte) 4, (byte) 5, (byte) 6)' cpp_value: '{4, 5, 6}' @@ -67,12 +65,10 @@ tests: java_value: '(short) 42' cpp_value: '42' python_value: '42' - fields: - name: optTest java_value: 'Optional.of((short) 7)' cpp_value: '{7}' python_value: '7' - fields: - name: vlaTest java_value: 'List.of((short) 4, (short) 5, (short) 6)' cpp_value: '{4, 5, 6}' @@ -99,12 +95,10 @@ tests: java_value: '(int) 42' cpp_value: '42' python_value: '42' - fields: - name: optTest java_value: 'Optional.of((int) 7)' cpp_value: '{7}' python_value: '7' - fields: - name: vlaTest java_value: 'List.of((int) 4, (int) 5, (int) 6)' cpp_value: '{4, 5, 6}' @@ -131,12 +125,10 @@ tests: java_value: '(long) 42' cpp_value: '42' python_value: '42' - fields: - name: optTest java_value: 'Optional.of((long) 7)' cpp_value: '{7}' python_value: '7' - fields: - name: vlaTest java_value: 'List.of((long) 4, (long) 5, (long) 6)' cpp_value: '{4, 5, 6}' From 681f943ca504c33cb59dcff66f0636b5f5bc79ea Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Mon, 25 May 2026 22:00:00 -0400 Subject: [PATCH 26/42] removed outdated comments --- photon-serde/templates/ThingTests.cpp.jinja | 3 --- photon-serde/templates/ThingTests.java.jinja | 1 - 2 files changed, 4 deletions(-) diff --git a/photon-serde/templates/ThingTests.cpp.jinja b/photon-serde/templates/ThingTests.cpp.jinja index bc62b83f14..47aecfcd7f 100644 --- a/photon-serde/templates/ThingTests.cpp.jinja +++ b/photon-serde/templates/ThingTests.cpp.jinja @@ -17,9 +17,6 @@ // THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY -// We're injecting this file into the normal test directory so it gets run in CI. Don't change the file's name or the gitignore will break. -// The file should be named "AutoTestSerde.cpp" - #include #include #include diff --git a/photon-serde/templates/ThingTests.java.jinja b/photon-serde/templates/ThingTests.java.jinja index 27c152f675..8646b5771e 100644 --- a/photon-serde/templates/ThingTests.java.jinja +++ b/photon-serde/templates/ThingTests.java.jinja @@ -17,7 +17,6 @@ // THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY -// We're injecting this file into the normal test directory so it gets run in CI. Don't change the file's name or the gitignore will break. package org.photonvision; import static org.junit.jupiter.api.Assertions.assertTrue; From 68c8fece457da0381b1936bcfc5ae8382915cfbf Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Mon, 25 May 2026 22:05:57 -0400 Subject: [PATCH 27/42] dhewiu --- photon-serde/templates/ThingTestDataclass.py.jinja | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/photon-serde/templates/ThingTestDataclass.py.jinja b/photon-serde/templates/ThingTestDataclass.py.jinja index 7dd0749cec..75e7080a68 100644 --- a/photon-serde/templates/ThingTestDataclass.py.jinja +++ b/photon-serde/templates/ThingTestDataclass.py.jinja @@ -40,8 +40,8 @@ from {{ get_message_by_name(type).python_module }} import {{ type }} @dataclass class {{ name }}: -{% for field in fields -%} + {% for field in fields -%} {{ field.name }}: {{ field | get_python_qualified_name }} {%- if not loop.last %} {% endif -%} -{% endfor %} +{%- endfor %} From 0659ce88c82912deb0bdb8338704a6cd912f2e87 Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Mon, 25 May 2026 22:07:38 -0400 Subject: [PATCH 28/42] removed old serde tests --- .../test/java/org/photonvision/SerdeTest.java | 223 ------------------ .../src/test/native/cpp/SerdeTest.cpp | 217 ----------------- 2 files changed, 440 deletions(-) delete mode 100644 photon-targeting/src/test/java/org/photonvision/SerdeTest.java delete mode 100644 photon-targeting/src/test/native/cpp/SerdeTest.cpp diff --git a/photon-targeting/src/test/java/org/photonvision/SerdeTest.java b/photon-targeting/src/test/java/org/photonvision/SerdeTest.java deleted file mode 100644 index 5393b29314..0000000000 --- a/photon-targeting/src/test/java/org/photonvision/SerdeTest.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright (C) Photon Vision. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.photonvision; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.util.List; -import java.util.Optional; -import org.junit.jupiter.api.Test; -import org.photonvision.common.dataflow.structures.Packet; -import org.photonvision.targeting.*; -import org.photonvision.targeting.serde.PhotonStructSerializable; -import org.wpilib.math.geometry.Rotation3d; -import org.wpilib.math.geometry.Transform3d; - -public class SerdeTest { - private > boolean testSerde(T data) { - var p = new Packet(10); - p.encode(data); - var unpackedData = p.decode(data); // kinda scuffed lowkey - System.out.println("IN: " + data.toString() + "\nOUT: " + unpackedData.toString()); - return data.equals(unpackedData); - } - - @Test - public void int8Test() { - System.out.println("Running int8 Test"); - // Default test - var test1 = new Int8TestMessage(); - assertTrue(testSerde(test1)); - // Optional test - var test2 = new Int8TestMessage(); - test2.optTest = Optional.of((byte) 3); - assertTrue(testSerde(test2)); - // VLA test - var test3 = new Int8TestMessage(); - test3.vlaTest = List.of((byte) 1, (byte) 2, (byte) 3); - assertTrue(testSerde(test3)); - // General test - var test4 = new Int8TestMessage(); - test4.test = (byte) 1; - test4.vlaTest = List.of((byte) 1, (byte) 2, (byte) 3); - test4.optTest = Optional.of((byte) 3); - assertTrue(testSerde(test4)); - } - - @Test - public void int16Test() { - System.out.println("Running int16 Test"); - // Default test - var test1 = new Int16TestMessage(); - assertTrue(testSerde(test1)); - // Optional test - var test2 = new Int16TestMessage(); - test2.optTest = Optional.of((short) 3); - assertTrue(testSerde(test2)); - // VLA test - var test3 = new Int16TestMessage(); - test3.vlaTest = List.of((short) 1, (short) 2, (short) 3); - assertTrue(testSerde(test3)); - // General test - var test4 = new Int16TestMessage(); - test4.test = (short) 1; - test4.vlaTest = List.of((short) 1, (short) 2, (short) 3); - test4.optTest = Optional.of((short) 3); - assertTrue(testSerde(test4)); - } - - @Test - public void int32Test() { - System.out.println("Running int32 Test"); - // Default test - var test1 = new Int32TestMessage(); - assertTrue(testSerde(test1)); - // Optional test - var test2 = new Int32TestMessage(); - test2.optTest = Optional.of((int) 3); - assertTrue(testSerde(test2)); - // VLA test - var test3 = new Int32TestMessage(); - test3.vlaTest = List.of((int) 1, (int) 2, (int) 3); - assertTrue(testSerde(test3)); - // General test - var test4 = new Int32TestMessage(); - test4.test = (int) 1; - test4.vlaTest = List.of((int) 1, (int) 2, (int) 3); - test4.optTest = Optional.of((int) 3); - assertTrue(testSerde(test4)); - } - - @Test - public void int64Test() { - System.out.println("Running int64 Test"); - // Default test - var test1 = new Int64TestMessage(); - assertTrue(testSerde(test1)); - // Optional test - var test2 = new Int64TestMessage(); - test2.optTest = Optional.of((long) 3); - assertTrue(testSerde(test2)); - // VLA test - var test3 = new Int64TestMessage(); - test3.vlaTest = List.of((long) 1, (long) 2, (long) 3); - assertTrue(testSerde(test3)); - // General test - var test4 = new Int64TestMessage(); - test4.test = (long) 1; - test4.vlaTest = List.of((long) 1, (long) 2, (long) 3); - test4.optTest = Optional.of((long) 3); - assertTrue(testSerde(test4)); - } - - @Test - public void float32Test() { - System.out.println("Running float32 Test"); - // Default test - var test1 = new Float32TestMessage(); - assertTrue(testSerde(test1)); - // Optional test - var test2 = new Float32TestMessage(); - test2.optTest = Optional.of((float) 3.0); - assertTrue(testSerde(test2)); - // VLA test - var test3 = new Float32TestMessage(); - test3.vlaTest = List.of((float) 1.0, (float) 2.0, (float) 3.0); - assertTrue(testSerde(test3)); - // General test - var test4 = new Float32TestMessage(); - test4.test = (float) 1.0; - test4.vlaTest = List.of((float) 1.0, (float) 2.0, (float) 3.0); - test4.optTest = Optional.of((float) 3.0); - assertTrue(testSerde(test4)); - } - - @Test - public void float64Test() { - System.out.println("Running float64 Test"); - // Default test - var test1 = new Float64TestMessage(); - assertTrue(testSerde(test1)); - // Optional test - var test2 = new Float64TestMessage(); - test2.optTest = Optional.of((double) 3.0); - assertTrue(testSerde(test2)); - // VLA test - var test3 = new Float64TestMessage(); - test3.vlaTest = List.of((double) 1.0, (double) 2.0, (double) 3.0); - assertTrue(testSerde(test3)); - // General test - var test4 = new Float64TestMessage(); - test4.test = (float) 1.0; - test4.vlaTest = List.of((double) 1.0, (double) 2.0, (double) 3.0); - test4.optTest = Optional.of((double) 3.0); - assertTrue(testSerde(test4)); - } - - @Test - public void boolTest() { - System.out.println("Running bool Test"); - // Default test - var test1 = new BoolTestMessage(); - assertTrue(testSerde(test1)); - // Optional test - var test2 = new BoolTestMessage(); - test2.optTest = Optional.of(true); - assertTrue(testSerde(test2)); - // VLA test - var test3 = new BoolTestMessage(); - test3.vlaTest = List.of(true, false, true); - assertTrue(testSerde(test3)); - // General test - var test4 = new BoolTestMessage(); - test4.test = true; - test4.vlaTest = List.of(true, false, true); - test4.optTest = Optional.of(true); - assertTrue(testSerde(test4)); - } - - @Test - public void Transform3dTest() { - System.out.println("Running Transform3d Test"); - // Default test - var test1 = new Transform3dTestMessage(); - assertTrue(testSerde(test1)); - // Optional test - var test2 = new Transform3dTestMessage(); - test2.optTest = Optional.of(new Transform3d(1.0, 2.0, 3.0, new Rotation3d(1.0, 2.0, 3.0))); - assertTrue(testSerde(test2)); - // VLA test - var test3 = new Transform3dTestMessage(); - test3.vlaTest = - List.of( - new Transform3d(1.0, 2.0, 3.0, new Rotation3d(1.0, 2.0, 3.0)), - new Transform3d(2.0, 1.0, 5.0, new Rotation3d(4.0, 3.0, 2.0)), - new Transform3d(1.0, 0.0, 0.0, new Rotation3d(1.0, 5.0, 3.0))); - assertTrue(testSerde(test3)); - // General test - var test4 = new Transform3dTestMessage(); - test4.test = new Transform3d(0.0, 1.0, 0.0, new Rotation3d(0.0, 2.0, 0.0)); - test4.vlaTest = - List.of( - new Transform3d(1.0, 2.0, 3.0, new Rotation3d(1.0, 2.0, 3.0)), - new Transform3d(2.0, 1.0, 5.0, new Rotation3d(4.0, 3.0, 2.0)), - new Transform3d(1.0, 0.0, 0.0, new Rotation3d(1.0, 5.0, 3.0))); - test4.optTest = Optional.of(new Transform3d(1.0, 2.0, 3.0, new Rotation3d(1.0, 2.0, 3.0))); - assertTrue(testSerde(test4)); - } -} diff --git a/photon-targeting/src/test/native/cpp/SerdeTest.cpp b/photon-targeting/src/test/native/cpp/SerdeTest.cpp deleted file mode 100644 index 879eca3161..0000000000 --- a/photon-targeting/src/test/native/cpp/SerdeTest.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (C) Photon Vision. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include - -#include - -#include "gtest/gtest.h" -#include "photon/dataflow/structures/Packet.h" -#include "photon/targeting/BoolTestMessage.h" -#include "photon/targeting/Float32TestMessage.h" -#include "photon/targeting/Float64TestMessage.h" -#include "photon/targeting/Int16TestMessage.h" -#include "photon/targeting/Int32TestMessage.h" -#include "photon/targeting/Int64TestMessage.h" -#include "photon/targeting/Int8TestMessage.h" -#include "photon/targeting/Transform3dTestMessage.h" - -using namespace photon; - -template - requires(PhotonStructSerializable) -inline bool test_serde(const T& data) { - Packet p; - p.Pack(data); - T unpackedData = p.Unpack(); - return data == unpackedData; -} - -TEST(SerdeTest, Int8) { - std::cout << "Running int8 Test\n"; - // Default Test - Int8TestMessage test1{}; - ASSERT_TRUE(test_serde(test1)); - // Optional Test - Int8TestMessage test2{}; - test2.optTest = {3}; - ASSERT_TRUE(test_serde(test2)); - // VLA Test - Int8TestMessage test3{}; - test3.vlaTest = {1, 2, 3}; - ASSERT_TRUE(test_serde(test3)); - // General Test - Int8TestMessage test4{}; - test4.test = 1; - test4.vlaTest = {1, 2, 3}; - test4.optTest = {3}; - ASSERT_TRUE(test_serde(test4)); -} - -TEST(SerdeTest, Int16) { - std::cout << "Running int16 Test\n"; - // Default Test - Int16TestMessage test1{}; - ASSERT_TRUE(test_serde(test1)); - // Optional Test - Int16TestMessage test2{}; - test2.optTest = {3}; - ASSERT_TRUE(test_serde(test2)); - // VLA Test - Int16TestMessage test3{}; - test3.vlaTest = {1, 2, 3}; - ASSERT_TRUE(test_serde(test3)); - // General Test - Int16TestMessage test4{}; - test4.test = 1; - test4.vlaTest = {1, 2, 3}; - test4.optTest = {3}; - ASSERT_TRUE(test_serde(test4)); -} - -TEST(SerdeTest, Int32) { - std::cout << "Running int32 Test\n"; - // Default Test - Int32TestMessage test1{}; - ASSERT_TRUE(test_serde(test1)); - // Optional Test - Int32TestMessage test2{}; - test2.optTest = {3}; - ASSERT_TRUE(test_serde(test2)); - // VLA Test - Int32TestMessage test3{}; - test3.vlaTest = {1, 2, 3}; - ASSERT_TRUE(test_serde(test3)); - // General Test - Int32TestMessage test4{}; - test4.test = 1; - test4.vlaTest = {1, 2, 3}; - test4.optTest = {3}; - ASSERT_TRUE(test_serde(test4)); -} - -TEST(SerdeTest, Int64) { - std::cout << "Running int64 Test\n"; - // Default Test - Int64TestMessage test1{}; - ASSERT_TRUE(test_serde(test1)); - // Optional Test - Int64TestMessage test2{}; - test2.optTest = {3}; - ASSERT_TRUE(test_serde(test2)); - // VLA Test - Int64TestMessage test3{}; - test3.vlaTest = {1, 2, 3}; - ASSERT_TRUE(test_serde(test3)); - // General Test - Int64TestMessage test4{}; - test4.test = 1; - test4.vlaTest = {1, 2, 3}; - test4.optTest = {3}; - ASSERT_TRUE(test_serde(test4)); -} - -TEST(SerdeTest, Float32) { - std::cout << "Running float32 Test\n"; - // Default Test - Float32TestMessage test1{}; - ASSERT_TRUE(test_serde(test1)); - // Optional Test - Float32TestMessage test2{}; - test2.optTest = {3.0}; - ASSERT_TRUE(test_serde(test2)); - // VLA Test - Float32TestMessage test3{}; - test3.vlaTest = {1.0, 2.0, 3.0}; - ASSERT_TRUE(test_serde(test3)); - // General Test - Float32TestMessage test4{}; - test4.test = 1.0; - test4.vlaTest = {1.0, 2.0, 3.0}; - test4.optTest = {3.0}; - ASSERT_TRUE(test_serde(test4)); -} - -TEST(SerdeTest, Float64) { - std::cout << "Running float64 Test\n"; - // Default Test - Float64TestMessage test1{}; - ASSERT_TRUE(test_serde(test1)); - // Optional Test - Float64TestMessage test2{}; - test2.optTest = {3.0}; - ASSERT_TRUE(test_serde(test2)); - // VLA Test - Float64TestMessage test3{}; - test3.vlaTest = {1.0, 2.0, 3.0}; - ASSERT_TRUE(test_serde(test3)); - // General Test - Float64TestMessage test4{}; - test4.test = 1.0; - test4.vlaTest = {1.0, 2.0, 3.0}; - test4.optTest = {3.0}; - ASSERT_TRUE(test_serde(test4)); -} - -TEST(SerdeTest, Bool) { - std::cout << "Running bool Test\n"; - // Default Test - BoolTestMessage test1{}; - ASSERT_TRUE(test_serde(test1)); - // Optional Test - BoolTestMessage test2{}; - test2.optTest = {true}; - ASSERT_TRUE(test_serde(test2)); - // VLA Test - BoolTestMessage test3{}; - test3.vlaTest = {true, false, true}; - ASSERT_TRUE(test_serde(test3)); - // General Test - BoolTestMessage test4{}; - test4.test = true; - test4.vlaTest = {false, true, false}; - test4.optTest = {true}; - ASSERT_TRUE(test_serde(test4)); -} - -TEST(SerdeTest, Transform3d) { - std::cout << "Running Transform3d Test\n"; - // Default Test - Transform3dTestMessage test1{}; - ASSERT_TRUE(test_serde(test1)); - // Optional Test - Transform3dTestMessage test2{}; - test2.optTest = {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}; - ASSERT_TRUE(test_serde(test2)); - // VLA Test - Transform3dTestMessage test3{}; - test3.vlaTest = { - {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}, - {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}, - {8_m, 2_m, 1_m, wpi::math::Rotation3d{0_deg, 1_deg, 88_deg}}}; - ASSERT_TRUE(test_serde(test3)); - // General Test - Transform3dTestMessage test4{}; - test4.test = {8_m, 2_m, 1_m, wpi::math::Rotation3d{0_deg, 1_deg, 88_deg}}; - test4.vlaTest = { - {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}, - {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}, - {8_m, 2_m, 1_m, wpi::math::Rotation3d{0_deg, 1_deg, 88_deg}}}; - test4.optTest = {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}; - ASSERT_TRUE(test_serde(test4)); -} From cb66fe94a5de66e0051448a9e5fb2f2b72a96239 Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Tue, 26 May 2026 00:59:14 -0400 Subject: [PATCH 29/42] updated linters. Also linting --- .wpiformat | 2 + build.gradle | 2 +- photon-serde/generate_messages.py | 80 ++++++++++++------- photon-serde/messages.yaml | 2 +- photon-serde/requirements.txt | 2 +- .../templates/ThingTestStruct.h.jinja | 2 +- photon-serde/tests.yaml | 2 +- 7 files changed, 58 insertions(+), 34 deletions(-) diff --git a/.wpiformat b/.wpiformat index f69dfcbe2b..3e42adddd8 100644 --- a/.wpiformat +++ b/.wpiformat @@ -4,7 +4,9 @@ cppHeaderFileInclude { modifiableFileExclude { photon-lib/py/photonlibpy/generated/ + photon-lib/py/generated-test photon-targeting/src/generated/ + photon-targeting/src/generated-test/ photon-targeting/src/main/native/cpp/photon/constrained_solvepnp/generate/ } diff --git a/build.gradle b/build.gradle index 174a59a9a5..d7488a6595 100644 --- a/build.gradle +++ b/build.gradle @@ -69,7 +69,7 @@ spotless { java { target fileTree('.') { include '**/*.java' - exclude '**/build/**', '**/build-*/**', '**/src/generated/**' + exclude '**/build/**', '**/build-*/**', '**/src/generated/**', '**/src/generated-test/**' } toggleOffOn() googleJavaFormat() diff --git a/photon-serde/generate_messages.py b/photon-serde/generate_messages.py index 93fa0c8e66..14c6630e78 100644 --- a/photon-serde/generate_messages.py +++ b/photon-serde/generate_messages.py @@ -23,10 +23,10 @@ import sys from pathlib import Path from typing import List, TypedDict, cast -from dataclasses import dataclass import yaml -from jinja2 import Environment, FileSystemLoader, Template +from jinja2 import Environment, FileSystemLoader + class SerdeField(TypedDict): name: str @@ -113,7 +113,6 @@ def get_cpp_qualified_name( return typestr - def get_python_qualified_name( message_db: List[MessageType], data_types, field: SerdeField ): @@ -262,6 +261,7 @@ def get_struct_schema_str(message: MessageType, message_db: List[MessageType]): return ret + def generate_photon_messages(cpp_java_root, py_root, template_root): messages = parse_yaml("messages.yaml") @@ -285,7 +285,7 @@ def generate_photon_messages(cpp_java_root, py_root, template_root): "len": -1, "java_type": name, "cpp_type": "photon::" + name, - "python_type": name + "python_type": name, } java_output_dir = Path(cpp_java_root) / "main/java/org/photonvision/struct" @@ -338,7 +338,7 @@ def generate_photon_messages(cpp_java_root, py_root, template_root): [cpp_serde_header_name, cpp_serde_header_template, cpp_serde_header_dir], [cpp_serde_source_name, cpp_serde_source_template, cpp_serde_source_dir], [cpp_struct_header_name, cpp_struct_header_template, cpp_struct_header_dir], - [py_name, py_template, py_serde_source_dir] + [py_name, py_template, py_serde_source_dir], ]: # Hack in our message getter template.globals["get_message_by_name"] = lambda name: get_message_by_name( @@ -376,13 +376,16 @@ def generate_photon_messages(cpp_java_root, py_root, template_root): cpp_includes=get_includes(messages, message), nested_photon_types=nested_photon_types, nested_wpilib_types=nested_wpilib_types, - test=False + test=False, ), encoding="utf-8", ) + # TODO: code duplication -def generate_tests(cpp_java_root, cpp_java_test_root, py_root, py_test_root, template_root): +def generate_tests( + cpp_java_root, cpp_java_test_root, py_root, py_test_root, template_root +): # Generate test messages test_messages = parse_yaml("test_messages.yaml") @@ -412,7 +415,7 @@ def generate_tests(cpp_java_root, cpp_java_test_root, py_root, py_test_root, tem "len": -1, "java_type": name, "cpp_type": "photon::" + name, - "python_type": name + "python_type": name, } java_output_dir = Path(cpp_java_root) / "main/java/org/photonvision/struct/test" @@ -423,12 +426,16 @@ def generate_tests(cpp_java_root, cpp_java_test_root, py_root, py_test_root, tem ) java_test_class_output_dir.mkdir(parents=True, exist_ok=True) - cpp_serde_header_dir = Path(cpp_java_root) / "main/native/include/photon/serde/test/" + cpp_serde_header_dir = ( + Path(cpp_java_root) / "main/native/include/photon/serde/test/" + ) cpp_serde_header_dir.mkdir(parents=True, exist_ok=True) cpp_serde_source_dir = Path(cpp_java_root) / "main/native/cpp/photon/serde/test/" cpp_serde_source_dir.mkdir(parents=True, exist_ok=True) - cpp_struct_header_dir = Path(cpp_java_root) / "main/native/include/photon/struct/test/" + cpp_struct_header_dir = ( + Path(cpp_java_root) / "main/native/include/photon/struct/test/" + ) cpp_struct_header_dir.mkdir(parents=True, exist_ok=True) cpp_test_struct_output_dir = ( @@ -439,9 +446,7 @@ def generate_tests(cpp_java_root, cpp_java_test_root, py_root, py_test_root, tem py_serde_source_dir = Path(py_root) / "test" py_serde_source_dir.mkdir(parents=True, exist_ok=True) - python_test_dataclass_output_dir = ( - Path(py_root) / "test" - ) + python_test_dataclass_output_dir = Path(py_root) / "test" env.filters["get_cpp_qualified_name"] = lambda field: get_cpp_qualified_name( message_db, extended_data_types, field @@ -490,9 +495,21 @@ def generate_tests(cpp_java_root, cpp_java_test_root, py_root, py_test_root, tem [cpp_serde_source_name, cpp_serde_source_template, cpp_serde_source_dir], [cpp_struct_header_name, cpp_struct_header_template, cpp_struct_header_dir], [py_name, py_template, py_serde_source_dir], - [java_test_class_name,java_test_class_template,java_test_class_output_dir], - [cpp_test_struct_name,cpp_test_struct_template,cpp_test_struct_output_dir], - [python_test_dataclass_name,python_test_dataclass_template,python_test_dataclass_output_dir] + [ + java_test_class_name, + java_test_class_template, + java_test_class_output_dir, + ], + [ + cpp_test_struct_name, + cpp_test_struct_template, + cpp_test_struct_output_dir, + ], + [ + python_test_dataclass_name, + python_test_dataclass_template, + python_test_dataclass_output_dir, + ], ]: # Hack in our message getter template.globals["get_message_by_name"] = lambda name: get_message_by_name( @@ -530,28 +547,27 @@ def generate_tests(cpp_java_root, cpp_java_test_root, py_root, py_test_root, tem cpp_includes=get_includes(message_db, test_message), nested_photon_types=nested_photon_types, nested_wpilib_types=nested_wpilib_types, - test=True + test=True, ), encoding="utf-8", ) # Generate test fixtures (WIP) tests = parse_yaml("tests.yaml") - java_test_target = Path(cpp_java_test_root) / "java/org/photonvision/AutoSerdeTest.java" + java_test_target = ( + Path(cpp_java_test_root) / "java/org/photonvision/AutoSerdeTest.java" + ) java_test_target.parent.mkdir(parents=True, exist_ok=True) cpp_test_target = Path(cpp_java_test_root) / "native/cpp/AutoSerdeTest.cpp" cpp_test_target.parent.mkdir(parents=True, exist_ok=True) - py_test_target = Path(py_test_root) / "AutoSerdeTest.py" - + Path(py_test_root) / "AutoSerdeTest.py" + java_test_template = env.get_template("ThingTests.java.jinja") cpp_test_template = env.get_template("ThingTests.cpp.jinja") - java_test_target.write_text( - java_test_template.render(tests) - ) - cpp_test_target.write_text( - cpp_test_template.render(tests) - ) + java_test_target.write_text(java_test_template.render(tests)) + cpp_test_target.write_text(cpp_test_template.render(tests)) + def main(argv): script_path = Path(__file__).resolve() @@ -591,12 +607,18 @@ def main(argv): parser.add_argument( "--tests", help="Generates tests and test messages instead of regular serde", - action="store_true" + action="store_true", ) args = parser.parse_args(argv) - if (args.tests): - generate_tests(args.cpp_java_output_dir, args.cpp_java_test_dir, args.py_output_dir, args.py_test_dir, args.template_root) + if args.tests: + generate_tests( + args.cpp_java_output_dir, + args.cpp_java_test_dir, + args.py_output_dir, + args.py_test_dir, + args.template_root, + ) else: generate_photon_messages( args.cpp_java_output_dir, args.py_output_dir, args.template_root diff --git a/photon-serde/messages.yaml b/photon-serde/messages.yaml index 78c39ddc09..8e960a0ad4 100644 --- a/photon-serde/messages.yaml +++ b/photon-serde/messages.yaml @@ -94,4 +94,4 @@ vla: True - name: multitagResult type: MultiTargetPNPResult - optional: True \ No newline at end of file + optional: True diff --git a/photon-serde/requirements.txt b/photon-serde/requirements.txt index 297c616082..454abc7a97 100644 --- a/photon-serde/requirements.txt +++ b/photon-serde/requirements.txt @@ -1,2 +1,2 @@ yaml -jinja2 \ No newline at end of file +jinja2 diff --git a/photon-serde/templates/ThingTestStruct.h.jinja b/photon-serde/templates/ThingTestStruct.h.jinja index b2e6c77a91..40f0e67cdd 100644 --- a/photon-serde/templates/ThingTestStruct.h.jinja +++ b/photon-serde/templates/ThingTestStruct.h.jinja @@ -48,4 +48,4 @@ public: }; } // namespace photon -#include "photon/serde/{{ name }}Serde.h" \ No newline at end of file +#include "photon/serde/test/{{ name }}Serde.h" \ No newline at end of file diff --git a/photon-serde/tests.yaml b/photon-serde/tests.yaml index 794e9f55fa..54618d628c 100644 --- a/photon-serde/tests.yaml +++ b/photon-serde/tests.yaml @@ -252,4 +252,4 @@ tests: - name: vlaTest java_value: 'List.of(new Transform3d(new Translation3d(1.0, 2.0, 3.0), new Rotation3d(0.1, 0.2, 0.3)), new Transform3d(new Translation3d(4.0, 5.0, 6.0), new Rotation3d(0.4, 0.5, 0.6)))' cpp_value: '{{1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}},{1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}},{8_m, 2_m, 1_m, wpi::math::Rotation3d{0_deg, 1_deg, 88_deg}}}' - python_value: '[Transform3d(Translation3d(1.0, 2.0, 3.0), Rotation3d(0.1, 0.2, 0.3)), Transform3d(Translation3d(4.0, 5.0, 6.0), Rotation3d(0.4, 0.5, 0.6))]' \ No newline at end of file + python_value: '[Transform3d(Translation3d(1.0, 2.0, 3.0), Rotation3d(0.1, 0.2, 0.3)), Transform3d(Translation3d(4.0, 5.0, 6.0), Rotation3d(0.4, 0.5, 0.6))]' From a1c61b69e0d3e3fbe63e726214272e3ff6b83bd2 Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Wed, 27 May 2026 14:20:45 -0400 Subject: [PATCH 30/42] moved serde tests out of photon-targeting and photonlibpy. python tests are still WIP --- .gitignore | 16 -- .wpiformat | 4 +- build.gradle | 2 +- .../generated/MultiTargetPNPResultSerde.py | 5 + .../generated/PhotonPipelineMetadataSerde.py | 4 + .../generated/PhotonPipelineResultSerde.py | 11 +- .../generated/PhotonTrackedTargetSerde.py | 5 + .../photonlibpy/generated/PnpResultSerde.py | 4 + .../generated/TargetCornerSerde.py | 4 + photon-serde-tests/README.md | 3 + photon-serde-tests/build.gradle | 139 +++++++++++ photon-serde-tests/py/BoolTestMessage.py | 42 ++++ .../py}/BoolTestMessageSerde.py | 9 +- photon-serde-tests/py/Float32TestMessage.py | 42 ++++ .../py}/Float32TestMessageSerde.py | 9 +- photon-serde-tests/py/Float64TestMessage.py | 42 ++++ .../py}/Float64TestMessageSerde.py | 9 +- photon-serde-tests/py/Int16TestMessage.py | 42 ++++ .../py}/Int16TestMessageSerde.py | 9 +- photon-serde-tests/py/Int32TestMessage.py | 42 ++++ .../py}/Int32TestMessageSerde.py | 9 +- photon-serde-tests/py/Int64TestMessage.py | 42 ++++ .../py}/Int64TestMessageSerde.py | 9 +- photon-serde-tests/py/Int8TestMessage.py | 42 ++++ .../py}/Int8TestMessageSerde.py | 9 +- .../py/Transform3dTestMessage.py | 42 ++++ .../py}/Transform3dTestMessageSerde.py | 9 +- .../struct/BoolTestMessageSerde.java | 102 ++++++++ .../struct/Float32TestMessageSerde.java | 102 ++++++++ .../struct/Float64TestMessageSerde.java | 102 ++++++++ .../struct/Int16TestMessageSerde.java | 102 ++++++++ .../struct/Int32TestMessageSerde.java | 102 ++++++++ .../struct/Int64TestMessageSerde.java | 102 ++++++++ .../struct/Int8TestMessageSerde.java | 102 ++++++++ .../struct/Transform3dTestMessageSerde.java | 102 ++++++++ .../targeting/BoolTestMessage.java | 80 ++++++ .../targeting/Float32TestMessage.java | 80 ++++++ .../targeting/Float64TestMessage.java | 80 ++++++ .../targeting/Int16TestMessage.java | 80 ++++++ .../targeting/Int32TestMessage.java | 80 ++++++ .../targeting/Int64TestMessage.java | 80 ++++++ .../targeting/Int8TestMessage.java | 80 ++++++ .../targeting/Transform3dTestMessage.java | 80 ++++++ .../cpp/photon/serde/BoolTestMessageSerde.cpp | 48 ++++ .../photon/serde/Float32TestMessageSerde.cpp | 48 ++++ .../photon/serde/Float64TestMessageSerde.cpp | 48 ++++ .../photon/serde/Int16TestMessageSerde.cpp | 48 ++++ .../photon/serde/Int32TestMessageSerde.cpp | 48 ++++ .../photon/serde/Int64TestMessageSerde.cpp | 48 ++++ .../cpp/photon/serde/Int8TestMessageSerde.cpp | 48 ++++ .../serde/Transform3dTestMessageSerde.cpp | 48 ++++ .../photon/serde/BoolTestMessageSerde.h | 59 +++++ .../photon/serde/Float32TestMessageSerde.h | 59 +++++ .../photon/serde/Float64TestMessageSerde.h | 59 +++++ .../photon/serde/Int16TestMessageSerde.h | 59 +++++ .../photon/serde/Int32TestMessageSerde.h | 59 +++++ .../photon/serde/Int64TestMessageSerde.h | 59 +++++ .../photon/serde/Int8TestMessageSerde.h | 59 +++++ .../serde/Transform3dTestMessageSerde.h | 60 +++++ .../photon/struct/BoolTestMessageStruct.h | 45 ++++ .../photon/struct/Float32TestMessageStruct.h | 45 ++++ .../photon/struct/Float64TestMessageStruct.h | 45 ++++ .../photon/struct/Int16TestMessageStruct.h | 45 ++++ .../photon/struct/Int32TestMessageStruct.h | 45 ++++ .../photon/struct/Int64TestMessageStruct.h | 45 ++++ .../photon/struct/Int8TestMessageStruct.h | 45 ++++ .../struct/Transform3dTestMessageStruct.h | 46 ++++ .../photon/targeting/BoolTestMessage.h | 51 ++++ .../photon/targeting/Float32TestMessage.h | 51 ++++ .../photon/targeting/Float64TestMessage.h | 51 ++++ .../photon/targeting/Int16TestMessage.h | 51 ++++ .../photon/targeting/Int32TestMessage.h | 51 ++++ .../photon/targeting/Int64TestMessage.h | 51 ++++ .../photon/targeting/Int8TestMessage.h | 51 ++++ .../photon/targeting/Transform3dTestMessage.h | 51 ++++ .../java/org/photonvision/AutoSerdeTest.java | 229 +++++++++++++++++ .../src/test/native/cpp/AutoSerdeTest.cpp | 236 ++++++++++++++++++ photon-serde/generate_messages.py | 50 ++-- photon-serde/templates/Message.java.jinja | 4 - photon-serde/templates/ThingSerde.cpp.jinja | 4 - photon-serde/templates/ThingSerde.py.jinja | 4 +- .../templates/ThingTestClass.java.jinja | 2 +- .../templates/ThingTestDataclass.py.jinja | 4 +- .../templates/ThingTestStruct.h.jinja | 4 +- photon-serde/templates/ThingTests.cpp.jinja | 8 +- photon-serde/tests.yaml | 6 +- .../struct/PhotonPipelineResultSerde.java | 2 +- .../serde/MultiTargetPNPResultSerde.cpp | 1 + .../serde/PhotonPipelineMetadataSerde.cpp | 1 + .../serde/PhotonPipelineResultSerde.cpp | 1 + .../photon/serde/PhotonTrackedTargetSerde.cpp | 1 + .../cpp/photon/serde/PnpResultSerde.cpp | 1 + .../cpp/photon/serde/TargetCornerSerde.cpp | 1 + settings.gradle | 1 + 94 files changed, 4153 insertions(+), 94 deletions(-) create mode 100644 photon-serde-tests/README.md create mode 100644 photon-serde-tests/build.gradle create mode 100644 photon-serde-tests/py/BoolTestMessage.py rename {photon-lib/py/photonlibpy/generated => photon-serde-tests/py}/BoolTestMessageSerde.py (95%) create mode 100644 photon-serde-tests/py/Float32TestMessage.py rename {photon-lib/py/photonlibpy/generated => photon-serde-tests/py}/Float32TestMessageSerde.py (95%) create mode 100644 photon-serde-tests/py/Float64TestMessage.py rename {photon-lib/py/photonlibpy/generated => photon-serde-tests/py}/Float64TestMessageSerde.py (95%) create mode 100644 photon-serde-tests/py/Int16TestMessage.py rename {photon-lib/py/photonlibpy/generated => photon-serde-tests/py}/Int16TestMessageSerde.py (95%) create mode 100644 photon-serde-tests/py/Int32TestMessage.py rename {photon-lib/py/photonlibpy/generated => photon-serde-tests/py}/Int32TestMessageSerde.py (95%) create mode 100644 photon-serde-tests/py/Int64TestMessage.py rename {photon-lib/py/photonlibpy/generated => photon-serde-tests/py}/Int64TestMessageSerde.py (95%) create mode 100644 photon-serde-tests/py/Int8TestMessage.py rename {photon-lib/py/photonlibpy/generated => photon-serde-tests/py}/Int8TestMessageSerde.py (95%) create mode 100644 photon-serde-tests/py/Transform3dTestMessage.py rename {photon-lib/py/photonlibpy/generated => photon-serde-tests/py}/Transform3dTestMessageSerde.py (94%) create mode 100644 photon-serde-tests/src/main/java/org/photonvision/struct/BoolTestMessageSerde.java create mode 100644 photon-serde-tests/src/main/java/org/photonvision/struct/Float32TestMessageSerde.java create mode 100644 photon-serde-tests/src/main/java/org/photonvision/struct/Float64TestMessageSerde.java create mode 100644 photon-serde-tests/src/main/java/org/photonvision/struct/Int16TestMessageSerde.java create mode 100644 photon-serde-tests/src/main/java/org/photonvision/struct/Int32TestMessageSerde.java create mode 100644 photon-serde-tests/src/main/java/org/photonvision/struct/Int64TestMessageSerde.java create mode 100644 photon-serde-tests/src/main/java/org/photonvision/struct/Int8TestMessageSerde.java create mode 100644 photon-serde-tests/src/main/java/org/photonvision/struct/Transform3dTestMessageSerde.java create mode 100644 photon-serde-tests/src/main/java/org/photonvision/targeting/BoolTestMessage.java create mode 100644 photon-serde-tests/src/main/java/org/photonvision/targeting/Float32TestMessage.java create mode 100644 photon-serde-tests/src/main/java/org/photonvision/targeting/Float64TestMessage.java create mode 100644 photon-serde-tests/src/main/java/org/photonvision/targeting/Int16TestMessage.java create mode 100644 photon-serde-tests/src/main/java/org/photonvision/targeting/Int32TestMessage.java create mode 100644 photon-serde-tests/src/main/java/org/photonvision/targeting/Int64TestMessage.java create mode 100644 photon-serde-tests/src/main/java/org/photonvision/targeting/Int8TestMessage.java create mode 100644 photon-serde-tests/src/main/java/org/photonvision/targeting/Transform3dTestMessage.java create mode 100644 photon-serde-tests/src/main/native/cpp/photon/serde/BoolTestMessageSerde.cpp create mode 100644 photon-serde-tests/src/main/native/cpp/photon/serde/Float32TestMessageSerde.cpp create mode 100644 photon-serde-tests/src/main/native/cpp/photon/serde/Float64TestMessageSerde.cpp create mode 100644 photon-serde-tests/src/main/native/cpp/photon/serde/Int16TestMessageSerde.cpp create mode 100644 photon-serde-tests/src/main/native/cpp/photon/serde/Int32TestMessageSerde.cpp create mode 100644 photon-serde-tests/src/main/native/cpp/photon/serde/Int64TestMessageSerde.cpp create mode 100644 photon-serde-tests/src/main/native/cpp/photon/serde/Int8TestMessageSerde.cpp create mode 100644 photon-serde-tests/src/main/native/cpp/photon/serde/Transform3dTestMessageSerde.cpp create mode 100644 photon-serde-tests/src/main/native/include/photon/serde/BoolTestMessageSerde.h create mode 100644 photon-serde-tests/src/main/native/include/photon/serde/Float32TestMessageSerde.h create mode 100644 photon-serde-tests/src/main/native/include/photon/serde/Float64TestMessageSerde.h create mode 100644 photon-serde-tests/src/main/native/include/photon/serde/Int16TestMessageSerde.h create mode 100644 photon-serde-tests/src/main/native/include/photon/serde/Int32TestMessageSerde.h create mode 100644 photon-serde-tests/src/main/native/include/photon/serde/Int64TestMessageSerde.h create mode 100644 photon-serde-tests/src/main/native/include/photon/serde/Int8TestMessageSerde.h create mode 100644 photon-serde-tests/src/main/native/include/photon/serde/Transform3dTestMessageSerde.h create mode 100644 photon-serde-tests/src/main/native/include/photon/struct/BoolTestMessageStruct.h create mode 100644 photon-serde-tests/src/main/native/include/photon/struct/Float32TestMessageStruct.h create mode 100644 photon-serde-tests/src/main/native/include/photon/struct/Float64TestMessageStruct.h create mode 100644 photon-serde-tests/src/main/native/include/photon/struct/Int16TestMessageStruct.h create mode 100644 photon-serde-tests/src/main/native/include/photon/struct/Int32TestMessageStruct.h create mode 100644 photon-serde-tests/src/main/native/include/photon/struct/Int64TestMessageStruct.h create mode 100644 photon-serde-tests/src/main/native/include/photon/struct/Int8TestMessageStruct.h create mode 100644 photon-serde-tests/src/main/native/include/photon/struct/Transform3dTestMessageStruct.h create mode 100644 photon-serde-tests/src/main/native/include/photon/targeting/BoolTestMessage.h create mode 100644 photon-serde-tests/src/main/native/include/photon/targeting/Float32TestMessage.h create mode 100644 photon-serde-tests/src/main/native/include/photon/targeting/Float64TestMessage.h create mode 100644 photon-serde-tests/src/main/native/include/photon/targeting/Int16TestMessage.h create mode 100644 photon-serde-tests/src/main/native/include/photon/targeting/Int32TestMessage.h create mode 100644 photon-serde-tests/src/main/native/include/photon/targeting/Int64TestMessage.h create mode 100644 photon-serde-tests/src/main/native/include/photon/targeting/Int8TestMessage.h create mode 100644 photon-serde-tests/src/main/native/include/photon/targeting/Transform3dTestMessage.h create mode 100644 photon-serde-tests/src/test/java/org/photonvision/AutoSerdeTest.java create mode 100644 photon-serde-tests/src/test/native/cpp/AutoSerdeTest.cpp diff --git a/.gitignore b/.gitignore index 4dceacfe17..032a1d7e11 100644 --- a/.gitignore +++ b/.gitignore @@ -163,19 +163,3 @@ flake.nix flake.lock /workspace - -# photon-serde tests (Java & Cpp) -photon-targeting/src/generated/main/java/org/photonvision/targeting -photon-targeting/src/generated/main/java/org/photonvision/struct/test - -photon-targeting/src/generated/main/cpp/photon/serde/test -photon-targeting/src/generated/main/native/include/photon/targeting -photon-targeting/src/generated/main/native/include/photon/serde/test -photon-targeting/src/generated/main/native/cpp/photon/serde/test -photon-targeting/src/generated/main/native/include/photon/struct/test -photon-targeting/src/generated/main/native/include/photon/targeting -photon-targeting/src/generated-test - -# photon-serde tests (Python) -photon-lib/py/photonlibpy/generated/test -photon-lib/py/generated-test diff --git a/.wpiformat b/.wpiformat index 74349964d3..86834211c7 100644 --- a/.wpiformat +++ b/.wpiformat @@ -4,10 +4,10 @@ cppHeaderFileInclude { generatedFileExclude { photon-lib/py/photonlibpy/generated/ - photon-lib/py/generated-test photon-targeting/src/generated/ - photon-targeting/src/generated-test/ photon-targeting/src/main/native/cpp/photon/constrained_solvepnp/generate/ + photon-serde-tests/src + photon-serde-tests/py } licenseUpdateExclude { diff --git a/build.gradle b/build.gradle index f8bc2ff762..2a41a1125d 100644 --- a/build.gradle +++ b/build.gradle @@ -65,7 +65,7 @@ spotless { java { target fileTree('.') { include '**/*.java' - exclude '**/build/**', '**/build-*/**', '**/src/generated/**', '**/src/generated-test/**', "**/bin/generated-sources/**" + exclude '**/build/**', '**/build-*/**', '**/src/generated/**', '**/src/generated-test/**', "**/bin/generated-sources/**", "photon-serde-tests/src/**" } toggleOffOn() googleJavaFormat() diff --git a/photon-lib/py/photonlibpy/generated/MultiTargetPNPResultSerde.py b/photon-lib/py/photonlibpy/generated/MultiTargetPNPResultSerde.py index c7192ad1f9..6a40dd0058 100644 --- a/photon-lib/py/photonlibpy/generated/MultiTargetPNPResultSerde.py +++ b/photon-lib/py/photonlibpy/generated/MultiTargetPNPResultSerde.py @@ -29,14 +29,19 @@ from typing import TYPE_CHECKING + from ..packet import Packet from ..targeting import * # noqa + + if TYPE_CHECKING: from ..targeting import MultiTargetPNPResult # noqa + from ..targeting import PnpResult # noqa + class MultiTargetPNPResultSerde: # Message definition md5sum. See photon_packet.adoc for details MESSAGE_VERSION = "541096947e9f3ca2d3f425ff7b04aa7b" diff --git a/photon-lib/py/photonlibpy/generated/PhotonPipelineMetadataSerde.py b/photon-lib/py/photonlibpy/generated/PhotonPipelineMetadataSerde.py index 9ec396384e..3ce40fd36c 100644 --- a/photon-lib/py/photonlibpy/generated/PhotonPipelineMetadataSerde.py +++ b/photon-lib/py/photonlibpy/generated/PhotonPipelineMetadataSerde.py @@ -29,13 +29,17 @@ from typing import TYPE_CHECKING + from ..packet import Packet from ..targeting import * # noqa + + if TYPE_CHECKING: from ..targeting import PhotonPipelineMetadata # noqa + class PhotonPipelineMetadataSerde: # Message definition md5sum. See photon_packet.adoc for details MESSAGE_VERSION = "ac0a45f686457856fb30af77699ea356" diff --git a/photon-lib/py/photonlibpy/generated/PhotonPipelineResultSerde.py b/photon-lib/py/photonlibpy/generated/PhotonPipelineResultSerde.py index 9bb1a715db..33d1abc5ab 100644 --- a/photon-lib/py/photonlibpy/generated/PhotonPipelineResultSerde.py +++ b/photon-lib/py/photonlibpy/generated/PhotonPipelineResultSerde.py @@ -29,16 +29,23 @@ from typing import TYPE_CHECKING + from ..packet import Packet from ..targeting import * # noqa + + if TYPE_CHECKING: from ..targeting import MultiTargetPNPResult # noqa + from ..targeting import PhotonPipelineMetadata # noqa + from ..targeting import PhotonPipelineResult # noqa + from ..targeting import PhotonTrackedTarget # noqa + class PhotonPipelineResultSerde: # Message definition md5sum. See photon_packet.adoc for details MESSAGE_VERSION = "4b2ff16a964b5e2bf04be0c1454d91c4" @@ -49,9 +56,7 @@ def pack(value: "PhotonPipelineResult") -> "Packet": ret = Packet() # metadata is of non-intrinsic type PhotonPipelineMetadata - ret.encodeBytes( - PhotonPipelineMetadata.photonStruct.pack(value.metadata).getData() - ) + ret.encodeBytes(PhotonPipelineMetadata.photonStruct.pack(value.metadata).getData()) # targets is a custom VLA! ret.encodeList(value.targets, PhotonTrackedTarget.photonStruct) diff --git a/photon-lib/py/photonlibpy/generated/PhotonTrackedTargetSerde.py b/photon-lib/py/photonlibpy/generated/PhotonTrackedTargetSerde.py index ebe96fc34b..617488653a 100644 --- a/photon-lib/py/photonlibpy/generated/PhotonTrackedTargetSerde.py +++ b/photon-lib/py/photonlibpy/generated/PhotonTrackedTargetSerde.py @@ -29,14 +29,19 @@ from typing import TYPE_CHECKING + from ..packet import Packet from ..targeting import * # noqa + + if TYPE_CHECKING: from ..targeting import PhotonTrackedTarget # noqa + from ..targeting import TargetCorner # noqa + class PhotonTrackedTargetSerde: # Message definition md5sum. See photon_packet.adoc for details MESSAGE_VERSION = "cc6dbb5c5c1e0fa808108019b20863f1" diff --git a/photon-lib/py/photonlibpy/generated/PnpResultSerde.py b/photon-lib/py/photonlibpy/generated/PnpResultSerde.py index 0447c69076..e053c4eb6f 100644 --- a/photon-lib/py/photonlibpy/generated/PnpResultSerde.py +++ b/photon-lib/py/photonlibpy/generated/PnpResultSerde.py @@ -29,13 +29,17 @@ from typing import TYPE_CHECKING + from ..packet import Packet from ..targeting import * # noqa + + if TYPE_CHECKING: from ..targeting import PnpResult # noqa + class PnpResultSerde: # Message definition md5sum. See photon_packet.adoc for details MESSAGE_VERSION = "ae4d655c0a3104d88df4f5db144c1e86" diff --git a/photon-lib/py/photonlibpy/generated/TargetCornerSerde.py b/photon-lib/py/photonlibpy/generated/TargetCornerSerde.py index 3fe56a7d7e..e4c2136b7f 100644 --- a/photon-lib/py/photonlibpy/generated/TargetCornerSerde.py +++ b/photon-lib/py/photonlibpy/generated/TargetCornerSerde.py @@ -29,13 +29,17 @@ from typing import TYPE_CHECKING + from ..packet import Packet from ..targeting import * # noqa + + if TYPE_CHECKING: from ..targeting import TargetCorner # noqa + class TargetCornerSerde: # Message definition md5sum. See photon_packet.adoc for details MESSAGE_VERSION = "16f6ac0dedc8eaccb951f4895d9e18b6" diff --git a/photon-serde-tests/README.md b/photon-serde-tests/README.md new file mode 100644 index 0000000000..6e63218089 --- /dev/null +++ b/photon-serde-tests/README.md @@ -0,0 +1,3 @@ +These are autogenerated tests for photon-serde. ALL CODE IN THIS DIRECTORY (except for build.gradle) IS AUTOMATICALLY GENERATED + +These tests are separated from the main code as we don't use the autogenerated photon-serde test messages anywhere except in the tests, and we don't want to expose them to end-users in photon-lib diff --git a/photon-serde-tests/build.gradle b/photon-serde-tests/build.gradle new file mode 100644 index 0000000000..c95fb2a04d --- /dev/null +++ b/photon-serde-tests/build.gradle @@ -0,0 +1,139 @@ +ext { + nativeName = "photonserdetest" + includePhotonTargeting = true +} + +apply plugin: 'cpp' +apply plugin: 'c' +apply plugin: 'google-test-test-suite' +apply plugin: 'org.wpilib.NativeUtils' +apply plugin: 'org.photonvision.tools.WpilibTools' +apply plugin: 'org.wpilib.GradleJni' + +ext.licenseFile = file("$rootDir/LICENSE") +apply from: "${rootDir}/shared/config.gradle" +apply from: "${rootDir}/shared/javacommon.gradle" + +nativeUtils { + exportsConfigs { + "${nativeName}" {} + } +} + +model { + components { + "${nativeName}"(NativeLibrarySpec) { + sources { + cpp { + source { + srcDirs 'src/main/native/cpp' + include '**/*.cpp', '**/*.cc' + } + exportedHeaders { + srcDirs 'src/main/native/include' + include "**/*.h" + } + } + } + + binaries.all { + if(project.hasProperty('includePhotonTargeting')) { + lib project: ':photon-targeting', library: 'photontargeting', linkage: 'shared' + } + } + + nativeUtils.useRequiredLibrary(it, "wpiutil_shared") + nativeUtils.useRequiredLibrary(it, "datalog_shared") + nativeUtils.useRequiredLibrary(it, "wpimath_shared") + } + } + testSuites { + "${nativeName}Test"(GoogleTestTestSuiteSpec) { + for(NativeComponentSpec c : $.components) { + if (c.name == nativeName) { + testing c + break + } + } + sources { + cpp { + source { + srcDirs 'src/test/native/cpp' + include '**/*.cpp' + } + exportedHeaders { + srcDirs 'src/test/native/include' + } + } + } + + binaries.all { + lib library: nativeName, linkage: 'shared' + if(project.hasProperty('includePhotonTargeting')) { + lib project: ':photon-targeting', library: 'photontargeting', linkage: 'shared' + } + } + + nativeUtils.useRequiredLibrary(it, "wpilib_shared") + nativeUtils.useRequiredLibrary(it, "googletest_static") + nativeUtils.useRequiredLibrary(it, "datalog_shared") + } + } + + tasks { + def c = $.testSuites + project.tasks.create('runCpp', Exec) { + description = "Run the photon-lib executable" + def found = false + def systemArch = getCurrentArch() + c.each { + if (it in GoogleTestTestSuiteSpec && it.name == "${nativeName}Test") { + it.binaries.each { + if (!found) { + def arch = it.targetPlatform.name + if (arch == systemArch) { + dependsOn it.tasks.install + commandLine it.tasks.install.runScriptFile.get().asFile.toString() + def filePath = it.tasks.install.installDirectory.get().toString() + File.separatorChar + 'lib' + test.dependsOn it.tasks.install + test.systemProperty 'java.library.path', filePath + test.environment 'LD_LIBRARY_PATH', filePath + test.environment 'DYLD_LIBRARY_PATH', filePath + test.workingDir filePath + + found = true + } + } + } + } + } + } + } +} + +apply from: "${rootDir}/shared/javacpp/publish.gradle" + +// setup wpilib bundled native libs +wpilibTools.deps.wpilibVersion = wpilibVersion + +def nativeConfigName = 'wpilibNatives' +def nativeConfig = configurations.create(nativeConfigName) + +def nativeTasks = wpilibTools.createExtractionTasks { + configurationName = nativeConfigName +} + +nativeTasks.addToSourceSetResources(sourceSets.test) + +dependencies { + wpilibNatives project(":photon-targeting") +} +nativeConfig.dependencies.add wpilibTools.deps.wpilib("wpiutil") +nativeConfig.dependencies.add wpilibTools.deps.wpilib("datalog") +nativeConfig.dependencies.add wpilibTools.deps.wpilib("wpimath") +nativeConfig.dependencies.add wpilibTools.deps.wpilib("wpinet") +nativeConfig.dependencies.add wpilibTools.deps.wpilib("ntcore") +nativeConfig.dependencies.add wpilibTools.deps.wpilib("hal") +nativeConfig.dependencies.add wpilibTools.deps.wpilib("cscore") +nativeConfig.dependencies.add wpilibTools.deps.wpilibOpenCv(openCVversion) +nativeConfig.dependencies.add wpilibTools.deps.wpilib("apriltag") diff --git a/photon-serde-tests/py/BoolTestMessage.py b/photon-serde-tests/py/BoolTestMessage.py new file mode 100644 index 0000000000..89a8391cb8 --- /dev/null +++ b/photon-serde-tests/py/BoolTestMessage.py @@ -0,0 +1,42 @@ +# +# MIT License +# +# Copyright (c) PhotonVision +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +############################################################################### +## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. +## --> DO NOT MODIFY <-- +############################################################################### + +from typing import TYPE_CHECKING, Optional +from dataclasses import dataclass + +from photonlib.packet import Packet +from photonlib.targeting import * # noqa + + + +@dataclass +class BoolTestMessage: + test: bool + vlaTest: list[bool] + optTest: Optional[bool] \ No newline at end of file diff --git a/photon-lib/py/photonlibpy/generated/BoolTestMessageSerde.py b/photon-serde-tests/py/BoolTestMessageSerde.py similarity index 95% rename from photon-lib/py/photonlibpy/generated/BoolTestMessageSerde.py rename to photon-serde-tests/py/BoolTestMessageSerde.py index 3fed217391..efbbd1dd73 100644 --- a/photon-lib/py/photonlibpy/generated/BoolTestMessageSerde.py +++ b/photon-serde-tests/py/BoolTestMessageSerde.py @@ -29,11 +29,14 @@ from typing import TYPE_CHECKING -from ..packet import Packet -from ..targeting import * # noqa + +from photonlib.packet import Packet +from photonlib.targeting import * # noqa + + if TYPE_CHECKING: - from ..targeting import BoolTestMessage # noqa + from ...targeting import BoolTestMessage # noqa class BoolTestMessageSerde: diff --git a/photon-serde-tests/py/Float32TestMessage.py b/photon-serde-tests/py/Float32TestMessage.py new file mode 100644 index 0000000000..cc72b080f1 --- /dev/null +++ b/photon-serde-tests/py/Float32TestMessage.py @@ -0,0 +1,42 @@ +# +# MIT License +# +# Copyright (c) PhotonVision +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +############################################################################### +## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. +## --> DO NOT MODIFY <-- +############################################################################### + +from typing import TYPE_CHECKING, Optional +from dataclasses import dataclass + +from photonlib.packet import Packet +from photonlib.targeting import * # noqa + + + +@dataclass +class Float32TestMessage: + test: float + vlaTest: list[float] + optTest: Optional[float] \ No newline at end of file diff --git a/photon-lib/py/photonlibpy/generated/Float32TestMessageSerde.py b/photon-serde-tests/py/Float32TestMessageSerde.py similarity index 95% rename from photon-lib/py/photonlibpy/generated/Float32TestMessageSerde.py rename to photon-serde-tests/py/Float32TestMessageSerde.py index b7fe2c4d73..73c8e596e2 100644 --- a/photon-lib/py/photonlibpy/generated/Float32TestMessageSerde.py +++ b/photon-serde-tests/py/Float32TestMessageSerde.py @@ -29,11 +29,14 @@ from typing import TYPE_CHECKING -from ..packet import Packet -from ..targeting import * # noqa + +from photonlib.packet import Packet +from photonlib.targeting import * # noqa + + if TYPE_CHECKING: - from ..targeting import Float32TestMessage # noqa + from ...targeting import Float32TestMessage # noqa class Float32TestMessageSerde: diff --git a/photon-serde-tests/py/Float64TestMessage.py b/photon-serde-tests/py/Float64TestMessage.py new file mode 100644 index 0000000000..e84fa592e1 --- /dev/null +++ b/photon-serde-tests/py/Float64TestMessage.py @@ -0,0 +1,42 @@ +# +# MIT License +# +# Copyright (c) PhotonVision +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +############################################################################### +## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. +## --> DO NOT MODIFY <-- +############################################################################### + +from typing import TYPE_CHECKING, Optional +from dataclasses import dataclass + +from photonlib.packet import Packet +from photonlib.targeting import * # noqa + + + +@dataclass +class Float64TestMessage: + test: float + vlaTest: list[float] + optTest: Optional[float] \ No newline at end of file diff --git a/photon-lib/py/photonlibpy/generated/Float64TestMessageSerde.py b/photon-serde-tests/py/Float64TestMessageSerde.py similarity index 95% rename from photon-lib/py/photonlibpy/generated/Float64TestMessageSerde.py rename to photon-serde-tests/py/Float64TestMessageSerde.py index 1ae7d6e678..169727bdea 100644 --- a/photon-lib/py/photonlibpy/generated/Float64TestMessageSerde.py +++ b/photon-serde-tests/py/Float64TestMessageSerde.py @@ -29,11 +29,14 @@ from typing import TYPE_CHECKING -from ..packet import Packet -from ..targeting import * # noqa + +from photonlib.packet import Packet +from photonlib.targeting import * # noqa + + if TYPE_CHECKING: - from ..targeting import Float64TestMessage # noqa + from ...targeting import Float64TestMessage # noqa class Float64TestMessageSerde: diff --git a/photon-serde-tests/py/Int16TestMessage.py b/photon-serde-tests/py/Int16TestMessage.py new file mode 100644 index 0000000000..96e541ab75 --- /dev/null +++ b/photon-serde-tests/py/Int16TestMessage.py @@ -0,0 +1,42 @@ +# +# MIT License +# +# Copyright (c) PhotonVision +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +############################################################################### +## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. +## --> DO NOT MODIFY <-- +############################################################################### + +from typing import TYPE_CHECKING, Optional +from dataclasses import dataclass + +from photonlib.packet import Packet +from photonlib.targeting import * # noqa + + + +@dataclass +class Int16TestMessage: + test: int + vlaTest: list[int] + optTest: Optional[int] \ No newline at end of file diff --git a/photon-lib/py/photonlibpy/generated/Int16TestMessageSerde.py b/photon-serde-tests/py/Int16TestMessageSerde.py similarity index 95% rename from photon-lib/py/photonlibpy/generated/Int16TestMessageSerde.py rename to photon-serde-tests/py/Int16TestMessageSerde.py index a1b6bc8758..4cba3831bb 100644 --- a/photon-lib/py/photonlibpy/generated/Int16TestMessageSerde.py +++ b/photon-serde-tests/py/Int16TestMessageSerde.py @@ -29,11 +29,14 @@ from typing import TYPE_CHECKING -from ..packet import Packet -from ..targeting import * # noqa + +from photonlib.packet import Packet +from photonlib.targeting import * # noqa + + if TYPE_CHECKING: - from ..targeting import Int16TestMessage # noqa + from ...targeting import Int16TestMessage # noqa class Int16TestMessageSerde: diff --git a/photon-serde-tests/py/Int32TestMessage.py b/photon-serde-tests/py/Int32TestMessage.py new file mode 100644 index 0000000000..7ae8be1fcb --- /dev/null +++ b/photon-serde-tests/py/Int32TestMessage.py @@ -0,0 +1,42 @@ +# +# MIT License +# +# Copyright (c) PhotonVision +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +############################################################################### +## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. +## --> DO NOT MODIFY <-- +############################################################################### + +from typing import TYPE_CHECKING, Optional +from dataclasses import dataclass + +from photonlib.packet import Packet +from photonlib.targeting import * # noqa + + + +@dataclass +class Int32TestMessage: + test: int + vlaTest: list[int] + optTest: Optional[int] \ No newline at end of file diff --git a/photon-lib/py/photonlibpy/generated/Int32TestMessageSerde.py b/photon-serde-tests/py/Int32TestMessageSerde.py similarity index 95% rename from photon-lib/py/photonlibpy/generated/Int32TestMessageSerde.py rename to photon-serde-tests/py/Int32TestMessageSerde.py index a86fbd1ee4..cc8aef6aa0 100644 --- a/photon-lib/py/photonlibpy/generated/Int32TestMessageSerde.py +++ b/photon-serde-tests/py/Int32TestMessageSerde.py @@ -29,11 +29,14 @@ from typing import TYPE_CHECKING -from ..packet import Packet -from ..targeting import * # noqa + +from photonlib.packet import Packet +from photonlib.targeting import * # noqa + + if TYPE_CHECKING: - from ..targeting import Int32TestMessage # noqa + from ...targeting import Int32TestMessage # noqa class Int32TestMessageSerde: diff --git a/photon-serde-tests/py/Int64TestMessage.py b/photon-serde-tests/py/Int64TestMessage.py new file mode 100644 index 0000000000..6d9daa7088 --- /dev/null +++ b/photon-serde-tests/py/Int64TestMessage.py @@ -0,0 +1,42 @@ +# +# MIT License +# +# Copyright (c) PhotonVision +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +############################################################################### +## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. +## --> DO NOT MODIFY <-- +############################################################################### + +from typing import TYPE_CHECKING, Optional +from dataclasses import dataclass + +from photonlib.packet import Packet +from photonlib.targeting import * # noqa + + + +@dataclass +class Int64TestMessage: + test: int + vlaTest: list[int] + optTest: Optional[int] \ No newline at end of file diff --git a/photon-lib/py/photonlibpy/generated/Int64TestMessageSerde.py b/photon-serde-tests/py/Int64TestMessageSerde.py similarity index 95% rename from photon-lib/py/photonlibpy/generated/Int64TestMessageSerde.py rename to photon-serde-tests/py/Int64TestMessageSerde.py index 7c1739c0b2..fb1673535d 100644 --- a/photon-lib/py/photonlibpy/generated/Int64TestMessageSerde.py +++ b/photon-serde-tests/py/Int64TestMessageSerde.py @@ -29,11 +29,14 @@ from typing import TYPE_CHECKING -from ..packet import Packet -from ..targeting import * # noqa + +from photonlib.packet import Packet +from photonlib.targeting import * # noqa + + if TYPE_CHECKING: - from ..targeting import Int64TestMessage # noqa + from ...targeting import Int64TestMessage # noqa class Int64TestMessageSerde: diff --git a/photon-serde-tests/py/Int8TestMessage.py b/photon-serde-tests/py/Int8TestMessage.py new file mode 100644 index 0000000000..03aeb409b0 --- /dev/null +++ b/photon-serde-tests/py/Int8TestMessage.py @@ -0,0 +1,42 @@ +# +# MIT License +# +# Copyright (c) PhotonVision +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +############################################################################### +## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. +## --> DO NOT MODIFY <-- +############################################################################### + +from typing import TYPE_CHECKING, Optional +from dataclasses import dataclass + +from photonlib.packet import Packet +from photonlib.targeting import * # noqa + + + +@dataclass +class Int8TestMessage: + test: int + vlaTest: list[int] + optTest: Optional[int] \ No newline at end of file diff --git a/photon-lib/py/photonlibpy/generated/Int8TestMessageSerde.py b/photon-serde-tests/py/Int8TestMessageSerde.py similarity index 95% rename from photon-lib/py/photonlibpy/generated/Int8TestMessageSerde.py rename to photon-serde-tests/py/Int8TestMessageSerde.py index 5361f47e93..ce4dc130b7 100644 --- a/photon-lib/py/photonlibpy/generated/Int8TestMessageSerde.py +++ b/photon-serde-tests/py/Int8TestMessageSerde.py @@ -29,11 +29,14 @@ from typing import TYPE_CHECKING -from ..packet import Packet -from ..targeting import * # noqa + +from photonlib.packet import Packet +from photonlib.targeting import * # noqa + + if TYPE_CHECKING: - from ..targeting import Int8TestMessage # noqa + from ...targeting import Int8TestMessage # noqa class Int8TestMessageSerde: diff --git a/photon-serde-tests/py/Transform3dTestMessage.py b/photon-serde-tests/py/Transform3dTestMessage.py new file mode 100644 index 0000000000..976b91a128 --- /dev/null +++ b/photon-serde-tests/py/Transform3dTestMessage.py @@ -0,0 +1,42 @@ +# +# MIT License +# +# Copyright (c) PhotonVision +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +############################################################################### +## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. +## --> DO NOT MODIFY <-- +############################################################################### + +from typing import TYPE_CHECKING, Optional +from dataclasses import dataclass + +from photonlib.packet import Packet +from photonlib.targeting import * # noqa + +from wpimath.geometry import Transform3d + +@dataclass +class Transform3dTestMessage: + test: Transform3d + vlaTest: list[Transform3d] + optTest: Optional[Transform3d] \ No newline at end of file diff --git a/photon-lib/py/photonlibpy/generated/Transform3dTestMessageSerde.py b/photon-serde-tests/py/Transform3dTestMessageSerde.py similarity index 94% rename from photon-lib/py/photonlibpy/generated/Transform3dTestMessageSerde.py rename to photon-serde-tests/py/Transform3dTestMessageSerde.py index 93b88082ed..8be7b35cbe 100644 --- a/photon-lib/py/photonlibpy/generated/Transform3dTestMessageSerde.py +++ b/photon-serde-tests/py/Transform3dTestMessageSerde.py @@ -29,11 +29,14 @@ from typing import TYPE_CHECKING -from ..packet import Packet -from ..targeting import * # noqa + +from photonlib.packet import Packet +from photonlib.targeting import * # noqa + + if TYPE_CHECKING: - from ..targeting import Transform3dTestMessage # noqa + from ...targeting import Transform3dTestMessage # noqa class Transform3dTestMessageSerde: diff --git a/photon-serde-tests/src/main/java/org/photonvision/struct/BoolTestMessageSerde.java b/photon-serde-tests/src/main/java/org/photonvision/struct/BoolTestMessageSerde.java new file mode 100644 index 0000000000..d016b41c39 --- /dev/null +++ b/photon-serde-tests/src/main/java/org/photonvision/struct/BoolTestMessageSerde.java @@ -0,0 +1,102 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.struct; + +import org.photonvision.common.dataflow.structures.Packet; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.utils.PacketUtils; + +// Assume that the base class lives here and we can import it +import org.photonvision.targeting.*; + +// Needed for optional shims +import java.util.function.BiConsumer; +import java.util.function.Function; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated serialization/deserialization helper for BoolTestMessage + */ +public class BoolTestMessageSerde implements PacketSerde { + + @Override + public final String getInterfaceUUID() { return "c8efe94a9c0d815658c74de6f672939c"; } + @Override + public final String getSchema() { return "bool test;bool vlaTest[?];optional bool optTest;"; } + @Override + public final String getTypeName() { return "BoolTestMessage"; } + + @Override + public int getMaxByteSize() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); + } + @Override + public void pack(Packet packet, BoolTestMessage value) { + // field test is of intrinsic type bool + packet.encode(value.test); + + // vlaTest is an intrinsic VLA! + packet.encodeListImpl(value.vlaTest,PacketUtils::packBoolean); + + // optTest is optional! it better not be a VLA too + packet.encodeOptionalImpl(value.optTest,PacketUtils::packBoolean); + } + + @Override + public BoolTestMessage unpack(Packet packet) { + var ret = new BoolTestMessage(); + + // test is of intrinsic type bool + ret.test = packet.decodeBoolean(); + + // vlaTest is an intrinsic VLA! + ret.vlaTest = packet.decodeListImpl(PacketUtils::unpackBoolean); + + // optTest is optional! it better not be a VLA too + ret.optTest = packet.decodeOptionalImpl(PacketUtils::unpackBoolean); + + return ret; + } + + @Override + public PacketSerde[] getNestedPhotonMessages() { + return new PacketSerde[] { + + }; + } + + @Override + public Struct[] getNestedWpilibMessages() { + return new Struct[] { + + }; + } +} diff --git a/photon-serde-tests/src/main/java/org/photonvision/struct/Float32TestMessageSerde.java b/photon-serde-tests/src/main/java/org/photonvision/struct/Float32TestMessageSerde.java new file mode 100644 index 0000000000..e61302dd02 --- /dev/null +++ b/photon-serde-tests/src/main/java/org/photonvision/struct/Float32TestMessageSerde.java @@ -0,0 +1,102 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.struct; + +import org.photonvision.common.dataflow.structures.Packet; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.utils.PacketUtils; + +// Assume that the base class lives here and we can import it +import org.photonvision.targeting.*; + +// Needed for optional shims +import java.util.function.BiConsumer; +import java.util.function.Function; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated serialization/deserialization helper for Float32TestMessage + */ +public class Float32TestMessageSerde implements PacketSerde { + + @Override + public final String getInterfaceUUID() { return "9fd9ed51ec69d6738ee24af43b2b9c7e"; } + @Override + public final String getSchema() { return "float32 test;float32 vlaTest[?];optional float32 optTest;"; } + @Override + public final String getTypeName() { return "Float32TestMessage"; } + + @Override + public int getMaxByteSize() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); + } + @Override + public void pack(Packet packet, Float32TestMessage value) { + // field test is of intrinsic type float32 + packet.encode(value.test); + + // vlaTest is an intrinsic VLA! + packet.encodeListImpl(value.vlaTest,PacketUtils::packFloat); + + // optTest is optional! it better not be a VLA too + packet.encodeOptionalImpl(value.optTest,PacketUtils::packFloat); + } + + @Override + public Float32TestMessage unpack(Packet packet) { + var ret = new Float32TestMessage(); + + // test is of intrinsic type float32 + ret.test = packet.decodeFloat(); + + // vlaTest is an intrinsic VLA! + ret.vlaTest = packet.decodeListImpl(PacketUtils::unpackFloat); + + // optTest is optional! it better not be a VLA too + ret.optTest = packet.decodeOptionalImpl(PacketUtils::unpackFloat); + + return ret; + } + + @Override + public PacketSerde[] getNestedPhotonMessages() { + return new PacketSerde[] { + + }; + } + + @Override + public Struct[] getNestedWpilibMessages() { + return new Struct[] { + + }; + } +} diff --git a/photon-serde-tests/src/main/java/org/photonvision/struct/Float64TestMessageSerde.java b/photon-serde-tests/src/main/java/org/photonvision/struct/Float64TestMessageSerde.java new file mode 100644 index 0000000000..e475a5ff41 --- /dev/null +++ b/photon-serde-tests/src/main/java/org/photonvision/struct/Float64TestMessageSerde.java @@ -0,0 +1,102 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.struct; + +import org.photonvision.common.dataflow.structures.Packet; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.utils.PacketUtils; + +// Assume that the base class lives here and we can import it +import org.photonvision.targeting.*; + +// Needed for optional shims +import java.util.function.BiConsumer; +import java.util.function.Function; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated serialization/deserialization helper for Float64TestMessage + */ +public class Float64TestMessageSerde implements PacketSerde { + + @Override + public final String getInterfaceUUID() { return "bc96c1f7d9db9371269d0e4f4d4b4cb2"; } + @Override + public final String getSchema() { return "float64 test;float64 vlaTest[?];optional float64 optTest;"; } + @Override + public final String getTypeName() { return "Float64TestMessage"; } + + @Override + public int getMaxByteSize() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); + } + @Override + public void pack(Packet packet, Float64TestMessage value) { + // field test is of intrinsic type float64 + packet.encode(value.test); + + // vlaTest is an intrinsic VLA! + packet.encodeListImpl(value.vlaTest,PacketUtils::packDouble); + + // optTest is optional! it better not be a VLA too + packet.encodeOptionalImpl(value.optTest,PacketUtils::packDouble); + } + + @Override + public Float64TestMessage unpack(Packet packet) { + var ret = new Float64TestMessage(); + + // test is of intrinsic type float64 + ret.test = packet.decodeDouble(); + + // vlaTest is an intrinsic VLA! + ret.vlaTest = packet.decodeListImpl(PacketUtils::unpackDouble); + + // optTest is optional! it better not be a VLA too + ret.optTest = packet.decodeOptionalImpl(PacketUtils::unpackDouble); + + return ret; + } + + @Override + public PacketSerde[] getNestedPhotonMessages() { + return new PacketSerde[] { + + }; + } + + @Override + public Struct[] getNestedWpilibMessages() { + return new Struct[] { + + }; + } +} diff --git a/photon-serde-tests/src/main/java/org/photonvision/struct/Int16TestMessageSerde.java b/photon-serde-tests/src/main/java/org/photonvision/struct/Int16TestMessageSerde.java new file mode 100644 index 0000000000..908134519b --- /dev/null +++ b/photon-serde-tests/src/main/java/org/photonvision/struct/Int16TestMessageSerde.java @@ -0,0 +1,102 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.struct; + +import org.photonvision.common.dataflow.structures.Packet; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.utils.PacketUtils; + +// Assume that the base class lives here and we can import it +import org.photonvision.targeting.*; + +// Needed for optional shims +import java.util.function.BiConsumer; +import java.util.function.Function; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated serialization/deserialization helper for Int16TestMessage + */ +public class Int16TestMessageSerde implements PacketSerde { + + @Override + public final String getInterfaceUUID() { return "23e6ccab160b942600aae8e94a72778a"; } + @Override + public final String getSchema() { return "int16 test;int16 vlaTest[?];optional int16 optTest;"; } + @Override + public final String getTypeName() { return "Int16TestMessage"; } + + @Override + public int getMaxByteSize() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); + } + @Override + public void pack(Packet packet, Int16TestMessage value) { + // field test is of intrinsic type int16 + packet.encode(value.test); + + // vlaTest is an intrinsic VLA! + packet.encodeListImpl(value.vlaTest,PacketUtils::packShort); + + // optTest is optional! it better not be a VLA too + packet.encodeOptionalImpl(value.optTest,PacketUtils::packShort); + } + + @Override + public Int16TestMessage unpack(Packet packet) { + var ret = new Int16TestMessage(); + + // test is of intrinsic type int16 + ret.test = packet.decodeShort(); + + // vlaTest is an intrinsic VLA! + ret.vlaTest = packet.decodeListImpl(PacketUtils::unpackShort); + + // optTest is optional! it better not be a VLA too + ret.optTest = packet.decodeOptionalImpl(PacketUtils::unpackShort); + + return ret; + } + + @Override + public PacketSerde[] getNestedPhotonMessages() { + return new PacketSerde[] { + + }; + } + + @Override + public Struct[] getNestedWpilibMessages() { + return new Struct[] { + + }; + } +} diff --git a/photon-serde-tests/src/main/java/org/photonvision/struct/Int32TestMessageSerde.java b/photon-serde-tests/src/main/java/org/photonvision/struct/Int32TestMessageSerde.java new file mode 100644 index 0000000000..ed8ef13400 --- /dev/null +++ b/photon-serde-tests/src/main/java/org/photonvision/struct/Int32TestMessageSerde.java @@ -0,0 +1,102 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.struct; + +import org.photonvision.common.dataflow.structures.Packet; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.utils.PacketUtils; + +// Assume that the base class lives here and we can import it +import org.photonvision.targeting.*; + +// Needed for optional shims +import java.util.function.BiConsumer; +import java.util.function.Function; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated serialization/deserialization helper for Int32TestMessage + */ +public class Int32TestMessageSerde implements PacketSerde { + + @Override + public final String getInterfaceUUID() { return "d8596149c4701e7b8912df238cd4ec66"; } + @Override + public final String getSchema() { return "int32 test;int32 vlaTest[?];optional int32 optTest;"; } + @Override + public final String getTypeName() { return "Int32TestMessage"; } + + @Override + public int getMaxByteSize() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); + } + @Override + public void pack(Packet packet, Int32TestMessage value) { + // field test is of intrinsic type int32 + packet.encode(value.test); + + // vlaTest is an intrinsic VLA! + packet.encodeListImpl(value.vlaTest,PacketUtils::packInt); + + // optTest is optional! it better not be a VLA too + packet.encodeOptionalImpl(value.optTest,PacketUtils::packInt); + } + + @Override + public Int32TestMessage unpack(Packet packet) { + var ret = new Int32TestMessage(); + + // test is of intrinsic type int32 + ret.test = packet.decodeInt(); + + // vlaTest is an intrinsic VLA! + ret.vlaTest = packet.decodeListImpl(PacketUtils::unpackInt); + + // optTest is optional! it better not be a VLA too + ret.optTest = packet.decodeOptionalImpl(PacketUtils::unpackInt); + + return ret; + } + + @Override + public PacketSerde[] getNestedPhotonMessages() { + return new PacketSerde[] { + + }; + } + + @Override + public Struct[] getNestedWpilibMessages() { + return new Struct[] { + + }; + } +} diff --git a/photon-serde-tests/src/main/java/org/photonvision/struct/Int64TestMessageSerde.java b/photon-serde-tests/src/main/java/org/photonvision/struct/Int64TestMessageSerde.java new file mode 100644 index 0000000000..94bbef6df8 --- /dev/null +++ b/photon-serde-tests/src/main/java/org/photonvision/struct/Int64TestMessageSerde.java @@ -0,0 +1,102 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.struct; + +import org.photonvision.common.dataflow.structures.Packet; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.utils.PacketUtils; + +// Assume that the base class lives here and we can import it +import org.photonvision.targeting.*; + +// Needed for optional shims +import java.util.function.BiConsumer; +import java.util.function.Function; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated serialization/deserialization helper for Int64TestMessage + */ +public class Int64TestMessageSerde implements PacketSerde { + + @Override + public final String getInterfaceUUID() { return "dd2e470b4d07bbcd208906c26a2ae37a"; } + @Override + public final String getSchema() { return "int64 test;int64 vlaTest[?];optional int64 optTest;"; } + @Override + public final String getTypeName() { return "Int64TestMessage"; } + + @Override + public int getMaxByteSize() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); + } + @Override + public void pack(Packet packet, Int64TestMessage value) { + // field test is of intrinsic type int64 + packet.encode(value.test); + + // vlaTest is an intrinsic VLA! + packet.encodeListImpl(value.vlaTest,PacketUtils::packLong); + + // optTest is optional! it better not be a VLA too + packet.encodeOptionalImpl(value.optTest,PacketUtils::packLong); + } + + @Override + public Int64TestMessage unpack(Packet packet) { + var ret = new Int64TestMessage(); + + // test is of intrinsic type int64 + ret.test = packet.decodeLong(); + + // vlaTest is an intrinsic VLA! + ret.vlaTest = packet.decodeListImpl(PacketUtils::unpackLong); + + // optTest is optional! it better not be a VLA too + ret.optTest = packet.decodeOptionalImpl(PacketUtils::unpackLong); + + return ret; + } + + @Override + public PacketSerde[] getNestedPhotonMessages() { + return new PacketSerde[] { + + }; + } + + @Override + public Struct[] getNestedWpilibMessages() { + return new Struct[] { + + }; + } +} diff --git a/photon-serde-tests/src/main/java/org/photonvision/struct/Int8TestMessageSerde.java b/photon-serde-tests/src/main/java/org/photonvision/struct/Int8TestMessageSerde.java new file mode 100644 index 0000000000..2d84615186 --- /dev/null +++ b/photon-serde-tests/src/main/java/org/photonvision/struct/Int8TestMessageSerde.java @@ -0,0 +1,102 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.struct; + +import org.photonvision.common.dataflow.structures.Packet; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.utils.PacketUtils; + +// Assume that the base class lives here and we can import it +import org.photonvision.targeting.*; + +// Needed for optional shims +import java.util.function.BiConsumer; +import java.util.function.Function; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated serialization/deserialization helper for Int8TestMessage + */ +public class Int8TestMessageSerde implements PacketSerde { + + @Override + public final String getInterfaceUUID() { return "76297a79f30e4d995b8f95c5fa6297fa"; } + @Override + public final String getSchema() { return "int8 test;int8 vlaTest[?];optional int8 optTest;"; } + @Override + public final String getTypeName() { return "Int8TestMessage"; } + + @Override + public int getMaxByteSize() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); + } + @Override + public void pack(Packet packet, Int8TestMessage value) { + // field test is of intrinsic type int8 + packet.encode(value.test); + + // vlaTest is an intrinsic VLA! + packet.encodeListImpl(value.vlaTest,PacketUtils::packByte); + + // optTest is optional! it better not be a VLA too + packet.encodeOptionalImpl(value.optTest,PacketUtils::packByte); + } + + @Override + public Int8TestMessage unpack(Packet packet) { + var ret = new Int8TestMessage(); + + // test is of intrinsic type int8 + ret.test = packet.decodeByte(); + + // vlaTest is an intrinsic VLA! + ret.vlaTest = packet.decodeListImpl(PacketUtils::unpackByte); + + // optTest is optional! it better not be a VLA too + ret.optTest = packet.decodeOptionalImpl(PacketUtils::unpackByte); + + return ret; + } + + @Override + public PacketSerde[] getNestedPhotonMessages() { + return new PacketSerde[] { + + }; + } + + @Override + public Struct[] getNestedWpilibMessages() { + return new Struct[] { + + }; + } +} diff --git a/photon-serde-tests/src/main/java/org/photonvision/struct/Transform3dTestMessageSerde.java b/photon-serde-tests/src/main/java/org/photonvision/struct/Transform3dTestMessageSerde.java new file mode 100644 index 0000000000..24b0b6c1cc --- /dev/null +++ b/photon-serde-tests/src/main/java/org/photonvision/struct/Transform3dTestMessageSerde.java @@ -0,0 +1,102 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.struct; + +import org.photonvision.common.dataflow.structures.Packet; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.utils.PacketUtils; + +// Assume that the base class lives here and we can import it +import org.photonvision.targeting.*; + +// Needed for optional shims +import java.util.function.BiConsumer; +import java.util.function.Function; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; +import org.wpilib.math.geometry.Transform3d; + +/** + * Auto-generated serialization/deserialization helper for Transform3dTestMessage + */ +public class Transform3dTestMessageSerde implements PacketSerde { + + @Override + public final String getInterfaceUUID() { return "37188f532d61c3b549080489012b4d07"; } + @Override + public final String getSchema() { return "Transform3d test;Transform3d vlaTest[?];optional Transform3d optTest;"; } + @Override + public final String getTypeName() { return "Transform3dTestMessage"; } + + @Override + public int getMaxByteSize() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'getMaxByteSize'"); + } + @Override + public void pack(Packet packet, Transform3dTestMessage value) { + // test is of shimmed type Transform3d + PacketUtils.packTransform3d(packet, value.test); + + // vlaTest is a shimmed VLA! + packet.encodeListImpl(value.vlaTest, PacketUtils::packTransform3d); + + // optTest is optional! it better not be a VLA too + packet.encodeOptionalImpl(value.optTest, PacketUtils::packTransform3d); + } + + @Override + public Transform3dTestMessage unpack(Packet packet) { + var ret = new Transform3dTestMessage(); + + // test is of shimmed type Transform3d + ret.test = PacketUtils.unpackTransform3d(packet); + + // vlaTest is a shimmed VLA! + ret.vlaTest = packet.decodeListImpl(PacketUtils::unpackTransform3d); + + // optTest is optional! it better not be a VLA too + ret.optTest = packet.decodeOptionalImpl(PacketUtils::unpackTransform3d); + + return ret; + } + + @Override + public PacketSerde[] getNestedPhotonMessages() { + return new PacketSerde[] { + + }; + } + + @Override + public Struct[] getNestedWpilibMessages() { + return new Struct[] { + Transform3d.struct + }; + } +} diff --git a/photon-serde-tests/src/main/java/org/photonvision/targeting/BoolTestMessage.java b/photon-serde-tests/src/main/java/org/photonvision/targeting/BoolTestMessage.java new file mode 100644 index 0000000000..d11f269a96 --- /dev/null +++ b/photon-serde-tests/src/main/java/org/photonvision/targeting/BoolTestMessage.java @@ -0,0 +1,80 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.targeting; + +import java.util.List; +import java.util.Optional; + +import org.photonvision.struct.BoolTestMessageSerde; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.targeting.serde.PhotonStructSerializable; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +public class BoolTestMessage implements PhotonStructSerializable { + + public boolean test; + public List vlaTest = List.of(); + public Optional optTest = Optional.empty(); + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + + BoolTestMessage other = (BoolTestMessage) obj; + if (this.test != other.test) return false; + if (!this.vlaTest.equals(other.vlaTest)) return false; + if (!this.optTest.equals(other.optTest)) return false; + return true; + } + + /** BoolTestMessage PhotonStruct for serialization. */ + public static final BoolTestMessageSerde photonStruct = new BoolTestMessageSerde(); + + @Override + public PacketSerde getSerde() { + return photonStruct; + } + + @Override + public String toString() { + return "BoolTestMessage [" + + "test=" + + test + + ", vlaTest=" + + vlaTest + + ", optTest=" + + optTest + + "]"; + } +} \ No newline at end of file diff --git a/photon-serde-tests/src/main/java/org/photonvision/targeting/Float32TestMessage.java b/photon-serde-tests/src/main/java/org/photonvision/targeting/Float32TestMessage.java new file mode 100644 index 0000000000..66da4713b8 --- /dev/null +++ b/photon-serde-tests/src/main/java/org/photonvision/targeting/Float32TestMessage.java @@ -0,0 +1,80 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.targeting; + +import java.util.List; +import java.util.Optional; + +import org.photonvision.struct.Float32TestMessageSerde; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.targeting.serde.PhotonStructSerializable; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +public class Float32TestMessage implements PhotonStructSerializable { + + public float test; + public List vlaTest = List.of(); + public Optional optTest = Optional.empty(); + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + + Float32TestMessage other = (Float32TestMessage) obj; + if (this.test != other.test) return false; + if (!this.vlaTest.equals(other.vlaTest)) return false; + if (!this.optTest.equals(other.optTest)) return false; + return true; + } + + /** Float32TestMessage PhotonStruct for serialization. */ + public static final Float32TestMessageSerde photonStruct = new Float32TestMessageSerde(); + + @Override + public PacketSerde getSerde() { + return photonStruct; + } + + @Override + public String toString() { + return "Float32TestMessage [" + + "test=" + + test + + ", vlaTest=" + + vlaTest + + ", optTest=" + + optTest + + "]"; + } +} \ No newline at end of file diff --git a/photon-serde-tests/src/main/java/org/photonvision/targeting/Float64TestMessage.java b/photon-serde-tests/src/main/java/org/photonvision/targeting/Float64TestMessage.java new file mode 100644 index 0000000000..04c8422d5b --- /dev/null +++ b/photon-serde-tests/src/main/java/org/photonvision/targeting/Float64TestMessage.java @@ -0,0 +1,80 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.targeting; + +import java.util.List; +import java.util.Optional; + +import org.photonvision.struct.Float64TestMessageSerde; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.targeting.serde.PhotonStructSerializable; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +public class Float64TestMessage implements PhotonStructSerializable { + + public double test; + public List vlaTest = List.of(); + public Optional optTest = Optional.empty(); + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + + Float64TestMessage other = (Float64TestMessage) obj; + if (this.test != other.test) return false; + if (!this.vlaTest.equals(other.vlaTest)) return false; + if (!this.optTest.equals(other.optTest)) return false; + return true; + } + + /** Float64TestMessage PhotonStruct for serialization. */ + public static final Float64TestMessageSerde photonStruct = new Float64TestMessageSerde(); + + @Override + public PacketSerde getSerde() { + return photonStruct; + } + + @Override + public String toString() { + return "Float64TestMessage [" + + "test=" + + test + + ", vlaTest=" + + vlaTest + + ", optTest=" + + optTest + + "]"; + } +} \ No newline at end of file diff --git a/photon-serde-tests/src/main/java/org/photonvision/targeting/Int16TestMessage.java b/photon-serde-tests/src/main/java/org/photonvision/targeting/Int16TestMessage.java new file mode 100644 index 0000000000..38f46f8a4b --- /dev/null +++ b/photon-serde-tests/src/main/java/org/photonvision/targeting/Int16TestMessage.java @@ -0,0 +1,80 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.targeting; + +import java.util.List; +import java.util.Optional; + +import org.photonvision.struct.Int16TestMessageSerde; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.targeting.serde.PhotonStructSerializable; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +public class Int16TestMessage implements PhotonStructSerializable { + + public short test; + public List vlaTest = List.of(); + public Optional optTest = Optional.empty(); + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + + Int16TestMessage other = (Int16TestMessage) obj; + if (this.test != other.test) return false; + if (!this.vlaTest.equals(other.vlaTest)) return false; + if (!this.optTest.equals(other.optTest)) return false; + return true; + } + + /** Int16TestMessage PhotonStruct for serialization. */ + public static final Int16TestMessageSerde photonStruct = new Int16TestMessageSerde(); + + @Override + public PacketSerde getSerde() { + return photonStruct; + } + + @Override + public String toString() { + return "Int16TestMessage [" + + "test=" + + test + + ", vlaTest=" + + vlaTest + + ", optTest=" + + optTest + + "]"; + } +} \ No newline at end of file diff --git a/photon-serde-tests/src/main/java/org/photonvision/targeting/Int32TestMessage.java b/photon-serde-tests/src/main/java/org/photonvision/targeting/Int32TestMessage.java new file mode 100644 index 0000000000..d3d1723099 --- /dev/null +++ b/photon-serde-tests/src/main/java/org/photonvision/targeting/Int32TestMessage.java @@ -0,0 +1,80 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.targeting; + +import java.util.List; +import java.util.Optional; + +import org.photonvision.struct.Int32TestMessageSerde; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.targeting.serde.PhotonStructSerializable; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +public class Int32TestMessage implements PhotonStructSerializable { + + public int test; + public List vlaTest = List.of(); + public Optional optTest = Optional.empty(); + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + + Int32TestMessage other = (Int32TestMessage) obj; + if (this.test != other.test) return false; + if (!this.vlaTest.equals(other.vlaTest)) return false; + if (!this.optTest.equals(other.optTest)) return false; + return true; + } + + /** Int32TestMessage PhotonStruct for serialization. */ + public static final Int32TestMessageSerde photonStruct = new Int32TestMessageSerde(); + + @Override + public PacketSerde getSerde() { + return photonStruct; + } + + @Override + public String toString() { + return "Int32TestMessage [" + + "test=" + + test + + ", vlaTest=" + + vlaTest + + ", optTest=" + + optTest + + "]"; + } +} \ No newline at end of file diff --git a/photon-serde-tests/src/main/java/org/photonvision/targeting/Int64TestMessage.java b/photon-serde-tests/src/main/java/org/photonvision/targeting/Int64TestMessage.java new file mode 100644 index 0000000000..6b6859bfa1 --- /dev/null +++ b/photon-serde-tests/src/main/java/org/photonvision/targeting/Int64TestMessage.java @@ -0,0 +1,80 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.targeting; + +import java.util.List; +import java.util.Optional; + +import org.photonvision.struct.Int64TestMessageSerde; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.targeting.serde.PhotonStructSerializable; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +public class Int64TestMessage implements PhotonStructSerializable { + + public long test; + public List vlaTest = List.of(); + public Optional optTest = Optional.empty(); + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + + Int64TestMessage other = (Int64TestMessage) obj; + if (this.test != other.test) return false; + if (!this.vlaTest.equals(other.vlaTest)) return false; + if (!this.optTest.equals(other.optTest)) return false; + return true; + } + + /** Int64TestMessage PhotonStruct for serialization. */ + public static final Int64TestMessageSerde photonStruct = new Int64TestMessageSerde(); + + @Override + public PacketSerde getSerde() { + return photonStruct; + } + + @Override + public String toString() { + return "Int64TestMessage [" + + "test=" + + test + + ", vlaTest=" + + vlaTest + + ", optTest=" + + optTest + + "]"; + } +} \ No newline at end of file diff --git a/photon-serde-tests/src/main/java/org/photonvision/targeting/Int8TestMessage.java b/photon-serde-tests/src/main/java/org/photonvision/targeting/Int8TestMessage.java new file mode 100644 index 0000000000..b8af7c5422 --- /dev/null +++ b/photon-serde-tests/src/main/java/org/photonvision/targeting/Int8TestMessage.java @@ -0,0 +1,80 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.targeting; + +import java.util.List; +import java.util.Optional; + +import org.photonvision.struct.Int8TestMessageSerde; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.targeting.serde.PhotonStructSerializable; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; + + +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +public class Int8TestMessage implements PhotonStructSerializable { + + public byte test; + public List vlaTest = List.of(); + public Optional optTest = Optional.empty(); + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + + Int8TestMessage other = (Int8TestMessage) obj; + if (this.test != other.test) return false; + if (!this.vlaTest.equals(other.vlaTest)) return false; + if (!this.optTest.equals(other.optTest)) return false; + return true; + } + + /** Int8TestMessage PhotonStruct for serialization. */ + public static final Int8TestMessageSerde photonStruct = new Int8TestMessageSerde(); + + @Override + public PacketSerde getSerde() { + return photonStruct; + } + + @Override + public String toString() { + return "Int8TestMessage [" + + "test=" + + test + + ", vlaTest=" + + vlaTest + + ", optTest=" + + optTest + + "]"; + } +} \ No newline at end of file diff --git a/photon-serde-tests/src/main/java/org/photonvision/targeting/Transform3dTestMessage.java b/photon-serde-tests/src/main/java/org/photonvision/targeting/Transform3dTestMessage.java new file mode 100644 index 0000000000..7362877940 --- /dev/null +++ b/photon-serde-tests/src/main/java/org/photonvision/targeting/Transform3dTestMessage.java @@ -0,0 +1,80 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision.targeting; + +import java.util.List; +import java.util.Optional; + +import org.photonvision.struct.Transform3dTestMessageSerde; +import org.photonvision.common.dataflow.structures.PacketSerde; +import org.photonvision.targeting.serde.PhotonStructSerializable; + +// WPILib imports (if any) +import org.wpilib.util.struct.Struct; +import org.wpilib.math.geometry.Transform3d; + +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +public class Transform3dTestMessage implements PhotonStructSerializable { + + public Transform3d test = new Transform3d(); + public List vlaTest = List.of(); + public Optional optTest = Optional.empty(); + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + + Transform3dTestMessage other = (Transform3dTestMessage) obj; + if (!this.test.equals(other.test)) return false; + if (!this.vlaTest.equals(other.vlaTest)) return false; + if (!this.optTest.equals(other.optTest)) return false; + return true; + } + + /** Transform3dTestMessage PhotonStruct for serialization. */ + public static final Transform3dTestMessageSerde photonStruct = new Transform3dTestMessageSerde(); + + @Override + public PacketSerde getSerde() { + return photonStruct; + } + + @Override + public String toString() { + return "Transform3dTestMessage [" + + "test=" + + test.toString() + + ", vlaTest=" + + vlaTest.toString() + + ", optTest=" + + optTest.toString() + + "]"; + } +} \ No newline at end of file diff --git a/photon-serde-tests/src/main/native/cpp/photon/serde/BoolTestMessageSerde.cpp b/photon-serde-tests/src/main/native/cpp/photon/serde/BoolTestMessageSerde.cpp new file mode 100644 index 0000000000..93533bdabb --- /dev/null +++ b/photon-serde-tests/src/main/native/cpp/photon/serde/BoolTestMessageSerde.cpp @@ -0,0 +1,48 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/serde/BoolTestMessageSerde.h" + + +namespace photon { + +using StructType = SerdeType; + +void StructType::Pack(Packet& packet, const BoolTestMessage& value) { + packet.Pack(value.test); + packet.Pack>(value.vlaTest); + packet.Pack>(value.optTest); +} + +BoolTestMessage StructType::Unpack(Packet& packet) { + return BoolTestMessage{ BoolTestMessage_PhotonStruct{ + .test = packet.Unpack(), + .vlaTest = packet.Unpack>(), + .optTest = packet.Unpack>(), + }}; +} + +} // namespace photon diff --git a/photon-serde-tests/src/main/native/cpp/photon/serde/Float32TestMessageSerde.cpp b/photon-serde-tests/src/main/native/cpp/photon/serde/Float32TestMessageSerde.cpp new file mode 100644 index 0000000000..13e20451ca --- /dev/null +++ b/photon-serde-tests/src/main/native/cpp/photon/serde/Float32TestMessageSerde.cpp @@ -0,0 +1,48 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/serde/Float32TestMessageSerde.h" + + +namespace photon { + +using StructType = SerdeType; + +void StructType::Pack(Packet& packet, const Float32TestMessage& value) { + packet.Pack(value.test); + packet.Pack>(value.vlaTest); + packet.Pack>(value.optTest); +} + +Float32TestMessage StructType::Unpack(Packet& packet) { + return Float32TestMessage{ Float32TestMessage_PhotonStruct{ + .test = packet.Unpack(), + .vlaTest = packet.Unpack>(), + .optTest = packet.Unpack>(), + }}; +} + +} // namespace photon diff --git a/photon-serde-tests/src/main/native/cpp/photon/serde/Float64TestMessageSerde.cpp b/photon-serde-tests/src/main/native/cpp/photon/serde/Float64TestMessageSerde.cpp new file mode 100644 index 0000000000..7215e6523e --- /dev/null +++ b/photon-serde-tests/src/main/native/cpp/photon/serde/Float64TestMessageSerde.cpp @@ -0,0 +1,48 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/serde/Float64TestMessageSerde.h" + + +namespace photon { + +using StructType = SerdeType; + +void StructType::Pack(Packet& packet, const Float64TestMessage& value) { + packet.Pack(value.test); + packet.Pack>(value.vlaTest); + packet.Pack>(value.optTest); +} + +Float64TestMessage StructType::Unpack(Packet& packet) { + return Float64TestMessage{ Float64TestMessage_PhotonStruct{ + .test = packet.Unpack(), + .vlaTest = packet.Unpack>(), + .optTest = packet.Unpack>(), + }}; +} + +} // namespace photon diff --git a/photon-serde-tests/src/main/native/cpp/photon/serde/Int16TestMessageSerde.cpp b/photon-serde-tests/src/main/native/cpp/photon/serde/Int16TestMessageSerde.cpp new file mode 100644 index 0000000000..99fd13699f --- /dev/null +++ b/photon-serde-tests/src/main/native/cpp/photon/serde/Int16TestMessageSerde.cpp @@ -0,0 +1,48 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/serde/Int16TestMessageSerde.h" + + +namespace photon { + +using StructType = SerdeType; + +void StructType::Pack(Packet& packet, const Int16TestMessage& value) { + packet.Pack(value.test); + packet.Pack>(value.vlaTest); + packet.Pack>(value.optTest); +} + +Int16TestMessage StructType::Unpack(Packet& packet) { + return Int16TestMessage{ Int16TestMessage_PhotonStruct{ + .test = packet.Unpack(), + .vlaTest = packet.Unpack>(), + .optTest = packet.Unpack>(), + }}; +} + +} // namespace photon diff --git a/photon-serde-tests/src/main/native/cpp/photon/serde/Int32TestMessageSerde.cpp b/photon-serde-tests/src/main/native/cpp/photon/serde/Int32TestMessageSerde.cpp new file mode 100644 index 0000000000..50a9ec29fd --- /dev/null +++ b/photon-serde-tests/src/main/native/cpp/photon/serde/Int32TestMessageSerde.cpp @@ -0,0 +1,48 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/serde/Int32TestMessageSerde.h" + + +namespace photon { + +using StructType = SerdeType; + +void StructType::Pack(Packet& packet, const Int32TestMessage& value) { + packet.Pack(value.test); + packet.Pack>(value.vlaTest); + packet.Pack>(value.optTest); +} + +Int32TestMessage StructType::Unpack(Packet& packet) { + return Int32TestMessage{ Int32TestMessage_PhotonStruct{ + .test = packet.Unpack(), + .vlaTest = packet.Unpack>(), + .optTest = packet.Unpack>(), + }}; +} + +} // namespace photon diff --git a/photon-serde-tests/src/main/native/cpp/photon/serde/Int64TestMessageSerde.cpp b/photon-serde-tests/src/main/native/cpp/photon/serde/Int64TestMessageSerde.cpp new file mode 100644 index 0000000000..a2bb7b34e6 --- /dev/null +++ b/photon-serde-tests/src/main/native/cpp/photon/serde/Int64TestMessageSerde.cpp @@ -0,0 +1,48 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/serde/Int64TestMessageSerde.h" + + +namespace photon { + +using StructType = SerdeType; + +void StructType::Pack(Packet& packet, const Int64TestMessage& value) { + packet.Pack(value.test); + packet.Pack>(value.vlaTest); + packet.Pack>(value.optTest); +} + +Int64TestMessage StructType::Unpack(Packet& packet) { + return Int64TestMessage{ Int64TestMessage_PhotonStruct{ + .test = packet.Unpack(), + .vlaTest = packet.Unpack>(), + .optTest = packet.Unpack>(), + }}; +} + +} // namespace photon diff --git a/photon-serde-tests/src/main/native/cpp/photon/serde/Int8TestMessageSerde.cpp b/photon-serde-tests/src/main/native/cpp/photon/serde/Int8TestMessageSerde.cpp new file mode 100644 index 0000000000..6c9f518f6f --- /dev/null +++ b/photon-serde-tests/src/main/native/cpp/photon/serde/Int8TestMessageSerde.cpp @@ -0,0 +1,48 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/serde/Int8TestMessageSerde.h" + + +namespace photon { + +using StructType = SerdeType; + +void StructType::Pack(Packet& packet, const Int8TestMessage& value) { + packet.Pack(value.test); + packet.Pack>(value.vlaTest); + packet.Pack>(value.optTest); +} + +Int8TestMessage StructType::Unpack(Packet& packet) { + return Int8TestMessage{ Int8TestMessage_PhotonStruct{ + .test = packet.Unpack(), + .vlaTest = packet.Unpack>(), + .optTest = packet.Unpack>(), + }}; +} + +} // namespace photon diff --git a/photon-serde-tests/src/main/native/cpp/photon/serde/Transform3dTestMessageSerde.cpp b/photon-serde-tests/src/main/native/cpp/photon/serde/Transform3dTestMessageSerde.cpp new file mode 100644 index 0000000000..223bb00370 --- /dev/null +++ b/photon-serde-tests/src/main/native/cpp/photon/serde/Transform3dTestMessageSerde.cpp @@ -0,0 +1,48 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/serde/Transform3dTestMessageSerde.h" + + +namespace photon { + +using StructType = SerdeType; + +void StructType::Pack(Packet& packet, const Transform3dTestMessage& value) { + packet.Pack(value.test); + packet.Pack>(value.vlaTest); + packet.Pack>(value.optTest); +} + +Transform3dTestMessage StructType::Unpack(Packet& packet) { + return Transform3dTestMessage{ Transform3dTestMessage_PhotonStruct{ + .test = packet.Unpack(), + .vlaTest = packet.Unpack>(), + .optTest = packet.Unpack>(), + }}; +} + +} // namespace photon diff --git a/photon-serde-tests/src/main/native/include/photon/serde/BoolTestMessageSerde.h b/photon-serde-tests/src/main/native/include/photon/serde/BoolTestMessageSerde.h new file mode 100644 index 0000000000..a671323f45 --- /dev/null +++ b/photon-serde-tests/src/main/native/include/photon/serde/BoolTestMessageSerde.h @@ -0,0 +1,59 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include + +// Include myself +#include "photon/dataflow/structures/Packet.h" +#include "photon/targeting/BoolTestMessage.h" + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +template <> +struct WPILIB_DLLEXPORT SerdeType { + static constexpr std::string_view GetSchemaHash() { + return "c8efe94a9c0d815658c74de6f672939c"; + } + + static constexpr std::string_view GetSchema() { + return "bool test;bool vlaTest[?];optional bool optTest;"; + } + + static photon::BoolTestMessage Unpack(photon::Packet& packet); + static void Pack(photon::Packet& packet, const photon::BoolTestMessage& value); +}; + +static_assert(photon::PhotonStructSerializable); + +} // namespace photon diff --git a/photon-serde-tests/src/main/native/include/photon/serde/Float32TestMessageSerde.h b/photon-serde-tests/src/main/native/include/photon/serde/Float32TestMessageSerde.h new file mode 100644 index 0000000000..34d82a2ca3 --- /dev/null +++ b/photon-serde-tests/src/main/native/include/photon/serde/Float32TestMessageSerde.h @@ -0,0 +1,59 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include + +// Include myself +#include "photon/dataflow/structures/Packet.h" +#include "photon/targeting/Float32TestMessage.h" + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +template <> +struct WPILIB_DLLEXPORT SerdeType { + static constexpr std::string_view GetSchemaHash() { + return "9fd9ed51ec69d6738ee24af43b2b9c7e"; + } + + static constexpr std::string_view GetSchema() { + return "float32 test;float32 vlaTest[?];optional float32 optTest;"; + } + + static photon::Float32TestMessage Unpack(photon::Packet& packet); + static void Pack(photon::Packet& packet, const photon::Float32TestMessage& value); +}; + +static_assert(photon::PhotonStructSerializable); + +} // namespace photon diff --git a/photon-serde-tests/src/main/native/include/photon/serde/Float64TestMessageSerde.h b/photon-serde-tests/src/main/native/include/photon/serde/Float64TestMessageSerde.h new file mode 100644 index 0000000000..a2d6b0f1da --- /dev/null +++ b/photon-serde-tests/src/main/native/include/photon/serde/Float64TestMessageSerde.h @@ -0,0 +1,59 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include + +// Include myself +#include "photon/dataflow/structures/Packet.h" +#include "photon/targeting/Float64TestMessage.h" + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +template <> +struct WPILIB_DLLEXPORT SerdeType { + static constexpr std::string_view GetSchemaHash() { + return "bc96c1f7d9db9371269d0e4f4d4b4cb2"; + } + + static constexpr std::string_view GetSchema() { + return "float64 test;float64 vlaTest[?];optional float64 optTest;"; + } + + static photon::Float64TestMessage Unpack(photon::Packet& packet); + static void Pack(photon::Packet& packet, const photon::Float64TestMessage& value); +}; + +static_assert(photon::PhotonStructSerializable); + +} // namespace photon diff --git a/photon-serde-tests/src/main/native/include/photon/serde/Int16TestMessageSerde.h b/photon-serde-tests/src/main/native/include/photon/serde/Int16TestMessageSerde.h new file mode 100644 index 0000000000..b71917804a --- /dev/null +++ b/photon-serde-tests/src/main/native/include/photon/serde/Int16TestMessageSerde.h @@ -0,0 +1,59 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include + +// Include myself +#include "photon/dataflow/structures/Packet.h" +#include "photon/targeting/Int16TestMessage.h" + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +template <> +struct WPILIB_DLLEXPORT SerdeType { + static constexpr std::string_view GetSchemaHash() { + return "23e6ccab160b942600aae8e94a72778a"; + } + + static constexpr std::string_view GetSchema() { + return "int16 test;int16 vlaTest[?];optional int16 optTest;"; + } + + static photon::Int16TestMessage Unpack(photon::Packet& packet); + static void Pack(photon::Packet& packet, const photon::Int16TestMessage& value); +}; + +static_assert(photon::PhotonStructSerializable); + +} // namespace photon diff --git a/photon-serde-tests/src/main/native/include/photon/serde/Int32TestMessageSerde.h b/photon-serde-tests/src/main/native/include/photon/serde/Int32TestMessageSerde.h new file mode 100644 index 0000000000..5eb44c6381 --- /dev/null +++ b/photon-serde-tests/src/main/native/include/photon/serde/Int32TestMessageSerde.h @@ -0,0 +1,59 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include + +// Include myself +#include "photon/dataflow/structures/Packet.h" +#include "photon/targeting/Int32TestMessage.h" + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +template <> +struct WPILIB_DLLEXPORT SerdeType { + static constexpr std::string_view GetSchemaHash() { + return "d8596149c4701e7b8912df238cd4ec66"; + } + + static constexpr std::string_view GetSchema() { + return "int32 test;int32 vlaTest[?];optional int32 optTest;"; + } + + static photon::Int32TestMessage Unpack(photon::Packet& packet); + static void Pack(photon::Packet& packet, const photon::Int32TestMessage& value); +}; + +static_assert(photon::PhotonStructSerializable); + +} // namespace photon diff --git a/photon-serde-tests/src/main/native/include/photon/serde/Int64TestMessageSerde.h b/photon-serde-tests/src/main/native/include/photon/serde/Int64TestMessageSerde.h new file mode 100644 index 0000000000..a2beb754f4 --- /dev/null +++ b/photon-serde-tests/src/main/native/include/photon/serde/Int64TestMessageSerde.h @@ -0,0 +1,59 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include + +// Include myself +#include "photon/dataflow/structures/Packet.h" +#include "photon/targeting/Int64TestMessage.h" + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +template <> +struct WPILIB_DLLEXPORT SerdeType { + static constexpr std::string_view GetSchemaHash() { + return "dd2e470b4d07bbcd208906c26a2ae37a"; + } + + static constexpr std::string_view GetSchema() { + return "int64 test;int64 vlaTest[?];optional int64 optTest;"; + } + + static photon::Int64TestMessage Unpack(photon::Packet& packet); + static void Pack(photon::Packet& packet, const photon::Int64TestMessage& value); +}; + +static_assert(photon::PhotonStructSerializable); + +} // namespace photon diff --git a/photon-serde-tests/src/main/native/include/photon/serde/Int8TestMessageSerde.h b/photon-serde-tests/src/main/native/include/photon/serde/Int8TestMessageSerde.h new file mode 100644 index 0000000000..d1c526b338 --- /dev/null +++ b/photon-serde-tests/src/main/native/include/photon/serde/Int8TestMessageSerde.h @@ -0,0 +1,59 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include + +// Include myself +#include "photon/dataflow/structures/Packet.h" +#include "photon/targeting/Int8TestMessage.h" + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +template <> +struct WPILIB_DLLEXPORT SerdeType { + static constexpr std::string_view GetSchemaHash() { + return "76297a79f30e4d995b8f95c5fa6297fa"; + } + + static constexpr std::string_view GetSchema() { + return "int8 test;int8 vlaTest[?];optional int8 optTest;"; + } + + static photon::Int8TestMessage Unpack(photon::Packet& packet); + static void Pack(photon::Packet& packet, const photon::Int8TestMessage& value); +}; + +static_assert(photon::PhotonStructSerializable); + +} // namespace photon diff --git a/photon-serde-tests/src/main/native/include/photon/serde/Transform3dTestMessageSerde.h b/photon-serde-tests/src/main/native/include/photon/serde/Transform3dTestMessageSerde.h new file mode 100644 index 0000000000..69bcc31f3f --- /dev/null +++ b/photon-serde-tests/src/main/native/include/photon/serde/Transform3dTestMessageSerde.h @@ -0,0 +1,60 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include + +// Include myself +#include "photon/dataflow/structures/Packet.h" +#include "photon/targeting/Transform3dTestMessage.h" + +// Includes for dependant types +#include +#include +#include +#include + + +namespace photon { + +template <> +struct WPILIB_DLLEXPORT SerdeType { + static constexpr std::string_view GetSchemaHash() { + return "37188f532d61c3b549080489012b4d07"; + } + + static constexpr std::string_view GetSchema() { + return "Transform3d test;Transform3d vlaTest[?];optional Transform3d optTest;"; + } + + static photon::Transform3dTestMessage Unpack(photon::Packet& packet); + static void Pack(photon::Packet& packet, const photon::Transform3dTestMessage& value); +}; + +static_assert(photon::PhotonStructSerializable); + +} // namespace photon diff --git a/photon-serde-tests/src/main/native/include/photon/struct/BoolTestMessageStruct.h b/photon-serde-tests/src/main/native/include/photon/struct/BoolTestMessageStruct.h new file mode 100644 index 0000000000..a3fca76c9d --- /dev/null +++ b/photon-serde-tests/src/main/native/include/photon/struct/BoolTestMessageStruct.h @@ -0,0 +1,45 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +struct BoolTestMessage_PhotonStruct { + bool test; + std::vector vlaTest; + std::optional optTest; + + friend bool operator==(BoolTestMessage_PhotonStruct const&, BoolTestMessage_PhotonStruct const&) = default; +}; + +} // namespace photon diff --git a/photon-serde-tests/src/main/native/include/photon/struct/Float32TestMessageStruct.h b/photon-serde-tests/src/main/native/include/photon/struct/Float32TestMessageStruct.h new file mode 100644 index 0000000000..652daa87dd --- /dev/null +++ b/photon-serde-tests/src/main/native/include/photon/struct/Float32TestMessageStruct.h @@ -0,0 +1,45 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +struct Float32TestMessage_PhotonStruct { + float test; + std::vector vlaTest; + std::optional optTest; + + friend bool operator==(Float32TestMessage_PhotonStruct const&, Float32TestMessage_PhotonStruct const&) = default; +}; + +} // namespace photon diff --git a/photon-serde-tests/src/main/native/include/photon/struct/Float64TestMessageStruct.h b/photon-serde-tests/src/main/native/include/photon/struct/Float64TestMessageStruct.h new file mode 100644 index 0000000000..5ee739d063 --- /dev/null +++ b/photon-serde-tests/src/main/native/include/photon/struct/Float64TestMessageStruct.h @@ -0,0 +1,45 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +struct Float64TestMessage_PhotonStruct { + double test; + std::vector vlaTest; + std::optional optTest; + + friend bool operator==(Float64TestMessage_PhotonStruct const&, Float64TestMessage_PhotonStruct const&) = default; +}; + +} // namespace photon diff --git a/photon-serde-tests/src/main/native/include/photon/struct/Int16TestMessageStruct.h b/photon-serde-tests/src/main/native/include/photon/struct/Int16TestMessageStruct.h new file mode 100644 index 0000000000..356b0ae1d5 --- /dev/null +++ b/photon-serde-tests/src/main/native/include/photon/struct/Int16TestMessageStruct.h @@ -0,0 +1,45 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +struct Int16TestMessage_PhotonStruct { + int16_t test; + std::vector vlaTest; + std::optional optTest; + + friend bool operator==(Int16TestMessage_PhotonStruct const&, Int16TestMessage_PhotonStruct const&) = default; +}; + +} // namespace photon diff --git a/photon-serde-tests/src/main/native/include/photon/struct/Int32TestMessageStruct.h b/photon-serde-tests/src/main/native/include/photon/struct/Int32TestMessageStruct.h new file mode 100644 index 0000000000..519a6aed06 --- /dev/null +++ b/photon-serde-tests/src/main/native/include/photon/struct/Int32TestMessageStruct.h @@ -0,0 +1,45 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +struct Int32TestMessage_PhotonStruct { + int32_t test; + std::vector vlaTest; + std::optional optTest; + + friend bool operator==(Int32TestMessage_PhotonStruct const&, Int32TestMessage_PhotonStruct const&) = default; +}; + +} // namespace photon diff --git a/photon-serde-tests/src/main/native/include/photon/struct/Int64TestMessageStruct.h b/photon-serde-tests/src/main/native/include/photon/struct/Int64TestMessageStruct.h new file mode 100644 index 0000000000..f4ce39755e --- /dev/null +++ b/photon-serde-tests/src/main/native/include/photon/struct/Int64TestMessageStruct.h @@ -0,0 +1,45 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +struct Int64TestMessage_PhotonStruct { + int64_t test; + std::vector vlaTest; + std::optional optTest; + + friend bool operator==(Int64TestMessage_PhotonStruct const&, Int64TestMessage_PhotonStruct const&) = default; +}; + +} // namespace photon diff --git a/photon-serde-tests/src/main/native/include/photon/struct/Int8TestMessageStruct.h b/photon-serde-tests/src/main/native/include/photon/struct/Int8TestMessageStruct.h new file mode 100644 index 0000000000..5b37d13a64 --- /dev/null +++ b/photon-serde-tests/src/main/native/include/photon/struct/Int8TestMessageStruct.h @@ -0,0 +1,45 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +// Includes for dependant types +#include +#include +#include + + +namespace photon { + +struct Int8TestMessage_PhotonStruct { + int8_t test; + std::vector vlaTest; + std::optional optTest; + + friend bool operator==(Int8TestMessage_PhotonStruct const&, Int8TestMessage_PhotonStruct const&) = default; +}; + +} // namespace photon diff --git a/photon-serde-tests/src/main/native/include/photon/struct/Transform3dTestMessageStruct.h b/photon-serde-tests/src/main/native/include/photon/struct/Transform3dTestMessageStruct.h new file mode 100644 index 0000000000..2cb9dd7481 --- /dev/null +++ b/photon-serde-tests/src/main/native/include/photon/struct/Transform3dTestMessageStruct.h @@ -0,0 +1,46 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +// Includes for dependant types +#include +#include +#include +#include + + +namespace photon { + +struct Transform3dTestMessage_PhotonStruct { + wpi::math::Transform3d test; + std::vector vlaTest; + std::optional optTest; + + friend bool operator==(Transform3dTestMessage_PhotonStruct const&, Transform3dTestMessage_PhotonStruct const&) = default; +}; + +} // namespace photon diff --git a/photon-serde-tests/src/main/native/include/photon/targeting/BoolTestMessage.h b/photon-serde-tests/src/main/native/include/photon/targeting/BoolTestMessage.h new file mode 100644 index 0000000000..ae7b782c59 --- /dev/null +++ b/photon-serde-tests/src/main/native/include/photon/targeting/BoolTestMessage.h @@ -0,0 +1,51 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/struct/BoolTestMessageStruct.h" + +namespace photon { +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +class BoolTestMessage : public BoolTestMessage_PhotonStruct { + using Base = BoolTestMessage_PhotonStruct; + +public: + BoolTestMessage() = default; + + explicit BoolTestMessage(Base&& data) : Base(data) {} + + template + explicit BoolTestMessage(Args&&... args) + : Base{std::forward(args)...} {} + + friend bool operator==(BoolTestMessage const&, BoolTestMessage const&) = default; +}; +} // namespace photon + +#include "photon/serde/BoolTestMessageSerde.h" \ No newline at end of file diff --git a/photon-serde-tests/src/main/native/include/photon/targeting/Float32TestMessage.h b/photon-serde-tests/src/main/native/include/photon/targeting/Float32TestMessage.h new file mode 100644 index 0000000000..f020bb63ee --- /dev/null +++ b/photon-serde-tests/src/main/native/include/photon/targeting/Float32TestMessage.h @@ -0,0 +1,51 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/struct/Float32TestMessageStruct.h" + +namespace photon { +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +class Float32TestMessage : public Float32TestMessage_PhotonStruct { + using Base = Float32TestMessage_PhotonStruct; + +public: + Float32TestMessage() = default; + + explicit Float32TestMessage(Base&& data) : Base(data) {} + + template + explicit Float32TestMessage(Args&&... args) + : Base{std::forward(args)...} {} + + friend bool operator==(Float32TestMessage const&, Float32TestMessage const&) = default; +}; +} // namespace photon + +#include "photon/serde/Float32TestMessageSerde.h" \ No newline at end of file diff --git a/photon-serde-tests/src/main/native/include/photon/targeting/Float64TestMessage.h b/photon-serde-tests/src/main/native/include/photon/targeting/Float64TestMessage.h new file mode 100644 index 0000000000..79d80fd45b --- /dev/null +++ b/photon-serde-tests/src/main/native/include/photon/targeting/Float64TestMessage.h @@ -0,0 +1,51 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/struct/Float64TestMessageStruct.h" + +namespace photon { +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +class Float64TestMessage : public Float64TestMessage_PhotonStruct { + using Base = Float64TestMessage_PhotonStruct; + +public: + Float64TestMessage() = default; + + explicit Float64TestMessage(Base&& data) : Base(data) {} + + template + explicit Float64TestMessage(Args&&... args) + : Base{std::forward(args)...} {} + + friend bool operator==(Float64TestMessage const&, Float64TestMessage const&) = default; +}; +} // namespace photon + +#include "photon/serde/Float64TestMessageSerde.h" \ No newline at end of file diff --git a/photon-serde-tests/src/main/native/include/photon/targeting/Int16TestMessage.h b/photon-serde-tests/src/main/native/include/photon/targeting/Int16TestMessage.h new file mode 100644 index 0000000000..a05168af30 --- /dev/null +++ b/photon-serde-tests/src/main/native/include/photon/targeting/Int16TestMessage.h @@ -0,0 +1,51 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/struct/Int16TestMessageStruct.h" + +namespace photon { +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +class Int16TestMessage : public Int16TestMessage_PhotonStruct { + using Base = Int16TestMessage_PhotonStruct; + +public: + Int16TestMessage() = default; + + explicit Int16TestMessage(Base&& data) : Base(data) {} + + template + explicit Int16TestMessage(Args&&... args) + : Base{std::forward(args)...} {} + + friend bool operator==(Int16TestMessage const&, Int16TestMessage const&) = default; +}; +} // namespace photon + +#include "photon/serde/Int16TestMessageSerde.h" \ No newline at end of file diff --git a/photon-serde-tests/src/main/native/include/photon/targeting/Int32TestMessage.h b/photon-serde-tests/src/main/native/include/photon/targeting/Int32TestMessage.h new file mode 100644 index 0000000000..d5df8c6063 --- /dev/null +++ b/photon-serde-tests/src/main/native/include/photon/targeting/Int32TestMessage.h @@ -0,0 +1,51 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/struct/Int32TestMessageStruct.h" + +namespace photon { +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +class Int32TestMessage : public Int32TestMessage_PhotonStruct { + using Base = Int32TestMessage_PhotonStruct; + +public: + Int32TestMessage() = default; + + explicit Int32TestMessage(Base&& data) : Base(data) {} + + template + explicit Int32TestMessage(Args&&... args) + : Base{std::forward(args)...} {} + + friend bool operator==(Int32TestMessage const&, Int32TestMessage const&) = default; +}; +} // namespace photon + +#include "photon/serde/Int32TestMessageSerde.h" \ No newline at end of file diff --git a/photon-serde-tests/src/main/native/include/photon/targeting/Int64TestMessage.h b/photon-serde-tests/src/main/native/include/photon/targeting/Int64TestMessage.h new file mode 100644 index 0000000000..9df6fa7fee --- /dev/null +++ b/photon-serde-tests/src/main/native/include/photon/targeting/Int64TestMessage.h @@ -0,0 +1,51 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/struct/Int64TestMessageStruct.h" + +namespace photon { +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +class Int64TestMessage : public Int64TestMessage_PhotonStruct { + using Base = Int64TestMessage_PhotonStruct; + +public: + Int64TestMessage() = default; + + explicit Int64TestMessage(Base&& data) : Base(data) {} + + template + explicit Int64TestMessage(Args&&... args) + : Base{std::forward(args)...} {} + + friend bool operator==(Int64TestMessage const&, Int64TestMessage const&) = default; +}; +} // namespace photon + +#include "photon/serde/Int64TestMessageSerde.h" \ No newline at end of file diff --git a/photon-serde-tests/src/main/native/include/photon/targeting/Int8TestMessage.h b/photon-serde-tests/src/main/native/include/photon/targeting/Int8TestMessage.h new file mode 100644 index 0000000000..d7e9e3c3ea --- /dev/null +++ b/photon-serde-tests/src/main/native/include/photon/targeting/Int8TestMessage.h @@ -0,0 +1,51 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/struct/Int8TestMessageStruct.h" + +namespace photon { +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +class Int8TestMessage : public Int8TestMessage_PhotonStruct { + using Base = Int8TestMessage_PhotonStruct; + +public: + Int8TestMessage() = default; + + explicit Int8TestMessage(Base&& data) : Base(data) {} + + template + explicit Int8TestMessage(Args&&... args) + : Base{std::forward(args)...} {} + + friend bool operator==(Int8TestMessage const&, Int8TestMessage const&) = default; +}; +} // namespace photon + +#include "photon/serde/Int8TestMessageSerde.h" \ No newline at end of file diff --git a/photon-serde-tests/src/main/native/include/photon/targeting/Transform3dTestMessage.h b/photon-serde-tests/src/main/native/include/photon/targeting/Transform3dTestMessage.h new file mode 100644 index 0000000000..1b12f52678 --- /dev/null +++ b/photon-serde-tests/src/main/native/include/photon/targeting/Transform3dTestMessage.h @@ -0,0 +1,51 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include "photon/struct/Transform3dTestMessageStruct.h" + +namespace photon { +/** + * Auto-generated ser/de test class, not intended for use in actual dataflow + */ +class Transform3dTestMessage : public Transform3dTestMessage_PhotonStruct { + using Base = Transform3dTestMessage_PhotonStruct; + +public: + Transform3dTestMessage() = default; + + explicit Transform3dTestMessage(Base&& data) : Base(data) {} + + template + explicit Transform3dTestMessage(Args&&... args) + : Base{std::forward(args)...} {} + + friend bool operator==(Transform3dTestMessage const&, Transform3dTestMessage const&) = default; +}; +} // namespace photon + +#include "photon/serde/Transform3dTestMessageSerde.h" \ No newline at end of file diff --git a/photon-serde-tests/src/test/java/org/photonvision/AutoSerdeTest.java b/photon-serde-tests/src/test/java/org/photonvision/AutoSerdeTest.java new file mode 100644 index 0000000000..bae6ae57b2 --- /dev/null +++ b/photon-serde-tests/src/test/java/org/photonvision/AutoSerdeTest.java @@ -0,0 +1,229 @@ +/* + * Copyright (C) Photon Vision. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +package org.photonvision; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.List; +import java.util.Optional; +import org.junit.jupiter.api.Test; +import org.photonvision.common.dataflow.structures.Packet; +import org.photonvision.targeting.*; +import org.photonvision.targeting.serde.PhotonStructSerializable; + +import org.wpilib.math.geometry.Rotation3d; +import org.wpilib.math.geometry.Translation3d; +import org.wpilib.math.geometry.Transform3d; + + +public class AutoSerdeTest { + private > boolean testSerde(T data) { + var p = new Packet(10); + p.encode(data); + var unpackedData = p.decode(data); // kinda scuffed lowkey + System.out.println("IN: " + data.toString() + "\nOUT: " + unpackedData.toString()); + return data.equals(unpackedData); + } + + @Test + public void Int8Test() { + System.out.println("Running Int8Test"); + + var default_test = new Int8TestMessage(); + assertTrue(testSerde(default_test)); + + var optional_test = new Int8TestMessage(); + optional_test.optTest = Optional.of((byte) 3); + assertTrue(testSerde(optional_test)); + + var vla_test = new Int8TestMessage(); + vla_test.vlaTest = List.of((byte) 1, (byte) 2, (byte) 3); + assertTrue(testSerde(vla_test)); + + var general_test = new Int8TestMessage(); + general_test.test = (byte) 42; + general_test.optTest = Optional.of((byte) 7); + general_test.vlaTest = List.of((byte) 4, (byte) 5, (byte) 6); + assertTrue(testSerde(general_test)); + + } + + @Test + public void Int16Test() { + System.out.println("Running Int16Test"); + + var default_test = new Int16TestMessage(); + assertTrue(testSerde(default_test)); + + var optional_test = new Int16TestMessage(); + optional_test.optTest = Optional.of((short) 3); + assertTrue(testSerde(optional_test)); + + var vla_test = new Int16TestMessage(); + vla_test.vlaTest = List.of((short) 1, (short) 2, (short) 3); + assertTrue(testSerde(vla_test)); + + var general_test = new Int16TestMessage(); + general_test.test = (short) 42; + general_test.optTest = Optional.of((short) 7); + general_test.vlaTest = List.of((short) 4, (short) 5, (short) 6); + assertTrue(testSerde(general_test)); + + } + + @Test + public void Int32Test() { + System.out.println("Running Int32Test"); + + var default_test = new Int32TestMessage(); + assertTrue(testSerde(default_test)); + + var optional_test = new Int32TestMessage(); + optional_test.optTest = Optional.of((int) 3); + assertTrue(testSerde(optional_test)); + + var vla_test = new Int32TestMessage(); + vla_test.vlaTest = List.of((int) 1, (int) 2, (int) 3); + assertTrue(testSerde(vla_test)); + + var general_test = new Int32TestMessage(); + general_test.test = (int) 42; + general_test.optTest = Optional.of((int) 7); + general_test.vlaTest = List.of((int) 4, (int) 5, (int) 6); + assertTrue(testSerde(general_test)); + + } + + @Test + public void Int64Test() { + System.out.println("Running Int64Test"); + + var default_test = new Int64TestMessage(); + assertTrue(testSerde(default_test)); + + var optional_test = new Int64TestMessage(); + optional_test.optTest = Optional.of((long) 3); + assertTrue(testSerde(optional_test)); + + var vla_test = new Int64TestMessage(); + vla_test.vlaTest = List.of((long) 1, (long) 2, (long) 3); + assertTrue(testSerde(vla_test)); + + var general_test = new Int64TestMessage(); + general_test.test = (long) 42; + general_test.optTest = Optional.of((long) 7); + general_test.vlaTest = List.of((long) 4, (long) 5, (long) 6); + assertTrue(testSerde(general_test)); + + } + + @Test + public void Float32Test() { + System.out.println("Running Float32Test"); + + var default_test = new Float32TestMessage(); + assertTrue(testSerde(default_test)); + + var optional_test = new Float32TestMessage(); + optional_test.optTest = Optional.of((float) 3.0); + assertTrue(testSerde(optional_test)); + + var vla_test = new Float32TestMessage(); + vla_test.vlaTest = List.of((float) 1.0, (float) 2.0, (float) 3.0); + assertTrue(testSerde(vla_test)); + + var general_test = new Float32TestMessage(); + general_test.test = (float) 42.0; + general_test.optTest = Optional.of((float) 7.0); + general_test.vlaTest = List.of((float) 4.0, (float) 5.0, (float) 6.0); + assertTrue(testSerde(general_test)); + + } + + @Test + public void Float64Test() { + System.out.println("Running Float64Test"); + + var default_test = new Float64TestMessage(); + assertTrue(testSerde(default_test)); + + var optional_test = new Float64TestMessage(); + optional_test.optTest = Optional.of((double) 3.0); + assertTrue(testSerde(optional_test)); + + var vla_test = new Float64TestMessage(); + vla_test.vlaTest = List.of((double) 1.0, (double) 2.0, (double) 3.0); + assertTrue(testSerde(vla_test)); + + var general_test = new Float64TestMessage(); + general_test.test = (double) 42.0; + general_test.optTest = Optional.of((double) 7.0); + general_test.vlaTest = List.of((double) 4.0, (double) 5.0, (double) 6.0); + assertTrue(testSerde(general_test)); + + } + + @Test + public void BoolTest() { + System.out.println("Running BoolTest"); + + var default_test = new BoolTestMessage(); + assertTrue(testSerde(default_test)); + + var optional_test = new BoolTestMessage(); + optional_test.optTest = Optional.of(true); + assertTrue(testSerde(optional_test)); + + var vla_test = new BoolTestMessage(); + vla_test.vlaTest = List.of(true, false, true); + assertTrue(testSerde(vla_test)); + + var general_test = new BoolTestMessage(); + general_test.test = false; + general_test.optTest = Optional.of(true); + general_test.vlaTest = List.of(true, false, true); + assertTrue(testSerde(general_test)); + + } + + @Test + public void Transform3dTest() { + System.out.println("Running Transform3dTest"); + + var default_test = new Transform3dTestMessage(); + assertTrue(testSerde(default_test)); + + var optional_test = new Transform3dTestMessage(); + optional_test.optTest = Optional.of(new Transform3d(new Translation3d(1.0, 2.0, 3.0), new Rotation3d(0.1, 0.2, 0.3))); + assertTrue(testSerde(optional_test)); + + var vla_test = new Transform3dTestMessage(); + vla_test.vlaTest = List.of(new Transform3d(new Translation3d(1.0, 2.0, 3.0), new Rotation3d(0.1, 0.2, 0.3)), new Transform3d(new Translation3d(4.0, 5.0, 6.0), new Rotation3d(0.4, 0.5, 0.6))); + assertTrue(testSerde(vla_test)); + + var general_test = new Transform3dTestMessage(); + general_test.test = new Transform3d(new Translation3d(7.0, 8.0, 9.0), new Rotation3d(0.7, 0.8, 0.9)); + general_test.optTest = Optional.of(new Transform3d(new Translation3d(1.0, 2.0, 3.0), new Rotation3d(0.1, 0.2, 0.3))); + general_test.vlaTest = List.of(new Transform3d(new Translation3d(1.0, 2.0, 3.0), new Rotation3d(0.1, 0.2, 0.3)), new Transform3d(new Translation3d(4.0, 5.0, 6.0), new Rotation3d(0.4, 0.5, 0.6))); + assertTrue(testSerde(general_test)); + + } + +} \ No newline at end of file diff --git a/photon-serde-tests/src/test/native/cpp/AutoSerdeTest.cpp b/photon-serde-tests/src/test/native/cpp/AutoSerdeTest.cpp new file mode 100644 index 0000000000..bfd07cb4df --- /dev/null +++ b/photon-serde-tests/src/test/native/cpp/AutoSerdeTest.cpp @@ -0,0 +1,236 @@ +/* + * Copyright (C) Photon Vision. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +// THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY + +#include +#include +#include + +#include + +#include "gtest/gtest.h" + +#include +#include +#include +#include + + +#include "photon/targeting/Int8TestMessage.h" +#include "photon/targeting/Int16TestMessage.h" +#include "photon/targeting/Int32TestMessage.h" +#include "photon/targeting/Int64TestMessage.h" +#include "photon/targeting/Float32TestMessage.h" +#include "photon/targeting/Float64TestMessage.h" +#include "photon/targeting/BoolTestMessage.h" +#include "photon/targeting/Transform3dTestMessage.h" + + +// Hack +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} + +using namespace photon; + +template + requires(PhotonStructSerializable) +inline bool test_serde(const T& data) { + Packet p; + p.Pack(data); + T unpackedData = p.Unpack(); + return data == unpackedData; +} + + +TEST(AutoSerdeTest, Int8Test) { + std::cout << "Running Int8Test\n"; + + Int8TestMessage default_test{}; + ASSERT_TRUE(test_serde(default_test)); + + Int8TestMessage optional_test{}; + optional_test.optTest = {3}; + ASSERT_TRUE(test_serde(optional_test)); + + Int8TestMessage vla_test{}; + vla_test.vlaTest = {1, 2, 3}; + ASSERT_TRUE(test_serde(vla_test)); + + Int8TestMessage general_test{}; + general_test.test = 42; + general_test.optTest = {7}; + general_test.vlaTest = {4, 5, 6}; + ASSERT_TRUE(test_serde(general_test)); + +} + +TEST(AutoSerdeTest, Int16Test) { + std::cout << "Running Int16Test\n"; + + Int16TestMessage default_test{}; + ASSERT_TRUE(test_serde(default_test)); + + Int16TestMessage optional_test{}; + optional_test.optTest = {3}; + ASSERT_TRUE(test_serde(optional_test)); + + Int16TestMessage vla_test{}; + vla_test.vlaTest = {1, 2, 3}; + ASSERT_TRUE(test_serde(vla_test)); + + Int16TestMessage general_test{}; + general_test.test = 42; + general_test.optTest = {7}; + general_test.vlaTest = {4, 5, 6}; + ASSERT_TRUE(test_serde(general_test)); + +} + +TEST(AutoSerdeTest, Int32Test) { + std::cout << "Running Int32Test\n"; + + Int32TestMessage default_test{}; + ASSERT_TRUE(test_serde(default_test)); + + Int32TestMessage optional_test{}; + optional_test.optTest = {3}; + ASSERT_TRUE(test_serde(optional_test)); + + Int32TestMessage vla_test{}; + vla_test.vlaTest = {1, 2, 3}; + ASSERT_TRUE(test_serde(vla_test)); + + Int32TestMessage general_test{}; + general_test.test = 42; + general_test.optTest = {7}; + general_test.vlaTest = {4, 5, 6}; + ASSERT_TRUE(test_serde(general_test)); + +} + +TEST(AutoSerdeTest, Int64Test) { + std::cout << "Running Int64Test\n"; + + Int64TestMessage default_test{}; + ASSERT_TRUE(test_serde(default_test)); + + Int64TestMessage optional_test{}; + optional_test.optTest = {3}; + ASSERT_TRUE(test_serde(optional_test)); + + Int64TestMessage vla_test{}; + vla_test.vlaTest = {1, 2, 3}; + ASSERT_TRUE(test_serde(vla_test)); + + Int64TestMessage general_test{}; + general_test.test = 42; + general_test.optTest = {7}; + general_test.vlaTest = {4, 5, 6}; + ASSERT_TRUE(test_serde(general_test)); + +} + +TEST(AutoSerdeTest, Float32Test) { + std::cout << "Running Float32Test\n"; + + Float32TestMessage default_test{}; + ASSERT_TRUE(test_serde(default_test)); + + Float32TestMessage optional_test{}; + optional_test.optTest = {3.0}; + ASSERT_TRUE(test_serde(optional_test)); + + Float32TestMessage vla_test{}; + vla_test.vlaTest = {1.0, 2.0, 3.0}; + ASSERT_TRUE(test_serde(vla_test)); + + Float32TestMessage general_test{}; + general_test.test = 42.0; + general_test.optTest = {7.0}; + general_test.vlaTest = {4.0, 5.0, 6.0}; + ASSERT_TRUE(test_serde(general_test)); + +} + +TEST(AutoSerdeTest, Float64Test) { + std::cout << "Running Float64Test\n"; + + Float64TestMessage default_test{}; + ASSERT_TRUE(test_serde(default_test)); + + Float64TestMessage optional_test{}; + optional_test.optTest = {3.0}; + ASSERT_TRUE(test_serde(optional_test)); + + Float64TestMessage vla_test{}; + vla_test.vlaTest = {1.0, 2.0, 3.0}; + ASSERT_TRUE(test_serde(vla_test)); + + Float64TestMessage general_test{}; + general_test.test = 42.0; + general_test.optTest = {7.0}; + general_test.vlaTest = {4.0, 5.0, 6.0}; + ASSERT_TRUE(test_serde(general_test)); + +} + +TEST(AutoSerdeTest, BoolTest) { + std::cout << "Running BoolTest\n"; + + BoolTestMessage default_test{}; + ASSERT_TRUE(test_serde(default_test)); + + BoolTestMessage optional_test{}; + optional_test.optTest = {true}; + ASSERT_TRUE(test_serde(optional_test)); + + BoolTestMessage vla_test{}; + vla_test.vlaTest = {true, false, true}; + ASSERT_TRUE(test_serde(vla_test)); + + BoolTestMessage general_test{}; + general_test.test = false; + general_test.optTest = {true}; + general_test.vlaTest = {true, false, true}; + ASSERT_TRUE(test_serde(general_test)); + +} + +TEST(AutoSerdeTest, Transform3dTest) { + std::cout << "Running Transform3dTest\n"; + + Transform3dTestMessage default_test{}; + ASSERT_TRUE(test_serde(default_test)); + + Transform3dTestMessage optional_test{}; + optional_test.optTest = {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}; + ASSERT_TRUE(test_serde(optional_test)); + + Transform3dTestMessage vla_test{}; + vla_test.vlaTest = {{1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}},{1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}},{8_m, 2_m, 1_m, wpi::math::Rotation3d{0_deg, 1_deg, 88_deg}}}; + ASSERT_TRUE(test_serde(vla_test)); + + Transform3dTestMessage general_test{}; + general_test.test = {8_m, 2_m, 1_m, wpi::math::Rotation3d{0_deg, 1_deg, 88_deg}}; + general_test.optTest = {1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}}; + general_test.vlaTest = {{1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}},{1_m, 2_m, 3_m, wpi::math::Rotation3d{6_deg, 7_deg, 12_deg}},{8_m, 2_m, 1_m, wpi::math::Rotation3d{0_deg, 1_deg, 88_deg}}}; + ASSERT_TRUE(test_serde(general_test)); + +} diff --git a/photon-serde/generate_messages.py b/photon-serde/generate_messages.py index 14c6630e78..46abf3ea4c 100644 --- a/photon-serde/generate_messages.py +++ b/photon-serde/generate_messages.py @@ -383,9 +383,7 @@ def generate_photon_messages(cpp_java_root, py_root, template_root): # TODO: code duplication -def generate_tests( - cpp_java_root, cpp_java_test_root, py_root, py_test_root, template_root -): +def generate_tests(cpp_java_test_root, py_test_root, template_root): # Generate test messages test_messages = parse_yaml("test_messages.yaml") @@ -418,35 +416,33 @@ def generate_tests( "python_type": name, } - java_output_dir = Path(cpp_java_root) / "main/java/org/photonvision/struct/test" + java_output_dir = Path(cpp_java_test_root) / "main/java/org/photonvision/struct" java_output_dir.mkdir(parents=True, exist_ok=True) java_test_class_output_dir = ( - Path(cpp_java_root) / "main/java/org/photonvision/targeting" + Path(cpp_java_test_root) / "main/java/org/photonvision/targeting" ) java_test_class_output_dir.mkdir(parents=True, exist_ok=True) - cpp_serde_header_dir = ( - Path(cpp_java_root) / "main/native/include/photon/serde/test/" - ) + cpp_serde_header_dir = Path(cpp_java_test_root) / "main/native/include/photon/serde" cpp_serde_header_dir.mkdir(parents=True, exist_ok=True) - cpp_serde_source_dir = Path(cpp_java_root) / "main/native/cpp/photon/serde/test/" + cpp_serde_source_dir = Path(cpp_java_test_root) / "main/native/cpp/photon/serde" cpp_serde_source_dir.mkdir(parents=True, exist_ok=True) cpp_struct_header_dir = ( - Path(cpp_java_root) / "main/native/include/photon/struct/test/" + Path(cpp_java_test_root) / "main/native/include/photon/struct/" ) cpp_struct_header_dir.mkdir(parents=True, exist_ok=True) cpp_test_struct_output_dir = ( - Path(cpp_java_root) / "main/native/include/photon/targeting/" + Path(cpp_java_test_root) / "main/native/include/photon/targeting/" ) cpp_test_struct_output_dir.mkdir(parents=True, exist_ok=True) - py_serde_source_dir = Path(py_root) / "test" + py_serde_source_dir = Path(py_test_root) py_serde_source_dir.mkdir(parents=True, exist_ok=True) - python_test_dataclass_output_dir = Path(py_root) / "test" + python_test_dataclass_output_dir = Path(py_test_root) env.filters["get_cpp_qualified_name"] = lambda field: get_cpp_qualified_name( message_db, extended_data_types, field @@ -555,10 +551,10 @@ def generate_tests( # Generate test fixtures (WIP) tests = parse_yaml("tests.yaml") java_test_target = ( - Path(cpp_java_test_root) / "java/org/photonvision/AutoSerdeTest.java" + Path(cpp_java_test_root) / "test/java/org/photonvision/AutoSerdeTest.java" ) java_test_target.parent.mkdir(parents=True, exist_ok=True) - cpp_test_target = Path(cpp_java_test_root) / "native/cpp/AutoSerdeTest.cpp" + cpp_test_target = Path(cpp_java_test_root) / "test/native/cpp/AutoSerdeTest.cpp" cpp_test_target.parent.mkdir(parents=True, exist_ok=True) Path(py_test_root) / "AutoSerdeTest.py" @@ -581,21 +577,21 @@ def main(argv): type=Path, ) parser.add_argument( - "--py_output_dir", - help="Optional. If set, will spit Python serde files here", - default=dirname.parent / "photon-lib/py/photonlibpy/generated", + "--cppjava_test_output_dir", + help="Optional. If set, will spit cpp/java test files here", + default=dirname.parent / "photon-serde-tests/src", type=Path, ) parser.add_argument( - "--cpp_java_test_dir", - help="Optional. If set, will output the generated test fixtures to this directory, otherwise it will use a path relative to the script", - default=dirname.parent / "photon-targeting/src/generated-test", + "--py_output_dir", + help="Optional. If set, will spit Python serde files here", + default=dirname.parent / "photon-lib/py/photonlibpy/generated", type=Path, ) parser.add_argument( - "--py_test_dir", - help="Optional. If set, will spit Python test fixtures here", - default=dirname.parent / "photon-lib/py/generated-test", + "--py_test_output_dir", + help="Optional. If set, will spit python test files here", + default=dirname.parent / "photon-serde-tests/py", type=Path, ) parser.add_argument( @@ -613,10 +609,8 @@ def main(argv): if args.tests: generate_tests( - args.cpp_java_output_dir, - args.cpp_java_test_dir, - args.py_output_dir, - args.py_test_dir, + args.cppjava_test_output_dir, + args.py_test_output_dir, args.template_root, ) else: diff --git a/photon-serde/templates/Message.java.jinja b/photon-serde/templates/Message.java.jinja index 0536c99cad..6f5d121da2 100644 --- a/photon-serde/templates/Message.java.jinja +++ b/photon-serde/templates/Message.java.jinja @@ -24,11 +24,7 @@ // THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY -{% if test %} -package org.photonvision.struct.test; -{% else %} package org.photonvision.struct; -{% endif %} import org.photonvision.common.dataflow.structures.Packet; import org.photonvision.common.dataflow.structures.PacketSerde; diff --git a/photon-serde/templates/ThingSerde.cpp.jinja b/photon-serde/templates/ThingSerde.cpp.jinja index 068267925c..c2b08f5c1d 100644 --- a/photon-serde/templates/ThingSerde.cpp.jinja +++ b/photon-serde/templates/ThingSerde.cpp.jinja @@ -24,11 +24,7 @@ // THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY -{% if test %} -#include "photon/serde/test/{{ name }}Serde.h" -{% else %} #include "photon/serde/{{ name }}Serde.h" -{% endif %} namespace photon { diff --git a/photon-serde/templates/ThingSerde.py.jinja b/photon-serde/templates/ThingSerde.py.jinja index 6d7c0d1f70..3a266ec36a 100644 --- a/photon-serde/templates/ThingSerde.py.jinja +++ b/photon-serde/templates/ThingSerde.py.jinja @@ -30,8 +30,8 @@ from typing import TYPE_CHECKING {% if test %} -from ...packet import Packet -from ...targeting import * # noqa +from photonlib.packet import Packet +from photonlib.targeting import * # noqa {% else %} from ..packet import Packet from ..targeting import * # noqa diff --git a/photon-serde/templates/ThingTestClass.java.jinja b/photon-serde/templates/ThingTestClass.java.jinja index e58a1d421b..42133cdbc7 100644 --- a/photon-serde/templates/ThingTestClass.java.jinja +++ b/photon-serde/templates/ThingTestClass.java.jinja @@ -29,7 +29,7 @@ package org.photonvision.targeting; import java.util.List; import java.util.Optional; -import org.photonvision.struct.test.{{ name }}Serde; +import org.photonvision.struct.{{ name }}Serde; import org.photonvision.common.dataflow.structures.PacketSerde; import org.photonvision.targeting.serde.PhotonStructSerializable; diff --git a/photon-serde/templates/ThingTestDataclass.py.jinja b/photon-serde/templates/ThingTestDataclass.py.jinja index 75e7080a68..c7b6044061 100644 --- a/photon-serde/templates/ThingTestDataclass.py.jinja +++ b/photon-serde/templates/ThingTestDataclass.py.jinja @@ -30,8 +30,8 @@ from typing import TYPE_CHECKING, Optional from dataclasses import dataclass -from ...packet import Packet -from ...targeting import * # noqa +from photonlib.packet import Packet +from photonlib.targeting import * # noqa {% for type in nested_wpilib_types -%} from {{ get_message_by_name(type).python_module }} import {{ type }} diff --git a/photon-serde/templates/ThingTestStruct.h.jinja b/photon-serde/templates/ThingTestStruct.h.jinja index 40f0e67cdd..8c200c9d9f 100644 --- a/photon-serde/templates/ThingTestStruct.h.jinja +++ b/photon-serde/templates/ThingTestStruct.h.jinja @@ -26,7 +26,7 @@ // THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. DO NOT MODIFY -#include "photon/struct/test/{{ name }}Struct.h" +#include "photon/struct/{{ name }}Struct.h" namespace photon { /** @@ -48,4 +48,4 @@ public: }; } // namespace photon -#include "photon/serde/test/{{ name }}Serde.h" \ No newline at end of file +#include "photon/serde/{{ name }}Serde.h" \ No newline at end of file diff --git a/photon-serde/templates/ThingTests.cpp.jinja b/photon-serde/templates/ThingTests.cpp.jinja index 47aecfcd7f..ea9216762d 100644 --- a/photon-serde/templates/ThingTests.cpp.jinja +++ b/photon-serde/templates/ThingTests.cpp.jinja @@ -21,7 +21,7 @@ #include #include -#include +#include #include "gtest/gtest.h" @@ -33,6 +33,12 @@ #include "photon/targeting/{{ test.type }}.h" {% endfor %} +// Hack +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} + using namespace photon; template diff --git a/photon-serde/tests.yaml b/photon-serde/tests.yaml index 54618d628c..351e59c6ea 100644 --- a/photon-serde/tests.yaml +++ b/photon-serde/tests.yaml @@ -9,9 +9,9 @@ cpp_includes: - '' - '' python_imports: -- 'from wpimath.geometry import Rotation3d' -- 'from wpimath.geometry import Translation3d' -- 'from wpimath.geometry import Transform3d' +- 'from wpimath import Rotation3d' +- 'from wpimath import Translation3d' +- 'from wpimath import Transform3d' tests: - name: Int8Test type: Int8TestMessage diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java index 48da60b3ad..46528cc3a0 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java @@ -89,7 +89,7 @@ public PhotonPipelineResult unpack(Packet packet) { @Override public PacketSerde[] getNestedPhotonMessages() { return new PacketSerde[] { - PhotonPipelineMetadata.photonStruct,MultiTargetPNPResult.photonStruct,PhotonTrackedTarget.photonStruct + MultiTargetPNPResult.photonStruct,PhotonTrackedTarget.photonStruct,PhotonPipelineMetadata.photonStruct }; } diff --git a/photon-targeting/src/generated/main/native/cpp/photon/serde/MultiTargetPNPResultSerde.cpp b/photon-targeting/src/generated/main/native/cpp/photon/serde/MultiTargetPNPResultSerde.cpp index 5676e05e44..8d377ba531 100644 --- a/photon-targeting/src/generated/main/native/cpp/photon/serde/MultiTargetPNPResultSerde.cpp +++ b/photon-targeting/src/generated/main/native/cpp/photon/serde/MultiTargetPNPResultSerde.cpp @@ -26,6 +26,7 @@ #include "photon/serde/MultiTargetPNPResultSerde.h" + namespace photon { using StructType = SerdeType; diff --git a/photon-targeting/src/generated/main/native/cpp/photon/serde/PhotonPipelineMetadataSerde.cpp b/photon-targeting/src/generated/main/native/cpp/photon/serde/PhotonPipelineMetadataSerde.cpp index 8dfddc3d0d..7c0b5574e3 100644 --- a/photon-targeting/src/generated/main/native/cpp/photon/serde/PhotonPipelineMetadataSerde.cpp +++ b/photon-targeting/src/generated/main/native/cpp/photon/serde/PhotonPipelineMetadataSerde.cpp @@ -26,6 +26,7 @@ #include "photon/serde/PhotonPipelineMetadataSerde.h" + namespace photon { using StructType = SerdeType; diff --git a/photon-targeting/src/generated/main/native/cpp/photon/serde/PhotonPipelineResultSerde.cpp b/photon-targeting/src/generated/main/native/cpp/photon/serde/PhotonPipelineResultSerde.cpp index eebb222826..d0bbbe33d2 100644 --- a/photon-targeting/src/generated/main/native/cpp/photon/serde/PhotonPipelineResultSerde.cpp +++ b/photon-targeting/src/generated/main/native/cpp/photon/serde/PhotonPipelineResultSerde.cpp @@ -26,6 +26,7 @@ #include "photon/serde/PhotonPipelineResultSerde.h" + namespace photon { using StructType = SerdeType; diff --git a/photon-targeting/src/generated/main/native/cpp/photon/serde/PhotonTrackedTargetSerde.cpp b/photon-targeting/src/generated/main/native/cpp/photon/serde/PhotonTrackedTargetSerde.cpp index d1dbbf0c1b..cb62d2bc11 100644 --- a/photon-targeting/src/generated/main/native/cpp/photon/serde/PhotonTrackedTargetSerde.cpp +++ b/photon-targeting/src/generated/main/native/cpp/photon/serde/PhotonTrackedTargetSerde.cpp @@ -26,6 +26,7 @@ #include "photon/serde/PhotonTrackedTargetSerde.h" + namespace photon { using StructType = SerdeType; diff --git a/photon-targeting/src/generated/main/native/cpp/photon/serde/PnpResultSerde.cpp b/photon-targeting/src/generated/main/native/cpp/photon/serde/PnpResultSerde.cpp index 0fc4a5882f..2d38d346c1 100644 --- a/photon-targeting/src/generated/main/native/cpp/photon/serde/PnpResultSerde.cpp +++ b/photon-targeting/src/generated/main/native/cpp/photon/serde/PnpResultSerde.cpp @@ -26,6 +26,7 @@ #include "photon/serde/PnpResultSerde.h" + namespace photon { using StructType = SerdeType; diff --git a/photon-targeting/src/generated/main/native/cpp/photon/serde/TargetCornerSerde.cpp b/photon-targeting/src/generated/main/native/cpp/photon/serde/TargetCornerSerde.cpp index 925fdd1806..d14eda59be 100644 --- a/photon-targeting/src/generated/main/native/cpp/photon/serde/TargetCornerSerde.cpp +++ b/photon-targeting/src/generated/main/native/cpp/photon/serde/TargetCornerSerde.cpp @@ -26,6 +26,7 @@ #include "photon/serde/TargetCornerSerde.h" + namespace photon { using StructType = SerdeType; diff --git a/settings.gradle b/settings.gradle index 30f98b2fb4..503440e89c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -14,4 +14,5 @@ include 'photon-targeting' include 'photon-core' include 'photon-server' include 'photon-lib' +include 'photon-serde-tests' include 'photon-docs' From 1029c36374006a6cb374eaba1fdc6be308c6de28 Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Thu, 28 May 2026 22:11:31 -0400 Subject: [PATCH 31/42] deleted testMessages.py --- .../py/photonlibpy/targeting/testMessages.py | 62 ------------------- 1 file changed, 62 deletions(-) delete mode 100644 photon-lib/py/photonlibpy/targeting/testMessages.py diff --git a/photon-lib/py/photonlibpy/targeting/testMessages.py b/photon-lib/py/photonlibpy/targeting/testMessages.py deleted file mode 100644 index a8bffeb7de..0000000000 --- a/photon-lib/py/photonlibpy/targeting/testMessages.py +++ /dev/null @@ -1,62 +0,0 @@ -from dataclasses import dataclass -from typing import Optional - -from wpimath.geometry import Transform3d - -# TODO: Autogenerate python test classes? - - -@dataclass -class Int8TestMessage: - test: int - vlaTest: list[int] - optTest: Optional[int] - - -@dataclass -class Int16TestMessage: - test: int - vlaTest: list[int] - optTest: Optional[int] - - -@dataclass -class Int32TestMessage: - test: int - vlaTest: list[int] - optTest: Optional[int] - - -@dataclass -class Int64TestMessage: - test: int - vlaTest: list[int] - optTest: Optional[int] - - -@dataclass -class Float32TestMessage: - test: float - vlaTest: list[float] - optTest: Optional[float] - - -@dataclass -class Float64TestMessage: - test: float - vlaTest: list[float] - optTest: Optional[float] - - -@dataclass -class BoolTestMessage: - test: bool - vlaTest: list[bool] - optTest: Optional[bool] - - -@dataclass -class Transform3dTestMessage: - test: Transform3d - vlaTest: list[Transform3d] - optTest: Optional[Transform3d] From 72b9bebe6d79c45a19385b6b202d4725579fd402 Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Fri, 29 May 2026 13:47:08 -0400 Subject: [PATCH 32/42] added python tests and added them to workflow --- .github/workflows/python.yml | 39 +++- photon-serde-tests/README.md | 4 +- photon-serde-tests/py/AutoSerdeTest.py | 213 ++++++++++++++++++ .../py/Transform3dTestMessage.py | 42 ---- .../py/messages/BoolTestMessage.py | 75 ++++++ .../py/{ => messages}/BoolTestMessageSerde.py | 2 +- .../py/messages/Float32TestMessage.py | 75 ++++++ .../{ => messages}/Float32TestMessageSerde.py | 2 +- .../py/messages/Float64TestMessage.py | 75 ++++++ .../{ => messages}/Float64TestMessageSerde.py | 2 +- .../py/{ => messages}/Int16TestMessage.py | 43 +++- .../{ => messages}/Int16TestMessageSerde.py | 2 +- .../py/{ => messages}/Int32TestMessage.py | 43 +++- .../{ => messages}/Int32TestMessageSerde.py | 2 +- .../py/{ => messages}/Int64TestMessage.py | 43 +++- .../{ => messages}/Int64TestMessageSerde.py | 2 +- .../Int8TestMessage.py} | 45 +++- .../py/{ => messages}/Int8TestMessageSerde.py | 2 +- .../py/messages/Transform3dTestMessage.py | 75 ++++++ .../Transform3dTestMessageSerde.py | 2 +- .../__init__.py} | 43 ++-- photon-serde-tests/requirements.txt | 1 + photon-serde/generate_messages.py | 15 +- photon-serde/requirements.txt | 2 - .../templates/PyInit.py.jinja | 26 +-- photon-serde/templates/ThingSerde.py.jinja | 2 +- .../templates/ThingTestDataclass.py.jinja | 22 +- .../templates/ThingTests.py.jinja | 31 ++- 28 files changed, 806 insertions(+), 124 deletions(-) create mode 100644 photon-serde-tests/py/AutoSerdeTest.py delete mode 100644 photon-serde-tests/py/Transform3dTestMessage.py create mode 100644 photon-serde-tests/py/messages/BoolTestMessage.py rename photon-serde-tests/py/{ => messages}/BoolTestMessageSerde.py (97%) create mode 100644 photon-serde-tests/py/messages/Float32TestMessage.py rename photon-serde-tests/py/{ => messages}/Float32TestMessageSerde.py (97%) create mode 100644 photon-serde-tests/py/messages/Float64TestMessage.py rename photon-serde-tests/py/{ => messages}/Float64TestMessageSerde.py (97%) rename photon-serde-tests/py/{ => messages}/Int16TestMessage.py (51%) rename photon-serde-tests/py/{ => messages}/Int16TestMessageSerde.py (97%) rename photon-serde-tests/py/{ => messages}/Int32TestMessage.py (51%) rename photon-serde-tests/py/{ => messages}/Int32TestMessageSerde.py (97%) rename photon-serde-tests/py/{ => messages}/Int64TestMessage.py (51%) rename photon-serde-tests/py/{ => messages}/Int64TestMessageSerde.py (97%) rename photon-serde-tests/py/{Float64TestMessage.py => messages/Int8TestMessage.py} (51%) rename photon-serde-tests/py/{ => messages}/Int8TestMessageSerde.py (97%) create mode 100644 photon-serde-tests/py/messages/Transform3dTestMessage.py rename photon-serde-tests/py/{ => messages}/Transform3dTestMessageSerde.py (97%) rename photon-serde-tests/py/{Float32TestMessage.py => messages/__init__.py} (56%) create mode 100644 photon-serde-tests/requirements.txt delete mode 100644 photon-serde/requirements.txt rename photon-serde-tests/py/Int8TestMessage.py => photon-serde/templates/PyInit.py.jinja (67%) rename photon-serde-tests/py/BoolTestMessage.py => photon-serde/templates/ThingTests.py.jinja (66%) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index e4cd865c71..f592dfb481 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -76,7 +76,44 @@ jobs: run: pytest --import-mode=importlib photon-lib/py/test/ - name: Run mypy type checking - run: mypy --show-column-numbers --config-file photon-lib/py/pyproject.toml photon-lib + run: mypy --show-column-numbers --config-file photon-lib/py/pyproject.toml photon-lib + + test-photonserde-py: + needs: build-py + runs-on: ubuntu-24.04 + + steps: + - name: Checkout code + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: 3.14 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pytest mypy + pip install -r photon-serde-tests/requirements.txt + + - name: Download artifacts + uses: actions/download-artifact@v8 + with: + name: dist + path: ./photon-lib/py/dist/ + + - name: Install PhotonLibPy package + working-directory: ./photon-lib/py + shell: bash + run: | + pip install --no-cache-dir dist/*.whl + + - name: Run PhotonSerde tests + shell: bash + run: pytest --import-mode=importlib photon-serde-tests/py build-python-examples: needs: build-py diff --git a/photon-serde-tests/README.md b/photon-serde-tests/README.md index 6e63218089..89e3a04b68 100644 --- a/photon-serde-tests/README.md +++ b/photon-serde-tests/README.md @@ -1,3 +1,5 @@ -These are autogenerated tests for photon-serde. ALL CODE IN THIS DIRECTORY (except for build.gradle) IS AUTOMATICALLY GENERATED +These are autogenerated tests for photon-serde. ALL CODE IN THIS DIRECTORY (except for build.gradle and requirements.txt) IS AUTOMATICALLY GENERATED + +requirements.txt is only for version-controlling WPILib. Photonlibpy itself is installed separately, and SHOULD NOT be in the requirements.txt These tests are separated from the main code as we don't use the autogenerated photon-serde test messages anywhere except in the tests, and we don't want to expose them to end-users in photon-lib diff --git a/photon-serde-tests/py/AutoSerdeTest.py b/photon-serde-tests/py/AutoSerdeTest.py new file mode 100644 index 0000000000..ceba60661a --- /dev/null +++ b/photon-serde-tests/py/AutoSerdeTest.py @@ -0,0 +1,213 @@ +# +# MIT License +# +# Copyright (c) PhotonVision +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +############################################################################### +## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. +## --> DO NOT MODIFY <-- +############################################################################### + +from photonlib.packet import Packet +from photonlib.targeting import * +from .messages import * + +from wpimath import Rotation3d; +from wpimath import Translation3d; +from wpimath import Transform3d; + + +def AutoSerdeTest(data) -> bool: + packet = data.photonStruct.pack(data) + unpacked = data.photonStruct.unpack(packet) + print(f"Original: {data}") + print(f"Unpacked: {unpacked}") + return data == unpacked + + +def test_Int8Test(): + print("Running Int8Test...") + + default_test = Int8TestMessage() + assert AutoSerdeTest(default_test) + + optional_test = Int8TestMessage() + optional_test.optTest = 3 + assert AutoSerdeTest(optional_test) + + vla_test = Int8TestMessage() + vla_test.vlaTest = [1, 2, 3] + assert AutoSerdeTest(vla_test) + + general_test = Int8TestMessage() + general_test.test = 42 + general_test.optTest = 7 + general_test.vlaTest = [4, 5, 6] + assert AutoSerdeTest(general_test) + + +def test_Int16Test(): + print("Running Int16Test...") + + default_test = Int16TestMessage() + assert AutoSerdeTest(default_test) + + optional_test = Int16TestMessage() + optional_test.optTest = 3 + assert AutoSerdeTest(optional_test) + + vla_test = Int16TestMessage() + vla_test.vlaTest = [1, 2, 3] + assert AutoSerdeTest(vla_test) + + general_test = Int16TestMessage() + general_test.test = 42 + general_test.optTest = 7 + general_test.vlaTest = [4, 5, 6] + assert AutoSerdeTest(general_test) + + +def test_Int32Test(): + print("Running Int32Test...") + + default_test = Int32TestMessage() + assert AutoSerdeTest(default_test) + + optional_test = Int32TestMessage() + optional_test.optTest = 3 + assert AutoSerdeTest(optional_test) + + vla_test = Int32TestMessage() + vla_test.vlaTest = [1, 2, 3] + assert AutoSerdeTest(vla_test) + + general_test = Int32TestMessage() + general_test.test = 42 + general_test.optTest = 7 + general_test.vlaTest = [4, 5, 6] + assert AutoSerdeTest(general_test) + + +def test_Int64Test(): + print("Running Int64Test...") + + default_test = Int64TestMessage() + assert AutoSerdeTest(default_test) + + optional_test = Int64TestMessage() + optional_test.optTest = 3 + assert AutoSerdeTest(optional_test) + + vla_test = Int64TestMessage() + vla_test.vlaTest = [1, 2, 3] + assert AutoSerdeTest(vla_test) + + general_test = Int64TestMessage() + general_test.test = 42 + general_test.optTest = 7 + general_test.vlaTest = [4, 5, 6] + assert AutoSerdeTest(general_test) + + +def test_Float32Test(): + print("Running Float32Test...") + + default_test = Float32TestMessage() + assert AutoSerdeTest(default_test) + + optional_test = Float32TestMessage() + optional_test.optTest = 3.0 + assert AutoSerdeTest(optional_test) + + vla_test = Float32TestMessage() + vla_test.vlaTest = [1.0, 2.0, 3.0] + assert AutoSerdeTest(vla_test) + + general_test = Float32TestMessage() + general_test.test = 42.0 + general_test.optTest = 7.0 + general_test.vlaTest = [4.0, 5.0, 6.0] + assert AutoSerdeTest(general_test) + + +def test_Float64Test(): + print("Running Float64Test...") + + default_test = Float64TestMessage() + assert AutoSerdeTest(default_test) + + optional_test = Float64TestMessage() + optional_test.optTest = 3.0 + assert AutoSerdeTest(optional_test) + + vla_test = Float64TestMessage() + vla_test.vlaTest = [1.0, 2.0, 3.0] + assert AutoSerdeTest(vla_test) + + general_test = Float64TestMessage() + general_test.test = 42.0 + general_test.optTest = 7.0 + general_test.vlaTest = [4.0, 5.0, 6.0] + assert AutoSerdeTest(general_test) + + +def test_BoolTest(): + print("Running BoolTest...") + + default_test = BoolTestMessage() + assert AutoSerdeTest(default_test) + + optional_test = BoolTestMessage() + optional_test.optTest = True + assert AutoSerdeTest(optional_test) + + vla_test = BoolTestMessage() + vla_test.vlaTest = [True, False, True] + assert AutoSerdeTest(vla_test) + + general_test = BoolTestMessage() + general_test.test = False + general_test.optTest = True + general_test.vlaTest = [True, False, True] + assert AutoSerdeTest(general_test) + + +def test_Transform3dTest(): + print("Running Transform3dTest...") + + default_test = Transform3dTestMessage() + assert AutoSerdeTest(default_test) + + optional_test = Transform3dTestMessage() + optional_test.optTest = Transform3d(Translation3d(1.0, 2.0, 3.0), Rotation3d(0.1, 0.2, 0.3)) + assert AutoSerdeTest(optional_test) + + vla_test = Transform3dTestMessage() + vla_test.vlaTest = [Transform3d(Translation3d(1.0, 2.0, 3.0), Rotation3d(0.1, 0.2, 0.3)), Transform3d(Translation3d(4.0, 5.0, 6.0), Rotation3d(0.4, 0.5, 0.6))] + assert AutoSerdeTest(vla_test) + + general_test = Transform3dTestMessage() + general_test.test = Transform3d(Translation3d(7.0, 8.0, 9.0), Rotation3d(0.7, 0.8, 0.9)) + general_test.optTest = Transform3d(Translation3d(1.0, 2.0, 3.0), Rotation3d(0.1, 0.2, 0.3)) + general_test.vlaTest = [Transform3d(Translation3d(1.0, 2.0, 3.0), Rotation3d(0.1, 0.2, 0.3)), Transform3d(Translation3d(4.0, 5.0, 6.0), Rotation3d(0.4, 0.5, 0.6))] + assert AutoSerdeTest(general_test) + diff --git a/photon-serde-tests/py/Transform3dTestMessage.py b/photon-serde-tests/py/Transform3dTestMessage.py deleted file mode 100644 index 976b91a128..0000000000 --- a/photon-serde-tests/py/Transform3dTestMessage.py +++ /dev/null @@ -1,42 +0,0 @@ -# -# MIT License -# -# Copyright (c) PhotonVision -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -############################################################################### -## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. -## --> DO NOT MODIFY <-- -############################################################################### - -from typing import TYPE_CHECKING, Optional -from dataclasses import dataclass - -from photonlib.packet import Packet -from photonlib.targeting import * # noqa - -from wpimath.geometry import Transform3d - -@dataclass -class Transform3dTestMessage: - test: Transform3d - vlaTest: list[Transform3d] - optTest: Optional[Transform3d] \ No newline at end of file diff --git a/photon-serde-tests/py/messages/BoolTestMessage.py b/photon-serde-tests/py/messages/BoolTestMessage.py new file mode 100644 index 0000000000..1dec7e6b96 --- /dev/null +++ b/photon-serde-tests/py/messages/BoolTestMessage.py @@ -0,0 +1,75 @@ +# +# MIT License +# +# Copyright (c) PhotonVision +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +############################################################################### +## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. +## --> DO NOT MODIFY <-- +############################################################################### + +from typing import TYPE_CHECKING, Optional, ClassVar +from dataclasses import dataclass + +from photonlib.packet import Packet +from photonlib.targeting import * # noqa + +from .BoolTestMessageSerde import BoolTestMessageSerde # noqa + + + + +class _BoolTestMessage_test_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _BoolTestMessage_test_PLACEHOLDER) + +class _BoolTestMessage_vlaTest_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _BoolTestMessage_vlaTest_PLACEHOLDER) + +class _BoolTestMessage_optTest_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _BoolTestMessage_optTest_PLACEHOLDER) + +BoolTestMessage_test_PLACEHOLDER = _BoolTestMessage_test_PLACEHOLDER() +BoolTestMessage_vlaTest_PLACEHOLDER = _BoolTestMessage_vlaTest_PLACEHOLDER() +BoolTestMessage_optTest_PLACEHOLDER = _BoolTestMessage_optTest_PLACEHOLDER() + + +@dataclass(kw_only=True) +class BoolTestMessage: + test: bool | _BoolTestMessage_test_PLACEHOLDER = BoolTestMessage_test_PLACEHOLDER + vlaTest: list[bool] | _BoolTestMessage_vlaTest_PLACEHOLDER = BoolTestMessage_vlaTest_PLACEHOLDER + optTest: Optional[bool] | _BoolTestMessage_optTest_PLACEHOLDER = BoolTestMessage_optTest_PLACEHOLDER + photonStruct: ClassVar[BoolTestMessageSerde] \ No newline at end of file diff --git a/photon-serde-tests/py/BoolTestMessageSerde.py b/photon-serde-tests/py/messages/BoolTestMessageSerde.py similarity index 97% rename from photon-serde-tests/py/BoolTestMessageSerde.py rename to photon-serde-tests/py/messages/BoolTestMessageSerde.py index efbbd1dd73..f574844709 100644 --- a/photon-serde-tests/py/BoolTestMessageSerde.py +++ b/photon-serde-tests/py/messages/BoolTestMessageSerde.py @@ -36,7 +36,7 @@ if TYPE_CHECKING: - from ...targeting import BoolTestMessage # noqa + from .BoolTestMessage import BoolTestMessage # noqa class BoolTestMessageSerde: diff --git a/photon-serde-tests/py/messages/Float32TestMessage.py b/photon-serde-tests/py/messages/Float32TestMessage.py new file mode 100644 index 0000000000..c3d3d3d6e8 --- /dev/null +++ b/photon-serde-tests/py/messages/Float32TestMessage.py @@ -0,0 +1,75 @@ +# +# MIT License +# +# Copyright (c) PhotonVision +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +############################################################################### +## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. +## --> DO NOT MODIFY <-- +############################################################################### + +from typing import TYPE_CHECKING, Optional, ClassVar +from dataclasses import dataclass + +from photonlib.packet import Packet +from photonlib.targeting import * # noqa + +from .Float32TestMessageSerde import Float32TestMessageSerde # noqa + + + + +class _Float32TestMessage_test_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _Float32TestMessage_test_PLACEHOLDER) + +class _Float32TestMessage_vlaTest_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _Float32TestMessage_vlaTest_PLACEHOLDER) + +class _Float32TestMessage_optTest_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _Float32TestMessage_optTest_PLACEHOLDER) + +Float32TestMessage_test_PLACEHOLDER = _Float32TestMessage_test_PLACEHOLDER() +Float32TestMessage_vlaTest_PLACEHOLDER = _Float32TestMessage_vlaTest_PLACEHOLDER() +Float32TestMessage_optTest_PLACEHOLDER = _Float32TestMessage_optTest_PLACEHOLDER() + + +@dataclass(kw_only=True) +class Float32TestMessage: + test: float | _Float32TestMessage_test_PLACEHOLDER = Float32TestMessage_test_PLACEHOLDER + vlaTest: list[float] | _Float32TestMessage_vlaTest_PLACEHOLDER = Float32TestMessage_vlaTest_PLACEHOLDER + optTest: Optional[float] | _Float32TestMessage_optTest_PLACEHOLDER = Float32TestMessage_optTest_PLACEHOLDER + photonStruct: ClassVar[Float32TestMessageSerde] \ No newline at end of file diff --git a/photon-serde-tests/py/Float32TestMessageSerde.py b/photon-serde-tests/py/messages/Float32TestMessageSerde.py similarity index 97% rename from photon-serde-tests/py/Float32TestMessageSerde.py rename to photon-serde-tests/py/messages/Float32TestMessageSerde.py index 73c8e596e2..ea9fd24ffa 100644 --- a/photon-serde-tests/py/Float32TestMessageSerde.py +++ b/photon-serde-tests/py/messages/Float32TestMessageSerde.py @@ -36,7 +36,7 @@ if TYPE_CHECKING: - from ...targeting import Float32TestMessage # noqa + from .Float32TestMessage import Float32TestMessage # noqa class Float32TestMessageSerde: diff --git a/photon-serde-tests/py/messages/Float64TestMessage.py b/photon-serde-tests/py/messages/Float64TestMessage.py new file mode 100644 index 0000000000..25686a160b --- /dev/null +++ b/photon-serde-tests/py/messages/Float64TestMessage.py @@ -0,0 +1,75 @@ +# +# MIT License +# +# Copyright (c) PhotonVision +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +############################################################################### +## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. +## --> DO NOT MODIFY <-- +############################################################################### + +from typing import TYPE_CHECKING, Optional, ClassVar +from dataclasses import dataclass + +from photonlib.packet import Packet +from photonlib.targeting import * # noqa + +from .Float64TestMessageSerde import Float64TestMessageSerde # noqa + + + + +class _Float64TestMessage_test_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _Float64TestMessage_test_PLACEHOLDER) + +class _Float64TestMessage_vlaTest_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _Float64TestMessage_vlaTest_PLACEHOLDER) + +class _Float64TestMessage_optTest_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _Float64TestMessage_optTest_PLACEHOLDER) + +Float64TestMessage_test_PLACEHOLDER = _Float64TestMessage_test_PLACEHOLDER() +Float64TestMessage_vlaTest_PLACEHOLDER = _Float64TestMessage_vlaTest_PLACEHOLDER() +Float64TestMessage_optTest_PLACEHOLDER = _Float64TestMessage_optTest_PLACEHOLDER() + + +@dataclass(kw_only=True) +class Float64TestMessage: + test: float | _Float64TestMessage_test_PLACEHOLDER = Float64TestMessage_test_PLACEHOLDER + vlaTest: list[float] | _Float64TestMessage_vlaTest_PLACEHOLDER = Float64TestMessage_vlaTest_PLACEHOLDER + optTest: Optional[float] | _Float64TestMessage_optTest_PLACEHOLDER = Float64TestMessage_optTest_PLACEHOLDER + photonStruct: ClassVar[Float64TestMessageSerde] \ No newline at end of file diff --git a/photon-serde-tests/py/Float64TestMessageSerde.py b/photon-serde-tests/py/messages/Float64TestMessageSerde.py similarity index 97% rename from photon-serde-tests/py/Float64TestMessageSerde.py rename to photon-serde-tests/py/messages/Float64TestMessageSerde.py index 169727bdea..2261bedf8b 100644 --- a/photon-serde-tests/py/Float64TestMessageSerde.py +++ b/photon-serde-tests/py/messages/Float64TestMessageSerde.py @@ -36,7 +36,7 @@ if TYPE_CHECKING: - from ...targeting import Float64TestMessage # noqa + from .Float64TestMessage import Float64TestMessage # noqa class Float64TestMessageSerde: diff --git a/photon-serde-tests/py/Int16TestMessage.py b/photon-serde-tests/py/messages/Int16TestMessage.py similarity index 51% rename from photon-serde-tests/py/Int16TestMessage.py rename to photon-serde-tests/py/messages/Int16TestMessage.py index 96e541ab75..aa5fe7cfbf 100644 --- a/photon-serde-tests/py/Int16TestMessage.py +++ b/photon-serde-tests/py/messages/Int16TestMessage.py @@ -27,16 +27,49 @@ ## --> DO NOT MODIFY <-- ############################################################################### -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING, Optional, ClassVar from dataclasses import dataclass from photonlib.packet import Packet from photonlib.targeting import * # noqa +from .Int16TestMessageSerde import Int16TestMessageSerde # noqa -@dataclass + + +class _Int16TestMessage_test_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _Int16TestMessage_test_PLACEHOLDER) + +class _Int16TestMessage_vlaTest_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _Int16TestMessage_vlaTest_PLACEHOLDER) + +class _Int16TestMessage_optTest_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _Int16TestMessage_optTest_PLACEHOLDER) + +Int16TestMessage_test_PLACEHOLDER = _Int16TestMessage_test_PLACEHOLDER() +Int16TestMessage_vlaTest_PLACEHOLDER = _Int16TestMessage_vlaTest_PLACEHOLDER() +Int16TestMessage_optTest_PLACEHOLDER = _Int16TestMessage_optTest_PLACEHOLDER() + + +@dataclass(kw_only=True) class Int16TestMessage: - test: int - vlaTest: list[int] - optTest: Optional[int] \ No newline at end of file + test: int | _Int16TestMessage_test_PLACEHOLDER = Int16TestMessage_test_PLACEHOLDER + vlaTest: list[int] | _Int16TestMessage_vlaTest_PLACEHOLDER = Int16TestMessage_vlaTest_PLACEHOLDER + optTest: Optional[int] | _Int16TestMessage_optTest_PLACEHOLDER = Int16TestMessage_optTest_PLACEHOLDER + photonStruct: ClassVar[Int16TestMessageSerde] \ No newline at end of file diff --git a/photon-serde-tests/py/Int16TestMessageSerde.py b/photon-serde-tests/py/messages/Int16TestMessageSerde.py similarity index 97% rename from photon-serde-tests/py/Int16TestMessageSerde.py rename to photon-serde-tests/py/messages/Int16TestMessageSerde.py index 4cba3831bb..3810956a04 100644 --- a/photon-serde-tests/py/Int16TestMessageSerde.py +++ b/photon-serde-tests/py/messages/Int16TestMessageSerde.py @@ -36,7 +36,7 @@ if TYPE_CHECKING: - from ...targeting import Int16TestMessage # noqa + from .Int16TestMessage import Int16TestMessage # noqa class Int16TestMessageSerde: diff --git a/photon-serde-tests/py/Int32TestMessage.py b/photon-serde-tests/py/messages/Int32TestMessage.py similarity index 51% rename from photon-serde-tests/py/Int32TestMessage.py rename to photon-serde-tests/py/messages/Int32TestMessage.py index 7ae8be1fcb..b9d074b7c1 100644 --- a/photon-serde-tests/py/Int32TestMessage.py +++ b/photon-serde-tests/py/messages/Int32TestMessage.py @@ -27,16 +27,49 @@ ## --> DO NOT MODIFY <-- ############################################################################### -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING, Optional, ClassVar from dataclasses import dataclass from photonlib.packet import Packet from photonlib.targeting import * # noqa +from .Int32TestMessageSerde import Int32TestMessageSerde # noqa -@dataclass + + +class _Int32TestMessage_test_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _Int32TestMessage_test_PLACEHOLDER) + +class _Int32TestMessage_vlaTest_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _Int32TestMessage_vlaTest_PLACEHOLDER) + +class _Int32TestMessage_optTest_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _Int32TestMessage_optTest_PLACEHOLDER) + +Int32TestMessage_test_PLACEHOLDER = _Int32TestMessage_test_PLACEHOLDER() +Int32TestMessage_vlaTest_PLACEHOLDER = _Int32TestMessage_vlaTest_PLACEHOLDER() +Int32TestMessage_optTest_PLACEHOLDER = _Int32TestMessage_optTest_PLACEHOLDER() + + +@dataclass(kw_only=True) class Int32TestMessage: - test: int - vlaTest: list[int] - optTest: Optional[int] \ No newline at end of file + test: int | _Int32TestMessage_test_PLACEHOLDER = Int32TestMessage_test_PLACEHOLDER + vlaTest: list[int] | _Int32TestMessage_vlaTest_PLACEHOLDER = Int32TestMessage_vlaTest_PLACEHOLDER + optTest: Optional[int] | _Int32TestMessage_optTest_PLACEHOLDER = Int32TestMessage_optTest_PLACEHOLDER + photonStruct: ClassVar[Int32TestMessageSerde] \ No newline at end of file diff --git a/photon-serde-tests/py/Int32TestMessageSerde.py b/photon-serde-tests/py/messages/Int32TestMessageSerde.py similarity index 97% rename from photon-serde-tests/py/Int32TestMessageSerde.py rename to photon-serde-tests/py/messages/Int32TestMessageSerde.py index cc8aef6aa0..4ae11470f7 100644 --- a/photon-serde-tests/py/Int32TestMessageSerde.py +++ b/photon-serde-tests/py/messages/Int32TestMessageSerde.py @@ -36,7 +36,7 @@ if TYPE_CHECKING: - from ...targeting import Int32TestMessage # noqa + from .Int32TestMessage import Int32TestMessage # noqa class Int32TestMessageSerde: diff --git a/photon-serde-tests/py/Int64TestMessage.py b/photon-serde-tests/py/messages/Int64TestMessage.py similarity index 51% rename from photon-serde-tests/py/Int64TestMessage.py rename to photon-serde-tests/py/messages/Int64TestMessage.py index 6d9daa7088..cbc8a6bee8 100644 --- a/photon-serde-tests/py/Int64TestMessage.py +++ b/photon-serde-tests/py/messages/Int64TestMessage.py @@ -27,16 +27,49 @@ ## --> DO NOT MODIFY <-- ############################################################################### -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING, Optional, ClassVar from dataclasses import dataclass from photonlib.packet import Packet from photonlib.targeting import * # noqa +from .Int64TestMessageSerde import Int64TestMessageSerde # noqa -@dataclass + + +class _Int64TestMessage_test_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _Int64TestMessage_test_PLACEHOLDER) + +class _Int64TestMessage_vlaTest_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _Int64TestMessage_vlaTest_PLACEHOLDER) + +class _Int64TestMessage_optTest_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _Int64TestMessage_optTest_PLACEHOLDER) + +Int64TestMessage_test_PLACEHOLDER = _Int64TestMessage_test_PLACEHOLDER() +Int64TestMessage_vlaTest_PLACEHOLDER = _Int64TestMessage_vlaTest_PLACEHOLDER() +Int64TestMessage_optTest_PLACEHOLDER = _Int64TestMessage_optTest_PLACEHOLDER() + + +@dataclass(kw_only=True) class Int64TestMessage: - test: int - vlaTest: list[int] - optTest: Optional[int] \ No newline at end of file + test: int | _Int64TestMessage_test_PLACEHOLDER = Int64TestMessage_test_PLACEHOLDER + vlaTest: list[int] | _Int64TestMessage_vlaTest_PLACEHOLDER = Int64TestMessage_vlaTest_PLACEHOLDER + optTest: Optional[int] | _Int64TestMessage_optTest_PLACEHOLDER = Int64TestMessage_optTest_PLACEHOLDER + photonStruct: ClassVar[Int64TestMessageSerde] \ No newline at end of file diff --git a/photon-serde-tests/py/Int64TestMessageSerde.py b/photon-serde-tests/py/messages/Int64TestMessageSerde.py similarity index 97% rename from photon-serde-tests/py/Int64TestMessageSerde.py rename to photon-serde-tests/py/messages/Int64TestMessageSerde.py index fb1673535d..9b465d6deb 100644 --- a/photon-serde-tests/py/Int64TestMessageSerde.py +++ b/photon-serde-tests/py/messages/Int64TestMessageSerde.py @@ -36,7 +36,7 @@ if TYPE_CHECKING: - from ...targeting import Int64TestMessage # noqa + from .Int64TestMessage import Int64TestMessage # noqa class Int64TestMessageSerde: diff --git a/photon-serde-tests/py/Float64TestMessage.py b/photon-serde-tests/py/messages/Int8TestMessage.py similarity index 51% rename from photon-serde-tests/py/Float64TestMessage.py rename to photon-serde-tests/py/messages/Int8TestMessage.py index e84fa592e1..477ee61124 100644 --- a/photon-serde-tests/py/Float64TestMessage.py +++ b/photon-serde-tests/py/messages/Int8TestMessage.py @@ -27,16 +27,49 @@ ## --> DO NOT MODIFY <-- ############################################################################### -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING, Optional, ClassVar from dataclasses import dataclass from photonlib.packet import Packet from photonlib.targeting import * # noqa +from .Int8TestMessageSerde import Int8TestMessageSerde # noqa -@dataclass -class Float64TestMessage: - test: float - vlaTest: list[float] - optTest: Optional[float] \ No newline at end of file + + +class _Int8TestMessage_test_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _Int8TestMessage_test_PLACEHOLDER) + +class _Int8TestMessage_vlaTest_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _Int8TestMessage_vlaTest_PLACEHOLDER) + +class _Int8TestMessage_optTest_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _Int8TestMessage_optTest_PLACEHOLDER) + +Int8TestMessage_test_PLACEHOLDER = _Int8TestMessage_test_PLACEHOLDER() +Int8TestMessage_vlaTest_PLACEHOLDER = _Int8TestMessage_vlaTest_PLACEHOLDER() +Int8TestMessage_optTest_PLACEHOLDER = _Int8TestMessage_optTest_PLACEHOLDER() + + +@dataclass(kw_only=True) +class Int8TestMessage: + test: int | _Int8TestMessage_test_PLACEHOLDER = Int8TestMessage_test_PLACEHOLDER + vlaTest: list[int] | _Int8TestMessage_vlaTest_PLACEHOLDER = Int8TestMessage_vlaTest_PLACEHOLDER + optTest: Optional[int] | _Int8TestMessage_optTest_PLACEHOLDER = Int8TestMessage_optTest_PLACEHOLDER + photonStruct: ClassVar[Int8TestMessageSerde] \ No newline at end of file diff --git a/photon-serde-tests/py/Int8TestMessageSerde.py b/photon-serde-tests/py/messages/Int8TestMessageSerde.py similarity index 97% rename from photon-serde-tests/py/Int8TestMessageSerde.py rename to photon-serde-tests/py/messages/Int8TestMessageSerde.py index ce4dc130b7..b207aa4a01 100644 --- a/photon-serde-tests/py/Int8TestMessageSerde.py +++ b/photon-serde-tests/py/messages/Int8TestMessageSerde.py @@ -36,7 +36,7 @@ if TYPE_CHECKING: - from ...targeting import Int8TestMessage # noqa + from .Int8TestMessage import Int8TestMessage # noqa class Int8TestMessageSerde: diff --git a/photon-serde-tests/py/messages/Transform3dTestMessage.py b/photon-serde-tests/py/messages/Transform3dTestMessage.py new file mode 100644 index 0000000000..f917da81df --- /dev/null +++ b/photon-serde-tests/py/messages/Transform3dTestMessage.py @@ -0,0 +1,75 @@ +# +# MIT License +# +# Copyright (c) PhotonVision +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +############################################################################### +## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. +## --> DO NOT MODIFY <-- +############################################################################### + +from typing import TYPE_CHECKING, Optional, ClassVar +from dataclasses import dataclass + +from photonlib.packet import Packet +from photonlib.targeting import * # noqa + +from .Transform3dTestMessageSerde import Transform3dTestMessageSerde # noqa + +from wpimath.geometry import Transform3d + + +class _Transform3dTestMessage_test_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _Transform3dTestMessage_test_PLACEHOLDER) + +class _Transform3dTestMessage_vlaTest_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _Transform3dTestMessage_vlaTest_PLACEHOLDER) + +class _Transform3dTestMessage_optTest_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _Transform3dTestMessage_optTest_PLACEHOLDER) + +Transform3dTestMessage_test_PLACEHOLDER = _Transform3dTestMessage_test_PLACEHOLDER() +Transform3dTestMessage_vlaTest_PLACEHOLDER = _Transform3dTestMessage_vlaTest_PLACEHOLDER() +Transform3dTestMessage_optTest_PLACEHOLDER = _Transform3dTestMessage_optTest_PLACEHOLDER() + + +@dataclass(kw_only=True) +class Transform3dTestMessage: + test: Transform3d | _Transform3dTestMessage_test_PLACEHOLDER = Transform3dTestMessage_test_PLACEHOLDER + vlaTest: list[Transform3d] | _Transform3dTestMessage_vlaTest_PLACEHOLDER = Transform3dTestMessage_vlaTest_PLACEHOLDER + optTest: Optional[Transform3d] | _Transform3dTestMessage_optTest_PLACEHOLDER = Transform3dTestMessage_optTest_PLACEHOLDER + photonStruct: ClassVar[Transform3dTestMessageSerde] \ No newline at end of file diff --git a/photon-serde-tests/py/Transform3dTestMessageSerde.py b/photon-serde-tests/py/messages/Transform3dTestMessageSerde.py similarity index 97% rename from photon-serde-tests/py/Transform3dTestMessageSerde.py rename to photon-serde-tests/py/messages/Transform3dTestMessageSerde.py index 8be7b35cbe..8a9a39e04a 100644 --- a/photon-serde-tests/py/Transform3dTestMessageSerde.py +++ b/photon-serde-tests/py/messages/Transform3dTestMessageSerde.py @@ -36,7 +36,7 @@ if TYPE_CHECKING: - from ...targeting import Transform3dTestMessage # noqa + from .Transform3dTestMessage import Transform3dTestMessage # noqa class Transform3dTestMessageSerde: diff --git a/photon-serde-tests/py/Float32TestMessage.py b/photon-serde-tests/py/messages/__init__.py similarity index 56% rename from photon-serde-tests/py/Float32TestMessage.py rename to photon-serde-tests/py/messages/__init__.py index cc72b080f1..cf41b304c3 100644 --- a/photon-serde-tests/py/Float32TestMessage.py +++ b/photon-serde-tests/py/messages/__init__.py @@ -22,21 +22,32 @@ # SOFTWARE. # -############################################################################### -## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. -## --> DO NOT MODIFY <-- -############################################################################### +from .Int8TestMessage import Int8TestMessage +from .Int16TestMessage import Int16TestMessage +from .Int32TestMessage import Int32TestMessage +from .Int64TestMessage import Int64TestMessage +from .Float32TestMessage import Float32TestMessage +from .Float64TestMessage import Float64TestMessage +from .BoolTestMessage import BoolTestMessage +from .Transform3dTestMessage import Transform3dTestMessage -from typing import TYPE_CHECKING, Optional -from dataclasses import dataclass -from photonlib.packet import Packet -from photonlib.targeting import * # noqa - - - -@dataclass -class Float32TestMessage: - test: float - vlaTest: list[float] - optTest: Optional[float] \ No newline at end of file +__all__ = ( + "Int8TestMessage", + "Int8TestMessageSerde", + "Int16TestMessage", + "Int16TestMessageSerde", + "Int32TestMessage", + "Int32TestMessageSerde", + "Int64TestMessage", + "Int64TestMessageSerde", + "Float32TestMessage", + "Float32TestMessageSerde", + "Float64TestMessage", + "Float64TestMessageSerde", + "BoolTestMessage", + "BoolTestMessageSerde", + "Transform3dTestMessage", + "Transform3dTestMessageSerde", + +) \ No newline at end of file diff --git a/photon-serde-tests/requirements.txt b/photon-serde-tests/requirements.txt new file mode 100644 index 0000000000..208bf69c9f --- /dev/null +++ b/photon-serde-tests/requirements.txt @@ -0,0 +1 @@ +robotpy-wpimath>=2027.0.0a6 \ No newline at end of file diff --git a/photon-serde/generate_messages.py b/photon-serde/generate_messages.py index 46abf3ea4c..39064452d2 100644 --- a/photon-serde/generate_messages.py +++ b/photon-serde/generate_messages.py @@ -439,10 +439,10 @@ def generate_tests(cpp_java_test_root, py_test_root, template_root): ) cpp_test_struct_output_dir.mkdir(parents=True, exist_ok=True) - py_serde_source_dir = Path(py_test_root) + py_serde_source_dir = Path(py_test_root) / "messages" py_serde_source_dir.mkdir(parents=True, exist_ok=True) - python_test_dataclass_output_dir = Path(py_test_root) + python_test_dataclass_output_dir = Path(py_test_root) / "messages" env.filters["get_cpp_qualified_name"] = lambda field: get_cpp_qualified_name( message_db, extended_data_types, field @@ -548,6 +548,12 @@ def generate_tests(cpp_java_test_root, py_test_root, template_root): encoding="utf-8", ) + # Generate python messages __init__.py file + pyinit_template = env.get_template("PyInit.py.jinja") + pyinit_target = py_serde_source_dir / "__init__.py" + types = [message["name"] for message in test_messages] + pyinit_target.write_text(pyinit_template.render(types=types), encoding="utf-8") + # Generate test fixtures (WIP) tests = parse_yaml("tests.yaml") java_test_target = ( @@ -556,13 +562,16 @@ def generate_tests(cpp_java_test_root, py_test_root, template_root): java_test_target.parent.mkdir(parents=True, exist_ok=True) cpp_test_target = Path(cpp_java_test_root) / "test/native/cpp/AutoSerdeTest.cpp" cpp_test_target.parent.mkdir(parents=True, exist_ok=True) - Path(py_test_root) / "AutoSerdeTest.py" + py_test_target = Path(py_test_root) / "AutoSerdeTest.py" + py_test_target.parent.mkdir(parents=True, exist_ok=True) java_test_template = env.get_template("ThingTests.java.jinja") cpp_test_template = env.get_template("ThingTests.cpp.jinja") + py_test_template = env.get_template("ThingTests.py.jinja") java_test_target.write_text(java_test_template.render(tests)) cpp_test_target.write_text(cpp_test_template.render(tests)) + py_test_target.write_text(py_test_template.render(tests)) def main(argv): diff --git a/photon-serde/requirements.txt b/photon-serde/requirements.txt deleted file mode 100644 index 454abc7a97..0000000000 --- a/photon-serde/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -yaml -jinja2 diff --git a/photon-serde-tests/py/Int8TestMessage.py b/photon-serde/templates/PyInit.py.jinja similarity index 67% rename from photon-serde-tests/py/Int8TestMessage.py rename to photon-serde/templates/PyInit.py.jinja index 03aeb409b0..98d30a1b8d 100644 --- a/photon-serde-tests/py/Int8TestMessage.py +++ b/photon-serde/templates/PyInit.py.jinja @@ -22,21 +22,13 @@ # SOFTWARE. # -############################################################################### -## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. -## --> DO NOT MODIFY <-- -############################################################################### +{% for type in types -%} +from .{{ type }} import {{ type }} +{% endfor%} -from typing import TYPE_CHECKING, Optional -from dataclasses import dataclass - -from photonlib.packet import Packet -from photonlib.targeting import * # noqa - - - -@dataclass -class Int8TestMessage: - test: int - vlaTest: list[int] - optTest: Optional[int] \ No newline at end of file +__all__ = ( + {% for type in types -%} + "{{ type }}", + "{{ type }}Serde", + {% endfor%} +) \ No newline at end of file diff --git a/photon-serde/templates/ThingSerde.py.jinja b/photon-serde/templates/ThingSerde.py.jinja index 3a266ec36a..066feb63e9 100644 --- a/photon-serde/templates/ThingSerde.py.jinja +++ b/photon-serde/templates/ThingSerde.py.jinja @@ -47,7 +47,7 @@ if TYPE_CHECKING: {%- for type in ns.types|sort%} {%- if not type | is_shimmed and not type | is_intrinsic %} {%- if test %} - from ...targeting import {{ type }} # noqa + from .{{ type }} import {{ type }} # noqa {%- else %} from ..targeting import {{ type }} # noqa {% endif -%} diff --git a/photon-serde/templates/ThingTestDataclass.py.jinja b/photon-serde/templates/ThingTestDataclass.py.jinja index c7b6044061..4d7a83390a 100644 --- a/photon-serde/templates/ThingTestDataclass.py.jinja +++ b/photon-serde/templates/ThingTestDataclass.py.jinja @@ -27,21 +27,37 @@ ## --> DO NOT MODIFY <-- ############################################################################### -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING, Optional, ClassVar from dataclasses import dataclass from photonlib.packet import Packet from photonlib.targeting import * # noqa +from .{{ name }}Serde import {{ name }}Serde # noqa + {% for type in nested_wpilib_types -%} from {{ get_message_by_name(type).python_module }} import {{ type }} {%- if not loop.last %},{% endif -%} {%- endfor%} -@dataclass +{% for field in fields %} +class _{{ name }}_{{ field.name }}_PLACEHOLDER: + __slots__ = () + def __repr__(self): + return f"" + + def __eq__(self, other): + return isinstance(other, _{{ name }}_{{ field.name }}_PLACEHOLDER) +{% endfor %} +{% for field in fields -%} +{{ name }}_{{ field.name }}_PLACEHOLDER = _{{ name }}_{{ field.name }}_PLACEHOLDER() +{% endfor %} + +@dataclass(kw_only=True) class {{ name }}: {% for field in fields -%} - {{ field.name }}: {{ field | get_python_qualified_name }} + {{ field.name }}: {{ field | get_python_qualified_name }} | _{{ name }}_{{ field.name }}_PLACEHOLDER = {{ name }}_{{ field.name }}_PLACEHOLDER {%- if not loop.last %} {% endif -%} {%- endfor %} + photonStruct: ClassVar[{{ name }}Serde] diff --git a/photon-serde-tests/py/BoolTestMessage.py b/photon-serde/templates/ThingTests.py.jinja similarity index 66% rename from photon-serde-tests/py/BoolTestMessage.py rename to photon-serde/templates/ThingTests.py.jinja index 89a8391cb8..09eb73d8fe 100644 --- a/photon-serde-tests/py/BoolTestMessage.py +++ b/photon-serde/templates/ThingTests.py.jinja @@ -27,16 +27,29 @@ ## --> DO NOT MODIFY <-- ############################################################################### -from typing import TYPE_CHECKING, Optional -from dataclasses import dataclass - from photonlib.packet import Packet -from photonlib.targeting import * # noqa +from photonlib.targeting import * +from .messages import * +{% for dep in python_imports -%} +{{ dep }}; +{% endfor %} +def AutoSerdeTest(data) -> bool: + packet = data.photonStruct.pack(data) + unpacked = data.photonStruct.unpack(packet) + print(f"Original: {data}") + print(f"Unpacked: {unpacked}") + return data == unpacked -@dataclass -class BoolTestMessage: - test: bool - vlaTest: list[bool] - optTest: Optional[bool] \ No newline at end of file +{% for test in tests %} +def test_{{ test.name }}(): + print("Running {{ test.name }}...") + {% for test_case in test.cases %} + {{ test_case.name }} = {{ test.type }}() + {% for field in test_case.fields -%} + {{ test_case.name }}.{{ field.name }} = {{ field.python_value }} + {% endfor -%} + assert AutoSerdeTest({{ test_case.name }}) + {% endfor %} +{% endfor %} \ No newline at end of file From 2d0b2958fe7bf8d4f13f27828ef0d0851a51b92c Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Fri, 29 May 2026 13:48:39 -0400 Subject: [PATCH 33/42] wpiformat my beloathed --- .github/workflows/python.yml | 4 ++-- photon-serde-tests/requirements.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index f592dfb481..899f66bf84 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -76,8 +76,8 @@ jobs: run: pytest --import-mode=importlib photon-lib/py/test/ - name: Run mypy type checking - run: mypy --show-column-numbers --config-file photon-lib/py/pyproject.toml photon-lib - + run: mypy --show-column-numbers --config-file photon-lib/py/pyproject.toml photon-lib + test-photonserde-py: needs: build-py runs-on: ubuntu-24.04 diff --git a/photon-serde-tests/requirements.txt b/photon-serde-tests/requirements.txt index 208bf69c9f..c85d1cd29f 100644 --- a/photon-serde-tests/requirements.txt +++ b/photon-serde-tests/requirements.txt @@ -1 +1 @@ -robotpy-wpimath>=2027.0.0a6 \ No newline at end of file +robotpy-wpimath>=2027.0.0a6 From a2dad4d2578be21140cf3b9812cdbccca11ad4cb Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Fri, 29 May 2026 13:52:08 -0400 Subject: [PATCH 34/42] fixedpython workflow file --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 899f66bf84..3251771bc5 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -113,7 +113,7 @@ jobs: - name: Run PhotonSerde tests shell: bash - run: pytest --import-mode=importlib photon-serde-tests/py + run: pytest --import-mode=importlib photon-serde-tests/py/AutoSerdeTest.py build-python-examples: needs: build-py From c3615553b78a6571946ed8279456904c201f343d Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Fri, 29 May 2026 13:55:12 -0400 Subject: [PATCH 35/42] chat will this fix it --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 3251771bc5..4ff33aa29a 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -113,7 +113,7 @@ jobs: - name: Run PhotonSerde tests shell: bash - run: pytest --import-mode=importlib photon-serde-tests/py/AutoSerdeTest.py + run: python -m pytest --import-mode=importlib photon-serde-tests/py/AutoSerdeTest.py build-python-examples: needs: build-py From 3474281cc237adeb13dbca0dab2b015132363b39 Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Fri, 29 May 2026 14:00:37 -0400 Subject: [PATCH 36/42] i may be stupid --- photon-serde-tests/py/AutoSerdeTest.py | 4 ++-- photon-serde-tests/py/messages/BoolTestMessage.py | 4 ++-- photon-serde-tests/py/messages/BoolTestMessageSerde.py | 4 ++-- photon-serde-tests/py/messages/Float32TestMessage.py | 4 ++-- photon-serde-tests/py/messages/Float32TestMessageSerde.py | 4 ++-- photon-serde-tests/py/messages/Float64TestMessage.py | 4 ++-- photon-serde-tests/py/messages/Float64TestMessageSerde.py | 4 ++-- photon-serde-tests/py/messages/Int16TestMessage.py | 4 ++-- photon-serde-tests/py/messages/Int16TestMessageSerde.py | 4 ++-- photon-serde-tests/py/messages/Int32TestMessage.py | 4 ++-- photon-serde-tests/py/messages/Int32TestMessageSerde.py | 4 ++-- photon-serde-tests/py/messages/Int64TestMessage.py | 4 ++-- photon-serde-tests/py/messages/Int64TestMessageSerde.py | 4 ++-- photon-serde-tests/py/messages/Int8TestMessage.py | 4 ++-- photon-serde-tests/py/messages/Int8TestMessageSerde.py | 4 ++-- photon-serde-tests/py/messages/Transform3dTestMessage.py | 4 ++-- photon-serde-tests/py/messages/Transform3dTestMessageSerde.py | 4 ++-- photon-serde/templates/ThingSerde.py.jinja | 4 ++-- photon-serde/templates/ThingTestDataclass.py.jinja | 4 ++-- photon-serde/templates/ThingTests.py.jinja | 4 ++-- 20 files changed, 40 insertions(+), 40 deletions(-) diff --git a/photon-serde-tests/py/AutoSerdeTest.py b/photon-serde-tests/py/AutoSerdeTest.py index ceba60661a..5076cfdd55 100644 --- a/photon-serde-tests/py/AutoSerdeTest.py +++ b/photon-serde-tests/py/AutoSerdeTest.py @@ -27,8 +27,8 @@ ## --> DO NOT MODIFY <-- ############################################################################### -from photonlib.packet import Packet -from photonlib.targeting import * +from photonlibpy.packet import Packet +from photonlibpy.targeting import * from .messages import * from wpimath import Rotation3d; diff --git a/photon-serde-tests/py/messages/BoolTestMessage.py b/photon-serde-tests/py/messages/BoolTestMessage.py index 1dec7e6b96..cd38d41e78 100644 --- a/photon-serde-tests/py/messages/BoolTestMessage.py +++ b/photon-serde-tests/py/messages/BoolTestMessage.py @@ -30,8 +30,8 @@ from typing import TYPE_CHECKING, Optional, ClassVar from dataclasses import dataclass -from photonlib.packet import Packet -from photonlib.targeting import * # noqa +from photonlibpy.packet import Packet +from photonlibpy.targeting import * # noqa from .BoolTestMessageSerde import BoolTestMessageSerde # noqa diff --git a/photon-serde-tests/py/messages/BoolTestMessageSerde.py b/photon-serde-tests/py/messages/BoolTestMessageSerde.py index f574844709..9848cd1614 100644 --- a/photon-serde-tests/py/messages/BoolTestMessageSerde.py +++ b/photon-serde-tests/py/messages/BoolTestMessageSerde.py @@ -30,8 +30,8 @@ from typing import TYPE_CHECKING -from photonlib.packet import Packet -from photonlib.targeting import * # noqa +from photonlibpy.packet import Packet +from photonlibpy.targeting import * # noqa diff --git a/photon-serde-tests/py/messages/Float32TestMessage.py b/photon-serde-tests/py/messages/Float32TestMessage.py index c3d3d3d6e8..8899dd631b 100644 --- a/photon-serde-tests/py/messages/Float32TestMessage.py +++ b/photon-serde-tests/py/messages/Float32TestMessage.py @@ -30,8 +30,8 @@ from typing import TYPE_CHECKING, Optional, ClassVar from dataclasses import dataclass -from photonlib.packet import Packet -from photonlib.targeting import * # noqa +from photonlibpy.packet import Packet +from photonlibpy.targeting import * # noqa from .Float32TestMessageSerde import Float32TestMessageSerde # noqa diff --git a/photon-serde-tests/py/messages/Float32TestMessageSerde.py b/photon-serde-tests/py/messages/Float32TestMessageSerde.py index ea9fd24ffa..8b00b5dab0 100644 --- a/photon-serde-tests/py/messages/Float32TestMessageSerde.py +++ b/photon-serde-tests/py/messages/Float32TestMessageSerde.py @@ -30,8 +30,8 @@ from typing import TYPE_CHECKING -from photonlib.packet import Packet -from photonlib.targeting import * # noqa +from photonlibpy.packet import Packet +from photonlibpy.targeting import * # noqa diff --git a/photon-serde-tests/py/messages/Float64TestMessage.py b/photon-serde-tests/py/messages/Float64TestMessage.py index 25686a160b..8e46f3ffd6 100644 --- a/photon-serde-tests/py/messages/Float64TestMessage.py +++ b/photon-serde-tests/py/messages/Float64TestMessage.py @@ -30,8 +30,8 @@ from typing import TYPE_CHECKING, Optional, ClassVar from dataclasses import dataclass -from photonlib.packet import Packet -from photonlib.targeting import * # noqa +from photonlibpy.packet import Packet +from photonlibpy.targeting import * # noqa from .Float64TestMessageSerde import Float64TestMessageSerde # noqa diff --git a/photon-serde-tests/py/messages/Float64TestMessageSerde.py b/photon-serde-tests/py/messages/Float64TestMessageSerde.py index 2261bedf8b..52664a64dd 100644 --- a/photon-serde-tests/py/messages/Float64TestMessageSerde.py +++ b/photon-serde-tests/py/messages/Float64TestMessageSerde.py @@ -30,8 +30,8 @@ from typing import TYPE_CHECKING -from photonlib.packet import Packet -from photonlib.targeting import * # noqa +from photonlibpy.packet import Packet +from photonlibpy.targeting import * # noqa diff --git a/photon-serde-tests/py/messages/Int16TestMessage.py b/photon-serde-tests/py/messages/Int16TestMessage.py index aa5fe7cfbf..103c21e4c4 100644 --- a/photon-serde-tests/py/messages/Int16TestMessage.py +++ b/photon-serde-tests/py/messages/Int16TestMessage.py @@ -30,8 +30,8 @@ from typing import TYPE_CHECKING, Optional, ClassVar from dataclasses import dataclass -from photonlib.packet import Packet -from photonlib.targeting import * # noqa +from photonlibpy.packet import Packet +from photonlibpy.targeting import * # noqa from .Int16TestMessageSerde import Int16TestMessageSerde # noqa diff --git a/photon-serde-tests/py/messages/Int16TestMessageSerde.py b/photon-serde-tests/py/messages/Int16TestMessageSerde.py index 3810956a04..43c6136dc3 100644 --- a/photon-serde-tests/py/messages/Int16TestMessageSerde.py +++ b/photon-serde-tests/py/messages/Int16TestMessageSerde.py @@ -30,8 +30,8 @@ from typing import TYPE_CHECKING -from photonlib.packet import Packet -from photonlib.targeting import * # noqa +from photonlibpy.packet import Packet +from photonlibpy.targeting import * # noqa diff --git a/photon-serde-tests/py/messages/Int32TestMessage.py b/photon-serde-tests/py/messages/Int32TestMessage.py index b9d074b7c1..8eebf0e063 100644 --- a/photon-serde-tests/py/messages/Int32TestMessage.py +++ b/photon-serde-tests/py/messages/Int32TestMessage.py @@ -30,8 +30,8 @@ from typing import TYPE_CHECKING, Optional, ClassVar from dataclasses import dataclass -from photonlib.packet import Packet -from photonlib.targeting import * # noqa +from photonlibpy.packet import Packet +from photonlibpy.targeting import * # noqa from .Int32TestMessageSerde import Int32TestMessageSerde # noqa diff --git a/photon-serde-tests/py/messages/Int32TestMessageSerde.py b/photon-serde-tests/py/messages/Int32TestMessageSerde.py index 4ae11470f7..5fc80e014b 100644 --- a/photon-serde-tests/py/messages/Int32TestMessageSerde.py +++ b/photon-serde-tests/py/messages/Int32TestMessageSerde.py @@ -30,8 +30,8 @@ from typing import TYPE_CHECKING -from photonlib.packet import Packet -from photonlib.targeting import * # noqa +from photonlibpy.packet import Packet +from photonlibpy.targeting import * # noqa diff --git a/photon-serde-tests/py/messages/Int64TestMessage.py b/photon-serde-tests/py/messages/Int64TestMessage.py index cbc8a6bee8..323c995068 100644 --- a/photon-serde-tests/py/messages/Int64TestMessage.py +++ b/photon-serde-tests/py/messages/Int64TestMessage.py @@ -30,8 +30,8 @@ from typing import TYPE_CHECKING, Optional, ClassVar from dataclasses import dataclass -from photonlib.packet import Packet -from photonlib.targeting import * # noqa +from photonlibpy.packet import Packet +from photonlibpy.targeting import * # noqa from .Int64TestMessageSerde import Int64TestMessageSerde # noqa diff --git a/photon-serde-tests/py/messages/Int64TestMessageSerde.py b/photon-serde-tests/py/messages/Int64TestMessageSerde.py index 9b465d6deb..a2960cc9cb 100644 --- a/photon-serde-tests/py/messages/Int64TestMessageSerde.py +++ b/photon-serde-tests/py/messages/Int64TestMessageSerde.py @@ -30,8 +30,8 @@ from typing import TYPE_CHECKING -from photonlib.packet import Packet -from photonlib.targeting import * # noqa +from photonlibpy.packet import Packet +from photonlibpy.targeting import * # noqa diff --git a/photon-serde-tests/py/messages/Int8TestMessage.py b/photon-serde-tests/py/messages/Int8TestMessage.py index 477ee61124..8c5bc5b9e8 100644 --- a/photon-serde-tests/py/messages/Int8TestMessage.py +++ b/photon-serde-tests/py/messages/Int8TestMessage.py @@ -30,8 +30,8 @@ from typing import TYPE_CHECKING, Optional, ClassVar from dataclasses import dataclass -from photonlib.packet import Packet -from photonlib.targeting import * # noqa +from photonlibpy.packet import Packet +from photonlibpy.targeting import * # noqa from .Int8TestMessageSerde import Int8TestMessageSerde # noqa diff --git a/photon-serde-tests/py/messages/Int8TestMessageSerde.py b/photon-serde-tests/py/messages/Int8TestMessageSerde.py index b207aa4a01..e9d80f2d70 100644 --- a/photon-serde-tests/py/messages/Int8TestMessageSerde.py +++ b/photon-serde-tests/py/messages/Int8TestMessageSerde.py @@ -30,8 +30,8 @@ from typing import TYPE_CHECKING -from photonlib.packet import Packet -from photonlib.targeting import * # noqa +from photonlibpy.packet import Packet +from photonlibpy.targeting import * # noqa diff --git a/photon-serde-tests/py/messages/Transform3dTestMessage.py b/photon-serde-tests/py/messages/Transform3dTestMessage.py index f917da81df..e1d137c21e 100644 --- a/photon-serde-tests/py/messages/Transform3dTestMessage.py +++ b/photon-serde-tests/py/messages/Transform3dTestMessage.py @@ -30,8 +30,8 @@ from typing import TYPE_CHECKING, Optional, ClassVar from dataclasses import dataclass -from photonlib.packet import Packet -from photonlib.targeting import * # noqa +from photonlibpy.packet import Packet +from photonlibpy.targeting import * # noqa from .Transform3dTestMessageSerde import Transform3dTestMessageSerde # noqa diff --git a/photon-serde-tests/py/messages/Transform3dTestMessageSerde.py b/photon-serde-tests/py/messages/Transform3dTestMessageSerde.py index 8a9a39e04a..130e0b8b5d 100644 --- a/photon-serde-tests/py/messages/Transform3dTestMessageSerde.py +++ b/photon-serde-tests/py/messages/Transform3dTestMessageSerde.py @@ -30,8 +30,8 @@ from typing import TYPE_CHECKING -from photonlib.packet import Packet -from photonlib.targeting import * # noqa +from photonlibpy.packet import Packet +from photonlibpy.targeting import * # noqa diff --git a/photon-serde/templates/ThingSerde.py.jinja b/photon-serde/templates/ThingSerde.py.jinja index 066feb63e9..109829e233 100644 --- a/photon-serde/templates/ThingSerde.py.jinja +++ b/photon-serde/templates/ThingSerde.py.jinja @@ -30,8 +30,8 @@ from typing import TYPE_CHECKING {% if test %} -from photonlib.packet import Packet -from photonlib.targeting import * # noqa +from photonlibpy.packet import Packet +from photonlibpy.targeting import * # noqa {% else %} from ..packet import Packet from ..targeting import * # noqa diff --git a/photon-serde/templates/ThingTestDataclass.py.jinja b/photon-serde/templates/ThingTestDataclass.py.jinja index 4d7a83390a..ca33922abe 100644 --- a/photon-serde/templates/ThingTestDataclass.py.jinja +++ b/photon-serde/templates/ThingTestDataclass.py.jinja @@ -30,8 +30,8 @@ from typing import TYPE_CHECKING, Optional, ClassVar from dataclasses import dataclass -from photonlib.packet import Packet -from photonlib.targeting import * # noqa +from photonlibpy.packet import Packet +from photonlibpy.targeting import * # noqa from .{{ name }}Serde import {{ name }}Serde # noqa diff --git a/photon-serde/templates/ThingTests.py.jinja b/photon-serde/templates/ThingTests.py.jinja index 09eb73d8fe..de7059a616 100644 --- a/photon-serde/templates/ThingTests.py.jinja +++ b/photon-serde/templates/ThingTests.py.jinja @@ -27,8 +27,8 @@ ## --> DO NOT MODIFY <-- ############################################################################### -from photonlib.packet import Packet -from photonlib.targeting import * +from photonlibpy.packet import Packet +from photonlibpy.targeting import * from .messages import * {% for dep in python_imports -%} From 534bc43397b55c325761cc457233000a57aad21c Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Fri, 29 May 2026 14:07:04 -0400 Subject: [PATCH 37/42] forgot to import the serdes in __init__.py --- photon-serde-tests/py/messages/__init__.py | 8 ++++++++ photon-serde/templates/PyInit.py.jinja | 1 + 2 files changed, 9 insertions(+) diff --git a/photon-serde-tests/py/messages/__init__.py b/photon-serde-tests/py/messages/__init__.py index cf41b304c3..81ded26c1e 100644 --- a/photon-serde-tests/py/messages/__init__.py +++ b/photon-serde-tests/py/messages/__init__.py @@ -23,13 +23,21 @@ # from .Int8TestMessage import Int8TestMessage +from .Int8TestMessageSerde import Int8TestMessageSerde from .Int16TestMessage import Int16TestMessage +from .Int16TestMessageSerde import Int16TestMessageSerde from .Int32TestMessage import Int32TestMessage +from .Int32TestMessageSerde import Int32TestMessageSerde from .Int64TestMessage import Int64TestMessage +from .Int64TestMessageSerde import Int64TestMessageSerde from .Float32TestMessage import Float32TestMessage +from .Float32TestMessageSerde import Float32TestMessageSerde from .Float64TestMessage import Float64TestMessage +from .Float64TestMessageSerde import Float64TestMessageSerde from .BoolTestMessage import BoolTestMessage +from .BoolTestMessageSerde import BoolTestMessageSerde from .Transform3dTestMessage import Transform3dTestMessage +from .Transform3dTestMessageSerde import Transform3dTestMessageSerde __all__ = ( diff --git a/photon-serde/templates/PyInit.py.jinja b/photon-serde/templates/PyInit.py.jinja index 98d30a1b8d..74a60c8cce 100644 --- a/photon-serde/templates/PyInit.py.jinja +++ b/photon-serde/templates/PyInit.py.jinja @@ -24,6 +24,7 @@ {% for type in types -%} from .{{ type }} import {{ type }} +from .{{ type }}Serde import {{ type }}Serde {% endfor%} __all__ = ( From 009faa0320c9ba7d2e71f21959099a0f393c994f Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Fri, 29 May 2026 14:27:59 -0400 Subject: [PATCH 38/42] removed unused imports and fixed circular dependencies --- photon-serde-tests/py/AutoSerdeTest.py | 6 +++--- .../py/messages/BoolTestMessage.py | 6 +++--- .../py/messages/Float32TestMessage.py | 6 +++--- .../py/messages/Float64TestMessage.py | 6 +++--- .../py/messages/Int16TestMessage.py | 6 +++--- .../py/messages/Int32TestMessage.py | 6 +++--- .../py/messages/Int64TestMessage.py | 6 +++--- .../py/messages/Int8TestMessage.py | 6 +++--- .../py/messages/Transform3dTestMessage.py | 6 +++--- photon-serde/generate_messages.py | 10 ++++++++++ photon-serde/templates/ThingSerde.py.jinja | 2 +- .../templates/ThingTestDataclass.py.jinja | 19 ++++++++++++++++--- photon-serde/templates/ThingTests.py.jinja | 2 +- 13 files changed, 55 insertions(+), 32 deletions(-) diff --git a/photon-serde-tests/py/AutoSerdeTest.py b/photon-serde-tests/py/AutoSerdeTest.py index 5076cfdd55..f49cbb0322 100644 --- a/photon-serde-tests/py/AutoSerdeTest.py +++ b/photon-serde-tests/py/AutoSerdeTest.py @@ -31,9 +31,9 @@ from photonlibpy.targeting import * from .messages import * -from wpimath import Rotation3d; -from wpimath import Translation3d; -from wpimath import Transform3d; +from wpimath import Rotation3d +from wpimath import Translation3d +from wpimath import Transform3d def AutoSerdeTest(data) -> bool: diff --git a/photon-serde-tests/py/messages/BoolTestMessage.py b/photon-serde-tests/py/messages/BoolTestMessage.py index cd38d41e78..0cd670b4d6 100644 --- a/photon-serde-tests/py/messages/BoolTestMessage.py +++ b/photon-serde-tests/py/messages/BoolTestMessage.py @@ -30,10 +30,10 @@ from typing import TYPE_CHECKING, Optional, ClassVar from dataclasses import dataclass -from photonlibpy.packet import Packet from photonlibpy.targeting import * # noqa -from .BoolTestMessageSerde import BoolTestMessageSerde # noqa +if TYPE_CHECKING: + from .BoolTestMessageSerde import BoolTestMessageSerde # noqa @@ -72,4 +72,4 @@ class BoolTestMessage: test: bool | _BoolTestMessage_test_PLACEHOLDER = BoolTestMessage_test_PLACEHOLDER vlaTest: list[bool] | _BoolTestMessage_vlaTest_PLACEHOLDER = BoolTestMessage_vlaTest_PLACEHOLDER optTest: Optional[bool] | _BoolTestMessage_optTest_PLACEHOLDER = BoolTestMessage_optTest_PLACEHOLDER - photonStruct: ClassVar[BoolTestMessageSerde] \ No newline at end of file + photonStruct: ClassVar["BoolTestMessageSerde"] \ No newline at end of file diff --git a/photon-serde-tests/py/messages/Float32TestMessage.py b/photon-serde-tests/py/messages/Float32TestMessage.py index 8899dd631b..71db6364ae 100644 --- a/photon-serde-tests/py/messages/Float32TestMessage.py +++ b/photon-serde-tests/py/messages/Float32TestMessage.py @@ -30,10 +30,10 @@ from typing import TYPE_CHECKING, Optional, ClassVar from dataclasses import dataclass -from photonlibpy.packet import Packet from photonlibpy.targeting import * # noqa -from .Float32TestMessageSerde import Float32TestMessageSerde # noqa +if TYPE_CHECKING: + from .Float32TestMessageSerde import Float32TestMessageSerde # noqa @@ -72,4 +72,4 @@ class Float32TestMessage: test: float | _Float32TestMessage_test_PLACEHOLDER = Float32TestMessage_test_PLACEHOLDER vlaTest: list[float] | _Float32TestMessage_vlaTest_PLACEHOLDER = Float32TestMessage_vlaTest_PLACEHOLDER optTest: Optional[float] | _Float32TestMessage_optTest_PLACEHOLDER = Float32TestMessage_optTest_PLACEHOLDER - photonStruct: ClassVar[Float32TestMessageSerde] \ No newline at end of file + photonStruct: ClassVar["Float32TestMessageSerde"] \ No newline at end of file diff --git a/photon-serde-tests/py/messages/Float64TestMessage.py b/photon-serde-tests/py/messages/Float64TestMessage.py index 8e46f3ffd6..d0af8601da 100644 --- a/photon-serde-tests/py/messages/Float64TestMessage.py +++ b/photon-serde-tests/py/messages/Float64TestMessage.py @@ -30,10 +30,10 @@ from typing import TYPE_CHECKING, Optional, ClassVar from dataclasses import dataclass -from photonlibpy.packet import Packet from photonlibpy.targeting import * # noqa -from .Float64TestMessageSerde import Float64TestMessageSerde # noqa +if TYPE_CHECKING: + from .Float64TestMessageSerde import Float64TestMessageSerde # noqa @@ -72,4 +72,4 @@ class Float64TestMessage: test: float | _Float64TestMessage_test_PLACEHOLDER = Float64TestMessage_test_PLACEHOLDER vlaTest: list[float] | _Float64TestMessage_vlaTest_PLACEHOLDER = Float64TestMessage_vlaTest_PLACEHOLDER optTest: Optional[float] | _Float64TestMessage_optTest_PLACEHOLDER = Float64TestMessage_optTest_PLACEHOLDER - photonStruct: ClassVar[Float64TestMessageSerde] \ No newline at end of file + photonStruct: ClassVar["Float64TestMessageSerde"] \ No newline at end of file diff --git a/photon-serde-tests/py/messages/Int16TestMessage.py b/photon-serde-tests/py/messages/Int16TestMessage.py index 103c21e4c4..47d23211ef 100644 --- a/photon-serde-tests/py/messages/Int16TestMessage.py +++ b/photon-serde-tests/py/messages/Int16TestMessage.py @@ -30,10 +30,10 @@ from typing import TYPE_CHECKING, Optional, ClassVar from dataclasses import dataclass -from photonlibpy.packet import Packet from photonlibpy.targeting import * # noqa -from .Int16TestMessageSerde import Int16TestMessageSerde # noqa +if TYPE_CHECKING: + from .Int16TestMessageSerde import Int16TestMessageSerde # noqa @@ -72,4 +72,4 @@ class Int16TestMessage: test: int | _Int16TestMessage_test_PLACEHOLDER = Int16TestMessage_test_PLACEHOLDER vlaTest: list[int] | _Int16TestMessage_vlaTest_PLACEHOLDER = Int16TestMessage_vlaTest_PLACEHOLDER optTest: Optional[int] | _Int16TestMessage_optTest_PLACEHOLDER = Int16TestMessage_optTest_PLACEHOLDER - photonStruct: ClassVar[Int16TestMessageSerde] \ No newline at end of file + photonStruct: ClassVar["Int16TestMessageSerde"] \ No newline at end of file diff --git a/photon-serde-tests/py/messages/Int32TestMessage.py b/photon-serde-tests/py/messages/Int32TestMessage.py index 8eebf0e063..42273b0324 100644 --- a/photon-serde-tests/py/messages/Int32TestMessage.py +++ b/photon-serde-tests/py/messages/Int32TestMessage.py @@ -30,10 +30,10 @@ from typing import TYPE_CHECKING, Optional, ClassVar from dataclasses import dataclass -from photonlibpy.packet import Packet from photonlibpy.targeting import * # noqa -from .Int32TestMessageSerde import Int32TestMessageSerde # noqa +if TYPE_CHECKING: + from .Int32TestMessageSerde import Int32TestMessageSerde # noqa @@ -72,4 +72,4 @@ class Int32TestMessage: test: int | _Int32TestMessage_test_PLACEHOLDER = Int32TestMessage_test_PLACEHOLDER vlaTest: list[int] | _Int32TestMessage_vlaTest_PLACEHOLDER = Int32TestMessage_vlaTest_PLACEHOLDER optTest: Optional[int] | _Int32TestMessage_optTest_PLACEHOLDER = Int32TestMessage_optTest_PLACEHOLDER - photonStruct: ClassVar[Int32TestMessageSerde] \ No newline at end of file + photonStruct: ClassVar["Int32TestMessageSerde"] \ No newline at end of file diff --git a/photon-serde-tests/py/messages/Int64TestMessage.py b/photon-serde-tests/py/messages/Int64TestMessage.py index 323c995068..38ece2e881 100644 --- a/photon-serde-tests/py/messages/Int64TestMessage.py +++ b/photon-serde-tests/py/messages/Int64TestMessage.py @@ -30,10 +30,10 @@ from typing import TYPE_CHECKING, Optional, ClassVar from dataclasses import dataclass -from photonlibpy.packet import Packet from photonlibpy.targeting import * # noqa -from .Int64TestMessageSerde import Int64TestMessageSerde # noqa +if TYPE_CHECKING: + from .Int64TestMessageSerde import Int64TestMessageSerde # noqa @@ -72,4 +72,4 @@ class Int64TestMessage: test: int | _Int64TestMessage_test_PLACEHOLDER = Int64TestMessage_test_PLACEHOLDER vlaTest: list[int] | _Int64TestMessage_vlaTest_PLACEHOLDER = Int64TestMessage_vlaTest_PLACEHOLDER optTest: Optional[int] | _Int64TestMessage_optTest_PLACEHOLDER = Int64TestMessage_optTest_PLACEHOLDER - photonStruct: ClassVar[Int64TestMessageSerde] \ No newline at end of file + photonStruct: ClassVar["Int64TestMessageSerde"] \ No newline at end of file diff --git a/photon-serde-tests/py/messages/Int8TestMessage.py b/photon-serde-tests/py/messages/Int8TestMessage.py index 8c5bc5b9e8..e0789b711b 100644 --- a/photon-serde-tests/py/messages/Int8TestMessage.py +++ b/photon-serde-tests/py/messages/Int8TestMessage.py @@ -30,10 +30,10 @@ from typing import TYPE_CHECKING, Optional, ClassVar from dataclasses import dataclass -from photonlibpy.packet import Packet from photonlibpy.targeting import * # noqa -from .Int8TestMessageSerde import Int8TestMessageSerde # noqa +if TYPE_CHECKING: + from .Int8TestMessageSerde import Int8TestMessageSerde # noqa @@ -72,4 +72,4 @@ class Int8TestMessage: test: int | _Int8TestMessage_test_PLACEHOLDER = Int8TestMessage_test_PLACEHOLDER vlaTest: list[int] | _Int8TestMessage_vlaTest_PLACEHOLDER = Int8TestMessage_vlaTest_PLACEHOLDER optTest: Optional[int] | _Int8TestMessage_optTest_PLACEHOLDER = Int8TestMessage_optTest_PLACEHOLDER - photonStruct: ClassVar[Int8TestMessageSerde] \ No newline at end of file + photonStruct: ClassVar["Int8TestMessageSerde"] \ No newline at end of file diff --git a/photon-serde-tests/py/messages/Transform3dTestMessage.py b/photon-serde-tests/py/messages/Transform3dTestMessage.py index e1d137c21e..010cbc2004 100644 --- a/photon-serde-tests/py/messages/Transform3dTestMessage.py +++ b/photon-serde-tests/py/messages/Transform3dTestMessage.py @@ -30,10 +30,10 @@ from typing import TYPE_CHECKING, Optional, ClassVar from dataclasses import dataclass -from photonlibpy.packet import Packet from photonlibpy.targeting import * # noqa -from .Transform3dTestMessageSerde import Transform3dTestMessageSerde # noqa +if TYPE_CHECKING: + from .Transform3dTestMessageSerde import Transform3dTestMessageSerde # noqa from wpimath.geometry import Transform3d @@ -72,4 +72,4 @@ class Transform3dTestMessage: test: Transform3d | _Transform3dTestMessage_test_PLACEHOLDER = Transform3dTestMessage_test_PLACEHOLDER vlaTest: list[Transform3d] | _Transform3dTestMessage_vlaTest_PLACEHOLDER = Transform3dTestMessage_vlaTest_PLACEHOLDER optTest: Optional[Transform3d] | _Transform3dTestMessage_optTest_PLACEHOLDER = Transform3dTestMessage_optTest_PLACEHOLDER - photonStruct: ClassVar[Transform3dTestMessageSerde] \ No newline at end of file + photonStruct: ClassVar["Transform3dTestMessageSerde"] \ No newline at end of file diff --git a/photon-serde/generate_messages.py b/photon-serde/generate_messages.py index 39064452d2..b87dff4b24 100644 --- a/photon-serde/generate_messages.py +++ b/photon-serde/generate_messages.py @@ -88,6 +88,14 @@ def is_shimmed(message_name: str): return is_shimmed +# Deal with test types +def get_test_filter(message_db): + def is_test(message_name: str): + message = get_message_by_name(message_db, message_name) + return "test" in message and message["test"] == True + + return is_test + def get_cpp_qualified_name( message_db: List[MessageType], data_types, field: SerdeField @@ -276,6 +284,7 @@ def generate_photon_messages(cpp_java_root, py_root, template_root): env.filters["is_intrinsic"] = is_intrinsic_type env.filters["is_shimmed"] = get_shimmed_filter(messages) + env.filters["is_test"] = lambda _x: False # no test messages in this pass # add our custom types extended_data_types = data_types.copy() @@ -404,6 +413,7 @@ def generate_tests(cpp_java_test_root, py_test_root, template_root): env.filters["is_intrinsic"] = is_intrinsic_type env.filters["is_shimmed"] = get_shimmed_filter(message_db) + env.filters["is_test"] = get_test_filter(message_db) # add our custom types extended_data_types = data_types.copy() diff --git a/photon-serde/templates/ThingSerde.py.jinja b/photon-serde/templates/ThingSerde.py.jinja index 109829e233..25dd5d3c2b 100644 --- a/photon-serde/templates/ThingSerde.py.jinja +++ b/photon-serde/templates/ThingSerde.py.jinja @@ -46,7 +46,7 @@ if TYPE_CHECKING: {% set _ = ns.types.append(name) -%} {%- for type in ns.types|sort%} {%- if not type | is_shimmed and not type | is_intrinsic %} -{%- if test %} +{%- if type | is_test %} from .{{ type }} import {{ type }} # noqa {%- else %} from ..targeting import {{ type }} # noqa diff --git a/photon-serde/templates/ThingTestDataclass.py.jinja b/photon-serde/templates/ThingTestDataclass.py.jinja index ca33922abe..cca03b88ac 100644 --- a/photon-serde/templates/ThingTestDataclass.py.jinja +++ b/photon-serde/templates/ThingTestDataclass.py.jinja @@ -30,10 +30,23 @@ from typing import TYPE_CHECKING, Optional, ClassVar from dataclasses import dataclass -from photonlibpy.packet import Packet from photonlibpy.targeting import * # noqa -from .{{ name }}Serde import {{ name }}Serde # noqa +if TYPE_CHECKING: + from .{{ name }}Serde import {{ name }}Serde # noqa +{%- set ns = namespace(types=[]) -%} +{%- for field in fields|unique(attribute="type")-%} + {%- set _ = ns.types.append(field.type) -%} +{%- endfor -%} +{%- for type in ns.types|sort%} +{%- if not type | is_shimmed and not type | is_intrinsic %} +{%- if type | is_test %} + from .{{ type }} import {{ type }} # noqa +{%- else %} + from ..targeting import {{ type }} # noqa +{% endif -%} +{%- endif %} +{%- endfor%} {% for type in nested_wpilib_types -%} from {{ get_message_by_name(type).python_module }} import {{ type }} @@ -60,4 +73,4 @@ class {{ name }}: {%- if not loop.last %} {% endif -%} {%- endfor %} - photonStruct: ClassVar[{{ name }}Serde] + photonStruct: ClassVar["{{ name }}Serde"] diff --git a/photon-serde/templates/ThingTests.py.jinja b/photon-serde/templates/ThingTests.py.jinja index de7059a616..fc37553c72 100644 --- a/photon-serde/templates/ThingTests.py.jinja +++ b/photon-serde/templates/ThingTests.py.jinja @@ -32,7 +32,7 @@ from photonlibpy.targeting import * from .messages import * {% for dep in python_imports -%} -{{ dep }}; +{{ dep }} {% endfor %} def AutoSerdeTest(data) -> bool: From 1d3cb7b07b7be107ec06212c87009180ab1afc36 Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Fri, 29 May 2026 16:01:20 -0400 Subject: [PATCH 39/42] fixed python serde autotests --- photon-lib/py/photonlibpy/packet.py | 6 ++- photon-serde-tests/py/AutoSerdeTest.py | 32 +++++++++++++ .../py/messages/BoolTestMessage.py | 46 +++++------------- .../py/messages/BoolTestMessageSerde.py | 1 + .../py/messages/Float32TestMessage.py | 46 +++++------------- .../py/messages/Float32TestMessageSerde.py | 1 + .../py/messages/Float64TestMessage.py | 46 +++++------------- .../py/messages/Float64TestMessageSerde.py | 1 + .../py/messages/Int16TestMessage.py | 46 +++++------------- .../py/messages/Int16TestMessageSerde.py | 1 + .../py/messages/Int32TestMessage.py | 46 +++++------------- .../py/messages/Int32TestMessageSerde.py | 1 + .../py/messages/Int64TestMessage.py | 46 +++++------------- .../py/messages/Int64TestMessageSerde.py | 1 + .../py/messages/Int8TestMessage.py | 46 +++++------------- .../py/messages/Int8TestMessageSerde.py | 1 + .../py/messages/Transform3dTestMessage.py | 48 +++++-------------- .../messages/Transform3dTestMessageSerde.py | 1 + .../java/org/photonvision/AutoSerdeTest.java | 32 +++++++++++++ photon-serde/generate_messages.py | 26 ++++++++++ photon-serde/messages.yaml | 2 +- photon-serde/templates/ThingSerde.py.jinja | 1 + .../templates/ThingTestDataclass.py.jinja | 20 ++------ photon-serde/templates/ThingTests.java.jinja | 1 + photon-serde/templates/ThingTests.py.jinja | 1 + .../struct/PhotonPipelineResultSerde.java | 2 +- 26 files changed, 201 insertions(+), 300 deletions(-) diff --git a/photon-lib/py/photonlibpy/packet.py b/photon-lib/py/photonlibpy/packet.py index 06ca8198f0..b10c300ba6 100644 --- a/photon-lib/py/photonlibpy/packet.py +++ b/photon-lib/py/photonlibpy/packet.py @@ -306,7 +306,8 @@ def encodeOptional(self, value: Optional[T], serde: Serde[T]): """ Encodes an optional value using a specific serializer. """ - if value is None: + # This is so that placeholders will still work in autogenerated tests + if not value: self.encodeBoolean(False) else: self.encodeBoolean(True) @@ -318,7 +319,8 @@ def encodeOptionalShimmed(self, value: Optional[T], shim: Callable[[T], None]): """ Encodes an optional value using a specific shimmed serializer. """ - if value is None: + # This is so that placeholders will still work in autogenerated tests + if not value: self.encodeBoolean(False) else: self.encodeBoolean(True) diff --git a/photon-serde-tests/py/AutoSerdeTest.py b/photon-serde-tests/py/AutoSerdeTest.py index f49cbb0322..d82de026bb 100644 --- a/photon-serde-tests/py/AutoSerdeTest.py +++ b/photon-serde-tests/py/AutoSerdeTest.py @@ -47,17 +47,21 @@ def AutoSerdeTest(data) -> bool: def test_Int8Test(): print("Running Int8Test...") + print("Test case default_test:") default_test = Int8TestMessage() assert AutoSerdeTest(default_test) + print("Test case optional_test:") optional_test = Int8TestMessage() optional_test.optTest = 3 assert AutoSerdeTest(optional_test) + print("Test case vla_test:") vla_test = Int8TestMessage() vla_test.vlaTest = [1, 2, 3] assert AutoSerdeTest(vla_test) + print("Test case general_test:") general_test = Int8TestMessage() general_test.test = 42 general_test.optTest = 7 @@ -68,17 +72,21 @@ def test_Int8Test(): def test_Int16Test(): print("Running Int16Test...") + print("Test case default_test:") default_test = Int16TestMessage() assert AutoSerdeTest(default_test) + print("Test case optional_test:") optional_test = Int16TestMessage() optional_test.optTest = 3 assert AutoSerdeTest(optional_test) + print("Test case vla_test:") vla_test = Int16TestMessage() vla_test.vlaTest = [1, 2, 3] assert AutoSerdeTest(vla_test) + print("Test case general_test:") general_test = Int16TestMessage() general_test.test = 42 general_test.optTest = 7 @@ -89,17 +97,21 @@ def test_Int16Test(): def test_Int32Test(): print("Running Int32Test...") + print("Test case default_test:") default_test = Int32TestMessage() assert AutoSerdeTest(default_test) + print("Test case optional_test:") optional_test = Int32TestMessage() optional_test.optTest = 3 assert AutoSerdeTest(optional_test) + print("Test case vla_test:") vla_test = Int32TestMessage() vla_test.vlaTest = [1, 2, 3] assert AutoSerdeTest(vla_test) + print("Test case general_test:") general_test = Int32TestMessage() general_test.test = 42 general_test.optTest = 7 @@ -110,17 +122,21 @@ def test_Int32Test(): def test_Int64Test(): print("Running Int64Test...") + print("Test case default_test:") default_test = Int64TestMessage() assert AutoSerdeTest(default_test) + print("Test case optional_test:") optional_test = Int64TestMessage() optional_test.optTest = 3 assert AutoSerdeTest(optional_test) + print("Test case vla_test:") vla_test = Int64TestMessage() vla_test.vlaTest = [1, 2, 3] assert AutoSerdeTest(vla_test) + print("Test case general_test:") general_test = Int64TestMessage() general_test.test = 42 general_test.optTest = 7 @@ -131,17 +147,21 @@ def test_Int64Test(): def test_Float32Test(): print("Running Float32Test...") + print("Test case default_test:") default_test = Float32TestMessage() assert AutoSerdeTest(default_test) + print("Test case optional_test:") optional_test = Float32TestMessage() optional_test.optTest = 3.0 assert AutoSerdeTest(optional_test) + print("Test case vla_test:") vla_test = Float32TestMessage() vla_test.vlaTest = [1.0, 2.0, 3.0] assert AutoSerdeTest(vla_test) + print("Test case general_test:") general_test = Float32TestMessage() general_test.test = 42.0 general_test.optTest = 7.0 @@ -152,17 +172,21 @@ def test_Float32Test(): def test_Float64Test(): print("Running Float64Test...") + print("Test case default_test:") default_test = Float64TestMessage() assert AutoSerdeTest(default_test) + print("Test case optional_test:") optional_test = Float64TestMessage() optional_test.optTest = 3.0 assert AutoSerdeTest(optional_test) + print("Test case vla_test:") vla_test = Float64TestMessage() vla_test.vlaTest = [1.0, 2.0, 3.0] assert AutoSerdeTest(vla_test) + print("Test case general_test:") general_test = Float64TestMessage() general_test.test = 42.0 general_test.optTest = 7.0 @@ -173,17 +197,21 @@ def test_Float64Test(): def test_BoolTest(): print("Running BoolTest...") + print("Test case default_test:") default_test = BoolTestMessage() assert AutoSerdeTest(default_test) + print("Test case optional_test:") optional_test = BoolTestMessage() optional_test.optTest = True assert AutoSerdeTest(optional_test) + print("Test case vla_test:") vla_test = BoolTestMessage() vla_test.vlaTest = [True, False, True] assert AutoSerdeTest(vla_test) + print("Test case general_test:") general_test = BoolTestMessage() general_test.test = False general_test.optTest = True @@ -194,17 +222,21 @@ def test_BoolTest(): def test_Transform3dTest(): print("Running Transform3dTest...") + print("Test case default_test:") default_test = Transform3dTestMessage() assert AutoSerdeTest(default_test) + print("Test case optional_test:") optional_test = Transform3dTestMessage() optional_test.optTest = Transform3d(Translation3d(1.0, 2.0, 3.0), Rotation3d(0.1, 0.2, 0.3)) assert AutoSerdeTest(optional_test) + print("Test case vla_test:") vla_test = Transform3dTestMessage() vla_test.vlaTest = [Transform3d(Translation3d(1.0, 2.0, 3.0), Rotation3d(0.1, 0.2, 0.3)), Transform3d(Translation3d(4.0, 5.0, 6.0), Rotation3d(0.4, 0.5, 0.6))] assert AutoSerdeTest(vla_test) + print("Test case general_test:") general_test = Transform3dTestMessage() general_test.test = Transform3d(Translation3d(7.0, 8.0, 9.0), Rotation3d(0.7, 0.8, 0.9)) general_test.optTest = Transform3d(Translation3d(1.0, 2.0, 3.0), Rotation3d(0.1, 0.2, 0.3)) diff --git a/photon-serde-tests/py/messages/BoolTestMessage.py b/photon-serde-tests/py/messages/BoolTestMessage.py index 0cd670b4d6..6b3fab6ebb 100644 --- a/photon-serde-tests/py/messages/BoolTestMessage.py +++ b/photon-serde-tests/py/messages/BoolTestMessage.py @@ -28,7 +28,7 @@ ############################################################################### from typing import TYPE_CHECKING, Optional, ClassVar -from dataclasses import dataclass +from dataclasses import dataclass, field from photonlibpy.targeting import * # noqa @@ -37,39 +37,15 @@ - -class _BoolTestMessage_test_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _BoolTestMessage_test_PLACEHOLDER) - -class _BoolTestMessage_vlaTest_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _BoolTestMessage_vlaTest_PLACEHOLDER) - -class _BoolTestMessage_optTest_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _BoolTestMessage_optTest_PLACEHOLDER) - -BoolTestMessage_test_PLACEHOLDER = _BoolTestMessage_test_PLACEHOLDER() -BoolTestMessage_vlaTest_PLACEHOLDER = _BoolTestMessage_vlaTest_PLACEHOLDER() -BoolTestMessage_optTest_PLACEHOLDER = _BoolTestMessage_optTest_PLACEHOLDER() - - @dataclass(kw_only=True) class BoolTestMessage: - test: bool | _BoolTestMessage_test_PLACEHOLDER = BoolTestMessage_test_PLACEHOLDER - vlaTest: list[bool] | _BoolTestMessage_vlaTest_PLACEHOLDER = BoolTestMessage_vlaTest_PLACEHOLDER - optTest: Optional[bool] | _BoolTestMessage_optTest_PLACEHOLDER = BoolTestMessage_optTest_PLACEHOLDER - photonStruct: ClassVar["BoolTestMessageSerde"] \ No newline at end of file + test: bool = field( + default_factory=lambda: False + ) + vlaTest: list[bool] = field( + default_factory=list + ) + optTest: Optional[bool] = field( + default_factory=lambda: None + ) + photonStruct: ClassVar["BoolTestMessageSerde"] diff --git a/photon-serde-tests/py/messages/BoolTestMessageSerde.py b/photon-serde-tests/py/messages/BoolTestMessageSerde.py index 9848cd1614..adf5ed60fb 100644 --- a/photon-serde-tests/py/messages/BoolTestMessageSerde.py +++ b/photon-serde-tests/py/messages/BoolTestMessageSerde.py @@ -32,6 +32,7 @@ from photonlibpy.packet import Packet from photonlibpy.targeting import * # noqa +from . import * diff --git a/photon-serde-tests/py/messages/Float32TestMessage.py b/photon-serde-tests/py/messages/Float32TestMessage.py index 71db6364ae..f5d82b400b 100644 --- a/photon-serde-tests/py/messages/Float32TestMessage.py +++ b/photon-serde-tests/py/messages/Float32TestMessage.py @@ -28,7 +28,7 @@ ############################################################################### from typing import TYPE_CHECKING, Optional, ClassVar -from dataclasses import dataclass +from dataclasses import dataclass, field from photonlibpy.targeting import * # noqa @@ -37,39 +37,15 @@ - -class _Float32TestMessage_test_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _Float32TestMessage_test_PLACEHOLDER) - -class _Float32TestMessage_vlaTest_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _Float32TestMessage_vlaTest_PLACEHOLDER) - -class _Float32TestMessage_optTest_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _Float32TestMessage_optTest_PLACEHOLDER) - -Float32TestMessage_test_PLACEHOLDER = _Float32TestMessage_test_PLACEHOLDER() -Float32TestMessage_vlaTest_PLACEHOLDER = _Float32TestMessage_vlaTest_PLACEHOLDER() -Float32TestMessage_optTest_PLACEHOLDER = _Float32TestMessage_optTest_PLACEHOLDER() - - @dataclass(kw_only=True) class Float32TestMessage: - test: float | _Float32TestMessage_test_PLACEHOLDER = Float32TestMessage_test_PLACEHOLDER - vlaTest: list[float] | _Float32TestMessage_vlaTest_PLACEHOLDER = Float32TestMessage_vlaTest_PLACEHOLDER - optTest: Optional[float] | _Float32TestMessage_optTest_PLACEHOLDER = Float32TestMessage_optTest_PLACEHOLDER - photonStruct: ClassVar["Float32TestMessageSerde"] \ No newline at end of file + test: float = field( + default_factory=lambda: 0.0 + ) + vlaTest: list[float] = field( + default_factory=list + ) + optTest: Optional[float] = field( + default_factory=lambda: None + ) + photonStruct: ClassVar["Float32TestMessageSerde"] diff --git a/photon-serde-tests/py/messages/Float32TestMessageSerde.py b/photon-serde-tests/py/messages/Float32TestMessageSerde.py index 8b00b5dab0..33034bce37 100644 --- a/photon-serde-tests/py/messages/Float32TestMessageSerde.py +++ b/photon-serde-tests/py/messages/Float32TestMessageSerde.py @@ -32,6 +32,7 @@ from photonlibpy.packet import Packet from photonlibpy.targeting import * # noqa +from . import * diff --git a/photon-serde-tests/py/messages/Float64TestMessage.py b/photon-serde-tests/py/messages/Float64TestMessage.py index d0af8601da..e161d9b6ac 100644 --- a/photon-serde-tests/py/messages/Float64TestMessage.py +++ b/photon-serde-tests/py/messages/Float64TestMessage.py @@ -28,7 +28,7 @@ ############################################################################### from typing import TYPE_CHECKING, Optional, ClassVar -from dataclasses import dataclass +from dataclasses import dataclass, field from photonlibpy.targeting import * # noqa @@ -37,39 +37,15 @@ - -class _Float64TestMessage_test_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _Float64TestMessage_test_PLACEHOLDER) - -class _Float64TestMessage_vlaTest_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _Float64TestMessage_vlaTest_PLACEHOLDER) - -class _Float64TestMessage_optTest_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _Float64TestMessage_optTest_PLACEHOLDER) - -Float64TestMessage_test_PLACEHOLDER = _Float64TestMessage_test_PLACEHOLDER() -Float64TestMessage_vlaTest_PLACEHOLDER = _Float64TestMessage_vlaTest_PLACEHOLDER() -Float64TestMessage_optTest_PLACEHOLDER = _Float64TestMessage_optTest_PLACEHOLDER() - - @dataclass(kw_only=True) class Float64TestMessage: - test: float | _Float64TestMessage_test_PLACEHOLDER = Float64TestMessage_test_PLACEHOLDER - vlaTest: list[float] | _Float64TestMessage_vlaTest_PLACEHOLDER = Float64TestMessage_vlaTest_PLACEHOLDER - optTest: Optional[float] | _Float64TestMessage_optTest_PLACEHOLDER = Float64TestMessage_optTest_PLACEHOLDER - photonStruct: ClassVar["Float64TestMessageSerde"] \ No newline at end of file + test: float = field( + default_factory=lambda: 0.0 + ) + vlaTest: list[float] = field( + default_factory=list + ) + optTest: Optional[float] = field( + default_factory=lambda: None + ) + photonStruct: ClassVar["Float64TestMessageSerde"] diff --git a/photon-serde-tests/py/messages/Float64TestMessageSerde.py b/photon-serde-tests/py/messages/Float64TestMessageSerde.py index 52664a64dd..3064394769 100644 --- a/photon-serde-tests/py/messages/Float64TestMessageSerde.py +++ b/photon-serde-tests/py/messages/Float64TestMessageSerde.py @@ -32,6 +32,7 @@ from photonlibpy.packet import Packet from photonlibpy.targeting import * # noqa +from . import * diff --git a/photon-serde-tests/py/messages/Int16TestMessage.py b/photon-serde-tests/py/messages/Int16TestMessage.py index 47d23211ef..60a68067e9 100644 --- a/photon-serde-tests/py/messages/Int16TestMessage.py +++ b/photon-serde-tests/py/messages/Int16TestMessage.py @@ -28,7 +28,7 @@ ############################################################################### from typing import TYPE_CHECKING, Optional, ClassVar -from dataclasses import dataclass +from dataclasses import dataclass, field from photonlibpy.targeting import * # noqa @@ -37,39 +37,15 @@ - -class _Int16TestMessage_test_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _Int16TestMessage_test_PLACEHOLDER) - -class _Int16TestMessage_vlaTest_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _Int16TestMessage_vlaTest_PLACEHOLDER) - -class _Int16TestMessage_optTest_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _Int16TestMessage_optTest_PLACEHOLDER) - -Int16TestMessage_test_PLACEHOLDER = _Int16TestMessage_test_PLACEHOLDER() -Int16TestMessage_vlaTest_PLACEHOLDER = _Int16TestMessage_vlaTest_PLACEHOLDER() -Int16TestMessage_optTest_PLACEHOLDER = _Int16TestMessage_optTest_PLACEHOLDER() - - @dataclass(kw_only=True) class Int16TestMessage: - test: int | _Int16TestMessage_test_PLACEHOLDER = Int16TestMessage_test_PLACEHOLDER - vlaTest: list[int] | _Int16TestMessage_vlaTest_PLACEHOLDER = Int16TestMessage_vlaTest_PLACEHOLDER - optTest: Optional[int] | _Int16TestMessage_optTest_PLACEHOLDER = Int16TestMessage_optTest_PLACEHOLDER - photonStruct: ClassVar["Int16TestMessageSerde"] \ No newline at end of file + test: int = field( + default_factory=lambda: 0 + ) + vlaTest: list[int] = field( + default_factory=list + ) + optTest: Optional[int] = field( + default_factory=lambda: None + ) + photonStruct: ClassVar["Int16TestMessageSerde"] diff --git a/photon-serde-tests/py/messages/Int16TestMessageSerde.py b/photon-serde-tests/py/messages/Int16TestMessageSerde.py index 43c6136dc3..ae410ed9c1 100644 --- a/photon-serde-tests/py/messages/Int16TestMessageSerde.py +++ b/photon-serde-tests/py/messages/Int16TestMessageSerde.py @@ -32,6 +32,7 @@ from photonlibpy.packet import Packet from photonlibpy.targeting import * # noqa +from . import * diff --git a/photon-serde-tests/py/messages/Int32TestMessage.py b/photon-serde-tests/py/messages/Int32TestMessage.py index 42273b0324..077b75dd64 100644 --- a/photon-serde-tests/py/messages/Int32TestMessage.py +++ b/photon-serde-tests/py/messages/Int32TestMessage.py @@ -28,7 +28,7 @@ ############################################################################### from typing import TYPE_CHECKING, Optional, ClassVar -from dataclasses import dataclass +from dataclasses import dataclass, field from photonlibpy.targeting import * # noqa @@ -37,39 +37,15 @@ - -class _Int32TestMessage_test_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _Int32TestMessage_test_PLACEHOLDER) - -class _Int32TestMessage_vlaTest_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _Int32TestMessage_vlaTest_PLACEHOLDER) - -class _Int32TestMessage_optTest_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _Int32TestMessage_optTest_PLACEHOLDER) - -Int32TestMessage_test_PLACEHOLDER = _Int32TestMessage_test_PLACEHOLDER() -Int32TestMessage_vlaTest_PLACEHOLDER = _Int32TestMessage_vlaTest_PLACEHOLDER() -Int32TestMessage_optTest_PLACEHOLDER = _Int32TestMessage_optTest_PLACEHOLDER() - - @dataclass(kw_only=True) class Int32TestMessage: - test: int | _Int32TestMessage_test_PLACEHOLDER = Int32TestMessage_test_PLACEHOLDER - vlaTest: list[int] | _Int32TestMessage_vlaTest_PLACEHOLDER = Int32TestMessage_vlaTest_PLACEHOLDER - optTest: Optional[int] | _Int32TestMessage_optTest_PLACEHOLDER = Int32TestMessage_optTest_PLACEHOLDER - photonStruct: ClassVar["Int32TestMessageSerde"] \ No newline at end of file + test: int = field( + default_factory=lambda: 0 + ) + vlaTest: list[int] = field( + default_factory=list + ) + optTest: Optional[int] = field( + default_factory=lambda: None + ) + photonStruct: ClassVar["Int32TestMessageSerde"] diff --git a/photon-serde-tests/py/messages/Int32TestMessageSerde.py b/photon-serde-tests/py/messages/Int32TestMessageSerde.py index 5fc80e014b..e274784cd8 100644 --- a/photon-serde-tests/py/messages/Int32TestMessageSerde.py +++ b/photon-serde-tests/py/messages/Int32TestMessageSerde.py @@ -32,6 +32,7 @@ from photonlibpy.packet import Packet from photonlibpy.targeting import * # noqa +from . import * diff --git a/photon-serde-tests/py/messages/Int64TestMessage.py b/photon-serde-tests/py/messages/Int64TestMessage.py index 38ece2e881..bb3352680f 100644 --- a/photon-serde-tests/py/messages/Int64TestMessage.py +++ b/photon-serde-tests/py/messages/Int64TestMessage.py @@ -28,7 +28,7 @@ ############################################################################### from typing import TYPE_CHECKING, Optional, ClassVar -from dataclasses import dataclass +from dataclasses import dataclass, field from photonlibpy.targeting import * # noqa @@ -37,39 +37,15 @@ - -class _Int64TestMessage_test_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _Int64TestMessage_test_PLACEHOLDER) - -class _Int64TestMessage_vlaTest_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _Int64TestMessage_vlaTest_PLACEHOLDER) - -class _Int64TestMessage_optTest_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _Int64TestMessage_optTest_PLACEHOLDER) - -Int64TestMessage_test_PLACEHOLDER = _Int64TestMessage_test_PLACEHOLDER() -Int64TestMessage_vlaTest_PLACEHOLDER = _Int64TestMessage_vlaTest_PLACEHOLDER() -Int64TestMessage_optTest_PLACEHOLDER = _Int64TestMessage_optTest_PLACEHOLDER() - - @dataclass(kw_only=True) class Int64TestMessage: - test: int | _Int64TestMessage_test_PLACEHOLDER = Int64TestMessage_test_PLACEHOLDER - vlaTest: list[int] | _Int64TestMessage_vlaTest_PLACEHOLDER = Int64TestMessage_vlaTest_PLACEHOLDER - optTest: Optional[int] | _Int64TestMessage_optTest_PLACEHOLDER = Int64TestMessage_optTest_PLACEHOLDER - photonStruct: ClassVar["Int64TestMessageSerde"] \ No newline at end of file + test: int = field( + default_factory=lambda: 0 + ) + vlaTest: list[int] = field( + default_factory=list + ) + optTest: Optional[int] = field( + default_factory=lambda: None + ) + photonStruct: ClassVar["Int64TestMessageSerde"] diff --git a/photon-serde-tests/py/messages/Int64TestMessageSerde.py b/photon-serde-tests/py/messages/Int64TestMessageSerde.py index a2960cc9cb..d7a317edf8 100644 --- a/photon-serde-tests/py/messages/Int64TestMessageSerde.py +++ b/photon-serde-tests/py/messages/Int64TestMessageSerde.py @@ -32,6 +32,7 @@ from photonlibpy.packet import Packet from photonlibpy.targeting import * # noqa +from . import * diff --git a/photon-serde-tests/py/messages/Int8TestMessage.py b/photon-serde-tests/py/messages/Int8TestMessage.py index e0789b711b..3dd9c6a7fb 100644 --- a/photon-serde-tests/py/messages/Int8TestMessage.py +++ b/photon-serde-tests/py/messages/Int8TestMessage.py @@ -28,7 +28,7 @@ ############################################################################### from typing import TYPE_CHECKING, Optional, ClassVar -from dataclasses import dataclass +from dataclasses import dataclass, field from photonlibpy.targeting import * # noqa @@ -37,39 +37,15 @@ - -class _Int8TestMessage_test_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _Int8TestMessage_test_PLACEHOLDER) - -class _Int8TestMessage_vlaTest_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _Int8TestMessage_vlaTest_PLACEHOLDER) - -class _Int8TestMessage_optTest_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _Int8TestMessage_optTest_PLACEHOLDER) - -Int8TestMessage_test_PLACEHOLDER = _Int8TestMessage_test_PLACEHOLDER() -Int8TestMessage_vlaTest_PLACEHOLDER = _Int8TestMessage_vlaTest_PLACEHOLDER() -Int8TestMessage_optTest_PLACEHOLDER = _Int8TestMessage_optTest_PLACEHOLDER() - - @dataclass(kw_only=True) class Int8TestMessage: - test: int | _Int8TestMessage_test_PLACEHOLDER = Int8TestMessage_test_PLACEHOLDER - vlaTest: list[int] | _Int8TestMessage_vlaTest_PLACEHOLDER = Int8TestMessage_vlaTest_PLACEHOLDER - optTest: Optional[int] | _Int8TestMessage_optTest_PLACEHOLDER = Int8TestMessage_optTest_PLACEHOLDER - photonStruct: ClassVar["Int8TestMessageSerde"] \ No newline at end of file + test: int = field( + default_factory=lambda: 0 + ) + vlaTest: list[int] = field( + default_factory=list + ) + optTest: Optional[int] = field( + default_factory=lambda: None + ) + photonStruct: ClassVar["Int8TestMessageSerde"] diff --git a/photon-serde-tests/py/messages/Int8TestMessageSerde.py b/photon-serde-tests/py/messages/Int8TestMessageSerde.py index e9d80f2d70..4e39b8ecad 100644 --- a/photon-serde-tests/py/messages/Int8TestMessageSerde.py +++ b/photon-serde-tests/py/messages/Int8TestMessageSerde.py @@ -32,6 +32,7 @@ from photonlibpy.packet import Packet from photonlibpy.targeting import * # noqa +from . import * diff --git a/photon-serde-tests/py/messages/Transform3dTestMessage.py b/photon-serde-tests/py/messages/Transform3dTestMessage.py index 010cbc2004..0cd331af2b 100644 --- a/photon-serde-tests/py/messages/Transform3dTestMessage.py +++ b/photon-serde-tests/py/messages/Transform3dTestMessage.py @@ -28,48 +28,24 @@ ############################################################################### from typing import TYPE_CHECKING, Optional, ClassVar -from dataclasses import dataclass +from dataclasses import dataclass, field from photonlibpy.targeting import * # noqa if TYPE_CHECKING: from .Transform3dTestMessageSerde import Transform3dTestMessageSerde # noqa -from wpimath.geometry import Transform3d - - -class _Transform3dTestMessage_test_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _Transform3dTestMessage_test_PLACEHOLDER) - -class _Transform3dTestMessage_vlaTest_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _Transform3dTestMessage_vlaTest_PLACEHOLDER) - -class _Transform3dTestMessage_optTest_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _Transform3dTestMessage_optTest_PLACEHOLDER) - -Transform3dTestMessage_test_PLACEHOLDER = _Transform3dTestMessage_test_PLACEHOLDER() -Transform3dTestMessage_vlaTest_PLACEHOLDER = _Transform3dTestMessage_vlaTest_PLACEHOLDER() -Transform3dTestMessage_optTest_PLACEHOLDER = _Transform3dTestMessage_optTest_PLACEHOLDER() - +from wpimath import Transform3d @dataclass(kw_only=True) class Transform3dTestMessage: - test: Transform3d | _Transform3dTestMessage_test_PLACEHOLDER = Transform3dTestMessage_test_PLACEHOLDER - vlaTest: list[Transform3d] | _Transform3dTestMessage_vlaTest_PLACEHOLDER = Transform3dTestMessage_vlaTest_PLACEHOLDER - optTest: Optional[Transform3d] | _Transform3dTestMessage_optTest_PLACEHOLDER = Transform3dTestMessage_optTest_PLACEHOLDER - photonStruct: ClassVar["Transform3dTestMessageSerde"] \ No newline at end of file + test: Transform3d = field( + default_factory=lambda: Transform3d() + ) + vlaTest: list[Transform3d] = field( + default_factory=list + ) + optTest: Optional[Transform3d] = field( + default_factory=lambda: None + ) + photonStruct: ClassVar["Transform3dTestMessageSerde"] diff --git a/photon-serde-tests/py/messages/Transform3dTestMessageSerde.py b/photon-serde-tests/py/messages/Transform3dTestMessageSerde.py index 130e0b8b5d..01aedc8e35 100644 --- a/photon-serde-tests/py/messages/Transform3dTestMessageSerde.py +++ b/photon-serde-tests/py/messages/Transform3dTestMessageSerde.py @@ -32,6 +32,7 @@ from photonlibpy.packet import Packet from photonlibpy.targeting import * # noqa +from . import * diff --git a/photon-serde-tests/src/test/java/org/photonvision/AutoSerdeTest.java b/photon-serde-tests/src/test/java/org/photonvision/AutoSerdeTest.java index bae6ae57b2..f5ca569e9a 100644 --- a/photon-serde-tests/src/test/java/org/photonvision/AutoSerdeTest.java +++ b/photon-serde-tests/src/test/java/org/photonvision/AutoSerdeTest.java @@ -46,17 +46,21 @@ private > boolean testSerde(T data) { public void Int8Test() { System.out.println("Running Int8Test"); + System.out.println("Test case default_test:"); var default_test = new Int8TestMessage(); assertTrue(testSerde(default_test)); + System.out.println("Test case optional_test:"); var optional_test = new Int8TestMessage(); optional_test.optTest = Optional.of((byte) 3); assertTrue(testSerde(optional_test)); + System.out.println("Test case vla_test:"); var vla_test = new Int8TestMessage(); vla_test.vlaTest = List.of((byte) 1, (byte) 2, (byte) 3); assertTrue(testSerde(vla_test)); + System.out.println("Test case general_test:"); var general_test = new Int8TestMessage(); general_test.test = (byte) 42; general_test.optTest = Optional.of((byte) 7); @@ -69,17 +73,21 @@ public void Int8Test() { public void Int16Test() { System.out.println("Running Int16Test"); + System.out.println("Test case default_test:"); var default_test = new Int16TestMessage(); assertTrue(testSerde(default_test)); + System.out.println("Test case optional_test:"); var optional_test = new Int16TestMessage(); optional_test.optTest = Optional.of((short) 3); assertTrue(testSerde(optional_test)); + System.out.println("Test case vla_test:"); var vla_test = new Int16TestMessage(); vla_test.vlaTest = List.of((short) 1, (short) 2, (short) 3); assertTrue(testSerde(vla_test)); + System.out.println("Test case general_test:"); var general_test = new Int16TestMessage(); general_test.test = (short) 42; general_test.optTest = Optional.of((short) 7); @@ -92,17 +100,21 @@ public void Int16Test() { public void Int32Test() { System.out.println("Running Int32Test"); + System.out.println("Test case default_test:"); var default_test = new Int32TestMessage(); assertTrue(testSerde(default_test)); + System.out.println("Test case optional_test:"); var optional_test = new Int32TestMessage(); optional_test.optTest = Optional.of((int) 3); assertTrue(testSerde(optional_test)); + System.out.println("Test case vla_test:"); var vla_test = new Int32TestMessage(); vla_test.vlaTest = List.of((int) 1, (int) 2, (int) 3); assertTrue(testSerde(vla_test)); + System.out.println("Test case general_test:"); var general_test = new Int32TestMessage(); general_test.test = (int) 42; general_test.optTest = Optional.of((int) 7); @@ -115,17 +127,21 @@ public void Int32Test() { public void Int64Test() { System.out.println("Running Int64Test"); + System.out.println("Test case default_test:"); var default_test = new Int64TestMessage(); assertTrue(testSerde(default_test)); + System.out.println("Test case optional_test:"); var optional_test = new Int64TestMessage(); optional_test.optTest = Optional.of((long) 3); assertTrue(testSerde(optional_test)); + System.out.println("Test case vla_test:"); var vla_test = new Int64TestMessage(); vla_test.vlaTest = List.of((long) 1, (long) 2, (long) 3); assertTrue(testSerde(vla_test)); + System.out.println("Test case general_test:"); var general_test = new Int64TestMessage(); general_test.test = (long) 42; general_test.optTest = Optional.of((long) 7); @@ -138,17 +154,21 @@ public void Int64Test() { public void Float32Test() { System.out.println("Running Float32Test"); + System.out.println("Test case default_test:"); var default_test = new Float32TestMessage(); assertTrue(testSerde(default_test)); + System.out.println("Test case optional_test:"); var optional_test = new Float32TestMessage(); optional_test.optTest = Optional.of((float) 3.0); assertTrue(testSerde(optional_test)); + System.out.println("Test case vla_test:"); var vla_test = new Float32TestMessage(); vla_test.vlaTest = List.of((float) 1.0, (float) 2.0, (float) 3.0); assertTrue(testSerde(vla_test)); + System.out.println("Test case general_test:"); var general_test = new Float32TestMessage(); general_test.test = (float) 42.0; general_test.optTest = Optional.of((float) 7.0); @@ -161,17 +181,21 @@ public void Float32Test() { public void Float64Test() { System.out.println("Running Float64Test"); + System.out.println("Test case default_test:"); var default_test = new Float64TestMessage(); assertTrue(testSerde(default_test)); + System.out.println("Test case optional_test:"); var optional_test = new Float64TestMessage(); optional_test.optTest = Optional.of((double) 3.0); assertTrue(testSerde(optional_test)); + System.out.println("Test case vla_test:"); var vla_test = new Float64TestMessage(); vla_test.vlaTest = List.of((double) 1.0, (double) 2.0, (double) 3.0); assertTrue(testSerde(vla_test)); + System.out.println("Test case general_test:"); var general_test = new Float64TestMessage(); general_test.test = (double) 42.0; general_test.optTest = Optional.of((double) 7.0); @@ -184,17 +208,21 @@ public void Float64Test() { public void BoolTest() { System.out.println("Running BoolTest"); + System.out.println("Test case default_test:"); var default_test = new BoolTestMessage(); assertTrue(testSerde(default_test)); + System.out.println("Test case optional_test:"); var optional_test = new BoolTestMessage(); optional_test.optTest = Optional.of(true); assertTrue(testSerde(optional_test)); + System.out.println("Test case vla_test:"); var vla_test = new BoolTestMessage(); vla_test.vlaTest = List.of(true, false, true); assertTrue(testSerde(vla_test)); + System.out.println("Test case general_test:"); var general_test = new BoolTestMessage(); general_test.test = false; general_test.optTest = Optional.of(true); @@ -207,17 +235,21 @@ public void BoolTest() { public void Transform3dTest() { System.out.println("Running Transform3dTest"); + System.out.println("Test case default_test:"); var default_test = new Transform3dTestMessage(); assertTrue(testSerde(default_test)); + System.out.println("Test case optional_test:"); var optional_test = new Transform3dTestMessage(); optional_test.optTest = Optional.of(new Transform3d(new Translation3d(1.0, 2.0, 3.0), new Rotation3d(0.1, 0.2, 0.3))); assertTrue(testSerde(optional_test)); + System.out.println("Test case vla_test:"); var vla_test = new Transform3dTestMessage(); vla_test.vlaTest = List.of(new Transform3d(new Translation3d(1.0, 2.0, 3.0), new Rotation3d(0.1, 0.2, 0.3)), new Transform3d(new Translation3d(4.0, 5.0, 6.0), new Rotation3d(0.4, 0.5, 0.6))); assertTrue(testSerde(vla_test)); + System.out.println("Test case general_test:"); var general_test = new Transform3dTestMessage(); general_test.test = new Transform3d(new Translation3d(7.0, 8.0, 9.0), new Rotation3d(0.7, 0.8, 0.9)); general_test.optTest = Optional.of(new Transform3d(new Translation3d(1.0, 2.0, 3.0), new Rotation3d(0.1, 0.2, 0.3))); diff --git a/photon-serde/generate_messages.py b/photon-serde/generate_messages.py index b87dff4b24..c8204f02d6 100644 --- a/photon-serde/generate_messages.py +++ b/photon-serde/generate_messages.py @@ -27,6 +27,12 @@ import yaml from jinja2 import Environment, FileSystemLoader +PYTHON_INTRINSIC_DEFAULTS = { + "int": "0", + "float": "0.0", + "bool": "False", +} + class SerdeField(TypedDict): name: str @@ -88,6 +94,7 @@ def is_shimmed(message_name: str): return is_shimmed + # Deal with test types def get_test_filter(message_db): def is_test(message_name: str): @@ -141,6 +148,19 @@ def get_python_qualified_name( return typestr +def get_python_default_factory( + message_db: List[MessageType], data_types, field: SerdeField +) -> str: + if "optional" in field and field["optional"] == True: + return "lambda: None" + if "vla" in field and field["vla"] == True: + return "list" + if is_intrinsic_type(field["type"]): + return f"lambda: {PYTHON_INTRINSIC_DEFAULTS[data_types[field["type"]]["python_type"]]}" + else: + return f"lambda: {field['type']}()" + + def get_message_by_name(message_db: List[MessageType], message_name: str): try: return next( @@ -318,6 +338,9 @@ def generate_photon_messages(cpp_java_root, py_root, template_root): env.filters["get_python_qualified_name"] = lambda field: get_python_qualified_name( messages, extended_data_types, field ) + env.filters["get_python_default_factory"] = ( + lambda field: get_python_default_factory(messages, extended_data_types, field) + ) for message in messages: # don't generate shimmed types. Probably not necessa @@ -461,6 +484,9 @@ def generate_tests(cpp_java_test_root, py_test_root, template_root): env.filters["get_python_qualified_name"] = lambda field: get_python_qualified_name( message_db, extended_data_types, field ) + env.filters["get_python_default_factory"] = ( + lambda field: get_python_default_factory(message_db, extended_data_types, field) + ) for test_message in test_messages: diff --git a/photon-serde/messages.yaml b/photon-serde/messages.yaml index 8e960a0ad4..97da9e8eac 100644 --- a/photon-serde/messages.yaml +++ b/photon-serde/messages.yaml @@ -18,7 +18,7 @@ java_encode_shim_ref: PacketUtils::packTransform3d cpp_type: wpi::math::Transform3d cpp_include: "" - python_module: "wpimath.geometry" + python_module: "wpimath" python_decode_shim: decodeTransform python_encode_shim: encodeTransform java_import: org.wpilib.math.geometry.Transform3d diff --git a/photon-serde/templates/ThingSerde.py.jinja b/photon-serde/templates/ThingSerde.py.jinja index 25dd5d3c2b..360316218f 100644 --- a/photon-serde/templates/ThingSerde.py.jinja +++ b/photon-serde/templates/ThingSerde.py.jinja @@ -32,6 +32,7 @@ from typing import TYPE_CHECKING {% if test %} from photonlibpy.packet import Packet from photonlibpy.targeting import * # noqa +from . import * {% else %} from ..packet import Packet from ..targeting import * # noqa diff --git a/photon-serde/templates/ThingTestDataclass.py.jinja b/photon-serde/templates/ThingTestDataclass.py.jinja index cca03b88ac..300820d672 100644 --- a/photon-serde/templates/ThingTestDataclass.py.jinja +++ b/photon-serde/templates/ThingTestDataclass.py.jinja @@ -28,7 +28,7 @@ ############################################################################### from typing import TYPE_CHECKING, Optional, ClassVar -from dataclasses import dataclass +from dataclasses import dataclass, field from photonlibpy.targeting import * # noqa @@ -53,24 +53,14 @@ from {{ get_message_by_name(type).python_module }} import {{ type }} {%- if not loop.last %},{% endif -%} {%- endfor%} -{% for field in fields %} -class _{{ name }}_{{ field.name }}_PLACEHOLDER: - __slots__ = () - def __repr__(self): - return f"" - - def __eq__(self, other): - return isinstance(other, _{{ name }}_{{ field.name }}_PLACEHOLDER) -{% endfor %} -{% for field in fields -%} -{{ name }}_{{ field.name }}_PLACEHOLDER = _{{ name }}_{{ field.name }}_PLACEHOLDER() -{% endfor %} - @dataclass(kw_only=True) class {{ name }}: {% for field in fields -%} - {{ field.name }}: {{ field | get_python_qualified_name }} | _{{ name }}_{{ field.name }}_PLACEHOLDER = {{ name }}_{{ field.name }}_PLACEHOLDER + {{ field.name }}: {{ field | get_python_qualified_name }} = field( + default_factory={{ field | get_python_default_factory }} + ) {%- if not loop.last %} {% endif -%} {%- endfor %} photonStruct: ClassVar["{{ name }}Serde"] + diff --git a/photon-serde/templates/ThingTests.java.jinja b/photon-serde/templates/ThingTests.java.jinja index 8646b5771e..dcefe44693 100644 --- a/photon-serde/templates/ThingTests.java.jinja +++ b/photon-serde/templates/ThingTests.java.jinja @@ -45,6 +45,7 @@ public class AutoSerdeTest { public void {{ test.name }}() { System.out.println("Running {{ test.name }}"); {% for test_case in test.cases %} + System.out.println("Test case {{ test_case.name }}:"); var {{ test_case.name }} = new {{ test.type }}(); {% for field in test_case.fields -%} {{ test_case.name }}.{{ field.name }} = {{ field.java_value }}; diff --git a/photon-serde/templates/ThingTests.py.jinja b/photon-serde/templates/ThingTests.py.jinja index fc37553c72..f81f3129de 100644 --- a/photon-serde/templates/ThingTests.py.jinja +++ b/photon-serde/templates/ThingTests.py.jinja @@ -46,6 +46,7 @@ def AutoSerdeTest(data) -> bool: def test_{{ test.name }}(): print("Running {{ test.name }}...") {% for test_case in test.cases %} + print("Test case {{ test_case.name }}:") {{ test_case.name }} = {{ test.type }}() {% for field in test_case.fields -%} {{ test_case.name }}.{{ field.name }} = {{ field.python_value }} diff --git a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java index 46528cc3a0..796bf7c48a 100644 --- a/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java +++ b/photon-targeting/src/generated/main/java/org/photonvision/struct/PhotonPipelineResultSerde.java @@ -89,7 +89,7 @@ public PhotonPipelineResult unpack(Packet packet) { @Override public PacketSerde[] getNestedPhotonMessages() { return new PacketSerde[] { - MultiTargetPNPResult.photonStruct,PhotonTrackedTarget.photonStruct,PhotonPipelineMetadata.photonStruct + PhotonTrackedTarget.photonStruct,PhotonPipelineMetadata.photonStruct,MultiTargetPNPResult.photonStruct }; } From d35ee077210d092d1646d4ed8cfab3495dd8b689 Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Fri, 29 May 2026 16:10:11 -0400 Subject: [PATCH 40/42] removed unnecessary changes from packet.py --- photon-lib/py/photonlibpy/packet.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/photon-lib/py/photonlibpy/packet.py b/photon-lib/py/photonlibpy/packet.py index b10c300ba6..9336f3a869 100644 --- a/photon-lib/py/photonlibpy/packet.py +++ b/photon-lib/py/photonlibpy/packet.py @@ -306,8 +306,7 @@ def encodeOptional(self, value: Optional[T], serde: Serde[T]): """ Encodes an optional value using a specific serializer. """ - # This is so that placeholders will still work in autogenerated tests - if not value: + if value is not None: self.encodeBoolean(False) else: self.encodeBoolean(True) @@ -319,8 +318,7 @@ def encodeOptionalShimmed(self, value: Optional[T], shim: Callable[[T], None]): """ Encodes an optional value using a specific shimmed serializer. """ - # This is so that placeholders will still work in autogenerated tests - if not value: + if value is not None: self.encodeBoolean(False) else: self.encodeBoolean(True) From 8c71e05b398e15b0612522fda9d37744b39dbb6c Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Fri, 29 May 2026 16:12:30 -0400 Subject: [PATCH 41/42] i may be stupid --- photon-lib/py/photonlibpy/packet.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/photon-lib/py/photonlibpy/packet.py b/photon-lib/py/photonlibpy/packet.py index 9336f3a869..06ca8198f0 100644 --- a/photon-lib/py/photonlibpy/packet.py +++ b/photon-lib/py/photonlibpy/packet.py @@ -306,7 +306,7 @@ def encodeOptional(self, value: Optional[T], serde: Serde[T]): """ Encodes an optional value using a specific serializer. """ - if value is not None: + if value is None: self.encodeBoolean(False) else: self.encodeBoolean(True) @@ -318,7 +318,7 @@ def encodeOptionalShimmed(self, value: Optional[T], shim: Callable[[T], None]): """ Encodes an optional value using a specific shimmed serializer. """ - if value is not None: + if value is None: self.encodeBoolean(False) else: self.encodeBoolean(True) From a1780501c3d845f003a9a305aaaffc6699f71e2b Mon Sep 17 00:00:00 2001 From: Jesse Kane Date: Sat, 30 May 2026 13:35:41 -0400 Subject: [PATCH 42/42] added auto-generated comment to PyInit --- photon-serde-tests/py/messages/__init__.py | 5 +++++ photon-serde/templates/PyInit.py.jinja | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/photon-serde-tests/py/messages/__init__.py b/photon-serde-tests/py/messages/__init__.py index 81ded26c1e..cac7dc9329 100644 --- a/photon-serde-tests/py/messages/__init__.py +++ b/photon-serde-tests/py/messages/__init__.py @@ -22,6 +22,11 @@ # SOFTWARE. # +############################################################################### +## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. +## --> DO NOT MODIFY <-- +############################################################################### + from .Int8TestMessage import Int8TestMessage from .Int8TestMessageSerde import Int8TestMessageSerde from .Int16TestMessage import Int16TestMessage diff --git a/photon-serde/templates/PyInit.py.jinja b/photon-serde/templates/PyInit.py.jinja index 74a60c8cce..936c666c83 100644 --- a/photon-serde/templates/PyInit.py.jinja +++ b/photon-serde/templates/PyInit.py.jinja @@ -22,6 +22,11 @@ # SOFTWARE. # +############################################################################### +## THIS FILE WAS AUTO-GENERATED BY ./photon-serde/generate_messages.py. +## --> DO NOT MODIFY <-- +############################################################################### + {% for type in types -%} from .{{ type }} import {{ type }} from .{{ type }}Serde import {{ type }}Serde