Class Tunables

java.lang.Object
org.team1126.lib.tunable.Tunables

public final class Tunables extends Object
The Tunables class is used to construct tunable properties of the robot to be modified live via NetworkTables.
  • Constructor Details

    • Tunables

      public Tunables()
  • Method Details

    • update

      public static void update()
      Polls changes from NetworkTables. Must be called periodically in order for Tunables to function (this is already done if utilizing LoggedRobot).
    • registerHandler

      public static <T> void registerHandler(Class<T> clazz, Tunables.TunableHandler<T> handler)
      Registers a handler for tuning objects.
      Type Parameters:
      T - The object's class.
      Parameters:
      clazz - The object's class.
      handler - The handler for the object.
    • getNested

      public static TunableTable getNested(String name)
      Gets a table that can be used to add nested tunable values under a specified path.
      Parameters:
      name - The name of the table.
    • add

      public static <T> T add(String name, T obj)
      Adds an object to be tuned. The specified object must implement Tunables.Tunable, or have a registered Tunables.TunableHandler in order for it to be added.
      Type Parameters:
      T - The object's class.
      Parameters:
      name - The name for the tunable. Must be unique.
      obj - The object to be tuned.
      Returns:
      The provided object.
    • value

      public static Tunables.TunableBoolean value(String name, boolean defaultValue)
      Creates a tunable boolean value.
      Parameters:
      name - The name for the tunable value. Must be unique.
      defaultValue - The default value of the tunable (e.g. a programmed constant).
    • value

      public static Tunables.TunableBoolean value(String name, boolean defaultValue, edu.wpi.first.util.function.BooleanConsumer onChange)
      Creates a tunable boolean value.
      Parameters:
      name - The name for the tunable value. Must be unique.
      defaultValue - The default value of the tunable (e.g. a programmed constant).
      onChange - A consumer that is invoked when the value of the tunable is modified.
    • value

      public static Tunables.TunableInteger value(String name, int defaultValue)
      Creates a tunable integer value.
      Parameters:
      name - The name for the tunable value. Must be unique.
      defaultValue - The default value of the tunable (e.g. a programmed constant).
    • value

      public static Tunables.TunableInteger value(String name, int defaultValue, IntConsumer onChange)
      Creates a tunable integer value.
      Parameters:
      name - The name for the tunable value. Must be unique.
      defaultValue - The default value of the tunable (e.g. a programmed constant).
      onChange - A consumer that is invoked when the value of the tunable is modified.
    • value

      public static Tunables.TunableFloat value(String name, float defaultValue)
      Creates a tunable float value.
      Parameters:
      name - The name for the tunable value. Must be unique.
      defaultValue - The default value of the tunable (e.g. a programmed constant).
    • value

      public static Tunables.TunableFloat value(String name, float defaultValue, edu.wpi.first.util.function.FloatConsumer onChange)
      Creates a tunable float value.
      Parameters:
      name - The name for the tunable value. Must be unique.
      defaultValue - The default value of the tunable (e.g. a programmed constant).
      onChange - A consumer that is invoked when the value of the tunable is modified.
    • value

      public static Tunables.TunableDouble value(String name, double defaultValue)
      Creates a tunable double value.
      Parameters:
      name - The name for the tunable value. Must be unique.
      defaultValue - The default value of the tunable (e.g. a programmed constant).
    • value

      public static Tunables.TunableDouble value(String name, double defaultValue, DoubleConsumer onChange)
      Creates a tunable double value.
      Parameters:
      name - The name for the tunable value. Must be unique.
      defaultValue - The default value of the tunable (e.g. a programmed constant).
      onChange - A consumer that is invoked when the value of the tunable is modified.
    • value

      public static Tunables.TunableString value(String name, String defaultValue)
      Creates a tunable string value.
      Parameters:
      name - The name for the tunable value. Must be unique.
      defaultValue - The default value of the tunable (e.g. a programmed constant).
    • value

      public static Tunables.TunableString value(String name, String defaultValue, Consumer<String> onChange)
      Creates a tunable string value.
      Parameters:
      name - The name for the tunable value. Must be unique.
      defaultValue - The default value of the tunable (e.g. a programmed constant).
      onChange - A consumer that is invoked when the value of the tunable is modified.