Class SmartMotorControllerTelemetry
java.lang.Object
yams.core.telemetry.SmartMotorControllerTelemetry
Smart motor controller telemetry.
Publishes motor controller state including duty-cycle output voltage, stator/supply current,
rotor/mechanism position and velocity, and motor temperature to NetworkTables so that tools
such as SmartDashboard, Elastic, and Advantage Scope can consume the data in real time. Tunable
fields (PID gains, setpoints, motion-profile limits) are additionally exposed on a separate
Tuning table so they can be adjusted without redeploying code.
This class is managed internally by SmartMotorController. You do not normally
instantiate it directly; instead call the methods on the motor controller itself:
Basic usage (default NetworkTable path)
// In robotInit() or subsystem constructor:
motor.setupTelemetry(); // publishes under Mechanisms/<motorName>
// In robotPeriodic() or subsystemPeriodic():
motor.updateTelemetry();
Custom NetworkTable path and telemetry config
NetworkTable dataTable =
NetworkTableInstance.getDefault().getTable("Mechanisms").getSubTable("Shooter"); NetworkTable
tuningTable = NetworkTableInstance.getDefault().getTable("Tuning").getSubTable("Shooter");
motor.setupTelemetry(dataTable, tuningTable);
// In periodic:
motor.updateTelemetry();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumBoolean telemetry forSmartMotorControllersstatic enumDouble telemetry field. -
Constructor Summary
ConstructorsConstructorDescriptionCreate motor controller telemetry, publish it withsetupTelemetry(SmartMotorController, NetworkTable, NetworkTable, SmartMotorControllerTelemetryConfig). -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyTuningValues(SmartMotorController smartMotorController) Apply the tuning values fromNetworkTableto theSmartMotorControllervoidclose()Close and unpublish telemetry.voidPublishSmartMotorControllertelemetry toNetworkTablevoidsetupTelemetry(SmartMotorController smartMotorController, org.wpilib.networktables.NetworkTable publishTable, org.wpilib.networktables.NetworkTable tuningTable, SmartMotorControllerTelemetryConfig config) Setup Telemetry Pub/Sub fields.voidstopTuning(SmartMotorController smartMotorController) Stop live tuning, as when the "Live Tuning" command ends.booleanWhether or not tuning is enabled.
-
Constructor Details
-
SmartMotorControllerTelemetry
public SmartMotorControllerTelemetry()Create motor controller telemetry, publish it withsetupTelemetry(SmartMotorController, NetworkTable, NetworkTable, SmartMotorControllerTelemetryConfig).
-
-
Method Details
-
setupTelemetry
public void setupTelemetry(SmartMotorController smartMotorController, org.wpilib.networktables.NetworkTable publishTable, org.wpilib.networktables.NetworkTable tuningTable, SmartMotorControllerTelemetryConfig config) Setup Telemetry Pub/Sub fields.- Parameters:
smartMotorController-SmartMotorControllerused to determine what telemetry features can and should be disabled bc they are not available.publishTable-NetworkTablethat holds all of the output fields.tuningTable-NetworkTablethat holds all of the tuning fields.config-SmartMotorControllerTelemetryConfigto apply.
-
publish
PublishSmartMotorControllertelemetry toNetworkTable- Parameters:
smc- Smart motor controller to publish telemetry for.
-
applyTuningValues
Apply the tuning values fromNetworkTableto theSmartMotorController- Parameters:
smartMotorController-SmartMotorControllerto control.- Throws:
SmartMotorControllerConfigurationException- if the controller's control mode is notCLOSED_LOOP.SmartMotorControllerConfigurationException- if the underlying motor controller implementation rejects a tuned gain (for example, a gain applied while slot 3 is active on a TalonFX).SmartMotorControllerConfigurationException- if the underlying motor controller implementation rejects an unsupported vendor control request when applying a setpoint or slot.IllegalArgumentException- if the tuned closed loop controller slot is not supported by the underlying motor controller implementation (for example, slot 3 on a TalonFX or TalonFXS).
-
stopTuning
Stop live tuning, as when the "Live Tuning" command ends. A tuning voltage stops and the closed loop controller holds the setpoint again. The voltage is turned off in the Tuning table too, so it is not applied again as soon as live tuning starts again.- Parameters:
smartMotorController-SmartMotorControllerbeing tuned.
-
close
public void close()Close and unpublish telemetry. -
tuningEnabled
public boolean tuningEnabled()Whether or not tuning is enabled.
-