Skip to content

Telemetry backends

A backend receives the values logged with Telemetry. Robot code never calls a backend directly. The registry sends each value to every backend registered for its path.

Before each OpMode’s init, NextFTC registers three backends and, when the OpMode stops, closes them. The Driver Station backend shows each path as a line of telemetry, the log backend writes a file, and the NetworkTables backend publishes to a server that dashboards connect to. Each can be turned off in the configuration.

The Driver Station backend adds one line per path to the OpMode’s SDK telemetry. The lines are retained, so they survive the SDK’s automatic clearing and don’t disturb lines the OpMode adds itself.

The Driver Station screen fills up fast, so the driverStationPrefixes setting can be used to only show some entries on the DS. The log file and the NetworkTables server still get everything.

FtcTelemetry.config.driverStationPrefixes = listOf("/Drive", "/Arm")

Values are shown as text. A unit is printed after the value, and an array or struct is shown with its contents. The lines refresh only when FtcTelemetry.update() runs.

Each OpMode writes a WPILOG to /sdcard/FIRST/nextftc/logs. The file name has the start time and the OpMode name. Logs are flushed every 250 ms and at the end of every OpMode stop. Logs can be opened in AdvantageScope.

While the NetworkTables server is running, it also serves the logs over HTTP, so they can be downloaded from a browser without pulling them off the Robot Controller.

Page Control Hub Robot Controller phone
Log list http://192.168.43.1:5810/download http://192.168.49.1:5810/download

The same list is available as JSON from /logs, and a single file can be downloaded from /logs/<filename>.

The NetworkTables backend publishes to a NetworkTables 4 server on port 5810 for as long as the Robot Controller app is open. The server outlives individual OpModes, so a dashboard stays connected between them.

In AdvantageScope or Elastic, connecting to 192.168.43.1 on a Control Hub or 192.168.49.1 on a phone shows values live. Struct values such as poses arrive typed, so AdvantageScope can draw them.

As of NextFTC v0.4.0, the NT4 server is read-only, so dashboards cannot change values.

To stop the server, for example before a competition, run the Disable NextFTC Telemetry Server OpMode. Run Enable NextFTC Telemetry Server to start it again. The Robot Controller saves the choice across app restarts, and the log file and Driver Station lines keep working while the server is off.

The same switch is available from code.

FtcTelemetry.setServerEnabled(false)

Turning the server off stops it immediately and disconnects any dashboards. Turning it back on takes effect when the next OpMode initializes.

The backends are controlled by FtcTelemetry.config. Its settings are not saved, so they return to their defaults whenever the app restarts and have to be set in code.

Setting Default Description
logToFile true Writes a WPILOG for each OpMode.
logDirectory /sdcard/FIRST/nextftc/logs The directory logs are written to.
logFlushIntervalMillis 250 The minimum time between log flushes, which update() performs.
Zero or less turns it off, and the log is then flushed only when its buffer fills or the OpMode stops.
liveServer true Serves NetworkTables 4 for dashboards.
serverPort 5810 The port the server listens on.
The server starts once, at the first OpMode that runs with it enabled, and keeps that port until the app restarts.
driverStation true Shows logged values on the Driver Station.
driverStationPrefixes empty If not empty, only paths at or under these prefixes are shown on the Driver Station.

NextFTC reads the settings right before an OpMode’s init, when it creates the backends. A setting changed inside init or later applies from the next OpMode. The best place to set them is the constructor of the NextRobot, which NextFTC constructs when the code loads, before any OpMode initializes.

class MyRobot : NextRobot {
init {
FtcTelemetry.config.logToFile = false
}
}

A custom backend implements TelemetryBackend, whose entry function returns an object that receives the values for one path. It is registered on Telemetry.registry, optionally with path prefixes that limit it to those paths. A backend must be thread-safe.

Telemetry.registry.register(MyBackend())
Telemetry.registry.register(MyBackend(), "/Drive") // only /Drive and below

The telemetry module has no dependency on the FTC SDK or Android, so code that logs can be tested on a plain JVM. A MockTelemetryBackend registered on Telemetry.registry records what was logged so a test can check it.