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

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenheroux committed Apr 2, 2024
2 parents 18b5db8 + c097e19 commit c15df18
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/frc/robot/swerve/Swerve.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardLayout;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.lib.Subsystem;
import frc.lib.Telemetry;
Expand Down Expand Up @@ -94,6 +95,8 @@ public void addToShuffleboard(ShuffleboardTab tab) {
"Setpoint Angle (deg)", () -> swerveModule.getSetpoint().angle.getDegrees());
swerveModuleColumn.addDouble(
"Setpoint Velocity (mps)", () -> swerveModule.getSetpoint().speedMetersPerSecond);

swerveModuleColumn.add(Commands.runOnce(swerveModule::syncSteerPosition).withName("Sync Steer"));
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/frc/robot/swerve/SwerveModuleIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
/** Swerve module hardware interface. */
public interface SwerveModuleIO {

/**
* Sets the steer motor's position to the azimuth encoder's position.
*/
public void syncSteerPosition();

/**
* Gets the state of the swerve module.
*
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/frc/robot/swerve/SwerveModuleIOCustom.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public SwerveModuleIOCustom(SwerveModuleConfig config) {

setpoint = new SwerveModuleState();

syncSteerPosition();
}

@Override
public void syncSteerPosition() {
azimuthEncoder.update(azimuthEncoderValues);
steerMotor.setPosition(azimuthEncoderValues.positionRotations);
}
Expand Down

0 comments on commit c15df18

Please sign in to comment.