How to properly publish data using network tables

Our team hasn’t used network tables before and are trying to use it to publish motor data to the dashboard, specifically temperature and encoder data.

My initial thought is to put something in each subsystem’s periodic() function (that we want to publish data from).

With that approach, how would I go about initializing the network table? Should we create a network table instance in RobotContainer and pass that in to each subsystem when I create it? Or should I just use NetworkTableInstance inst = NetworkTableInstance.getDefault(); inside every subsystem?

The sample code from WPILib is pretty basic and doesn’t go into much detail on how it’s used further

You can use the SmartDashboard class to do it. It uses NetworkTables under the hood and can be displayed in Shuffleboard as well. Displaying Expressions from a Robot Program — FIRST Robotics Competition documentation

If you want to use NetworkTables directly, then yes, you would get the NetworkTableInstance as shown in the docs, then .getTable("tableName"), then .getEntry("entryName"), then you can .put{type}(value) to set the value.

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