Class SwerveAlignment
CTRE's swerve telemetry only reports module angles after the magnet offset has been
applied, so there is no way to recover the number that belongs in
SwerveConfig.configEncoderOffsets(...) from a log or a dashboard. This class fills that gap: it
publishes each module's offset-applied position, the magnet offset actually programmed into the
device, and the difference between them, which is the "Absolute Position No Offset" value Phoenix
Tuner X shows.
The Swerve Align page of the robot app (src/main/deploy/app/pages/swerve-align)
subscribes to these keys over NetworkTables.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringNetworkTables/DogLog key prefix for everything this class publishes.static final String[]Module names, in the orderSwerveConfig.getModules()returns them. -
Constructor Summary
ConstructorsConstructorDescriptionSwerveAlignment(SwerveModule<?, ?, CANcoder>[] modules, SwerveConfig config) Creates the alignment publisher. -
Method Summary
Modifier and TypeMethodDescriptionvoidlog()Refreshes and publishes the alignment data.static doublewrapRotations(double rotations) Wraps a rotation count into[-0.5, 0.5), matching how CTRE reports CANcoder absolute position.
-
Field Details
-
KEY_PREFIX
NetworkTables/DogLog key prefix for everything this class publishes.- See Also:
-
MODULE_NAMES
Module names, in the orderSwerveConfig.getModules()returns them.
-
-
Constructor Details
-
SwerveAlignment
Creates the alignment publisher.Construct this after
optimizeBusUtilization()so the update frequencies it requests are not immediately thrown away.- Parameters:
modules- the drivetrain's modules, inSwerveConfig.getModules()orderconfig- the swerve config the modules were built from
-
-
Method Details
-
log
public void log()Refreshes and publishes the alignment data. Safe to call every robot loop.Only publishes while the robot is disabled. Alignment is a pit procedure done on blocks with the robot disabled. These are 32 keys at 20 Hz, about 77 records a second, going into a log that already overran DogLog's queue and dropped data during the 2026-09-05 17:10 session. There is nothing to learn from them while the robot is driving.
-
wrapRotations
public static double wrapRotations(double rotations) Wraps a rotation count into[-0.5, 0.5), matching how CTRE reports CANcoder absolute position.- Parameters:
rotations- the value to wrap- Returns:
- the equivalent value in
[-0.5, 0.5)
-