What is NetworkTables?
NetworkTables provides:- Automatic Synchronization: Changes propagate to all connected clients
- Persistent Data: Values survive program restarts
- Topic-Based: Organized by hierarchical names like
/SmartDashboard/Speed - Type-Safe: Supports primitives, arrays, and structured data
- Low Latency: Optimized for real-time robotics
Getting Started
Getting the Default Instance
ntcore/src/main/native/include/networktables/NetworkTableInstance.h:131
Getting a Table
Tables organize related entries:ntcore/src/main/native/include/networktables/NetworkTableInstance.h:435
Publishing and Subscribing
Using Topics (NT4 - Recommended)
Topics provide type-safe, efficient communication:ntcore/src/main/native/include/networktables/NetworkTableInstance.h:199
Supported Topic Types
ntcore/src/main/native/include/networktables/NetworkTableInstance.h:177
Structured Data
Publish complex types using structs:ntcore/src/main/native/include/networktables/NetworkTableInstance.h:279
Using NetworkTable Entries
Simple Put/Get API
For basic use cases:ntcore/src/main/native/include/networktables/NetworkTable.h:361
Array Values
ntcore/src/main/native/include/networktables/NetworkTable.h:490
Listeners and Callbacks
React to value changes:ntcore/src/main/native/include/networktables/NetworkTableInstance.h:515
Server and Client Modes
Robot (Server Mode)
The robot typically runs as a server:ntcore/src/main/native/include/networktables/NetworkTableInstance.h:617
Coprocessor (Client Mode)
Vision coprocessors connect as clients:ntcore/src/main/native/include/networktables/NetworkTableInstance.h:645
Common Patterns
SmartDashboard Integration
Tunable Parameters
Adjust PID gains from dashboard:Vision Data Exchange
Persistent Values
Values that survive robot reboots:ntcore/src/main/native/include/networktables/NetworkTable.h:336
Connection Management
Check Connection Status
ntcore/src/main/native/include/networktables/NetworkTableInstance.h:747
Flush Updates
ntcore/src/main/native/include/networktables/NetworkTableInstance.h:730
Best Practices
- Use Topics Over Entries: NT4 topics are more efficient than legacy entries
- Batch Updates: Group related updates to minimize network traffic
- Minimize Publish Rate: Don’t publish faster than necessary (20-50Hz is often sufficient)
- Use Structured Types: Prefer structs over multiple individual values
- Name Hierarchically: Use clear paths like
/subsystem/component/value - Persist Configuration: Use persistent entries for tunable parameters
- Handle Disconnections: Always provide default values for Get operations
Debugging
View with OutlineViewer
WPILib includes OutlineViewer for browsing NetworkTables:- Shows all topics and values
- Edit values in real-time
- Monitor connection status
Logging
ntcore/src/main/native/include/networktables/NetworkTableInstance.h:837