Package org.team1126.lib.tunable
Class Tunables
java.lang.Object
org.team1126.lib.tunable.Tunables
The Tunables class is used to construct tunable properties
of the robot to be modified live via NetworkTables.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceBase interface for tunable objects.static final classA tunable boolean value.static final classA tunable double value.static final classA tunable float value.static interfaceInterface for wrapping objects to be tunable.static final classA tunable integer value.static final classA tunable string value. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TAdds an object to be tuned.static TunableTableGets a table that can be used to add nested tunable values under a specified path.static <T> voidregisterHandler(Class<T> clazz, Tunables.TunableHandler<T> handler) Registers a handler for tuning objects.static voidupdate()Polls changes from NetworkTables.static Tunables.TunableBooleanCreates a tunable boolean value.static Tunables.TunableBooleanCreates a tunable boolean value.static Tunables.TunableDoubleCreates a tunable double value.static Tunables.TunableDoublevalue(String name, double defaultValue, DoubleConsumer onChange) Creates a tunable double value.static Tunables.TunableFloatCreates a tunable float value.static Tunables.TunableFloatCreates a tunable float value.static Tunables.TunableIntegerCreates a tunable integer value.static Tunables.TunableIntegervalue(String name, int defaultValue, IntConsumer onChange) Creates a tunable integer value.static Tunables.TunableStringCreates a tunable string value.static Tunables.TunableStringCreates a tunable string value.
-
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 utilizingLoggedRobot). -
registerHandler
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
Gets a table that can be used to add nested tunable values under a specified path.- Parameters:
name- The name of the table.
-
add
Adds an object to be tuned. The specified object must implementTunables.Tunable, or have a registeredTunables.TunableHandlerin 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
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
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
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
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
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
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.
-