Telemetry
By default, every value logged with Telemetry is shown on the Driver Station, written to a log file on the Robot Controller, and published over a NetworkTables server that dashboards such as AdvantageScope and Elastic can read.
The destinations are called backends, and NextFTC creates them before each OpMode’s init and closes them when it stops.
The telemetry module contains the logging API and has no dependency on the FTC SDK.
The telemetry-ftc module connects it to the OpMode lifecycle.
Both are included in the robot module, so no setup is needed.
Telemetry concepts
Section titled “Telemetry concepts”- Topic: a named channel that holds values of one type. A topic keeps that type for as long as a backend is registered, and a value of any other type logged to it is dropped with a warning.
- Path: the full name of a topic, such as
/Arm/Position. Slashes divide a path into tables. - Table: a namespace of topics and other tables.
Arm/Positionis the topicPositionin the tableArm, and AdvantageScope displays tables as a tree. - Backend: a destination for logged values. The registry sends each value to every backend registered for its path.
dev.nextftc.telemetry.Telemetry is a static class that wraps the registry and its root table, so it can be called from any class.
Logging never throws.
A value that can’t be logged is reported as a warning in the Robot Controller log and then dropped.
Logging values
Section titled “Logging values”The simplest way to log is Telemetry.log(name, value).
Numbers, booleans, strings, and primitive arrays are logged to a topic of the matching type, and any other object is logged as a struct.
Telemetry.log("Arm/Position", arm.position)Telemetry.log("Arm/AtTarget", arm.atTarget)Telemetry.log("Drive/Pose", follower.pose)Telemetry.log("Arm/Position", arm.getPosition());Telemetry.log("Arm/AtTarget", arm.getAtTarget());Telemetry.log("Drive/Pose", follower.getPose());A number, boolean, or string that equals the previous value on its path is skipped, to keep logs and network traffic small. Arrays and structs are always logged, because the same object can be changed in place between calls.
Topics
Section titled “Topics”log looks up the topic by name on every call.
A typed topic held in a field skips the lookup, so it is the better choice for values logged every loop.
Topics exist for Boolean, Int, Long, Float, Double, and String, for arrays of each, and for structs and lists of structs.
private val shooter = Telemetry.table("Shooter")private val velocity = shooter.doubleTopic("wheelVelocity")private val ready = shooter.booleanTopic("ready")
fun periodic() { velocity.set(motor.velocity) ready.set(atSpeed())}private final TelemetryTable shooter = Telemetry.table("Shooter");private final DoubleTopic velocity = shooter.doubleTopic("wheelVelocity");private final BooleanTopic ready = shooter.booleanTopic("ready");
public void periodic() { velocity.set(motor.getVelocity()); ready.set(atSpeed());}A TelemetryTable has the same log and topic functions as Telemetry, scoped to its own path.
To log a repeated value anyway, set keepDuplicates to true on the topic.
A topic can carry a unit. AdvantageScope displays and converts values using it, and the Driver Station prints it after the value. The unit is sent when the path is first published, so it has to be set before the first value is logged.
private val velocity = shooter.doubleTopic("wheelVelocity").withUnit("m/s")private final DoubleTopic velocity = withUnit(shooter.doubleTopic("wheelVelocity"), "m/s");A Measure passed to log is logged as a double in its base unit, with that unit attached automatically.
Updating the Driver Station
Section titled “Updating the Driver Station”Each logged path appears as one line on the Driver Station, captioned with the path.
The lines are sent when FtcTelemetry.update() runs.
NextOpMode calls it every loop, but a regular OpMode or LinearOpMode has to call it directly.
FtcTelemetry.update()FtcTelemetry.update();