Struct vs protobuf
Both struct and protobuf topics carry binary payloads over NetworkTables. Choose based on interoperability and schema needs.
Struct
- Fixed-size binary layout used by WPILib Java/C++ struct topics
- Best for standard geometry types (
Pose2d,Translation2d, …) that already exist on the robot - Use
getStructTopic/useStructTopicwith a built-in descriptor or a customtypeName+schemastring - Interoperates directly with WPILib struct publishers/subscribers
Protobuf
- Schema-driven messages via Protocol Buffers
- Best for custom message types defined in
.protofiles - Use
getProtobufTopic/useProtobufTopicwith Zod validators and, when publishing,protoFilePath(Node),protoSource, ormessageType - Schema is exchanged over NetworkTables; decoding can be validated at runtime with Zod
Which to pick
- Matching WPILib geometry / existing struct topics → struct
- Custom app-defined messages with a
.proto→ protobuf