Class Telemetry
- All Implemented Interfaces:
Subsystem
Three tiers:
log(edu.wpi.first.wpilibj2.command.Command)writes to the wpilog only. DogLog skips a record when the value has not changed, so a boolean or a state string costs nothing while it is steady; a double that moves every loop costs a record every loop.logDash(java.lang.String, double)also publishes the value to NetworkTables at 10 Hz, for the Driver Station dashboard and the robot app. Use it for exactly the keys a dashboard shows; the whole log is not mirrored to NetworkTables unless the mirror switch is on (seestart(boolean, boolean, boolean, boolean, boolean, boolean, frc.spectrumLib.telemetry.Telemetry.PrintPriority)).slowLogThisLoop()is true every fifth loop. Wrap logs that do not need loop-rate resolution (currents, temperatures, vision status) in it.
On 2026-09-05 a roboRIO ran at 92 to 95 percent CPU on a 30 ms loop while every record was mirrored to NetworkTables and flushed every 20 ms, which cost a core. These tiers cut the volume to what is actually read.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enumPriority levels for printing to the console. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringSmartDashboard key of the switch that mirrors every log entry to NetworkTables, for live AdvantageScope sessions in the shop.static final intLoops between slow-tier publishes: every fifth 20 ms loop is 10 Hz. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CommandWraps a command so that its initialization and end are logged to the "Commands" key.static voidLogs any alert newly published underSmartDashboard/Alerts(errors, warnings, infos) to the "Alerts" DogLog key.static voidstatic voidstatic voidstatic voidstatic voidstatic voidlogDashAlways(String key, boolean value) static voidlogDashAlways(String key, double value) Logs a double and publishes it to the dashboard on this very call.static voidlogDashAlways(String key, double value, String unit) static voidlogDashAlways(String key, long value) static voidlogDashAlways(String key, String value) static voidLogs a state machine's state when it changes: the exact loop of every transition, nothing while it holds.static voidlogStateDash(String key, Enum<?> state) logState(java.lang.String, java.lang.Enum<?>), also published to the dashboard on every change (a change can land between slow-tier ticks, sologDash(java.lang.String, double)could miss it).voidperiodic()static voidPrints a message atTelemetry.PrintPriority.NORMALpriority.static voidprint(String output, Telemetry.PrintPriority priority) Echoes to the console when the priority allows, and always logs to the "Prints" key.static booleanTrue on the loops the slow telemetry tier publishes on.static voidstart(boolean ntMirrorDefault, boolean captureDs, boolean captureNt, boolean captureConsole, boolean logExtras, boolean tunableOnFMS, Telemetry.PrintPriority priority) Starts the telemetry system.static voidStarts a timed span.static voidEnds a timed span and logs its length in seconds, matching the units DogLog's timer used, so existing analysis of theScheduler/*keys keeps working.Methods inherited from class dev.doglog.DogLog
clearFault, clearFault, decreaseFault, decreaseFault, faultsActive, faultsLogged, getOptions, isEnabled, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, logFault, logFault, logFault, setEnabled, setOptions, setPdh, time, timestamp, tunable, tunable, tunable, tunable, tunable, tunable, tunable, tunable, tunable, tunable, tunable, tunable, tunable, tunable, tunable, tunable, tunable, tunable, tunable, tunable, tunable, tunable, tunable, tunable, tunable, tunable, tunable, tunable, tunable, tunableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface edu.wpi.first.wpilibj2.command.Subsystem
defer, getCurrentCommand, getDefaultCommand, getName, idle, register, removeDefaultCommand, run, runEnd, runOnce, setDefaultCommand, simulationPeriodic, startEnd, startRun
-
Field Details
-
NT_MIRROR_SWITCH_KEY
SmartDashboard key of the switch that mirrors every log entry to NetworkTables, for live AdvantageScope sessions in the shop. Off by default; always off when the FMS is attached.- See Also:
-
SLOW_LOG_EVERY_LOOPS
public static final int SLOW_LOG_EVERY_LOOPSLoops between slow-tier publishes: every fifth 20 ms loop is 10 Hz.- See Also:
-
-
Constructor Details
-
Telemetry
public Telemetry()
-
-
Method Details
-
slowLogThisLoop
public static boolean slowLogThisLoop()True on the loops the slow telemetry tier publishes on. Every caller in the same loop agrees, so related values land on the same records. -
periodic
public void periodic() -
start
public static void start(boolean ntMirrorDefault, boolean captureDs, boolean captureNt, boolean captureConsole, boolean logExtras, boolean tunableOnFMS, Telemetry.PrintPriority priority) Starts the telemetry system.Values a dashboard needs are published to NetworkTables individually through
logDash(java.lang.String, double); everything else stays in the wpilog. Mirroring every entry is opt-in through the "Telemetry/MirrorLogsToNT" switch, and is forced off whenever the FMS is attached regardless of the switch.- Parameters:
ntMirrorDefault- initial position of the mirror-everything switch.falsefor the robot; flip it in Elastic when AdvantageScope needs the full live stream
-
logDash
-
logDash
-
logDash
-
logDash
-
logDash
-
logDashAlways
Logs a double and publishes it to the dashboard on this very call. For values logged on their own cadence (a timer, a state change) that must not wait for a slow-tier loop. -
logDashAlways
-
logDashAlways
-
logDashAlways
-
logDashAlways
-
logState
Logs a state machine's state when it changes: the exact loop of every transition, nothing while it holds. -
logStateDash
logState(java.lang.String, java.lang.Enum<?>), also published to the dashboard on every change (a change can land between slow-tier ticks, sologDash(java.lang.String, double)could miss it). -
time
Starts a timed span. Pair withtimeEnd(String)on the same key.Replaces DogLog's timer so the result reaches the dashboard: the
Scheduler/*spans are on the Elastic layout and are the primary record of loop time. -
timeEnd
Ends a timed span and logs its length in seconds, matching the units DogLog's timer used, so existing analysis of theScheduler/*keys keeps working. -
log
Wraps a command so that its initialization and end are logged to the "Commands" key. The wrapper keeps the original name. -
print
Echoes to the console when the priority allows, and always logs to the "Prints" key. -
print
Prints a message atTelemetry.PrintPriority.NORMALpriority. The message is always written to the DogLog "Prints" key but only echoed to stdout when the global priority allows it. -
logAlerts
public static void logAlerts()Logs any alert newly published underSmartDashboard/Alerts(errors, warnings, infos) to the "Alerts" DogLog key.Reads the subscribers' change queues rather than the current arrays, so a loop on which nothing changed does no NetworkTables read and allocates nothing.
-