Class Telemetry

java.lang.Object
dev.doglog.DogLog
frc.spectrumLib.telemetry.Telemetry
All Implemented Interfaces:
Subsystem

public class Telemetry extends DogLog implements Subsystem
Telemetry and logging utility. Extends DogLog to provide structured logging and console output with priority levels.

Three tiers:

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.

  • Field Details

    • NT_MIRROR_SWITCH_KEY

      public static final String 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_LOOPS
      Loops 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()
      Specified by:
      periodic in interface Subsystem
    • 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. false for the robot; flip it in Elastic when AdvantageScope needs the full live stream
    • 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)
      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

      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)
    • logState

      public static void logState(String key, Enum<?> state)
      Logs a state machine's state when it changes: the exact loop of every transition, nothing while it holds.
    • logStateDash

      public static void logStateDash(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, so logDash(java.lang.String, double) could miss it).
    • time

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

      public static void timeEnd(String key)
      Ends a timed span and logs its length in seconds, matching the units DogLog's timer used, so existing analysis of the Scheduler/* keys keeps working.
    • log

      public static Command log(Command cmd)
      Wraps a command so that its initialization and end are logged to the "Commands" key. The wrapper keeps the original name.
    • print

      public static void print(String output, Telemetry.PrintPriority priority)
      Echoes to the console when the priority allows, and always logs to the "Prints" key.
    • print

      public static void print(String output)
      Prints a message at Telemetry.PrintPriority.NORMAL priority. 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 under SmartDashboard/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.