Class DoubleTelemetry<F>
java.lang.Object
yams.core.telemetry.DoubleTelemetry<F>
- Type Parameters:
F- Enum type identifying which field this telemetry entry represents.
Double Telemetry for SmartMotorControllers.
A lightweight wrapper that publishes a single double value to NetworkTables and/or
a WPILib DataLog, with optional unit metadata consumed by Advantage Scope and Elastic. It is
used internally by SmartMotorControllerTelemetry to track numeric fields such as
position, velocity, current, and PID gains but it can also be constructed directly when
you need a standalone numeric entry.
Example
// Create and publish a double entry for shooter velocity under the Shooter table.
DoubleTelemetry<DoubleTelemetryField> velocity = new DoubleTelemetry<>(
"velocity", // NetworkTables key
0.0, // default value
SmartMotorControllerTelemetry.DoubleTelemetryField.MechanismVelocity,
false, // not tunable
"rotations_per_second"); // unit label
NetworkTable shooterTable = NetworkTableInstance.getDefault().getTable("Shooter");
velocity.enable();
velocity.setupNetworkTable(shooterTable);
// In periodic:
velocity.set(shooter.getVelocityRPS());
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDoubleTelemetry(String keyString, double defaultVal, F field, boolean tunable, String unit) Setup double telemetry for a field. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the telemetry field.voiddisable()Disable the telemetry.voiddisplay(boolean state) Display the telemetry.voidenable()Enable the telemetry.voidforceSet(double value) Forcibly overwrite the tunable value in NetworkTables, bypassing the subscriber-must-match guard inset(double).doubleget()Get the value.getField()Get the field.booleanset(double value) Set the value of the publisher, checking to see if the value is the same as the subscriber.voidsetDefaultValue(double defaultValue) Set default values.voidsetupDataLog(String prefix) Setup theDataLogwith this entry.voidsetupNetworkTable(org.wpilib.networktables.NetworkTable dataTable) Setup network tables.voidsetupNetworkTables(org.wpilib.networktables.NetworkTable dataTable, org.wpilib.networktables.NetworkTable tuningTable) Setup network tables.Set the unit.booleantunable()Check to see if the value has changed.
-
Field Details
-
enabled
protected boolean enabledEnabled?
-
-
Constructor Details
-
DoubleTelemetry
-
-
Method Details
-
setDefaultValue
public void setDefaultValue(double defaultValue) Set default values.- Parameters:
defaultValue- Default for the entry.
-
setupNetworkTables
public void setupNetworkTables(org.wpilib.networktables.NetworkTable dataTable, org.wpilib.networktables.NetworkTable tuningTable) Setup network tables.- Parameters:
dataTable- Data tables.tuningTable- Tuning table.
-
setupDataLog
Setup theDataLogwith this entry.- Parameters:
prefix- The prefix to this entry inDataLog
-
transformUnit
Set the unit.- Parameters:
cfg-SmartMotorControllerConfigused to determine the unit. If the MechanismCircumference is set it will be in meters, else it will be in degrees.- Returns:
DoubleTelemetryfor chaining.
-
setupNetworkTable
public void setupNetworkTable(org.wpilib.networktables.NetworkTable dataTable) Setup network tables.- Parameters:
dataTable- Data tables.
-
forceSet
public void forceSet(double value) Forcibly overwrite the tunable value in NetworkTables, bypassing the subscriber-must-match guard inset(double). The nexttunable()reports the change, as if it was made on the dashboard.- Parameters:
value- Value to force onto the tuning topic.
-
set
public boolean set(double value) Set the value of the publisher, checking to see if the value is the same as the subscriber.- Parameters:
value- Value to set.- Returns:
- True if value was able to be set.
-
get
public double get()Get the value.- Returns:
- value of telemetry.
- Throws:
RuntimeException- if the telemetry is enabled and this field is not tunable, so no tuning subscriber exists.RuntimeException- if the telemetry is enabled andsetupNetworkTables(NetworkTable, NetworkTable)was not called with a non-null tuning table, so no tuning subscriber exists.
-
tunable
public boolean tunable()Check to see if the value has changed.- Returns:
- True if the value has changed.
-
enable
public void enable()Enable the telemetry. -
disable
public void disable()Disable the telemetry. -
display
public void display(boolean state) Display the telemetry.- Parameters:
state- Enable or disable.
-
getField
-
close
public void close()Close the telemetry field.
-