Removing longs from IntegerTopics in NetworkTables #7923
Replies: 2 comments 9 replies
-
After getting a few more responses in Discord, I have been made aware that message packing automatically reduces integer values to the minimum size, so the longest size is processed in code. The reason floats and doubles don't do this is because the process is more expensive than just sending the raw float/double value. Still wondering if this would be a good thing to add for semantics. |
Beta Was this translation helpful? Give feedback.
-
I think I'd be okay (for 2027) adding more variants at the API level, although all will still map to the same underlying integer type. The key issue to think through is what to do about numeric overflows--e.g. what do you get if someone publishes a large 64-bit number (that doesn't fit into 32 bits) and the subscriber is only a 32-bit integer? The fastest thing to do is truncate (otherwise we'll always have to check for every number if it overflows and saturate appropriately), but that's also probably the least correct answer? |
Beta Was this translation helpful? Give feedback.
-
Recently, I have been working on my own NT logger, so I have been getting into logging ints, floats, and doubles.
When using the
IntegerArraySubscriber
class, I noticed that it didn't actually takeint[]
, but instead the parameter was along[]
. This is the same case withIntegerSubscriber
and their Publisher counterparts. Looking into this a bit more, I found that there wasn't aLongSubscriber
, only theIntegerSubscriber
. After asking around in the FIRST CHS discord, I learned that internally, NetworkTables logs ints with theint64_t
type, which is a long in java. The problem I have with this argument is that aFloatTopic
exists, which is a 32-bit decimal value. If there is support for logging 32-bit decimal values, then why is there no support for 32-bit integer values?Beta Was this translation helpful? Give feedback.
All reactions