Lesson 4.9: NetworkTables Basics
π― What Youβll Learn
By the end of this lesson you will be able to:
- Explain what NetworkTables is and why FRC robots use it
- Describe the publish/subscribe model and how data flows between robot and dashboard
- Identify SmartDashboard methods in your teamβs code and explain what they do
- Explain how the Limelight camera publishes vision data through NetworkTables
- Describe how the autonomous chooser uses NetworkTables to let drivers select an auto routine
What Is NetworkTables?
Every FRC robot has a hidden data layer running alongside the command-based code youβve been reading. That layer is called NetworkTables β a real-time key-value store that lets different programs share data over the network.
Think of NetworkTables as a shared whiteboard:
- The robot code writes values to the whiteboard (motor speeds, sensor readings, robot position)
- The Driver Station dashboard reads those values and displays them
- The Limelight camera writes vision data to the whiteboard
- AdvantageScope or Shuffleboard reads everything for logging and visualization
All of this happens automatically over the robotβs network β no manual file transfers or serial connections needed.
The Key-Value Model
NetworkTables stores data as key-value pairs, organized into tables (like folders). Each entry has:
- A key (the name): e.g.,
"/SmartDashboard/Intake/Speed" - A value (the data): e.g.,
0.5 - A type: number, boolean, string, or structured types like
Pose2d
NetworkTablesβββ SmartDashboard/β βββ Intake/Speed = 0.5β βββ Shooter/RPM = 3200.0β βββ Auto Chooser = "TwoNoteAuto"βββ limelight/β βββ tv = 1.0 (target visible)β βββ tx = -3.5 (horizontal offset)β βββ botpose_wpiblue = [1.2, 5.4, 0, ...]βββ FMSInfo/ βββ IsRedAlliance = false βββ MatchNumber = 42The Publish/Subscribe Model
NetworkTables uses a publish/subscribe pattern. This is a fundamental concept in software engineering β not just FRC.
Publishers
A publisher writes data to NetworkTables. Your robot code is the primary publisher:
// Simple approach β SmartDashboard wrapperSmartDashboard.putNumber("Intake/Speed", intakeMotor.getVelocity().getValueAsDouble());SmartDashboard.putBoolean("Intake/Deployed", isDeployed);SmartDashboard.putString("Robot/State", "INTAKING");
// Advanced approach β direct NetworkTables publisherNetworkTableInstance.getDefault() .getTable("MyTable") .getEntry("myValue") .setDouble(3.14);Subscribers
A subscriber reads data from NetworkTables. Dashboards, logging tools, and even other parts of your robot code can subscribe:
// Reading a value published by the Limelightdouble tx = LimelightHelpers.getTX(""); // Internally reads from NetworkTables
// Reading a SmartDashboard valuedouble speed = SmartDashboard.getNumber("Intake/Speed", 0.0);// ^^^// Default value if key doesn't existWhy Publish/Subscribe?
The beauty of this model is decoupling. The robot code doesnβt need to know whoβs reading the data. It just publishes. Whether itβs Shuffleboard, AdvantageScope, a Limelight, or nothing at all β the robot code is the same. This makes it easy to add new dashboard widgets or logging tools without changing any robot code.
Your team's code calls SmartDashboard.putNumber('Shooter/RPM', 3200). What does this do?
SmartDashboard β The Easy API
SmartDashboard is a convenience wrapper around NetworkTables. Itβs the most common way FRC teams publish data because itβs simple:
| Method | What It Does | Example |
|---|---|---|
putNumber(key, value) | Publishes a double | putNumber("Shooter/RPM", 3200) |
putBoolean(key, value) | Publishes a boolean | putBoolean("Intake/HasNote", true) |
putString(key, value) | Publishes a string | putString("Auto/Selected", "TwoNote") |
getNumber(key, default) | Reads a double | getNumber("Shooter/RPM", 0.0) |
getBoolean(key, default) | Reads a boolean | getBoolean("Intake/HasNote", false) |
All SmartDashboard entries live under the SmartDashboard/ table in NetworkTables. When you call putNumber("Shooter/RPM", 3200), the full NetworkTables key is "/SmartDashboard/Shooter/RPM".
Where SmartDashboard Appears in Your Code
Search your project for SmartDashboard to find where your team publishes data. Common locations:
- Subsystem
periodic()methods β publishing sensor readings every loop - Telemetry.java β
Telemetry.java publishes drivetrain data - RobotContainer β publishing auto chooser selections
Limelight Data Flow
Your teamβs Limelight camera is one of the most interesting NetworkTables publishers. It runs its own vision processing and publishes results directly to NetworkTables β your robot code just reads them.
How Limelight Uses NetworkTables
The Limelight publishes data under the limelight/ table:
| Key | Type | What It Means |
|---|---|---|
tv | Number (0 or 1) | Is a target visible? 1 = yes, 0 = no |
tx | Number (degrees) | Horizontal offset from crosshair to target |
ty | Number (degrees) | Vertical offset from crosshair to target |
ta | Number (%) | Target area (how much of the image the target fills) |
botpose_wpiblue | Number array | Robotβs estimated position on the field (from AprilTags) |
Your teamβs code reads these values through
// These methods internally read from the limelight/ NetworkTables tabledouble targetVisible = LimelightHelpers.getTV(""); // reads limelight/tvdouble horizontalOffset = LimelightHelpers.getTX(""); // reads limelight/txPose2d robotPose = LimelightHelpers.getBotPoseEstimate_wpiBlue("").pose;The empty string "" is the Limelightβs name β if you only have one Limelight, the default name works. Teams with multiple cameras use names like "limelight-front" and "limelight-back".
The Data Flow
Limelight Camera NetworkTables Robot Codeββββββββββββββββ ββββββββββββββ ββββββββββSees AprilTag #4 β Publishes botpose_wpiblue β LimelightHelpers.getBotPoseEstimate()Calculates offset β Publishes tx, ty, ta β LimelightHelpers.getTX(), getTY()Detects target β Publishes tv = 1 β LimelightHelpers.getTV()The camera does all the heavy vision processing. Your robot code just reads the results. This is the power of NetworkTables β the camera and robot code donβt need to know about each otherβs internals. They communicate through shared data.
The Autonomous Chooser
One of the most practical uses of NetworkTables is the autonomous chooser β the dropdown on the Driver Station dashboard that lets the drive team select which auto routine to run.
How It Works
- Robot code creates a
SendableChooserand adds auto options:
private final SendableChooser<Command> autoChooser = new SendableChooser<>();
public RobotContainer() { autoChooser.setDefaultOption("Do Nothing", new InstantCommand()); autoChooser.addOption("Two Note Auto", buildTwoNoteAuto()); autoChooser.addOption("Three Note Auto", buildThreeNoteAuto());
SmartDashboard.putData("Auto Chooser", autoChooser);}-
SmartDashboard.putData() publishes the chooser to NetworkTables. The dashboard reads it and displays a dropdown.
-
The drive team selects an option on the dashboard before the match starts.
-
When autonomous begins, the robot code reads the selection:
public void autonomousInit() { Command autoCommand = autoChooser.getSelected(); if (autoCommand != null) { autoCommand.schedule(); }}The entire flow happens through NetworkTables. The robot publishes the options, the dashboard displays them, the driver selects one, and the robot reads the selection β all through the shared data layer.
How does the Limelight camera send vision data to your robot code?
Viewing NetworkTables Data
You can view all NetworkTables data in real time using several tools:
| Tool | What It Shows | When to Use |
|---|---|---|
| Shuffleboard | Customizable dashboard with widgets | During practice β drag and drop widgets for the data you care about |
| AdvantageScope | Full NetworkTables tree + logging | During debugging β see every entry, graph values over time |
| OutlineViewer | Raw NetworkTables tree (text-based) | Quick inspection β see all keys and values in a simple list |
| Glass | WPILibβs built-in dashboard | Simulation β works without a real robot |
In the next activity, youβll use one of these tools to explore your robotβs live NetworkTables data.
-
Publish/subscribe: Publishers write data to shared keys, and subscribers read from those keys β neither needs to know about the other.
-
Two publishers: (a) Your robot code (via SmartDashboard.putNumber/putBoolean/putString) and (b) the Limelight camera (publishes vision data like tx, ty, tv, botpose). Other valid answers: the FMS (publishes match info), the Driver Station (publishes joystick data).
-
Auto chooser flow: The robot code creates a SendableChooser with auto options and publishes it to NetworkTables via SmartDashboard.putData(). The dashboard reads the options and shows a dropdown. The driver selects an option. When autonomous starts, the robot code calls autoChooser.getSelected() to read the selection from NetworkTables and schedule that command.
NetworkTables vs. Other Communication
Itβs worth understanding what NetworkTables is not:
| Communication | What It Does | NetworkTables? |
|---|---|---|
| CAN bus | Robot code β motor controllers, sensors | No β CAN is hardware-level, not NetworkTables |
| NetworkTables | Robot code β dashboards, cameras, logging | Yes β this lesson! |
| Driver Station protocol | Robot code β Driver Station (enable/disable, joysticks) | Partially β joystick data comes through DS, but some data uses NT |
| FMS | Field Management System β robot (match info, alliance) | Yes β FMS data is published to NetworkTables |
CAN bus handles the low-level hardware communication (telling motors what to do). NetworkTables handles the high-level data sharing (telling dashboards whatβs happening). They serve different purposes at different levels.
Key Terms
π All terms below are also in the full glossary for quick reference.
| Term | Definition |
|---|---|
| NetworkTables | A real-time key-value data store that lets programs on the robot network share data β the communication backbone between robot code, dashboards, and cameras |
| Publish/Subscribe | A communication pattern where publishers write data to shared keys and subscribers read from those keys, without needing to know about each other |
| SmartDashboard | A WPILib convenience class that wraps NetworkTables access, providing simple putNumber/getNumber methods for publishing and reading data |
| SendableChooser | A WPILib class that creates a dropdown selector on the dashboard via NetworkTables, commonly used for autonomous routine selection |
| Key-Value Pair | A data entry in NetworkTables consisting of a name (key) and associated data (value), organized into tables |
| Limelight | A vision camera that processes AprilTags and targets, publishing results to NetworkTables for the robot code to read |
Whatβs Next?
You now understand the data layer that connects your robot to the outside world. NetworkTables is the invisible backbone behind every dashboard widget, every Limelight reading, and every auto chooser selection.
In Activity 4.10: Explore Live NetworkTables, youβll connect to a running robot (or simulation) and use OutlineViewer or AdvantageScope to see every NetworkTables entry in real time. Youβll document what your robot publishes and where that data comes from in the code.
In Activity 4.10: Explore Live NetworkTables, youβll connect to a running robot (or simulation) and use OutlineViewer or AdvantageScope to see every NetworkTables entry in real time. Youβll document what your robot publishes and where that data comes from in the code.