DataLog best practices
Every YAMS telemetry field is published to NetworkTables by default. Separately, you can opt any field into a WPILib DataLog, the same file format read by AdvantageScope offline, and the one WPILib's DataLogManager automatically saves to a USB drive or the SystemCore's local storage during a match. This page covers how to control both destinations independently, and calls out the one place, SwerveDrive, where the rules are different.
The two knobs: NetworkTables and DataLog
For any single-motor mechanism (Arm, Elevator, Pivot, FlyWheel, DifferentialMechanism, DoubleJointedArm) telemetry is controlled per motor controller with SmartMotorControllerTelemetryConfig:
SmartMotorControllerTelemetryConfig telemetryConfig = new SmartMotorControllerTelemetryConfig()
.withTelemetryVerbosity(TelemetryVerbosity.LOW)
.withStatorCurrent()
.withTemperature()
.withDataLogName("motors/shooter") // log the fields above to DataLog...
.withoutNetworkTables(); // ...and don't publish them to NT4
SmartMotorControllerConfig motorConfig = new SmartMotorControllerConfig(this)
.withClosedLoopController(4, 0, 0)
.withGearing(new MechanismGearing(GearBox.fromReductionStages(3, 4)))
.withTelemetry("ShooterMotor", telemetryConfig);withDataLogName(name)turns on DataLog for every field enabled on that config, under the given prefix.withoutNetworkTables()(orwithNetworkTables(false)) stops those fields from being published to NT4 at all. You can freely enable DataLog, NetworkTables, both, or neither, they're independent toggles.Which fields get logged is controlled the same way for both destinations, there's only one set of enabled fields, per
withTelemetryVerbosity()and the individualwith*()methods described in Telemetry.
Choosing what to log
Every field is disabled by default. withTelemetryVerbosity() gives you a cumulative preset (LOW → MID → HIGH, each including everything below it) so you don't have to enable dozens of fields by hand, then layer on or remove individual fields as needed.
A few guidelines:
Don't just reach for
HIGHeverywhere.HIGHincludes PID gains, feedforward gains, current limits, and every boolean status flag, useful while tuning, but mostly redundant once a mechanism is dialed in. PreferLOWorMIDplus the handful of fields you actually watch (current, temperature, setpoint and position) for a competition build.Prune before you log, not after. DataLog files only grow, there's no way to selectively remove a field after the fact without re-recording. Decide what you need before the match, not while reviewing the log afterward.
DataLog is not a substitute for NetworkTables during development. Live tools (Elastic, Shuffleboard, AdvantageScope in live mode) read NT4, not DataLog. Keep NetworkTables on while you're actively tuning, and consider disabling it only for fields you truly don't need live, once you're locking in a competition build.
Need to flip a field that doesn't have its own with*() method, or toggle several fields at once? withCustom(field, value) takes any BooleanTelemetryField/DoubleTelemetryField (or an array of either) plus a boolean, and enables or disables them accordingly:
Enabling/disabling NetworkTables conditionally
withNetworkTables(boolean) takes a plain boolean, read once when the config is built, so drive it from a constant you set before you deploy:
This keeps full NT4 telemetry for pit testing and practice, and drops NT4 traffic (while still writing to DataLog) in the code you deploy for matches.
Swerve drive is different
SwerveDriveConfig.withTelemetry(name, TelemetryVerbosity) and SwerveModuleConfig.withTelemetry(name, TelemetryVerbosity) pick a verbosity preset the same way a single-motor mechanism does, both always take the telemetry name as the first argument, there's no name-less overload. For anything more, hand withTelemetry(name, ...) a SwerveDriveTelemetryConfig/SwerveModuleTelemetryConfig instead of a bare TelemetryVerbosity, that's what lets you enable individual fields, disable NetworkTables, or set a DataLog name for the drive-level and per-module fields (pose, gyro, chassis speeds, module states, absolute encoder angle).
You can still send this to DataLog:
new SwerveDriveTelemetryConfig(TelemetryVerbosity.HIGH)/new SwerveModuleTelemetryConfig(TelemetryVerbosity.HIGH) are shorthand constructors for new SwerveDriveTelemetryConfig().withTelemetryVerbosity(TelemetryVerbosity.HIGH) and the module equivalent. Each module's DataLog name is independent of the drive's SwerveDriveTelemetryConfig.withDataLogName(...) above, set it separately per module if you want per-module DataLog prefixes.
Getting granular fields out of a swerve module's motors
The drive and azimuth motors of a SwerveModule are still ordinary SmartMotorControllers under the hood. If you want field-level control (or a DataLog name) on just the drive motor or just the azimuth motor, set it on that motor's own SmartMotorControllerConfig, before you build the SwerveModule, exactly as you would for a standalone motor:
This gives you the same fine-grained control (and independent DataLog name) on that one motor that you'd get on any other mechanism's motor, it's only the swerve-level pose/gyro/chassis-speed/encoder fields that are all-or-nothing per verbosity level.
Related pages
Last updated
Was this helpful?
