How to publish a DoubleSupplier to NetworkTables?

I want to publish a value to NetworkTables that will be updating constantly, such as the current speed of a motor. My understanding is that the normal way to do this is to create a DoublePublisher and call dblPub.set(value) whenever my value changes. However, since this value changes so rapidly, I was hoping there was a way to link a DoublePublisher with a DoubleSupplier in a way that updates the NetworkTable topic in the background instead of my code explicitly calling dblPub.set(dblSup.getAsDouble()) periodically.

Perhaps the simplest way to do this would be to use ShuffleboardContainer.addDouble​(String title, DoubleSupplier valueSupplier). However, ideally I would like to interact with the NetworkTables API directly instead of relying on ShuffleBoard stuff.

The NetworkTables API does not provide an integrated callback polling mechanism to set values. You might want to look at Monologue for a fire-and-forget solution that’s a relatively thin layer on top of NT/DataLog. Introducing Monologue: Annotation-based Telemetry and Data Logging for Java Teams

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.