Class DoubleTelemetry<F>

java.lang.Object
yams.core.telemetry.DoubleTelemetry<F>
Type Parameters:
F - Enum type identifying which field this telemetry entry represents.

public class DoubleTelemetry<F> extends Object
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&lt;DoubleTelemetryField&gt; velocity = new DoubleTelemetry&lt;&gt;(
    "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
    Modifier and Type
    Field
    Description
    protected boolean
    Enabled?
  • Constructor Summary

    Constructors
    Constructor
    Description
    DoubleTelemetry(String keyString, double defaultVal, F field, boolean tunable, String unit)
    Setup double telemetry for a field.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Close the telemetry field.
    void
    Disable the telemetry.
    void
    display(boolean state)
    Display the telemetry.
    void
    Enable the telemetry.
    void
    forceSet(double value)
    Forcibly overwrite the tunable value in NetworkTables, bypassing the subscriber-must-match guard in set(double).
    double
    get()
    Get the value.
    Get the field.
    boolean
    set(double value)
    Set the value of the publisher, checking to see if the value is the same as the subscriber.
    void
    setDefaultValue(double defaultValue)
    Set default values.
    void
    Setup the DataLog with this entry.
    void
    setupNetworkTable(org.wpilib.networktables.NetworkTable dataTable)
    Setup network tables.
    void
    setupNetworkTables(org.wpilib.networktables.NetworkTable dataTable, org.wpilib.networktables.NetworkTable tuningTable)
    Setup network tables.
    Set the unit.
    boolean
    Check to see if the value has changed.

    Methods inherited from class Object

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

    • enabled

      protected boolean enabled
      Enabled?
  • Constructor Details

    • DoubleTelemetry

      public DoubleTelemetry(String keyString, double defaultVal, F field, boolean tunable, String unit)
      Setup double telemetry for a field.
      Parameters:
      keyString - Key to use.
      defaultVal - Default value.
      field - Field representing.
      tunable - Tunable.
      unit - Unit to display.
  • 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

      public void setupDataLog(String prefix)
      Setup the DataLog with this entry.
      Parameters:
      prefix - The prefix to this entry in DataLog
    • transformUnit

      public DoubleTelemetry transformUnit(SmartMotorControllerConfig<?> cfg)
      Set the unit.
      Parameters:
      cfg - SmartMotorControllerConfig used to determine the unit. If the MechanismCircumference is set it will be in meters, else it will be in degrees.
      Returns:
      DoubleTelemetry for 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 in set(double). The next tunable() 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 and setupNetworkTables(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

      public F getField()
      Get the field.
      Returns:
      field.
    • close

      public void close()
      Close the telemetry field.