Class Telemetry

java.lang.Object
org.wpilib.telemetry.Telemetry

public final class Telemetry extends Object
Telemetry sends information from the robot program to dashboards, debug tools, or log files.

For more advanced use cases, use the NetworkTables or DataLog APIs directly.

  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the root telemetry table.
    Gets a child telemetry table.
    static void
    Indicates duplicate values should be preserved.
    static void
    log(String name, boolean value)
    Logs a boolean.
    static void
    log(String name, boolean[] value)
    Logs a boolean array.
    static void
    log(String name, byte value)
    Logs a byte.
    static void
    log(String name, byte[] value)
    Logs a raw value (byte array).
    static void
    log(String name, byte[] value, String typeString)
    Logs a raw value (byte array) with custom type string.
    static void
    log(String name, double value)
    Logs a double.
    static void
    log(String name, double[] value)
    Logs a double array.
    static void
    log(String name, float value)
    Logs a float.
    static void
    log(String name, float[] value)
    Logs a float array.
    static void
    log(String name, int value)
    Logs an int.
    static void
    log(String name, int[] value)
    Logs an int array.
    static void
    log(String name, long value)
    Logs a long.
    static void
    log(String name, long[] value)
    Logs a long array.
    static void
    log(String name, short value)
    Logs a short.
    static void
    log(String name, short[] value)
    Logs a short array.
    static void
    log(String name, Object value)
    Logs a generic object.
    static void
    log(String name, Object[] value)
    Logs a generic array.
    static void
    log(String name, String value)
    Logs a String.
    static void
    log(String name, String[] value)
    Logs a String array.
    static void
    log(String name, String value, String typeString)
    Logs a String with custom type string.
    static void
    log(String name, Collection<?> value)
    Rejects logging a collection without an explicit element type.
    static void
    log(String name, Collection<?> value, Class<?> elementType)
    Logs a collection with an explicit element type.
    static <T> void
    log(String name, Collection<T> value, Struct<? super T> struct)
    Logs a collection of objects with a Struct serializer.
    static <T> void
    log(String name, T[] value, Struct<? super T> struct)
    Logs an array of objects with a Struct serializer.
    static <T> void
    log(String name, T value, Protobuf<? super T, ?> proto)
    Logs an object with a Protobuf serializer.
    static <T> void
    log(String name, T value, Struct<? super T> struct)
    Logs an object with a Struct serializer.
    static void
    setProperty(String name, String key, String value)
    Sets property for a value.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getTable

      public static TelemetryTable getTable()
      Gets the root telemetry table.
      Returns:
      table
    • getTable

      public static TelemetryTable getTable(String name)
      Gets a child telemetry table.
      Parameters:
      name - table name
      Returns:
      table
    • keepDuplicates

      public static void keepDuplicates(String name)
      Indicates duplicate values should be preserved. Normally duplicate values are ignored.
      Parameters:
      name - the name
    • setProperty

      public static void setProperty(String name, String key, String value)
      Sets property for a value. Properties are stored as a key/value map.
      Parameters:
      name - the name
      key - property key
      value - property value
    • log

      public static void log(String name, Object value)
      Logs a generic object.

      For non-null values, the value is dispatched in this order: TelemetryLoggable, StructSerializable, ProtobufSerializable, boxed primitive and string types, and finally handlers registered with TelemetryRegistry.registerTypeHandler(Class, TelemetryRegistry.TypeHandler). TelemetryLoggable values are logged to a child table named name. Struct and protobuf serializable values are logged with their public static struct or proto serializers. Boolean, Float, Double, Byte, Short, Integer, Long, other Number values, and String are logged as primitive or string entries. Generic Number values other than boxed integral types are logged as double entries. If no registered handler matches, the value falls back to being logged as a string using Object.toString(). Collection values must be logged with an explicit element type.

      Parameters:
      name - the name
      value - the value; must be non-null
    • log

      public static <T> void log(String name, T value, Struct<? super T> struct)
      Logs an object with a Struct serializer.
      Type Parameters:
      T - data type
      Parameters:
      name - the name
      value - the value
      struct - struct serializer for the value type or one of its supertypes
    • log

      public static <T> void log(String name, T value, Protobuf<? super T, ?> proto)
      Logs an object with a Protobuf serializer.
      Type Parameters:
      T - data type
      Parameters:
      name - the name
      value - the value
      proto - protobuf serializer for the value type or one of its supertypes
    • log

      public static void log(String name, Object[] value)
      Logs a generic array.

      Byte arrays are logged as raw byte arrays.

      Parameters:
      name - the name
      value - the value
    • log

      public static <T> void log(String name, T[] value, Struct<? super T> struct)
      Logs an array of objects with a Struct serializer.
      Type Parameters:
      T - data type
      Parameters:
      name - the name
      value - the value
      struct - struct serializer for the value type or one of its supertypes
    • log

      public static void log(String name, Collection<?> value) throws CollectionElementTypeRequiredException
      Rejects logging a collection without an explicit element type.

      Use log(String, Collection, Class) or log(String, Collection, Struct) instead.

      Parameters:
      name - the name
      value - the value
      Throws:
      CollectionElementTypeRequiredException - always
    • log

      public static <T> void log(String name, Collection<T> value, Struct<? super T> struct)
      Logs a collection of objects with a Struct serializer.
      Type Parameters:
      T - data type
      Parameters:
      name - the name
      value - the value
      struct - struct serializer for the value type or one of its supertypes
    • log

      public static void log(String name, Collection<?> value, Class<?> elementType)
      Logs a collection with an explicit element type.

      The element type selects the backend representation. Byte element types are logged as raw byte arrays. Boolean, Float, Double, and String element types are logged like arrays of the same element type. Number and other non-integral number element types are logged as double arrays. Short, Integer, and Long element types are logged as integer arrays. Struct-serializable element types are logged with their public static struct serializer. Other element types fall back to string arrays using Object.toString().

      Parameters:
      name - the name
      value - the value
      elementType - the collection element type
    • log

      public static void log(String name, boolean value)
      Logs a boolean.
      Parameters:
      name - the name
      value - the value
    • log

      public static void log(String name, byte value)
      Logs a byte.
      Parameters:
      name - the name
      value - the value
    • log

      public static void log(String name, short value)
      Logs a short.
      Parameters:
      name - the name
      value - the value
    • log

      public static void log(String name, int value)
      Logs an int.
      Parameters:
      name - the name
      value - the value
    • log

      public static void log(String name, long value)
      Logs a long.
      Parameters:
      name - the name
      value - the value
    • log

      public static void log(String name, float value)
      Logs a float.
      Parameters:
      name - the name
      value - the value
    • log

      public static void log(String name, double value)
      Logs a double.
      Parameters:
      name - the name
      value - the value
    • log

      public static void log(String name, String value)
      Logs a String.
      Parameters:
      name - the name
      value - the value
    • log

      public static void log(String name, String value, String typeString)
      Logs a String with custom type string.
      Parameters:
      name - the name
      value - the value
      typeString - the type string
    • log

      public static void log(String name, boolean[] value)
      Logs a boolean array.
      Parameters:
      name - the name
      value - the value
    • log

      public static void log(String name, short[] value)
      Logs a short array.
      Parameters:
      name - the name
      value - the value
    • log

      public static void log(String name, int[] value)
      Logs an int array.
      Parameters:
      name - the name
      value - the value
    • log

      public static void log(String name, long[] value)
      Logs a long array.
      Parameters:
      name - the name
      value - the value
    • log

      public static void log(String name, float[] value)
      Logs a float array.
      Parameters:
      name - the name
      value - the value
    • log

      public static void log(String name, double[] value)
      Logs a double array.
      Parameters:
      name - the name
      value - the value
    • log

      public static void log(String name, String[] value)
      Logs a String array.
      Parameters:
      name - the name
      value - the value
    • log

      public static void log(String name, byte[] value)
      Logs a raw value (byte array).
      Parameters:
      name - the name
      value - the value
    • log

      public static void log(String name, byte[] value, String typeString)
      Logs a raw value (byte array) with custom type string.
      Parameters:
      name - the name
      value - the value
      typeString - the type string