Class TelemetryTable

java.lang.Object
org.wpilib.telemetry.TelemetryTable

public final class TelemetryTable 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.

  • Constructor Details

    • TelemetryTable

      public TelemetryTable(TelemetryBackend backend)
      Constructs a root telemetry table that writes directly to a backend without using the global telemetry registry.
      Parameters:
      backend - telemetry backend
  • Method Details

    • getPath

      public String getPath()
      Gets the table path.
      Returns:
      path with trailing "/"
    • setType

      public boolean setType(String typeString)
      Sets the table type. TelemetryLoggable implementations can use this function to communicate the type of data in the table. Callers should check the return value and not log data if false is returned.
      Parameters:
      typeString - type string
      Returns:
      False if type mismatch.
    • getType

      public String getType()
      Gets the table type.
      Returns:
      Table type as set by setType(), or null if none set.
    • getTable

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

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

      public 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 <T> void log(String name, T 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.

      Type Parameters:
      T - data type
      Parameters:
      name - the name
      value - the value; must be non-null
    • log

      public <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 <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 <T> void log(String name, T[] value)
      Logs a generic array.

      Byte arrays are logged as raw byte arrays.

      Type Parameters:
      T - data type
      Parameters:
      name - the name
      value - the value
    • log

      public <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 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 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. StructSerializable 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 <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 void log(String name, boolean value)
      Logs a boolean.
      Parameters:
      name - the name
      value - the value
    • log

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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