Class Telemetry
java.lang.Object
frc.spectrumLib.telemetry.Telemetry
Telemetry and logging facade, backed by AdvantageKit.
In 2026 this class extended DogLog. On SystemCore it keeps the same static API (log,
logDash, logDashAlways, print, time/timeEnd,
slowLogThisLoop), so every existing call site compiles unchanged. Every value is now an
AdvantageKit output (Logger.recordOutput(String, byte[])). Outputs land in the same wpilog as
the replayed inputs, under /RealOutputs/... on the robot and /ReplayOutputs/...
in replay, so a replayed match regenerates every one of these keys from the code under test.
Rules that come with AdvantageKit
- Main thread only.
Loggeris not thread-safe. Nothing on a Notifier, the CTRE odometry thread or a vision callback may call this class; hand the data to the main loop and log it there (seeSwerve's odometry queue). - Outputs never drive logic. Anything a decision depends on must come from a logged
input (
Logger.processInputs(String, LoggableInputs)), or replay will diverge.
Tiers
log(String, double)records to the log only.logDash(String, double)/logDashAlways(String, double)record to the log and mark the key as a dashboard key, whichDashboardReceiveralso sends to NetworkTables. Only dashboard keys (these, and every key the Elastic layout reads) go to NT, unless the "/SmartDashboard/Telemetry/MirrorLogsToNT" switch is on. That is the 2026 offseason rule, for the CPU it costs.slowLogThisLoop()is true at 10 Hz whatever the loop rate. Wrap logs that do not need loop-rate resolution (currents, temperatures, vision status) in it.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumNamed fault conditions that can be surfaced as structured log entries.static enumPriority levels for printing to the console. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDashboard key of the switch that mirrors every log entry to NetworkTables.static final doubleSeconds between slow-tier publishes (10 Hz at any loop rate). -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddDashboardKey(String key) Marks a key for NetworkTables, e.g.static intaddDashboardKeysFromElasticLayout(String layoutJson) Marks every output the Elastic layout reads as a dashboard key, so what Elastic shows is exactly what goes over NetworkTables and the two cannot drift apart.static booleanisDashboardKey(String key) Whether an output key (relative to the outputs table) is a dashboard key.static booleanisDashboardTableKey(String tableKey) Whether an absolute log-table key (/RealOutputs/<key>) is a dashboard key.static booleanWhether every output is being mirrored to NetworkTables right now.static voidstatic voidstatic voidstatic voidstatic voidstatic voidstatic voidstatic voidstatic voidstatic voidstatic <E extends Enum<E>>
voidstatic voidstatic voidstatic <U extends Unit>
voidstatic <T extends WPISerializable>
voidstatic <T extends StructSerializable>
voidstatic CommandWraps a command so that its initialization and end are logged to the "Commands" key.static voidstatic voidstatic voidstatic voidstatic voidstatic voidlogDashAlways(String key, boolean value) static voidlogDashAlways(String key, double value) static voidlogDashAlways(String key, double value, String unit) static voidlogDashAlways(String key, long value) static voidlogDashAlways(String key, String value) static voidLogs a discrete event.static voidperiodic()Updates the mirror switch.static voidPrints a message atTelemetry.PrintPriority.NORMALpriority.static voidprint(String output, Telemetry.PrintPriority priority) Print a statement if the priority allows it.static booleanReturnstrueon the loops the slow telemetry tier publishes on.static voidstart(Telemetry.PrintPriority priority) Sets the console print priority.static voidstartDashboard(boolean mirrorByDefault) Creates the mirror switch.static voidStarts a timed span.static voidEnds a timed span and logs its length in seconds, so existing analysis of theScheduler/*keys keeps working.
-
Field Details
-
SLOW_LOG_PERIOD_SECONDS
public static final double SLOW_LOG_PERIOD_SECONDSSeconds between slow-tier publishes (10 Hz at any loop rate).- See Also:
-
NT_MIRROR_SWITCH_KEY
Dashboard key of the switch that mirrors every log entry to NetworkTables. Forced off when the FMS is attached.- See Also:
-
-
Method Details
-
slowLogThisLoop
public static boolean slowLogThisLoop()Returnstrueon the loops the slow telemetry tier publishes on. Every caller in the same loop agrees, so related values are logged in the same cycle.- Returns:
- whether slow-tier values should be logged this loop
-
start
Sets the console print priority. Data receivers and the replay source are configured inRobotbeforeLogger.start(), not here.- Parameters:
priority- The minimum priority level for console output.
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
startDashboard
public static void startDashboard(boolean mirrorByDefault) Creates the mirror switch. Call once, after the logger has started.- Parameters:
mirrorByDefault- initial position: on in simulation, off on the robot
-
periodic
public static void periodic()Updates the mirror switch. Call once per loop. -
isMirroringAll
public static boolean isMirroringAll()Whether every output is being mirrored to NetworkTables right now. -
isDashboardKey
Whether an output key (relative to the outputs table) is a dashboard key. -
isDashboardTableKey
Whether an absolute log-table key (/RealOutputs/<key>) is a dashboard key. For the NetworkTables receiver, which walks the whole table every cycle: one hash lookup per entry, no substring. -
addDashboardKey
Marks a key for NetworkTables, e.g. one a dashboard layout reads. -
addDashboardKeysFromElasticLayout
Marks every output the Elastic layout reads as a dashboard key, so what Elastic shows is exactly what goes over NetworkTables and the two cannot drift apart. Topics under/AdvantageKit/RealOutputs/become output keys.- Parameters:
layoutJson- the layout file's contents- Returns:
- how many keys were added
-
logDash
-
logDash
-
logDash
-
logDash
-
logDash
-
logDashAlways
-
logDashAlways
-
logDashAlways
-
logDashAlways
-
logDashAlways
-
time
Starts a timed span. Pair withtimeEnd(String)on the same key.Uses the real clock, not
Logger.getTimestamp(), because the point is to measure how long the code took. In replay these values describe the replay machine, not the robot.- Parameters:
key- the log key the elapsed time will be written to
-
timeEnd
Ends a timed span and logs its length in seconds, so existing analysis of theScheduler/*keys keeps working.- Parameters:
key- the key passed totime(String)
-
logEvent
Logs a discrete event. AdvantageKit keeps one value per key per cycle. Logging two messages to the same key in one loop kept only the second, so two commands ending in the same loop, or two prints, lost one. Events are accumulated per loop and recorded as a string array holding all of them.- Parameters:
key- the log keymessage- the event
-
log
-
print
Print a statement if the priority allows it. AdvantageKit captures the console into the log, so the text is also recorded; it is additionally logged under "Prints" for search. -
print
Prints a message atTelemetry.PrintPriority.NORMALpriority.- Parameters:
output- The string to print
-