For the complete documentation index, see llms.txt. This page is also available as Markdown.

Telemetry

Telemetry is what YAMS tells you about your mechanisms while the code runs: where each one is, where it was asked to go, and what its motors are doing. You watch it live on a dashboard, and you can record it to look at after a match.

Where to find your mechanism's values

While the code runs, YAMS publishes to NetworkTables, which dashboards such as AdvantageScope and Elastic read. It uses two tables, and nothing goes under NT:/SmartDashboard.

Two NetworkTables trees for an elevator named Elevator with a motor named ElevatorMotor. Under NT Mechanisms are the read-only values such as mechanism/position and motor/outputVoltage. Under NT Tuning are the editable values such as closedloop/feedback/kP, and the Live Tuning command
An elevator named Elevator with a motor named ElevatorMotor.
Table
Holds
Path

NT:/Mechanisms

What the mechanism is doing. Read-only.

NT:/Mechanisms/<Mechanism>/<Motor>/<key>

NT:/Mechanisms

The mechanism's Mechanism2d

NT:/Mechanisms/<Mechanism>/mechanism

NT:/Tuning

Values you can edit

NT:/Tuning/<Mechanism>/<Motor>/<key>

NT:/Tuning

The Live Tuning command

NT:/Tuning/<Subsystem>/Live Tuning

<Mechanism> and <Motor> are the telemetry names given to withTelemetry(...) on the mechanism config and on the SmartMotorControllerConfig. <Subsystem> is the subsystem's getName() in Commands v2 (its class name by default), or the Commands v3 Mechanism's name. For the ArmSubsystem in the Arm tutorial, that is NT:/Mechanisms/Arm/ArmMotor/..., NT:/Tuning/Arm/ArmMotor/... and NT:/Tuning/ArmSubsystem/Live Tuning. See Live tuning for how to use the tunable side.

The Mechanism2d window

Every mechanism draws itself in a Mechanism2d, at NT:/Mechanisms/<Mechanism>/mechanism. It is the window you open in the Sim GUI or AdvantageScope in the tutorials' "Simulate it" step. In simulation the mechanism publishes it again on every simIterate(), so the drawing moves with the mechanism. It is published on the real robot too, but everything it shows is also in the numeric values, so you don't need it there.

The Sim GUI window /Mechanisms/Arm/mechanism for the Arm tutorial's arm, at its starting angle of minus 5 degrees. The arm is an orange line from the center of the window to its right edge, with a thinner white setpoint line on top of it. An enlarged view of the pivot shows four short lines: green and pink above the arm for the upper hard and soft limits, and yellow and red below it for the lower soft and hard limits.
The Arm tutorial's arm in the Sim GUI, with the pivot enlarged on the right.

Besides the mechanism itself, it draws a white line for the setpoint and short lines at its limits:

Color
Shows

White

The setpoint

Green

The upper hard limit

Red

The lower hard limit

Pink

The upper soft limit

Yellow

The lower soft limit

Use them to see at a glance whether the mechanism is heading where you asked, and how close it is to its limits.

Choosing what a motor publishes

There are two ways to choose: pick a verbosity level, or pick the fields yourself.

Verbosity levels

withTelemetry(name, TelemetryVerbosity) is the quick way. Each level includes the one before it.

Three nested boxes. The outer box is HIGH, which contains MID, which contains LOW. LOW publishes positions and velocities. MID is everything in LOW plus the output voltage and the stator and supply currents. HIGH is everything in MID plus everything tunable: gains, limits and ramp rates, the motor temperature, status booleans and the Live Tuning command
HIGH includes MID, and MID includes LOW.
Level
Adds
Good for

LOW

Positions, velocities and accelerations (mechanism/*, measurement/*, rotor/*, and externalencoder/* when there is an external encoder), the setpoints (closedloop/setpoint/*) and the active slot

Competition, where you only need to see what happened

MID

motor/outputVoltage, current/stator, current/supply

Checking power draw

HIGH

Every tunable value, motor/temperature, closedloop/period, the status booleans, and the Live Tuning command

Tuning and development

Choosing fields yourself

Build a SmartMotorControllerTelemetryConfig and enable only what you want:

A fragment from an arm subsystem:

withCustom(...) covers everything else. Use it for a field with no with*() method of its own, or to switch several fields in one call. It takes a BooleanTelemetryField or DoubleTelemetryField, or an array of either, and a boolean:

In C++ the methods are WithCustom(field, enabled) and WithCustom(std::vector, enabled). The Java classes are in yams.core.telemetry, and TelemetryVerbosity is in yams.core.telemetry.enums.

The SmartMotorControllerTelemetryConfig javadoc lists every method.

Recording a match to a DataLog

NetworkTables only shows what is happening now. To look back at a match afterwards, also send the same values to a DataLog file on the SystemCore.

Your mechanism feeds MechanismTelemetry, which publishes the same values to NetworkTables, live and on by default and read by dashboards, and to a DataLog file, enabled with withDataLogName and opened in AdvantageScope after the match
One set of values, two places to send them.
Destination
On by default?
Turn it on or off with
Use it for

NetworkTables (NT4)

Yes

withoutNetworkTables() turns it off

Watching and tuning live

DataLog file

No

withDataLogName(name) turns it on

Reviewing a match afterwards

Both are set on SmartMotorControllerTelemetryConfig. MechanismTelemetry does the work: every mechanism, and every SwerveModule, owns one, and it sends the same values to both destinations.

To record the arm from the Arm tutorial, give its motor a telemetry config with a DataLog name, in place of the TelemetryVerbosity it was given:

SmartMotorControllerTelemetryConfig is in yams.core.telemetry.

Every field the config turns on is then also written to the DataLog under Arm/ArmMotor. Only the values you read are logged; the values you can type under NT:/Tuning are not. To log during matches without filling NetworkTables, add .withoutNetworkTables() to the telemetry config. Live tuning then has nothing to edit, so leave it off while you tune.

A DataLog uses storage on the SystemCore, and logging everything fills it quickly. Log only what you need. See the WPILib DataLog docs.

Swerve drive telemetry

A swerve drive publishes poses, chassis velocities and module states. Those are not single numbers, so they are published as NT4 structs that AdvantageScope understands directly.

The NetworkTables tree for a swerve drive named swerve: pose and gyro at LOW verbosity, chassis/current, chassis/field and states/current at MID, chassis/desired and states/desired at HIGH, the tuning command, and a modules table with one entry per module holding its absolute encoder, its state and its drive and azimuth motors
What a swerve drive publishes, and at which verbosity.

Setting it up

SwerveDrive and SwerveModule have their own telemetry configs. They work the same way as a motor's: every field is off until a verbosity level or a with*() method turns it on.

Config
Passed to
Notable fields

SwerveDriveTelemetryConfig

SwerveDriveConfig.withTelemetry(name, config)

withPose(), withGyro(), withCurrentModuleStates(), withDesiredModuleStates()

SwerveModuleTelemetryConfig

SwerveModuleConfig.withTelemetry(name, config)

withAbsoluteEncoder(), withState()

new SwerveDriveTelemetryConfig(TelemetryVerbosity.HIGH) is shorthand for new SwerveDriveTelemetryConfig().withTelemetryVerbosity(TelemetryVerbosity.HIGH). SwerveModuleTelemetryConfig has the same shorthand.

Things that differ from a motor

  • The name is required. SwerveDriveConfig.withTelemetry(...) always takes the name first: withTelemetry(name, TelemetryVerbosity) or withTelemetry(name, SwerveDriveTelemetryConfig). There is no withTelemetryName(...).

  • DataLog is set on the telemetry config. SwerveDriveConfig and SwerveModuleConfig have no withDataLogName(...). Use SwerveDriveTelemetryConfig.withDataLogName(...) and SwerveModuleTelemetryConfig.withDataLogName(...).

  • A module's state is HIGH only. At LOW and MID a module publishes only its absolute encoder angle.

  • The motors are configured separately. Neither swerve config reaches the drive and azimuth motors inside a module. Give each motor's SmartMotorControllerConfig its own .withTelemetry(name, SmartMotorControllerTelemetryConfig), as for any other motor. See DataLog Best Practices.

  • withCustom(...) works here too. It takes a DoubleTelemetryField, StructTelemetryField, StructArrayTelemetryField or BooleanTelemetryField, or an array of one, and a boolean.

WPILib 2027 renamed ChassisSpeeds to ChassisVelocities and SwerveModuleState to SwerveModuleVelocity. The YAMS method and telemetry field names (withDesiredModuleStates(), setSwerveModuleStates(...), withFieldRelativeChassisSpeeds()) kept their old spelling.

How struct telemetry works: StructTelemetry and StructArrayTelemetry

SmartMotorControllerTelemetry publishes plain numbers and booleans with DoubleTelemetry and BooleanTelemetry. Swerve telemetry is built on two generic counterparts:

Class
Publishes
Used for

StructTelemetry<T>

One struct value

Pose2d, ChassisVelocities, one SwerveModuleVelocity

StructArrayTelemetry<T>

An array of struct values

The four module SwerveModuleVelocity[] fields

Both behave like DoubleTelemetry: they can be enabled per field, sent to NetworkTables and to a DataLog, and, for fields marked tunable, read back a value edited on the dashboard. You do not normally construct them yourself. The swerve telemetry configs create and manage them.

Live tuning

At HIGH verbosity SwerveDriveTelemetryConfig also publishes tunable keys for auto-align and for the drive and azimuth motors under NT:/Tuning/<name>/. See Tune a swerve drive for the keys and how to use them.

Units

Values you read under NT:/Mechanisms are in rotations and rotations per second, or meters and meters per second for a mechanism with a circumference. Values you type under NT:/Tuning are in degrees and RPM, or meters. AdvantageScope can show any value in other units: right-click it in a graph legend and choose Convert Units....

Live tuning keys and units lists the unit of every key.

Next

Last updated

Was this helpful?