Class Telemetry

java.lang.Object
frc.spectrumLib.telemetry.Telemetry

public class Telemetry extends Object
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. Logger is 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 (see Swerve'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

  • Field Details

    • SLOW_LOG_PERIOD_SECONDS

      public static final double SLOW_LOG_PERIOD_SECONDS
      Seconds between slow-tier publishes (10 Hz at any loop rate).
      See Also:
    • NT_MIRROR_SWITCH_KEY

      public static final String 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()
      Returns true on 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

      public static void start(Telemetry.PrintPriority priority)
      Sets the console print priority. Data receivers and the replay source are configured in Robot before Logger.start(), not here.
      Parameters:
      priority - The minimum priority level for console output.
    • log

      public static void log(String key, double value)
    • log

      public static void log(String key, double value, String unit)
    • log

      public static void log(String key, float value)
    • log

      public static void log(String key, boolean value)
    • log

      public static void log(String key, int value)
    • log

      public static void log(String key, long value)
    • log

      public static void log(String key, String value)
    • log

      public static void log(String key, double[] value)
    • log

      public static void log(String key, boolean[] value)
    • log

      public static void log(String key, long[] value)
    • log

      public static void log(String key, int[] value)
    • log

      public static void log(String key, String[] value)
    • log

      public static <E extends Enum<E>> void log(String key, E value)
    • log

      public static <T extends WPISerializable> void log(String key, T value)
    • log

      @SafeVarargs public static <T extends StructSerializable> void log(String key, T... value)
    • log

      public static <U extends Unit> void log(String key, Measure<U> value)
    • 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

      public static boolean isDashboardKey(String key)
      Whether an output key (relative to the outputs table) is a dashboard key.
    • isDashboardTableKey

      public static boolean isDashboardTableKey(String tableKey)
      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

      public static void addDashboardKey(String key)
      Marks a key for NetworkTables, e.g. one a dashboard layout reads.
    • addDashboardKeysFromElasticLayout

      public static int addDashboardKeysFromElasticLayout(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. Topics under /AdvantageKit/RealOutputs/ become output keys.
      Parameters:
      layoutJson - the layout file's contents
      Returns:
      how many keys were added
    • logDash

      public static void logDash(String key, double value)
    • logDash

      public static void logDash(String key, double value, String unit)
    • logDash

      public static void logDash(String key, boolean value)
    • logDash

      public static void logDash(String key, String value)
    • logDash

      public static void logDash(String key, long value)
    • logDashAlways

      public static void logDashAlways(String key, double value)
    • logDashAlways

      public static void logDashAlways(String key, double value, String unit)
    • logDashAlways

      public static void logDashAlways(String key, boolean value)
    • logDashAlways

      public static void logDashAlways(String key, String value)
    • logDashAlways

      public static void logDashAlways(String key, long value)
    • time

      public static void time(String key)
      Starts a timed span. Pair with timeEnd(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

      public static void timeEnd(String key)
      Ends a timed span and logs its length in seconds, so existing analysis of the Scheduler/* keys keeps working.
      Parameters:
      key - the key passed to time(String)
    • logEvent

      public static void logEvent(String key, String message)
      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 key
      message - the event
    • log

      public static Command log(Command cmd)
      Wraps a command so that its initialization and end are logged to the "Commands" key.
      Parameters:
      cmd - The command to wrap
      Returns:
      a decorated command that logs lifecycle events and preserves the original name
    • print

      public static void print(String output, Telemetry.PrintPriority priority)
      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

      public static void print(String output)
      Prints a message at Telemetry.PrintPriority.NORMAL priority.
      Parameters:
      output - The string to print