Skip to content
This repository was archived by the owner on May 19, 2024. It is now read-only.

Commit c097e19

Browse files
committed
feat(swerve): Add button to manually sync swerve.
1 parent d8c3d21 commit c097e19

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

Diff for: src/main/java/frc/robot/swerve/Swerve.java

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout;
99
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
1010
import edu.wpi.first.wpilibj2.command.Command;
11+
import edu.wpi.first.wpilibj2.command.Commands;
1112
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
1213
import frc.lib.Subsystem;
1314
import frc.lib.Telemetry;
@@ -94,6 +95,8 @@ public void addToShuffleboard(ShuffleboardTab tab) {
9495
"Setpoint Angle (deg)", () -> swerveModule.getSetpoint().angle.getDegrees());
9596
swerveModuleColumn.addDouble(
9697
"Setpoint Velocity (mps)", () -> swerveModule.getSetpoint().speedMetersPerSecond);
98+
99+
swerveModuleColumn.add(Commands.runOnce(swerveModule::syncSteerPosition).withName("Sync Steer"));
97100
}
98101
}
99102

Diff for: src/main/java/frc/robot/swerve/SwerveModuleIO.java

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
/** Swerve module hardware interface. */
88
public interface SwerveModuleIO {
99

10+
/**
11+
* Sets the steer motor's position to the azimuth encoder's position.
12+
*/
13+
public void syncSteerPosition();
14+
1015
/**
1116
* Gets the state of the swerve module.
1217
*

Diff for: src/main/java/frc/robot/swerve/SwerveModuleIOCustom.java

+5
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ public SwerveModuleIOCustom(SwerveModuleConfig config) {
5252

5353
setpoint = new SwerveModuleState();
5454

55+
syncSteerPosition();
56+
}
57+
58+
@Override
59+
public void syncSteerPosition() {
5560
azimuthEncoder.update(azimuthEncoderValues);
5661
steerMotor.setPosition(azimuthEncoderValues.positionRotations);
5762
}

0 commit comments

Comments
 (0)