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.

Elevator with a motor named ElevatorMotor.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.

Besides the mechanism itself, it draws a white line for the setpoint and short lines at its limits:
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.

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.

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.
DataLog Best Practices: choosing what to log, and how it works for
SwerveDrive.How do I view my DataLog in AdvantageScope?: a step by step walkthrough.
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.

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.
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)orwithTelemetry(name, SwerveDriveTelemetryConfig). There is nowithTelemetryName(...).DataLog is set on the telemetry config.
SwerveDriveConfigandSwerveModuleConfighave nowithDataLogName(...). UseSwerveDriveTelemetryConfig.withDataLogName(...)andSwerveModuleTelemetryConfig.withDataLogName(...).A module's state is
HIGHonly. AtLOWandMIDa 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
SmartMotorControllerConfigits own.withTelemetry(name, SmartMotorControllerTelemetryConfig), as for any other motor. See DataLog Best Practices.withCustom(...)works here too. It takes aDoubleTelemetryField,StructTelemetryField,StructArrayTelemetryFieldorBooleanTelemetryField, or an array of one, and a boolean.
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
Watch your mechanism while you tune it: Step 5: Tune it
Review a match afterwards: How do I view my DataLog in AdvantageScope?
Last updated
Was this helpful?
